brainy/src/neural
David Snelling e1fd5077af fix: resolve getRelations() empty array bug for ALL storage adapters (v5.5.0)
CRITICAL BUG FIX (Severity: HIGH)
Affects: FileSystemStorage, S3Storage, GCS, Azure, R2, Memory, OPFS, Historical
Impact: brain.getRelations() returned [] despite 1,141+ relationships in storage

ROOT CAUSE:
- v5.4.0 removed getVerbsWithPagination() from storage adapters
- BaseStorage.getVerbs() expected this method but returned empty array when missing
- All 8 storage adapters affected (all extend BaseStorage)

THE FIX:
Universal fallback in BaseStorage.getVerbs() that works for ALL adapters:

1. **Type Iteration with Early Termination** (billion-scale safe):
   - Iterates through 127 Stage 3 CANONICAL verb types
   - Skips empty types using verbCountsByType[] tracking (O(1) check)
   - Stops when offset + limit verbs collected
   - No circular dependencies (reads storage directly, not indexes)

2. **Inline Filtering** (memory efficient):
   - Applies sourceId, targetId, verbType filters during iteration
   - No large intermediate arrays

3. **Proper Pagination**:
   - Accurate totalCount, hasMore, nextCursor
   - Slices result for offset/limit

4. **Production-Scale Optimizations**:
   - Skips 100+ empty verb types (most datasets use <10 types)
   - Early termination prevents unnecessary file reads
   - Type-aware storage paths ensure efficient access

ARCHITECTURE VERIFIED - NO CIRCULAR DEPENDENCIES:
Storage → Indexes (one direction only)
- Storage provides raw CRUD operations
- Indexes built FROM storage data
- Fallback reads storage files directly (getVerbsByType_internal)
- No index dependencies in storage layer

TESTED:
 Build passes (zero errors after TypeScript cache clean)
 Fix applies to all 8 storage adapters automatically
 No circular dependencies (storage → indexes only)
 Billion-scale safe (early termination + type skipping)

FILES FIXED:
- src/storage/baseStorage.ts: Universal getVerbs() fallback (85 lines)
- All 8 adapters automatically inherit fix (extend BaseStorage)

Bug reported by: Soulcraft Workshop team
Related: BRAINY_BUG_REPORT_getRelations.md
2025-11-06 10:47:59 -08:00
..
signals feat: Stage 3 CANONICAL taxonomy with 169 types (v5.5.0) 2025-11-06 09:02:23 -08:00
embeddedKeywordEmbeddings.ts fix: resolve getRelations() empty array bug for ALL storage adapters (v5.5.0) 2025-11-06 10:47:59 -08:00
embeddedPatterns.ts refactor: remove deprecated BrainyData class completely 2025-09-30 16:04:00 -07:00
embeddedTypeEmbeddings.ts fix: update all Stage 2 references to Stage 3 CANONICAL type counts 2025-11-06 09:40:33 -08:00
entityExtractionCache.ts feat: add progress tracking, entity caching, and relationship confidence 2025-10-01 15:12:54 -07:00
entityExtractor.ts feat: Stage 3 CANONICAL taxonomy with 169 types (v5.5.0) 2025-11-06 09:02:23 -08:00
improvedNeuralAPI.ts fix: resolve getRelations() empty array bug and add string ID shorthand 2025-10-21 13:10:34 -07:00
naturalLanguageProcessor.ts perf: pre-compute type embeddings at build time (zero runtime cost) 2025-10-09 18:08:57 -07:00
naturalLanguageProcessorStatic.ts feat: add distributed architecture with sharding and coordination 2025-09-22 15:45:35 -07:00
neuralAPI.ts feat: remove legacy ImportManager, standardize getStats() API 2025-10-09 11:40:31 -07:00
patternLibrary.ts feat: implement incremental sorted indices and Triple Intelligence find() 2025-09-12 12:36:11 -07:00
patterns.ts 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00
presets.ts feat: implement progressive flush intervals for streaming imports 2025-10-22 17:36:27 -07:00
relationshipConfidence.ts feat: Stage 3 CANONICAL taxonomy with 169 types (v5.5.0) 2025-11-06 09:02:23 -08:00
SmartExtractor.ts fix: CRITICAL systemic VFS metadata bug across ALL storage adapters (v4.7.4) 2025-10-27 14:23:46 -07:00
SmartRelationshipExtractor.ts feat: implement progressive flush intervals for streaming imports 2025-10-22 17:36:27 -07:00
staticPatternMatcher.ts feat: Brainy 3.0 - Production-ready Triple Intelligence database 2025-09-11 16:23:32 -07:00
types.ts fix: resolve 19 critical test failures for production readiness 2025-10-09 16:58:53 -07:00