Skip to content

selfhost/rag: reject dimension-mismatched vectors in the SQLite vectorize adapter instead of silently truncating #8766

Description

@JSONbored

Context

Parent: #8757. src/selfhost/vectorize.ts cosineSimilarity (line ~35) computes over Math.min(a.length, b.length) — a store containing mixed-width vectors (operator swaps embed model without reindexing) silently produces wrong similarity scores. Qdrant hard-fails this at the collection level (qdrant-vectorize.ts:93-95) and pgvector raises; the SQLite adapter is the odd one out. No existing test covers the mismatch case (test/unit/selfhost-vectorize.test.ts).

Requirements

  • On width mismatch, skip the row (degrade-to-fewer-results, consistent with RAG's fail-safe posture) and log once per query at WARN with both widths; never silently truncate.
  • Pin with a test: mismatched-width row excluded, matching rows still returned, log emitted.

Deliverables

  • The guard + test.

Test Coverage Requirements

99%+ patch coverage, branch-counted.

Metadata

Metadata

Assignees

Labels

maintainer-onlyOwner-only work — yields no Gittensor points.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions