chore(hooks): scope pre-edit-impact to cqs src/ and tests/ (skip vendored Rust)#1068
Merged
Conversation
The hook was matching any path containing `/src/`, which included vendored Rust subtrees like `cuvs-fork-push/rust/cuvs/src/`. When an Edit fired against a cuvs file, the hook tried to invoke `python3 .claude/hooks/pre-edit-impact.py` with cwd=cuvs-fork-push, where that path doesn't exist — silently blocking the Edit with a 'No such file' error. Hit during today's rebase of rapidsai/cuvs#2019 to resolve a merge conflict; had to work around by writing the file via a Python script in Bash. Tighten the path predicate: derive cqs root from the script's own location, then accept only files under `<cqs_root>/src/` or `<cqs_root>/tests/`. cuvs-fork-push, evals/, samples/, and any future vendored Rust subtree all silently bail. Verified with four smoke cases: - cuvs path → exit 0, no `cqs impact` invocation - cqs/src path → exit 0, runs `cqs impact` (no output for hypothetical fns) - cqs/tests path → exit 0, runs `cqs impact` - cqs/evals/*.rs → exit 0, no invocation (not under src/ or tests/) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
The PreToolUse hook for Edit (
pre-edit-impact.py) was matching any path containing/src/, which included vendored Rust subtrees likecuvs-fork-push/rust/cuvs/src/. When an Edit fired against a cuvs file, the hook tried to invokepython3 .claude/hooks/pre-edit-impact.pywith cwd=cuvs-fork-push, where that script doesn't exist — silently blocking the Edit with aNo such fileerror.Hit today during a rebase of rapidsai/cuvs#2019 to resolve a merge conflict — had to work around by writing the resolved file via a Python heredoc in Bash, which is brittle.
Fix
Tighten the path predicate: derive cqs root from the script's own location (
<cqs_root>/.claude/hooks/pre-edit-impact.py→../../), then accept only files under<cqs_root>/src/or<cqs_root>/tests/. Vendored Rust subtrees (cuvs-fork-push, future bundled deps),evals/,samples/, etc. all silently bail before thecqs impactlookup.Test plan
Smoke-tested four scenarios with synthetic hook input:
/mnt/c/Projects/cqs/cuvs-fork-push/rust/cuvs/src/cagra/index.rs/mnt/c/Projects/cqs/src/search/router.rscqs impact/mnt/c/Projects/cqs/tests/router_test.rscqs impact/mnt/c/Projects/cqs/evals/some.rs🤖 Generated with Claude Code