feat(8.0): API simplification — remove neural()/Db.search, one storage path key, integration→0

8.0 RC cleanup toward "one place per thing, zero-config, no deprecation":

- Remove the `brain.neural()` clustering namespace (ImprovedNeuralAPI + the dead
  legacy NeuralAPI + the neural CLI + neural-only types). Similarity is `find({vector})`
  / `similar({to})`; attribute grouping is the aggregation `GROUP BY` engine. The separate
  entity-extraction / smart-import feature (NeuralImport, NeuralEntityExtractor, SmartExtractor,
  NaturalLanguageProcessor, `brain.extract()`/`brain.nlp()`) is kept.
- Remove `Db.search()`; `find()` is the one query verb (accepts a bare string or FindParams).
  Fix the bundled MCP client, which called a non-existent `brain.search(query, limit)` →
  now `find({ query, limit })`.
- Storage config: collapse to one canonical top-level `path` key. The pre-8.0 aliases
  (`rootDirectory`, `options.*`, `fileSystemStorage.*`) are removed and now THROW with the
  exact rename instead of silently defaulting to `./brainy-data` on upgrade. A single resolver
  feeds createStorage, the 7.x→8.0 migration probe, and the plugin-factory handoff, so a native
  storage provider resolves the identical root (no split-brain).
- Fix `similar({ threshold })`: the min-similarity filter was silently dropped; it is now
  applied as a post-filter on `result.score` (the documented way to bound semantic results).
- Fix `vfs.rename()` on a directory: child path updates spread the entity vector into `update()`
  and failed dimension validation; they are metadata-only updates now.
- Fix `vfs.move()`: copy+delete orphaned the content-addressed content blob (the destination
  shared the source hash, then unlink removed it). `move()` now delegates to `rename()` — an
  in-place path change that preserves the blob and the entity id, for files and directories.
- Fix streaming import: the bulk fast path never flushed mid-import nor signalled queryability.
  Entity writes are now chunked by a progressive flush interval (100 → 1000 → 5000); each chunk
  flushes and emits `progress.queryable`, so imported data is queryable during the import.
- Sweep all docs, comments, and JSDoc for the removed/changed APIs.

Integration suite: 49 files / 588 passed / 0 failed. Unit: 80 files / 1456 passed, no type errors.
This commit is contained in:
David Snelling 2026-06-20 13:31:11 -07:00
parent 0c4a51c24e
commit 606445cd61
74 changed files with 712 additions and 7470 deletions

View file

@ -56,7 +56,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
describe('Reader sees correct entity counts after writer cold-start', () => {
it('preserves entity count across writer→close→reader-open', async () => {
writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir }, silent: true })
writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', path: dir }, silent: true })
await writer.init()
const writerIds = new Set<string>()
for (let i = 0; i < 10; i++) {
@ -68,7 +68,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
writer = null
reader = await Brainy.openReadOnly({
storage: { type: 'filesystem', rootDirectory: dir }
storage: { type: 'filesystem', path: dir }
})
// find() must return every entity we explicitly added — the historical
// bug was 0 results despite N being on disk. Anything beyond N from
@ -80,7 +80,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
})
it('preserves type classification (no "all entities are thing" poisoning)', async () => {
writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir }, silent: true })
writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', path: dir }, silent: true })
await writer.init()
// Three types. Each id is tracked individually so we don't conflate
// user-added entities with whatever VFS / auto-extraction inserts.
@ -95,7 +95,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
writer = null
reader = await Brainy.openReadOnly({
storage: { type: 'filesystem', rootDirectory: dir }
storage: { type: 'filesystem', path: dir }
})
// Every user-added id is recoverable when querying by its declared
@ -120,7 +120,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
describe('find() consistency', () => {
it('returns entities that exist on disk (not silent empty)', async () => {
writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir }, silent: true })
writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', path: dir }, silent: true })
await writer.init()
const conceptIds: string[] = []
for (let i = 0; i < 4; i++) {
@ -136,7 +136,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
writer = null
reader = await Brainy.openReadOnly({
storage: { type: 'filesystem', rootDirectory: dir }
storage: { type: 'filesystem', path: dir }
})
const all = await reader.find({ where: { entityType: 'booking' } })
expect(all.length).toBe(4)
@ -145,7 +145,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
})
it('returns [] with a logged warning for unindexed field', async () => {
writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir }, silent: true })
writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', path: dir }, silent: true })
await writer.init()
await writer.add({ data: 'test', type: NounType.Concept })
await writer.flush()
@ -153,7 +153,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
writer = null
reader = await Brainy.openReadOnly({
storage: { type: 'filesystem', rootDirectory: dir }
storage: { type: 'filesystem', path: dir }
})
// Field that has never been written — production find() should degrade
// to [] (caught by getIdsForFilter), not throw upward.
@ -162,7 +162,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
})
it('raw getIds() throws BrainyError(FIELD_NOT_INDEXED) for unindexed field', async () => {
writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir }, silent: true })
writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', path: dir }, silent: true })
await writer.init()
await writer.add({ data: 'test', type: NounType.Concept })
await writer.flush()
@ -181,7 +181,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
describe('explain() and health() match the new contract', () => {
it('explain() returns column-store path for indexed fields', async () => {
writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir }, silent: true })
writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', path: dir }, silent: true })
await writer.init()
await writer.add({
data: 'test',
@ -196,7 +196,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
})
it('health() reports pass for a clean writer + reader handoff', async () => {
writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', rootDirectory: dir }, silent: true })
writer = new Brainy({ requireSubtype: false, storage: { type: 'filesystem', path: dir }, silent: true })
await writer.init()
for (let i = 0; i < 5; i++) {
await writer.add({ data: `entry ${i}`, type: NounType.Concept })
@ -206,7 +206,7 @@ describe('BR-FIND-WHERE-ZERO regression', () => {
writer = null
reader = await Brainy.openReadOnly({
storage: { type: 'filesystem', rootDirectory: dir }
storage: { type: 'filesystem', path: dir }
})
const report = await reader.health()
// index-parity must pass (HNSW count matches metadata count) and