Compare commits
No commits in common. "be307a15794246e95799123d9515e1ade0cedf56" and "4c81d7d4c37bd80cfefd2bcd1f96a0f99b55f56a" have entirely different histories.
be307a1579
...
4c81d7d4c3
34 changed files with 31 additions and 159 deletions
|
|
@ -34,10 +34,6 @@ describe('API Parameter Validation', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should use "where" parameter for metadata filtering', async () => {
|
it('should use "where" parameter for metadata filtering', async () => {
|
||||||
const results = await brain.find({
|
const results = await brain.find({
|
||||||
where: { category: 'test-category' },
|
where: { category: 'test-category' },
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
* - Backward compatibility preserved
|
* - Backward compatibility preserved
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy } from '../../src/brainy.js'
|
import { Brainy } from '../../src/brainy.js'
|
||||||
import { NounType } from '../../src/types/graphTypes.js'
|
import { NounType } from '../../src/types/graphTypes.js'
|
||||||
|
|
||||||
|
|
@ -19,10 +19,6 @@ describe('Entity Confidence & Weight Exposure', () => {
|
||||||
await brain.init()
|
await brain.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('Entity interface', () => {
|
describe('Entity interface', () => {
|
||||||
it('should expose confidence when adding entity with confidence', async () => {
|
it('should expose confidence when adding entity with confidence', async () => {
|
||||||
const id = await brain.add({
|
const id = await brain.add({
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
* index-served (a body field, or a bucketed timestamp), exactly the owing rows
|
* index-served (a body field, or a bucketed timestamp), exactly the owing rows
|
||||||
* are read and the rest are still served from the index.
|
* are read and the rest are still served from the index.
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'
|
import { describe, it, expect, beforeAll, vi } from 'vitest'
|
||||||
import { Brainy } from '../../src/brainy'
|
import { Brainy } from '../../src/brainy'
|
||||||
import { NounType } from '../../src/types/graphTypes'
|
import { NounType } from '../../src/types/graphTypes'
|
||||||
import { generateTestVector } from '../helpers/test-factory'
|
import { generateTestVector } from '../helpers/test-factory'
|
||||||
|
|
@ -59,10 +59,6 @@ describe('find/get({ fields }) — projection', () => {
|
||||||
await brain.flush()
|
await brain.flush()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
/** Count canonical record reads for one call. */
|
/** Count canonical record reads for one call. */
|
||||||
const countingReads = async <R>(body: () => Promise<R>): Promise<{ out: R; reads: number }> => {
|
const countingReads = async <R>(body: () => Promise<R>): Promise<{ out: R; reads: number }> => {
|
||||||
const spy = vi.spyOn(brain as any, 'batchGet')
|
const spy = vi.spyOn(brain as any, 'batchGet')
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
* it). Now the anchor is fetched with its vector, and an anchor without one
|
* it). Now the anchor is fetched with its vector, and an anchor without one
|
||||||
* refuses by name instead of failing inside the index.
|
* refuses by name instead of failing inside the index.
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeAll, afterAll } from 'vitest'
|
import { describe, it, expect, beforeAll } from 'vitest'
|
||||||
import { Brainy } from '../../src/brainy'
|
import { Brainy } from '../../src/brainy'
|
||||||
import { NounType } from '../../src/types/graphTypes'
|
import { NounType } from '../../src/types/graphTypes'
|
||||||
import { v5 } from '../../src/universal/uuid'
|
import { v5 } from '../../src/universal/uuid'
|
||||||
|
|
@ -28,10 +28,6 @@ describe('find({ near }) uses the anchor vector', () => {
|
||||||
await brain.add({ id: 'far', data: 'far row', type: NounType.Thing, vector: generateTestVector() })
|
await brain.add({ id: 'far', data: 'far row', type: NounType.Thing, vector: generateTestVector() })
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns the anchor\'s neighbours by its own vector', async () => {
|
it('returns the anchor\'s neighbours by its own vector', async () => {
|
||||||
const results = await brain.find({ near: { id: 'anchor' }, limit: 3 })
|
const results = await brain.find({ near: { id: 'anchor' }, limit: 3 })
|
||||||
expect(results.length).toBeGreaterThan(0)
|
expect(results.length).toBeGreaterThan(0)
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
* the covering is ASSERTED from the leg's own output rather than assumed. This
|
* the covering is ASSERTED from the leg's own output rather than assumed. This
|
||||||
* pin is about ordering, and it says nothing about recall.
|
* pin is about ordering, and it says nothing about recall.
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeAll, afterAll } from 'vitest'
|
import { describe, it, expect, beforeAll } from 'vitest'
|
||||||
import { Brainy } from '../../src/brainy'
|
import { Brainy } from '../../src/brainy'
|
||||||
import { NounType, VerbType } from '../../src/types/graphTypes'
|
import { NounType, VerbType } from '../../src/types/graphTypes'
|
||||||
import { resolveEntityId } from '../../src/utils/idNormalization'
|
import { resolveEntityId } from '../../src/utils/idNormalization'
|
||||||
|
|
@ -107,10 +107,6 @@ describe('find(): orderBy is the order on every path', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('the fixture: the hybrid candidate set covers the whole filter universe', async () => {
|
it('the fixture: the hybrid candidate set covers the whole filter universe', async () => {
|
||||||
const universe: string[] = await (brain as any).filterIdsBelted({ lane: 'alpha' })
|
const universe: string[] = await (brain as any).filterIdsBelted({ lane: 'alpha' })
|
||||||
expect(universe).toHaveLength(ROWS)
|
expect(universe).toHaveLength(ROWS)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
* against the adjacency before it is believed, so a not-serving graph refuses
|
* against the adjacency before it is believed, so a not-serving graph refuses
|
||||||
* loudly instead of answering `[]` as truth.
|
* loudly instead of answering `[]` as truth.
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'
|
import { describe, it, expect, beforeAll, vi } from 'vitest'
|
||||||
import { Brainy } from '../../src/brainy'
|
import { Brainy } from '../../src/brainy'
|
||||||
import { NounType, VerbType } from '../../src/types/graphTypes'
|
import { NounType, VerbType } from '../../src/types/graphTypes'
|
||||||
import { generateTestVector } from '../helpers/test-factory'
|
import { generateTestVector } from '../helpers/test-factory'
|
||||||
|
|
@ -56,10 +56,6 @@ describe('find(): the optional planner door', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
/** Install a planner door for one call, then remove it. */
|
/** Install a planner door for one call, then remove it. */
|
||||||
const withDoor = async <T>(
|
const withDoor = async <T>(
|
||||||
door: (...a: any[]) => Promise<any>,
|
door: (...a: any[]) => Promise<any>,
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ describe('Unified Find() Integration Tests', () => {
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await cleanup.cleanup()
|
await cleanup.cleanup()
|
||||||
await brain.close()
|
|
||||||
brain = null as any
|
brain = null as any
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ describe('related() with a verb-type array returns every requested type', () =>
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await brain.close()
|
|
||||||
brain = null as any
|
brain = null as any
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,7 @@ describe('Relationship Intelligence', () => {
|
||||||
await brain.init()
|
await brain.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(() => {
|
||||||
await brain.close()
|
|
||||||
if (fs.existsSync(testDir)) {
|
if (fs.existsSync(testDir)) {
|
||||||
fs.rmSync(testDir, { recursive: true })
|
fs.rmSync(testDir, { recursive: true })
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
* - addMany({ ifAbsent: true }) applies the flag to every item
|
* - addMany({ ifAbsent: true }) applies the flag to every item
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy } from '../../src/brainy.js'
|
import { Brainy } from '../../src/brainy.js'
|
||||||
import { RevisionConflictError } from '../../src/transaction/RevisionConflictError.js'
|
import { RevisionConflictError } from '../../src/transaction/RevisionConflictError.js'
|
||||||
import { NounType } from '../../src/types/graphTypes.js'
|
import { NounType } from '../../src/types/graphTypes.js'
|
||||||
|
|
@ -22,10 +22,6 @@ describe('7.31.0 — _rev CAS + ifAbsent', () => {
|
||||||
await brain.init()
|
await brain.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('_rev initialization + surface', () => {
|
describe('_rev initialization + surface', () => {
|
||||||
it('initializes _rev to 1 on add()', async () => {
|
it('initializes _rev to 1 on add()', async () => {
|
||||||
const id = await brain.add({ data: 'hello', type: NounType.Document })
|
const id = await brain.add({ data: 'hello', type: NounType.Document })
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,6 @@ describe('repairContainment: batched pass 2', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await brain.close()
|
|
||||||
brain = null as any
|
brain = null as any
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import * as XLSX from 'xlsx'
|
||||||
describe('VFS Debug', () => {
|
describe('VFS Debug', () => {
|
||||||
it('minimal VFS writeFile test', async () => {
|
it('minimal VFS writeFile test', async () => {
|
||||||
const brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
|
const brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
|
||||||
try {
|
|
||||||
await brain.init()
|
await brain.init()
|
||||||
|
|
||||||
console.log('✅ Brain initialized')
|
console.log('✅ Brain initialized')
|
||||||
|
|
@ -78,8 +77,5 @@ describe('VFS Debug', () => {
|
||||||
// THE REAL TEST: Can we query VFS?
|
// THE REAL TEST: Can we query VFS?
|
||||||
expect(children.length).toBeGreaterThan(0)
|
expect(children.length).toBeGreaterThan(0)
|
||||||
expect(rootContents.length).toBeGreaterThan(0)
|
expect(rootContents.length).toBeGreaterThan(0)
|
||||||
} finally {
|
|
||||||
await brain.close()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
* No mocks, no fakes, real implementation
|
* No mocks, no fakes, real implementation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy } from '../../src/brainy.js'
|
import { Brainy } from '../../src/brainy.js'
|
||||||
import { NounType } from '../../src/types/graphTypes.js'
|
import { NounType } from '../../src/types/graphTypes.js'
|
||||||
|
|
||||||
|
|
@ -21,10 +21,6 @@ describe('Brainy 3.0 Core (Unit Tests)', () => {
|
||||||
await brain.init()
|
await brain.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('CRUD Operations', () => {
|
describe('CRUD Operations', () => {
|
||||||
it('should create items with add', async () => {
|
it('should create items with add', async () => {
|
||||||
const id = await brain.add({
|
const id = await brain.add({
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
* soft-delete semantic: `field !== value` MUST include entities that have no
|
* soft-delete semantic: `field !== value` MUST include entities that have no
|
||||||
* such field at all.
|
* such field at all.
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy } from '../../../src/brainy'
|
import { Brainy } from '../../../src/brainy'
|
||||||
import { NounType } from '../../../src/types/graphTypes'
|
import { NounType } from '../../../src/types/graphTypes'
|
||||||
|
|
||||||
|
|
@ -26,10 +26,6 @@ describe('find() complement operators (ne / exists:false / missing:true)', () =>
|
||||||
ids.noField2 = await brain.add({ data: 'n2', type: NounType.Thing, metadata: { other: 2 } })
|
ids.noField2 = await brain.add({ data: 'n2', type: NounType.Thing, metadata: { other: 2 } })
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('ne returns everything except the matching value — INCLUDING entities without the field', async () => {
|
it('ne returns everything except the matching value — INCLUDING entities without the field', async () => {
|
||||||
const rows = await brain.find({ where: { status: { ne: 'active' } }, limit: 100 })
|
const rows = await brain.find({ where: { status: { ne: 'active' } }, limit: 100 })
|
||||||
const got = new Set(rows.map((r) => r.id))
|
const got = new Set(rows.map((r) => r.id))
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
* returns an id whose record matches NEITHER the type nor the where filter) and
|
* returns an id whose record matches NEITHER the type nor the where filter) and
|
||||||
* assert the phantom is dropped while the genuine matches survive.
|
* assert the phantom is dropped while the genuine matches survive.
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy } from '../../../src/brainy'
|
import { Brainy } from '../../../src/brainy'
|
||||||
import { NounType } from '../../../src/types/graphTypes'
|
import { NounType } from '../../../src/types/graphTypes'
|
||||||
|
|
||||||
|
|
@ -48,10 +48,6 @@ describe('find() index-integrity guard (phantom row class)', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('healthy index: the discriminant query returns only the staff Person', async () => {
|
it('healthy index: the discriminant query returns only the staff Person', async () => {
|
||||||
const rows = await brain.find({ type: NounType.Person, where: { entityType: 'staff' }, limit: 100 })
|
const rows = await brain.find({ type: NounType.Person, where: { entityType: 'staff' }, limit: 100 })
|
||||||
expect(rows.map((r) => r.id)).toEqual([staffId])
|
expect(rows.map((r) => r.id)).toEqual([staffId])
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy } from '../../../src/brainy'
|
import { Brainy } from '../../../src/brainy'
|
||||||
import { createAddParams } from '../../helpers/test-factory'
|
import { createAddParams } from '../../helpers/test-factory'
|
||||||
import { NounType } from '../../../src/types/graphTypes'
|
import { NounType } from '../../../src/types/graphTypes'
|
||||||
|
|
@ -13,10 +13,6 @@ describe('Brainy.find()', () => {
|
||||||
await brain.init()
|
await brain.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('success paths', () => {
|
describe('success paths', () => {
|
||||||
it('should find entities by text query', async () => {
|
it('should find entities by text query', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
* exercised by cor's combined matrix); they inject probe/spy hooks onto the live JS
|
* exercised by cor's combined matrix); they inject probe/spy hooks onto the live JS
|
||||||
* metadata index, which has neither method by default.
|
* metadata index, which has neither method by default.
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy } from '../../../src/brainy'
|
import { Brainy } from '../../../src/brainy'
|
||||||
import { NounType } from '../../../src/types/graphTypes'
|
import { NounType } from '../../../src/types/graphTypes'
|
||||||
|
|
||||||
|
|
@ -34,10 +34,6 @@ describe('metadata-provider contract wiring (getIdsForFilter opts)', () => {
|
||||||
mi = (brain as any).metadataIndex
|
mi = (brain as any).metadataIndex
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('RETIRED: a read never calls probeConsistency() / self-heals via detectAndRepairCorruption — that is the read-triggered dark rebuild the health-gate law forbids', async () => {
|
it('RETIRED: a read never calls probeConsistency() / self-heals via detectAndRepairCorruption — that is the read-triggered dark rebuild the health-gate law forbids', async () => {
|
||||||
let probes = 0
|
let probes = 0
|
||||||
let repairs = 0
|
let repairs = 0
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
* gate that hung getStats / readdir / readFile behind an unrelated family's
|
* gate that hung getStats / readdir / readFile behind an unrelated family's
|
||||||
* migration until the wait timed out.
|
* migration until the wait timed out.
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy } from '../../../src/brainy.js'
|
import { Brainy } from '../../../src/brainy.js'
|
||||||
import { MigrationInProgressError } from '../../../src/errors/brainyError.js'
|
import { MigrationInProgressError } from '../../../src/errors/brainyError.js'
|
||||||
|
|
||||||
|
|
@ -38,19 +38,12 @@ const jam = (provider: unknown) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('migration LOCK is family-scoped', () => {
|
describe('migration LOCK is family-scoped', () => {
|
||||||
const opened: Brainy[] = []
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
process.env.BRAINY_DETERMINISTIC_EMBEDDINGS = 'true'
|
process.env.BRAINY_DETERMINISTIC_EMBEDDINGS = 'true'
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
for (const b of opened.splice(0)) await b.close().catch(() => {})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('a stuck VECTOR migration does not block canonical or graph/metadata reads', async () => {
|
it('a stuck VECTOR migration does not block canonical or graph/metadata reads', async () => {
|
||||||
const brain = await seed()
|
const brain = await seed()
|
||||||
opened.push(brain)
|
|
||||||
const childId = (
|
const childId = (
|
||||||
(await brain.vfs.readdir('/notes', { withFileTypes: true })) as Array<{ entityId: string }>
|
(await brain.vfs.readdir('/notes', { withFileTypes: true })) as Array<{ entityId: string }>
|
||||||
)[0].entityId
|
)[0].entityId
|
||||||
|
|
@ -67,7 +60,6 @@ describe('migration LOCK is family-scoped', () => {
|
||||||
|
|
||||||
it('a stuck VECTOR migration STILL blocks a read that needs the vector family', async () => {
|
it('a stuck VECTOR migration STILL blocks a read that needs the vector family', async () => {
|
||||||
const brain = await seed()
|
const brain = await seed()
|
||||||
opened.push(brain)
|
|
||||||
jam((brain as any).index)
|
jam((brain as any).index)
|
||||||
|
|
||||||
// A semantic query consults the vector index — it must wait, and (bounded by
|
// A semantic query consults the vector index — it must wait, and (bounded by
|
||||||
|
|
@ -78,7 +70,6 @@ describe('migration LOCK is family-scoped', () => {
|
||||||
|
|
||||||
it('a stuck GRAPH migration blocks traversal but not vector/canonical reads', async () => {
|
it('a stuck GRAPH migration blocks traversal but not vector/canonical reads', async () => {
|
||||||
const brain = await seed()
|
const brain = await seed()
|
||||||
opened.push(brain)
|
|
||||||
const childId = (
|
const childId = (
|
||||||
(await brain.vfs.readdir('/notes', { withFileTypes: true })) as Array<{ entityId: string }>
|
(await brain.vfs.readdir('/notes', { withFileTypes: true })) as Array<{ entityId: string }>
|
||||||
)[0].entityId
|
)[0].entityId
|
||||||
|
|
@ -96,7 +87,6 @@ describe('migration LOCK is family-scoped', () => {
|
||||||
|
|
||||||
it('with no migration in flight, every read serves (the fast path is a no-op)', async () => {
|
it('with no migration in flight, every read serves (the fast path is a no-op)', async () => {
|
||||||
const brain = await seed()
|
const brain = await seed()
|
||||||
opened.push(brain)
|
|
||||||
await expect(brain.getStats()).resolves.toBeDefined()
|
await expect(brain.getStats()).resolves.toBeDefined()
|
||||||
await expect(brain.find({ query: 'doc' })).resolves.toBeDefined()
|
await expect(brain.find({ query: 'doc' })).resolves.toBeDefined()
|
||||||
await expect(brain.vfs.readdir('/notes')).resolves.toHaveLength(1)
|
await expect(brain.vfs.readdir('/notes')).resolves.toHaveLength(1)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ describe('Duplicate Check Optimization', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await brain.close()
|
// Cleanup is automatic with memory storage
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should detect duplicate relationships using GraphAdjacencyIndex', async () => {
|
it('should detect duplicate relationships using GraphAdjacencyIndex', async () => {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
* _indexRebuildFailed / _indexDegradedIds degraded states (mirroring
|
* _indexRebuildFailed / _indexDegradedIds degraded states (mirroring
|
||||||
* validateIndexConsistency / checkHealth).
|
* validateIndexConsistency / checkHealth).
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy, NounType } from '../../src/index.js'
|
import { Brainy, NounType } from '../../src/index.js'
|
||||||
|
|
||||||
describe('getIndexStatus honest readiness (Finding 9)', () => {
|
describe('getIndexStatus honest readiness (Finding 9)', () => {
|
||||||
|
|
@ -20,10 +20,6 @@ describe('getIndexStatus honest readiness (Finding 9)', () => {
|
||||||
await brain.flush()
|
await brain.flush()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('a not-ready provider makes populated honest (false) and exposes ready:false', async () => {
|
it('a not-ready provider makes populated honest (false) and exposes ready:false', async () => {
|
||||||
brain.index.isReady = () => false // count present, serving structure NOT loaded
|
brain.index.isReady = () => false // count present, serving structure NOT loaded
|
||||||
const status = await brain.getIndexStatus()
|
const status = await brain.getIndexStatus()
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
* scan; and a one-shot probe self-heals a no-isReady provider whose adjacency
|
* scan; and a one-shot probe self-heals a no-isReady provider whose adjacency
|
||||||
* did not cold-load.
|
* did not cold-load.
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy, NounType, VerbType } from '../../../src/index.js'
|
import { Brainy, NounType, VerbType } from '../../../src/index.js'
|
||||||
|
|
||||||
describe('graph fast-path honest readiness (Finding 2)', () => {
|
describe('graph fast-path honest readiness (Finding 2)', () => {
|
||||||
|
|
@ -33,10 +33,6 @@ describe('graph fast-path honest readiness (Finding 2)', () => {
|
||||||
await storage.getVerbsBySource(a)
|
await storage.getVerbsBySource(a)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('not-ready provider → shard scan returns the REAL edges, not a silent []', async () => {
|
it('not-ready provider → shard scan returns the REAL edges, not a silent []', async () => {
|
||||||
const gi = storage.graphIndex
|
const gi = storage.graphIndex
|
||||||
// Simulate a cold native provider: count/manifest loaded (isInitialized) but
|
// Simulate a cold native provider: count/manifest loaded (isInitialized) but
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* The 8.0 JS index cold-loads correctly, so we simulate the cold native failure
|
* The 8.0 JS index cold-loads correctly, so we simulate the cold native failure
|
||||||
* mode by intercepting the provider's getIdsForFilter/rebuild.
|
* mode by intercepting the provider's getIdsForFilter/rebuild.
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy, NounType, MetadataIndexNotReadyError } from '../../src/index.js'
|
import { Brainy, NounType, MetadataIndexNotReadyError } from '../../src/index.js'
|
||||||
|
|
||||||
const V = () => Array.from({ length: 384 }, (_, i) => Math.sin(i * 0.1) + 0.001)
|
const V = () => Array.from({ length: 384 }, (_, i) => Math.sin(i * 0.1) + 0.001)
|
||||||
|
|
@ -31,10 +31,6 @@ describe('Metadata cold-read guard (#venue silent-[])', () => {
|
||||||
await brain.flush()
|
await brain.flush()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('warm brain: filtered find is correct and the guard does not rebuild', async () => {
|
it('warm brain: filtered find is correct and the guard does not rebuild', async () => {
|
||||||
const mi = brain.metadataIndex
|
const mi = brain.metadataIndex
|
||||||
let rebuilds = 0
|
let rebuilds = 0
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
* the production feature-detection reads it.
|
* the production feature-detection reads it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy, NounType, MigrationInProgressError } from '../../src/index.js'
|
import { Brainy, NounType, MigrationInProgressError } from '../../src/index.js'
|
||||||
import { GraphAdjacencyIndex } from '../../src/graph/graphAdjacencyIndex.js'
|
import { GraphAdjacencyIndex } from '../../src/graph/graphAdjacencyIndex.js'
|
||||||
|
|
||||||
|
|
@ -39,12 +39,6 @@ describe('Migration LOCK (#18) — coordinated 7.x→8.0 auto-upgrade', () => {
|
||||||
await brain.init()
|
await brain.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
// The "close() is not gated" test already closes `brain` itself as its
|
|
||||||
// own assertion — closing an already-closed brain is a safe no-op here.
|
|
||||||
await brain.close().catch(() => {})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('does not gate operations when no provider is migrating (fast path)', async () => {
|
it('does not gate operations when no provider is migrating (fast path)', async () => {
|
||||||
const id = await brain.add({ data: 'hello', type: NounType.Concept })
|
const id = await brain.add({ data: 'hello', type: NounType.Concept })
|
||||||
expect(id).toBeTruthy()
|
expect(id).toBeTruthy()
|
||||||
|
|
@ -136,9 +130,6 @@ describe('Migration LOCK (#18) — coordinated 7.x→8.0 auto-upgrade', () => {
|
||||||
expect(e).toBeInstanceOf(MigrationInProgressError)
|
expect(e).toBeInstanceOf(MigrationInProgressError)
|
||||||
expect(e.retryable).toBe(true)
|
expect(e.retryable).toBe(true)
|
||||||
expect(typeof e.elapsedMs).toBe('number')
|
expect(typeof e.elapsedMs).toBe('number')
|
||||||
} finally {
|
|
||||||
// close() is proven not-gated by the test below — safe even mid-migration.
|
|
||||||
await shortBrain.close()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,10 @@ describe('EmbeddingSignal', () => {
|
||||||
signal = new EmbeddingSignal(brain)
|
signal = new EmbeddingSignal(brain)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(() => {
|
||||||
signal.clearCache()
|
signal.clearCache()
|
||||||
signal.clearHistory()
|
signal.clearHistory()
|
||||||
signal.resetStats()
|
signal.resetStats()
|
||||||
await brain.close()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('initialization', () => {
|
describe('initialization', () => {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
* hydration (zero per-entity reads when unfiltered). Both must preserve the exact
|
* hydration (zero per-entity reads when unfiltered). Both must preserve the exact
|
||||||
* pagination contract: same order, cursor continuation, filters, totalCount.
|
* pagination contract: same order, cursor continuation, filters, totalCount.
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
||||||
import { Brainy, NounType } from '../../../src/index.js'
|
import { Brainy, NounType } from '../../../src/index.js'
|
||||||
|
|
||||||
describe('paginated enumeration — parallel hydration + id-only (cortex heal-cost)', () => {
|
describe('paginated enumeration — parallel hydration + id-only (cortex heal-cost)', () => {
|
||||||
|
|
@ -30,10 +30,6 @@ describe('paginated enumeration — parallel hydration + id-only (cortex heal-co
|
||||||
storage = brain.storage
|
storage = brain.storage
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
/** Page the whole dataset through a small limit via cursor and collect ordered ids. */
|
/** Page the whole dataset through a small limit via cursor and collect ordered ids. */
|
||||||
const pageAll = async (fn: (opts: any) => Promise<any>, key: 'items' | 'ids') => {
|
const pageAll = async (fn: (opts: any) => Promise<any>, key: 'items' | 'ids') => {
|
||||||
const out: string[] = []
|
const out: string[] = []
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
* Tests to verify that brain.find({ type: NounType.X }) correctly filters entities
|
* Tests to verify that brain.find({ type: NounType.X }) correctly filters entities
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy, NounType } from '../../src/index.js'
|
import { Brainy, NounType } from '../../src/index.js'
|
||||||
|
|
||||||
describe('Type Filtering (A Consumer Team Issue)', () => {
|
describe('Type Filtering (A Consumer Team Issue)', () => {
|
||||||
|
|
@ -17,10 +17,6 @@ describe('Type Filtering (A Consumer Team Issue)', () => {
|
||||||
await brain.init()
|
await brain.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should filter entities by NounType.Person', async () => {
|
it('should filter entities by NounType.Person', async () => {
|
||||||
// Add 3 people
|
// Add 3 people
|
||||||
await brain.add({ data: 'John Smith', type: NounType.Person, metadata: { name: 'John' } })
|
await brain.add({ data: 'John Smith', type: NounType.Person, metadata: { name: 'John' } })
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,6 @@ describe('the indexable-array bound', () => {
|
||||||
await brain.init()
|
await brain.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('BELOW the bound: the array indexes, every element of it', () => {
|
describe('BELOW the bound: the array indexes, every element of it', () => {
|
||||||
it('the eleven-element array that used to vanish is searchable', async () => {
|
it('the eleven-element array that used to vanish is searchable', async () => {
|
||||||
// ELEVEN — one over the old silent limit, the whole shape of the defect.
|
// ELEVEN — one over the old silent limit, the whole shape of the defect.
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
* column store adopts the field. It is named in `getIdsFromChunksForRange`'s
|
* column store adopts the field. It is named in `getIdsFromChunksForRange`'s
|
||||||
* doc comment rather than papered over.
|
* doc comment rather than papered over.
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy } from '../../../src/brainy'
|
import { Brainy } from '../../../src/brainy'
|
||||||
import { NounType } from '../../../src/types/graphTypes'
|
import { NounType } from '../../../src/types/graphTypes'
|
||||||
import { SparseIndex, ChunkManager } from '../../../src/utils/metadataIndexChunking'
|
import { SparseIndex, ChunkManager } from '../../../src/utils/metadataIndexChunking'
|
||||||
|
|
@ -122,10 +122,6 @@ describe('legacy sparse index: range queries order values, or refuse', () => {
|
||||||
expect(index.columnStore.hasField(FIELD)).toBe(false)
|
expect(index.columnStore.hasField(FIELD)).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('(a) a long BOUND against ordinary short values', () => {
|
describe('(a) a long BOUND against ordinary short values', () => {
|
||||||
// 'apple' < 'mango' < 'zebra', and every bound below is compared against
|
// 'apple' < 'mango' < 'zebra', and every bound below is compared against
|
||||||
// these three raw keys.
|
// these three raw keys.
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
* validateInvariants(), and repairIndex() maps a failing invariant with heal:'rebuild'
|
* validateInvariants(), and repairIndex() maps a failing invariant with heal:'rebuild'
|
||||||
* to that provider's rebuild(). "healthy-while-broken must be impossible."
|
* to that provider's rebuild(). "healthy-while-broken must be impossible."
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy, NounType } from '../../src/index.js'
|
import { Brainy, NounType } from '../../src/index.js'
|
||||||
import type { ProviderInvariantReport } from '../../src/index.js'
|
import type { ProviderInvariantReport } from '../../src/index.js'
|
||||||
|
|
||||||
|
|
@ -48,10 +48,6 @@ describe('validateIndexConsistency delegates to provider validateInvariants() (P
|
||||||
await brain.flush()
|
await brain.flush()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('a broken provider report makes the store unhealthy and names the failing invariant', async () => {
|
it('a broken provider report makes the store unhealthy and names the failing invariant', async () => {
|
||||||
brain.index.validateInvariants = async () => brokenReport('vector')
|
brain.index.validateInvariants = async () => brokenReport('vector')
|
||||||
const v = await brain.validateIndexConsistency()
|
const v = await brain.validateIndexConsistency()
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
* signal (from either strategy) THROWS VectorIndexNotReadyError immediately,
|
* signal (from either strategy) THROWS VectorIndexNotReadyError immediately,
|
||||||
* with no rebuild attempt in between — never a silent empty result.
|
* with no rebuild attempt in between — never a silent empty result.
|
||||||
*/
|
*/
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy, NounType, VectorIndexNotReadyError } from '../../src/index.js'
|
import { Brainy, NounType, VectorIndexNotReadyError } from '../../src/index.js'
|
||||||
|
|
||||||
const V = (): number[] => Array.from({ length: 384 }, (_, i) => Math.sin(i * 0.1) + 0.001)
|
const V = (): number[] => Array.from({ length: 384 }, (_, i) => Math.sin(i * 0.1) + 0.001)
|
||||||
|
|
@ -28,10 +28,6 @@ describe('Vector cold-read guard (verifyVectorLive) — silent-[] on cold semant
|
||||||
await brain.flush()
|
await brain.flush()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('warm brain: semantic find is correct and the guard does not rebuild', async () => {
|
it('warm brain: semantic find is correct and the guard does not rebuild', async () => {
|
||||||
const vi = brain.index
|
const vi = brain.index
|
||||||
let rebuilds = 0
|
let rebuilds = 0
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
* Tests to verify VFS import behavior and identify if VFS creates only wrappers or also graph entities
|
* Tests to verify VFS import behavior and identify if VFS creates only wrappers or also graph entities
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy, NounType } from '../../src/index.js'
|
import { Brainy, NounType } from '../../src/index.js'
|
||||||
|
|
||||||
describe('VFS Multi-instance Diagnostic', () => {
|
describe('VFS Multi-instance Diagnostic', () => {
|
||||||
|
|
@ -17,10 +17,6 @@ describe('VFS Multi-instance Diagnostic', () => {
|
||||||
await brain.init()
|
await brain.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should verify VFS creates document wrappers AND allows entity filtering', async () => {
|
it('should verify VFS creates document wrappers AND allows entity filtering', async () => {
|
||||||
console.log('\n🔬 VFS Multi-instance Diagnostic Test\n')
|
console.log('\n🔬 VFS Multi-instance Diagnostic Test\n')
|
||||||
console.log('='.repeat(70))
|
console.log('='.repeat(70))
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* Ensures tree methods prevent recursion and work correctly
|
* Ensures tree methods prevent recursion and work correctly
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy } from '../../src/brainy.js'
|
import { Brainy } from '../../src/brainy.js'
|
||||||
import { VirtualFileSystem } from '../../src/vfs/VirtualFileSystem.js'
|
import { VirtualFileSystem } from '../../src/vfs/VirtualFileSystem.js'
|
||||||
import { VFSTreeUtils } from '../../src/vfs/TreeUtils.js'
|
import { VFSTreeUtils } from '../../src/vfs/TreeUtils.js'
|
||||||
|
|
@ -24,10 +24,6 @@ describe('VFS Tree Operations', () => {
|
||||||
await vfs.init()
|
await vfs.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('Critical: No Self-Inclusion Bug', () => {
|
describe('Critical: No Self-Inclusion Bug', () => {
|
||||||
it('should NEVER return a directory as its own child', async () => {
|
it('should NEVER return a directory as its own child', async () => {
|
||||||
// Create test structure
|
// Create test structure
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
* - Issue #2: File read decompression error
|
* - Issue #2: File read decompression error
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy } from '../../src/brainy.js'
|
import { Brainy } from '../../src/brainy.js'
|
||||||
import { VirtualFileSystem } from '../../src/vfs/VirtualFileSystem.js'
|
import { VirtualFileSystem } from '../../src/vfs/VirtualFileSystem.js'
|
||||||
|
|
||||||
|
|
@ -25,10 +25,6 @@ describe('VFS Bug Fixes', () => {
|
||||||
await vfs.init()
|
await vfs.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('Issue #1: Duplicate Directory Nodes', () => {
|
describe('Issue #1: Duplicate Directory Nodes', () => {
|
||||||
it('should not create duplicate directory entries when writing multiple files to same directory', async () => {
|
it('should not create duplicate directory entries when writing multiple files to same directory', async () => {
|
||||||
// Write multiple files to the same directory (reproduce the bug scenario)
|
// Write multiple files to the same directory (reproduce the bug scenario)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
* other operations in parallel batches.
|
* other operations in parallel batches.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
import { describe, it, expect, beforeEach } from 'vitest'
|
||||||
import { Brainy } from '../../src/brainy.js'
|
import { Brainy } from '../../src/brainy.js'
|
||||||
import { VirtualFileSystem } from '../../src/vfs/VirtualFileSystem.js'
|
import { VirtualFileSystem } from '../../src/vfs/VirtualFileSystem.js'
|
||||||
|
|
||||||
|
|
@ -30,10 +30,6 @@ describe('VFS bulkWrite Race Condition Fix', () => {
|
||||||
await vfs.init()
|
await vfs.init()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await brain.close()
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('operation ordering', () => {
|
describe('operation ordering', () => {
|
||||||
it('should create directories before files when mixed in same batch', async () => {
|
it('should create directories before files when mixed in same batch', async () => {
|
||||||
// This is the exact scenario that triggered the race condition:
|
// This is the exact scenario that triggered the race condition:
|
||||||
|
|
|
||||||
Reference in a new issue