Skip to content

chore(hooks): scope pre-edit-impact to cqs src/ and tests/ (skip vendored Rust)#1068

Merged
jamie8johnson merged 1 commit into
mainfrom
chore/scope-pre-edit-hook
Apr 21, 2026
Merged

chore(hooks): scope pre-edit-impact to cqs src/ and tests/ (skip vendored Rust)#1068
jamie8johnson merged 1 commit into
mainfrom
chore/scope-pre-edit-hook

Conversation

@jamie8johnson
Copy link
Copy Markdown
Owner

Summary

The PreToolUse hook for Edit (pre-edit-impact.py) 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 script doesn't exist — silently blocking the Edit with a No such file error.

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 the cqs impact lookup.

Test plan

Smoke-tested four scenarios with synthetic hook input:

Path Expected Got
/mnt/c/Projects/cqs/cuvs-fork-push/rust/cuvs/src/cagra/index.rs silent exit 0
/mnt/c/Projects/cqs/src/search/router.rs runs cqs impact
/mnt/c/Projects/cqs/tests/router_test.rs runs cqs impact
/mnt/c/Projects/cqs/evals/some.rs silent exit 0

🤖 Generated with Claude Code

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>
@jamie8johnson jamie8johnson merged commit 841f0f3 into main Apr 21, 2026
8 checks passed
@jamie8johnson jamie8johnson deleted the chore/scope-pre-edit-hook branch April 21, 2026 01:49
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.

1 participant