removeItem() scanned the ENTIRE corpus on every delete to find nodes that referenced the removed id (and to repair edges left asymmetric by pruning), so a delete was O(N) and a bulk delete O(N²) — on the open-core JS vector path that serves when no native provider is registered. Maintain a reverse-adjacency index (`target → level → set of nodes that link to target`), so removeItem touches only the removed node's actual in-neighbors: O(in-degree) per delete, O(N·degree) for a bulk delete. The index is lazily built, maintained incrementally at every forward-edge mutation (add-link and prune), and invalidated (rebuilt on next use) by the bulk paths (cold-load restore + clear). New tests assert the three invariants that matter for a reverse index: no dangling references to deleted nodes, the incrementally- maintained index exactly equals a fresh rebuild from the live adjacency, and search still returns the survivors' true nearest neighbours (exact vs brute force). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| aggregation | ||
| brainy | ||
| db | ||
| graph | ||
| hnsw | ||
| import | ||
| indexes/columnStore | ||
| neural | ||
| performance | ||
| storage | ||
| transaction | ||
| types | ||
| universal | ||
| utils | ||
| vfs | ||
| boundary-no-native.test.ts | ||
| brainy-core.unit.test.ts | ||
| brainy-get-optimization.test.ts | ||
| create-entities-default.test.ts | ||
| fieldTypeInference.test.ts | ||
| plugin-version-coupling.test.ts | ||
| plugin.test.ts | ||
| type-filtering.unit.test.ts | ||
| vfs-multi-instance-diagnostic.test.ts | ||
| vfs-restart-fix.test.ts | ||