fix(pi-fff): use exact aux finder for external paths - #713
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes incorrect reuse of “covering” auxiliary finders for explicit external paths by requiring an exact-root aux finder, preventing false negatives (and unrelated fuzzy fallback results) when broader aux roots exclude the requested subtree (e.g. node_modules).
Changes:
- Acquire auxiliary finders with
{ exact: true }for outside-workspace path routing and simplify query construction by removing ancestor-root rebasing. - Add a regression test that warms a broad aux finder, then verifies an explicit external file path forces creation/use of an aux finder rooted at the target directory.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/pi-fff/src/index.ts | Switches external-path routing to exact aux-root acquisition and removes rebasing logic so the query matches the requested root. |
| packages/pi-fff/test/extension.test.ts | Adds an extension-level regression test ensuring explicit external file paths create/reuse an exact-root finder and return matches from the target file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const grep = tools.get("ffgrep"); | ||
| await grep.execute("warmup", { pattern: "warmup", path: broadRoot }); | ||
| const result = await grep.execute("repro", { |
|
@gustav-fff review |
|
[triage-bot] DIRECTED: Reviewed dc9301f. Correctness. Fix is right for #711. Rebasing a suffix onto a broader cached finder can never recover files the broader index excluded via gitignore ( Perf tradeoff worth flagging. With Nit (Copilot's point, valid). Cross-repo PR from a fork — cannot push. Suggested diff: ```ts Verified locally: `bun test test/extension.test.ts` — 9 pass. Typecheck skipped (`tsc` unavailable in triage env; PR author already ran it). Honk-Honk 🪿 |
Closes #711.
Root cause
resolveFinderForPath()reused any cached auxiliary finder whose root covered the requestedroute.root.A broader finder such as
~/.pican exclude nested directories likenode_moduleswhile building its index. Rebasing the query suffix relative to that broader root cannot recover files that were never indexed. When the exact search returned no matches, fuzzy fallback could also return unrelated files from the broader index.Fix
Acquire the exact requested auxiliary root for explicit paths outside the workspace:
Since exact acquisition guarantees that the finder is rooted at
route.root, build the query directly fromroute.suffixand remove the obsolete ancestor-root rebasing logic.Add an extension-level regression test that first caches a broader finder, then searches an absolute file path under its ignored
node_modulessubtree. The test verifies that a finder rooted at the target directory is created and the requested file is returned.Steps to reproduce
Start Pi in a workspace outside
~/.pi, ensure an auxiliary finder rooted at~/.pihas already been cached, then run:{ "pattern": "randomUUID", "path": "/Users/example/.pi/agent/npm/node_modules/@tintinweb/pi-subagents/src/agent-manager.ts", "limit": 3 }~/.pifinder is reused, but its index excludesnode_modules; the requested file is missed and fuzzy fallback may return unrelated files.How verified
cd packages/pi-fff && bun test test/extension.test.ts— 9 passedcd packages/pi-fff && bun run typecheckThe full pi-fff suite on Windows reported 38 passed and 9 existing failures in
aux-finders.test.tsandaux-pool.test.ts; those tests use hard-coded POSIX paths such as/tmpand/a/b.