fix(mcp): resolve module-qualified symbol lookups (#173)#179
Merged
Conversation
`codegraph_callees stage_apply::run` (and `_node`, `_impact`, ...) returned "not found" against a repo with 7-9 sibling Rust modules, each exporting `pub async fn run`. Two underlying issues: 1. The FTS5 query builder stripped `:` as a special char without splitting on `::`, so `stage_apply::run` collapsed to the literal `stage_applyrun` which matches nothing. Treat `::` as whitespace before the strip step so both halves become FTS tokens. 2. `matchesSymbol` only understood `Parent.child` qualifiers and relied on `qualifiedName` carrying the module path. Rust file- level functions don't have their module name in `qualifiedName` (it's encoded in the file path instead), so even dot-style lookups failed. Accept `::`, `.`, `/` as separators; multi-level forms compose; Rust `crate::`/`super::`/`self::` prefixes get stripped before path matching. Fall back to file-path containment when the qualified-name suffix doesn't match — `stage_apply::run` matches a `run` in any file whose path has a `stage_apply` segment. Also tightens the no-match branch: qualified lookups no longer fall through to a fuzzy text match. `stage_apply::nonexistent_fn` returns `null` instead of silently resolving to an unrelated `rollback` in the same file. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
::as a token separator in the FTS5 query builder sostage_apply::runno longer collapses to the unsearchablestage_applyrunmatchesSymbolto accept::,., and/qualifier syntaxes, fall back to file-path containment whenqualifiedNamedoesn't carry the module hierarchy (Rust / Python), and strip Rust path prefixes (crate,super,self)stage_apply::nonexistent_fnreturnsnullinstead of resolving to an unrelatedrollback__tests__/symbol-lookup.test.tscovering::, multi-level,crate::-prefixed,/-style, bare-name, and the unknown-qualifier caseWhy
#173 —
codegraph_callees stage_apply::runreturned "not found" against a repo with 7-9 sibling Rust modules each exportingpub async fn run. The bare-namerunlookup was reported to silently resolve to an unrelatedrun_due_tasks(already addressed byfindAllSymbolsaggregation in 0.7.x — kept and pinned by test).Root causes:
src/db/queries.ts):as a special char without splitting on::, collapsingstage_apply::runtostage_applyrun::with whitespace before the strip passmatchesSymbol(src/mcp/tools.ts)Parent.child(dot) qualifiers and required the qualifier to appear inqualifiedName::,.,/. Fall back to file-path containment so Rust file-level functions (stage_apply.rs→stage_applymodule) match. Strip Rust path prefixes (crate,super,self)findSymbol(src/mcp/tools.ts)nullfor qualified lookups with no qualifier-respecting matchEnd-to-end verification
Indexed
https://github.com/kernex-dev/kernex-agentat the exact commit7eb5d13from the issue (59 files, 1,340 nodes):Test plan
npx vitest run __tests__/symbol-lookup.test.ts— 9 new testsnpm test— all 599 tests pass (zero regressions inpr19-improvementsdisambiguation tests, search-query-parser, mcp-initialize)npm run build— clean tscCloses #173
🤖 Generated with Claude Code