@soulcraft/brainy 6.2.3 → 6.2.5

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)
@@ -29,7 +29,6 @@
29
29
  */
30
30
  import { BaseStorage } from '../baseStorage.js';
31
31
  import { CommitLog } from '../cow/CommitLog.js';
32
- import { TreeObject } from '../cow/TreeObject.js';
33
32
  import { BlobStorage } from '../cow/BlobStorage.js';
34
33
  import { HNSWNoun, HNSWVerb, NounMetadata, VerbMetadata, StatisticsData } from '../../coreTypes.js';
35
34
  export interface HistoricalStorageAdapterOptions {
@@ -55,7 +54,6 @@ export declare class HistoricalStorageAdapter extends BaseStorage {
55
54
  private cacheSize;
56
55
  private cache;
57
56
  commitLog?: CommitLog;
58
- treeObject?: TreeObject;
59
57
  blobStorage?: BlobStorage;
60
58
  constructor(options: HistoricalStorageAdapterOptions);
61
59
  /**
@@ -95,10 +95,10 @@ export class HistoricalStorageAdapter extends BaseStorage {
95
95
  */
96
96
  async init() {
97
97
  // Get COW components from underlying storage
98
- this.commitLog = this.underlyingStorage._commitLog;
99
- this.treeObject = this.underlyingStorage._treeObject;
100
- this.blobStorage = this.underlyingStorage._blobStorage;
101
- if (!this.commitLog || !this.treeObject || !this.blobStorage) {
98
+ // v6.2.4: Fixed property names - use public properties without underscore prefix
99
+ this.commitLog = this.underlyingStorage.commitLog;
100
+ this.blobStorage = this.underlyingStorage.blobStorage;
101
+ if (!this.commitLog || !this.blobStorage) {
102
102
  throw new Error('Historical storage requires underlying storage to have COW enabled. ' +
103
103
  'Call brain.init() first to initialize COW.');
104
104
  }
@@ -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.3",
3
+ "version": "6.2.5",
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",