Repository navigation
Description
skill-reference-verify locates partial-Edit context by word token, and its header comment claims that anchor holds the diff-scope contract. It does not. The same claim was made by stale-path-verify until 65b4f67c on #1432 replaced token-anchoring with line-anchoring and proved the gap with a regression case. This issue is what is left after that fix: the sibling guards that still carry the loose anchor.
The gap
An Edit can replace a bare substring inside an existing citation — swapping setup for ghost inside /alpha:setup leaves /alpha:ghost on disk — and the hunk then carries no complete citation for the direct scan. Reconstruction recovers bounded on-disk context:
mapfile -t toks < <(printf '%s' "$residue" | grep -oE '[a-z][a-z0-9-]{3,}' | sort -u)
for tok in "${toks[@]}"; do
lines=$(grep -F -- "$tok" "$FILE" 2>/dev/null)
...A 4-character token is short enough to occur on lines the edit never touched. A hunk of unrelated prose containing such a token greps back every line carrying it, and a pre-existing broken reference among them passes the later substring filter and fires — from an edit that did not touch it. The guard's own stated contract, violated by the mechanism meant to preserve it.
The fix that already exists
stale-path-verify now anchors on the hunk's own lines: every line of new_string is on disk verbatim by PostToolUse time, so grepping the hunk's lines always retains the line the edit landed in and selects a strict subset of what token-anchoring returned. The token filter survives as a second gate on the reported candidate rather than as the locator. Porting that shape is the work here, adjusted to each guard's reference syntax.
Per-guard scope
skill-reference-verify— the real target. Identical mechanism, identical 4-char word-token floor, identical overstated claim in its header comment ("a pre-existing unrelated reference sharing one of those lines never fires").cli-flag-verify— lesser, and already honest. It anchors on flag tokens (--force-with-lease), which are far more specific than a bare word, and its comment already states the residual accurately: "a hunk flag that also occurs on an untouched line is scanned there too; only a DIFFERENT pre-existing flag is excluded." Worth converting for uniformity onceskill-reference-verifylands, not worth its own risk budget first.
Acceptance
skill-reference-verifylocates context by the hunk's lines, with the token filter demoted to a candidate gate.- A behavioral test in the false-positive direction: an Edit to unrelated prose whose word token also occurs in an untouched broken reference elsewhere in the file must not fire — verified to fail against the pre-fix guard, as feat(guardrails): rescope the withdrawn path guard onto a provenance gate #1432's cases were.
- Existing partial-replacement true-positive cases keep passing.
- The header comment states what the anchor guarantees rather than overstating it.
Related
- feat(guardrails): rescope the withdrawn path guard onto a provenance gate #1432 — fixed this in
stale-path-verify(65b4f67c) and carries the regression case to model - guardrails: add a claim-verification guard (plugin-skill reference) #1270 — the claim-verification guard issue the reconstruction pattern originates from
Activity
kyle-sexton commentedon Jul 26, 2026
Scope correction — #1432 moved under this issue while it was being written.
Commit
65b4f67con that PR fixed the anchor instale-path-verify: reconstruction now locates lines by the hunk's own lines (every line ofnew_stringis on disk verbatim byPostToolUsetime, so line-anchoring selects a strict subset of what token-anchoring did and always retains the edited line), with the token filter demoted to a second gate on the reported candidate. A regression case covers the exact shape described above — a prose hunk sharing only a path segment with an untouched stale citation elsewhere in the file.So this issue is now about the two siblings that still carry the loose token anchor:
skill-reference-verifyandcli-flag-verify. The "candidate directions" section is superseded by a better answer than either option it lists — portstale-path-verify's line-anchoring, adjusted to each guard's own reference shape. The reuse-or-replace argument now runs the other way:stale-path-verifyis the divergent one until the siblings follow.[-]guardrails: partial-Edit reconstruction narrows diff-scope but does not close it, in all three guards[/-][+]guardrails: skill-reference-verify's partial-Edit anchor still breaks diff-scope (stale-path-verify is fixed)[/+]kyle-sexton commentedon Jul 26, 2026
This was generated by AI during triage.
Verification: Confirmed against
skill-reference-verifyas currently shipped onmain: the token floor is exactlygrep -oE '[a-z][a-z0-9-]{3,}'(4-char minimum), and the header comment reads "the anchor is the token, not the line" / "a pre-existing unrelated reference sharing one of those lines never fires" — the overstated guarantee this issue describes. Also confirmedcli-flag-verify's comment already states its narrower, honest residual ("only a DIFFERENT pre-existing flag is excluded"), matching this issue's framing of it as "lesser, and already honest" and explicitly out of scope here. Confirmed via this issue's own follow-up comment that its scope is corrected to the two siblings that still carry the loose token anchor — this is not a duplicate ofstale-path-verify's own (already-fixed, still-unmerged-to-main) issue.Not a duplicate of #1455. #1455 is a false negative in
stale-path-verify(reconstruction refuses to run below a 4-char token). This issue is a false positive in a different, already-shipped guard (skill-reference-verify's token-anchor pulls in untouched lines). Different guards, different failure directions, different fixes — correctly tracked as separate items.Classification: Bug.
priority: medium.Routing: delegable -> autonomous-eligible. Unlike its three siblings, this issue has a proven reference pattern to port (line-anchoring, already shipped for an equivalent problem in a sibling guard in this plugin) and a single, concretely scoped target (
skill-reference-verifyonly —cli-flag-verifyis explicitly out of scope per the issue body). The pattern itself is fully specified in this issue's body, so implementing it does not require the sibling guard's own PR to merge first. No open design fork remains.Agent Brief
Type: Bug
Summary:
skill-reference-verify's partial-Edit reconstruction anchors on a word-token substring search across the whole file, which can select lines the triggering edit never touched — violating the guard's own stated diff-scope contract.Current behavior:
When an
Editreplaces a bare substring inside an existing skill-reference citation, the direct scan on the hunk's own text finds no complete citation, so the guard falls back to reconstruction: it extracts word tokens of at least 4 characters from the edited region, greps the whole file for any line containing one of those tokens, and adjudicates every returned line as if the edit had touched it. A 4-character token is short enough to occur on unrelated lines, so an edit to ordinary prose can pull in a pre-existing, already-broken reference elsewhere in the file and report it as a finding for an edit that never touched that line. The guard's header comment currently overstates what this anchor guarantees ("a pre-existing unrelated reference sharing one of those lines never fires").Desired behavior:
Reconstruction locates on-disk context using the lines of the edit's own replacement text (every such line is present verbatim in the file by the time this guard runs), not by token search across the whole file. Line-based anchoring is a strict subset of what token search returns: it always retains the line the edit actually landed on, and it never pulls in an untouched line just because that line happens to share a token. The existing word-token check survives as a secondary filter applied to a candidate the line-anchor already found, not as the primary locator. This pattern — anchor on the hunk's own lines first, treat the token as a second gate rather than the locator — is already proven and shipped for an equivalent partial-Edit reconstruction problem in
stale-path-verify, a sibling guard in this same plugin; port its shape, adjusted to this guard's own reference syntax (e.g./plugin:skill-style citations rather than filesystem paths).Key interfaces:
skill-reference-verify's hook script — its locator changes from "grep the whole file by token" to "grep the hunk's own lines, then apply the token as a secondary filter on what that returns."Acceptance criteria:
Editto unrelated prose whose word token also occurs in an untouched, already-broken reference elsewhere in the same file produces NO finding. Confirm this case fails against the current (pre-fix) guard before landing the fix, mirroring how the equivalent regression case was proven forstale-path-verify.skill-reference-verifycontinue to pass unchanged.Out of scope:
cli-flag-verify— has a related but narrower anchor already, explicitly deferred by this issue to a follow-up once this fix lands; do not touch it here.kyle-sexton commentedon Jul 26, 2026
kyle-sexton commentedon Jul 26, 2026
This was generated by AI during work-loop execution.
Claimed and executed autonomously (work-loop, admission gate already passed). Fix implemented in PR #1466:
skill-reference-verify's partial-Edit reconstruction now anchors on the hunk's own lines (mirroringstale-path-verify's #1432/65b4f67c fix), with the token filter demoted to a second gate on the candidate. A regression test proves the false-positive direction, verified to fail against the pre-fix guard. Scope stayed bounded toskill-reference-verifyonly — the human-gated siblings (#1446/#1452/#1455) were not touched.docs(guardrails): hedge skill-reference-verify's line-anchor comment …
Merge origin/main into fix/964-alias-chain-reexpansion (version compo…
Merge remote-tracking branch 'origin/main' into feat/security-hardeni…