@soulcraft/brainy 3.37.1 → 3.37.3

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,16 @@
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
+ ### [3.37.3](https://github.com/soulcraftlabs/brainy/compare/v3.37.2...v3.37.3) (2025-10-10)
6
+
7
+ - fix: populate totalNodes/totalEdges in ALL storage adapters for HNSW rebuild (a21a845)
8
+
9
+
10
+ ### [3.37.2](https://github.com/soulcraftlabs/brainy/compare/v3.37.1...v3.37.2) (2025-10-10)
11
+
12
+ - fix: ensure GCS storage initialization before pagination (2565685)
13
+
14
+
5
15
  ### [3.37.1](https://github.com/soulcraftlabs/brainy/compare/v3.37.0...v3.37.1) (2025-10-10)
6
16
 
7
17
 
@@ -782,6 +782,7 @@ export class GcsStorage extends BaseStorage {
782
782
  * Iterates through UUID-based shards for consistent pagination
783
783
  */
784
784
  async getNodesWithPagination(options) {
785
+ await this.ensureInitialized(); // CRITICAL: Must initialize before using this.bucket
785
786
  const limit = options.limit || 100;
786
787
  const useCache = options.useCache !== false;
787
788
  try {
@@ -1176,7 +1177,14 @@ export class GcsStorage extends BaseStorage {
1176
1177
  const [contents] = await file.download();
1177
1178
  const statistics = JSON.parse(contents.toString());
1178
1179
  this.logger.trace('Statistics retrieved successfully');
1179
- return statistics;
1180
+ // CRITICAL FIX: Populate totalNodes and totalEdges from in-memory counts
1181
+ // HNSW rebuild depends on these fields to determine entity count
1182
+ return {
1183
+ ...statistics,
1184
+ totalNodes: this.totalNounCount,
1185
+ totalEdges: this.totalVerbCount,
1186
+ lastUpdated: new Date().toISOString()
1187
+ };
1180
1188
  }
1181
1189
  catch (error) {
1182
1190
  if (error.code === 404) {
@@ -559,6 +559,10 @@ export class MemoryStorage extends BaseStorage {
559
559
  verbCount: { ...this.statistics.verbCount },
560
560
  metadataCount: { ...this.statistics.metadataCount },
561
561
  hnswIndexSize: this.statistics.hnswIndexSize,
562
+ // CRITICAL FIX: Populate totalNodes and totalEdges from in-memory counts
563
+ // HNSW rebuild depends on these fields to determine entity count
564
+ totalNodes: this.totalNounCount,
565
+ totalEdges: this.totalVerbCount,
562
566
  lastUpdated: this.statistics.lastUpdated,
563
567
  // Include serviceActivity if present
564
568
  ...(this.statistics.serviceActivity && {
@@ -1125,6 +1125,10 @@ export class OPFSStorage extends BaseStorage {
1125
1125
  verbCount: { ...this.statistics.verbCount },
1126
1126
  metadataCount: { ...this.statistics.metadataCount },
1127
1127
  hnswIndexSize: this.statistics.hnswIndexSize,
1128
+ // CRITICAL FIX: Populate totalNodes and totalEdges from in-memory counts
1129
+ // HNSW rebuild depends on these fields to determine entity count
1130
+ totalNodes: this.totalNounCount,
1131
+ totalEdges: this.totalVerbCount,
1128
1132
  lastUpdated: this.statistics.lastUpdated
1129
1133
  };
1130
1134
  }
@@ -1149,6 +1153,10 @@ export class OPFSStorage extends BaseStorage {
1149
1153
  verbCount: { ...this.statistics.verbCount },
1150
1154
  metadataCount: { ...this.statistics.metadataCount },
1151
1155
  hnswIndexSize: this.statistics.hnswIndexSize,
1156
+ // CRITICAL FIX: Populate totalNodes and totalEdges from in-memory counts
1157
+ // HNSW rebuild depends on these fields to determine entity count
1158
+ totalNodes: this.totalNounCount,
1159
+ totalEdges: this.totalVerbCount,
1152
1160
  lastUpdated: this.statistics.lastUpdated
1153
1161
  };
1154
1162
  }
@@ -1171,6 +1179,10 @@ export class OPFSStorage extends BaseStorage {
1171
1179
  verbCount: { ...this.statistics.verbCount },
1172
1180
  metadataCount: { ...this.statistics.metadataCount },
1173
1181
  hnswIndexSize: this.statistics.hnswIndexSize,
1182
+ // CRITICAL FIX: Populate totalNodes and totalEdges from in-memory counts
1183
+ // HNSW rebuild depends on these fields to determine entity count
1184
+ totalNodes: this.totalNounCount,
1185
+ totalEdges: this.totalVerbCount,
1174
1186
  lastUpdated: this.statistics.lastUpdated
1175
1187
  };
1176
1188
  }
@@ -1191,6 +1203,10 @@ export class OPFSStorage extends BaseStorage {
1191
1203
  verbCount: { ...this.statistics.verbCount },
1192
1204
  metadataCount: { ...this.statistics.metadataCount },
1193
1205
  hnswIndexSize: this.statistics.hnswIndexSize,
1206
+ // CRITICAL FIX: Populate totalNodes and totalEdges from in-memory counts
1207
+ // HNSW rebuild depends on these fields to determine entity count
1208
+ totalNodes: this.totalNounCount,
1209
+ totalEdges: this.totalVerbCount,
1194
1210
  lastUpdated: this.statistics.lastUpdated
1195
1211
  };
1196
1212
  }
@@ -2144,6 +2144,10 @@ export class S3CompatibleStorage extends BaseStorage {
2144
2144
  verbCount: { ...this.statisticsCache.verbCount },
2145
2145
  metadataCount: { ...this.statisticsCache.metadataCount },
2146
2146
  hnswIndexSize: this.statisticsCache.hnswIndexSize,
2147
+ // CRITICAL FIX: Populate totalNodes and totalEdges from in-memory counts
2148
+ // HNSW rebuild depends on these fields to determine entity count
2149
+ totalNodes: this.totalNounCount,
2150
+ totalEdges: this.totalVerbCount,
2147
2151
  lastUpdated: this.statisticsCache.lastUpdated
2148
2152
  };
2149
2153
  }
@@ -2186,6 +2190,13 @@ export class S3CompatibleStorage extends BaseStorage {
2186
2190
  hnswIndexSize: statistics.hnswIndexSize,
2187
2191
  lastUpdated: statistics.lastUpdated
2188
2192
  };
2193
+ // CRITICAL FIX: Add totalNodes and totalEdges from in-memory counts
2194
+ // HNSW rebuild depends on these fields to determine entity count
2195
+ return {
2196
+ ...statistics,
2197
+ totalNodes: this.totalNounCount,
2198
+ totalEdges: this.totalVerbCount
2199
+ };
2189
2200
  }
2190
2201
  // Successfully loaded statistics from storage
2191
2202
  return statistics;
@@ -2193,7 +2204,15 @@ export class S3CompatibleStorage extends BaseStorage {
2193
2204
  catch (error) {
2194
2205
  this.logger.warn('Error getting statistics data, returning cached or null:', error);
2195
2206
  // Return cached data if available, even if stale, rather than throwing
2196
- return this.statisticsCache || null;
2207
+ // CRITICAL FIX: Add totalNodes and totalEdges when returning cached data
2208
+ if (this.statisticsCache) {
2209
+ return {
2210
+ ...this.statisticsCache,
2211
+ totalNodes: this.totalNounCount,
2212
+ totalEdges: this.totalVerbCount
2213
+ };
2214
+ }
2215
+ return null;
2197
2216
  }
2198
2217
  }
2199
2218
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "3.37.1",
3
+ "version": "3.37.3",
4
4
  "description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. 31 nouns × 40 verbs for infinite expressiveness.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",