Repository navigation
fix(mcp): match search_code file_pattern with a directory against the repo-relative path - #2841
Conversation
… repo-relative path search_code matched file_pattern against the file basename only, so any pattern containing a directory (src/cli/*.c, apps/web/src/**/*.ts) silently returned 0 results, while search_graph's file_pattern matches the full repo-relative path. A file_pattern containing '/' is now matched in C against the repo-relative path of every indexed file, on all platforms, with search_graph-equivalent semantics: '*' and '**' match across '/', '**/' also matches zero directories, '?' matches one character, and a pattern without wildcards is a substring match. Patterns without '/' keep the existing basename behaviour. On Windows such patterns are scanned in process from the already-filtered list instead of the PowerShell -like post-filter. A search with a '/' pattern that returns nothing now carries a hint explaining whole-path matching and pointing at path_filter, and the schema describes both parameters. Refs DeusData#2836 Signed-off-by: Shane McCarron <shane.mccarron@corvexconnect.com>
QA Round 1Scope: Contract Verification
Finding 1 — path_filter hint claims file_pattern "matched nothing" when files matched but the search text did not
Finding 2 — Hint rendering in the default tree/toon output is untested
Summary
No blocking findings. Contract: 6 criteria pass. 1 is partial, because suite-green is left to CI. ObservationsNone. SAST review not applicableTarget QA performed by Claude Code (claude-opus-5-5), manager + 3-lens panel Dispositions (orchestrator, Step 3B)
Verification
QA-Fix-Commit: 73ff216 Posted by the developer account (QA-agent token unavailable). Review by Claude Opus 5.5 (Anthropic) in Claude Code via qa-panel. |
QA Round 2Scope: Contract Verification
Summary
No new findings. The round-1 fix ( Observations
SAST review not applicableTarget QA performed by Claude Code (claude-opus-5-5), manager + 3-lens panel Cycle outcome: round 2 is clean. There are no findings, all contract criteria pass, and the round-1 fix is reviewed. Carried forward: no tree/toon-format test for the hint. Not approved: no QA-agent token is available, and approval is the human reviewer's call. Posted by the developer account (QA-agent token unavailable). Review by Claude Opus 5.5 (Anthropic) in Claude Code via qa-panel. |
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
Thank you, Shane! The directory-aware file_pattern matching is a careful fix for #2836: it mirrors search_graph's path semantics (including One maintainer change so CI covers the current tree: we merged current main into your branch (merge commit 6f63e38, signed off). Main had moved on in src/mcp/mcp.c with an unrelated change, so the earlier green no longer covered the combined tree; the merge was clean and changes nothing in your diff. A fresh CI run is on its way, and we will follow up here once it is through. Please pull before pushing again so your branch keeps this commit. |
|
Merged as 30f1fbf - thank you, Shane! A search_code file_pattern that contains '/' now matches the repo-relative path with the same semantics as search_graph, patterns without '/' keep matching the basename, and a zero-result search says why. Thank you for the careful matcher, the tests, and for filing #2836 first. |
Summary
search_codematchedfile_patternagainst the file basename only. Any pattern containing a directory, such assrc/cli/*.corapps/web/src/**/*.ts, silently returned 0 results, whilesearch_graphmatches the same pattern against the full repo-relative path.Closes #2836
Change (
src/mcp/mcp.c)search_code_path_glob_match. It runs in linear time and doesn't usefnmatch, which Windows lacks.*and**match across/, and**/also matches zero directories.?matches one character.search_graph.write_scoped_filelist: afile_patterncontaining/is matched against the repo-relative path on every platform. Windows separators are normalised first. Patterns without/keep the existing basename behaviour./patterns are scanned in process from the already-filtered list, not by the PowerShell-likepost-filter.cbm_search_code_file_pattern_can_prefilteralready rejects/, so nothing is filtered twice./pattern returns no results, the response carries ahint, in both tree and JSON output. The hint explains that the pattern must match the whole repo-relative path and points atpath_filter.file_pattern("Glob on file name; with '/', on repo-relative path (** = any dirs).") andpath_filter("Regex on repo-relative path.").Acceptance criteria
file_patterncontaining/is matched against the repo-relative path, with**crossing directories (including zero directories).file_patternwithout/keeps the current basename semantics./pattern that yields 0 results returns a hint pointing atpath_filter.file_patternandpath_filter.mcpsuite tests stay green.Known limits
find -name, so a/pattern there returns 0. The hint still fires.*crosses/, and matching is case-sensitive. Both are consistent withsearch_graphand with the existing basename match.Testing
search_code_file_pattern_matches_repo_relative_path_issue2836intests/test_mcp.c, with fixture filessrc/main.candsrc/cli/watcher.c:src/cli/*.c→ 1 matchsrc/**/*.c→ 2**/cli/*.c→ 1src/cli/→ 1watcher.c→ 1*.c→ 2lib/*.c→ 0, with the hintmcp.c, the new test fails, because the four directory patterns return 0 and there is no hint.scripts/test.sh --suites mcp: 397 passed, 4 skipped, 0 failed.🤖 Generated with Claude Code
https://claude.ai/code/session_01CDDUoWEZMNZ9fLvzp2pPGT