Repository navigation
fix(hooks): make integrity messages match what was checked (fixes #5039) - #5058
Open
IG-ABHINAV wants to merge 1 commit into
Open
IG-ABHINAV wants to merge 1 commit into
IG-ABHINAV wants to merge 1 commit into
Conversation
The tamper message named ~/.claude even when CLAUDE_CONFIG_DIR pointed elsewhere; print the path actually verified. A damaged baseline stopped the command with the error alone, so name the command that rewrites it. runtime_check returned before verify_hook_at whenever the hook was missing, so the documented OrphanedHash warning could never print.
|
|
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.
Fixes #5039.
What / why
Three integrity messages in
src/hooks/integrity.rsdo not match what actually happened:~/.claude/hooks/...even whenCLAUDE_CONFIG_DIRpoints somewhere else — so with a custom config dir the message names a file that was never checked.Invalid hash format ...) stops the command with the error alone; there is no hint thatrtk init -g --auto-patchis what rewrites it, even though the docs promise one.runtime_checkreturns early whenever the hook file is missing, so the documentedOrphanedHashwarning ("hash file exists but hook is missing") can never print — an orphaned baseline is indistinguishable from nothing installed.Approach
hook_path.display()in the tampered message instead of the hardcoded~/.claudeprefix.verify_hook_atfailures with\n To restore: rtk init -g --auto-patch(the original first line is preserved, so existing assertions still match).!hook_path.exists()return so the orphaned-hash warning is emitted;NotInstalledstays silent.Tests
cargo fmt --all -- --check→ PASScargo clippy --workspace --all-targets→ PASS (0 lints; changed file confirmed linted)cargo test --all --no-fail-fast→ 5155 passed / 6 failed / 8 ignoredcargo test --lib hooks::integrity→ 20 passed, 0 failed (includes the 2 new unit tests)bash scripts/check-test-presence.sh origin/develop→ OKThe 6 failures are proven pre-existing: the identical command set on a clean
origin/develop(08a261a) fails the same 5 targets with the same 6 tests (find_cmdexit-status,read_lines_lossyUTF-8,help_passthrough_fuzz_test, plus 3 flaky targets —git_ls_tree_test,go_test_pipe_test,rewrite_shell_wrapper_testfail on a different individual test each run on both base and branch).Manual end-to-end on Windows (
target/debug/rtk.exe,CLAUDE_CONFIG_DIR=<tmp>/.claude):~/.claudeanywhere;.rtk-hook.sha256=not a hash→Invalid hash format ...followed byTo restore: rtk init -g --auto-patch;rtk: warning: hash file exists but hook is missing+Run \rtk init -g` to reinstall.`, command still exits 0.Judgment call: I kept the restore hint on the error path only (not on warnings) so routine output stays quiet — say the word if you would rather have it on the orphaned-hash warning too.