Skip to content

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

Merged
ScriptedAlchemy merged 3 commits into
masterfrom
devin/1791127158-node-not-found-suggestions
Oct 5, 2026
Merged

ScriptedAlchemy merged 3 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. The field is a PrimitiveSymbolLocationV1[] and is omitted when empty. It lists up to five served symbols within a bounded edit distance, clamp(len/3, 1, 3), of the requested ID, simple name, or qualified name. Results are ordered nearest first.
  • Misses from tracedecay_node, tracedecay_impact, and rename preview now use the same node_not_found_result suggester.
  • The bounded edit-distance function now lives in tracedecay_domain::text::edit_distance_within. The CLI's nearest-tool lookup uses it instead of a separate implementation.

Fixes #3014

Motivation

A miss returned only "Node not found." A caller who mistyped an ID or passed a name received no useful next step. 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 five 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 with pnpm --dir dashboard run contracts:generate and the extension's pnpm run build. The embedded schema rejects unknown properties, so the bundle must be rebuilt.
  • crates/tracedecay-domain/src/text.rs: adds edit_distance_within and its unit tests.
  • Unknown IDs with no nearby symbol produce the same JSON as before. The existing exact not-found tests pass unchanged.

Test plan

  • New behavior tests against the production MCP interface. Both fail when suggestions are forced empty, which matches 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, and -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 omitted 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

@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: a82c064

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.

ScriptedAlchemy and others added 3 commits October 5, 2026 14:42
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>
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>
@ScriptedAlchemy
ScriptedAlchemy force-pushed the devin/1791127158-node-not-found-suggestions branch from 6b6da45 to a82c064 Compare October 5, 2026 21:50
@ScriptedAlchemy
ScriptedAlchemy merged commit 8e4fd14 into master Oct 5, 2026
4 of 8 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.

graph: suggest nearest symbols on node_not_found

1 participant