Files
Dragan Spiridonov 65d551492d fix(test): two CI failures from PR #404 / #399 hnswlib-node migration
1) tests/integration/hnsw-unification.integration.test.ts:485 —
   `createHnswIndex Factory > should create a working index with default
   config` was asserting `recall() === 1.0`. With useNativeHNSW now
   defaulting to true (post #399), the factory routes through
   NativeHnswBackend whose conservative recall() returns 0.99. The
   assertion is updated to match the IHnswIndexProvider contract
   (`0 < recall <= 1`) — same fix as the equivalent test in
   tests/unit/hnsw-unification.test.ts that I caught locally but
   missed at the integration test layer.

2) tests/integration/ruvector/native-hnsw-real-fixture.test.ts —
   resize stress test was using `Math.sin(i * 0.01 + j * 0.03)` for
   the synthetic vector shape. That phase formula has aliasing: ids
   differing by ~628 (≈ 2π/0.01) produce nearly identical sine waves.
   id=5893 and id=7778 have phases that differ by ~3·2π → essentially
   the same vector. The local test happened to pass because hnswlib's
   graph walk landed on id=7777 as top-1; CI's x64 graph walk landed
   on id=5892 instead. Both are mathematically correct ranks for
   near-duplicate vectors.

   Replaced with FNV-1a-seeded Box-Muller Gaussian vectors so each id
   gets a unique, well-separated direction in 384-dim space.
   Neighbours in id-space are NOT neighbours in vector-space, so the
   self-query is unambiguous.

   Also reduced N from 12000 → 10500 (just past the 10000
   INITIAL_MAX_ELEMENTS threshold to trigger one resizeIndex()
   doubling, which is all the test needs to verify) and added an
   explicit 60s test timeout for the Box-Muller computation cost.

Local run: tests/integration/hnsw-unification.integration.test.ts
(19 tests) and tests/integration/ruvector/native-hnsw-real-fixture.test.ts
(8 tests) — 27/27 pass.

Refs #399, #404, ADR-090.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 18:45:45 +00:00
..