@soulcraft/brainy 6.2.4 β†’ 6.2.6

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.
@@ -433,6 +433,8 @@ export class GraphAdjacencyIndex {
433
433
  // Clear current index
434
434
  this.verbIdSet.clear();
435
435
  this.totalRelationshipsIndexed = 0;
436
+ // v6.2.4: CRITICAL FIX - Clear relationship counts to prevent accumulation
437
+ this.relationshipCountsByType.clear();
436
438
  // Note: LSM-trees will be recreated from storage via their own initialization
437
439
  // Verb data will be loaded on-demand via UnifiedCache
438
440
  // Adaptive loading strategy based on storage type (v4.2.4)
@@ -388,6 +388,11 @@ export class AzureBlobStorage extends BaseStorage {
388
388
  // Use write buffer in high-volume mode
389
389
  if (this.highVolumeMode && this.nounWriteBuffer) {
390
390
  this.logger.trace(`πŸ“ BUFFERING: Adding noun ${node.id} to write buffer (high-volume mode active)`);
391
+ // v6.2.6: CRITICAL FIX - Populate cache BEFORE buffering for read-after-write consistency
392
+ // Without this, add() returns but relate() can't find the entity (cloud storage production bug)
393
+ if (node.vector && Array.isArray(node.vector) && node.vector.length > 0) {
394
+ this.nounCacheManager.set(node.id, node);
395
+ }
391
396
  await this.nounWriteBuffer.add(node.id, node);
392
397
  return;
393
398
  }
@@ -779,6 +784,8 @@ export class AzureBlobStorage extends BaseStorage {
779
784
  // Use write buffer in high-volume mode
780
785
  if (this.highVolumeMode && this.verbWriteBuffer) {
781
786
  this.logger.trace(`πŸ“ BUFFERING: Adding verb ${edge.id} to write buffer`);
787
+ // v6.2.6: CRITICAL FIX - Populate cache BEFORE buffering for read-after-write consistency
788
+ this.verbCacheManager.set(edge.id, edge);
782
789
  await this.verbWriteBuffer.add(edge.id, edge);
783
790
  return;
784
791
  }
@@ -313,6 +313,12 @@ export class GcsStorage extends BaseStorage {
313
313
  // Use write buffer in high-volume mode
314
314
  if (this.highVolumeMode && this.nounWriteBuffer) {
315
315
  this.logger.trace(`πŸ“ BUFFERING: Adding noun ${node.id} to write buffer (high-volume mode active)`);
316
+ // v6.2.6: CRITICAL FIX - Populate cache BEFORE buffering for read-after-write consistency
317
+ // Without this, add() returns but relate() can't find the entity (GCS production bug)
318
+ // The buffer flushes asynchronously, but cache ensures immediate reads succeed
319
+ if (node.vector && Array.isArray(node.vector) && node.vector.length > 0) {
320
+ this.nounCacheManager.set(node.id, node);
321
+ }
316
322
  await this.nounWriteBuffer.add(node.id, node);
317
323
  return;
318
324
  }
@@ -648,6 +654,9 @@ export class GcsStorage extends BaseStorage {
648
654
  // Use write buffer in high-volume mode
649
655
  if (this.highVolumeMode && this.verbWriteBuffer) {
650
656
  this.logger.trace(`πŸ“ BUFFERING: Adding verb ${edge.id} to write buffer`);
657
+ // v6.2.6: CRITICAL FIX - Populate cache BEFORE buffering for read-after-write consistency
658
+ // Without this, relate() might not find the verb immediately after creation
659
+ this.verbCacheManager.set(edge.id, edge);
651
660
  await this.verbWriteBuffer.add(edge.id, edge);
652
661
  return;
653
662
  }
@@ -355,6 +355,11 @@ export class R2Storage extends BaseStorage {
355
355
  // Use write buffer in high-volume mode
356
356
  if (this.highVolumeMode && this.nounWriteBuffer) {
357
357
  this.logger.trace(`πŸ“ BUFFERING: Adding noun ${node.id} to write buffer`);
358
+ // v6.2.6: CRITICAL FIX - Populate cache BEFORE buffering for read-after-write consistency
359
+ // Without this, add() returns but relate() can't find the entity (cloud storage production bug)
360
+ if (node.vector && Array.isArray(node.vector) && node.vector.length > 0) {
361
+ this.nounCacheManager.set(node.id, node);
362
+ }
358
363
  await this.nounWriteBuffer.add(node.id, node);
359
364
  return;
360
365
  }
@@ -571,6 +576,8 @@ export class R2Storage extends BaseStorage {
571
576
  await this.ensureInitialized();
572
577
  this.checkVolumeMode();
573
578
  if (this.highVolumeMode && this.verbWriteBuffer) {
579
+ // v6.2.6: CRITICAL FIX - Populate cache BEFORE buffering for read-after-write consistency
580
+ this.verbCacheManager.set(edge.id, edge);
574
581
  await this.verbWriteBuffer.add(edge.id, edge);
575
582
  return;
576
583
  }
@@ -810,6 +810,12 @@ export class S3CompatibleStorage extends BaseStorage {
810
810
  // Use write buffer in high-volume mode
811
811
  if (this.highVolumeMode && this.nounWriteBuffer) {
812
812
  this.logger.trace(`πŸ“ BUFFERING: Adding noun ${node.id} to write buffer (high-volume mode active)`);
813
+ // v6.2.6: CRITICAL FIX - Populate cache BEFORE buffering for read-after-write consistency
814
+ // Without this, add() returns but relate() can't find the entity (cloud storage production bug)
815
+ // The buffer flushes asynchronously, but cache ensures immediate reads succeed
816
+ if (node.vector && Array.isArray(node.vector) && node.vector.length > 0) {
817
+ this.nounCacheManager.set(node.id, node);
818
+ }
813
819
  await this.nounWriteBuffer.add(node.id, node);
814
820
  return;
815
821
  }
@@ -237,6 +237,11 @@ export class MetadataIndexManager {
237
237
  */
238
238
  async lazyLoadCounts() {
239
239
  try {
240
+ // v6.2.4: CRITICAL FIX - Clear counts before loading to prevent accumulation
241
+ // Previously, counts accumulated across restarts causing 100x inflation
242
+ this.totalEntitiesByType.clear();
243
+ this.entityCountsByTypeFixed.fill(0);
244
+ this.verbCountsByTypeFixed.fill(0);
240
245
  // v6.2.2: Load counts from sparse index (correct source)
241
246
  const nounSparseIndex = await this.loadSparseIndex('noun');
242
247
  if (!nounSparseIndex) {
@@ -2100,6 +2105,12 @@ export class MetadataIndexManager {
2100
2105
  // v3.44.1: No sparseIndices Map to clear - UnifiedCache handles eviction
2101
2106
  this.fieldIndexes.clear();
2102
2107
  this.dirtyFields.clear();
2108
+ // v6.2.4: CRITICAL FIX - Clear type counts to prevent accumulation
2109
+ // Previously, counts accumulated across rebuilds causing incorrect values
2110
+ this.totalEntitiesByType.clear();
2111
+ this.entityCountsByTypeFixed.fill(0);
2112
+ this.verbCountsByTypeFixed.fill(0);
2113
+ this.typeFieldAffinity.clear();
2103
2114
  // Clear all cached sparse indices in UnifiedCache
2104
2115
  // This ensures rebuild starts fresh (v3.44.1)
2105
2116
  this.unifiedCache.clear('metadata');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "6.2.4",
3
+ "version": "6.2.6",
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",