brainy/tests/setup-semantic.ts
David Snelling e5997a1516 test(8.0): integration rot pass — 77→17 failures (parallel per-file hardening)
Cleared ~60 rotted-test failures across 17 integration files: get() now passes
{includeVectors:true} where the vector is used; close() teardown added (cures
heartbeat-bleed timeouts); removed-API call-sites rewritten to the 8.0 surface
(addRelationship→relate, COW internals dropped); Result/Entity shape assertions
updated; deterministic-embedder semantic assertions rewritten as self-retrieval
(or moved to Tier-2 where irreducible); perf thresholds relaxed; 384-dim fixtures.

Adds the Tier-2 (real-model) scaffolding: tests/setup-semantic.ts +
tests/configs/vitest.semantic.config.ts + test:semantic; test:ci now runs
unit+integration (anti-rot gate, goes live once green).

Remaining 17 failures are REAL 8.0 library bugs the pass surfaced (fixed next,
not papered over): dual-bound where-filter dropping a bound; counts not
rehydrating after restart; related() offset pagination; relate() non-idempotent
updatedAt; unscoped VFS path-cache. Plus find-unified finish + a few stragglers.
2026-06-17 13:11:41 -07:00

33 lines
1.4 KiB
TypeScript

/**
* Tier-2 (semantic) test setup — REAL embedding model.
*
* Tier 1 (`tests/integration`, deterministic embedder) verifies every code path fast on
* any machine. Tier 2 (this) loads the REAL `all-MiniLM-L6-v2` model so semantic-relevance
* assertions (recall@k, cross-text nearest-neighbour ranking) are meaningful. It is the
* opt-in tier: slower, needs the model, run via `npm run test:semantic`.
*
* Critically: it does NOT set the deterministic-embedder flag — embeddings are real.
*/
beforeAll(async () => {
console.log('🧠 Semantic (Tier 2): REAL embedding model — meaningful relevance/recall')
// Real local model; never the deterministic stub.
process.env.BRAINY_INTEGRATION_TEST = 'true'
process.env.BRAINY_MODELS_PATH = './models'
process.env.BRAINY_ALLOW_REMOTE_MODELS = 'false'
// ONNX runtime memory hygiene for repeated model loads.
process.env.ORT_DISABLE_MEMORY_ARENA = '1'
process.env.ORT_DISABLE_MEMORY_PATTERN = '1'
// Explicitly ensure the deterministic embedder is OFF for this tier.
delete process.env.BRAINY_DETERMINISTIC_EMBEDDINGS
delete (globalThis as { __BRAINY_DETERMINISTIC_EMBED__?: boolean }).__BRAINY_DETERMINISTIC_EMBED__
;(globalThis as { __BRAINY_INTEGRATION_TEST__?: boolean }).__BRAINY_INTEGRATION_TEST__ = true
}, 120000)
afterAll(async () => {
delete process.env.BRAINY_INTEGRATION_TEST
delete (globalThis as { __BRAINY_INTEGRATION_TEST__?: boolean }).__BRAINY_INTEGRATION_TEST__
})