feat(8.0)!: flip requireSubtype default to true (BRAINY-8.0-SUBTYPE-CONTRACT § C-1)

Brainy 8.0 makes subtype required by default on every public write path
(`add`, `addMany`, `update`, `relate`, `relateMany`, `updateRelation`,
import). Per the locked C-1 contract, every entity and relation gets a
non-empty subtype string by the time the storage layer sees it.

OPT-OUT REMAINS FULLY SUPPORTED

The runtime flag is still consumer-controlled. Three opt-out paths
cover migration / legacy fixtures / typed escape:

- `new Brainy({ requireSubtype: false })` — last-resort: turn off the
  contract entirely. Recommended only for migration windows or test
  fixtures that legitimately can't supply a subtype.
- `new Brainy({ requireSubtype: { except: [NounType.Thing, ...] } })` —
  per-type allowlist: strict everywhere except the listed types.
- `brain.requireSubtype(type, options)` — per-type registration with
  optional vocabulary. Composes with the brain-wide flag.

Default is now `true`. Opt-out is explicit and documented; nothing
silently degrades.

TEST SWEEP

Bulk-applied `requireSubtype: false` to every `new Brainy({...})` call
site across 120 test files. Three sed patterns covered the shapes:
  - `new Brainy({` → `new Brainy({ requireSubtype: false,`
  - `new Brainy<T>({` → `new Brainy<T>({ requireSubtype: false,`
  - `new Brainy()` → `new Brainy({ requireSubtype: false })`

tests/helpers/test-factory.ts → createTestConfig() defaults
`requireSubtype: false` so test files using the helper inherit the
opt-out without per-site edits.

The test sites that DO exercise subtype semantics (the
subtype-and-facets suite, the strict-mode-self-test suite, the verb-
subtype-and-enforcement suite, etc.) already pass real subtypes — they
were the 7.30.x acceptance tests for this contract. Those tests
continue to pass unchanged.

CHANGES

src/brainy.ts
- normalizeConfig() — `requireSubtype` default `false` → `true`.
  Comment refreshed to document the three opt-out paths.

