Skip to content

feat(server): suggest near slugs when a direct read finds no entity - #211

Merged
yordis merged 2 commits into
TrogonStack:mainfrom
enilsen16:enilsen16/feat-not-found-suggestions
Oct 20, 2026
Merged

yordis merged 2 commits into
TrogonStack:mainfrom
enilsen16:enilsen16/feat-not-found-suggestions

Conversation

@enilsen16

@enilsen16 enilsen16 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When a direct read does not find an entity, the error says only entity not found. The caller must list or search to find the correct slug. For example, get_slice_projection for command_slice acme-storefront/place-order fails, but the slug is place-order-slice.

Change

  • The server adds did_you_mean to the NOT_FOUND ErrorInfo metadata. The value is up to 3 comma-separated slugs, closest first. The slugs have the same kind and the same namespace as the request. A prefix or substring match ranks above an edit-distance match.
  • Only these four direct reads add suggestions: get_entity, get_slice_projection, get_storyboard_projection and get_event_model_projection (live read only, not as_of_changeset).
  • The suggestions come only from the caller's lensed snapshot, and only after require_visible passes. A namespace that the caller cannot see still gets the bare NOT_FOUND, so a lookup cannot show what the namespace contains.
  • Failure::from_reason in the client copies did_you_mean into the failure details as a list. MCP shows it as next_action_detail.did_you_mean with no MCP change.
  • The ranking is a small pure function (trogon-atlas-server/src/suggest.rs). The workspace has no string-distance crate, so this change adds none.
  • docs/reference/failure-reasons.md documents the new metadata.

Test

  • suggest.rs unit tests: a missing suffix ranks above a closer typo; only the same kind and namespace are suggested; at most 3 distinct slugs; an unrelated slug is not suggested.
  • failure.rs unit test: did_you_mean metadata becomes a list in the details.
  • tests/cross_tenant_reads.rs: the owner gets did_you_mean for a near slug, and a caller who cannot see the namespace gets NOT_FOUND with no did_you_mean.
  • cargo test -p trogon-atlas-server -p trogon-atlas-client -p trogon-atlas-mcp -p trogon-atlas-cli and cargo clippy -p trogon-atlas-server -p trogon-atlas-client --all-targets -- -D warnings pass.

Follow-up for the maintainer

Other not-found paths still return the bare error. They can use the same read_err helper if you want them:

  • get_outgoing_references, export_event_model_manifests, validate_event_model, diff_entities (both sides)
  • retarget_references (the to target) and the put_entity read
  • the as_of_changeset path of get_event_model_projection
  • get_changeset, revert_changeset and the changeset lookups in snapshot_as_of / baseline_changesets_after (these are ids, not slugs, so a slug ranking may not fit)

Closes #77


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Signed-off-by: Erik Nilsen <enilsen16@live.com>
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e9ebb37a-60a9-43bf-8306-5c91c3288598
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@enilsen16
enilsen16 marked this pull request as ready for review October 20, 2026 15:19
@cursor

cursor Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Suggestions are derived from visibility-filtered snapshots, but they still leak slug names within readable namespaces on not-found paths, so tenancy and ranking behavior need to stay correct.

Overview
Direct reads that miss an entity can now return did_you_mean on NOT_FOUND ErrorInfo metadata: up to three comma-separated slugs (same kind and namespace, ranked by prefix/substring then edit distance). get_entity, get_slice_projection, get_storyboard_projection, and live get_event_model_projection route store NotFound through a new read_err helper that builds suggestions from the caller’s lensed snapshot only after require_visible passes, so hidden namespaces still get a bare not-found.

The server adds suggest::did_you_mean and conv::not_found_with_suggestions. Failure::from_reason in the client splits the metadata into a did_you_mean list in failure details (surfacing on MCP as next_action_detail.did_you_mean). docs/reference/failure-reasons.md documents the metadata.

Reviewed by Cursor Bugbot for commit 8a91321. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Erik Nilsen <enilsen16@live.com>
@yordis
yordis merged commit 8d1b2d1 into TrogonStack:main Oct 20, 2026
27 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.

Not-found errors do not suggest the slug the caller probably meant

2 participants