@soulcraft/brainy 6.3.0 → 6.3.2

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/brainy.d.ts +55 -0
  3. package/dist/brainy.js +86 -0
  4. package/dist/versioning/VersionIndex.d.ts +42 -47
  5. package/dist/versioning/VersionIndex.js +141 -166
  6. package/dist/versioning/VersionManager.d.ts +26 -6
  7. package/dist/versioning/VersionManager.js +101 -8
  8. package/dist/versioning/VersionStorage.d.ts +25 -15
  9. package/dist/versioning/VersionStorage.js +49 -65
  10. package/package.json +1 -1
  11. package/dist/augmentations/KnowledgeAugmentation.d.ts +0 -40
  12. package/dist/augmentations/KnowledgeAugmentation.js +0 -251
  13. package/dist/importManager.d.ts +0 -78
  14. package/dist/importManager.js +0 -267
  15. package/dist/query/typeInference.d.ts +0 -158
  16. package/dist/query/typeInference.js +0 -760
  17. package/dist/storage/adapters/typeAwareStorageAdapter.d.ts +0 -252
  18. package/dist/storage/adapters/typeAwareStorageAdapter.js +0 -814
  19. package/dist/types/brainyDataInterface.d.ts +0 -52
  20. package/dist/types/brainyDataInterface.js +0 -10
  21. package/dist/vfs/ConceptSystem.d.ts +0 -203
  22. package/dist/vfs/ConceptSystem.js +0 -545
  23. package/dist/vfs/EntityManager.d.ts +0 -75
  24. package/dist/vfs/EntityManager.js +0 -216
  25. package/dist/vfs/EventRecorder.d.ts +0 -84
  26. package/dist/vfs/EventRecorder.js +0 -269
  27. package/dist/vfs/GitBridge.d.ts +0 -167
  28. package/dist/vfs/GitBridge.js +0 -537
  29. package/dist/vfs/KnowledgeLayer.d.ts +0 -35
  30. package/dist/vfs/KnowledgeLayer.js +0 -443
  31. package/dist/vfs/PersistentEntitySystem.d.ts +0 -165
  32. package/dist/vfs/PersistentEntitySystem.js +0 -503
  33. package/dist/vfs/SemanticVersioning.d.ts +0 -105
  34. package/dist/vfs/SemanticVersioning.js +0 -309
