chore(8.0): Phase C + D + E — config simplification, TODO sweep, test race fix

Phase C: storageAutoConfig.ts rewrite (376 LOC → ~110 LOC). The four cloud
adapters are gone so the auto-detection state machine collapses to a single
filesystem-vs-memory choice. StorageType enum is now {MEMORY, FILESYSTEM} only;
StoragePreset stays {AUTO, MEMORY, DISK}. zeroConfig.ts hard-pins
s3Available: false now that the type narrows past the runtime check.

Phase D: TODO/FIXME sweep in src/. Removed seven stale markers. The CLI cow
migrate command's backup path now uses fs.cp with recursive + force:false
instead of a TODO placeholder.

Phase E: skipped-test deletion + parallel-test race fix.
  - storage-batch-operations.test.ts loses its "Cloud Adapter Batch
    Operations" block (GCS/S3/Azure tests, 88 LOC).
  - cow-full-integration.test.ts loses its skipped "S3 adapter" test.
  - create-entities-default.test.ts had testDir hardcoded to
    './test-create-entities-default'; parallel vitest shards collided on
    the writer lock. testDir is now os.tmpdir() + pid + random, and the
    storage option is rootDirectory (the recognized key — the prior
    'path' key fell through to './brainy-data' and triggered a separate
    lock collision against any concurrent default-pathed brain). Added
    afterEach brain.close() so the lock releases before rmSync.
This commit is contained in:
David Snelling 2026-06-09 15:46:51 -07:00
parent cb16a39a0c
commit 2626ab8d62
10 changed files with 94 additions and 485 deletions

View file

@ -12,10 +12,14 @@ import * as path from 'path'
describe('createEntities Default Value (v4.3.2 Bug Fix)', () => {
let brain: Brainy
const testDir = './test-create-entities-default'
// Unique testDir per test invocation so parallel vitest shards don't fight
// over the same writer lock on filesystem storage.
const testDir = path.join(
require('os').tmpdir(),
`brainy-create-entities-default-${process.pid}-${Math.random().toString(36).slice(2)}`
)
beforeEach(async () => {
// Clean up test directory
if (fs.existsSync(testDir)) {
fs.rmSync(testDir, { recursive: true })
}
@ -23,14 +27,18 @@ describe('createEntities Default Value (v4.3.2 Bug Fix)', () => {
brain = new Brainy({ requireSubtype: false,
storage: {
type: 'filesystem',
path: testDir
rootDirectory: testDir
}
})
await brain.init()
})
afterEach(() => {
// Clean up test directory
afterEach(async () => {
// Release the writer lock before cleaning up the directory, otherwise
// parallel vitest shards see a stale lockfile on retry.
if (brain) {
try { await brain.close() } catch { /* noop */ }
}
if (fs.existsSync(testDir)) {
fs.rmSync(testDir, { recursive: true })
}