The integration suite loaded the real WASM model for every test, so a full run took ~hours and reliably aborted (vitest reporter timeout) — which is why it was never gated and silently rotted. Brainy already separates the embedder from all other logic, so running integration with a deterministic embedder keeps every code path real (HNSW build+search, graph traversal, metadata filtering, transactions, storage/sharding, VFS, aggregation, import) while making the suite complete in ~2 min on ANY machine — no GPU, no 16 GB requirement. - Add isDeterministicEmbedMode() — a single source of truth for the test-embedder switch (BRAINY_DETERMINISTIC_EMBEDDINGS, plus the legacy BRAINY_UNIT_TEST alias), used by EmbeddingManager (init/embed/embedBatch) and brainy's eager-init guard. - setup-integration.ts opts into it: Tier 1 = functional end-to-end. Real-model semantic quality + the real embedding pipeline move to a Tier-2 suite. Full integration now runs 482 passing / 583 in ~2 min (was un-completable). The remaining failures are pre-existing test rot, fixed next. Unit 1414 green.
44 lines
2.1 KiB
TypeScript
44 lines
2.1 KiB
TypeScript
/**
|
|
* Integration Test Setup — Tier 1: Functional end-to-end (deterministic embedder)
|
|
*
|
|
* These tests exercise every real code path — HNSW build + search, graph
|
|
* traversal, metadata filtering, triple-intelligence composition, MVCC
|
|
* transactions, sharding/persistence, VFS, aggregation, import — but with a
|
|
* DETERMINISTIC embedder instead of the real WASM transformer. The embedding's
|
|
* semantic *quality* is irrelevant to these assertions (which are structural:
|
|
* counts, ids, relationships, self-retrieval, transaction outcomes); making the
|
|
* vector deterministic turns a multi-hour, un-completable suite into a sub-minute
|
|
* one that any contributor can run on any machine, no GPU or 16 GB required.
|
|
*
|
|
* Semantic relevance + the real embedding pipeline are covered separately by the
|
|
* Tier-2 semantic suite (`tests/semantic/`, real model) — see
|
|
* `tests/configs/vitest.semantic.config.ts`.
|
|
*/
|
|
|
|
beforeAll(() => {
|
|
console.log('🧪 Integration (Tier 1): deterministic embedder, all other code paths real')
|
|
|
|
// Deterministic embeddings — see src/embeddings/deterministicEmbedMode.ts.
|
|
process.env.BRAINY_DETERMINISTIC_EMBEDDINGS = 'true'
|
|
;(globalThis as { __BRAINY_DETERMINISTIC_EMBED__?: boolean }).__BRAINY_DETERMINISTIC_EMBED__ = true
|
|
|
|
// Marker retained for any test that branches on the integration environment.
|
|
;(globalThis as { __BRAINY_INTEGRATION_TEST__?: boolean }).__BRAINY_INTEGRATION_TEST__ = true
|
|
})
|
|
|
|
afterAll(() => {
|
|
delete process.env.BRAINY_DETERMINISTIC_EMBEDDINGS
|
|
delete (globalThis as { __BRAINY_DETERMINISTIC_EMBED__?: boolean }).__BRAINY_DETERMINISTIC_EMBED__
|
|
delete (globalThis as { __BRAINY_INTEGRATION_TEST__?: boolean }).__BRAINY_INTEGRATION_TEST__
|
|
})
|
|
|
|
/**
|
|
* No-op retained for back-compat. Tier-1 integration tests use the deterministic
|
|
* embedder, so the real model's 16 GB requirement no longer applies — there is
|
|
* nothing to gate on. (Real-model memory cost lives in the Tier-2 semantic suite.)
|
|
*
|
|
* @param _minGB - Ignored.
|
|
*/
|
|
export function requiresMemory(_minGB: number): void {
|
|
// Intentionally empty — see the doc comment above.
|
|
}
|