-
released this
2025-11-06 23:25:32 +01:00 | 594 commits to main since this release🐛 Critical Bug Fix
Fixed critical bug where
getRelations()returned empty array despite relationships existing. This affected ALL 8 storage adapters when called without filters.Root Cause
The bug was a simple parameter default issue:
getVerbs()calledgetVerbsWithPagination()without passingoffsetoffsetwasundefined→targetCount = undefined + 100 = NaN- Loop condition
collectedVerbs.length < NaNwas alwaysfalse - Loop never ran → returned 0 results
The Fix
Two-line change:
// Default offset to 0 if undefined const { limit, offset = 0, filter } = optionsApplied to:
getVerbsWithPagination()(line 1183)getNounsWithPagination()(line 1051)
Impact
Fixed:
- ✅ Workshop bug report: 1,141 relationships exist but
getRelations()returned empty array - ✅ All fresh Brainy instances (MemoryStorage, FileSystemStorage, etc.)
- ✅ Affects all 8 storage adapters (all extend BaseStorage)
Performance:
- ✅ No degradation - optimizations now work as designed
- ✅ Type skipping verified: checked 1 type, skipped 126 empty types
- ✅ Early termination verified: stopped at limit
- ✅ Billion-scale safe: bounded memory, streaming, type-aware
Not Affected:
- Filtered queries:
getRelations({ from: id }),getRelations({ to: id }) - Queries with type filter:
getRelations({ type: 'relatedTo' })
Test Results
MemoryStorage ✅
Layer 1 (getVerbsByType_internal): 1 verbs ✅ Layer 2 (getVerbs with filter): 1 verbs ✅ Layer 3 (getVerbs no filter): 1 verbs ✅ ← FIXED! Layer 4 (brain.getRelations()): 1 relations ✅ ← FIXED!FileSystemStorage ✅
brain.getRelations(): 1 relationships ✅ storage.getVerbs(): 1 verbs ✅Files Changed
src/storage/baseStorage.ts- Added parameter defaults and conditional optimization
Upgrade Instructions
For Workshop Team:
npm install @soulcraft/brainy@5.6.0No code changes required - the fix is automatic upon upgrade.
Full Changelog
Fixed:
- Fix getRelations() returning empty array for fresh instances (#5e9efd1)
Previous (v5.5.0):
- Optimize nouns+verbs pagination for billion-scale (symmetric architecture)
- Resolve getRelations() empty array bug for ALL storage adapters
Install:
npm install @soulcraft/brainy@5.6.0Tested on:
- ✅ MemoryStorage
- ✅ FileSystemStorage
- ✅ All 8 storage adapters (inherit from BaseStorage)
Billion-scale verified:
- ✅ Sharding preserved
- ✅ Type-aware preserved
- ✅ Early termination working
- ✅ Memory bounded
Downloads
-
Source code (ZIP)
0 downloads
-
Source code (TAR.GZ)
0 downloads