Repository navigation
Description
Epic: M0 Blocked by: — Tier: mechanical Doc: docs/internal/graph-2026-09/PLAN.md §4, §5 I-4 Graph node: 01
Finding
pre-tool.sh's commit-message validator extracts MSG by scanning the entire TOOL_INPUT, not the git commit segment, so any earlier quoted string or any heredoc anywhere in a compound command is mistaken for the commit message — and a perfectly valid conventional commit is blocked.
Two distinct mis-extraction paths, both hit in one session (2026-08-30, during #943 and #975 work):
1. First double-quoted span wins (templates/hooks/pre-tool.sh:926):
MSG=$(echo "$TOOL_INPUT" | awk -F'"' '{print $2}')awk -F'"' '{print $2}' returns the first quoted span in the whole command, not the -m argument.
$ cd <worktree> && diff a.md b.md && echo "mirrors byte-identical"; git add -A && git commit -m "fix(#943): cite only real enforcers"
HOOK_BLOCKED: Commit must follow conventional commits format
Got: mirrors byte-identical
2. Any heredoc in the command hijacks extraction (:919-922): the heredoc branch is tried first and matches <<'PYEOF' (or any <<*EOF*), even when the heredoc belongs to a later, unrelated command:
$ git add -A && git commit -m "test(#975): pin metrics call-site wiring" && python3 - <<'PYEOF'
p = "src/lib/workflow/run-orchestrator.ts"
...
HOOK_BLOCKED: Commit must follow conventional commits format
Got: p = "src/lib/workflow/run-orchestrator.ts"
Why it matters
This is a false positive in a guard: the commit is conventional, the hook says it isn't, and the displayed Got: line names text the author never intended as a message — which makes the block read as a hook malfunction rather than actionable feedback. The workaround (split into a standalone git commit call) is discoverable only by experience; it costs a round trip every time and is a recurring papercut for both humans and phase agents. Same family as #564 (regexes matching inside quoted content) but a different site and the inverse symptom: #564 was guards firing on quoted content; this is the extractor reading the wrong span and blocking legitimate work.
Note the guard is correct to be conservative — the fix is not to weaken validation, but to scope extraction to the git commit segment that seg_match already identified.
Suggested fix
Scope extraction to the matched git commit … segment rather than the whole TOOL_INPUT (the script already segments commands for seg_match), and prefer an -m-anchored extraction over a positional field split — e.g. locate -m within the segment and take the following quoted argument, only falling back to the heredoc branch when the heredoc is attached to that same segment.
Scope (graph plan 2026-09)
- may touch:
templates/hooks/pre-tool.sh,.claude/hooks/pre-tool.sh,hooks/pre-tool.sh,__tests__/pre-tool-hook.integration.test.ts - not in scope: any other guard in the hook; weakening the conventional-commit pattern.
Acceptance criteria (graph plan 2026-09)
- AC-1: the Finding §1 repro (earlier
echo "…", then a validgit commit -m "fix(#943): …") is allowed — Verify:npx vitest run __tests__/pre-tool-hook.integration.test.ts -t "981"→ the AC-1 case asserts exit 0 with the verbatim command from the issue body. - AC-2: the Finding §2 repro (valid commit followed by
&& python3 - <<'PYEOF') is allowed — Verify: same test file, AC-2 case asserts exit 0. - AC-3:
git add -A && git commit -m "updated stuff"inside a compound command is still blocked withGot: updated stuff— Verify: same file, AC-3 case asserts exit 2 and theGot:line names the real message. - AC-4:
git commit -m "$(cat <<'EOF' … EOF)"still validates the heredoc's first line — Verify: same file, AC-4 case asserts exit 0 for a conventional first line and exit 2 for a non-conventional one. - AC-5: three copies identical — Verify:
md5 -q templates/hooks/pre-tool.sh .claude/hooks/pre-tool.sh hooks/pre-tool.sh | uniq | wc -l→1. - AC-6: the existing commit-format cases stay green — Verify:
npx vitest run __tests__/pre-tool-hook.integration.test.ts→ all pass.
Done when (graph plan 2026-09)
A valid conventional commit is never blocked because of text outside its own git commit segment, and a non-conventional one still is, in all three hook copies.
Original acceptance criteria (superseded by the graph-plan ACs above; kept for history)
- AC-1: a compound command containing an earlier double-quoted string and a valid conventional
git commit -m "fix(x): y"is allowed. Evidence: hook unit test asserting exit 0 for the repro in Finding §1 - AC-2: a valid conventional commit followed by an unrelated heredoc command (
... && python3 - <<'PYEOF') is allowed. Evidence: hook unit test asserting exit 0 for the repro in Finding §2 - AC-3: a genuinely non-conventional message (e.g.
git commit -m "updated stuff") is still blocked, including when it appears in a compound command. Evidence: existing commit-format tests stay green plus one new compound-command negative case - AC-4: the heredoc extraction path still works when the heredoc is the commit message (
git commit -m "$(cat <<'EOF' …)"). Evidence: unit test asserting the heredoc-message case parses and validates as today - AC-5: the fix is mirrored across all three hook locations per repo convention. Evidence:
npm run lint:skill-sync(or the hooks-drift check) green
Environment
sequant 2.13.0, templates/hooks/pre-tool.sh:913-939. Repros are verbatim from the 2026-08-30 session (both blocked commits were valid conventional commits that succeeded when re-issued standalone).
Activity
admarble commentedon Sep 7, 2026
Runner context (graph-run, 2026-09-06): the plan for this graph is on PR #998 (branch
docs/graph-plan-2026-09), not yet on main. Read it from the branch, not the working tree:PLAN §5 invariants are binding here: I-4 (hook/skill copies byte-identical:
md5 -q a b c | uniq | wc -l→ 1), I-5 (gate tests ship aMutation-verified:record in the PR body), I-6 (stop at PR — nevergh pr merge, never close the issue), I-9 (run the Verify commands verbatim; never reason an AC done). Base is main20e2a867(v2.13.1); no code drift from the plan basec3c1b0a8beyond the version bump. Stay inside the may touch list in the node file.Node file:
issues/01-981-hook-commit-extraction.md.admarble commentedon Sep 7, 2026
Complexity: Standard (6 ACs, 4 directories)
AC Quality Check
All 6 AC are single-line with an explicit
Verify:command and expected outcome — compliant with the constitution's AC Authoring Standard. No vague/unmeasurable/open-ended language found. AC-1/AC-2/AC-4 verify by test-name filter (-t "981"); AC-6 is the full-file regression check; AC-5 is the byte-identity gate (I-4). No lint concerns.Scope Assessment
Non-Goals: explicit in the issue body — "not in scope: any other guard in the hook; weakening the conventional-commit pattern."
templates/hooks/,.claude/hooks/,hooks/,__tests__/) — 3 are mirrored copies of one fileVerdict: ✅ SCOPE_OK
Acceptance Criteria
AC-1: Finding §1 repro (earlier
echo "…"before a validgit commit -m "fix(#943): …") is allowedVerification: Integration Test
Scenario: Given a compound Bash command with an unrelated double-quoted string before the commit → When the hook validates it → Then exit 0.
Assumptions: None beyond the fix itself.
AC-2: Finding §2 repro (valid commit followed by
&& python3 - <<'PYEOF') is allowedVerification: Integration Test
Scenario: Given a valid
git commit -m "…"followed by an unrelated heredoc-bearing command → When validated → Then exit 0.Assumptions: None.
AC-3:
git add -A && git commit -m "updated stuff"inside a compound command is still blockedVerification: Integration Test
Scenario: Given a compound command whose actual commit message is non-conventional → When validated → Then exit 2 with
Got: updated stuff(the real message, not a decoy).Assumptions: None.
AC-4:
git commit -m "$(cat <<'EOF' … EOF)"still validates the heredoc's first lineVerification: Integration Test
Scenario: Given the standard heredoc-commit-message idiom → When the first line is conventional → Then exit 0; when non-conventional → Then exit 2.
Assumptions: The heredoc here is attached to the same
git commitinvocation (inside its$( )), distinguishing it from AC-2's unrelated heredoc.AC-5: Three hook copies byte-identical
Verification: Integration Test (shell-level)
Scenario: Given the fix applied → When comparing the three copies → Then
md5 -q templates/hooks/pre-tool.sh .claude/hooks/pre-tool.sh hooks/pre-tool.sh | uniq | wc -l→1.Assumptions: None. Currently all three copies are identical (
e32afcec…), so this is purely a "don't forget to mirror" gate.AC-6: Existing commit-format cases stay green
Verification: Integration Test
Scenario: Given the full
__tests__/pre-tool-hook.integration.test.tssuite → When run after the fix → Then all pass (no regressions to the ~15+ existing commit/heredoc/sudo cases already in that file).Assumptions: None.
Implementation Plan
Phase 1: Segment-scoped raw extraction
emit_segments/seg_match(templates/hooks/pre-tool.sh:210-307) already track quote/heredoc/subshell state to splitTOOL_INPUTinto segments, but sanitize quoted/heredoc content to blank by design (:192-199) —$SEGMENTScan't supply the literal message text.git commit(bounded by the same top-level terminators; && || | newline— not by subshell content, so a$(...)-wrapped heredoc belonging to this commit's-mstays in-span per AC-4), instead of sanitizing it.emit_segments— that function is a hot path for every other guard'sseg_match, and must not be put at risk for this one guard (Open Question 1).Phase 2: Rewire the commit-message validator
templates/hooks/pre-tool.sh:913-956, obtain the git-commit segment's raw text first, then run the existing three-way MSG extraction (heredoc-first, then-m "…", then-m '…') against that segment instead of the raw$TOOL_INPUT. The extraction cascade logic and the conventional-commitsPATTERNcheck (:938) are unchanged — only their input narrows.Phase 3: Tests
it(...)cases in__tests__/pre-tool-hook.integration.test.ts, using the verbatim repro commands quoted in the issue's Finding section, named so-t "981"selects them.Phase 4: Mirror and close out
templates/hooks/pre-tool.shto.claude/hooks/pre-tool.shandhooks/pre-tool.shverbatim; verify AC-5's md5 command.Mutation-verified: AC-N — <mutation>; <test> failed; restored.in the PR body, plus the machine-anchoredSEQUANT_MUTATIONcomment.Design Review
templates/hooks/pre-tool.sh's existing commit-validation block and its two mirrors — this is a scoping fix to logic that already lives there, not a new subsystem.git commit, then run today's unmodified MSG cascade against it — minimal diff, reuses the pattern-matching and error-formatting code as-is.emit_segments/seg_matchsegment-boundary state machine (already the fix for the sibling bug class fix(hooks):^gh (issue|pr)prefix skip disarms all 5 pre-tool guards for compound commands, and re-breaks on anycdprefix #763/bug(hooks): pre-tool.sh regexes match inside quoted gh issue/pr body content (line 108 force-push, line 248 git-commit) #564/bug(hooks): pre-tool.sh regexes for destructive/deployment/reset/workflow commands also match inside quoted gh body content #570) — this extends the same boundary-detection idea to raw-text extraction instead of sanitized matching.emit_segmentsto stop sanitizing?" — because sanitization there is load-bearing for every other guard (a guard must never fire on quoted/heredoc data); only the commit-message extractor needs the raw text, so it gets its own narrow helper instead of loosening a shared one.Feature Quality Planning
All standard checks pass. Notable items:
Open Questions
emit_segments, or duplicate the state machine? Recommendation: separate function (Phase 1, step 3). Impact if wrong: sharing risks regressing the sanitized-segment path every other guard depends on; duplicating risks the two drifting apart on a future edit to one but not the other — mitigate by a comment cross-referencing the two.git commitinvocations in one compound command (e.g. amend-then-recommit) — validate all matching segments, or just the first? Recommendation: validate every top-level segment matchinggit commit, not just the first found. Impact if wrong: a malformed second commit message could ride through validated as the first (good) one, defeating the guard on a rare but plausible chained-commit command. Not covered by any of the 6 AC — flagging as a design choice for /exec, not a scope-expanding requirement.Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: SCOPE_OK, no complexity label, single-file-family fix. Skipping
testgen: unlike a typical "Integration Test verification → recommend testgen" case, every AC here already specifies its exact test name/assertion and target file (__tests__/pre-tool-hook.integration.test.ts, filtered by-t "981") — testgen's stub-generation would add no value over what the AC Verify commands already pin down. Graph plan tags this nodeTier: mechanical(docs/internal/graph-2026-09/PLAN.md §8) — runner routes accordingly.Label Review
Current:
graph-2026-09Recommended:
graph-2026-09,plannedReason: No scope-driven label change; adding
plannedper standard/specconvention.Quality Loop: Won't auto-enable — SCOPE_OK, no complexity signal.
→
gh issue edit 981 --add-label "planned"admarble commentedon Sep 7, 2026
Pre-PR Confidence Check
raw_commit_segmentis a hand-rolled awk state machine (quote/paren/heredoc tracking), not a real shell parser — it's deliberately scoped to the same top-level-boundary semantics as the existingemit_segments/seg_match, and only the firstgit commitsegment in a compound command is validated (an accepted limitation per the issue's Open Question 2).__tests__/pre-tool-hook.integration.test.ts, and the existing commit-format suite stays green.AC Verification
Got:md5identical across all threeChecks
npx vitest run __tests__/pre-tool-hook.integration.test.tsnpm run buildnpm run lintbash -non all 3 hook copiesFiles changed
templates/hooks/pre-tool.sh,.claude/hooks/pre-tool.sh,hooks/pre-tool.sh— addedraw_commit_segment, scopedMSGextraction to it__tests__/pre-tool-hook.integration.test.ts— added AC-1..AC-6 casesCHANGELOG.md— Unreleased/Fixed entryPR
#999
admarble commentedon Sep 7, 2026
QA Review for Issue #981
AC Coverage
981 AC-1test passes exit 0 across all 3 copies981 AC-2test passes exit 0updated stuffin compound command still blocked with realGot:981 AC-3asserts exit 2 +Got: updated stuff981 AC-4cases pass (exit 0 / exit 2)md5 -q ... | uniq | wc -l→1(executed)Coverage: 6/6 AC items literally met
Done-when clause: ❌ NOT MET — see Adversarial Re-Read below
Precheck Findings
Precheck Findings: unavailable — inline fallback used.
CI Status
build (22.x)typecheckHooks Validationnode-floor-guardPlugin Structure ValidationSetup Directory Creationvalidate-pluginvalidate-skillstautology-advisoryCI Summary: 9 passed, 0 pending, 0 failed. No CI-dependent ACs.
Quality Metrics
any)Test Coverage Analysis
templates/hooks/pre-tool.sh__tests__/pre-tool-hook.integration.test.ts.claude/hooks/pre-tool.shhooks/pre-tool.shCHANGELOG.mdCoverage: 3/3 changed source files have tests.
bash -nclean on all three.Code Review
Strengths:
raw_commit_segmentcorrectly mirrorsemit_segments' top-level boundary semantics while deliberately preserving quotes/heredoc bodies, with a well-written header explaining exactly why the sanitized$SEGMENTScannot be reused.$( )nesting is tracked as depth so the AC-4-m "$(cat <<'EOF' … EOF)"idiom stays inside its own segment, newlines and all.Got:line is now accurate in cases where main printed an empty/garbage message (verified on multi-line and heredoc-preceded forms).Issues:
raw_commit_segmenttreats a bare\nas a top-level segment boundary without honoring\-continuation, so the segment ends atgit commit \— which contains no-m, leavingMSGempty and skipping validation entirely.-m-anchored extraction the issue's Suggested-fix section recommended was not adopted; extraction still uses the positionalawk -F'"' '{print $2}'split, so a quoted flag before-mstill wins. Not a regression (main behaves identically) but the issue explicitly proposed fixing it here.Suggestions:
Test Quality Review
&&negative, but no line-continuation form — the shape that regressedbashsubprocess, real temp git reposmkdtemprepos,commit.gpgsign false, cleaned infinallyAnti-Pattern Detection
Dependency Audit: N/A — no
package.jsonchanges.Code Patterns: No hardcoded secrets, eval, SQL concatenation, or interface binding introduced. Shell-only change;
bash -nclean on all three copies.shellchecknot installed locally — not run.Call-Site Review
New exported functions detected: 1 shell function (
raw_commit_segment)raw_commit_segmenttemplates/hooks/pre-tool.sh:1051(+2 mirrors)if [[ "$TOOL_NAME" == "Bash" ]] && seg_match 'git commit'Single call site, correctly gated behind the same
seg_matchthat already decided the guard applies.Execution Evidence
npx vitest run __tests__/pre-tool-hook.integration.test.ts -t "981"npx vitest run __tests__/pre-tool-hook.integration.test.tsmd5 -q <3 copies> | uniq | wc -l1bash -n× 3origin/maincopy over 17 crafted commandsEvidence status: Complete
Skill Command Verification
N/A — no
.claude/skills/**/*.mdfiles changed.Detection Pattern Verification
N/A — no skill markdown changed. (The diff does add
awk/grep/sedpatterns, but in.shhook files, outside §6c's skill-markdown scope. They were instead verified empirically — see Adversarial Re-Read.)CLI Registration Verification
N/A — no option interfaces (
RunOptions,bin/cli.ts) modified.Smoke Test
Got:\-continuationSmoke Test Status: Partial — one edge case fails
Manual Test ACs
N/A — no manual-test ACs detected; every AC declares a runnable command, all executed.
Risk Assessment
git commit \↵-m "updated stuff"invocation (backslash line continuation, either quote style, with or without a precedinggit add -A &&) now passes the conventional-commit guard silently.raw_commit_segmentends the segment at the newline, the segment holds no-m,MSGstays empty, and theif [[ -n "$MSG" ]]branch never runs. Onorigin/mainthese same commands are blocked. Fail-open in a guard is worse than the confusing-but-correct block it replaces.git commit. Also untested:--author="…"/-c key="…"before-m, and backslash-escaped quotes inside the message.emit_segments/seg_match(same file) share the segment-splitting concept but sanitize rather than preserve content, and are unchanged by this diff — they are not affected by the continuation bug because they are not used for message extraction. No other file in the repo extracts a commit message. The three hook copies are byte-identical, so the defect is present in all three — not a cross-file sibling so much as a mirrored one.MSG=extraction branches (heredoc / double-quote / single-quote) in the sameifblock all now read$COMMIT_SEG; all three were audited. All three share the same root cause — each is guarded by agrepon$COMMIT_SEGthat fails when the segment was truncated at a continuation newline, so the fix must be at the segment level (or in the fallback), not in any one branch.Trust-Boundary Check
Finding: Clean — the issue body and comments contain no HTML comments, URLs,
curl/wget/POST, or base64 payloads; the only imperative content is the "Suggested fix" section, which describes product behavior (where to scope extraction), not agent behavior. The diff implements only the described product change.Status: Clean
Behavior-Rule Survival Check
Ran
detectBehaviorRuleover all six ACs — none triggered.Status: N/A
Declared-Evidence Execution
npx vitest run __tests__/pre-tool-hook.integration.test.ts -t "981"md5 -q … | uniq | wc -l1npx vitest run __tests__/pre-tool-hook.integration.test.tsStatus: Complete
Mutation Verification
Ran
isGateTestEvidenceover all sixVerify:clauses — none classify as gate-test evidence, so noSEQUANT_MUTATIONmarker is required.Status: Not-Applicable
CHANGELOG Verification
#981)Result: CHANGELOG requirements met
Adversarial Re-Read
Findings:
I ran both hook copies (this branch vs
origin/main) against 17 crafted commands through the real hook entry point to test the extractor empirically rather than by reading it.Confirmed improvements over main (real #981 false positives now fixed):
echo "run git commit later"; git commit -m "fix: real message"Got: run git commit laterecho "git commit -m \"bogus\""; git commit -m "fix: real message"git add -A↵git commit -m "updated stuff"Got:emptyGot: updated stuffGot:emptyGot: updated stuffRegression introduced by this diff — a non-conventional commit that main blocks is now allowed:
git commit \↵-m "updated stuff"git commit \↵--no-verify \↵-m "updated stuff"git add -A && git commit \↵-m "updated stuff"git commit \↵-m 'updated stuff'Root cause:
raw_commit_segmenttreats an unquoted\nat depth 0 as a segment boundary (templates/hooks/pre-tool.sh:416) without honoring a trailing\line continuation. The emitted segment isgit commit \, which satisfiesindex(t, "git commit")sofound=1and the scan stops — but it contains no-m, so all threeMSG=branches miss,MSGstays empty, andif [[ -n "$MSG" ]]skips validation entirely.Why this is a requirement gap, not a nitpick: the issue's Done-when clause reads "A valid conventional commit is never blocked because of text outside its own
git commitsegment, and a non-conventional one still is, in all three hook copies." The second half is now false for the continuation form, on all three copies. The issue body also states explicitly: "the guard is correct to be conservative — the fix is not to weaken validation." This weakens it.Proportionality note (stated plainly rather than oversold): a repo-wide grep for the
commit \continuation idiom across*.md/*.sh/*.tsfound 0 occurrences in-repo, so frequency in sequant's own tooling is low. The hook ships downstream and guards human commits too, where the idiom is more common.Suggested remediation (minimal, matches the author's stated intent): widen the existing fail-safe fallback so it also fires when the chosen segment yields no message — e.g. after the three
MSG=branches,if [[ -z "$MSG" && "$COMMIT_SEG" != "$TOOL_INPUT" ]], re-run extraction against$TOOL_INPUT. That restores main's blocking behavior for the continuation form while keeping every #981 fix intact. Add a line-continuation case to the test file alongside981 AC-3.Residual gap (pre-existing, not a regression, no AC covers it): the
-m-anchored extraction the issue's Suggested-fix section recommended was not adopted.git commit --author="A B" -m "fix: valid message"is still blocked withGot: A Bon both main and this branch. Worth a follow-up issue rather than widening this PR.Other checks: no Non-Goals in the issue body have expanded into scope; the evidence claims in the PR body are post-fix validations (I re-ran each), not pre-fix repros; working tree is clean, branch is 0 behind
origin/main, no stashed work.Status: Gaps Found
Verdict: AC_NOT_MET
All six numbered ACs are literally met and CI is fully green — this is careful work with a well-documented extractor, and it genuinely fixes both reported repros plus two
Got:-accuracy cases.It is blocked on one thing: the diff introduces a fail-open regression in the guard it was meant to repair. Four command shapes that
origin/mainblocks now pass silently, all of them thegit commit \↵-m "…"line-continuation form. That directly contradicts the second half of the issue's own Done-when clause ("and a non-conventional one still is") and its explicit instruction that "the fix is not to weaken validation." A guard that stops validating without saying so is the failure mode most worth blocking on, and the remediation is small and already implied by the author's own fail-safe comment.Documentation
[Unreleased]→ Fixed, references fix(hooks): commit-message validator extracts from the whole command, so an earlier quoted string or unrelated heredoc blocks a valid conventional commit #981)Next Steps
\-continuation form.__tests__/pre-tool-hook.integration.test.tsnext to981 AC-3, and mirror the hook fix across all three copies (re-verifymd5→1).-m-anchored extraction (--author="A B" -m "fix: x"still mis-extracts on main and this branch).fix(hooks): keep segment scoping from opening a fail-open in the comm…
docs(changelog): note the fail-open guard in the #981 entry
admarble commentedon Sep 7, 2026
Loop Iteration 1/3
Issues from Previous Phase
Parsed from the
SEQUANT_QA_GAPSmarker on the QA comment (verdictAC_NOT_MET):git commit, the exact shape that regressed.repository_gap / document— excluded per the loop'sdocument/pause_for_humanfilter (residual-m-anchoring gap; pre-existing, identical on main).Fixes Applied
Finding 1 — root cause,
raw_commit_segment(templates/hooks/pre-tool.sh+ 2 mirrors, all byte-identical):\+newline is a shell continuation, so both characters are dropped and the newline no longer ends the segment. Previously the segment was cut at the backslash, stranding-moutside it →MSGempty →if [[ -n "$MSG" ]]skipped validation entirely.\"being misread as the closing quote.seg, the scanner now also buildscodewith quoted/subshell content blanked, andemit()testsindex(code, "git commit")instead of the raw text. This mirrors whatemit_segments/seg_matchalready do, so the scan agrees with the guard that invoked it.Why the second change was needed: while verifying finding 1 I probed the adjacent case and found a second fail-open of the same class, also a regression vs main —
echo "run git commit later"; git commit -m "updated stuff"was allowed, because the quoted mention won segment selection and that segment supplies no-m. Fixed together rather than left for the next QA round.Deliberately not done: my QA comment suggested a blanket "retry extraction against the whole
TOOL_INPUTwhen the segment yields no message" fallback. I dropped that on implementation — it would have re-introduced the original #981 false positive (the decoy segment's text becomes the message again). Fixing segment selection achieves the same fail-safe without that cost.Finding 2 — tests (
__tests__/pre-tool-hook.integration.test.ts:955-1002), 3 new cases × 3 hook copies:Got: updated stuffgit commitdecoy, non-conventional real commitGot: updated stuffRe-validation Results
npx vitest run __tests__/pre-tool-hook.integration.test.tsnpm run buildnpm run lintmd5 -q× 3 hook copies1(identical)bash -n× 3progressed: true(632e5ac → 6aa876a)Differential matrix — 22 crafted commands run through the real hook entry point on three builds (main / pre-fix / fixed): 0 mismatches.
git commit \↵-m "updated stuff"--no-verify, 3-linegit add -A && git commit \↵…echo "run git commit later"; git commit -m "updated stuff"-minside quotes, non-conventional&&compound (bad)&&in message, escaped quotes, multi-line, heredoc-before-commit…)The newly-blocked cases also report an accurate
Got: updated stuff, where main printed an emptyGot:.Mutation verification — reverted the three hook copies to the pre-fix commit (
632e5aca) with the new tests in place: exactly the 2 new negative tests failed (× 3 copies = 6 failures), nothing else. Restored; tree clean.Mutation-verified: reverted templates/.claude/hooks pre-tool.sh to 632e5aca; "981: a backslash line-continuation does not let a non-conventional message escape validation" and "981: a quoted mention of git commit does not shadow the real non-conventional commit" failed (6 instances); restored.Status
FIXED — Continue to QA
Both actionable findings resolved; the excluded
documentfinding (-manchoring, e.g.git commit --author="A B" -m "fix: x") is unchanged and still behaves identically to main — worth a follow-up issue, not this PR.admarble commentedon Sep 7, 2026
QA Review for Issue #981
Re-review after
/loopiteration 1 (d17c7456). Prior QA wasAC_NOT_METat632e5aca.AC Coverage
updated stuffin compound command blocked with realGot:Got: updated stuffmd5 … | uniq | wc -l→1git commitsegment, and a non-conventional one still is"d17c7456Coverage: 6/6 numbered ACs met; Done-when clause not met.
Precheck Findings
Precheck Findings: unavailable — inline fallback used.
CI Status
build (22.x),typecheck,Hooks Validation,node-floor-guard,Plugin Structure Validation,Setup Directory Creation,validate-plugin,validate-skills,tautology-advisory)CI Summary: 9 passed, 0 pending, 0 failed. No CI-dependent ACs.
Quality Metrics
any)Test Coverage Analysis
templates/hooks/pre-tool.sh(+2 mirrors)__tests__/pre-tool-hook.integration.test.ts(261 cases, parametrized × 3 copies)CHANGELOG.mdCoverage: 3/3 changed source files have tests.
bash -nclean on all three.Code Review
Strengths:
\-continuation fail-open and the quoted-decoy fail-open now block, with an accurateGot: updated stuff.TOOL_INPUT" fallback was the right call — it would have re-opened the original fix(hooks): commit-message validator extracts from the whole command, so an earlier quoted string or unrelated heredoc blocks a valid conventional commit #981 false positive.Issues:
emit()'s new code-form test blanks subshell content, so agit commitinside( … )or$( … )is invisible to segment selection.raw_commit_segmentreturns empty, the validator falls back to the wholeTOOL_INPUT, and the pre-fix(hooks): commit-message validator extracts from the whole command, so an earlier quoted string or unrelated heredoc blocks a valid conventional commit #981 first-quoted-span extraction takes over. Detail below.Suggestions:
depth > 0branch, appendctocoderather than a blank. Quote state is still tracked inside subshells — thecur == sq/cur == dqbranches run before thedepth > 0branch — so quoted content there would still be blanked correctly, and only genuine subshell code would become visible to selection. Needs a test for the heredoc-body-inside-$( … )interaction (anEOFbody sits atdepth > 0and unquoted, so it would newly reachcode); I did not verify that a naive change is safe.Test Quality Review
git commitin( … )/$( … )— the shape that regressed this roundbashsubprocess, real temp reposmkdtemp, gpgsign off,finallycleanupAnti-Pattern Detection
Dependency Audit: N/A — no
package.jsonchanges.Code Patterns: no secrets/eval/SQL-concat/interface-binding introduced; shell-only change,
bash -nclean × 3.shellchecknot installed locally — not run.Call-Site Review
raw_commit_segmenttemplates/hooks/pre-tool.sh:1084(+2 mirrors)seg_match 'git commit'Single call site. Note the finding below is precisely a disagreement between that gate and the function it gates —
seg_matchsays yes,raw_commit_segmentsays nothing.Execution Evidence
npx vitest run __tests__/pre-tool-hook.integration.test.tsmd5 -q <3 copies> | uniq | wc -l1bash -n× 3main/632e5acapre-loop /6aa876a6current) over 16 commandsemit_segments+seg_matchvsraw_commit_segmentover 9 shell constructsEvidence status: Complete
Skill Command Verification
N/A — no
.claude/skills/**/*.mdfiles changed.Detection Pattern Verification
N/A — no skill markdown changed. (Hook
awkpatterns verified empirically instead.)CLI Registration Verification
N/A — no option interfaces modified.
Smoke Test
Got:\-continuation( … )after a quoted decoySmoke Test Status: Partial
Manual Test ACs
N/A — every AC declares a runnable command; all executed this pass.
Risk Assessment
echo "…"; (cd sub && git commit -m "fix: x")— subshell-wrapping to scope acdis a common idiom, and the issue's own repro begins with acd— has their valid conventional commit blocked, withGot:naming the earlier echo's text. That is verbatim the fix(hooks): commit-message validator extracts from the whole command, so an earlier quoted string or unrelated heredoc blocks a valid conventional commit #981 symptom this PR exists to remove, and it worked at632e5aca;d17c7456reintroduced it.git commitin( … )or$( … ). Also untested: heredoc body inside$( … )reaching the newcodestring;--author="…"/-c key="…"before-m(pre-existing, unchanged).emit_segments/seg_match(same file) are the cross-function siblings — this finding is a disagreement between them andraw_commit_segment, and the loop commit's stated goal was to make the two agree. They now agree on quoted content but disagree on subshell content. No other file extracts a commit message. The three hook copies are byte-identical (md5→1), so the defect is mirrored in all three.code = code …assignment added byd17c7456(11 sites). Ten blank data or copy code correctly; thedepth > 0branch (templates/hooks/pre-tool.sh:420) is the single divergent one — it blanks content that quote tracking has already proven to be code.Trust-Boundary Check
Finding: Clean — issue body and comments contain no HTML comments, URLs,
curl/wget/POST, or base64 payloads. The only imperative content describes product behavior. The diff implements only that.Status: Clean
Behavior-Rule Survival Check
Status: N/A
Declared-Evidence Execution
npx vitest run __tests__/pre-tool-hook.integration.test.tsmd5 -q … | uniq | wc -l1Status: Complete
Mutation Verification
isGateTestEvidencereturns false for all sixVerify:clauses — no marker required.Status: Not-Applicable
CHANGELOG Verification
#981Result: CHANGELOG requirements met
Adversarial Re-Read
Findings:
The prior round's two fail-opens are genuinely fixed — I re-ran both and they block. But the mechanism chosen to fix the second one introduced a new hole of the opposite kind.
I probed for disagreement between
seg_match(the gate) andraw_commit_segment(the function it gates) across 9 shell constructs. Three diverge —seg_matchmatches,raw_commit_segmentreturns nothing:seg_matchraw_commit_segment( git commit -m "fix: x" )$( git commit -m "fix: x" )true && ( echo a; git commit -m "fix: x" )An empty return hits
[[ -z "$COMMIT_SEG" ]] && COMMIT_SEG="$TOOL_INPUT"— the pre-#981 whole-command path. Differential run against three builds:632e5aca6aa876a6echo "mirrors byte-identical"; (cd sub && git commit -m "fix(#943): real")echo "mirrors byte-identical"; ( git commit -m "fix: x" )echo "mirrors byte-identical"; $( git commit -m "fix: x" )( git commit -m "fix: x" )alone{ git commit -m "fix: x"; }after decoyif true; then git commit …; fiafter decoyBrace groups and
if/thenare unaffected because only(and$(incrementdepth.Root cause:
emit()now selects on the quote-blankedcodeform, and thedepth > 0branch (templates/hooks/pre-tool.sh:420) writes a blank intocodefor every character inside a subshell. Sogit commitinside( … )never appears incode, no segment qualifies, and the function returns empty. The blanking is over-broad: quote state is already tracked inside subshells by thecur == sq/cur == dqbranches, which run first — so thedepth > 0branch only ever sees unquoted characters, which are exactly the code that selection should be able to see.Why this blocks: the Done-when clause's first half — "A valid conventional commit is never blocked because of text outside its own
git commitsegment" — is false again, for a shape that was working one commit ago. Last round I blocked on the clause's second half; the fix for that broke the first half. Trading one half of the contract for the other isn't convergence.Other checks: all six numbered ACs verified by execution, not reading; the PR body's evidence claims are post-fix validations (re-run this pass); no Non-Goals have expanded into scope; working tree clean, 0 behind
origin/main, no stashed work; CI fully green.Status: Severe Gap
Verdict: AC_NOT_MET
The loop iteration did real work: both prior fail-opens are closed, verified by re-execution, with three genuine regression tests and an accurate
Got:line. All six numbered ACs pass and CI is 9/9 green.It is blocked because the fix for the second fail-open over-corrected. Selecting segments on a fully quote-and-subshell-blanked
codeform makesgit commitinvisible inside( … )and$( … ), soraw_commit_segmentreturns empty, extraction falls back to the whole command, and the original #981 false positive returns for subshell-wrapped commits — includingecho "…"; (cd sub && git commit -m "fix: x"), which worked at632e5aca. That is the first half of the issue's Done-when clause, and this is a regression introduced by the most recent commit rather than a pre-existing gap.The remediation looks small — stop blanking
codein thedepth > 0branch — but it needs a test for the heredoc-inside-$( … )interaction before it can be trusted, so I have not applied it.Documentation
[Unreleased]entry present and accurateNext Steps
raw_commit_segment'sdepth > 0branch, appendctocodeinstead of a blank, so subshell code stays visible toemit()while quote branches keep blanking subshell data.echo "decoy"; ( git commit -m "fix: x" )and the$( … )form, plus a heredoc-body-inside-$( … )case to pin the interaction.md5→1.fix(hooks): let subshell code count for segment selection, heredoc bo…
docs(changelog): note subshell handling in the #981 entry
19 remaining items
fix(hooks): read the heredoc idiom in any spacing; pin idiom variants…
admarble commentedon Sep 7, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 6/12 met
Gaps:
main(-m "$VAR"after a conventional-looking assignment) is unpinned in either direction (Finding 2 below).Suggestions:
fix(hooks): a bare variable-reference message is not validated; pin t…
admarble commentedon Sep 7, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 0/1 met
Gaps:
templates/hooks/pre-tool.sh:1231— the comment justifying the bare-variable exemption says blocking on literal$MSGwould be "a false positivemaindid not have." Measured againstorigin/main:git commit -m "$MSG"→ exit 2,Got: $MSG. Main did have it. The test's own comment at:1418describes main's behavior accurately; the hook comment does not.Suggestions:
MSG="updated stuff"; git commit -m "$MSG") before giving up on validation — it would recover most of the coverage lost below without weakening anything.fix(hooks): resolve a variable-reference message through its same-com…
fix(hooks): resolve variable messages in code context only, before th…
admarble commentedon Sep 7, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 0/5 met
Gaps:
limit=0sentinel collision (templates/hooks/pre-tool.sh:1284,1287,1339+ driver at:1394) — see Adversarial Re-Read below. Reachable false positive.Suggestions:
main(0.22 s → 0.34 s measured end-to-end through the driver, which includesgit init). Only on thegit commitpath; acceptable, noted for awareness.fix(hooks): -1 is the unlimited sentinel for variable resolution; a l…
admarble commentedon Sep 7, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 0/1 met
Gaps:
Suggestions:
git -Csibling gap (below) are worth follow-ups, not scope expansion here.fix(hooks): locate the variable window on a continuation-normalized c…
fix(hooks): dynamic assignment values are unknowable; duplicate commi…
admarble commentedon Sep 7, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 0/1 met
Gaps:
mainhad and adds a variable-resolution subsystem. All are strict improvements, all within the commit guard (not "any other guard", the issue's stated non-goal) — but this is a reviewability burden, and the implementer has explicitly escalated the split decision rather than deciding it.Suggestions:
:485-503and:530-546) are still near-duplicates even though the delimiter parse was factored out. Already noted as a follow-up in the PR body; agreed it's not a behavior change.admarble commentedon Sep 7, 2026
Runner verification — node 01, final (PR #999 at
49432ad1, QA verdict AC_MET_BUT_NOT_A_PLUS after 17 rounds; loop stopped)Verify commands from
issues/01-981-hook-commit-extraction.md, re-run verbatim at the final commit:-t "981"over__tests__/pre-tool-hook.integration.test.ts→ Tests 93 passedmd5 … | uniq | wc -l→ 1Why the loop stopped short of READY_FOR_MERGE: the reviewer's last three items are not code changes inside this PR — (1) the scope split of the adjacent fail-open closures (
6a1776d5,7427aa22,eba633ef, and the variable-resolution commitsdf28e2cf…49432ad1), escalated to you since round 8; (2) the pre-existing--no-verifywhole-input scan that this merge makes newly reachable (PLAN §9 OQ-21 on PR #998 — consider landing it first); (3) the PR body's performance figures, now consolidated into one measured line. Every code finding from rounds 4–16 (three regressions againstmain, four fail-opens, six false-positive shapes) is fixed and pinned in both polarities over all three copies.What the A+ pass changed beyond the original agent work: the extractor is anchored on each commit's own message flag (
-m,-am-style clusters,--message, the$(cat <<EOF)idiom in any spacing, a heredoc feeding-F-), validates the subject line only, walks every commit segment, ignores unquoted#comments, and resolves a bare$VARmessage through its same-command literal assignment in code context (dynamic values unknowable). 330 tests.Merge decision is yours — I will not merge.
docs(plan): 2026-09 backlog graph (16 nodes, /graph-run ready) (#998)