@soulcraft/brainy 5.6.0 โ 5.6.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 +32 -0
- package/dist/storage/adapters/azureBlobStorage.js +9 -0
- package/dist/storage/adapters/fileSystemStorage.js +17 -0
- package/dist/storage/adapters/gcsStorage.js +11 -0
- package/dist/storage/adapters/opfsStorage.js +22 -0
- package/dist/storage/adapters/r2Storage.js +11 -2
- package/dist/storage/adapters/s3CompatibleStorage.js +13 -0
- package/dist/storage/baseStorage.js +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
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
|
+
## [5.6.1](https://github.com/soulcraftlabs/brainy/compare/v5.6.0...v5.6.1) (2025-11-11)
|
|
6
|
+
|
|
7
|
+
### ๐ Bug Fixes
|
|
8
|
+
|
|
9
|
+
* **storage**: Fix `clear()` not deleting COW version control data ([#workshop-bug-report](https://github.com/soulcraftlabs/brainy/issues))
|
|
10
|
+
- Fixed all storage adapters to properly delete `_cow/` directory on clear()
|
|
11
|
+
- Fixed in-memory entity counters not being reset after clear()
|
|
12
|
+
- Prevents COW reinitialization after clear() by setting `cowEnabled = false`
|
|
13
|
+
- **Impact**: Resolves storage persistence bug (103MB โ 0 bytes after clear)
|
|
14
|
+
- **Affected adapters**: FileSystemStorage, OPFSStorage, S3CompatibleStorage (GCSStorage, R2Storage, AzureBlobStorage already correct)
|
|
15
|
+
|
|
16
|
+
### ๐ Technical Details
|
|
17
|
+
|
|
18
|
+
* **Root causes identified**:
|
|
19
|
+
1. `_cow/` directory contents deleted but directory not removed
|
|
20
|
+
2. In-memory counters (`totalNounCount`, `totalVerbCount`) not reset
|
|
21
|
+
3. COW could auto-reinitialize on next operation
|
|
22
|
+
* **Fixes applied**:
|
|
23
|
+
- FileSystemStorage: Use `fs.rm()` to delete entire `_cow/` directory
|
|
24
|
+
- OPFSStorage: Use `removeEntry('_cow', {recursive: true})`
|
|
25
|
+
- Cloud adapters: Already use `deleteObjectsWithPrefix('_cow/')`
|
|
26
|
+
- All adapters: Reset `totalNounCount = 0` and `totalVerbCount = 0`
|
|
27
|
+
- BaseStorage: Added guard in `initializeCOW()` to prevent reinitialization when `cowEnabled === false`
|
|
28
|
+
|
|
29
|
+
## [5.6.0](https://github.com/soulcraftlabs/brainy/compare/v5.5.0...v5.6.0) (2025-11-11)
|
|
30
|
+
|
|
31
|
+
### ๐ Bug Fixes
|
|
32
|
+
|
|
33
|
+
* **relations**: Fix `getRelations()` returning empty array for fresh instances
|
|
34
|
+
- Resolved initialization race condition in relationship loading
|
|
35
|
+
- Fresh Brain instances now correctly load persisted relationships
|
|
36
|
+
|
|
5
37
|
## [5.5.0](https://github.com/soulcraftlabs/brainy/compare/v5.4.0...v5.5.0) (2025-11-06)
|
|
6
38
|
|
|
7
39
|
### ๐ฏ Stage 3 CANONICAL Taxonomy - Complete Coverage
|
|
@@ -851,12 +851,21 @@ export class AzureBlobStorage extends BaseStorage {
|
|
|
851
851
|
try {
|
|
852
852
|
this.logger.info('๐งน Clearing all data from Azure container...');
|
|
853
853
|
// Delete all blobs in container
|
|
854
|
+
// v5.6.1: listBlobsFlat() returns ALL blobs including _cow/ prefix
|
|
855
|
+
// This correctly deletes COW version control data (commits, trees, blobs, refs)
|
|
854
856
|
for await (const blob of this.containerClient.listBlobsFlat()) {
|
|
855
857
|
if (blob.name) {
|
|
856
858
|
const blockBlobClient = this.containerClient.getBlockBlobClient(blob.name);
|
|
857
859
|
await blockBlobClient.delete();
|
|
858
860
|
}
|
|
859
861
|
}
|
|
862
|
+
// CRITICAL: Reset COW state to prevent automatic reinitialization
|
|
863
|
+
// When COW data is cleared, we must also clear the COW managers
|
|
864
|
+
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
865
|
+
this.refManager = undefined;
|
|
866
|
+
this.blobStorage = undefined;
|
|
867
|
+
this.commitLog = undefined;
|
|
868
|
+
this.cowEnabled = false;
|
|
860
869
|
// Clear caches
|
|
861
870
|
this.nounCacheManager.clear();
|
|
862
871
|
this.verbCacheManager.clear();
|
|
@@ -874,9 +874,26 @@ export class FileSystemStorage extends BaseStorage {
|
|
|
874
874
|
if (await this.directoryExists(this.indexDir)) {
|
|
875
875
|
await removeDirectoryContents(this.indexDir);
|
|
876
876
|
}
|
|
877
|
+
// v5.6.1: Remove COW (copy-on-write) version control data
|
|
878
|
+
// This directory stores all git-like versioning data (commits, trees, blobs, refs)
|
|
879
|
+
// Must be deleted to fully clear all data including version history
|
|
880
|
+
const cowDir = path.join(this.rootDir, '_cow');
|
|
881
|
+
if (await this.directoryExists(cowDir)) {
|
|
882
|
+
// Delete the entire _cow/ directory (not just contents)
|
|
883
|
+
await fs.promises.rm(cowDir, { recursive: true, force: true });
|
|
884
|
+
// CRITICAL: Reset COW state to prevent automatic reinitialization
|
|
885
|
+
// When COW data is cleared, we must also clear the COW managers
|
|
886
|
+
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
887
|
+
this.refManager = undefined;
|
|
888
|
+
this.blobStorage = undefined;
|
|
889
|
+
this.commitLog = undefined;
|
|
890
|
+
this.cowEnabled = false;
|
|
891
|
+
}
|
|
877
892
|
// Clear the statistics cache
|
|
878
893
|
this.statisticsCache = null;
|
|
879
894
|
this.statisticsModified = false;
|
|
895
|
+
this.totalNounCount = 0;
|
|
896
|
+
this.totalVerbCount = 0;
|
|
880
897
|
}
|
|
881
898
|
/**
|
|
882
899
|
* Enhanced clear operation with safety mechanisms and performance optimizations
|
|
@@ -778,6 +778,17 @@ export class GcsStorage extends BaseStorage {
|
|
|
778
778
|
await deleteObjectsWithPrefix(this.metadataPrefix);
|
|
779
779
|
await deleteObjectsWithPrefix(this.verbMetadataPrefix);
|
|
780
780
|
await deleteObjectsWithPrefix(this.systemPrefix);
|
|
781
|
+
// v5.6.1: Clear COW (copy-on-write) version control data
|
|
782
|
+
// This includes all git-like versioning data (commits, trees, blobs, refs)
|
|
783
|
+
// Must be deleted to fully clear all data including version history
|
|
784
|
+
await deleteObjectsWithPrefix('_cow/');
|
|
785
|
+
// CRITICAL: Reset COW state to prevent automatic reinitialization
|
|
786
|
+
// When COW data is cleared, we must also clear the COW managers
|
|
787
|
+
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
788
|
+
this.refManager = undefined;
|
|
789
|
+
this.blobStorage = undefined;
|
|
790
|
+
this.commitLog = undefined;
|
|
791
|
+
this.cowEnabled = false;
|
|
781
792
|
// Clear caches
|
|
782
793
|
this.nounCacheManager.clear();
|
|
783
794
|
this.verbCacheManager.clear();
|
|
@@ -387,9 +387,31 @@ export class OPFSStorage extends BaseStorage {
|
|
|
387
387
|
await removeDirectoryContents(this.verbMetadataDir);
|
|
388
388
|
// Remove all files in the index directory
|
|
389
389
|
await removeDirectoryContents(this.indexDir);
|
|
390
|
+
// v5.6.1: Remove COW (copy-on-write) version control data
|
|
391
|
+
// This directory stores all git-like versioning data (commits, trees, blobs, refs)
|
|
392
|
+
// Must be deleted to fully clear all data including version history
|
|
393
|
+
try {
|
|
394
|
+
// Delete the entire _cow/ directory (not just contents)
|
|
395
|
+
await this.rootDir.removeEntry('_cow', { recursive: true });
|
|
396
|
+
// CRITICAL: Reset COW state to prevent automatic reinitialization
|
|
397
|
+
// When COW data is cleared, we must also clear the COW managers
|
|
398
|
+
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
399
|
+
this.refManager = undefined;
|
|
400
|
+
this.blobStorage = undefined;
|
|
401
|
+
this.commitLog = undefined;
|
|
402
|
+
this.cowEnabled = false;
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
// Ignore if _cow directory doesn't exist (not all instances use COW)
|
|
406
|
+
if (error.name !== 'NotFoundError') {
|
|
407
|
+
throw error;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
390
410
|
// Clear the statistics cache
|
|
391
411
|
this.statisticsCache = null;
|
|
392
412
|
this.statisticsModified = false;
|
|
413
|
+
this.totalNounCount = 0;
|
|
414
|
+
this.totalVerbCount = 0;
|
|
393
415
|
}
|
|
394
416
|
catch (error) {
|
|
395
417
|
console.error('Error clearing storage:', error);
|
|
@@ -771,13 +771,22 @@ export class R2Storage extends BaseStorage {
|
|
|
771
771
|
async clear() {
|
|
772
772
|
await this.ensureInitialized();
|
|
773
773
|
prodLog.info('๐งน R2: Clearing all data from bucket...');
|
|
774
|
-
// Clear all prefixes
|
|
775
|
-
|
|
774
|
+
// Clear all prefixes (v5.6.1: includes _cow/ for version control data)
|
|
775
|
+
// _cow/ stores all git-like versioning data (commits, trees, blobs, refs)
|
|
776
|
+
// Must be deleted to fully clear all data including version history
|
|
777
|
+
for (const prefix of [this.nounPrefix, this.verbPrefix, this.metadataPrefix, this.verbMetadataPrefix, this.systemPrefix, '_cow/']) {
|
|
776
778
|
const objects = await this.listObjectsUnderPath(prefix);
|
|
777
779
|
for (const key of objects) {
|
|
778
780
|
await this.deleteObjectFromPath(key);
|
|
779
781
|
}
|
|
780
782
|
}
|
|
783
|
+
// CRITICAL: Reset COW state to prevent automatic reinitialization
|
|
784
|
+
// When COW data is cleared, we must also clear the COW managers
|
|
785
|
+
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
786
|
+
this.refManager = undefined;
|
|
787
|
+
this.blobStorage = undefined;
|
|
788
|
+
this.commitLog = undefined;
|
|
789
|
+
this.cowEnabled = false;
|
|
781
790
|
this.nounCacheManager.clear();
|
|
782
791
|
this.verbCacheManager.clear();
|
|
783
792
|
this.totalNounCount = 0;
|
|
@@ -1621,9 +1621,22 @@ export class S3CompatibleStorage extends BaseStorage {
|
|
|
1621
1621
|
await deleteObjectsWithPrefix(this.verbMetadataPrefix);
|
|
1622
1622
|
// Delete all objects in the index directory
|
|
1623
1623
|
await deleteObjectsWithPrefix(this.indexPrefix);
|
|
1624
|
+
// v5.6.1: Delete COW (copy-on-write) version control data
|
|
1625
|
+
// This includes all git-like versioning data (commits, trees, blobs, refs)
|
|
1626
|
+
// Must be deleted to fully clear all data including version history
|
|
1627
|
+
await deleteObjectsWithPrefix('_cow/');
|
|
1628
|
+
// CRITICAL: Reset COW state to prevent automatic reinitialization
|
|
1629
|
+
// When COW data is cleared, we must also clear the COW managers
|
|
1630
|
+
// Otherwise initializeCOW() will auto-recreate initial commit on next operation
|
|
1631
|
+
this.refManager = undefined;
|
|
1632
|
+
this.blobStorage = undefined;
|
|
1633
|
+
this.commitLog = undefined;
|
|
1634
|
+
this.cowEnabled = false;
|
|
1624
1635
|
// Clear the statistics cache
|
|
1625
1636
|
this.statisticsCache = null;
|
|
1626
1637
|
this.statisticsModified = false;
|
|
1638
|
+
this.totalNounCount = 0;
|
|
1639
|
+
this.totalVerbCount = 0;
|
|
1627
1640
|
}
|
|
1628
1641
|
catch (error) {
|
|
1629
1642
|
prodLog.error('Failed to clear storage:', error);
|
|
@@ -203,6 +203,11 @@ export class BaseStorage extends BaseStorageAdapter {
|
|
|
203
203
|
* @returns Promise that resolves when COW is initialized
|
|
204
204
|
*/
|
|
205
205
|
async initializeCOW(options) {
|
|
206
|
+
// v5.6.1: If COW was explicitly disabled (e.g., via clear()), don't reinitialize
|
|
207
|
+
// This prevents automatic recreation of COW data after clear() operations
|
|
208
|
+
if (this.cowEnabled === false) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
206
211
|
// Check if RefManager already initialized (full COW setup complete)
|
|
207
212
|
if (this.refManager) {
|
|
208
213
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.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",
|