Repository navigation
Conversation
Replace the five `! grep -qE '^gh (issue|pr) '` prefix carve-outs (10 sites, added by #564/#570) with command-word matching over quote-stripped shell segments. A real command chained after `gh issue`/`gh pr` (e.g. `gh issue list && git push --force`) now blocks; body text and `cd <dir> &&` prefixes are allowed without any carve-out. - AC-1: delete the `rm -rf /|~|$HOME` alternation (redundant with Claude Code's native analyzer; its `/` fragment blocked ordinary absolute deletes) - AC-2: `:108` is now a command-word `sudo` guard with its own message - AC-3/4: all carve-outs removed; anchored bypass blocks, false positives stay fixed including the `cd`-prefix case - AC-5: every HOOK_BLOCKED logs command text + rule id to a single rotated, secret-redacted sink (.sequant/logs fallback instead of purge-prone $TMPDIR) - AC-6/7: correct the miscalibrated `echo gh issue && ...` tests to the anchored `gh issue list && ...` shape; encode the evidence table across all 3 copies - AC-8: three hook copies byte-identical; dist marketplace regenerated - AC-10: document recommended Claude Code >= 2.1.208 in the README Entire-Checkpoint: c7c3504d285b
10 tasks
…osition
Addresses the QA gaps on AC-5 (log sink) and the guard-coverage narrowing.
Log sink (AC-5c). The fallback was a *relative* `.sequant/logs`, which resolved
against the hook's cwd rather than any fixed root. Three consequences:
1. It scattered stray `.sequant/` dirs into whatever directory the hook ran
in, so the AC-7 regression corpus was one sink per directory, not one.
2. `pre-tool.sh` moved but `post-tool.sh` did not, and the two share
`claude-timing.log` (START from pre, END from post) plus
`claude-quality.log`. With CLAUDE_PLUGIN_DATA unset — the npm/CI path —
every START/END pair split across two files, silently breaking the timing
instrumentation this hook exists to feed.
3. Worst: the hook created the directory *before* the no-changes guard read
`git status --porcelain`. The untracked dir made the repo look dirty, so
the guard concluded there were changes and allowed the empty commits it
exists to block. The hook's own side effect turned the hook's guard off.
Both hooks now resolve, with an identical block: CLAUDE_PLUGIN_DATA/logs ->
HOME/.sequant/logs -> TMPDIR. Always absolute, always outside the repo, so it
cannot touch `git status`, and one sink is shared by the main repo and every
worktree. This departs from AC-5c's suggested repo-local wording, which is what
produced the bug; it meets AC-5c's actual requirement ("a single non-purged
sink") more closely.
Guard coverage. emit_segments now treats every position the shell would really
execute as a command word: chained, `( ... )`, `$( ... )`, and `$( ... )` inside
double quotes (double quotes do not disable command substitution). This matters
because the escalation guard has no native Claude Code backstop, and the prior
anchoring left it narrower than the code it replaced.
Heredoc bodies are stdin *data*, not code, and are skipped. Without this, making
`$( )` live inside double quotes would block any commit whose message merely
mentions a guarded command via the standard `cat <<'EOF'` idiom — reintroducing
the #564/#570 false-positive class through a new door. Verified: removing the
skip flips that case to blocked.
Argument positions (`xargs ...`, `bash -c "..."`) stay allowed and are now
locked in by tests: treating an argument as code is the original #564/#570
mistake.
Tests. The prior suite forced CLAUDE_PLUGIN_DATA everywhere, so the fallback
branch real users hit was never exercised — the blind spot both defects shipped
through. Adds a log-sink block driving the fallback across all three copies
(single sink, START/END pairing, guard not self-defeated) plus command-word and
heredoc cases. 135 -> 183 tests. Each new assertion was mutation-checked against
the pre-fix hook.
Docs corrected where the change falsified them: plugin-distribution, worktree-
isolation, what-weve-built, and the mirrored verification-criteria/fullsolve
skill references.
Latency unchanged in the good direction (AC-9): 61.7ms vs 80.4ms on main, n=30.
…-gh-issue-pr-prefix-skip-disarms-all-5-pr # Conflicts: # CHANGELOG.md
admarble
deleted the
feature/763-fix-hooks-gh-issue-pr-prefix-skip-disarms-all-5-pr
branch
July 16, 2026 03:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #763. The five catastrophic guards in
pre-tool.shwere each wrapped with a! grep -qE '^gh (issue|pr) 'carve-out (added by #564, extended to four more sites by #570) that tested the command's prefix, not its content. Any compound command starting with a realgh issue/gh prinvocation disarmed the guard — including the load-bearing force-push protection — and the same^anchor re-broke the false-positive fix on anycd <dir> && gh issue …prefix.; && || |and newline, quotes stripped via a small pure-awk/bash splitter). A token inside a quoted--body/--titleargument is never a command word (allowed); a real command chained after an allowed one is its own segment (still blocks).rmalternation deleted (AC-1). Redundant with Claude Code's native dangerous-rmanalyzer (fires even underbypassPermissions); itsrm -rf /fragment substring-matched every absolute path, blocking ordinary worktree/scratch deletes.:108is now a dedicated command-wordsudoguard (not natively covered).HOOK_BLOCKEDlogs the offending command + the rule that fired to a single rotated, secret-redacted sink (.sequant/logsfallback instead of the macOS-purged$TMPDIR).Pre-PR AC Verification
rmalternation from:108:108→ command-wordsudoguard, distinct messageecho/grep -r sudoku/commit allowed;sudo …blocks (sudo command)^gh (issue|pr)carve-outs removed; anchored bypass blocks:295warn-only asserts no exit-2cd-prefixcd <dir> && gh issue create …both allowedlog_block/redact_secrets/rotate_log; redaction testecho gh issue && …testsgh issue list && …; sudo-message churn fixeddist/regeneratedef380228…× 3;npm run prepare:marketplacerunrmregex is net-faster)Out of scope (per issue): in-workspace destruction guard, the full argv parser + block-list,
rm -frfalse-negatives, version-floor enforcement.Test plan
npx vitest run __tests__/pre-tool-hook.integration.test.ts— 135 passed (parametrized across all 3 copies)npm run build— cleannpm run lint— cleanCloses #763
Update — QA gaps fixed (
57d44b7)QA found AC-5 not met and one coverage regression; all closed. 10/10 ACs met. The AC-5 and AC-2 rows above are superseded by this section.
AC-5c — log sink. The
.sequant/logsfallback was cwd-relative, so it scattered stray dirs, andpost-tool.shwas left on$TMPDIRwhile sharingclaude-timing.logwithpre-tool.sh— splitting every START/END pair. Worst, the hook created the dir before the no-changes guard readgit status --porcelain, so the untracked dir made the tree look dirty and the guard allowed the empty commits it exists to block:Both hooks now resolve
CLAUDE_PLUGIN_DATA/logs→$HOME/.sequant/logs→$TMPDIRwith an identical block — absolute, outside every repo, one sink across all worktrees. This departs from AC-5c's suggested repo-local wording (which produced the bug) to meet its stated requirement, "a single non-purged sink".AC-2 — command-word coverage. The guard was narrower than the code it replaced.
emit_segmentsnow covers every position the shell executes: chained,( … ),$( … ), and$( … )inside double quotes. Heredoc bodies are skipped as the stdin data they are — without that,git commit -m "$(cat <<'EOF' … EOF)"would block on a message that merely mentions a guarded command, reintroducing the #564/#570 FP class.xargs …/bash -c "…"stay allowed (argument, not command word) and are now pinned by tests.Verification: 183 hook tests (was 135) · 31/31 real-hook probe matrix · new assertions mutation-checked against the pre-fix hook · AC-9 latency 61.7ms vs 80.4ms on main (n=30) · pre-tool ×3 identical
4fd209d6…,dist/regenerated · docs corrected in 4 places · 8/8 CI green.