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
|
|
@ -12,6 +12,7 @@ import { Brainy, NounType, VerbType } from '../src/brainy.js'
|
|||
import { DirectoryImporter } from '../src/vfs/importers/DirectoryImporter.js'
|
||||
import { ProgressTracker, formatProgress } from '../src/types/progress.types.js'
|
||||
import { detectRelationshipsWithConfidence } from '../src/neural/relationshipConfidence.js'
|
||||
import { NeuralEntityExtractor } from '../src/neural/entityExtractor.js'
|
||||
|
||||
async function main() {
|
||||
console.log('🧠 Brainy 3.21.0 - Directory Import with Caching Example\n')
|
||||
|
|
@ -22,6 +23,9 @@ async function main() {
|
|||
|
||||
console.log('✅ Brainy initialized\n')
|
||||
|
||||
// The entity extractor (and its extraction cache) is constructed directly.
|
||||
const extractor = new NeuralEntityExtractor(brain)
|
||||
|
||||
// Example 1: Import directory with entity extraction caching
|
||||
console.log('📁 Example 1: Import Directory with Caching\n')
|
||||
|
||||
|
|
@ -72,7 +76,7 @@ async function main() {
|
|||
|
||||
console.log('First extraction (cache miss):')
|
||||
const startTime1 = Date.now()
|
||||
const entities1 = await brain.neural.extractor.extract(sampleText, {
|
||||
const entities1 = await extractor.extract(sampleText, {
|
||||
types: [NounType.Person, NounType.Service, NounType.Technology],
|
||||
confidence: 0.7,
|
||||
cache: {
|
||||
|
|
@ -87,7 +91,7 @@ async function main() {
|
|||
|
||||
console.log('Second extraction (cache hit):')
|
||||
const startTime2 = Date.now()
|
||||
const entities2 = await brain.neural.extractor.extract(sampleText, {
|
||||
const entities2 = await extractor.extract(sampleText, {
|
||||
types: [NounType.Person, NounType.Service, NounType.Technology],
|
||||
confidence: 0.7,
|
||||
cache: {
|
||||
|
|
@ -100,7 +104,7 @@ async function main() {
|
|||
console.log(` Speedup: ${Math.round(time1 / time2)}x faster!\n`)
|
||||
|
||||
// Show cache statistics
|
||||
const cacheStats = brain.neural.extractor.getCacheStats()
|
||||
const cacheStats = extractor.getCacheStats()
|
||||
console.log('📊 Cache Statistics:')
|
||||
console.log(` Hits: ${cacheStats.hits}`)
|
||||
console.log(` Misses: ${cacheStats.misses}`)
|
||||
|
|
@ -204,20 +208,20 @@ async function main() {
|
|||
console.log('Cache operations:')
|
||||
|
||||
// Cleanup expired entries
|
||||
const cleaned = brain.neural.extractor.cleanupCache()
|
||||
const cleaned = extractor.cleanupCache()
|
||||
console.log(` Cleaned ${cleaned} expired entries`)
|
||||
|
||||
// Invalidate specific cache entry
|
||||
const invalidated = brain.neural.extractor.invalidateCache('hash:abc123')
|
||||
const invalidated = extractor.invalidateCache('hash:abc123')
|
||||
console.log(` Invalidated entry: ${invalidated}`)
|
||||
|
||||
// Get final stats
|
||||
const finalStats = brain.neural.extractor.getCacheStats()
|
||||
const finalStats = extractor.getCacheStats()
|
||||
console.log(` Final cache size: ${finalStats.totalEntries} entries`)
|
||||
console.log(` Memory used: ~${Math.round(finalStats.cacheSize / 1024)}KB`)
|
||||
|
||||
// Clear all cache (optional)
|
||||
// brain.neural.extractor.clearCache()
|
||||
// extractor.clearCache()
|
||||
// console.log(' Cleared entire cache')
|
||||
|
||||
console.log('\n✨ Example complete!')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue