refactor(8.0): delete DataAPI — superseded by Db persist/restore + import API + stats
The legacy backup/import/export/stats facade (src/api/DataAPI.ts) drifted from the modern entity shape and every job it did now has a first-class surface. Delete it and brain.data(), and rewire the CLI: - data-stats → brain.stats() (full BrainyStats report: per-type breakdowns, indexed fields, index health, storage backend, writer lock, version) - clean → brain.clear() - export → alias of snapshot; a db.persist() snapshot is the full-fidelity export format (open with Brainy.load, load wholesale with brainy restore); external data ingestion remains brainy import (UniversalImportAPI) Rewiring clean onto brain.clear() exposed two real bugs, both fixed: - clear() left this.graphIndex undefined forever — any graph-touching call afterwards (relate, getNeighbors, stats) crashed. clear() now re-resolves the graph index exactly as init() does and re-wires the shared UUID↔int resolver, and re-resolves the metadata index with the same provider fallback as init(). - storage.clear() reset the legacy totals but not the per-type/subtype count rollups or id→type caches, so stats() reported phantom counts for deleted entities. Both adapters now delegate derived-state reset to reloadDerivedState(), the same path restore-from-snapshot uses. One-shot CLI commands (data-stats, clean, snapshot/export, restore, history, generation) now close the brain and exit explicitly — global cache timers otherwise keep the process alive holding the writer lock. Verified: build clean, 1383/1383 unit tests, 24/24 db-mvcc integration, plus an end-to-end CLI smoke (add → data-stats → export → clean → data-stats).
This commit is contained in:
parent
cc8037db10
commit
478fa176f2
12 changed files with 262 additions and 639 deletions
|
|
@ -220,16 +220,18 @@ describe('Brainy 3.0 Core (Unit Tests)', () => {
|
|||
type: NounType.Concept
|
||||
})
|
||||
|
||||
// Clear using DataAPI
|
||||
const dataAPI = await brain.data()
|
||||
await dataAPI.clear({ entities: true, relations: false })
|
||||
|
||||
// Verify data is cleared
|
||||
const results = await brain.find({
|
||||
// Clear everything — entities, relationships, and all indexes
|
||||
await brain.clear()
|
||||
|
||||
// Verify user data is cleared. clear() re-creates a fresh VFS root
|
||||
// entity, and a thresholdless vector search can surface it — so filter
|
||||
// VFS bookkeeping out and assert the added entities are gone.
|
||||
const results = await brain.find({
|
||||
query: 'Test',
|
||||
limit: 10
|
||||
limit: 10
|
||||
})
|
||||
expect(results.length).toBe(0)
|
||||
const userResults = results.filter(r => !r.metadata?.isVFS)
|
||||
expect(userResults.length).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue