feat(8.0): zero-config finalize + cut JS quantization (config.vector = recall + persistMode)

This commit is contained in:
David Snelling 2026-06-15 10:08:51 -07:00
parent f4c5d9749f
commit f8e0079d3f
12 changed files with 348 additions and 1739 deletions

View file

@ -6,7 +6,6 @@
* - Search returns correct results after vector eviction
* - Memory mode retains vectors (default behavior)
* - Lazy mode requires storage adapter
* - Combined lazy + quantization mode
*/
import { describe, it, expect, beforeEach } from 'vitest'
@ -180,79 +179,7 @@ describe('Lazy Vector Loading (B2)', () => {
})
// =================================================================
// 4. LAZY + QUANTIZATION COMBINED
// =================================================================
describe('lazy mode with quantization', () => {
it('should use SQ8 for traversal and load full vectors for rerank', async () => {
const storage = new MemoryStorage()
const index = new JsHnswVectorIndex(
{
M: 8,
efConstruction: 100,
efSearch: 50,
ml: 8,
vectorStorage: 'lazy',
quantization: { enabled: true, rerankMultiplier: 3 }
},
euclideanDistance,
{ useParallelization: false, storage }
)
const targetId = uuidv4()
const target = randomVector(dim)
await saveVector(storage, targetId, target)
await index.addItem({ id: targetId, vector: target })
for (let i = 0; i < 30; i++) {
const id = uuidv4()
const v = randomVector(dim)
await saveVector(storage, id, v)
await index.addItem({ id, vector: v })
}
// Search with reranking — should load full vectors for rerank phase
const results = await index.search(target, 5)
expect(results.length).toBe(5)
// The target should be the closest match
const targetResult = results.find(([id]) => id === targetId)
expect(targetResult).toBeDefined()
})
it('should return results sorted by exact distance after rerank', async () => {
const storage = new MemoryStorage()
const index = new JsHnswVectorIndex(
{
M: 8,
efConstruction: 100,
efSearch: 50,
ml: 8,
vectorStorage: 'lazy',
quantization: { enabled: true, rerankMultiplier: 3 }
},
euclideanDistance,
{ useParallelization: false, storage }
)
for (let i = 0; i < 40; i++) {
const id = uuidv4()
const v = randomVector(dim)
await saveVector(storage, id, v)
await index.addItem({ id, vector: v })
}
const query = randomVector(dim)
const results = await index.search(query, 10)
// Results should be sorted by exact distance (rerank ensures this)
for (let i = 1; i < results.length; i++) {
expect(results[i][1]).toBeGreaterThanOrEqual(results[i - 1][1])
}
})
})
// =================================================================
// 5. MULTIPLE SEARCHES IN LAZY MODE
// 4. MULTIPLE SEARCHES IN LAZY MODE
// =================================================================
describe('multiple searches in lazy mode', () => {
it('should handle repeated searches correctly', async () => {