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:
parent
0c4a51c24e
commit
606445cd61
74 changed files with 712 additions and 7470 deletions
|
|
@ -524,102 +524,6 @@ describe('Brainy Public API - Complete Coverage', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('Neural API', () => {
|
||||
let entityIds: string[]
|
||||
|
||||
beforeEach(async () => {
|
||||
brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
|
||||
await brain.init()
|
||||
|
||||
const result = await brain.addMany({
|
||||
items: [
|
||||
{ data: 'Cat', type: NounType.Concept, metadata: { category: 'animal' } },
|
||||
{ data: 'Dog', type: NounType.Concept, metadata: { category: 'animal' } },
|
||||
{ data: 'Tiger', type: NounType.Concept, metadata: { category: 'animal' } },
|
||||
{ data: 'Car', type: NounType.Thing, metadata: { category: 'vehicle' } },
|
||||
{ data: 'Truck', type: NounType.Thing, metadata: { category: 'vehicle' } },
|
||||
{ data: 'Python', type: NounType.Language, metadata: { category: 'programming' } },
|
||||
{ data: 'JavaScript', type: NounType.Language, metadata: { category: 'programming' } }
|
||||
]
|
||||
})
|
||||
entityIds = result.successful
|
||||
}, 120000)
|
||||
|
||||
afterEach(async () => {
|
||||
await brain.close()
|
||||
})
|
||||
|
||||
describe('brain.neural().clusters()', () => {
|
||||
it('should cluster entities by similarity', async () => {
|
||||
const clusters = await brain.neural().clusters({
|
||||
k: 3,
|
||||
maxIterations: 10
|
||||
})
|
||||
|
||||
expect(clusters).toBeDefined()
|
||||
expect(clusters.length).toBeGreaterThan(0)
|
||||
expect(clusters.every(c => c.members.length > 0)).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('brain.neural().hierarchy()', () => {
|
||||
it('should build semantic hierarchy for an entity', async () => {
|
||||
// hierarchy() requires an entity ID
|
||||
const hierarchy = await brain.neural().hierarchy(entityIds[0])
|
||||
|
||||
expect(hierarchy).toBeDefined()
|
||||
// Hierarchy structure includes optional root, levels, children, etc.
|
||||
expect(typeof hierarchy).toBe('object')
|
||||
})
|
||||
})
|
||||
|
||||
describe('brain.neural().outliers()', () => {
|
||||
it('should detect anomalous entities', async () => {
|
||||
await brain.add({
|
||||
data: 'Quantum physics equations and string theory',
|
||||
type: NounType.Document,
|
||||
metadata: { category: 'science' }
|
||||
})
|
||||
|
||||
const outliers = await brain.neural().outliers({
|
||||
threshold: 0.8
|
||||
})
|
||||
|
||||
expect(outliers).toBeDefined()
|
||||
expect(Array.isArray(outliers)).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('brain.neural().visualize()', () => {
|
||||
it('should generate visualization data', async () => {
|
||||
const vizData = await brain.neural().visualize({
|
||||
dimensions: 2,
|
||||
algorithm: 'force'
|
||||
})
|
||||
|
||||
expect(vizData).toBeDefined()
|
||||
expect(vizData.nodes).toBeDefined()
|
||||
expect(Array.isArray(vizData.nodes)).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('brain.neural().neighbors()', () => {
|
||||
it('should find nearest neighbors', async () => {
|
||||
if (entityIds.length > 0) {
|
||||
const result = await brain.neural().neighbors(entityIds[0], {
|
||||
limit: 3
|
||||
})
|
||||
|
||||
// NeighborsResult has a neighbors array
|
||||
expect(result).toBeDefined()
|
||||
expect(result.neighbors).toBeDefined()
|
||||
// Small datasets may not produce nearest neighbors
|
||||
expect(result.neighbors.length).toBeGreaterThanOrEqual(0)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Statistics', () => {
|
||||
beforeEach(async () => {
|
||||
brain = new Brainy({ requireSubtype: false, storage: { type: 'memory' } })
|
||||
|
|
@ -659,7 +563,7 @@ describe('Brainy Public API - Complete Coverage', () => {
|
|||
const fsBrain = new Brainy({ requireSubtype: false,
|
||||
storage: {
|
||||
type: 'filesystem',
|
||||
options: { path: fsTestDir }
|
||||
path: fsTestDir
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -693,7 +597,7 @@ describe('Brainy Public API - Complete Coverage', () => {
|
|||
const fsBrain = new Brainy({ requireSubtype: false,
|
||||
storage: {
|
||||
type: 'filesystem',
|
||||
options: { path: fsTestDir }
|
||||
path: fsTestDir
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue