Skip to content

[DEV-82] Add built-in docs drift guard automation preset - #94

Open
danii1 wants to merge 3 commits into
mainfrom
feature/dev-82
Open

[DEV-82] Add built-in docs drift guard automation preset#94
danii1 wants to merge 3 commits into
mainfrom
feature/dev-82

Conversation

@danii1

@danii1 danii1 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Task: DEV-82

Summary: Add built-in docs drift guard automation preset

Implementation Details

Let me explore the key infrastructure files I'll need to integrate with.
Now I have a full picture. Let me set up the plan and check a few last details on the Jira client.
Now I'll implement. Starting with the generic preset registry:
Now the structured-output schema validation:
Now the diff-context collector with the git port:
Now the diff-context builder:
Now the tracker and PR ports:
Now the main orchestrator:
Now the preset definition, and the built-in registration module:
Now the presets registration barrel and the config parser extension:
Now add the default preset spawn runner to the acquirer:
Typecheck passes. Let me run the existing automation-related tests, then write tests for the new functionality:
Existing tests pass. Now let me write the test suite. First a git fixture helper:
Now the diff-context test with a fake git port:
Now the tracker-client issue-creation tests:
The rewritten-history test has a test-logic bug (baseline was the initial commit, still an ancestor). Let me fix that and debug the PR apply issue:
Found it — executeGitCommand trims output, so slice(3) mangles the path. Fixing the porcelain parsing:
The bug is Utils.executeGitCommand trims the whole output, stripping the first line's leading status column. Rewriting workingTreePaths with path-only plumbing:
The run works — my test queried HEAD on main after branch restore instead of the drift branch:
All passing. Now the full package test suite:
All tests pass. Let me add an acquirer-dispatch test for the preset path, then check lint/format:
The automation isn't due yet (next occurrence is tomorrow). Pre-seed the schedule cursor to make it due immediately:
Now let me write the documentation. First the dedicated guide:
Now update worker.md and workspaces.md to reference the preset:
A few robustness fixes: close the created RunStore, and fix a stale interface comment:
Let me do a final review of the complete change set:
One robustness fix — a failed branch restore must not mask the original failure:
DEV-82 is implemented. All 1056 tests pass, typecheck and lint are clean, and the package builds.

What was built

Generic preset framework (packages/code/src/lib/automations/)

  • preset-registry.ts — versioned, data-driven registry (PresetDefinition with output modes, option validation, prerequisite checks, and a run contract). Adding a preset never touches scheduler control flow; this is proven by a test registering a second preset through the real acquirer.
  • presets.ts — registers built-ins on import.

docs-drift-guard preset (automations/docs-drift-guard/)

  • definition.ts — name/version, ticket (default) and pull_request modes, doc_paths/baseline_sha option validation.
  • paths.ts — default doc set (docs/**, nested AGENTS.md/CLAUDE.md, README*) with safe glob overrides.
  • checkpoint-store.ts — per-repo/per-automation SHA in queue.db; advances only after clean outcomes (valid no_drift, no behavior changes, or successful publication).
  • diff-context.ts — deterministic checkpoint..head range: ignored/binary/deleted/oversized files handled with visible truncation flags; docs-only ranges skip the agent entirely.
  • result.ts — structured-output validation distinguishing no_drift / findings / inconclusive; invalid or inconclusive output fails the run and preserves the checkpoint; deterministic dedupe keys.
  • run.ts — orchestrator: default-branch resolution via Utils.getMainBranchName, first-run bounded baseline (or explicit baseline_sha), rewritten-history and shallow-clone guards, ticket publication with marker-based dedup, PR publication with docs-only staging, branch restore, and PR reuse (reset + force-push + body update instead of duplicates). Run records capture preset version, range, findings, and created ticket/PR refs.
  • ports.ts / agent-port.ts / git-port.ts — injectable tracker/PR/agent/git ports; defaults reuse the existing harness selection, sandbox, GitHub App/token auth, and Utils git plumbing.

Integration

  • automation-config.tspreset/output_mode/doc_paths/baseline_sha parsing with actionable errors (unknown preset, unsupported mode, bad paths, prompt/preset mixing).
  • automation-acquirer.ts — preset automations dispatch through the registry in-process (makeDefaultPresetSpawnRun) with cooperative abort; scheduling, leases, licensing, and run attribution unchanged.
  • TaskTrackerClient — normalized IssueCreatableClient capability implemented on the GitHub and GitLab clients, flagged in tracker-capabilities.ts.

Tests (7 new files, 44+ cases) cover registry resolution, config validation, path selection, structured output, checkpoints, diff filtering, dedup, both output modes, and end-to-end runs in isolated temp git repos with mocked tracker/PR/agent clients.

Docs — new docs/code/docs-drift-guard.md guide plus updates to worker.md, workspaces.md, and USAGE.md.


This PR was automatically created by @devintern/code

@danii1 danii1 added experiments devintern-authored Pull request written by DevIntern working its own backlog labels Aug 28, 2026
# Conflicts:
#	packages/code/src/lib/automation-config.ts
@danii1

danii1 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

🔀 This branch had merge conflicts with main; devintern resolved them and pushed the merge. Please double-check the resolution.

# Conflicts:
#	docs/code/workspaces.md
#	packages/code/src/lib/automation-config.ts
@danii1

danii1 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

🔀 This branch had merge conflicts with main; devintern resolved them and pushed the merge. Please double-check the resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devintern-authored Pull request written by DevIntern working its own backlog experiments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant