[DEV-82] Add built-in docs drift guard automation preset - #94
Open
danii1 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 —
executeGitCommandtrims output, soslice(3)mangles the path. Fixing the porcelain parsing:The bug is
Utils.executeGitCommandtrims the whole output, stripping the first line's leading status column. RewritingworkingTreePathswith 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 (PresetDefinitionwith output modes, option validation, prerequisite checks, and aruncontract). 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-guardpreset (automations/docs-drift-guard/)definition.ts— name/version,ticket(default) andpull_requestmodes,doc_paths/baseline_shaoption validation.paths.ts— default doc set (docs/**, nestedAGENTS.md/CLAUDE.md,README*) with safe glob overrides.checkpoint-store.ts— per-repo/per-automation SHA inqueue.db; advances only after clean outcomes (validno_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 distinguishingno_drift/findings/inconclusive; invalid or inconclusive output fails the run and preserves the checkpoint; deterministic dedupe keys.run.ts— orchestrator: default-branch resolution viaUtils.getMainBranchName, first-run bounded baseline (or explicitbaseline_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, andUtilsgit plumbing.Integration
automation-config.ts—preset/output_mode/doc_paths/baseline_shaparsing 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— normalizedIssueCreatableClientcapability implemented on the GitHub and GitLab clients, flagged intracker-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.mdguide plus updates toworker.md,workspaces.md, andUSAGE.md.This PR was automatically created by @devintern/code