Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

test(quantization): anchor binary recall to a known match

Rudy Celeklifda46806fac0
diff --git a/v3/@claude-flow/plugins/__tests__/ruvector-quantization.test.ts b/v3/@claude-flow/plugins/__tests__/ruvector-quantization.test.ts
index a5550c46b4..1f982bb683 100644
--- a/v3/@claude-flow/plugins/__tests__/ruvector-quantization.test.ts
+++ b/v3/@claude-flow/plugins/__tests__/ruvector-quantization.test.ts
@@ -479,18 +479,27 @@ describe('RuVector Quantization', () => {
const query = normalizedVector(dimensions);
const k = 10;
- const exactResults = searchExact(store, query, k);
- const binaryResults = searchQuantizedBinary(store, query, k);
+ // Random top-k neighbors need not survive one-bit quantization. Put a
+ // known match first so even a Hamming-distance tie has a stable winner.
+ const searchStore = createQuantizedStore();
+ addVector(searchStore, 'exact-match', query);
+ for (const [id, vector] of store.vectors) {
+ addVector(searchStore, id, vector);
+ }
+
+ const exactResults = searchExact(searchStore, query, k);
+ const binaryResults = searchQuantizedBinary(searchStore, query, k);
expect(binaryResults).toHaveLength(k);
+ expect(exactResults[0].id).toBe('exact-match');
+ expect(binaryResults[0].id).toBe('exact-match');
// Calculate recall (binary is less accurate but much faster)
const exactIds = exactResults.map((r) => r.id);
const binaryIds = binaryResults.map((r) => r.id);
const recall = calculateRecall(exactIds, binaryIds, k);
- // Binary quantization has lower recall but is very fast
- expect(recall).toBeGreaterThanOrEqual(0.1); // Lower threshold for binary
+ expect(recall).toBeGreaterThanOrEqual(1 / k);
});
it('should reduce memory by ~32x with binary', () => {