ruvector/crates/ruvector-wasm/src
rUv 08c0d742c4
fix(ruvector-wasm): correct adapter for WASM build's flat-index, distance-score, and metadata gaps (#568)
The published @ruvector/wasm build behaves differently from its generated
.d.ts in three ways that bite consumers:

1. HNSW is not active — the wasm32 target compiles without the `hnsw`
   feature and falls back to a flat (brute-force) index, so search is O(n).
   The O(log n) win is latent until the WASM HNSW lands.
2. `result.score` is a cosine distance (lower is better), not the
   "higher is better" similarity the .d.ts advertises (ordering is correct:
   a, b before c).
3. Metadata does not round-trip — search/get return {}.

Add RuvectorWasmAdapter (@ruvector/wasm/adapter) which wraps VectorDB with:
- a metadata sidecar so inserted metadata round-trips
- similarity = 1 - distance (generalised per metric) with `.score` aliased
  to similarity, plus the raw `distance` preserved
- indexType/usesHnsw + WASM_HNSW_AVAILABLE so callers don't assume HNSW
- client-side metadata filtering with over-fetch

Includes TS declarations with corrected doc comments, a node:test suite
covering all three findings, README guidance, and package exports.

Co-authored-by: Claude <noreply@anthropic.com>
2026-06-14 18:32:26 -04:00
..
kernel style: apply rustfmt across entire codebase 2026-01-28 17:00:26 +00:00
adapter.d.ts fix(ruvector-wasm): correct adapter for WASM build's flat-index, distance-score, and metadata gaps (#568) 2026-06-14 18:32:26 -04:00
adapter.js fix(ruvector-wasm): correct adapter for WASM build's flat-index, distance-score, and metadata gaps (#568) 2026-06-14 18:32:26 -04:00
indexeddb.js feat: Complete ALL Ruvector phases - production-ready vector database 2025-11-19 14:37:21 +00:00
lib.rs fix: 9-issue cleanup batch + regression-guard CI workflow (#466) 2026-05-16 12:14:49 -04:00
worker-pool.js feat: Complete ALL Ruvector phases - production-ready vector database 2025-11-19 14:37:21 +00:00
worker.js feat: Complete ALL Ruvector phases - production-ready vector database 2025-11-19 14:37:21 +00:00