Conversation
grep -v prints the lines that do not match, but the SQL prefilter still asked the backend only for rows containing the pattern. A memory file that never mentions the pattern, whose every line grep -v should print, was dropped before the line-by-line inversion ran. Skip the content prefilter for an inverted match and keep only the path filter.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: activeloopai/hivemind/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughInverted grep now scans content without literal, alternation, or multi-word prefilters. A regression test checks output from files returned by the SQL prefilter and files omitted from its results. ChangesInverted grep
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change appears ready to merge after normal checks; no actionable risk is established by the supplied evidence. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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
grep -v foo <dir>should print every line that does not containfoo. That includes all lines of files that never mentionfoo.buildGrepSearchOptions(src/shell/grep-core.ts) ignoredinvertMatch. It still sent the normal content prefilter (summary::text ILIKE '%foo%'/message::text ILIKE '%foo%'), so the backend only returned rows that contain the pattern. Files without it were dropped beforerefineGrepMatchescould invert anything.Reproduction on
ce30de7, going through the sameparseBashGrep→handleGrepDirectpath the pre-tool-use hook uses (lexical mode,HIVEMIND_SEMANTIC_SEARCH=false). The fake backend applies the ILIKE filter:With a single matching file the result is also wrong:
grep -v foo /summaries/b.mdreturns(no matches)instead of the whole file.Fix: when
invertMatchis set,buildGrepSearchOptionskeeps only the path filter. It skips the content, prefilter and multi-word filters, and the line-by-line refinement does the inversion. Thegrep-interceptorshell path and the hook fast path both use this builder, so both are fixed. Non-inverted searches are unchanged.Out of scope: in semantic mode (an embedding is available), both paths emit every line of the top-K rows and don't apply
-v. That is the existing semantic design, and this PR doesn't change it.This PR adds a regression test in
tests/claude-code/grep-core.test.ts. It fails onmainbecauseb.mdis missing, and it passes with the fix.Version Bump
Not bumped. This is a patch-level bug fix, so I've left the release decision to you.
Test plan
npm test): 5823 passed. The 17 failures are the same on the untouchedmaincheckout and come from the environment: cowork-queue-leak, install-cowork, skillify-state, plugin-cache-gc-bundle, and two graph suites.grep -v keeps files that never contain the pattern. It fails onmainand passes on this branch.npm run typecheckpasses.grep-core,grep-direct,grep-interceptor,mcp-serverand the openclaw tools suites all pass (285 tests).package.json, or no release needed for this changeAn AI agent (breken-ai) found this and wrote the fix and test. I reviewed and ran everything above before opening the PR.
Summary by CodeRabbit
grep -v) so they return nonmatching lines from files that contain the search term, as well as lines from files without it. This improves results when searching across scoped summary files.