Repository navigation
fix(hooks): fail closed on LATE STAGING — close the empty-index bypass - #43
Conversation
The immediate-next cutover promised by CHANGELOG/2026.190.1751.md. The PreToolUse hook fires ONCE per Bash call, BEFORE the command runs. So anything that stages content DURING the command -- a `git add` in the same command, or `git commit -a` / -i / -o -- stages it AFTER the gate read the index. The two diff-dependent checks then judge a stale, usually EMPTY diff and wave the commit through, defeating both: the `documentation reviewed` tier-vs-diff coherence check, and the runtime-tier CHANGELOG/<YYYY.DDD.HHMM>.md requirement. Not theoretical: commit c5fb02f landed at a runtime tier with NO CHANGELOG entry by exactly this route (`git add ... && git commit ...` in one Bash call). Measured against origin/main's gate BEFORE the fix -- every one ALLOWED: compound `add && commit`, docs tier -> ALLOW compound `add && commit`, runtime tier -> ALLOW `git commit -a`, docs tier -> ALLOW `git commit --all`, runtime tier -> ALLOW bundled `-am`, docs tier -> ALLOW `-o pathspec`, docs tier -> ALLOW `git stage` in same command -> ALLOW All seven BLOCK on this branch. The fix -- fail closed, no fallback. The gate cannot see the future index, so it refuses to judge. When a diff-dependent tier is declared AND the command stages late, block with the remedy: stage in a separate Bash call first (`git add -u`, then `git commit`). - scan_commit_args also returns stages_late for -a/--all, -i/--include, -o/--only, short bundles included (-am). The existing "stop at the first m/F" rule keeps `-ma` correct: there the 'a' is the message value, not --all. - A `git add`/`git stage` invocation anywhere in the same command, via the shared gitcmd.git_invocations. A mention inside a quoted message is one token, never an invocation, so it cannot false-trigger. Scope stays narrow: the block fires only when a tier that READS the diff is present. A -F-file message parses no inline tier, so the diff checks never run and -a is moot there -- unchanged from main, and still the pr-validator's job. This sits beside the existing unresolvable-`-C` guard as the second member of one class: the gate cannot inspect the real diff, so it does not pretend to. In-tree coverage: gate_test.py, 53 cases, all pass. Eleven new -- the seven bypasses (each ALLOW on origin/main, BLOCK here: they fail without this fix), plus four boundary pins: an attached -m'a...' is not --all; a bare `git add` with no commit is allowed; -a with a -F file (no inline tier) is allowed; a literal `git add` inside a quoted message is allowed. Assisted-by: Claude (fully tested and validated)
pr-validator — APPROVED ✅Change class: hook/workflow scripts ( Checklist
Independent verification I ran
Decision — APPROVEDThe fix does exactly what its body enumerates, correctly, with no regression, at a justified tier, with in-tree coverage that fails without it. It is a monotonic strengthening of a discipline backstop. Non-blocking residual (author's option for a future cutover, NOT required to land this): the fix seals the staging-verb vectors ( Finalizing the merge-time CalVer, squash-merging, and tagging now. Assisted-by: Claude (analysed on a live system) |
…t gate late-staging fail-closed) Assisted-by: Claude (fully tested and validated)
Merge-time finalize (pr-validator V-P15b): reconcile the plugins gitlink to the merged #43 main (a309283, docs-only R5 sweep) per B6, and stamp the merge-time CalVer (CHANGELOG/2026.194.0751.md -> 2026.194.1124.md, H1 rewritten). Assisted-by: Claude (fully tested and validated) Claude-Session: https://claude.ai/code/session_01Fgfbn9VHa9o4ouPHtJo3eR
… (candy/plugin-box) (#89) P15 — the build-mode charly box verb HANDLERS (generate/validate/new/pkg) move out of charly core into a new COMPILED-IN command plugin candy/plugin-box, nested under the shared box grammar group via the generic NestedCommandProvider mechanism. Core BoxCmd stays the dispatch spine (build/merge/labels/feature/inspect/list + the authoring verbs). Plus a validate.go dead-stub sweep (validateBaseReferences/validateDNS deleted, validateLibvirt cleaned). Seams (no new capability, no duplication): generate → InvokeProvider(build:generate); new → sdk/kit scaffold engine directly; validate/pkg → HostBuild("cli") to hidden K1-doomed core __box-validate/__box-pkg. inspect/list retained (K1). Retained core surfaces each carry a tracked K-wave exit (K1/#46/#47). Advances the v2 plugin-host core direction. Validated by fresh pr-validator V-P15b: R10 check-commands-local PASS (box-new-validate-generate + box-pkg-dispatches exit=0, corroborated on disk); go build/test/vet/gofmt/golangci-lint(0)/cue:gen-repro all green (re-run); boundary-law clean; plugins gitlink reconciled to merged #43 main. Assisted-by: Claude (fully tested and validated)
Summary
The immediate-next cutover promised by
CHANGELOG/2026.190.1751.md(PR #41), opened the moment that one landed — per R2, not deferred.Change class: hook scripts (
.claude/hooks/pre-commit-gate.sh,gate_test.py) + CHANGELOG. Gate: execute the changed scripts live. Tier:fully tested and validated.The bypass
The
PreToolUsehook fires once per Bash call, BEFORE the command runs. So anything that stages content during the command — agit addin the same command, orgit commit -a/-i/-o— stages it after the gate read the index. The two diff-dependent checks then judge a stale, usually EMPTY diff and wave the commit through, defeating both:documentation reviewedtier-vs-diff coherence check, andCHANGELOG/<YYYY.DDD.HHMM>.mdrequirement.Not theoretical. Commit
c5fb02fon this repo landed at a runtime tier with no CHANGELOG entry by exactly this route (git add … && git commit …in one Bash call).Check coverage — the new cases fail without the fix
Measured against
origin/main's gate (pre-fix) and this branch's gate (post-fix):The fix — fail closed, no fallback
The gate cannot see the future index, so it refuses to judge. When a diff-dependent tier is declared AND the command stages late, it blocks with the remedy: stage in a separate Bash call first (
git add -u, thengit commit). Detection is one predicate from two sources:scan_commit_argsreturnsstages_latefor-a/--all,-i/--include,-o/--only, short bundles included (-am). The existing "stop at the firstm/F" rule keeps-macorrect — there theais the message value, not--all.git add/git stageinvocation anywhere in the same command, via the sharedgitcmd.git_invocations(R3 — no new parser). A mention inside a quoted message is one token, never an invocation.Scope stays narrow. The block fires only when a tier that READS the diff is present. A
-F-file message parses no inline tier, so the diff checks never run and-ais moot there — unchanged frommain, and still thepr-validator's job. This sits beside the existing unresolvable--Cguard as the second member of one class: the gate cannot inspect the real diff, so it does not pretend to.R10 evidence — verbatim
python3 .claude/hooks/gate_test.pyFour boundary cases pin the scope: an attached
-m'a…'is not--all; a baregit addwith no commit is allowed;-awith a-Ffile (no inline tier) is allowed; a literalgit addinside a quoted message is allowed.R0–R10
origin/mainbefore any code changed.gitcmd.git_invocations; no second parser.Note for the evaluator
Merge with
--squash—--rebaseis disabled repo-wide as ofv2026.190.1835. Compose the squash message and carry theAssisted-by: Claude (fully tested and validated)trailer.Assisted-by: Claude (fully tested and validated)