• v6.3.0 292be1b9cd

    dpsifr released this 2025-12-04 21:55:35 +01:00 | 499 commits to main since this release

    Critical Architecture Fix: Singleton GraphAdjacencyIndex

    This release fixes the root cause of the VFS tree corruption bug reported by the Soulcraft Workshop team.

    🐛 Bug Fixed

    VFS tree structure returns 0 children after file writes - Previously, calling vfs.mkdir() or vfs.writeFile() could corrupt the VFS index, causing readdir('/') to return incomplete results. Data was NOT lost - it existed in storage but wasn't queryable.

    🔧 Root Cause

    The bug was caused by dual ownership of GraphAdjacencyIndex:

    1. Storage.graphIndex (created in BaseStorage.init())
    2. Brainy.graphIndex (created in Brainy.init())

    When verbs were saved, both instances were updated. But if Storage's graphIndex was recreated (via ensureInitialized()), the new instance had an empty verbIdSet. Queries filtered through this empty verbIdSet returned nothing.

    Fix Summary

    1. GraphAdjacencyIndex Singleton Pattern

      • Brainy now uses storage.getGraphIndex() instead of creating its own
      • Single source of truth - no more dual ownership
      • Added invalidateGraphIndex() for branch switches
    2. Auto-rebuild verbIdSet Defense

      • If LSM-trees have data but verbIdSet is empty, automatically populate it
      • Safety net for edge cases
    3. Removed Double-Add Bug

      • Graph index updates now happen ONLY via transaction system
      • Prevents duplicate counting in relationshipCountsByType
    4. PathResolver Cache Invalidation

      • Added invalidateAllCaches() method
      • checkout() now clears VFS caches before recreating VFS

    📦 Upgrade

    npm install @soulcraft/brainy@6.3.0
    
    • Workshop Bug Report: VFS tree corruption after mkdir/writeFile
    • Previous patches (v6.2.8-v6.2.9) addressed symptoms, this fixes the root cause

    🤖 Generated with Claude Code

    Downloads