Skip to content

Classify semantic search failures by structured error variant (closes #2798) - #3770

Merged
malibio merged 2 commits into
mainfrom
issue-2798-structured-error-kinds
Oct 13, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-2798-structured-error-kinds

Conversation

@malibio

@malibio malibio commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds NodeServiceError::EmbeddingUnavailable, produced by query_embedding_error for an unloaded / failed-to-load / integrity-failed model.
  • Replaces the err_msg.contains(...) chain in search_ops with semantic_search_error, a match on the variant. An empty or over-long query now returns InvalidParams rather than Internal("Search failed: ...").
  • Scope was narrowed with the maintainer: findings 2 and 3 of the issue reference code that no longer exists (resolve_forward_segment, create_*_resolving_collisions), so they are not addressed.

Test plan

  • Unit tests for the variant mapping, including message text that would have tripped the old substring checks
  • bun run test:changed (rust, scripts, types:check, node-types:check)

🤖 Generated with Claude Code

@malibio

malibio commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

Net positive and correctly scoped to Finding 1. Replacing four .contains() substring checks with a match on structured variants is the right fix, the new EmbeddingUnavailable variant is minimal, and the test deliberately feeds misleading message text to prove the variant decides. No backward-compat code, suppressions, or issue numbers in comments. The compiler enforces the only exhaustive match (From<NodeServiceError> for OpsError), and nothing in daemon/CLI/agent/frontend matches on the old strings (the hits in relationship-field.svelte / base-node.svelte are unrelated "not found" UI text; embedding_service_test.rs:2289 is a stale comment only). Other NodeServiceError matches (playbook, markdown, schema) all use specific arms and are unaffected. One doc-comment regression to fix before merge.

Findings

Critical Issues

  • None.

Suggested Improvements

  • [Improvement] packages/core/src/ops/search_ops.rs ~L62-82: semantic_search_error was inserted between the doc comment of should_skip_scope_filter ("An empty list names no type...") and the function it documents. Rustdoc now glues that paragraph onto semantic_search_error, and should_skip_scope_filter loses its documentation. Move the new fn above that doc block (or below should_skip_scope_filter).
  • [Improvement] search_ops.rs NodeServiceError::NodeNotFound arm: nothing on the semantic_search_nodes path produces NodeNotFound (the only node_not_found in embedding_service.rs is in embed_root_node, L410), and the old "no embeddings" string never had a producer either. The arm preserves a user-facing "No content available..." message that is effectively unreachable, and if some future dependency did return NodeNotFound it would be misreported as a caller error. Consider dropping it (YAGNI) and letting it fall to the generic arm, or confirm a real producer.
  • [Improvement] Behaviour note worth stating in the PR description: with include_title_matches the Err(e) if include_title_matches branch still swallows InvalidParams (empty / over-long query) and serves keyword-only results, so the new InvalidParams is only surfaced when keyword search is off. That is unchanged from before (it swallowed Internal), but it means an over-long query silently degrades instead of reporting the validation problem; decide whether InvalidParams should be excluded from the degrade path.

Nitpicks

  • Nit: semantic_search_error maps every QueryFailed to "Database error during search", where before "KNN search failed: ..." fell through to "Search failed". Harmless and arguably more accurate; just be aware the message changed.
  • Nit: ops/mod.rs EmbeddingUnavailable arm yields "Embedding service unavailable: ..." while the search path yields "Embedding service not ready"; two phrasings for one condition. Fine, but one wording would be tidier.

Verdict

Approve after the doc-comment placement is fixed; the other items are optional.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: approve once the misplaced doc comment on should_skip_scope_filter / semantic_search_error is fixed (see review comment). No blockers otherwise; remaining items are optional improvements.

@malibio

malibio commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed review: moved semantic_search_error below should_skip_scope_filter (doc comment misplacement) and dropped the unreachable NodeNotFound arm plus its test assertion.

Skipped: (3) degrade path swallowing InvalidParams when include_title_matches is set — pre-existing behaviour (it swallowed Internal too) and out of scope; revisit if a user-visible empty-query case appears. Nits (QueryFailed wording, unavailable/not-ready phrasing) are cosmetic.

Re-review: not needed — a doc-comment move and removal of a dead arm, no logic change on reachable paths.

malibio and others added 2 commits October 13, 2026 10:05
…ssage text (closes #2798)

Add NodeServiceError::EmbeddingUnavailable for a model that is not loaded,
produce it from query_embedding_error, and replace the .contains() chain in
search_ops with a match on the variant.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…le NodeNotFound arm

- Moved semantic_search_error below should_skip_scope_filter so the doc block
  stays attached to the function it describes.
- Dropped the NodeNotFound arm: nothing on the semantic_search_nodes path
  produces it, so it kept a dead message alive.

Skipped: degrade path swallowing InvalidParams under include_title_matches
(pre-existing behaviour, out of scope); QueryFailed wording and the
unavailable/not-ready phrasing nits (cosmetic).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@malibio
malibio force-pushed the issue-2798-structured-error-kinds branch from ea77d76 to b6ef9d5 Compare October 13, 2026 08:05
@malibio
malibio merged commit 6efe93f into main Oct 13, 2026
@malibio
malibio deleted the issue-2798-structured-error-kinds branch October 13, 2026 08:05
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