@soulcraft/brainy 6.0.0 β†’ 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [6.0.1](https://github.com/soulcraftlabs/brainy/compare/v6.0.0...v6.0.1) (2025-11-20)
6
+
7
+ ### πŸ› Critical Bug Fixes
8
+
9
+ **Fixed infinite loop during storage initialization on fresh workspaces (v6.0.1)**
10
+
11
+ **Symptom:** FileSystemStorage (and all storage adapters) entered infinite loop on fresh installation, printing "πŸ“ New installation: using depth 1 sharding..." message hundreds of thousands of times.
12
+
13
+ **Root Cause:** In v6.0.0, `BaseStorage.init()` sets `isInitialized = true` at the END of initialization (after creating GraphAdjacencyIndex). If any code path during initialization called `ensureInitialized()`, it would trigger `init()` recursively because the flag was still `false`.
14
+
15
+ **Fix:** Set `isInitialized = true` at the START of `BaseStorage.init()` (before any initialization work) to prevent recursive calls. Flag is reset to `false` on error to allow retries.
16
+
17
+ **Impact:**
18
+ - βœ… Fixes production blocker reported by Workshop team
19
+ - βœ… All 8 storage adapters fixed (FileSystem, Memory, S3, R2, GCS, Azure, OPFS, Historical)
20
+ - βœ… Init completes in ~1 second on fresh installation (was hanging indefinitely)
21
+ - βœ… No new test failures introduced (1178 tests passing)
22
+
23
+ **Files Changed:**
24
+ - `src/storage/baseStorage.ts:261-287` - Moved `isInitialized = true` to top of init() with try/catch
25
+
26
+ **Migration:** No code changes required - drop-in replacement for v6.0.0.
27
+
28
+ ---
29
+
5
30
  ## [6.0.0](https://github.com/soulcraftlabs/brainy/compare/v5.12.0...v6.0.0) (2025-11-19)
6
31
 
7
32
  ## πŸš€ v6.0.0 - ID-First Storage Architecture
@@ -178,21 +178,31 @@ export class BaseStorage extends BaseStorageAdapter {
178
178
  * IMPORTANT: If your adapter overrides init(), call await super.init() first!
179
179
  */
180
180
  async init() {
181
- // Load type statistics from storage (if they exist)
182
- await this.loadTypeStatistics();
183
- // v6.0.0: Create GraphAdjacencyIndex (lazy-loaded, no rebuild)
184
- // LSM-trees are initialized on first use via ensureInitialized()
185
- // Index is populated incrementally as verbs are added via addVerb()
181
+ // v6.0.1: CRITICAL FIX - Set flag FIRST to prevent infinite recursion
182
+ // If any code path during initialization calls ensureInitialized(), it would
183
+ // trigger init() again. Setting the flag immediately breaks the recursion cycle.
184
+ this.isInitialized = true;
186
185
  try {
187
- prodLog.debug('[BaseStorage] Creating GraphAdjacencyIndex...');
188
- this.graphIndex = new GraphAdjacencyIndex(this);
189
- prodLog.debug(`[BaseStorage] GraphAdjacencyIndex instantiated (lazy-loaded), graphIndex=${!!this.graphIndex}`);
186
+ // Load type statistics from storage (if they exist)
187
+ await this.loadTypeStatistics();
188
+ // v6.0.0: Create GraphAdjacencyIndex (lazy-loaded, no rebuild)
189
+ // LSM-trees are initialized on first use via ensureInitialized()
190
+ // Index is populated incrementally as verbs are added via addVerb()
191
+ try {
192
+ prodLog.debug('[BaseStorage] Creating GraphAdjacencyIndex...');
193
+ this.graphIndex = new GraphAdjacencyIndex(this);
194
+ prodLog.debug(`[BaseStorage] GraphAdjacencyIndex instantiated (lazy-loaded), graphIndex=${!!this.graphIndex}`);
195
+ }
196
+ catch (error) {
197
+ prodLog.error('[BaseStorage] Failed to create GraphAdjacencyIndex:', error);
198
+ throw error;
199
+ }
190
200
  }
191
201
  catch (error) {
192
- prodLog.error('[BaseStorage] Failed to create GraphAdjacencyIndex:', error);
202
+ // Reset flag on failure to allow retry
203
+ this.isInitialized = false;
193
204
  throw error;
194
205
  }
195
- this.isInitialized = true;
196
206
  }
197
207
  /**
198
208
  * Rebuild GraphAdjacencyIndex from existing verbs (v6.0.0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "6.0.0",
3
+ "version": "6.0.1",
4
4
  "description": "Universal Knowledge Protocolβ„’ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. Stage 3 CANONICAL: 42 nouns Γ— 127 verbs covering 96-97% of all human knowledge.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",