Skip to content

fix: pre-prompt-hook.sh and pre-path-hook.sh gain the #402 worktree-mismatch warning (#416) - #421

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/416
Sep 18, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/416

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

This is the rest of #402: PR #415 wired jit_worktree_mismatch_line()/jit_worktree_notice() into pre-tool-hook.sh alone, on purpose, and said so rather than quietly widening. pre-prompt-hook.sh and pre-path-hook.sh resolve JIT_BASE from CLAUDE_PROJECT_DIR the same way and had the same exposure with no warning. The helper in scripts/common.sh was already generic; this PR is the wiring and the tests for the other two hooks.

What changed

  • scripts/pre-prompt-hook.sh and scripts/pre-path-hook.sh each export JIT_WORKTREE_NOTE (bash side, mirroring pre-tool-hook.sh's existing PreToolUse:Bash jit-context injection observed serving pre-edit (stale) rule bodies well after the on-disk file was confirmed current #402 wiring verbatim in shape) and add a single-arm awk-side jit_blk_prepend notice block (neither hook has a blocked/block_tail concept, unlike pre-tool-hook.sh -- confirmed by grep, 0 hits for "blocked" in either file).
  • Dedup marker: the issue itself raised as open whether the three hooks should share one marker or keep three. This PR follows each hook's own existing convention instead of inventing a fourth: pre-prompt-hook.sh already shares a "vocab"-keyed shown_file with pre-tool-hook.sh for its jit-refused-config notice, so the new block shares that same marker. pre-path-hook.sh already keeps its own "path"-keyed shown_file isolated for the same notice, so the new block stays isolated too.
  • New #416 sections in tests/test-pre-prompt-hook.sh and tests/test-pre-path-hook.sh, mirroring tests/test-pre-tool-hook.sh's own #402 section: two real git worktrees, one rule name with two different bodies, confirming the wrong-tree body is served and the fix adds the warning -- plus the symmetric AGREE_WT positive control (see Review below).

Tests

RED: hook script changes alone stashed (git stash push -- scripts/pre-prompt-hook.sh scripts/pre-path-hook.sh), tests left in place -- test-pre-prompt-hook.sh 148/151 passed, 3 failed; test-pre-path-hook.sh 96/99 passed, 3 failed. The 3 failures in each file are exactly the new fix-assertions.

GREEN: after git stash pop, 151/151 and 99/99; after the review-driven addition below (commit cbeae82), 153/153 and 101/101.

Review

Two concurrent spawns against commit bfabd6a: a general-purpose reviewer (NO FINDINGS) and oss:auditor (FINDINGS: 1). oss:auditor found the #416 test sections were missing the symmetric AGREE_WT control tests/test-pre-tool-hook.sh's #402 section already has; added and reran green before this PR.

Adjacent, not touched

changelog.d/402.fixed.hook-warns.md's historical text ("pre-prompt-hook.sh and pre-path-hook.sh ... do not yet carry this warning") now reads as stale prose. Left alone: recording state as of merge time is the normal convention for a changelog fragment, and nothing here duplicates or contradicts it misleadingly.

Closes #416

[AI-generated]

Florian DAVID added 2 commits September 18, 2026 07:33
…ree-mismatch warning (#416)

Follow-up to #402/PR #415, which limited itself to pre-tool-hook.sh and said so
explicitly. Both remaining hooks resolve JIT_BASE from CLAUDE_PROJECT_DIR the
same way and had the same exposure with no warning. jit_worktree_mismatch_line()
and jit_worktree_notice() in common.sh were already generic; this is the wiring
for the other two, plus tests reproducing the mechanism against each hook's own
rule dimension (vocabulary, path).

Dedup follows each hook's existing precedent rather than inventing a new marker:
pre-prompt-hook.sh shares its "vocab"-keyed shown_file with the tool hook, same
as its jit-refused-config notice already does; pre-path-hook.sh keeps its own
"path"-keyed shown_file isolated, same as its config_refused/layers_refused
notices already do.

Co-Authored-By: Max <noreply>
oss:auditor self-review finding: the two new #416 test sections each proved
only that an agreeing pair rooted at main stays silent (AGREE_MAIN), not the
symmetric case rooted at the worktree (AGREE_WT) -- the half
tests/test-pre-tool-hook.sh already carries for #402. Without it, a notice
that fired whenever CLAUDE_PROJECT_DIR != $D416/main, rather than on a genuine
two-sided mismatch, would still have passed every assertion.

Co-Authored-By: Max <noreply>
@fdaviddpt
fdaviddpt merged commit 62bb493 into main Sep 18, 2026
13 checks passed
@fdaviddpt
fdaviddpt deleted the fix/416 branch September 18, 2026 06:47
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.

pre-prompt-hook.sh and pre-path-hook.sh carry the same CLAUDE_PROJECT_DIR worktree exposure as #402, with no warning

1 participant