brainy/tests/vfs/vfs-initialization.unit.test.ts
David Snelling bf0afe8563 refactor(8.0): remove dead, unreachable, and unwired modules
Pre-GA dead-code sweep. A deterministic import-reachability walk from the
package's real entry points (the exports map, the CLI bin, the conversation
surface) found 34 source modules that nothing reachable imports — they
compile and ship as dist output that no consumer or internal path can ever
reach. All were superseded duplicates, abandoned parallel implementations,
or built-but-never-wired features:

  - superseded duplicates of live modules: an older "unified" entry, a
    standalone neural-import variant, a static NLP processor + its matcher,
    a parallel API-types module, a duplicate progress-types module
  - an abandoned import path (orchestrator + entity deduplicator + barrels)
    left behind when ingestion moved to the coordinator
  - unwired feature modules (instance pool, import presets, cached
    embeddings, relationship-confidence scorer) reachable only from tests
  - dead leaf utilities (write buffer, deleted-items index, bounded
    registry, two crypto shims, a cache manager, a structured logger, a
    stale v5 type-migration helper, a browser-only FS type shim) and
    several dead re-export barrels
  - a CLI catalog command wired into no command

Also removed two tests that only exercised deleted modules, repointed two
VFS tests off a deleted barrel onto the implementation module, and deleted
one example that demoed removed features.

Verified: clean build (both tsc passes), unit 1505 + integration 607 green,
and a re-run of the reachability walk reports zero remaining orphans.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 15:18:40 -07:00

84 lines
2.4 KiB
TypeScript

/**
* VFS Initialization Tests
*
* Tests v5.1.0+ auto-initialization behavior
*/
import { describe, it, expect } from 'vitest'
import { VirtualFileSystem } from '../../src/vfs/VirtualFileSystem.js'
import { Brainy } from '../../src/brainy.js'
describe('VFS Initialization', () => {
describe('Auto-Initialization (v5.1.0+)', () => {
it('should auto-initialize VFS during brain.init()', async () => {
const brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' },
silent: true
})
await brain.init()
const vfs = brain.vfs
// VFS is ready to use immediately after brain.init()
await vfs.writeFile('/test.txt', 'Hello World')
const content = await vfs.readFile('/test.txt')
expect(content.toString()).toBe('Hello World')
await brain.close()
})
it('should automatically create root directory on brain.init()', async () => {
const brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' },
silent: true
})
await brain.init()
const vfs = brain.vfs
// Root directory exists after brain.init()
expect(await vfs.exists('/')).toBe(true)
// Root is a directory
const stats = await vfs.stat('/')
expect(stats.isDirectory()).toBe(true)
// Can list root directory
const entries = await vfs.readdir('/')
expect(Array.isArray(entries)).toBe(true)
await brain.close()
})
it('should handle nested directories after brain.init()', async () => {
const brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' },
silent: true
})
await brain.init()
const vfs = brain.vfs
// Create nested structure
await vfs.mkdir('/documents')
await vfs.writeFile('/documents/readme.txt', 'Important info')
await vfs.mkdir('/documents/reports')
await vfs.writeFile('/documents/reports/q1.txt', 'Q1 Report')
// Verify structure
const rootEntries = await vfs.readdir('/')
expect(rootEntries).toContain('documents')
const docEntries = await vfs.readdir('/documents')
expect(docEntries).toContain('readme.txt')
expect(docEntries).toContain('reports')
const reportEntries = await vfs.readdir('/documents/reports')
expect(reportEntries).toContain('q1.txt')
await brain.close()
})
})
})