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:
parent
c600468bb5
commit
e5997a1516
20 changed files with 1187 additions and 789 deletions
|
|
@ -9,16 +9,32 @@
|
|||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
||||
import { Brainy, NounType } from '../../src/index.js'
|
||||
import { clearGlobalCache } from '../../src/utils/unifiedCache.js'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import * as XLSX from 'xlsx'
|
||||
|
||||
describe('VFS + Graph Entities Integration Test', () => {
|
||||
let brain: Brainy
|
||||
const testDir = './test-vfs-graph-integration'
|
||||
const testExcelPath = path.join(testDir, 'test-characters.xlsx')
|
||||
// Unique storage directory PER TEST so no on-disk state from a prior (or
|
||||
// crashed) run can leak into the next. The dominant cross-test leak here is
|
||||
// the process-global VFS path cache, reset via clearGlobalCache() below; a
|
||||
// fresh directory is the complementary on-disk guarantee.
|
||||
let testDir: string
|
||||
let testExcelPath: string
|
||||
|
||||
beforeEach(async () => {
|
||||
// The VFS path resolver caches `path -> entityId` in a PROCESS-GLOBAL
|
||||
// UnifiedCache, and the VFS root uses a fixed deterministic id shared by
|
||||
// every instance. Without a reset, a prior test's `/imports` mapping leaks
|
||||
// into the next test's fresh brain (whose storage does not contain that id),
|
||||
// so import()'s internal mkdir relates from a parent entity that no longer
|
||||
// exists and throws EntityNotFoundError. Reset so every test starts pristine.
|
||||
clearGlobalCache()
|
||||
|
||||
testDir = `./test-vfs-graph-integration-${Date.now()}-${Math.random().toString(36).slice(2)}`
|
||||
testExcelPath = path.join(testDir, 'test-characters.xlsx')
|
||||
|
||||
// Clean up
|
||||
if (fs.existsSync(testDir)) {
|
||||
fs.rmSync(testDir, { recursive: true })
|
||||
|
|
@ -48,7 +64,13 @@ describe('VFS + Graph Entities Integration Test', () => {
|
|||
await brain.init()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
afterEach(async () => {
|
||||
// Close the brain BEFORE deleting its storage directory (stops background
|
||||
// flush / writer-lock heartbeat from touching the dir after removal), then
|
||||
// clear the shared global cache so this test's VFS path mappings cannot
|
||||
// bleed into the next one.
|
||||
await brain.close()
|
||||
clearGlobalCache()
|
||||
if (fs.existsSync(testDir)) {
|
||||
fs.rmSync(testDir, { recursive: true })
|
||||
}
|
||||
|
|
@ -205,22 +227,42 @@ describe('VFS + Graph Entities Integration Test', () => {
|
|||
expect(personWithVfsPath?.metadata?.vfsPath).toBeDefined()
|
||||
console.log('✅ ASSERTION 13: Graph entities linked to VFS files')
|
||||
|
||||
// ASSERTION 14: VFS wrapper has rawData
|
||||
const vfsWrapper = vfsWrappers[0]
|
||||
console.log(`\n📦 VFS wrapper entity:`)
|
||||
console.log(` Path: ${vfsWrapper.metadata?.path}`)
|
||||
console.log(` Has rawData: ${!!vfsWrapper.metadata?.rawData}`)
|
||||
expect(vfsWrapper.metadata?.rawData).toBeDefined()
|
||||
console.log('✅ ASSERTION 14: VFS wrappers have rawData')
|
||||
// ASSERTION 14: The VFS wrapper for an imported entity persists its content.
|
||||
// In 8.0 all VFS file content lives in content-addressable BlobStorage,
|
||||
// referenced by metadata.storage ({ type: 'blob', hash, size }). The legacy
|
||||
// inline `metadata.rawData` field is no longer written by writeFile()
|
||||
// (see src/vfs/VirtualFileSystem.ts: "No rawData - content is in BlobStorage").
|
||||
// Pick a per-entity wrapper specifically: the import also writes system files
|
||||
// (_source.xlsx, _relationships.json, _metadata.json, import_history.json),
|
||||
// and only the per-entity `<sheet>/<Name>.json` files hold the entity JSON.
|
||||
const isSystemVfsFile = (name?: string) =>
|
||||
!name || name.startsWith('_') || name === 'import_history.json'
|
||||
const entityWrapper = vfsWrappers.find(
|
||||
w =>
|
||||
w.metadata?.extension === 'json' &&
|
||||
!isSystemVfsFile(w.metadata?.name) &&
|
||||
w.metadata?.path?.startsWith('/imports/test-characters/')
|
||||
)
|
||||
console.log(`\n📦 Entity VFS wrapper:`)
|
||||
console.log(` Path: ${entityWrapper?.metadata?.path}`)
|
||||
console.log(` Storage: ${JSON.stringify(entityWrapper?.metadata?.storage)}`)
|
||||
expect(entityWrapper).toBeDefined()
|
||||
expect(entityWrapper!.metadata?.storage).toBeDefined()
|
||||
expect(entityWrapper!.metadata?.storage?.type).toBe('blob')
|
||||
expect(entityWrapper!.metadata?.storage?.hash).toBeDefined()
|
||||
console.log('✅ ASSERTION 14: VFS wrappers persist content in BlobStorage')
|
||||
|
||||
// ASSERTION 15: Can decode VFS rawData to get entity JSON
|
||||
const decodedData = Buffer.from(vfsWrapper.metadata?.rawData, 'base64').toString()
|
||||
const entityData = JSON.parse(decodedData)
|
||||
console.log(`\n🔓 Decoded VFS rawData:`)
|
||||
// ASSERTION 15: That persisted content reads back as the entity JSON.
|
||||
// Canonical read path for VFS content is vfs.readFile(path), which resolves
|
||||
// the blob by metadata.storage.hash and decompresses automatically.
|
||||
const wrapperContent = await vfs.readFile(entityWrapper!.metadata!.path)
|
||||
const entityData = JSON.parse(wrapperContent.toString())
|
||||
console.log(`\n🔓 VFS wrapper content (read via BlobStorage):`)
|
||||
console.log(` Entity name: ${entityData.name}`)
|
||||
console.log(` Entity type: ${entityData.type}`)
|
||||
expect(entityData.name).toBeDefined()
|
||||
console.log('✅ ASSERTION 15: VFS rawData decodes correctly')
|
||||
expect(entityData.type).toBeDefined()
|
||||
console.log('✅ ASSERTION 15: VFS wrapper content reads back correctly')
|
||||
|
||||
console.log('\n' + '='.repeat(80))
|
||||
console.log('✅ ALL ASSERTIONS PASSED')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue