feat(plugin): answer in the deny — denied greps return actual results#22
Conversation
When pre-grep-guide denies a symbol-shaped raw grep, run the AST-aware
equivalent (code-graph-mcp grep, ~20ms warm, 2s timeout) synchronously
inside the hook and embed the results in the deny reason. Measured
recommend->use transfer of suggestion-style interventions is ~0%; results
already in front of the model bypass that choice entirely.
Three outcomes: hits -> deny with embedded results (4KB line-boundary
truncation, recs answered:true); CLI unavailable/error/timeout -> v0.46
static deny (answered:false); 0 hits -> ALLOW with one-line FYI
(fallthrough:"no-hits") since regex-dialect differences mean 0 hits is
not proof of absence. Opt-out: CODE_GRAPH_NO_ANSWER_IN_DENY=1.
Verified non-polluting: CLI grep does not write usage.jsonl, so
hook-initiated runs cannot inflate the deny->use funnel. Rust untouched
(answered/fallthrough are additive JSONL fields readers ignore).
Also hardens hook stdin: read fd 0 instead of /dev/stdin (path form
fails silently on socketpair stdin, e.g. spawnSync({input}) harnesses).
additive: new-test-first, no prior failing path (35 new tests RED->GREEN;
121/121 pre-grep-guide + 14/14 cg-answer; live smoke against real repo
index embedded real extract_relations hits, residue cleaned).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR implements the v0.47.0 "deny-with-answer" feature for the pre-grep-guide hook. A new ChangesDeny-with-Answer Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Summary
When
pre-grep-guide.jsdenies a symbol-shaped raw grep, run the AST-aware equivalent (code-graph-mcp grep "<pattern>" [path], ~20ms warm, 2s timeout) synchronously inside the hook and embed the actual results in the deny reason. Measured recommend→use transfer of suggestion-style interventions is ~0% — the model rarely initiates a new tool call because a message told it to, but it will use results already in front of it.Behavior
{action:"deny", answered:true}{action:"deny", answered:false}{action:"hint", fallthrough:"no-hits"}Opt-out:
CODE_GRAPH_NO_ANSWER_IN_DENY=1(restores v0.46 static deny).CODE_GRAPH_NO_BLOCK_GREP=1unchanged.Metric integrity
grepsubcommand does NOT writeusage.jsonl→ hook-initiated runs cannot inflate the deny→use funnel.Deny→usereads LOW by design — segment byanswered.answered/fallthroughare additive JSONL fields existing readers ignore.Also
/dev/stdin(path form fails silently on socketpair stdin, e.g.spawnSync({input})harnesses; real Claude Code pipes unaffected).grep -rn "extract_relations" src/parser/produced a deny embedding real hits with containing fn/module; smoke residue cleaned.🤖 Generated with Claude Code
Summary by CodeRabbit