Skip to content

fix(#1064): preserve heredoc commit subjects in the pre-tool commit validator - #1088

Merged
admarble merged 1 commit into
mainfrom
feature/1064-bug-hooks-commit-validator-strips-from-a-git-commi
Sep 18, 2026
Merged

admarble merged 1 commit into
mainfrom
feature/1064-bug-hooks-commit-validator-strips-from-a-git-commi

Conversation

@admarble

@admarble admarble commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #1064. The commit-message validator in pre-tool.sh ran strip_comments over the whole command before extracting a heredoc subject, so in git commit -F - <<'EOF' everything from the # in fix(#497): … onward was blanked as a "comment" and every type(#N): subject sent via stdin was blocked (Got: fix().

commit_message_from now keeps two views of the command: the comment-sanitized s still drives command recognition and the flag scan (so data can never match a flag), while the raw raw string — same length, same offsets — is what heredoc_first_line reads the subject from. message_at threads raw through all three call sites. Applied to all three mirrors; five new integration cases × three copies.

The implementation commit (819d30c0) was produced by the Codex driver during the #1060 gate run; its QA under Codex found AC-1…AC-5 met and no implementation defect, failing only on this PR's missing evidence. The evidence below was re-run independently.

AC coverage

AC Status Evidence
AC-1 MET -t "1064" → Tests 15 passed | 336 skipped (351)
AC-2 MET -t "1064 blocks" → Tests 3 passed | 348 skipped (351)
AC-3 MET -t "1064 pins" → Tests 9 passed | 342 skipped (351)
AC-4 MET shasum … | sort -u | wc -l → 1
AC-5 MET full file → Tests 351 passed (351)
AC-6 MET see below

Mutation verification

Mutation-verified: AC-1 — reverted heredoc_first_line(raw, start) to heredoc_first_line(s, start) in hooks/pre-tool.sh; 1064: allows a -F - heredoc subject containing # failed (1 failed, 14 passed — only the mutated copy); restored.

Mutation-verified: AC-2 — removed the final if (line != "") print line in hooks/pre-tool.sh so the validator prints nothing for -F -; 1064 blocks a non-conventional -F - heredoc subject failed (1 failed, 14 passed); restored.

Worktree clean after each restore; -t "1064" back to 15/15.

Hook precedence

Hook precedence: both copies run — Claude Code does not pick one. With the sequant plugin enabled ("sequant@sequant": true), a session registers "$CLAUDE_PROJECT_DIR"/.claude/hooks/pre-tool.sh from .claude/settings.json and "${CLAUDE_PLUGIN_ROOT}/hooks/pre-tool.sh" (cache ~/.claude/plugins/cache/sequant/sequant/2.15.1/) from the plugin's hooks.json, and executes both on every tool call. Either can block.

Settled by the hook's own log routing — the plugin copy runs with CLAUDE_PLUGIN_DATA set and logs to ~/.claude/plugins/data/sequant-sequant/logs/, the repo copy without it and logs to ~/.sequant/logs/. I noted both claude-timing.log line counts, made a single Read tool call from a live Claude Code session in this repo, and diffed:

repo-copy log (~/.sequant/logs, CLAUDE_PLUGIN_DATA unset):
1789742234.924510000 START Read
1789742235.074562000 END Read
plugin-copy log (CLAUDE_PLUGIN_DATA=~/.claude/plugins/data/sequant-sequant):
1789742234.932383000 START Read
1789742235.076027000 END Read

One tool call, two hook executions 8 ms apart. Consequence for this fix — the form-A command from #1064 fed to each copy from a temp repo with a staged change:

~/.claude/plugins/cache/sequant/sequant/2.15.1/hooks/pre-tool.sh -> exit 2 | Got: fix(
<main>/.claude/hooks/pre-tool.sh                                   -> exit 2 | Got: fix(
<this branch>/.claude/hooks/pre-tool.sh                            -> exit 0

So merging this unblocks form A only once the plugin cache also carries the fix: until claude plugin update sequant pulls a version with it, the 2.15.1 plugin copy keeps exiting 2 and still blocks the commit even though the repo copy allows it.

Test plan

  • npx vitest run __tests__/pre-tool-hook.integration.test.ts — 351/351
  • -t "1064" / "1064 blocks" / "1064 pins" — 15 / 3 / 9
  • mirror parity — 1 unique digest
  • AC-1, AC-2 mutations — each fails exactly the targeted test, restored
  • CI

🤖 Generated with Claude Code

@admarble
admarble merged commit f776158 into main Sep 18, 2026
9 checks passed
@admarble
admarble deleted the feature/1064-bug-hooks-commit-validator-strips-from-a-git-commi branch September 18, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(hooks): commit validator strips # from a git commit -F - heredoc subject, blocking every type(#N): message sent via stdin

1 participant