BREAKING API CHANGES IN v5.1.0: 1. VFS now a property (brain.vfs) not method (brain.vfs()) 2. VFS auto-initializes during brain.init() - no separate vfs.init() needed 3. Root directory (/) created automatically during brain.init() 4. Stricter UUID validation (32 hex chars required) 5. VFS readFile() returns Buffer (use .toString() for string) TEST FIXES (106 tests fixed, 86% → 96.7% pass rate): - Fixed brain.vfs() → brain.vfs in 17 test files - Updated VFS initialization tests for auto-init behavior - Fixed type-filtering test to account for VFS root directory - Fixed UUID validation tests to use valid UUID format - Updated VFS readFile expectations (Buffer → string conversion) FILES UPDATED (19 test files): - tests/unit/brainy-core.unit.test.ts (UUID validation) - tests/unit/type-filtering.unit.test.ts (VFS root count) - tests/unit/workshop-vfs-diagnostic.test.ts (VFS API) - tests/vfs/vfs-initialization.unit.test.ts (auto-init behavior) - tests/vfs/vfs.unit.test.ts (VFS API) - tests/vfs/vfs-bug-fixes.unit.test.ts (VFS API) - tests/integration/* (VFS API changes, 7 files) - tests/manual/* (VFS API changes, 5 files) TEST RESULTS: - Before: 906/1051 passing (86%), 120 failures - After: 1016/1051 passing (96.7%), 14 failures - Critical systems: VFS (✓ ALL PASS), COW (✓ ALL PASS), Batch Ops (✓ 25/26) Remaining 14 failures are edge cases (UUID validation) - will fix in patch.
90 lines
3.1 KiB
TypeScript
90 lines
3.1 KiB
TypeScript
/**
|
|
* Diagnostic: Check if isVFS flag is actually being stored
|
|
*/
|
|
|
|
import { describe, it, expect, beforeAll, afterAll } from 'vitest'
|
|
import { Brainy } from '../../src/brainy.js'
|
|
import { NounType } from '../../src/types/graphTypes.js'
|
|
import * as fs from 'fs'
|
|
import * as path from 'path'
|
|
|
|
describe('isVFS Flag Diagnostic', () => {
|
|
const testDir = path.join(process.cwd(), 'test-isvfs-diagnostic')
|
|
let brain: Brainy
|
|
|
|
beforeAll(async () => {
|
|
if (fs.existsSync(testDir)) {
|
|
fs.rmSync(testDir, { recursive: true, force: true })
|
|
}
|
|
fs.mkdirSync(testDir, { recursive: true })
|
|
|
|
brain = new Brainy({
|
|
storage: {
|
|
type: 'filesystem',
|
|
options: { path: testDir }
|
|
}
|
|
})
|
|
await brain.init()
|
|
})
|
|
|
|
afterAll(() => {
|
|
if (fs.existsSync(testDir)) {
|
|
fs.rmSync(testDir, { recursive: true, force: true })
|
|
}
|
|
})
|
|
|
|
it('should show what entities are created', async () => {
|
|
// Create VFS file
|
|
const vfs = brain.vfs
|
|
await vfs.init()
|
|
await vfs.writeFile('/test.txt', 'Hello World')
|
|
|
|
// Get ALL entities
|
|
console.log('\n📋 All entities in database:')
|
|
const allEntities = await brain.find({ limit: 100, includeVFS: true })
|
|
console.log(` Total: ${allEntities.length}`)
|
|
|
|
for (const entity of allEntities) {
|
|
console.log(`\n Entity: ${entity.id}`)
|
|
console.log(` Type: ${entity.type}`)
|
|
console.log(` Metadata keys: ${Object.keys(entity.metadata || {}).join(', ')}`)
|
|
if (entity.metadata?.path) {
|
|
console.log(` Path: ${entity.metadata.path}`)
|
|
}
|
|
if (entity.metadata?.vfsType) {
|
|
console.log(` VfsType: ${entity.metadata.vfsType}`)
|
|
}
|
|
if (entity.metadata?.isVFS !== undefined) {
|
|
console.log(` isVFS: ${entity.metadata.isVFS}`)
|
|
}
|
|
if (entity.metadata?.name) {
|
|
console.log(` Name: ${entity.metadata.name}`)
|
|
}
|
|
}
|
|
|
|
// Try different queries
|
|
console.log('\n\n📋 Query 1: brain.find({ limit: 100 }) [default, no includeVFS]')
|
|
const query1 = await brain.find({ limit: 100 })
|
|
console.log(` Results: ${query1.length}`)
|
|
|
|
console.log('\n📋 Query 2: brain.find({ limit: 100, includeVFS: true })')
|
|
const query2 = await brain.find({ limit: 100, includeVFS: true })
|
|
console.log(` Results: ${query2.length}`)
|
|
|
|
console.log('\n📋 Query 3: brain.find({ where: { isVFS: true } })')
|
|
const query3 = await brain.find({ where: { isVFS: true }, limit: 100 })
|
|
console.log(` Results: ${query3.length}`)
|
|
|
|
console.log('\n📋 Query 4: brain.find({ where: { path: "/test.txt" } })')
|
|
const query4 = await brain.find({ where: { path: '/test.txt' }, limit: 100 })
|
|
console.log(` Results: ${query4.length}`)
|
|
|
|
console.log('\n📋 Query 5: brain.find({ type: NounType.Document })')
|
|
const query5 = await brain.find({ type: NounType.Document, limit: 100 })
|
|
console.log(` Results: ${query5.length}`)
|
|
|
|
console.log('\n📋 Query 6: brain.find({ type: NounType.Document, includeVFS: true })')
|
|
const query6 = await brain.find({ type: NounType.Document, includeVFS: true, limit: 100 })
|
|
console.log(` Results: ${query6.length}`)
|
|
})
|
|
})
|