Repository navigation
fix(agents): scope the drift check to the generated blocks, not whole files - #271
Merged
Merged
Conversation
… files
`git diff --quiet HEAD -- "${generated_files[@]}"` was right while every target
was a generated-only reference. It stopped being right in #255, when CLAUDE.md
and docs/agent-skills.md joined that array: both are mostly hand-written prose,
so ANY in-progress edit to either — a sentence in the authoring rules, a line in
the gate table — failed with "generated skill references are stale" while every
GENERATED block was byte-identical to HEAD.
That is the false-positive mirror of the rule this repo already keeps about
false greens, and it is worse than it sounds: the failure names the right file
with the wrong reason, so the obvious response is to re-run the generator, which
changes nothing, and the next response is to stop believing the gate.
The check now extracts the BEGIN/END blocks from HEAD and from the worktree and
compares only those. Still HEAD-relative, so a `git add` cannot launder a stale
file. A deleted block is still caught, because the markers are included in the
extraction. The failure output is now a real unified diff of the block, labelled
HEAD/ vs regenerated/, instead of a `126 ++---` stat line.
One subtlety worth writing down, because testing it wrong is easy: `check` runs
regen BEFORE it diffs, so hand-editing a block proves nothing — the edit is
overwritten and the gate passes. What it detects is a SOURCE change that makes
committed output wrong. Verified against both: a new `resource "aws_sns_topic"`
surfaced as `+ 1 aws_sns_topic` in footprint.md, and removing the campaigns
screen from the axe gate's SCREENS moved it from swept to unswept in
screens.md. Prose edits to CLAUDE.md and docs/agent-skills.md now pass.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
athvin
added a commit
that referenced
this pull request
Oct 22, 2026
…top it passing silently (#279) Two defects, the second of my own making an hour ago. ## The drift check did not run on the PRs that change skills `detect` skips every compile job for a PR touching nothing but `.claude/**`, and the drift check rode the cargo `lint` job — so it did not run on exactly those PRs. That was sound while every generator derived from code OUTSIDE `.claude/`, because a code change always ran the full gate. `gen_skill_inventory` broke it. It derives from SKILL.md descriptions, so a one-line description edit makes the inventory tables in docs/agent-skills.md and CLAUDE.md stale. Demonstrated: changing landing-page's first clause to "the PROBE route group" leaves both tables stale, and a PR carrying only that change reports three green checks, none of which looks at staleness. It merges green and turns main red on the push-to-main run. The `skills` job now runs `all` rather than `lint`. It still needs no toolchain — verified by running the whole script in a bare ubuntu container with no cargo, node, pnpm, docker, terraform or aws. The check stays in the cargo job as well, because `skills` is not a required status check and so cannot block a merge on its own; promoting it would make the pair redundant, and both halves have now been observed failing. The job is renamed to `agent skills (lint + drift)`, which is safe because it is not among the eight required contexts. ## The drift check passed silently when git was unavailable Introduced in #271. The per-file comparison skips anything it cannot read out of HEAD (`git cat-file -e … || continue`), which is right for a newly added file — but outside a git repository EVERY file is skipped, the stale list comes back empty, and the check reports "generated references are current" and exits 0 having compared nothing. That is the failure this repo keeps a rule about: success and never-ran are indistinguishable from outside. Two guards now, mirroring `lint`'s zero-skills exit and check-bff-authz.mjs's zero-routes exit — HEAD must resolve, and the comparison must have examined at least one file. Verified: outside a repo the check now exits 1 with a named reason. Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
3 tasks
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.
A false positive I introduced in #255, found by a parallel session hitting it.
The defect
git diff --quiet HEAD -- "${generated_files[@]}"was correct while every target was a generated-only reference. #255 addedCLAUDE.mdanddocs/agent-skills.mdto that array so the inventory tables could stop being hand-maintained — but both files are mostly prose, so any in-progress edit to either failed the gate with "generated skill references are stale" while every GENERATED block was byte-identical toHEAD.It is the false-positive mirror of the false-green rule this repo already keeps, and it degrades badly: the failure names the right file with the wrong reason, so the obvious response is to re-run the generator, which changes nothing, and the response after that is to stop believing the gate.
The fix
Extract the
BEGIN/ENDblocks fromHEADand from the worktree; compare only those.HEAD-relative, so agit addcannot launder a stale file.HEAD/…vsregenerated/…) rather than a126 ++---stat line.One subtlety, now written into the standard
checkruns regen before it diffs, so hand-editing a block proves nothing — the edit is overwritten and the gate passes. What it detects is a source change that makes committed output wrong. Testing it the other way shows a passing gate and proves nothing, which is how I nearly convinced myself this fix had broken the gate.Verified both directions
CLAUDE.md/docs/agent-skills.mdresource "aws_sns_topic"in a.tf+ 1 aws_sns_topic🤖 Generated with Claude Code