Skip to content

Fix standalone constraints in multi_grep - #753

Open
Kh05ifr4nD wants to merge 2 commits into
dmtrKovalenko:mainfrom
Kh05ifr4nD:fix/multi-grep-standalone-constraints
Open

Fix standalone constraints in multi_grep#753
Kh05ifr4nD wants to merge 2 commits into
dmtrKovalenko:mainfrom
Kh05ifr4nD:fix/multi-grep-standalone-constraints

Conversation

@Kh05ifr4nD

@Kh05ifr4nD Kh05ifr4nD commented Aug 8, 2026

Copy link
Copy Markdown

Fixes #738.

Supersedes #739 with a configuration-level fix.

multi_grep receives patterns and constraints separately, but its adapters parsed the constraint field as an ordinary grep query. A lone path could become search text and disappear before the search. Exact-file misses could then discard the file constraint during prefiltering and search the wider index.

Parse the dedicated constraint field directly and keep multi-pattern prefiltering strict. Ordinary grep retains its existing query parsing and filename retry. The unsupported plain-grep fallback is removed.

Verified with the Rust workspace tests, Clippy, rustfmt, a release build, and MCP stdio cases covering directory, glob, exact and missing files, exclusions, and OR matching.

Summary by CodeRabbit

  • Bug Fixes

    • Improved multi-pattern searches with file path and directory constraints.
    • Searches now correctly return no matches when constraints match no indexed files.
    • Prevented constraint misses from broadening search results.
    • Standardized empty multi-pattern results to display “0 matches.”
  • Tests

    • Added regression coverage for unmatched file path constraints and multiple standalone constraints.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 337b9681-d3fd-4727-873a-b2027291a0fb

📥 Commits

Reviewing files that changed from the base of the PR and between 2107f03 and 33b8cc2.

📒 Files selected for processing (7)
  • crates/fff-c/src/lib.rs
  • crates/fff-core/src/grep/multi_pattern.rs
  • crates/fff-core/src/grep/prefilter.rs
  • crates/fff-core/tests/path_separator_constraint_test.rs
  • crates/fff-mcp/src/server.rs
  • crates/fff-python/src/finder.rs
  • crates/fff-query-parser/src/parser.rs

📝 Walkthrough

Walkthrough

The PR adds direct standalone constraint parsing, applies constraints through the multi-pattern prefilter, removes MCP fallback searching, updates C and Python integrations, and adds parser and path-filter regression tests.

Changes

Constraint Parsing and Multi-Grep Integration

Layer / File(s) Summary
Standalone constraint parser
crates/fff-query-parser/src/parser.rs
Adds QueryParser::parse_constraints and tests directory, file-path, and multiple standalone constraint handling across parser configurations.
Constraint-aware prefiltering
crates/fff-core/src/grep/multi_pattern.rs, crates/fff-core/src/grep/prefilter.rs, crates/fff-core/tests/path_separator_constraint_test.rs
Uses prefilter_files for multi-pattern constraint filtering, exposes it to the parent module, and tests that missing FilePath constraints return no matches.
Frontend constraint integration
crates/fff-c/src/lib.rs, crates/fff-mcp/src/server.rs, crates/fff-python/src/finder.rs
Passes directly parsed constraints to multi_grep and removes the MCP individual-pattern fallback and special empty-result handling.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: dmtrkovalenko

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the fix for standalone constraints in multi_grep.
Linked Issues check ✅ Passed The changes parse standalone constraints directly, enforce strict filtering, preserve grep behavior, and add regression coverage for issue #738.
Out of Scope Changes check ✅ Passed The changes support the constraint-parsing fix and its regression coverage; no unrelated code changes are evident.
Docstring Coverage ✅ Passed Docstring coverage is 90.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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.

[Bug]: multi_grep drops standalone positive path constraints

1 participant