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.
This commit is contained in:
David Snelling 2026-06-17 13:11:41 -07:00
parent c600468bb5
commit e5997a1516
20 changed files with 1187 additions and 789 deletions

View file

@ -10,6 +10,7 @@
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
import { Brainy } from '../../src/brainy.js'
import { ValidationConfig, resetLimitWarningCache } from '../../src/utils/paramValidation.js'
import { mkdtempSync, rmSync } from 'fs'
import { tmpdir } from 'os'
import { join } from 'path'
@ -25,6 +26,16 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
CLOUD_RUN_MEMORY: process.env.CLOUD_RUN_MEMORY,
MEMORY_LIMIT: process.env.MEMORY_LIMIT
}
// ValidationConfig is a process-wide singleton that only rebuilds when a brain
// passes maxQueryLimit/reservedQueryMemory (brainy.ts init reconfigure). Tests
// here rely on auto-detection (container/free-memory tiers), which read live
// process state when the singleton is first constructed. Reset both the config
// singleton and the limit-warning dedup before every test so each one observes
// the env it sets — without this, basis/maxLimit bleed from earlier tests and
// results become order-dependent.
ValidationConfig.reset()
resetLimitWarningCache()
})
afterEach(() => {
@ -37,6 +48,10 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
process.env[key] = originalEnv[key]
}
})
// Leave the singleton clean for any other integration file sharing this process.
ValidationConfig.reset()
resetLimitWarningCache()
})
describe('Production Workflow: Cloud Run Deployment', () => {
@ -55,9 +70,12 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
// Verify container detected
expect(stats.memory.containerLimit).toBe(4 * 1024 * 1024 * 1024)
// Verify optimal limits
// Verify optimal limits.
// containerMemory tier reserves 25% of the container for queries, then
// divides by 25 KB/result (MAX_LIMIT_KB_PER_RESULT) and floors to 1k steps:
// 4GiB * 0.25 = 1 GiB; floor(1 GiB / (25 KB)) = 40_960 -> 40_000.
expect(stats.limits.basis).toBe('containerMemory')
expect(stats.limits.maxQueryLimit).toBe(10000) // 25% of 4GB
expect(stats.limits.maxQueryLimit).toBe(40000)
// Verify can query with these limits
for (let i = 0; i < 100; i++) {
@ -102,8 +120,10 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
const stats = brain.getMemoryStats()
// reservedMemory tier divides the reserved bytes by 25 KB/result and floors
// to 1k steps: floor(2 GiB / (25 KB)) = 81_920 -> 81_000.
expect(stats.limits.basis).toBe('reservedMemory')
expect(stats.limits.maxQueryLimit).toBe(20000) // 2GB / 100MB * 1000
expect(stats.limits.maxQueryLimit).toBe(81000)
await brain.close()
})
@ -154,8 +174,8 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
expect(stats.memory.containerLimit).toBeDefined()
expect(stats.config).toBeDefined()
// Can debug: "Why is my limit only 10k?"
// Answer: basis='containerMemory', container=4GB, 4GB * 0.25 = 1GB -> 10k
// Can debug: "Why is my limit what it is?"
// Answer: basis='containerMemory', container=4GB, 4GB * 0.25 = 1GB / 25KB -> 40k
await brain.close()
})
@ -175,12 +195,13 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
// Zero config, optimal behavior
const stats = brain.getMemoryStats()
expect(stats.limits.maxQueryLimit).toBe(10000)
// Same calc as the 4GiB container test above: 25% of 4 GiB / 25 KB -> 40_000.
expect(stats.limits.maxQueryLimit).toBe(40000)
expect(stats.limits.basis).toBe('containerMemory')
// Should work without issues
for (let i = 0; i < 100; i++) {
await brain.add({ type: 'note', data: `Test ${i}` })
await brain.add({ type: 'document', data: `Test ${i}` })
}
const results = await brain.find({ limit: 100 })