feat(mcp): Self-healing symbol lookup errors - #28
Merged
Conversation
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.
Motivation
The MCP ergonomics benchmark (docs reviews/2026-08-24-mcp-ergonomics-benchmark.md) identifies
symbol-not-foundas the dominant visible failure class: ×20 occurrences across the corpus (fabric 7, graphology 1, konva turn-2 alone burned 12 misses probing wrong names/kinds). Current misses offer at most 3 prefix/substring hints and no file overview, forcing extra agent round-trips to recover.Design (commander spec, both layers deterministic + byte-stable)
1. Ranked suggestions
Up to 5 candidates scored by best tier:
Ties broken alphabetically; duplicates removed. No new dependencies — a small inline bounded Levenshtein with early exit (
Noneonce any DP row minimum exceeds 2, plus length-difference shortcut).2. Embedded mini-outline on miss
The same isError message appends a capped outline of the file's top-level symbols —
kind namelines sorted by byte position, MAX 20 lines, then... and N morewhen truncated. Nested definitions (e.g. methods inside impl blocks) are skipped via span containment on the position-sorted symbols. Message shape:First line stays exactly
symbol not found: X(pinned by tests). Output depends only on file content + query → byte-stable across runs.3. Range-parse teaching
Invalid
linesranges now state the accepted formats verbatim:invalid range \X`: expected N, N-M, or N-(existinginvalid range` contract preserved for both CLI and MCP paths).Scope
MCP-only enrichment (the CLI symbol error is unchanged); success path untouched. Tests written red-first in tests/mcp_test.rs.
Gates
cargo fmt --check ✓ · cargo clippy --all-features -- -D warnings ✓ · cargo test (285 tests) ✓