fix(mcp): suggest nearest symbols on node_not_found - #3076
Open
devin-ai-integration[bot] wants to merge 2 commits into
Open
devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
PrimitiveNotFoundV1 now carries up to five served symbols within a bounded edit distance of the requested id, simple name, or qualified name. Node, impact, and rename-preview misses share one suggester, and the CLI's nearest-tool lookup reuses the same bounded edit distance from tracedecay-domain. Fixes #3014 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Unbound edge targets have no extraction metadata or logical file, so symbol_location cannot render them; admitting one turned a not-found answer into a graph-corrupt error. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This branch has not been deployed
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
PrimitiveNotFoundV1has a newsuggestionsfield (PrimitiveSymbolLocationV1[], left out when empty). It lists up to 5 served symbols within a bounded edit distance (clamp(len/3, 1, 3)) of the requested id, simple name, or qualified name, nearest first.tracedecay_node,tracedecay_impact, and rename-preview misses all go through the onenode_not_found_resultsuggester.tracedecay_domain::text::edit_distance_within. The CLI's nearest-tool lookup uses it in place of its own copy.Fixes #3014
Motivation
A miss only returned "Node not found", so a caller who mistyped an id or passed a name had nothing to go on. See #3014.
Changes
crates/tracedecay-mcp/src/handlers/graph/mod.rs:node_not_found_result(graph, node_id, occurrence)makes one cancellation-aware pass over the catalog withfind_symbols. It keeps the 5 closest matches in aBTreeMapkeyed by(distance, id).navigation.rsandrename_preview.rscall it.crates/tracedecay-contracts/.../primitive_surface.rs: adds thesuggestionsfield.sdks/typescript/src/operations.tsandplugin/chatgpt-extension/embedded/server.mjsare regenerated (pnpm --dir dashboard run contracts:generate, extensionpnpm run build). The embedded schema rejects unknown properties, so the bundle has to be rebuilt.crates/tracedecay-domain/src/text.rs:edit_distance_within, with unit tests.Test plan
bash scripts/require-exact-test.sh cargo test -p tracedecay --features test-transport --test mcp_suite mcp_handler_test::node_behavior_test::tracedecay_node_suggests_the_nearest_symbols_for_an_unknown_id -- --exactbash scripts/require-exact-test.sh cargo test -p tracedecay --features test-transport --test mcp_suite mcp_handler_test::impact_behavior_test::impact_reports_callers_by_depth_and_refuses_invalid_requests -- --exactgraph_query_test::test_node_not_found,graph_analysis_test::test_rename_preview_not_foundcargo fmt --all -- --check,python3 scripts/linux-test-partitions.py check,pnpm run check:embeddedcargo clippy -p <crate> --all-targets -- -D warningsfor tracedecay-domain, -contracts, -mcp, -cliChecklist
CHANGELOG.mdupdated: not done; release-please generates it.envfiles includedLink to Devin session: https://app.devin.ai/sessions/cd07d7e34d024ed2aef8a0c58184660f
Open in Devin Desktop: https://app.devin.ai/desktop/session/cd07d7e34d024ed2aef8a0c58184660f?variant=devin
Requested by: @ScriptedAlchemy