brainy/tests/configs/vitest.unit.config.ts
David Snelling 42ae5be455 feat: ID-first storage architecture + remove memory-unsafe APIs (v6.0.0)
BREAKING CHANGES:

**ID-First Storage Paths**
- Direct O(1) entity access without type lookups
- Before: entities/nouns/{TYPE}/metadata/{SHARD}/{ID}.json
- After:  entities/nouns/{SHARD}/{ID}/metadata.json
- Migration handled automatically on first init()

**Removed Memory-Unsafe APIs**
- Removed brain.merge() - loaded all entities into memory
- Removed brain.diff() - loaded all entities into memory
- Removed brain.data().backup() - loaded all entities into memory
- Removed brain.data().restore() - depended on backup()
- Removed CLI commands: backup, restore, cow merge

**Migration Paths**
- merge() → Use checkout() or manually copy entities with pagination
- diff() → Use asOf() with manual paginated comparison
- backup() → Use fork() for instant COW snapshots
- restore() → Use checkout() to switch to snapshot branch

Core Improvements:
-  All 8 storage adapters properly call super.init()
-  GraphAdjacencyIndex integration in BaseStorage.init()
-  Fixed ID-first path bugs (vector.json → vectors.json)
-  Fixed MemoryStorage.initializeCounts() for ID-first paths
-  New VFS APIs: du(), access(), find()
-  Comprehensive documentation with migration guides

Storage Adapters Fixed:
- MemoryStorage, FileSystemStorage, AzureBlobStorage
- GCSStorage, R2Storage, S3CompatibleStorage
- OPFSStorage, HistoricalStorageAdapter

Files Changed: 28 files, +1,075/-1,933 lines (net -858)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-19 16:46:11 -08:00

59 lines
No EOL
1.6 KiB
TypeScript

import { defineConfig } from 'vitest/config'
/**
* Unit Test Configuration - NO REAL AI MODELS
*
* Based on industry practices from HuggingFace, sentence-transformers, etc.
* Unit tests use mocks to avoid memory issues entirely.
*/
export default defineConfig({
test: {
globals: true,
setupFiles: ['./tests/setup-unit.ts'],
environment: 'node',
// UNIT TESTS: Fast execution, no memory issues
// v6.0.0: Increased timeouts for GraphAdjacencyIndex initialization with forks
testTimeout: 30000, // 30 seconds
hookTimeout: 30000, // 30 seconds (increased for init() with forks)
// Include only unit tests
include: [
'tests/unit/**/*.test.ts',
'tests/**/*.unit.test.ts'
],
// Exclude integration tests
exclude: [
'tests/integration/**',
'tests/**/*.integration.test.ts',
'tests/**/*.e2e.test.ts',
'tests/unit/graph/graphIndex-pagination.test.ts', // v6.0.0: TODO fix infinite loop
'node_modules/**'
],
// v6.0.0: Use 'threads' with proper setup (fast, ONNX mocked in setup-unit.ts)
// Industry standard: mock native modules in unit tests (HuggingFace, Transformers.js)
pool: 'threads',
poolOptions: {
threads: {
singleThread: false
}
},
reporters: ['verbose'],
// Coverage for unit tests
coverage: {
enabled: true,
provider: 'v8',
reporter: ['text', 'html'],
include: ['src/**/*.ts'],
exclude: [
'src/**/*.test.ts',
'src/embeddings/worker-*.ts', // Skip worker files
'dist/**'
]
}
}
})