Skip to content

fix(mcp): suggest nearest symbols on node_not_found - #3076

Open
devin-ai-integration[bot] wants to merge 2 commits into
masterfrom
devin/1791127158-node-not-found-suggestions
Open

devin-ai-integration[bot] wants to merge 2 commits into
masterfrom
devin/1791127158-node-not-found-suggestions

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • PrimitiveNotFoundV1 has a new suggestions field (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 one node_not_found_result suggester.
  • The bounded edit distance now lives in 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 with find_symbols. It keeps the 5 closest matches in a BTreeMap keyed by (distance, id). navigation.rs and rename_preview.rs call it.
  • crates/tracedecay-contracts/.../primitive_surface.rs: adds the suggestions field. sdks/typescript/src/operations.ts and plugin/chatgpt-extension/embedded/server.mjs are regenerated (pnpm --dir dashboard run contracts:generate, extension pnpm 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.
  • Unknown ids that have no nearby symbol produce the same JSON as before (existing exact not-found tests pass unchanged).

Test plan

  • New behavior tests against the production MCP surface. Both fail with suggestions forced empty (the old output) and pass with this change:
    • 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 -- --exact
    • bash 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 -- --exact
  • Existing exact not-found tests pass: graph_query_test::test_node_not_found, graph_analysis_test::test_rename_preview_not_found
  • cargo fmt --all -- --check, python3 scripts/linux-test-partitions.py check, pnpm run check:embedded
  • cargo clippy -p <crate> --all-targets -- -D warnings for tracedecay-domain, -contracts, -mcp, -cli

Checklist

  • CHANGELOG.md updated: not done; release-please generates it
  • No secrets, credentials, or .env files included
  • Breaking changes documented: none; the field is additive and left out when empty

Link 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


Devin Review

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>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@changeset-bot

changeset-bot Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d786e1b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

devin-ai-integration[bot]

This comment was marked as resolved.

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

No deployments
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.

graph: suggest nearest symbols on node_not_found

1 participant