ruvector/crates/ruvector-wasm/tests
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
..
adapter.test.mjs 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
wasm.rs fix: Resolve CI build failures 2025-11-26 15:25:47 +00:00