Skip to content

fix(plugin): grep guard matches absolute paths — was missing ~97% of real traffic#23

Merged
sdsrss merged 1 commit into
mainfrom
fix/abs-path-matcher
Jun 10, 2026
Merged

fix(plugin): grep guard matches absolute paths — was missing ~97% of real traffic#23
sdsrss merged 1 commit into
mainfrom
fix/abs-path-matcher

Conversation

@sdsrss

@sdsrss sdsrss commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Root cause

SRC_PATH's lookbehind (?:^|\s|["']) never matched absolute paths — and the Claude Code harness explicitly steers Bash toward absolute paths (cd in compound commands triggers permission prompts). Field replay of daagu's 3 real coding sessions (2026-06-11): 42/42 head-greps used absolute paths → 1 hint / 0 block as-is. The v0.27 prefix expansion (backend/, frontend/, …) only ever considered the relative spelling.

Fix

normalizeCommandPaths(cmd, cwd): strip every <cwd>/ occurrence before shouldHint / shouldBlock / extractSearchPath (the hook's cwd IS the project root, so the strip is exact). Paths outside the project remain absolute and keep not firing. Cooldown stays keyed on the raw command. The inline answer's CLI scope arg is passed relative.

Evidence

  • 10 new tests RED→GREEN (131/131): unit + real transcript commands replayed in both spellings + abs-path e2e asserting args=["grep","<pat>","src/storage/"] reaches the CLI relative.
  • Full 42-command daagu corpus replay: hint 1→30, block 0→16.
  • Live smoke in daagu with a real abs-path command: deny embedding real hits (containing fn per hit), answered:true; residue cleaned.

Known limitation (pre-existing, out of scope)

CLI grep shells to ripgrep; rg 14.1.0's gitignore handling diverges from git on dir/ + !negation whitelists (observed in daagu: git-whitelisted scheduler/tasks/ pruned when walking from above). Worst case is the honest no-hits fallthrough — the raw grep is allowed through and finds the truth. Documented in CHANGELOG; candidate follow-up.

🤖 Generated with Claude Code

…real traffic

SRC_PATH's lookbehind (^|\s|quote) never matched absolute paths, but the
CC harness explicitly steers Bash toward them. Field replay (daagu,
2026-06-11, 3 real coding sessions): 42/42 head-greps absolute -> 1 hint /
0 block as-is vs 30 hint / 16 block with this fix. v0.47.0's
answer-in-the-deny was unreachable on consumer projects until now.

Fix: normalizeCommandPaths strips <cwd>/ (hook cwd IS the project root)
before shouldHint/shouldBlock/extractSearchPath; split/join not regex
(cwd may contain metacharacters). Paths outside the project stay absolute
and keep not firing. Cooldown still keyed on the raw command.

Evidence: 10 new tests RED->GREEN incl. real-transcript replays in both
spellings + abs-path e2e asserting relative CLI argv (131/131). Full
42-command daagu corpus replay: hint 1->30, block 0->16. Live daagu smoke:
abs-path config_version grep -> deny embedding real hits with containing
fn, answered:true; residue cleaned.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@sdsrss, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 32 minutes and 44 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 35e99012-e792-4525-b3ef-99acd44d70ba

📥 Commits

Reviewing files that changed from the base of the PR and between b6f4e69 and 8ccf1e8.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • claude-plugin/scripts/pre-grep-guide.js
  • claude-plugin/scripts/pre-grep-guide.test.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/abs-path-matcher

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sdsrss sdsrss merged commit 25d0de2 into main Jun 10, 2026
9 checks passed
@sdsrss sdsrss deleted the fix/abs-path-matcher branch June 10, 2026 19:03
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