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
|
|
@ -173,12 +173,6 @@ program
|
|||
.option('--skip-node-modules', 'Skip node_modules', true)
|
||||
.action(importCommands.import)
|
||||
|
||||
program
|
||||
.command('export [file]')
|
||||
.description('Export database')
|
||||
.option('-f, --format <format>', 'Output format (json|csv|jsonl)', 'json')
|
||||
.action(coreCommands.export)
|
||||
|
||||
program
|
||||
.command('diagnostics')
|
||||
.alias('diag')
|
||||
|
|
@ -549,11 +543,12 @@ program
|
|||
|
||||
// ===== Data Management Commands =====
|
||||
|
||||
|
||||
program
|
||||
program
|
||||
.command('data-stats')
|
||||
.description('Show detailed database statistics')
|
||||
.option('--verbose', 'List every indexed field name')
|
||||
.option('--json', 'Output as JSON')
|
||||
.option('--pretty', 'Pretty print JSON')
|
||||
.action(dataCommands.stats)
|
||||
|
||||
// ===== Inspect Commands =====
|
||||
|
|
@ -764,7 +759,12 @@ program
|
|||
|
||||
program
|
||||
.command('snapshot <path>')
|
||||
.description('📸 Persist the current generation as a self-contained snapshot (instant hard links)')
|
||||
.alias('export')
|
||||
.description(
|
||||
'📸 Persist the current generation as a self-contained snapshot (instant hard links). ' +
|
||||
'A snapshot is the full-fidelity export format: open it with Brainy.load(path) or ' +
|
||||
'load it wholesale with `brainy restore`. For ingesting external data files, see `brainy import`.'
|
||||
)
|
||||
.action(snapshotCommands.snapshot)
|
||||
|
||||
program
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue