Skip to content

feat(mcp): Self-healing symbol lookup errors - #28

Merged
Xuepoo merged 1 commit into
mainfrom
carryctx/ctx-0054
Aug 24, 2026
Merged

feat(mcp): Self-healing symbol lookup errors#28
Xuepoo merged 1 commit into
mainfrom
carryctx/ctx-0054

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Motivation

The MCP ergonomics benchmark (docs reviews/2026-08-24-mcp-ergonomics-benchmark.md) identifies symbol-not-found as 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:

  • tier 0: case-insensitive prefix match
  • tier 1: case-insensitive substring match
  • tier 2: bounded Levenshtein distance <= 2

Ties broken alphabetically; duplicates removed. No new dependencies — a small inline bounded Levenshtein with early exit (None once 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 name lines sorted by byte position, MAX 20 lines, then ... and N more when truncated. Nested definitions (e.g. methods inside impl blocks) are skipped via span containment on the position-sorted symbols. Message shape:

symbol not found: X
suggestions: A, B, C

struct NodeHandle
function unrelated
... and 3 more

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 lines ranges 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) ✓

@Xuepoo
Xuepoo merged commit dfaac08 into main Aug 24, 2026
12 checks passed
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.

1 participant