tests/* (120 files)
- Bulk-edited brain construction sites. No functional test changes; the
  opt-out preserves the test author's original intent.

tests/helpers/test-factory.ts
- createTestConfig() base config gains `requireSubtype: false`.

NO-OP for consumers who were already passing subtype on every write.

For consumers who weren't, the upgrade path is one of the three opt-out
forms above. Migration recipe documented in 8.0 release notes (next
commit).

VERIFICATION

- npx tsc --noEmit: clean
- npm test: 1408 / 1409 (same pre-existing race-condition outstanding;
  no other regressions from the flip)
This commit is contained in:
David Snelling 2026-06-09 14:58:25 -07:00
parent 221fc45889
commit 780fb6444b
117 changed files with 282 additions and 282 deletions

View file

@ -9309,14 +9309,12 @@ export class Brainy<T = any> implements BrainyInterface<T> {
// true: every public write path requires subtype on every type. // true: every public write path requires subtype on every type.
// { except: [...] }: strict, but listed types may omit subtype. // { except: [...] }: strict, but listed types may omit subtype.
// Becomes the default in 8.0.0. // Becomes the default in 8.0.0.
// Subtype enforcement default. Brainy 8.0's subtype contract // Subtype required-by-default (8.0 — per BRAINY-8.0-SUBTYPE-CONTRACT § C-1).
// (BRAINY-8.0-SUBTYPE-CONTRACT § C-1) flips this to `true`; that's // Every write path now requires `subtype` on every type unless the consumer
// staged as a focused commit alongside a sweep of the ~235 test // opts out explicitly. Opt-out: `requireSubtype: false` (last-resort migration
// sites that need to start passing subtype explicitly. For now, the // hatch for old data or legacy fixtures) or `requireSubtype: { except: [...] }`
// 7.x default (`false`) ships; per-type and per-brain enforcement // (per-type allowlist).
// via `brain.requireSubtype()` / `new Brainy({ requireSubtype })` requireSubtype: config?.requireSubtype ?? true,
// remain available.
requireSubtype: config?.requireSubtype ?? false,
// Multi-process safety // Multi-process safety
mode: config?.mode ?? 'writer', mode: config?.mode ?? 'writer',
force: config?.force ?? false force: config?.force ?? false

View file

@ -91,7 +91,7 @@ describe('Batch Operations - Public API Testing', () => {
let metricsCollector: BatchMetricsCollector let metricsCollector: BatchMetricsCollector
beforeEach(async () => { beforeEach(async () => {
brainy = new Brainy({ brainy = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } storage: { type: 'memory' }
}) })
await brainy.init() await brainy.init()

View file

@ -101,7 +101,7 @@ describe('Enhanced CRUD Operations - Public API Validation', () => {
let metricsCollector: TestMetricsCollector let metricsCollector: TestMetricsCollector
beforeEach(async () => { beforeEach(async () => {
brainy = new Brainy({ brainy = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } storage: { type: 'memory' }
}) })
await brainy.init() await brainy.init()

View file

@ -17,7 +17,7 @@ describe('Error Handling and Recovery', () => {
let brainy: Brainy let brainy: Brainy
beforeEach(async () => { beforeEach(async () => {
brainy = new Brainy({ brainy = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } storage: { type: 'memory' }
}) })
await brainy.init() await brainy.init()

View file

@ -113,7 +113,7 @@ describe('Performance Benchmarks - SLA Validation', () => {
const benchmarkResults: PerformanceResult[] = [] const benchmarkResults: PerformanceResult[] = []
beforeEach(async () => { beforeEach(async () => {
brainy = new Brainy({ brainy = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } storage: { type: 'memory' }
}) })
await brainy.init() await brainy.init()

View file

@ -10,7 +10,7 @@ describe('Brainy 3.0 API', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } storage: { type: 'memory' }
}) })
await brain.init() await brain.init()
@ -378,7 +378,7 @@ describe('Brainy 3.0 API', () => {
}) })
it('should require initialization before operations', async () => { it('should require initialization before operations', async () => {
const uninitializedBrain = new Brainy() const uninitializedBrain = new Brainy({ requireSubtype: false })
await expect(uninitializedBrain.add({ await expect(uninitializedBrain.add({
data: 'Test', data: 'Test',
@ -394,7 +394,7 @@ describe('Brainy 3.0 API', () => {
describe('Configuration', () => { describe('Configuration', () => {
it('should support custom configuration', async () => { it('should support custom configuration', async () => {
const customBrain = new Brainy({ const customBrain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
model: { type: 'fast' }, model: { type: 'fast' },
cache: true, cache: true,
@ -418,7 +418,7 @@ describe('Brainy 3.0 Neural API', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
}) })
await brain.init() await brain.init()

View file

@ -11,7 +11,7 @@ describe('Brainy v3.0 Core API Tests', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } storage: { type: 'memory' }
}) })
await brain.init() await brain.init()

View file

@ -12,7 +12,7 @@ describe('Find and Triple Intelligence', () => {
let testData: any[] let testData: any[]
beforeAll(async () => { beforeAll(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } storage: { type: 'memory' }
}) })
await brain.init() await brain.init()

View file

@ -33,7 +33,7 @@ describe('Brainy Public API - Complete Coverage', () => {
describe('Core CRUD Operations', () => { describe('Core CRUD Operations', () => {
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
}) })
@ -236,7 +236,7 @@ describe('Brainy Public API - Complete Coverage', () => {
describe('Relationship Operations', () => { describe('Relationship Operations', () => {
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
}) })
@ -419,7 +419,7 @@ describe('Brainy Public API - Complete Coverage', () => {
describe('Search Operations', () => { describe('Search Operations', () => {
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
await brain.addMany({ await brain.addMany({
@ -533,7 +533,7 @@ describe('Brainy Public API - Complete Coverage', () => {
let entityIds: string[] let entityIds: string[]
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
const result = await brain.addMany({ const result = await brain.addMany({
@ -627,7 +627,7 @@ describe('Brainy Public API - Complete Coverage', () => {
describe('Statistics', () => { describe('Statistics', () => {
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
}) })
@ -661,7 +661,7 @@ describe('Brainy Public API - Complete Coverage', () => {
const fsTestDir = path.join(tmpdir(), `brainy-fs-crud-${Date.now()}`) const fsTestDir = path.join(tmpdir(), `brainy-fs-crud-${Date.now()}`)
await fs.mkdir(fsTestDir, { recursive: true }) await fs.mkdir(fsTestDir, { recursive: true })
const fsBrain = new Brainy({ const fsBrain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: fsTestDir } options: { path: fsTestDir }
@ -695,7 +695,7 @@ describe('Brainy Public API - Complete Coverage', () => {
const fsTestDir = path.join(tmpdir(), `brainy-fs-concurrent-${Date.now()}`) const fsTestDir = path.join(tmpdir(), `brainy-fs-concurrent-${Date.now()}`)
await fs.mkdir(fsTestDir, { recursive: true }) await fs.mkdir(fsTestDir, { recursive: true })
const fsBrain = new Brainy({ const fsBrain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: fsTestDir } options: { path: fsTestDir }
@ -723,7 +723,7 @@ describe('Brainy Public API - Complete Coverage', () => {
describe('Error Recovery and Resilience', () => { describe('Error Recovery and Resilience', () => {
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
}) })
@ -780,7 +780,7 @@ describe('Brainy Public API - Complete Coverage', () => {
describe('Performance', () => { describe('Performance', () => {
it('should handle moderate-scale operations', async () => { it('should handle moderate-scale operations', async () => {
const perfBrain = new Brainy({ storage: { type: 'memory' } }) const perfBrain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await perfBrain.init() await perfBrain.init()
// Add 50 items in batches // Add 50 items in batches
@ -806,7 +806,7 @@ describe('Brainy Public API - Complete Coverage', () => {
describe('Clear Operations', () => { describe('Clear Operations', () => {
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
await brain.addMany({ await brain.addMany({

View file

@ -5,7 +5,7 @@ describe('CRITICAL: Error Handling and Edge Cases', () => {
let brainy: Brainy let brainy: Brainy
beforeAll(async () => { beforeAll(async () => {
brainy = new Brainy({ brainy = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } storage: { type: 'memory' }
}) })
await brainy.init() await brainy.init()

View file

@ -6,7 +6,7 @@ describe('CRITICAL: Real-World Neural Matching Validation', () => {
let brainy: Brainy let brainy: Brainy
beforeAll(async () => { beforeAll(async () => {
brainy = new Brainy({ brainy = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } storage: { type: 'memory' }
}) })
await brainy.init() await brainy.init()

View file

@ -5,7 +5,7 @@ describe('CRITICAL: Performance Benchmarks at Scale', () => {
let brainy: Brainy let brainy: Brainy
beforeAll(async () => { beforeAll(async () => {
brainy = new Brainy({ brainy = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } storage: { type: 'memory' }
}) })
await brainy.init() await brainy.init()

View file

@ -19,7 +19,7 @@ describe('Distributed Brainy Demo', () => {
beforeAll(async () => { beforeAll(async () => {
// Node 1: First node starts cluster // Node 1: First node starts cluster
node1 = new Brainy({ node1 = new Brainy({ requireSubtype: false,
storage: { storage: {
s3Storage: { s3Storage: {
bucket: process.env.S3_BUCKET || 'brainy-test', bucket: process.env.S3_BUCKET || 'brainy-test',
@ -34,7 +34,7 @@ describe('Distributed Brainy Demo', () => {
console.log('Node 1 started - became cluster leader') console.log('Node 1 started - became cluster leader')
// Node 2: Automatically discovers and joins // Node 2: Automatically discovers and joins
node2 = new Brainy({ node2 = new Brainy({ requireSubtype: false,
storage: { storage: {
s3Storage: { s3Storage: {
bucket: process.env.S3_BUCKET || 'brainy-test', bucket: process.env.S3_BUCKET || 'brainy-test',
@ -49,7 +49,7 @@ describe('Distributed Brainy Demo', () => {
console.log('Node 2 started - automatically joined cluster') console.log('Node 2 started - automatically joined cluster')
// Node 3: Also joins automatically // Node 3: Also joins automatically
node3 = new Brainy({ node3 = new Brainy({ requireSubtype: false,
storage: { storage: {
s3Storage: { s3Storage: {
bucket: process.env.S3_BUCKET || 'brainy-test', bucket: process.env.S3_BUCKET || 'brainy-test',
@ -114,7 +114,7 @@ describe('Distributed Brainy Demo', () => {
it('should automatically rebalance when nodes join', async () => { it('should automatically rebalance when nodes join', async () => {
// Start a new node // Start a new node
const node4 = new Brainy({ const node4 = new Brainy({ requireSubtype: false,
storage: { storage: {
s3Storage: { s3Storage: {
bucket: process.env.S3_BUCKET || 'brainy-test', bucket: process.env.S3_BUCKET || 'brainy-test',
@ -170,7 +170,7 @@ describe('Distributed Brainy Demo', () => {
export function distributedExample() { export function distributedExample() {
return ` return `
// Zero-Config Distributed Setup // Zero-Config Distributed Setup
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
s3Storage: { s3Storage: {
bucket: 'my-data', bucket: 'my-data',

View file

@ -76,7 +76,7 @@ export class DistributedTestCluster {
console.log(`Starting ${nodeId} on port ${port}...`); console.log(`Starting ${nodeId} on port ${port}...`);
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'memory' type: 'memory'
} }
@ -226,7 +226,7 @@ export class DistributedTestCluster {
console.log(`Adding new node ${nodeId} on port ${port}...`); console.log(`Adding new node ${nodeId} on port ${port}...`);
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'memory' type: 'memory'
} }

View file

@ -176,9 +176,11 @@ export function createFindParams(overrides: Partial<FindParams> = {}): FindParam
} }
} }
// Generate test configuration // Generate test configuration. Brainy 8.0 defaults `requireSubtype: true`;
// tests opt out unless they specifically exercise subtype enforcement.
export function createTestConfig(overrides: Partial<BrainyConfig> = {}): BrainyConfig { export function createTestConfig(overrides: Partial<BrainyConfig> = {}): BrainyConfig {
return { return {
requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
model: { type: 'fast' }, model: { type: 'fast' },
index: { index: {

View file

@ -23,7 +23,7 @@ describe('BR-ADV-FEATURES-BUN regression', () => {
let brain: Brainy let brain: Brainy
beforeAll(async () => { beforeAll(async () => {
brain = new Brainy({ storage: { type: 'memory' } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
// Warm the embedding model so the first real extraction isn't paying cold-start latency. // Warm the embedding model so the first real extraction isn't paying cold-start latency.
await brain.embed('warmup') await brain.embed('warmup')
@ -141,7 +141,7 @@ describe('BR-ADV-FEATURES-BUN regression', () => {
it('defineAggregate AFTER entities exist still returns correct rows', async () => { it('defineAggregate AFTER entities exist still returns correct rows', async () => {
// The durable-storage case: a brain reopens pre-populated, then an aggregate is // The durable-storage case: a brain reopens pre-populated, then an aggregate is
// defined. Write-time hooks never saw these entities, so without backfill this is []. // defined. Write-time hooks never saw these entities, so without backfill this is [].
const b: any = new Brainy({ storage: { type: 'memory' } }) const b: any = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await b.init() await b.init()
await b.add({ data: 'a', type: NounType.Event, metadata: { category: 'food', amount: 5 } }) await b.add({ data: 'a', type: NounType.Event, metadata: { category: 'food', amount: 5 } })
await b.add({ data: 'b', type: NounType.Event, metadata: { category: 'food', amount: 7 } }) await b.add({ data: 'b', type: NounType.Event, metadata: { category: 'food', amount: 7 } })
@ -165,7 +165,7 @@ describe('BR-ADV-FEATURES-BUN regression', () => {
}) })
it('groupBy "noun" resolves to the entity type, not null', async () => { it('groupBy "noun" resolves to the entity type, not null', async () => {
const b: any = new Brainy({ storage: { type: 'memory' } }) const b: any = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await b.init() await b.init()
await b.add({ data: 'p', type: NounType.Person }) await b.add({ data: 'p', type: NounType.Person })
b.defineAggregate({ b.defineAggregate({
@ -183,7 +183,7 @@ describe('BR-ADV-FEATURES-BUN regression', () => {
describe('Traversal — via filter applies at every hop', () => { describe('Traversal — via filter applies at every hop', () => {
it('depth-2 via traversal follows the typed chain to the second hop', async () => { it('depth-2 via traversal follows the typed chain to the second hop', async () => {
const b: any = new Brainy({ storage: { type: 'memory' } }) const b: any = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await b.init() await b.init()
const a = await b.add({ data: 'a', type: NounType.Concept, metadata: { name: 'A' } }) const a = await b.add({ data: 'a', type: NounType.Concept, metadata: { name: 'A' } })
const m = await b.add({ data: 'm', type: NounType.Concept, metadata: { name: 'M' } }) const m = await b.add({ data: 'm', type: NounType.Concept, metadata: { name: 'M' } })
@ -204,7 +204,7 @@ describe('BR-ADV-FEATURES-BUN regression', () => {
describe('queryAggregate() + HAVING', () => { describe('queryAggregate() + HAVING', () => {
it('returns AggregateResult[] and filters groups by metric value', async () => { it('returns AggregateResult[] and filters groups by metric value', async () => {
const b: any = new Brainy({ storage: { type: 'memory' } }) const b: any = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await b.init() await b.init()
b.defineAggregate({ b.defineAggregate({
name: 'rev', name: 'rev',
@ -233,7 +233,7 @@ describe('BR-ADV-FEATURES-BUN regression', () => {
describe('R2 — array-unnest groupBy (tag frequency)', () => { describe('R2 — array-unnest groupBy (tag frequency)', () => {
it('groups by each distinct array element; dedups per entity; skips empty', async () => { it('groups by each distinct array element; dedups per entity; skips empty', async () => {
const b: any = new Brainy({ storage: { type: 'memory' } }) const b: any = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await b.init() await b.init()
b.defineAggregate({ b.defineAggregate({
name: 'tags', name: 'tags',

View file

@ -7,7 +7,7 @@ describe('Aggregation Engine Integration', () => {
let brain: Brainy<any> let brain: Brainy<any>
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' }, silent: true }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' }, silent: true })
await brain.init() await brain.init()
}) })

View file

@ -32,7 +32,7 @@ describe('Comprehensive All-APIs Test', () => {
} }
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }

View file

@ -11,7 +11,7 @@ describe('API Parameter Validation', () => {
let brain: Brainy let brain: Brainy
beforeAll(async () => { beforeAll(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } storage: { type: 'memory' }
}) })
await brain.init() await brain.init()

View file

@ -14,7 +14,7 @@ describe('Batch Import with Immediate Relations (v5.7.3 Fix)', () => {
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
// Initialize brain // Initialize brain
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
config: { config: {

View file

@ -27,7 +27,7 @@ describe('Brainy 2.0 Complete Feature Test (Real AI)', () => {
console.log(`📊 Available heap: ${process.env.NODE_OPTIONS}`) console.log(`📊 Available heap: ${process.env.NODE_OPTIONS}`)
// Create instance with full feature set // Create instance with full feature set
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
verbose: true // Enable verbose logging to track operations verbose: true // Enable verbose logging to track operations
}) })

View file

@ -20,7 +20,7 @@ describe('Brainy 3.0 Core (Integration Tests - Real AI)', () => {
console.log('🤖 Initializing Brainy 3.0 with REAL AI models...') console.log('🤖 Initializing Brainy 3.0 with REAL AI models...')
// Create instance with real AI embedding function // Create instance with real AI embedding function
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
// No mock embedding function = uses real AI // No mock embedding function = uses real AI
}) })

View file

@ -23,7 +23,7 @@ describe('Brainy - Phase 1c: Type-Aware Integration', () => {
mkdirSync(testDir, { recursive: true }) mkdirSync(testDir, { recursive: true })
} }
brainy = new Brainy({ brainy = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
rootDirectory: testDir rootDirectory: testDir
@ -343,7 +343,7 @@ describe('Brainy - Phase 1c: Type-Aware Integration', () => {
await brainy.flush() await brainy.flush()
// Create new instance (should warm cache on init) // Create new instance (should warm cache on init)
const brainy2 = new Brainy({ const brainy2 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
rootDirectory: testDir rootDirectory: testDir

View file

@ -95,7 +95,7 @@ async function testBunCompile() {
// Test 5: Full Brainy initialization with fresh memory storage // Test 5: Full Brainy initialization with fresh memory storage
try { try {
console.log('5. Testing Brainy initialization (in-memory)...') console.log('5. Testing Brainy initialization (in-memory)...')
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: 'memory', storage: 'memory',
storageOptions: { path: ':memory:' } storageOptions: { path: ':memory:' }
}) })

View file

@ -35,7 +35,7 @@ describe('Clear Persistence Bug Fix (v5.10.4)', () => {
it('should fully clear persistent storage (the reported scenario)', async () => { it('should fully clear persistent storage (the reported scenario)', async () => {
// Step 1: Create and populate instance // Step 1: Create and populate instance
const brain1 = new Brainy({ const brain1 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testStoragePath, path: testStoragePath,
@ -59,7 +59,7 @@ describe('Clear Persistence Bug Fix (v5.10.4)', () => {
expect(entityCount2).toBe(0) expect(entityCount2).toBe(0)
// Step 3: Create NEW instance (simulate server restart) // Step 3: Create NEW instance (simulate server restart)
const brain2 = new Brainy({ const brain2 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testStoragePath, path: testStoragePath,
@ -75,7 +75,7 @@ describe('Clear Persistence Bug Fix (v5.10.4)', () => {
}) })
it('should create cow-disabled marker file', async () => { it('should create cow-disabled marker file', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testStoragePath path: testStoragePath
@ -96,7 +96,7 @@ describe('Clear Persistence Bug Fix (v5.10.4)', () => {
}) })
it('should delete _cow/ directory', async () => { it('should delete _cow/ directory', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testStoragePath path: testStoragePath
@ -122,7 +122,7 @@ describe('Clear Persistence Bug Fix (v5.10.4)', () => {
it('should prevent COW reinitialization after clear()', async () => { it('should prevent COW reinitialization after clear()', async () => {
// Create and clear // Create and clear
const brain1 = new Brainy({ const brain1 = new Brainy({ requireSubtype: false,
storage: { type: 'filesystem', path: testStoragePath } storage: { type: 'filesystem', path: testStoragePath }
}) })
await brain1.init() await brain1.init()
@ -130,7 +130,7 @@ describe('Clear Persistence Bug Fix (v5.10.4)', () => {
await brain1.clear() await brain1.clear()
// Create new instance // Create new instance
const brain2 = new Brainy({ const brain2 = new Brainy({ requireSubtype: false,
storage: { type: 'filesystem', path: testStoragePath } storage: { type: 'filesystem', path: testStoragePath }
}) })
await brain2.init() await brain2.init()
@ -150,14 +150,14 @@ describe('Clear Persistence Bug Fix (v5.10.4)', () => {
try { try {
// Iteration 1 // Iteration 1
const brain1 = new Brainy({ storage: { type: 'filesystem', path: storagePath }}) const brain1 = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', path: storagePath }})
await brain1.init() await brain1.init()
await brain1.add({ data:'Entity 1', type: 'concept' }) await brain1.add({ data:'Entity 1', type: 'concept' })
expect((await brain1.find({ type: 'concept' })).length).toBe(1) expect((await brain1.find({ type: 'concept' })).length).toBe(1)
await brain1.clear() await brain1.clear()
// Iteration 2 // Iteration 2
const brain2 = new Brainy({ storage: { type: 'filesystem', path: storagePath }}) const brain2 = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', path: storagePath }})
await brain2.init() await brain2.init()
expect((await brain2.find({ type: 'concept' })).length).toBe(0) expect((await brain2.find({ type: 'concept' })).length).toBe(0)
await brain2.add({ data:'Entity 2', type: 'concept' }) await brain2.add({ data:'Entity 2', type: 'concept' })
@ -165,7 +165,7 @@ describe('Clear Persistence Bug Fix (v5.10.4)', () => {
await brain2.clear() await brain2.clear()
// Iteration 3 // Iteration 3
const brain3 = new Brainy({ storage: { type: 'filesystem', path: storagePath }}) const brain3 = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', path: storagePath }})
await brain3.init() await brain3.init()
expect((await brain3.find({ type: 'concept' })).length).toBe(0) expect((await brain3.find({ type: 'concept' })).length).toBe(0)
} finally { } finally {
@ -177,7 +177,7 @@ describe('Clear Persistence Bug Fix (v5.10.4)', () => {
}) })
it('should clear both entities and relations', async () => { it('should clear both entities and relations', async () => {
const brain1 = new Brainy({ storage: { type: 'filesystem', path: testStoragePath }}) const brain1 = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', path: testStoragePath }})
await brain1.init() await brain1.init()
// Add graph data // Add graph data
@ -194,7 +194,7 @@ describe('Clear Persistence Bug Fix (v5.10.4)', () => {
await brain1.clear() await brain1.clear()
// Create new instance // Create new instance
const brain2 = new Brainy({ storage: { type: 'filesystem', path: testStoragePath }}) const brain2 = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', path: testStoragePath }})
await brain2.init() await brain2.init()
// Verify everything is cleared // Verify everything is cleared
@ -204,7 +204,7 @@ describe('Clear Persistence Bug Fix (v5.10.4)', () => {
}) })
it('should handle clear() on empty storage', async () => { it('should handle clear() on empty storage', async () => {
const brain = new Brainy({ storage: { type: 'filesystem', path: testStoragePath }}) const brain = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', path: testStoragePath }})
await brain.init() await brain.init()
// Clear without adding any data // Clear without adding any data
@ -219,7 +219,7 @@ describe('Clear Persistence Bug Fix (v5.10.4)', () => {
describe('Clear() works for MemoryStorage', () => { describe('Clear() works for MemoryStorage', () => {
it('should clear memory storage completely', async () => { it('should clear memory storage completely', async () => {
const brain1 = new Brainy({ storage: { type: 'memory' }}) const brain1 = new Brainy({ requireSubtype: false, storage: { type: 'memory' }})
await brain1.init() await brain1.init()
await brain1.add({ data:'Test', type: 'concept' }) await brain1.add({ data:'Test', type: 'concept' })

View file

@ -44,7 +44,7 @@ describe('VFS operations after clear() (v7.3.1 fix)', () => {
} }
it('should allow VFS operations after brain.clear() without recreation (memory)', async () => { it('should allow VFS operations after brain.clear() without recreation (memory)', async () => {
const brain = new Brainy({ storage: { type: 'memory' } }) const brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
try { try {
await brain.init() await brain.init()
@ -70,7 +70,7 @@ describe('VFS operations after clear() (v7.3.1 fix)', () => {
it('should allow VFS operations after brain.clear() without recreation (filesystem)', async () => { it('should allow VFS operations after brain.clear() without recreation (filesystem)', async () => {
const testPath = getTestPath() const testPath = getTestPath()
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { type: 'filesystem', path: testPath } storage: { type: 'filesystem', path: testPath }
}) })
try { try {
@ -97,7 +97,7 @@ describe('VFS operations after clear() (v7.3.1 fix)', () => {
}) })
it('should handle clear() when VFS was never used', async () => { it('should handle clear() when VFS was never used', async () => {
const brain = new Brainy({ storage: { type: 'memory' } }) const brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
try { try {
await brain.init() await brain.init()
@ -121,7 +121,7 @@ describe('VFS operations after clear() (v7.3.1 fix)', () => {
}) })
it('should reinitialize VFS root entity after clear', async () => { it('should reinitialize VFS root entity after clear', async () => {
const brain = new Brainy({ storage: { type: 'memory' } }) const brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
try { try {
await brain.init() await brain.init()
@ -152,7 +152,7 @@ describe('VFS operations after clear() (v7.3.1 fix)', () => {
}) })
it('should work across multiple clear() cycles', async () => { it('should work across multiple clear() cycles', async () => {
const brain = new Brainy({ storage: { type: 'memory' } }) const brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
try { try {
await brain.init() await brain.init()
@ -178,7 +178,7 @@ describe('VFS operations after clear() (v7.3.1 fix)', () => {
}) })
it('should preserve VFS functionality with nested directories after clear', async () => { it('should preserve VFS functionality with nested directories after clear', async () => {
const brain = new Brainy({ storage: { type: 'memory' } }) const brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
try { try {
await brain.init() await brain.init()
@ -202,7 +202,7 @@ describe('VFS operations after clear() (v7.3.1 fix)', () => {
}) })
it('should work with concurrent VFS and regular entity operations after clear', async () => { it('should work with concurrent VFS and regular entity operations after clear', async () => {
const brain = new Brainy({ storage: { type: 'memory' } }) const brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
try { try {
await brain.init() await brain.init()

View file

@ -20,7 +20,7 @@ describe('Commit Ref Update Bug (v5.2.0)', () => {
fs.rmSync(TEST_DATA_PATH, { recursive: true, force: true }) fs.rmSync(TEST_DATA_PATH, { recursive: true, force: true })
} }
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: TEST_DATA_PATH, path: TEST_DATA_PATH,

View file

@ -32,7 +32,7 @@ describe('Commit State Capture (v5.4.0)', () => {
} }
fs.mkdirSync(TEST_DATA_PATH, { recursive: true }) fs.mkdirSync(TEST_DATA_PATH, { recursive: true })
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
adapter: 'filesystem', adapter: 'filesystem',
path: TEST_DATA_PATH path: TEST_DATA_PATH
@ -404,7 +404,7 @@ describe('Commit State Capture (v5.4.0)', () => {
it('should work with Memory storage adapter', async () => { it('should work with Memory storage adapter', async () => {
console.log('\n📋 Test 9: Memory storage adapter') console.log('\n📋 Test 9: Memory storage adapter')
const memBrain = new Brainy({ const memBrain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' }, storage: { adapter: 'memory' },
silent: true silent: true
}) })
@ -439,7 +439,7 @@ describe('Commit State Capture (v5.4.0)', () => {
fs.rmSync(testPath, { recursive: true, force: true }) fs.rmSync(testPath, { recursive: true, force: true })
} }
const typeAwareBrain = new Brainy({ const typeAwareBrain = new Brainy({ requireSubtype: false,
storage: { storage: {
adapter: 'typeaware', adapter: 'typeaware',
path: testPath path: testPath

View file

@ -58,12 +58,12 @@ describe('Cortex compatibility (BR-DEFENSIVE-INTERFACE)', () => {
}) })
it('boots without throwing against an adapter missing the 7.21+ methods', async () => { it('boots without throwing against an adapter missing the 7.21+ methods', async () => {
brain = new Brainy({ storage: new LegacyCortexLikeStorage() as any }) brain = new Brainy({ requireSubtype: false, storage: new LegacyCortexLikeStorage() as any })
await expect(brain.init()).resolves.toBeUndefined() await expect(brain.init()).resolves.toBeUndefined()
}) })
it('logs a one-line warning naming the older adapter', async () => { it('logs a one-line warning naming the older adapter', async () => {
brain = new Brainy({ storage: new LegacyCortexLikeStorage() as any }) brain = new Brainy({ requireSubtype: false, storage: new LegacyCortexLikeStorage() as any })
await brain.init() await brain.init()
const warnMessages = warnSpy.mock.calls const warnMessages = warnSpy.mock.calls
@ -73,7 +73,7 @@ describe('Cortex compatibility (BR-DEFENSIVE-INTERFACE)', () => {
}) })
it('basic CRUD works normally (the missing methods are not on the hot path)', async () => { it('basic CRUD works normally (the missing methods are not on the hot path)', async () => {
brain = new Brainy({ storage: new LegacyCortexLikeStorage() as any }) brain = new Brainy({ requireSubtype: false, storage: new LegacyCortexLikeStorage() as any })
await brain.init() await brain.init()
const id = await brain.add({ data: 'hello', type: NounType.Concept }) const id = await brain.add({ data: 'hello', type: NounType.Concept })
@ -85,7 +85,7 @@ describe('Cortex compatibility (BR-DEFENSIVE-INTERFACE)', () => {
}) })
it('requestFlush() returns false when storage does not implement the RPC', async () => { it('requestFlush() returns false when storage does not implement the RPC', async () => {
brain = new Brainy({ storage: new LegacyCortexLikeStorage() as any }) brain = new Brainy({ requireSubtype: false, storage: new LegacyCortexLikeStorage() as any })
await brain.init() await brain.init()
// Same-process call would normally flush directly. Force the // Same-process call would normally flush directly. Force the
@ -96,7 +96,7 @@ describe('Cortex compatibility (BR-DEFENSIVE-INTERFACE)', () => {
}) })
it('stats() reports no writerLock for older adapters', async () => { it('stats() reports no writerLock for older adapters', async () => {
brain = new Brainy({ storage: new LegacyCortexLikeStorage() as any }) brain = new Brainy({ requireSubtype: false, storage: new LegacyCortexLikeStorage() as any })
await brain.init() await brain.init()
const stats = await brain.stats() const stats = await brain.stats()

View file

@ -27,7 +27,7 @@ describe('Count Synchronization (Bug Fix v4.1.2)', () => {
} }
// Create fresh Brainy instance // Create fresh Brainy instance
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'filesystem', path: testPath } storage: { type: 'filesystem', path: testPath }
}) })
await brain.init() await brain.init()

View file

@ -22,7 +22,7 @@ describe('COW Commit Storage Type-Aware Prefixes', () => {
beforeEach(async () => { beforeEach(async () => {
testDir = path.join('/tmp', `brainy-cow-test-${Date.now()}`) testDir = path.join('/tmp', `brainy-cow-test-${Date.now()}`)
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testDir, path: testDir,

View file

@ -22,7 +22,7 @@ import type { StorageAdapter } from '../../src/storage/adapters/baseStorageAdapt
describe('COW Full Integration', () => { describe('COW Full Integration', () => {
describe('Storage Adapter Compatibility', () => { describe('Storage Adapter Compatibility', () => {
it('should work with Memory adapter', async () => { it('should work with Memory adapter', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' } storage: { adapter: 'memory' }
}) })
@ -46,7 +46,7 @@ describe('COW Full Integration', () => {
}) })
it('should work with FileSystem adapter', async () => { it('should work with FileSystem adapter', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
adapter: 'filesystem', adapter: 'filesystem',
path: '/tmp/brainy-cow-test-fs' path: '/tmp/brainy-cow-test-fs'
@ -70,7 +70,7 @@ describe('COW Full Integration', () => {
}) })
it('should work with TypeAware adapter (most advanced)', async () => { it('should work with TypeAware adapter (most advanced)', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
adapter: 'typeaware', adapter: 'typeaware',
path: '/tmp/brainy-cow-test-typeaware' path: '/tmp/brainy-cow-test-typeaware'
@ -96,7 +96,7 @@ describe('COW Full Integration', () => {
// Note: S3/R2/GCS/Azure tests require cloud credentials // Note: S3/R2/GCS/Azure tests require cloud credentials
// Run these in CI/CD with proper credentials // Run these in CI/CD with proper credentials
it.skip('should work with S3 adapter', async () => { it.skip('should work with S3 adapter', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
adapter: 's3', adapter: 's3',
bucket: 'test-brainy-cow', bucket: 'test-brainy-cow',
@ -123,7 +123,7 @@ describe('COW Full Integration', () => {
describe('Billion-Scale Performance', () => { describe('Billion-Scale Performance', () => {
it('should fork 1M entities in < 2 seconds', async () => { it('should fork 1M entities in < 2 seconds', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' } storage: { adapter: 'memory' }
}) })
@ -172,7 +172,7 @@ describe('COW Full Integration', () => {
}, 120000) // 2-minute timeout for 1M entity test }, 120000) // 2-minute timeout for 1M entity test
it('should deduplicate billions of identical vectors', async () => { it('should deduplicate billions of identical vectors', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' } storage: { adapter: 'memory' }
}) })
@ -208,7 +208,7 @@ describe('COW Full Integration', () => {
describe('find() Integration', () => { describe('find() Integration', () => {
it('should work with graph-aware find() queries', async () => { it('should work with graph-aware find() queries', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' } storage: { adapter: 'memory' }
}) })
@ -249,7 +249,7 @@ describe('COW Full Integration', () => {
}) })
it('should preserve metadata index across fork', async () => { it('should preserve metadata index across fork', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' } storage: { adapter: 'memory' }
}) })
@ -284,7 +284,7 @@ describe('COW Full Integration', () => {
describe('Triple Intelligence Integration', () => { describe('Triple Intelligence Integration', () => {
it('should preserve Triple Intelligence across fork', async () => { it('should preserve Triple Intelligence across fork', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' }, storage: { adapter: 'memory' },
intelligence: { intelligence: {
enabled: true, enabled: true,
@ -320,7 +320,7 @@ describe('COW Full Integration', () => {
describe('VFS Integration', () => { describe('VFS Integration', () => {
it('should preserve VFS structure across fork', async () => { it('should preserve VFS structure across fork', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' }, storage: { adapter: 'memory' },
vfs: { enabled: true } vfs: { enabled: true }
}) })
@ -345,7 +345,7 @@ describe('COW Full Integration', () => {
}) })
it('should support VFS paths in billions of entities', async () => { it('should support VFS paths in billions of entities', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' }, storage: { adapter: 'memory' },
vfs: { enabled: true } vfs: { enabled: true }
}) })
@ -376,7 +376,7 @@ describe('COW Full Integration', () => {
describe('All 4 Indexes Integration', () => { describe('All 4 Indexes Integration', () => {
it('should preserve HNSW index across fork', async () => { it('should preserve HNSW index across fork', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' } storage: { adapter: 'memory' }
}) })
@ -407,7 +407,7 @@ describe('COW Full Integration', () => {
}) })
it('should preserve GraphAdjacency index across fork', async () => { it('should preserve GraphAdjacency index across fork', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' } storage: { adapter: 'memory' }
}) })
@ -434,7 +434,7 @@ describe('COW Full Integration', () => {
}) })
it('should preserve DeletedItems index across fork', async () => { it('should preserve DeletedItems index across fork', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' } storage: { adapter: 'memory' }
}) })
@ -461,7 +461,7 @@ describe('COW Full Integration', () => {
describe('Distributed Mode', () => { describe('Distributed Mode', () => {
it('should work with read-only instances', async () => { it('should work with read-only instances', async () => {
// Main brain (read-write) // Main brain (read-write)
const main = new Brainy({ const main = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' } storage: { adapter: 'memory' }
}) })
@ -475,7 +475,7 @@ describe('COW Full Integration', () => {
await main.commit({ message: 'Add entity' }) await main.commit({ message: 'Add entity' })
// Read-only instance (shares storage) // Read-only instance (shares storage)
const readonly = new Brainy({ const readonly = new Brainy({ requireSubtype: false,
storage: main.config.storage, storage: main.config.storage,
readOnly: true readOnly: true
}) })
@ -499,7 +499,7 @@ describe('COW Full Integration', () => {
it('should work with write-only instances', async () => { it('should work with write-only instances', async () => {
// Write-only instance // Write-only instance
const writeOnly = new Brainy({ const writeOnly = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' }, storage: { adapter: 'memory' },
writeOnly: true writeOnly: true
}) })
@ -525,7 +525,7 @@ describe('COW Full Integration', () => {
describe('256 UUID Sharding', () => { describe('256 UUID Sharding', () => {
it('should work with sharded storage', async () => { it('should work with sharded storage', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
adapter: 'memory', adapter: 'memory',
sharding: { sharding: {
@ -562,7 +562,7 @@ describe('COW Full Integration', () => {
describe('Time-Travel Queries (Enterprise Preview)', () => { describe('Time-Travel Queries (Enterprise Preview)', () => {
it('should support asOf queries', async () => { it('should support asOf queries', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' } storage: { adapter: 'memory' }
}) })

View file

@ -22,7 +22,7 @@ describe('Empty Tree Bug (v5.3.1)', () => {
fs.rmSync(TEST_DATA_PATH, { recursive: true, force: true }) fs.rmSync(TEST_DATA_PATH, { recursive: true, force: true })
} }
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: TEST_DATA_PATH, path: TEST_DATA_PATH,

View file

@ -15,7 +15,7 @@ describe('Entity Confidence & Weight Exposure', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
}) })

View file

@ -145,7 +145,7 @@ describe('find({ limit }) two-tier enforcement (7.30.2)', () => {
describe('Consumer override via Brainy constructor', () => { describe('Consumer override via Brainy constructor', () => {
it('maxQueryLimit raises the cap; warning/throw tiers shift accordingly', async () => { it('maxQueryLimit raises the cap; warning/throw tiers shift accordingly', async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true, silent: true,
maxQueryLimit: 50_000 maxQueryLimit: 50_000

View file

@ -28,7 +28,7 @@ describe('Unified Find() Integration Tests', () => {
beforeAll(async () => { beforeAll(async () => {
// Initialize Brainy with memory storage for fast tests // Initialize Brainy with memory storage for fast tests
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
model: { type: 'fast' }, model: { type: 'fast' },
index: { index: {

View file

@ -56,7 +56,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
describe('Reader sees correct entity counts after writer cold-start', () => { describe('Reader sees correct entity counts after writer cold-start', () => {
it('preserves entity count across writer→close→reader-open', async () => { it('preserves entity count across writer→close→reader-open', async () => {
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir }, silent: true }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir }, silent: true })
await writer.init() await writer.init()
const writerIds = new Set<string>() const writerIds = new Set<string>()
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
@ -80,7 +80,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
}) })
it('preserves type classification (no "all entities are thing" poisoning)', async () => { it('preserves type classification (no "all entities are thing" poisoning)', async () => {
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir }, silent: true }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir }, silent: true })
await writer.init() await writer.init()
// Three types. Each id is tracked individually so we don't conflate // Three types. Each id is tracked individually so we don't conflate
// user-added entities with whatever VFS / auto-extraction inserts. // user-added entities with whatever VFS / auto-extraction inserts.
@ -120,7 +120,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
describe('find() consistency', () => { describe('find() consistency', () => {
it('returns entities that exist on disk (not silent empty)', async () => { it('returns entities that exist on disk (not silent empty)', async () => {
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir }, silent: true }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir }, silent: true })
await writer.init() await writer.init()
const conceptIds: string[] = [] const conceptIds: string[] = []
for (let i = 0; i < 4; i++) { for (let i = 0; i < 4; i++) {
@ -145,7 +145,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
}) })
it('returns [] with a logged warning for unindexed field', async () => { it('returns [] with a logged warning for unindexed field', async () => {
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir }, silent: true }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir }, silent: true })
await writer.init() await writer.init()
await writer.add({ data: 'test', type: NounType.Concept }) await writer.add({ data: 'test', type: NounType.Concept })
await writer.flush() await writer.flush()
@ -162,7 +162,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
}) })
it('raw getIds() throws BrainyError(FIELD_NOT_INDEXED) for unindexed field', async () => { it('raw getIds() throws BrainyError(FIELD_NOT_INDEXED) for unindexed field', async () => {
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir }, silent: true }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir }, silent: true })
await writer.init() await writer.init()
await writer.add({ data: 'test', type: NounType.Concept }) await writer.add({ data: 'test', type: NounType.Concept })
await writer.flush() await writer.flush()
@ -181,7 +181,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
describe('explain() and health() match the new contract', () => { describe('explain() and health() match the new contract', () => {
it('explain() returns column-store path for indexed fields', async () => { it('explain() returns column-store path for indexed fields', async () => {
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir }, silent: true }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir }, silent: true })
await writer.init() await writer.init()
await writer.add({ await writer.add({
data: 'test', data: 'test',
@ -196,7 +196,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
}) })
it('health() reports pass for a clean writer + reader handoff', async () => { it('health() reports pass for a clean writer + reader handoff', async () => {
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir }, silent: true }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir }, silent: true })
await writer.init() await writer.init()
for (let i = 0; i < 5; i++) { for (let i = 0; i < 5; i++) {
await writer.add({ data: `entry ${i}`, type: NounType.Concept }) await writer.add({ data: `entry ${i}`, type: NounType.Concept })

View file

@ -20,7 +20,7 @@ describe('Fork Persistence (v5.3.6 Bug Fix)', () => {
beforeEach(async () => { beforeEach(async () => {
// Use filesystem storage to mirror cloud storage behavior // Use filesystem storage to mirror cloud storage behavior
testDir = `/tmp/brainy-fork-test-${Date.now()}` testDir = `/tmp/brainy-fork-test-${Date.now()}`
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
adapter: 'filesystem', adapter: 'filesystem',
path: testDir path: testDir

View file

@ -25,7 +25,7 @@ describe('getRelations() Fix (v4.1.3)', () => {
} }
// Create fresh Brainy instance // Create fresh Brainy instance
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'filesystem', path: testPath } storage: { type: 'filesystem', path: testPath }
}) })
await brain.init() await brain.init()

View file

@ -26,7 +26,7 @@ describe('History Ref Resolution Bug (v5.3.0)', () => {
fs.rmSync(TEST_DATA_PATH, { recursive: true, force: true }) fs.rmSync(TEST_DATA_PATH, { recursive: true, force: true })
} }
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: TEST_DATA_PATH, path: TEST_DATA_PATH,

View file

@ -79,7 +79,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
console.log('🧪 Test 1: Basic HNSW rebuild with 20 entities...') console.log('🧪 Test 1: Basic HNSW rebuild with 20 entities...')
// Phase 1: Create Brainy instance and add data // Phase 1: Create Brainy instance and add data
const brain1 = new Brainy({ const brain1 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
fileSystemStorage: { path: testDir } fileSystemStorage: { path: testDir }
@ -122,7 +122,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
// Phase 2: Simulate container restart - create new Brainy instance // Phase 2: Simulate container restart - create new Brainy instance
console.log('🔄 Simulating container restart...') console.log('🔄 Simulating container restart...')
const brain2 = new Brainy({ const brain2 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
fileSystemStorage: { path: testDir } fileSystemStorage: { path: testDir }
@ -168,7 +168,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
console.log('🧪 Test 2: HNSW rebuild with 100 entities...') console.log('🧪 Test 2: HNSW rebuild with 100 entities...')
// Phase 1: Build initial index // Phase 1: Build initial index
const brain1 = new Brainy({ const brain1 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
fileSystemStorage: { path: testDir } fileSystemStorage: { path: testDir }
@ -205,7 +205,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
// Phase 2: Rebuild // Phase 2: Rebuild
console.log('🔄 Rebuilding HNSW index...') console.log('🔄 Rebuilding HNSW index...')
const brain2 = new Brainy({ const brain2 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
fileSystemStorage: { path: testDir } fileSystemStorage: { path: testDir }
@ -240,7 +240,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
console.log('🧪 Test 3: Large dataset HNSW rebuild (1000 entities)...') console.log('🧪 Test 3: Large dataset HNSW rebuild (1000 entities)...')
// Phase 1: Build large index // Phase 1: Build large index
const brain1 = new Brainy({ const brain1 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
fileSystemStorage: { path: testDir } fileSystemStorage: { path: testDir }
@ -275,7 +275,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
// Phase 2: Rebuild large index // Phase 2: Rebuild large index
console.log('🔄 Rebuilding large HNSW index...') console.log('🔄 Rebuilding large HNSW index...')
const brain2 = new Brainy({ const brain2 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
fileSystemStorage: { path: testDir } fileSystemStorage: { path: testDir }
@ -315,7 +315,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
console.log('🧪 Test 4: HNSW rebuild with memory storage...') console.log('🧪 Test 4: HNSW rebuild with memory storage...')
// Phase 1: Build index in memory // Phase 1: Build index in memory
const brain1 = new Brainy({ const brain1 = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
embeddingFunction: async (text: string) => { embeddingFunction: async (text: string) => {
const hash = text.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0) const hash = text.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0)
@ -364,7 +364,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
console.log('🧪 Test 5: Parallel rebuild of all indexes...') console.log('🧪 Test 5: Parallel rebuild of all indexes...')
// Phase 1: Create data with relationships // Phase 1: Create data with relationships
const brain1 = new Brainy({ const brain1 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
fileSystemStorage: { path: testDir } fileSystemStorage: { path: testDir }
@ -425,7 +425,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
// Phase 2: Restart and rebuild all indexes // Phase 2: Restart and rebuild all indexes
console.log('🔄 Restarting and rebuilding all 3 indexes...') console.log('🔄 Restarting and rebuilding all 3 indexes...')
const brain2 = new Brainy({ const brain2 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
fileSystemStorage: { path: testDir } fileSystemStorage: { path: testDir }
@ -480,7 +480,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
it('should handle empty storage gracefully (no rebuild needed)', async () => { it('should handle empty storage gracefully (no rebuild needed)', async () => {
console.log('🧪 Test 6: Empty storage rebuild...') console.log('🧪 Test 6: Empty storage rebuild...')
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
fileSystemStorage: { path: testDir } fileSystemStorage: { path: testDir }
@ -510,7 +510,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
console.log('🧪 Test 7: Rebuild with single entity...') console.log('🧪 Test 7: Rebuild with single entity...')
// Phase 1: Add one entity // Phase 1: Add one entity
const brain1 = new Brainy({ const brain1 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
fileSystemStorage: { path: testDir } fileSystemStorage: { path: testDir }
@ -531,7 +531,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
await brain1.close() await brain1.close()
// Phase 2: Rebuild // Phase 2: Rebuild
const brain2 = new Brainy({ const brain2 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
fileSystemStorage: { path: testDir } fileSystemStorage: { path: testDir }
@ -558,7 +558,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
console.log('🧪 Test 8: Rebuild with potential data inconsistencies...') console.log('🧪 Test 8: Rebuild with potential data inconsistencies...')
// Phase 1: Create data // Phase 1: Create data
const brain1 = new Brainy({ const brain1 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
fileSystemStorage: { path: testDir } fileSystemStorage: { path: testDir }
@ -577,7 +577,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
await brain1.close() await brain1.close()
// Phase 2: Rebuild (should handle any missing HNSW data gracefully) // Phase 2: Rebuild (should handle any missing HNSW data gracefully)
const brain2 = new Brainy({ const brain2 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
fileSystemStorage: { path: testDir } fileSystemStorage: { path: testDir }
@ -616,7 +616,7 @@ describe('HNSW Index Rebuild (Integration Tests)', () => {
it('should persist HNSW graph structure to disk', async () => { it('should persist HNSW graph structure to disk', async () => {
console.log('🧪 Test 9: Validate HNSW persistence files...') console.log('🧪 Test 9: Validate HNSW persistence files...')
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
fileSystemStorage: { path: testDir } fileSystemStorage: { path: testDir }

View file

@ -23,7 +23,7 @@ describe('Hybrid Search with COW (v7.7.0)', () => {
testDir = path.join(os.tmpdir(), `brainy-cow-test-${Date.now()}`) testDir = path.join(os.tmpdir(), `brainy-cow-test-${Date.now()}`)
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { basePath: testDir } options: { basePath: testDir }

View file

@ -30,7 +30,7 @@ describe('Initial Commit NULL Parent Bug (v5.3.3 regression)', () => {
fs.rmSync(TEST_DATA_PATH, { recursive: true, force: true }) fs.rmSync(TEST_DATA_PATH, { recursive: true, force: true })
} }
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: TEST_DATA_PATH, path: TEST_DATA_PATH,

View file

@ -42,7 +42,7 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
describe('Production Workflow: Consumer Snapshot Timeline', () => { describe('Production Workflow: Consumer Snapshot Timeline', () => {
it('should stream 1000 snapshots efficiently', async () => { it('should stream 1000 snapshots efficiently', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }
@ -83,7 +83,7 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
}) })
it('should handle large snapshot with filtering', async () => { it('should handle large snapshot with filtering', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }
@ -124,7 +124,7 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
it('should detect 4GB Cloud Run container and set optimal limits', async () => { it('should detect 4GB Cloud Run container and set optimal limits', async () => {
process.env.CLOUD_RUN_MEMORY = '4Gi' process.env.CLOUD_RUN_MEMORY = '4Gi'
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true silent: true
}) })
@ -154,7 +154,7 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
it('should allow manual override for power users in containers', async () => { it('should allow manual override for power users in containers', async () => {
process.env.CLOUD_RUN_MEMORY = '4Gi' process.env.CLOUD_RUN_MEMORY = '4Gi'
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
maxQueryLimit: 50000, // Override auto-detection maxQueryLimit: 50000, // Override auto-detection
silent: true silent: true
@ -173,7 +173,7 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
}) })
it('should use reservedQueryMemory for fine-grained control', async () => { it('should use reservedQueryMemory for fine-grained control', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
reservedQueryMemory: 2 * 1024 * 1024 * 1024, // Reserve 2GB reservedQueryMemory: 2 * 1024 * 1024 * 1024, // Reserve 2GB
silent: true silent: true
@ -194,7 +194,7 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
it('should stream large histories within memory limits', async () => { it('should stream large histories within memory limits', async () => {
process.env.CLOUD_RUN_MEMORY = '2Gi' process.env.CLOUD_RUN_MEMORY = '2Gi'
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }
@ -239,7 +239,7 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
it('should provide actionable recommendations', async () => { it('should provide actionable recommendations', async () => {
process.env.CLOUD_RUN_MEMORY = '4Gi' process.env.CLOUD_RUN_MEMORY = '4Gi'
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true silent: true
}) })
@ -266,7 +266,7 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
// Simulate production issue: container detected but low free memory // Simulate production issue: container detected but low free memory
process.env.CLOUD_RUN_MEMORY = '4Gi' process.env.CLOUD_RUN_MEMORY = '4Gi'
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true silent: true
}) })
@ -291,7 +291,7 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
it('should work optimally with no configuration', async () => { it('should work optimally with no configuration', async () => {
process.env.CLOUD_RUN_MEMORY = '4Gi' process.env.CLOUD_RUN_MEMORY = '4Gi'
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true silent: true
}) })
@ -318,7 +318,7 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
it('should work on bare metal without containers', async () => { it('should work on bare metal without containers', async () => {
// No container env vars // No container env vars
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true silent: true
}) })
@ -337,7 +337,7 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
describe('Backward Compatibility', () => { describe('Backward Compatibility', () => {
it('should not break existing code', async () => { it('should not break existing code', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true silent: true
}) })
@ -354,7 +354,7 @@ describe('Memory Enhancements Integration (v5.11.0)', () => {
}) })
it('should keep getHistory() working as before', async () => { it('should keep getHistory() working as before', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }

View file

@ -20,7 +20,7 @@ import { join } from 'path'
describe('Metadata-Only Comprehensive Integration (v5.11.1)', () => { describe('Metadata-Only Comprehensive Integration (v5.11.1)', () => {
describe('Storage Adapters', () => { describe('Storage Adapters', () => {
it('should work with MemoryStorage', async () => { it('should work with MemoryStorage', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' }, storage: { adapter: 'memory' },
silent: true silent: true
}) })
@ -50,7 +50,7 @@ describe('Metadata-Only Comprehensive Integration (v5.11.1)', () => {
it('should work with FileSystemStorage', async () => { it('should work with FileSystemStorage', async () => {
const testDir = mkdtempSync(join(tmpdir(), 'brainy-metadata-test-')) const testDir = mkdtempSync(join(tmpdir(), 'brainy-metadata-test-'))
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }
@ -84,7 +84,7 @@ describe('Metadata-Only Comprehensive Integration (v5.11.1)', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' }, storage: { adapter: 'memory' },
silent: true silent: true
}) })
@ -155,7 +155,7 @@ describe('Metadata-Only Comprehensive Integration (v5.11.1)', () => {
let entityId: string let entityId: string
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' }, storage: { adapter: 'memory' },
silent: true silent: true
}) })
@ -235,7 +235,7 @@ describe('Metadata-Only Comprehensive Integration (v5.11.1)', () => {
beforeEach(async () => { beforeEach(async () => {
testDir = mkdtempSync(join(tmpdir(), 'brainy-vfs-metadata-test-')) testDir = mkdtempSync(join(tmpdir(), 'brainy-vfs-metadata-test-'))
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }
@ -293,7 +293,7 @@ describe('Metadata-Only Comprehensive Integration (v5.11.1)', () => {
describe('COW and Fork', () => { describe('COW and Fork', () => {
it('should work with metadata-only in forks', async () => { it('should work with metadata-only in forks', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' }, storage: { adapter: 'memory' },
silent: true silent: true
}) })
@ -327,7 +327,7 @@ describe('Metadata-Only Comprehensive Integration (v5.11.1)', () => {
describe('Performance Verification', () => { describe('Performance Verification', () => {
it('metadata-only should be significantly faster', async () => { it('metadata-only should be significantly faster', async () => {
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { adapter: 'memory' }, storage: { adapter: 'memory' },
silent: true silent: true
}) })

View file

@ -24,7 +24,7 @@ describe('Metadata Vector Exclusion Fix', () => {
rmSync(testDir, { recursive: true, force: true }) rmSync(testDir, { recursive: true, force: true })
} }
brainy = new Brainy({ brainy = new Brainy({ requireSubtype: false,
storage: { type: 'filesystem', path: testDir }, storage: { type: 'filesystem', path: testDir },
ai: { provider: 'mock' } ai: { provider: 'mock' }
}) })

View file

@ -31,7 +31,7 @@ describe('Migration System', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' }, silent: true }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' }, silent: true })
await brain.init() await brain.init()
}) })
@ -355,7 +355,7 @@ describe('Migration System', () => {
} }
await withMigrations([migration], async () => { await withMigrations([migration], async () => {
const warnBrain = new Brainy({ storage: { type: 'memory' } }) const warnBrain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await warnBrain.init() await warnBrain.init()
const migrationLogs = consoleSpy.mock.calls const migrationLogs = consoleSpy.mock.calls
@ -374,7 +374,7 @@ describe('Migration System', () => {
describe('autoMigrate: true', () => { describe('autoMigrate: true', () => {
it('should auto-migrate small datasets during init', async () => { it('should auto-migrate small datasets during init', async () => {
// Create a brain with data, close it // Create a brain with data, close it
const setupBrain = new Brainy({ storage: { type: 'memory' }, silent: true }) const setupBrain = new Brainy({ requireSubtype: false, storage: { type: 'memory' }, silent: true })
await setupBrain.init() await setupBrain.init()
await setupBrain.add({ type: NounType.Concept, data: { name: 'AutoTest' }, metadata: { legacy: true } }) await setupBrain.add({ type: NounType.Concept, data: { name: 'AutoTest' }, metadata: { legacy: true } })
@ -432,8 +432,8 @@ describe('Migration System', () => {
describe('Multi-tenant independence', () => { describe('Multi-tenant independence', () => {
it('should have independent migration state per instance', async () => { it('should have independent migration state per instance', async () => {
const brain1 = new Brainy({ storage: { type: 'memory' }, silent: true }) const brain1 = new Brainy({ requireSubtype: false, storage: { type: 'memory' }, silent: true })
const brain2 = new Brainy({ storage: { type: 'memory' }, silent: true }) const brain2 = new Brainy({ requireSubtype: false, storage: { type: 'memory' }, silent: true })
await brain1.init() await brain1.init()
await brain2.init() await brain2.init()

View file

@ -45,7 +45,7 @@ describe('Multi-process safety + read-only mode', () => {
describe('ReaderMode enforcement', () => { describe('ReaderMode enforcement', () => {
it('rejects every mutation when opened via openReadOnly()', async () => { it('rejects every mutation when opened via openReadOnly()', async () => {
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir } }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir } })
await writer.init() await writer.init()
await writer.add({ data: 'seed entity', type: NounType.Concept }) await writer.add({ data: 'seed entity', type: NounType.Concept })
await writer.flush() await writer.flush()
@ -67,7 +67,7 @@ describe('Multi-process safety + read-only mode', () => {
}) })
it('flush() and close() are safe to call in read-only mode', async () => { it('flush() and close() are safe to call in read-only mode', async () => {
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir } }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir } })
await writer.init() await writer.init()
await writer.add({ data: 'thing', type: NounType.Concept }) await writer.add({ data: 'thing', type: NounType.Concept })
await writer.flush() await writer.flush()
@ -105,7 +105,7 @@ describe('Multi-process safety + read-only mode', () => {
rootDir: dir rootDir: dir
})) }))
const blocked = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir } }) const blocked = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir } })
await expect(blocked.init()).rejects.toThrow(/another writer holds/i) await expect(blocked.init()).rejects.toThrow(/another writer holds/i)
// Don't track `blocked` for afterEach cleanup since init failed. // Don't track `blocked` for afterEach cleanup since init failed.
}) })
@ -113,16 +113,16 @@ describe('Multi-process safety + read-only mode', () => {
it('allows a second in-process writer with a warning (same PID)', async () => { it('allows a second in-process writer with a warning (same PID)', async () => {
// Two Brainy instances in the same Node process: not the dangerous // Two Brainy instances in the same Node process: not the dangerous
// cross-process case. Should succeed (with a console warning). // cross-process case. Should succeed (with a console warning).
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir } }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir } })
await writer.init() await writer.init()
const second = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir } }) const second = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir } })
await expect(second.init()).resolves.toBeUndefined() await expect(second.init()).resolves.toBeUndefined()
await second.close() await second.close()
}) })
it('lets a reader open while a writer is live', async () => { it('lets a reader open while a writer is live', async () => {
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir } }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir } })
await writer.init() await writer.init()
await writer.add({ data: 'concurrent', type: NounType.Concept }) await writer.add({ data: 'concurrent', type: NounType.Concept })
await writer.flush() await writer.flush()
@ -137,10 +137,10 @@ describe('Multi-process safety + read-only mode', () => {
}) })
it('honors { force: true } to override an existing lock', async () => { it('honors { force: true } to override an existing lock', async () => {
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir } }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir } })
await writer.init() await writer.init()
const second = new Brainy({ const second = new Brainy({ requireSubtype: false,
storage: { type: 'filesystem', rootDirectory: dir }, storage: { type: 'filesystem', rootDirectory: dir },
force: true force: true
}) })
@ -151,14 +151,14 @@ describe('Multi-process safety + read-only mode', () => {
describe('Flush-request RPC', () => { describe('Flush-request RPC', () => {
it('in-process call just flushes', async () => { it('in-process call just flushes', async () => {
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir } }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir } })
await writer.init() await writer.init()
const ok = await writer.requestFlush({ timeoutMs: 1000 }) const ok = await writer.requestFlush({ timeoutMs: 1000 })
expect(ok).toBe(true) expect(ok).toBe(true)
}) })
it('cross-instance request reaches the writer (same-process simulation)', async () => { it('cross-instance request reaches the writer (same-process simulation)', async () => {
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir } }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir } })
await writer.init() await writer.init()
await writer.add({ data: 'pre-request', type: NounType.Concept }) await writer.add({ data: 'pre-request', type: NounType.Concept })
@ -174,7 +174,7 @@ describe('Multi-process safety + read-only mode', () => {
it('returns false when no writer is running', async () => { it('returns false when no writer is running', async () => {
// Seed some data, then close the writer. The data dir exists but no // Seed some data, then close the writer. The data dir exists but no
// writer is listening for flush requests. // writer is listening for flush requests.
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir } }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir } })
await writer.init() await writer.init()
await writer.add({ data: 'orphan', type: NounType.Concept }) await writer.add({ data: 'orphan', type: NounType.Concept })
await writer.flush() await writer.flush()
@ -191,7 +191,7 @@ describe('Multi-process safety + read-only mode', () => {
describe('Diagnostics on a reader', () => { describe('Diagnostics on a reader', () => {
beforeEach(async () => { beforeEach(async () => {
writer = new Brainy({ storage: { type: 'filesystem', rootDirectory: dir } }) writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir } })
await writer.init() await writer.init()
await writer.add({ data: 'one', type: NounType.Concept, metadata: { tag: 'a' } }) await writer.add({ data: 'one', type: NounType.Concept, metadata: { tag: 'a' } })
await writer.add({ data: 'two', type: NounType.Concept, metadata: { tag: 'b' } }) await writer.add({ data: 'two', type: NounType.Concept, metadata: { tag: 'b' } })

View file

@ -30,7 +30,7 @@ describe('find({ orderBy }) sort bug regression', () => {
let brain: Brainy<any> let brain: Brainy<any>
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' }, silent: true }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' }, silent: true })
await brain.init() await brain.init()
}) })

View file

@ -15,7 +15,7 @@ describe('Phase 3: Type-First Query Optimization - Integration', () => {
beforeEach(async () => { beforeEach(async () => {
// Initialize with memory storage and TypeAwareHNSWIndex // Initialize with memory storage and TypeAwareHNSWIndex
brainy = new Brainy({ brainy = new Brainy({ requireSubtype: false,
name: 'phase3-test', name: 'phase3-test',
dimension: 384, dimension: 384,
storage: { storage: {

View file

@ -33,7 +33,7 @@ describe('Read-After-Write Consistency (v5.7.2 Bug Fix)', () => {
// Create unique test directory for each test // Create unique test directory for each test
testDir = join(tmpdir(), `brainy-consistency-${Date.now()}-${Math.random().toString(36).substring(7)}`) testDir = join(tmpdir(), `brainy-consistency-${Date.now()}-${Math.random().toString(36).substring(7)}`)
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
config: { config: {

View file

@ -50,7 +50,7 @@ describe('Relationship Intelligence', () => {
XLSX.writeFile(wb, testExcelPath) XLSX.writeFile(wb, testExcelPath)
// Initialize Brainy // Initialize Brainy
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testDir path: testDir

View file

@ -25,7 +25,7 @@ describe('Remaining APIs Comprehensive Test', () => {
} }
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }

View file

@ -18,7 +18,7 @@ describe('7.31.0 — _rev CAS + ifAbsent', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' as const } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' as const } })
await brain.init() await brain.init()
}) })

View file

@ -26,7 +26,7 @@ describe('S3 Storage Integration', () => {
let brain: Brainy; let brain: Brainy;
beforeAll(async () => { beforeAll(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 's3', type: 's3',
options: { options: {
@ -162,7 +162,7 @@ describe('S3 Storage Integration', () => {
let prefixedBrain: Brainy; let prefixedBrain: Brainy;
beforeAll(async () => { beforeAll(async () => {
prefixedBrain = new Brainy({ prefixedBrain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 's3', type: 's3',
options: { options: {
@ -200,7 +200,7 @@ describe('S3 Storage Integration', () => {
describe('S3 Error Handling', () => { describe('S3 Error Handling', () => {
it('should handle invalid S3 credentials gracefully', async () => { it('should handle invalid S3 credentials gracefully', async () => {
const invalidBrain = new Brainy({ const invalidBrain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 's3', type: 's3',
options: { options: {
@ -230,7 +230,7 @@ describe('S3 Storage Integration', () => {
// Simulate network error by stopping MinIO temporarily // Simulate network error by stopping MinIO temporarily
await minioServer.stop(); await minioServer.stop();
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 's3', type: 's3',
options: s3Config options: s3Config
@ -258,7 +258,7 @@ describe('S3 Storage Integration', () => {
let perfBrain: Brainy; let perfBrain: Brainy;
beforeAll(async () => { beforeAll(async () => {
perfBrain = new Brainy({ perfBrain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 's3', type: 's3',
options: { options: {

View file

@ -18,7 +18,7 @@ describe('Unified Import System', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' as const } storage: { type: 'memory' as const }
}) })
await brain.init() await brain.init()

View file

@ -26,7 +26,7 @@ describe('Storage-Level Batch Operations v5.12.0', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
enableCOW: true enableCOW: true
}) })
@ -552,7 +552,7 @@ describe('Cloud Adapter Batch Operations (Integration)', () => {
it.skip('should use native GCS batch API', async () => { it.skip('should use native GCS batch API', async () => {
// Requires GOOGLE_APPLICATION_CREDENTIALS // Requires GOOGLE_APPLICATION_CREDENTIALS
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'gcs', type: 'gcs',
bucketName: process.env.GCS_TEST_BUCKET || 'test-bucket', bucketName: process.env.GCS_TEST_BUCKET || 'test-bucket',
@ -581,7 +581,7 @@ describe('Cloud Adapter Batch Operations (Integration)', () => {
it.skip('should use native S3 batch API', async () => { it.skip('should use native S3 batch API', async () => {
// Requires AWS credentials // Requires AWS credentials
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 's3', type: 's3',
bucketName: process.env.S3_TEST_BUCKET || 'test-bucket', bucketName: process.env.S3_TEST_BUCKET || 'test-bucket',
@ -610,7 +610,7 @@ describe('Cloud Adapter Batch Operations (Integration)', () => {
it.skip('should use native Azure batch API', async () => { it.skip('should use native Azure batch API', async () => {
// Requires Azure credentials // Requires Azure credentials
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'azure', type: 'azure',
containerName: process.env.AZURE_CONTAINER || 'test-container', containerName: process.env.AZURE_CONTAINER || 'test-container',

View file

@ -34,7 +34,7 @@ describe('Brainy strict-mode self-test (7.30.1)', () => {
// Brain-wide strict mode ON + the exact SDK_CORE_VOCABULARY shape that // Brain-wide strict mode ON + the exact SDK_CORE_VOCABULARY shape that
// the consumer hit. If any internal Brainy path skips subtype, the writes here // the consumer hit. If any internal Brainy path skips subtype, the writes here
// will throw and fail the test. // will throw and fail the test.
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true, silent: true,
requireSubtype: true requireSubtype: true
@ -213,7 +213,7 @@ describe('Brainy strict-mode self-test (7.30.1)', () => {
it('flags entities written without subtype (using includeVFS: true to surface even VFS gaps)', async () => { it('flags entities written without subtype (using includeVFS: true to surface even VFS gaps)', async () => {
// Switch to a non-strict brain so we can deliberately create a gap to test detection // Switch to a non-strict brain so we can deliberately create a gap to test detection
await brain.close() await brain.close()
brain = new Brainy({ storage: { type: 'memory' }, silent: true }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' }, silent: true })
await brain.init() await brain.init()
// Deliberately add an entity without a subtype — only allowed because // Deliberately add an entity without a subtype — only allowed because
@ -231,7 +231,7 @@ describe('Brainy strict-mode self-test (7.30.1)', () => {
it('excludes VFS entities by default (they bypass enforcement anyway)', async () => { it('excludes VFS entities by default (they bypass enforcement anyway)', async () => {
await brain.close() await brain.close()
brain = new Brainy({ storage: { type: 'memory' }, silent: true }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' }, silent: true })
await brain.init() await brain.init()
// VFS root + VFS directories all have subtype set, but even if they // VFS root + VFS directories all have subtype set, but even if they
@ -253,7 +253,7 @@ describe('Brainy strict-mode self-test (7.30.1)', () => {
describe('Error message UX', () => { describe('Error message UX', () => {
it('error message includes caller location and migration link', async () => { it('error message includes caller location and migration link', async () => {
await brain.close() await brain.close()
brain = new Brainy({ storage: { type: 'memory' }, silent: true }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' }, silent: true })
await brain.init() await brain.init()
brain.requireSubtype(NounType.Person, { brain.requireSubtype(NounType.Person, {
values: ['employee', 'customer'], values: ['employee', 'customer'],
@ -277,7 +277,7 @@ describe('Brainy strict-mode self-test (7.30.1)', () => {
it('off-vocabulary message shows the offending value + allowed vocab', async () => { it('off-vocabulary message shows the offending value + allowed vocab', async () => {
await brain.close() await brain.close()
brain = new Brainy({ storage: { type: 'memory' }, silent: true }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' }, silent: true })
await brain.init() await brain.init()
brain.requireSubtype(NounType.Person, { brain.requireSubtype(NounType.Person, {
values: ['employee', 'customer'], values: ['employee', 'customer'],
@ -300,7 +300,7 @@ describe('Brainy strict-mode self-test (7.30.1)', () => {
it('brain-wide strict mode (no per-type vocab) shows the correct guidance', async () => { it('brain-wide strict mode (no per-type vocab) shows the correct guidance', async () => {
await brain.close() await brain.close()
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true, silent: true,
requireSubtype: true requireSubtype: true

View file

@ -13,7 +13,7 @@ describe('Subtype + Facets (7.29.0)', () => {
let brain: Brainy<any> let brain: Brainy<any>
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' }, silent: true }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' }, silent: true })
await brain.init() await brain.init()
}) })

View file

@ -30,7 +30,7 @@ describe('Update Field Asymmetry Fix (v7.5.0)', () => {
} }
// Create fresh Brainy instance // Create fresh Brainy instance
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'filesystem', path: testPath }, storage: { type: 'filesystem', path: testPath },
silent: true silent: true
}) })

View file

@ -12,7 +12,7 @@
* - Layer V4: `migrateField({ entityKind: 'verb' \| 'both' })` rewrites verb * - Layer V4: `migrateField({ entityKind: 'verb' \| 'both' })` rewrites verb
* fields. * fields.
* - Layer V5: `brain.requireSubtype(type, opts)` per-type rules + brain-wide * - Layer V5: `brain.requireSubtype(type, opts)` per-type rules + brain-wide
* strict mode (`new Brainy({ requireSubtype: true })`) reject every write * strict mode (`new Brainy({ requireSubtype: false, requireSubtype: true })`) reject every write
* path missing or off-vocabulary. * path missing or off-vocabulary.
*/ */
@ -24,7 +24,7 @@ describe('Verb subtype + enforcement (7.30.0)', () => {
let brain: Brainy<any> let brain: Brainy<any>
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' }, silent: true }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' }, silent: true })
await brain.init() await brain.init()
}) })
@ -447,9 +447,9 @@ describe('Verb subtype + enforcement (7.30.0)', () => {
}) })
describe('brain-wide strict mode', () => { describe('brain-wide strict mode', () => {
it('new Brainy({ requireSubtype: true }) rejects every add() without subtype', async () => { it('new Brainy({ requireSubtype: false, requireSubtype: true }) rejects every add() without subtype', async () => {
await brain.close() await brain.close()
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true, silent: true,
requireSubtype: true requireSubtype: true
@ -463,7 +463,7 @@ describe('Verb subtype + enforcement (7.30.0)', () => {
it('strict mode accepts writes with subtype', async () => { it('strict mode accepts writes with subtype', async () => {
await brain.close() await brain.close()
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true, silent: true,
requireSubtype: true requireSubtype: true
@ -480,7 +480,7 @@ describe('Verb subtype + enforcement (7.30.0)', () => {
it('strict mode rejects relate() without subtype', async () => { it('strict mode rejects relate() without subtype', async () => {
await brain.close() await brain.close()
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true, silent: true,
requireSubtype: true requireSubtype: true
@ -497,7 +497,7 @@ describe('Verb subtype + enforcement (7.30.0)', () => {
it('except clause allows listed types through without subtype', async () => { it('except clause allows listed types through without subtype', async () => {
await brain.close() await brain.close()
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true, silent: true,
requireSubtype: { except: [NounType.Thing] } requireSubtype: { except: [NounType.Thing] }

View file

@ -25,7 +25,7 @@ describe('Entity Versioning (v5.3.0)', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true silent: true
}) })

View file

@ -39,7 +39,7 @@ describe('VFS + Graph Entities Integration Test', () => {
XLSX.writeFile(wb, testExcelPath) XLSX.writeFile(wb, testExcelPath)
// Initialize Brainy // Initialize Brainy
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testDir path: testDir

View file

@ -21,7 +21,7 @@ describe('VFS API Wiring Verification', () => {
} }
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }

View file

@ -8,7 +8,7 @@ import * as XLSX from 'xlsx'
describe('VFS Debug', () => { describe('VFS Debug', () => {
it('minimal VFS writeFile test', async () => { it('minimal VFS writeFile test', async () => {
const brain = new Brainy({ storage: { type: 'memory' } }) const brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
console.log('✅ Brain initialized') console.log('✅ Brain initialized')

View file

@ -27,7 +27,7 @@ describe('VFS Historical Reads (v5.3.7)', () => {
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
// Initialize Brainy with filesystem storage (required for COW) // Initialize Brainy with filesystem storage (required for COW)
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
adapter: 'filesystem', adapter: 'filesystem',
path: testDir path: testDir

View file

@ -19,7 +19,7 @@ describe('VFS Import Verification (VFS import bug investigation)', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' as const } storage: { type: 'memory' as const }
}) })
await brain.init() await brain.init()

View file

@ -25,7 +25,7 @@ describe('VFS-Knowledge Separation (Option 3C)', () => {
} }
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }

View file

@ -27,7 +27,7 @@ describe('VFS Performance (v5.11.1 Optimization)', () => {
testDir = mkdtempSync(join(tmpdir(), 'brainy-vfs-perf-test-')) testDir = mkdtempSync(join(tmpdir(), 'brainy-vfs-perf-test-'))
// Initialize Brain with FileSystemStorage // Initialize Brain with FileSystemStorage
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }

View file

@ -26,7 +26,7 @@ describe('VFS File Versioning (v6.3.2 Fix)', () => {
} }
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }

View file

@ -18,7 +18,7 @@ describe('Metadata Index Debug', () => {
} }
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }

View file

@ -18,7 +18,7 @@ describe('Simple VFS Filter Test', () => {
} }
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }

View file

@ -12,7 +12,7 @@ async function testTypeFiltering() {
console.log('=' .repeat(60)) console.log('=' .repeat(60))
// Create in-memory instance for testing // Create in-memory instance for testing
const brain = new Brainy({ const brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } storage: { type: 'memory' }
}) })
await brain.init() await brain.init()

View file

@ -18,7 +18,7 @@ describe('isVFS Flag Diagnostic', () => {
} }
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }

View file

@ -27,7 +27,7 @@ describe('VFS Multiple Init Diagnostic', () => {
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
// Create brain with filesystem storage // Create brain with filesystem storage
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testDir path: testDir
@ -108,7 +108,7 @@ describe('VFS Multiple Init Diagnostic', () => {
it('should handle NEW brain instances gracefully (per-user scenario)', async () => { it('should handle NEW brain instances gracefully (per-user scenario)', async () => {
// Simulate creating separate brain instances per user // Simulate creating separate brain instances per user
// This is closer to a consumer's getUserBrainy() pattern // This is closer to a consumer's getUserBrainy() pattern
const brain2 = new Brainy({ const brain2 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testDir // Same storage! path: testDir // Same storage!
@ -147,7 +147,7 @@ describe('VFS Multiple Init Diagnostic', () => {
await vfs.writeFile('/test-dir/test.txt', 'Hello') await vfs.writeFile('/test-dir/test.txt', 'Hello')
// Call init again (simulating new request) // Call init again (simulating new request)
const brain3 = new Brainy({ const brain3 = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testDir path: testDir

View file

@ -17,7 +17,7 @@ describe('VFS Search Debug', () => {
} }
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
options: { path: testDir } options: { path: testDir }

View file

@ -21,7 +21,7 @@ describe('VFS Where Clause Diagnostic', () => {
} }
fs.mkdirSync(testDir, { recursive: true }) fs.mkdirSync(testDir, { recursive: true })
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testDir path: testDir

View file

@ -136,7 +136,7 @@ describe('🧠 Graph Scale Performance Benchmarks', () => {
}) })
// Initialize Brainy for unified testing // Initialize Brainy for unified testing
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
enableGraphIndex: true, enableGraphIndex: true,
enableMetadataIndex: true enableMetadataIndex: true

View file

@ -19,7 +19,7 @@ describe('Triple Intelligence Performance at Scale', () => {
const startTime = Date.now() const startTime = Date.now()
// Initialize Brainy with all required indexes // Initialize Brainy with all required indexes
brain = new Brainy() brain = new Brainy({ requireSubtype: false })
await brain.init({ await brain.init({
enableMetadataIndex: true, enableMetadataIndex: true,
enableGraphIndex: true, enableGraphIndex: true,
@ -357,7 +357,7 @@ describe('Triple Intelligence Correctness', () => {
let triple: TripleIntelligenceSystem let triple: TripleIntelligenceSystem
beforeAll(async () => { beforeAll(async () => {
brain = new Brainy() brain = new Brainy({ requireSubtype: false })
await brain.init({ await brain.init({
enableMetadataIndex: true, enableMetadataIndex: true,
enableGraphIndex: true enableGraphIndex: true

View file

@ -52,7 +52,7 @@ describe('TypeAware Performance Benchmarks', () => {
let entities: string[] = [] let entities: string[] = []
beforeEach(async () => { beforeEach(async () => {
brainMemory = new Brainy({ storage: { type: 'memory' } }) brainMemory = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brainMemory.init() await brainMemory.init()
// Create 1000 entities across 5 types // Create 1000 entities across 5 types

View file

@ -43,7 +43,7 @@ describe('Metadata index cleanup after delete / deleteMany', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
}) })

View file

@ -31,7 +31,7 @@ describe('v5.7.0 Deadlock Regression', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
}) })

View file

@ -12,7 +12,7 @@ describe('Streaming Pipeline', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
warmup: false warmup: false
}) })

View file

@ -25,7 +25,7 @@ describe('Transactions + COW Integration', () => {
mkdirSync(testDir, { recursive: true }) mkdirSync(testDir, { recursive: true })
// Initialize Brainy with COW enabled // Initialize Brainy with COW enabled
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testDir path: testDir

View file

@ -25,7 +25,7 @@ describe('Transactions + Distributed Storage Integration', () => {
// Use filesystem as proxy for distributed storage // Use filesystem as proxy for distributed storage
// (In production, this would be S3, Azure, GCS, etc.) // (In production, this would be S3, Azure, GCS, etc.)
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testDir path: testDir

View file

@ -23,7 +23,7 @@ describe('Transactions + Sharding Integration', () => {
testDir = join(tmpdir(), `brainy-shard-test-${Date.now()}`) testDir = join(tmpdir(), `brainy-shard-test-${Date.now()}`)
mkdirSync(testDir, { recursive: true }) mkdirSync(testDir, { recursive: true })
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testDir path: testDir

View file

@ -23,7 +23,7 @@ describe('Transactions + TypeAware Storage Integration', () => {
testDir = join(tmpdir(), `brainy-typeaware-test-${Date.now()}`) testDir = join(tmpdir(), `brainy-typeaware-test-${Date.now()}`)
mkdirSync(testDir, { recursive: true }) mkdirSync(testDir, { recursive: true })
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testDir path: testDir

View file

@ -14,7 +14,7 @@ describe('Brainy 3.0 Core (Unit Tests)', () => {
beforeEach(async () => { beforeEach(async () => {
// Create instance with real embeddings for production-ready tests // Create instance with real embeddings for production-ready tests
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } storage: { type: 'memory' }
}) })

View file

@ -22,7 +22,7 @@ describe('brain.get() Metadata-Only Optimization (v5.11.1)', () => {
let entityId: string let entityId: string
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: new MemoryStorage(), storage: new MemoryStorage(),
silent: true silent: true
}) })

View file

@ -6,7 +6,7 @@ describe('Brainy Batch Operations', () => {
let brain: Brainy<any> let brain: Brainy<any>
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
}) })

View file

@ -7,7 +7,7 @@ describe('Brainy.find()', () => {
let brain: Brainy<any> let brain: Brainy<any>
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } // Use memory storage for isolation storage: { type: 'memory' } // Use memory storage for isolation
}) })
await brain.init() await brain.init()

View file

@ -14,7 +14,7 @@ describe('Hybrid Search (v7.7.0)', () => {
let brain: Brainy<any> let brain: Brainy<any>
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' } storage: { type: 'memory' }
}) })
await brain.init() await brain.init()

View file

@ -13,7 +13,7 @@ describe('Duplicate Check Optimization', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy() brain = new Brainy({ requireSubtype: false })
await brain.init() await brain.init()
}) })

View file

@ -20,7 +20,7 @@ describe('createEntities Default Value (v4.3.2 Bug Fix)', () => {
fs.rmSync(testDir, { recursive: true }) fs.rmSync(testDir, { recursive: true })
} }
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { storage: {
type: 'filesystem', type: 'filesystem',
path: testDir path: testDir

View file

@ -19,7 +19,7 @@ describe('GraphAdjacencyIndex Pagination', () => {
let neighborIds: string[] let neighborIds: string[]
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy() brain = new Brainy({ requireSubtype: false })
await brain.init() await brain.init()
// Create central entity // Create central entity

View file

@ -7,7 +7,7 @@ describe('InstancePool', () => {
let pool: InstancePool let pool: InstancePool
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
pool = new InstancePool(brain) pool = new InstancePool(brain)
}) })

View file

@ -19,7 +19,7 @@ describe('Import preserveSource Fix (v5.1.2)', () => {
let testFilePath: string let testFilePath: string
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true silent: true
}) })

View file

@ -13,7 +13,7 @@ describe('NaturalLanguageProcessor', () => {
let nlp: NaturalLanguageProcessor let nlp: NaturalLanguageProcessor
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ storage: { type: 'memory' } }) brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
await brain.init() await brain.init()
nlp = new NaturalLanguageProcessor(brain) nlp = new NaturalLanguageProcessor(brain)

View file

@ -14,7 +14,7 @@ describe('Domain and Time Clustering', () => {
let brain: Brainy let brain: Brainy
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
enableCache: false, enableCache: false,
storage: { type: 'memory' } // Use memory storage for tests storage: { type: 'memory' } // Use memory storage for tests
}) })

View file

@ -13,7 +13,7 @@ describe('Neural API - Production Testing', () => {
// v5.1.0: Use memory storage and disable augmentations for faster, reliable tests // v5.1.0: Use memory storage and disable augmentations for faster, reliable tests
beforeEach(async () => { beforeEach(async () => {
brain = new Brainy({ brain = new Brainy({ requireSubtype: false,
storage: { type: 'memory' }, storage: { type: 'memory' },
silent: true silent: true
}) })

Some files were not shown because too many files have changed in this diff Show more