Prevent silent O(n) search fallback when sqlite-vec is unavailable #17

Open
opened 2026-03-15 01:25:57 +00:00 by Francy51 · 0 comments
Owner

When sqlite-vec is unavailable, search silently degrades to a JavaScript full scan over stored JSON embeddings.

Why this is a problem:

  • Query cost grows linearly with corpus size.
  • Each search parses stored embedding JSON and computes cosine distance in-process.
  • This creates a severe performance cliff that is easy to miss in development and difficult to operate safely at scale.

Observed in:

  • lib/server/db/index.ts
    • logs a warning and falls back to table-backed vector storage
  • lib/server/search.ts
    • vectorSearch() loads candidate rows, parses JSON embeddings, computes cosine distance, sorts, and slices in JS when the extension is unavailable

Suggested direction:

  • Treat missing vector capability as a degraded mode that is explicit, gated, or disabled.
  • Avoid silently preserving the same feature contract with radically different performance.
  • Consider:
    • failing startup in environments that require semantic search
    • feature-flagging search when vector support is missing
    • providing a clearly limited lexical-only fallback instead of faux vector search

Acceptance criteria:

  • Search does not silently drop to O(n) vector scans.
  • Missing vector support is visible as an explicit degraded capability.
  • Performance expectations are preserved or the feature is clearly disabled.
When `sqlite-vec` is unavailable, search silently degrades to a JavaScript full scan over stored JSON embeddings. Why this is a problem: - Query cost grows linearly with corpus size. - Each search parses stored embedding JSON and computes cosine distance in-process. - This creates a severe performance cliff that is easy to miss in development and difficult to operate safely at scale. Observed in: - `lib/server/db/index.ts` - logs a warning and falls back to table-backed vector storage - `lib/server/search.ts` - `vectorSearch()` loads candidate rows, parses JSON embeddings, computes cosine distance, sorts, and slices in JS when the extension is unavailable Suggested direction: - Treat missing vector capability as a degraded mode that is explicit, gated, or disabled. - Avoid silently preserving the same feature contract with radically different performance. - Consider: - failing startup in environments that require semantic search - feature-flagging search when vector support is missing - providing a clearly limited lexical-only fallback instead of faux vector search Acceptance criteria: - Search does not silently drop to O(n) vector scans. - Missing vector support is visible as an explicit degraded capability. - Performance expectations are preserved or the feature is clearly disabled.
Francy51 added the P1 label 2026-03-15 01:25:57 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Francy51/Neon-Desk#17