mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-07-09 17:28:42 +00:00
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>
|
||
|---|---|---|
| .. | ||
| adapter.test.mjs | ||
| wasm.rs | ||