fix(selfhost): skip dimension-mismatched vectors in the SQLite vectorize adapter instead of silently truncating - #8792
Conversation
…ize adapter instead of silently truncating (#8766) cosineSimilarity's Math.min(a.length, b.length) meant a store containing mixed-width vectors (an operator swapping embedding models without a full reindex) silently produced wrong similarity scores over the shorter prefix. Qdrant hard-fails this at the collection level and pgvector raises — the SQLite adapter was the odd one out. A mismatched-width row is now skipped (degrade-to-fewer-candidates, the RAG pipeline's established fail-safe posture) with one WARN per query naming the query width and the deduped set of mismatched stored widths.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
loopover-ui | c1572db | Commit Preview URL Branch Preview URL |
Jul 26 2026, 06:00 AM |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8792 +/- ##
==========================================
+ Coverage 90.56% 92.26% +1.70%
==========================================
Files 96 797 +701
Lines 22490 79563 +57073
Branches 3884 24111 +20227
==========================================
+ Hits 20367 73408 +53041
- Misses 1945 5090 +3145
- Partials 178 1065 +887
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-26 06:09:57 UTC
Review summary Nits — 5 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Summary
RAG-audit hardening from epic #8757.
cosineSimilarity'sMath.min(a.length, b.length)silently scored mixed-width vectors over the shorter prefix — wrong similarity results if an operator ever swaps embedding models without a full reindex. Qdrant hard-fails this at the collection level and pgvector raises; the SQLite adapter was the only backend that silently computed garbage.Changes
src/selfhost/vectorize.ts— the query path skips any stored vector whose width differs from the query's (degrade-to-fewer-candidates, the RAG pipeline's established fail-safe posture) and emits onesqlite_vectorize_dimension_mismatchWARN per query (not per row) naming the query width and the deduped mismatched widths.cosineSimilarityitself is untouched (pure function, existing behavior pinned by its own tests).Test plan
npm run typecheck— cleanCloses #8766