Skip to content

Fix standalone constraints in multi_grep - #753

Merged
dmtrKovalenko merged 3 commits into
dmtrKovalenko:mainfrom
Kh05ifr4nD:fix/multi-grep-standalone-constraints
Aug 15, 2026
Merged

dmtrKovalenko merged 3 commits into
dmtrKovalenko:mainfrom
Kh05ifr4nD:fix/multi-grep-standalone-constraints

Conversation

@Kh05ifr4nD

@Kh05ifr4nD Kh05ifr4nD commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

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 unmatched constraints from broadening search results.
    • Standardized empty multi-pattern results to display “0 matches.”
    • Applied consistent constraint handling across supported search interfaces.
  • 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: d67cbfea-3443-4a26-ae4e-4d74e5861bb4

📥 Commits

Reviewing files that changed from the base of the PR and between 33b8cc2 and 1fbb431.

📒 Files selected for processing (1)
  • crates/fff-core/src/grep/prefilter.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

Mergeability Score: ⚪ Minimal · up to 1fbb4

The PR updates multi-pattern constraint handling and removes an unsupported fallback; no actionable merge-blocking risk remains.

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 describes the main 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 All changes support standalone constraint parsing, strict multi-pattern filtering, preserved grep behavior, or regression coverage.
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.

Comment thread crates/fff-core/src/grep/prefilter.rs Outdated
@dmtrKovalenko
dmtrKovalenko merged commit ffd8eb9 into dmtrKovalenko:main Aug 15, 2026
52 of 53 checks passed
abhijit-s pushed a commit to abhijit-s/fff that referenced this pull request Aug 17, 2026
Sync of dmtrKovalenko/fff (b71b7cf..be2dd8d). Notable upstream work:
LMDB env lifecycle overhaul — one shared env per canonical path per
process (dmtrKovalenko#775) plus a new env_pool with raised max_readers to avoid
MDB_READERS_FULL (dmtrKovalenko#783); standalone constraints in multi_grep (dmtrKovalenko#753);
a parent-liveness watcher so the MCP no longer exits while its parent
is alive (dmtrKovalenko#770); file-picker rebuild after FFFClearCache (dmtrKovalenko#772);
readOnlyHint on all tools (dmtrKovalenko#771); and pi-fff global config (dmtrKovalenko#790).

Why these resolutions:

- Version: our workspace is 0.18.0; upstream bumped 0.10.3 -> 0.10.5.
  Kept 0.18.0 in every Cargo.toml/Cargo.lock version conflict while
  preserving upstream's non-version additions (zlob =1.6.3, fff-core
  crate-type = ["rlib"], fff-mcp windows-sys target dep for the new
  Windows parent watcher).

- dbs/ module: the dbs/ reorg already lives in our shared merge base,
  so this sync only adds upstream's new env_pool.rs (additive, no
  rename conflict). Our eviction feature already targets dbs/.

- dmtrKovalenko#775 shared-env x our idle/stale root eviction (f40b086): verified
  compatible. Eviction drops EngineState (hence FrecencyTracker's
  SharedEnv) via Drop only — it never calls SharedEnv::destroy and
  never deletes on-disk data.mdb (the only file removal in env_pool is
  the size-cap guard). Dropping the last holder closes the env; a
  re-register reopens the same canonical path from the process pool,
  so per-slug frecency persists across an evict -> re-register cycle.
  Eviction machinery unchanged: last_access_ms stamping, drop_root's
  Arc::strong_count>1 live-connection guard, the reaper phases,
  idle_root_ttl_secs config, RootHealth.last_access_age_sec (kept the
  appended-LAST field for bincode order), and the ctl IDLE column.

- fff-mcp/Cargo.toml: unioned our fff-ipc/dirs/libc deps, clap_complete,
  and [package.metadata.deb] with upstream's new windows-sys target
  block; dev tempfile pinned to upstream's 3.8.

- fff-mcp/src/main.rs: kept our set-log-level/completions args and
  added upstream's `mod parent;`, taking upstream's reworded
  idle-timeout doc comment.

- multi_pattern.rs: three-way merge kept both our `recheck` field and
  upstream's prefilter_files standalone-constraint path.

- Makefile: unioned upstream's build-e2e target with our daemon targets.

- release.yaml: kept our publishing guards (PyPI gated to upstream's
  owner; crates.io and npm disabled via `if: false`).

- install-mcp.sh: kept the pinned-tag + SHA256 block removed (we ship
  via Homebrew/apt); upstream's re-add discarded.

Build: cargo build -p fff-mcp -p fff-engine -p fff-ctl green.
Tests: 480 passed / 0 failed across fff-search, fff-engine, fff-ipc,
fff-ctl, including lmdb_env_pool (4), lmdb_readers_full_repro (2), and
lmdb_stale_lock_deadlock (4).
abhijit-s pushed a commit to abhijit-s/fff that referenced this pull request Aug 17, 2026
Second stable release. Captures the idle/stale on-demand-root eviction
feature and two upstream syncs since 0.18.0 (4-commit + 17-commit rounds),
including LMDB shared-env-per-path (dmtrKovalenko#775), raised max_readers (dmtrKovalenko#783),
multi_grep standalone constraints (dmtrKovalenko#753), and MCP parent-liveness (dmtrKovalenko#770).
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

2 participants