Bug
cosineSim() in three files silently truncates or zero-pads when vector dimensions differ, producing meaningless similarity scores.
memory-initializer.ts:2468 — Math.min(a.length, b.length) truncates longer vector
memory-bridge.ts:3589 — same truncation
intelligence.ts:595 — Math.max + zero-pad (?? 0) — geometrically wrong
Impact
Any user whose stored vectors have a different dimension than query vectors gets wrong search results with no error. This happens silently when fallback paths produce 384-dim vectors while the primary path uses 768-dim.
Fix
All three functions now throw on a.length !== b.length. Surrounding try/catch blocks in callers handle the error gracefully (score of 0 or skip the entry).
Commit: ff50410 (ADR-0076 Track A)
ADR Reference
ADR-0075 Problem 2, ADR-0076 A1
Bug
cosineSim()in three files silently truncates or zero-pads when vector dimensions differ, producing meaningless similarity scores.memory-initializer.ts:2468—Math.min(a.length, b.length)truncates longer vectormemory-bridge.ts:3589— same truncationintelligence.ts:595—Math.max+ zero-pad (?? 0) — geometrically wrongImpact
Any user whose stored vectors have a different dimension than query vectors gets wrong search results with no error. This happens silently when fallback paths produce 384-dim vectors while the primary path uses 768-dim.
Fix
All three functions now throw on
a.length !== b.length. Surrounding try/catch blocks in callers handle the error gracefully (score of 0 or skip the entry).Commit:
ff50410(ADR-0076 Track A)ADR Reference
ADR-0075 Problem 2, ADR-0076 A1