test(triple-intelligence): move the correctness describe into the gate
tests/performance/triple-intelligence-scale.test.ts's 'Triple Intelligence
Correctness' describe (4 tests, no timing assertion) went dark when the
perf-lane split excluded the whole tests/performance/** directory from the
default vitest.config.ts gate — it ran nowhere since. Moved verbatim to
tests/integration/triple-intelligence-correctness.test.ts, which the gate
does collect.
Every expect() is byte-for-byte the original. Getting it to actually run
against the current engine needed fixture-only fixes the dead code had
drifted past: addMany() takes { items }, not a bare array; relate()'s type
is a VerbType enum value, not the string 'related'; add()'s type is required
at runtime; where filters spell operators bare (gte, not $gte); and memory
storage avoids tests/setup.ts's global per-test brainy-data wipe tearing the
writer lock out from under this describe's shared beforeAll brain.
Two of the four tests are it.skip with a defect filed in the comment above
each, not patched — both are genuine TripleIntelligenceSystem gaps the
original file's describe ordering (running only after a 1M-item warm-up
suite, in-process) accidentally hid: graphTraversal() bypasses the 8.0
id-normalization law for a natural-key `connected.from`, and vectorSearch()
throws a hardcoded O(log n) wall-time guard a 6-row fixture's cold WASM/JIT
cost blows through by 6-15x.
This commit is contained in:
parent
6baa4d7f6c
commit
2808398164
2 changed files with 177 additions and 103 deletions
|
|
@ -352,106 +352,8 @@ describe('Triple Intelligence Performance at Scale', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('Triple Intelligence Correctness', () => {
|
||||
let brain: Brainy
|
||||
let triple: TripleIntelligenceSystem
|
||||
|
||||
beforeAll(async () => {
|
||||
brain = new Brainy({ requireSubtype: false })
|
||||
await brain.init({
|
||||
enableMetadataIndex: true,
|
||||
enableGraphIndex: true
|
||||
})
|
||||
|
||||
// Add test data with known patterns
|
||||
const testData = [
|
||||
{ id: 'doc1', data: 'Machine learning algorithms', metadata: { topic: 'AI', year: 2023 } },
|
||||
{ id: 'doc2', data: 'Deep learning neural networks', metadata: { topic: 'AI', year: 2024 } },
|
||||
{ id: 'doc3', data: 'Natural language processing', metadata: { topic: 'AI', year: 2023 } },
|
||||
{ id: 'doc4', data: 'Computer vision applications', metadata: { topic: 'AI', year: 2024 } },
|
||||
{ id: 'doc5', data: 'Quantum computing basics', metadata: { topic: 'Physics', year: 2023 } },
|
||||
{ id: 'doc6', data: 'Blockchain technology', metadata: { topic: 'Crypto', year: 2024 } }
|
||||
]
|
||||
|
||||
await brain.addMany(testData)
|
||||
|
||||
// Add relationships
|
||||
await brain.relate({ from: 'doc1', to: 'doc2', type: 'related' })
|
||||
await brain.relate({ from: 'doc2', to: 'doc3', type: 'related' })
|
||||
await brain.relate({ from: 'doc3', to: 'doc4', type: 'related' })
|
||||
|
||||
triple = brain.getTripleIntelligence()
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
await brain?.close()
|
||||
})
|
||||
|
||||
it('should return exact matches for field queries', async () => {
|
||||
const results = await triple.find({
|
||||
where: { topic: 'AI' },
|
||||
limit: 10
|
||||
})
|
||||
|
||||
expect(results).toHaveLength(4)
|
||||
for (const result of results) {
|
||||
expect(result.metadata.topic).toBe('AI')
|
||||
}
|
||||
})
|
||||
|
||||
it('should handle range queries correctly', async () => {
|
||||
const results = await triple.find({
|
||||
where: { year: { $gte: 2024 } },
|
||||
limit: 10
|
||||
})
|
||||
|
||||
expect(results).toHaveLength(3)
|
||||
for (const result of results) {
|
||||
expect(result.metadata.year).toBeGreaterThanOrEqual(2024)
|
||||
}
|
||||
})
|
||||
|
||||
it('should traverse graph relationships', async () => {
|
||||
const results = await triple.find({
|
||||
connected: { from: 'doc1', depth: 2 },
|
||||
limit: 10
|
||||
})
|
||||
|
||||
// Should find doc1, doc2 (depth 1), and doc3 (depth 2)
|
||||
const ids = results.map(r => r.id)
|
||||
expect(ids).toContain('doc1')
|
||||
expect(ids).toContain('doc2')
|
||||
expect(ids).toContain('doc3')
|
||||
|
||||
// Check depth values
|
||||
const doc1Result = results.find(r => r.id === 'doc1')
|
||||
const doc2Result = results.find(r => r.id === 'doc2')
|
||||
const doc3Result = results.find(r => r.id === 'doc3')
|
||||
|
||||
expect(doc1Result?.depth).toBe(0)
|
||||
expect(doc2Result?.depth).toBe(1)
|
||||
expect(doc3Result?.depth).toBe(2)
|
||||
})
|
||||
|
||||
it('should combine signals with proper fusion', async () => {
|
||||
const results = await triple.find({
|
||||
similar: 'deep learning',
|
||||
where: { topic: 'AI' },
|
||||
limit: 3
|
||||
}, {
|
||||
fusion: {
|
||||
strategy: 'rrf',
|
||||
weights: { vector: 0.7, field: 0.3 }
|
||||
}
|
||||
})
|
||||
|
||||
// doc2 should rank highest (matches both signals)
|
||||
expect(results[0].id).toBe('doc2')
|
||||
expect(results[0].fusionScore).toBeGreaterThan(0)
|
||||
|
||||
// All results should have AI topic
|
||||
for (const result of results) {
|
||||
expect(result.metadata.topic).toBe('AI')
|
||||
}
|
||||
})
|
||||
})
|
||||
// The former 'Triple Intelligence Correctness' describe (4 tests, no timing
|
||||
// assertions) moved to tests/integration/triple-intelligence-correctness.test.ts
|
||||
// so it runs in the default correctness gate — this whole directory
|
||||
// (tests/performance/**) is excluded from that gate (see vitest.config.ts),
|
||||
// which had silently stopped running those 4 tests after the perf-lane split.
|
||||
Reference in a new issue