You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(guardrails): repeated leases for one ref are compared by literal spelling, blocking a safe push #1418
block-dangerous-git compares repeated --force-with-lease entries by their literal refname spelling. When one push spells the same destination two ways, the guard treats them as two refs and blocks on the second entry — which git never consults.
git push --force-with-lease=main:<full-sha> --force-with-lease=refs/heads/main:origin/main origin main
git matches a lease entry's refname against the ref actually being updated and returns on the first match, so the pinned main entry governs and the second is dead text. The guard blocks. Verified by the reviewer on git 2.43.0: git accepted the pinned-first ordering and rejected the reverse as stale info.
This is a false positive — a safe push refused, with an obvious workaround (spell both entries identically). It was left in place deliberately when #1275 landed, and the reasoning is recorded at the call site: git's DWIM matching depends on which refs the push actually updates, which is a function of the refspecs, the remote configuration, and push.default — none visible to a static argv guard. Folding two spellings into one is therefore an assumption, and when it is wrong the guard drops a live unsafe entry from the verdict and fails open, silently, on the exact class the guard exists to stop. Trading a visible false positive for a heuristic that can fail open was not worth it inside a PR that had already absorbed six rounds of review findings.
The narrower fix worth trying: key entries by their fully-qualified refs/heads/<name>only when the command itself qualifies them, leaving unqualified spellings compared literally. That never folds two refs the command did not itself declare equivalent, so it cannot introduce the fail-open case. It needs its own tests, including the ordering pair above in both directions and a case where two genuinely different refs are pushed together.
Origin: review thread PRRT_kwDOTCGFQM6Ty6Q7 on #1275 (merged as 767252b7f5), resolved as answered-not-implemented with this follow-up promised.
No linked issue: this is the tracked follow-up itself.
Classification:work-class: scoped, bug-fix-shaped — block-dangerous-git compares repeated --force-with-lease refname spellings literally, blocking a safe push; the fix is bounded (key entries by fully-qualified refname only when the command itself qualifies it) with tests already scoped in the issue body (the ordering-pair case in both directions, plus a distinct-refs case).
first_drain_complete is still false in durable loop state (issue #1248's pinned telemetry), so per the admission gate's first-drain ratification requirement this C3 bug-fix candidate queues rather than dispatches until ratified.
Intended dispatch (once ratified):/work-items:work — narrow the refname-folding heuristic in block-dangerous-git per the issue's proposed fix, add the tests the issue calls for, PR against the follow-up promised on review thread PRRT_kwDOTCGFQM6Ty6Q7 (#1275).
Outcome: NOT ratified. The first-drain C3 admission stays gated. needs-human remains; agent-ready was not added.
1. The defect is real and reproduces
Confirmed empirically by driving the hook directly (read-only; no files in the repo were modified), using the same black-box harness shape as plugins/guardrails/hooks/block-dangerous-git.test.sh:
Command
Exit
git push --force-with-lease=main:<40-hex> --force-with-lease=refs/heads/main:origin/main origin main
2 (BLOCKED)
git push --force-with-lease=main:<40-hex> --force-with-lease=main:origin/main origin main
0 (allowed)
git push --force-with-lease=main:<40-hex> origin main
0 (allowed)
Rows 1 and 2 are the same push differing only in how the second lease entry spells its refname, and they get opposite verdicts. That isolates the cause to spelling, exactly as reported.
Source of the behavior — plugins/guardrails/hooks/block-dangerous-git.sh:293-296:
lease_ref_claimed() {
local seen="$1" ref="$2"
[[ $'\n'"$seen"==*$'\n'"$ref"$'\n'* ]]
}
Literal substring match, called once, at block-dangerous-git.sh:619.
But it is not an oversight. The rationale is recorded directly above it at block-dangerous-git.sh:284-291: literal matching is "the conservative reading of git's refname_match()", keeping two spellings distinct "so an unsafe later entry is still counted rather than silently dropped."
2. Panel
Three seats, prior triage rationale and the work-class label withheld from both external seats; each was given the issue title and body only, and required to ground itself in the actual code.
Seat
Class
(a) security-surface
(e) human call
Autonomous PR?
Confidence
Fresh Claude reviewer
C4
YES
YES (qualified)
NO
high
OpenAI Codex (alternate vendor)
C4
YES
NO
NO
high
This agent's own read
C3 by footprint
YES
YES (leaning)
NO
high
Unanimous on the two things that decide admission: (a) is YES and autonomous-PR-without-prior-approval is NO. All three agree (b) dependency-pin = NO, (c) cross-cutting = NO, (d) diff hard-to-reverse = NO.
3. Why it stays gated
The admission bar is conjunctive: C2/C3 and not security-surface and not dependency-pin and not cross-cutting and not hard-to-reverse and not a human call. (a) fails it. The small diff footprint does not rescue it — what changes is which lease entries the guard may treat as dead text, in the permissive direction, inside the guard that exists to stop remote-clobbering force-pushes.
The fresh-Claude seat added the finding that decides this, and it is worth recording:
git's refname_match() walks ref_rev_parse_rules (%s, refs/%s, refs/tags/%s, refs/heads/%s, refs/remotes/%s, …), so the ref sets are nested, not symmetric. main matches refs/heads/mainandrefs/tags/main; refs/heads/main matches only itself.
Folding is therefore safe in one direction only: an earlier unqualified entry provably dominates a later qualified one. The reverse fold is the fail-open.
The fix proposed in the issue body — key by refs/heads/<name> when the command qualifies it — is underspecified about direction. Implemented as a normalization key rather than a directional dominance predicate, it produces the unsafe fold.
Decisively: the existing suite has no tag/DWIM case, so the unsafe implementation would pass CI green. An agent writing both the fix and its tests from the same assumption would see validation that is not there. Producer = tester is the exact failure this gate exists to catch.
Note also that the reported false positive is on the safe side of the asymmetry, and its workaround is one keystroke-level change (spell both entries identically). This is priority: low. The cost of leaving it gated is near zero; the cost of a wrong fix is a clobbered branch.
Decision needed from a human
Option 1 — Approve the approach first, then dispatch (RECOMMENDED).
Human signs off on the rule — specifically, that the fix is a directional dominance predicate (earlier-unqualified dominates later-qualified; never the reverse), not a symmetric normalization key. Once that sentence is approved in writing on this issue, the implementation itself is genuinely bounded and an agent can carry it, because the ambiguity that made it unsafe is gone. Acceptance criteria to attach: both orderings of the mixed-spelling pair; a simultaneous refs/tags/main + refs/heads/main push that must stay blocked (the fail-open regression test, which does not exist today); the mid-form heads/main; and two genuinely distinct refs. Per this repo's fresh-docs mandate, the git-side semantics must be cited from a fetched primary source, not recall. Why recommended: it converts a risk-tolerance judgment into a stated engineering constraint, which is the one thing a panel cannot supply for itself, and it costs one human sentence.
Option 2 — Have an agent produce the approach proposal only, no code.
Unattended agent writes up the dominance predicate and the test matrix as a comment for sign-off; a human approves; implementation follows later. Slower, and mostly re-derives what this audit already recorded above.
Option 3 — Close as won't-fix.
The literal comparison was a deliberate, recorded decision; the false positive is low-priority with a trivial workaround; the guard stays maximally fail-closed. Legitimate, but discards a real (if minor) defect and the follow-up promised on review thread PRRT_kwDOTCGFQM6Ty6Q7.
Option 4 — Ratify as-is for autonomous execution.
Not supported by this audit. Recorded only for completeness; 3 of 3 seats advised against it at high confidence.
Activity
kyle-sexton commentedon Jul 25, 2026
This was generated by AI during triage.
Classification:
work-class: scoped, bug-fix-shaped —block-dangerous-gitcompares repeated--force-with-leaserefname spellings literally, blocking a safe push; the fix is bounded (key entries by fully-qualified refname only when the command itself qualifies it) with tests already scoped in the issue body (the ordering-pair case in both directions, plus a distinct-refs case).first_drain_completeis stillfalsein durable loop state (issue #1248's pinned telemetry), so per the admission gate's first-drain ratification requirement this C3 bug-fix candidate queues rather than dispatches until ratified.Intended dispatch (once ratified):
/work-items:work— narrow the refname-folding heuristic inblock-dangerous-gitper the issue's proposed fix, add the tests the issue calls for, PR against the follow-up promised on review threadPRRT_kwDOTCGFQM6Ty6Q7(#1275).kyle-sexton commentedon Jul 29, 2026
This claim was posted by an AI agent (triage lane). Gate-audit in progress on the pending C3 first-drain ratification.
kyle-sexton commentedon Jul 29, 2026
This was generated by AI during a gate audit. No labels were changed.
Gate audit: stays
needs-human— 3-of-3 panel says the approach needs human sign-off firstThis is a reply to the
kind=ratify-c3marker comment on this issue:— #1418 (comment)
Outcome: NOT ratified. The first-drain C3 admission stays gated.
needs-humanremains;agent-readywas not added.1. The defect is real and reproduces
Confirmed empirically by driving the hook directly (read-only; no files in the repo were modified), using the same black-box harness shape as
plugins/guardrails/hooks/block-dangerous-git.test.sh:git push --force-with-lease=main:<40-hex> --force-with-lease=refs/heads/main:origin/main origin maingit push --force-with-lease=main:<40-hex> --force-with-lease=main:origin/main origin maingit push --force-with-lease=main:<40-hex> origin mainRows 1 and 2 are the same push differing only in how the second lease entry spells its refname, and they get opposite verdicts. That isolates the cause to spelling, exactly as reported.
Source of the behavior —
plugins/guardrails/hooks/block-dangerous-git.sh:293-296:Literal substring match, called once, at
block-dangerous-git.sh:619.But it is not an oversight. The rationale is recorded directly above it at
block-dangerous-git.sh:284-291: literal matching is "the conservative reading of git'srefname_match()", keeping two spellings distinct "so an unsafe later entry is still counted rather than silently dropped."2. Panel
Three seats, prior triage rationale and the work-class label withheld from both external seats; each was given the issue title and body only, and required to ground itself in the actual code.
Unanimous on the two things that decide admission: (a) is YES and autonomous-PR-without-prior-approval is NO. All three agree (b) dependency-pin = NO, (c) cross-cutting = NO, (d) diff hard-to-reverse = NO.
3. Why it stays gated
The admission bar is conjunctive: C2/C3 and not security-surface and not dependency-pin and not cross-cutting and not hard-to-reverse and not a human call. (a) fails it. The small diff footprint does not rescue it — what changes is which lease entries the guard may treat as dead text, in the permissive direction, inside the guard that exists to stop remote-clobbering force-pushes.
The fresh-Claude seat added the finding that decides this, and it is worth recording:
refname_match()walksref_rev_parse_rules(%s,refs/%s,refs/tags/%s,refs/heads/%s,refs/remotes/%s, …), so the ref sets are nested, not symmetric.mainmatchesrefs/heads/mainandrefs/tags/main;refs/heads/mainmatches only itself.refs/heads/<name>when the command qualifies it — is underspecified about direction. Implemented as a normalization key rather than a directional dominance predicate, it produces the unsafe fold.Note also that the reported false positive is on the safe side of the asymmetry, and its workaround is one keystroke-level change (spell both entries identically). This is
priority: low. The cost of leaving it gated is near zero; the cost of a wrong fix is a clobbered branch.Decision needed from a human
Option 1 — Approve the approach first, then dispatch (RECOMMENDED).
Human signs off on the rule — specifically, that the fix is a directional dominance predicate (earlier-unqualified dominates later-qualified; never the reverse), not a symmetric normalization key. Once that sentence is approved in writing on this issue, the implementation itself is genuinely bounded and an agent can carry it, because the ambiguity that made it unsafe is gone. Acceptance criteria to attach: both orderings of the mixed-spelling pair; a simultaneous
refs/tags/main+refs/heads/mainpush that must stay blocked (the fail-open regression test, which does not exist today); the mid-formheads/main; and two genuinely distinct refs. Per this repo's fresh-docs mandate, the git-side semantics must be cited from a fetched primary source, not recall.Why recommended: it converts a risk-tolerance judgment into a stated engineering constraint, which is the one thing a panel cannot supply for itself, and it costs one human sentence.
Option 2 — Have an agent produce the approach proposal only, no code.
Unattended agent writes up the dominance predicate and the test matrix as a comment for sign-off; a human approves; implementation follows later. Slower, and mostly re-derives what this audit already recorded above.
Option 3 — Close as won't-fix.
The literal comparison was a deliberate, recorded decision; the false positive is low-priority with a trivial workaround; the guard stays maximally fail-closed. Legitimate, but discards a real (if minor) defect and the follow-up promised on review thread
PRRT_kwDOTCGFQM6Ty6Q7.Option 4 — Ratify as-is for autonomous execution.
Not supported by this audit. Recorded only for completeness; 3 of 3 seats advised against it at high confidence.
kyle-sexton commentedon Jul 29, 2026
AI-generated: triage lane claim released. Gate audit complete — item remains
needs-human; no labels were changed.fix(guardrails): treat qualified and short lease refnames as equivalent