package/CHANGELOG.md CHANGED
@@ -2,6 +2,34 @@
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.3.2](https://github.com/soulcraftlabs/brainy/compare/v6.3.1...v6.3.2) (2025-12-09)
6
+
7
+
8
+ ### 🐛 Bug Fixes
9
+
10
+ * **versioning:** VFS file versions now capture actual blob content ([3e0f235](https://github.com/soulcraftlabs/brainy/commit/3e0f235f8b2cfcc6f0792a457879a02e4b93897a))
11
+
12
+ ### [6.3.1](https://github.com/soulcraftlabs/brainy/compare/v6.3.0...v6.3.1) (2025-12-09)
13
+
14
+ - fix(versioning): clean architecture with index pollution prevention (f145fa1)
15
+ - chore(release): 6.3.0 - singleton GraphAdjacencyIndex architecture fix (292be1b)
16
+ - fix(architecture): singleton GraphAdjacencyIndex via storage.getGraphIndex() (v6.3.0) (c15892e)
17
+ - chore(release): 6.2.9 - fix critical VFS bugs (directory corruption) (810b756)
18
+ - fix(vfs): resolve two critical VFS bugs causing directory listing corruption (2ba69ec)
19
+ - chore(release): 6.2.8 - deferred HNSW persistence for 30-50× faster cloud adds (1da6048)
20
+ - perf(hnsw): deferred persistence mode for 30-50× faster cloud storage adds (4d1d567)
21
+ - chore(release): 6.2.7 - simplify cloud storage to always-on write buffering (a33b759)
22
+ - perf(storage): simplify cloud adapters to always-on write buffering (26510ce)
23
+ - chore(release): 6.2.6 - fix cloud storage read-after-write consistency (6449bb1)
24
+ - fix(storage): populate cache before write buffer for read-after-write consistency (2d27bd0)
25
+ - chore(release): 6.2.5 - fix counts.byType() accumulation bug (e4bbd7f)
26
+ - fix(counts): counts.byType() returns inflated values due to accumulation bug (9456c2c)
27
+ - chore(release): 6.2.4 - fix asOf() COW property name mismatch (ea53c11)
28
+ - fix(cow): asOf() fails with "COW not enabled" due to property name mismatch (b3ae18b)
29
+ - chore(release): 6.2.3 - fix counts.byType({ excludeVFS: true }) returning empty (0ba6da4)
30
+ - fix(counts): counts.byType({ excludeVFS: true }) now returns correct type counts (9b2ff2d)
31
+
32
+
5
33
  ### [6.2.2](https://github.com/soulcraftlabs/brainy/compare/v6.2.1...v6.2.2) (2025-11-25)
6
34
 
7
35
  - refactor: remove 3,700+ LOC of unused HNSW implementations (e3146ce)
package/dist/brainy.d.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  * Beautiful, Professional, Planet-Scale, Fun to Use
5
5
  * NO STUBS, NO MOCKS, REAL IMPLEMENTATION
6
6
  */
7
+ import { BaseStorage } from './storage/baseStorage.js';
7
8
  import { Vector } from './coreTypes.js';
8
9
  import { ImprovedNeuralAPI } from './neural/improvedNeuralAPI.js';
9
10
  import { NaturalLanguageProcessor } from './neural/naturalLanguageProcessor.js';
@@ -1629,6 +1630,60 @@ export declare class Brainy<T = any> implements BrainyInterface<T> {
1629
1630
  };
1630
1631
  density: number;
1631
1632
  }>;
1633
+ /**
1634
+ * Search entities by metadata filters (internal API)
1635
+ * Used by versioning system for querying version metadata
1636
+ *
1637
+ * @param filters - Metadata filter object (same format as `where` in find())
1638
+ * @returns Array of matching entities
1639
+ * @internal
1640
+ */
1641
+ searchByMetadata(filters: Record<string, any>): Promise<any[]>;
1642
+ /**
1643
+ * Get raw noun metadata (internal API)
1644
+ * Used by versioning system for reading entity state
1645
+ *
1646
+ * @param id - Entity ID
1647
+ * @returns Noun metadata or null if not found
1648
+ * @internal
1649
+ */
1650
+ getNounMetadata(id: string): Promise<any | null>;
1651
+ /**
1652
+ * Save raw noun metadata (internal API)
1653
+ * Used by versioning system for storing version index entries
1654
+ *
1655
+ * @param id - Entity ID
1656
+ * @param data - Metadata to save
1657
+ * @internal
1658
+ */
1659
+ saveNounMetadata(id: string, data: any): Promise<void>;
1660
+ /**
1661
+ * Delete noun metadata (internal API)
1662
+ * Used by versioning system for removing version index entries
1663
+ *
1664
+ * @param id - Entity ID
1665
+ * @internal
1666
+ */
1667
+ deleteNounMetadata(id: string): Promise<void>;
1668
+ /**
1669
+ * Current branch name (internal API)
1670
+ * Used by versioning system for branch-aware operations
1671
+ * @internal
1672
+ */
1673
+ get currentBranch(): string;
1674
+ /**
1675
+ * Reference manager for COW commits (internal API)
1676
+ * Used by versioning system for commit operations
1677
+ * @internal
1678
+ */
1679
+ get refManager(): any;
1680
+ /**
1681
+ * Storage adapter (internal API)
1682
+ * Used by versioning system for direct storage access
1683
+ * Returns BaseStorage which has saveMetadata/getMetadata for key-value storage
1684
+ * @internal
1685
+ */
1686
+ get storageAdapter(): BaseStorage;
1632
1687
  /**
1633
1688
  * Parse natural language query using advanced NLP with 220+ patterns
1634
1689
  * The embedding model is always available as it's core to Brainy's functionality
package/dist/brainy.js CHANGED
@@ -3554,6 +3554,92 @@ export class Brainy {
3554
3554
  async getStats(options) {
3555
3555
  return this.counts.getStats(options);
3556
3556
  }
3557
+ // ============= INTERNAL VERSIONING API =============
3558
+ // These methods are used by the versioning system (brain.versions.*)
3559
+ // They expose internal storage and index operations needed for entity versioning
3560
+ /**
3561
+ * Search entities by metadata filters (internal API)
3562
+ * Used by versioning system for querying version metadata
3563
+ *
3564
+ * @param filters - Metadata filter object (same format as `where` in find())
3565
+ * @returns Array of matching entities
3566
+ * @internal
3567
+ */
3568
+ async searchByMetadata(filters) {
3569
+ await this.ensureInitialized();
3570
+ const ids = await this.metadataIndex.getIdsForFilter(filters);
3571
+ if (ids.length === 0)
3572
+ return [];
3573
+ const results = [];
3574
+ const entitiesMap = await this.batchGet(ids);
3575
+ for (const id of ids) {
3576
+ const entity = entitiesMap.get(id);
3577
+ if (entity) {
3578
+ results.push(entity);
3579
+ }
3580
+ }
3581
+ return results;
3582
+ }
3583
+ /**
3584
+ * Get raw noun metadata (internal API)
3585
+ * Used by versioning system for reading entity state
3586
+ *
3587
+ * @param id - Entity ID
3588
+ * @returns Noun metadata or null if not found
3589
+ * @internal
3590
+ */
3591
+ async getNounMetadata(id) {
3592
+ await this.ensureInitialized();
3593
+ return this.storage.getNounMetadata(id);
3594
+ }
3595
+ /**
3596
+ * Save raw noun metadata (internal API)
3597
+ * Used by versioning system for storing version index entries
3598
+ *
3599
+ * @param id - Entity ID
3600
+ * @param data - Metadata to save
3601
+ * @internal
3602
+ */
3603
+ async saveNounMetadata(id, data) {
3604
+ await this.ensureInitialized();
3605
+ await this.storage.saveNounMetadata(id, data);
3606
+ }
3607
+ /**
3608
+ * Delete noun metadata (internal API)
3609
+ * Used by versioning system for removing version index entries
3610
+ *
3611
+ * @param id - Entity ID
3612
+ * @internal
3613
+ */
3614
+ async deleteNounMetadata(id) {
3615
+ await this.ensureInitialized();
3616
+ await this.storage.deleteNounMetadata(id);
3617
+ }
3618
+ /**
3619
+ * Current branch name (internal API)
3620
+ * Used by versioning system for branch-aware operations
3621
+ * @internal
3622
+ */
3623
+ get currentBranch() {
3624
+ return this.storage.currentBranch || 'main';
3625
+ }
3626
+ /**
3627
+ * Reference manager for COW commits (internal API)
3628
+ * Used by versioning system for commit operations
3629
+ * @internal
3630
+ */
3631
+ get refManager() {
3632
+ return this.storage.refManager;
3633
+ }
3634
+ /**
3635
+ * Storage adapter (internal API)
3636
+ * Used by versioning system for direct storage access
3637
+ * Returns BaseStorage which has saveMetadata/getMetadata for key-value storage
3638
+ * @internal
3639
+ */
3640
+ get storageAdapter() {
3641
+ return this.storage;
3642
+ }
3557
3643
  // ============= HELPER METHODS =============
3558
3644
  /**
3559
3645
  * Parse natural language query using advanced NLP with 220+ patterns
@@ -1,33 +1,24 @@
1
1
  /**
2
- * VersionIndex - Fast Version Lookup Using Existing Index Infrastructure (v5.3.0)
2
+ * VersionIndex - Pure Key-Value Version Storage (v6.3.0)
3
3
  *
4
- * Integrates with Brainy's existing index system:
5
- * - Uses MetadataIndexManager for field indexing
6
- * - Leverages UnifiedCache for memory management
7
- * - Uses EntityIdMapper for efficient ID handling
8
- * - Uses ChunkManager for adaptive chunking
9
- * - Leverages Roaring Bitmaps for fast set operations
4
+ * Stores version metadata using simple key-value storage:
5
+ * - Version list per entity: __version_meta_{entityId}_{branch}
6
+ * - Content stored separately by VersionStorage
10
7
  *
11
- * Version metadata is stored as regular entities with type='_version'
12
- * This allows us to use existing index infrastructure without modification!
13
- *
14
- * Fields indexed:
15
- * - versionEntityId: Entity being versioned
16
- * - versionBranch: Branch version was created on
17
- * - versionNumber: Version number
18
- * - versionTag: Optional user tag
19
- * - versionTimestamp: Creation timestamp
20
- * - versionCommitHash: Commit hash
8
+ * Key Design Decisions:
9
+ * - Versions are NOT entities (no brain.add())
10
+ * - Versions do NOT pollute find() results
11
+ * - Simple O(1) lookups per entity
12
+ * - Versions per entity is typically small (10-1000)
21
13
  *
22
14
  * NO MOCKS - Production implementation
23
15
  */
24
- import type { EntityVersion } from './VersionManager.js';
25
- import type { VersionQuery } from './VersionManager.js';
16
+ import type { EntityVersion, VersionQuery } from './VersionManager.js';
26
17
  /**
27
- * VersionIndex - Version lookup and querying using existing indexes
18
+ * VersionIndex - Pure key-value version metadata storage
28
19
  *
29
- * Strategy: Store version metadata as special entities with type='_version'
30
- * This leverages ALL existing index infrastructure automatically!
20
+ * Uses simple JSON storage instead of creating entities.
21
+ * This ensures versions never appear in find() results.
31
22
  */
32
23
  export declare class VersionIndex {
33
24
  private brain;
@@ -35,25 +26,21 @@ export declare class VersionIndex {
35
26
  constructor(brain: any);
36
27
  /**
37
28
  * Initialize version index
38
- *
39
- * No special setup needed - we use existing entity storage and indexes!
40
29
  */
41
30
  initialize(): Promise<void>;
42
31
  /**
43
32
  * Add version to index
44
33
  *
45
- * Stores version metadata as a special entity with type='_version'
46
- * This automatically indexes it using existing MetadataIndexManager!
34
+ * Stores version entry in key-value storage.
35
+ * Handles deduplication by content hash.
47
36
  *
48
- * @param version Version metadata
37
+ * @param version Version metadata to store
49
38
  */
50
39
  addVersion(version: EntityVersion): Promise<void>;
51
40
  /**
52
41
  * Get versions for an entity
53
42
  *
54
- * Uses existing MetadataIndexManager to query efficiently!
55
- *
56
- * @param query Version query
43
+ * @param query Version query with filters
57
44
  * @returns List of versions (newest first)
58
45
  */
59
46
  getVersions(query: VersionQuery): Promise<EntityVersion[]>;
@@ -92,35 +79,43 @@ export declare class VersionIndex {
92
79
  */
93
80
  removeVersion(entityId: string, version: number, branch: string): Promise<void>;
94
81
  /**
95
- * Convert entity to EntityVersion format
96
- *
97
- * @param entity Entity from storage
98
- * @returns EntityVersion or null if invalid
99
- */
100
- private entityToVersion;
101
- /**
102
- * Generate unique ID for version entity
103
- *
104
- * Format: _version:{entityId}:{version}:{branch}
82
+ * Clear all versions for an entity
105
83
  *
106
84
  * @param entityId Entity ID
107
- * @param version Version number
108
85
  * @param branch Branch name
109
- * @returns Version entity ID
86
+ * @returns Number of versions deleted
110
87
  */
111
- private getVersionEntityId;
88
+ clearVersions(entityId: string, branch: string): Promise<number>;
112
89
  /**
113
90
  * Get all versioned entities (for cleanup/debugging)
114
91
  *
115
- * @returns List of entity IDs that have versions
92
+ * Note: This is an expensive operation that requires scanning.
93
+ * In the simple key-value approach, we don't maintain a global index.
94
+ * This method returns an empty array - use storage-level scanning if needed.
95
+ *
96
+ * @returns Empty array (not supported in simple approach)
116
97
  */
117
98
  getVersionedEntities(): Promise<string[]>;
118
99
  /**
119
- * Clear all versions for an entity
100
+ * Generate storage key for version metadata
120
101
  *
121
102
  * @param entityId Entity ID
122
103
  * @param branch Branch name
123
- * @returns Number of versions deleted
104
+ * @returns Storage key
124
105
  */
125
- clearVersions(entityId: string, branch: string): Promise<number>;
106
+ private getMetaKey;
107
+ /**
108
+ * Load version store from storage
109
+ *
110
+ * @param key Storage key
111
+ * @returns Version store or null
112
+ */
113
+ private loadStore;
114
+ /**
115
+ * Save version store to storage
116
+ *
117
+ * @param key Storage key
118
+ * @param store Version store
119
+ */
120
+ private saveStore;
126
121
  }