brainy/tests/unit
David Snelling 1694f68419 fix: graph adjacency cold-load consistency guard — no more silent [] on connected
A native graph provider can load its relationship COUNT (manifest) on a cold open
but fail to load the source→target adjacency itself (observed on mmap-filesystem:
the SSTable-segment load is swallowed). The result is find({ connected }),
neighbors(), and related() silently returning [] despite persisted edges — and
staying empty after warm-up. Because it is [] not an error, callers cannot tell
real data is missing.

Brainy now runs a one-time consistency check on the first graph read: if the index
reports relationships exist but a known persisted edge's source resolves to no
neighbors, force a rebuild from storage (which re-scans + repopulates the adjacency);
if even that cannot read the edge, throw the new GraphIndexNotReadyError instead of
serving [] as truth. O(1) probe (one verb + one neighbor lookup), cached per brain,
and a no-op once the adjacency is live — so it self-heals the cold-open case and is
loud when it genuinely can't.

Wired into neighbors() + getRelations() (the graph-read primitives behind
find({ connected })). The underlying cold-open load is a native-provider concern
(addressed upstream); this makes the failure self-healing + loud rather than silent.

Tests: tests/unit/brainy/graph-adjacency-cold-load.test.ts (live → no-op; broken →
rebuild; unfixable → throws; size 0 / no edges → no-op; transient failure → re-checks
without breaking the query). Full unit gate green (1531/1531).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 10:55:12 -07:00
..
aggregation feat: exact percentile and distinctCount aggregation ops 2026-05-26 16:18:47 -07:00
api refactor: rename BackupData → PortableGraph (the type is interchange, not a backup) 2026-06-19 12:30:06 -07:00
brainy fix: graph adjacency cold-load consistency guard — no more silent [] on connected 2026-06-24 10:55:12 -07:00
graph feat: add v5.8.0 features - transactions, pagination, and comprehensive docs 2025-11-14 10:26:23 -08:00
hnsw fix: mmap-vector backend capacity NaN at the provider FFI boundary 2026-06-10 09:29:54 -07:00
import fix: flush all native providers on shutdown to prevent data loss 2026-02-01 16:23:49 -08:00
indexes/columnStore feat: column-store JS↔native interchange — raw-blob unify (2.4.0 #4) 2026-05-28 10:37:47 -07:00
neural fix: recalibrate find({ limit }) cap + two-tier enforcement + caller location 2026-06-08 12:49:43 -07:00
performance refactor: remove augmentation system and semantic type matching 2026-02-01 10:48:56 -08:00
storage fix: getNouns cursor pagination re-scanned the first page forever (permanent CPU loop) 2026-06-22 18:00:01 -07:00
types fix: update tests for Stage 3 CANONICAL taxonomy (42 nouns, 127 verbs) 2025-11-11 10:09:01 -08:00
utils fix: query-cap memory misread (MemAvailable + floor) + rootDirectory getter for native mmap fast-path 2026-06-16 08:46:39 -07:00
versioning fix(versioning): clean architecture with index pollution prevention 2025-12-09 09:36:10 -08:00
vfs fix: vfs.rename() issues a metadata-only update + rollback of fresh adds removes them 2026-06-11 14:59:40 -07:00
brainy-core.unit.test.ts feat: enforce data/metadata separation, numeric range queries, improved docs 2026-02-09 12:07:54 -08:00
brainy-get-optimization.test.ts fix: flush all native providers on shutdown to prevent data loss 2026-02-01 16:23:49 -08:00
create-entities-default.test.ts fix: flush all native providers on shutdown to prevent data loss 2026-02-01 16:23:49 -08:00
fieldTypeInference.test.ts feat: production-ready value-based temporal field detection 2025-10-16 13:58:57 -07:00
plugin.test.ts refactor: remove augmentation system and semantic type matching 2026-02-01 10:48:56 -08:00
type-filtering.unit.test.ts fix: recalibrate find({ limit }) cap + two-tier enforcement + caller location 2026-06-08 12:49:43 -07:00
vfs-multi-instance-diagnostic.test.ts fix: recalibrate find({ limit }) cap + two-tier enforcement + caller location 2026-06-08 12:49:43 -07:00
vfs-restart-fix.test.ts fix: set verb.source/target to entity UUID instead of NounType 2026-02-02 09:20:38 -08:00