@soulcraft/brainy 5.7.2 → 5.7.4
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 +12 -0
- package/dist/brainy.js +8 -0
- package/dist/storage/baseStorage.js +8 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
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.7.4](https://github.com/soulcraftlabs/brainy/compare/v5.7.3...v5.7.4) (2025-11-12)
|
|
6
|
+
|
|
7
|
+
- fix: resolve v5.7.3 race condition by persisting write-through cache (v5.7.4) (6e19ec8)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### [5.7.3](https://github.com/soulcraftlabs/brainy/compare/v5.7.2...v5.7.3) (2025-11-12)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### 🐛 Bug Fixes
|
|
14
|
+
|
|
15
|
+
* resolve REAL v5.7.x race condition - type cache layer (v5.7.3) ([ee17565](https://github.com/soulcraftlabs/brainy/commit/ee1756565ca01666e2aa3b31a80b62c6aa8046e8))
|
|
16
|
+
|
|
5
17
|
### [5.7.2](https://github.com/soulcraftlabs/brainy/compare/v5.7.1...v5.7.2) (2025-11-12)
|
|
6
18
|
|
|
7
19
|
|
package/dist/brainy.js
CHANGED
|
@@ -3080,6 +3080,14 @@ export class Brainy {
|
|
|
3080
3080
|
// Note: Graph structure is already persisted via storage.saveVerb() calls
|
|
3081
3081
|
// This just flushes the in-memory cache for performance
|
|
3082
3082
|
this.graphIndex.flush()
|
|
3083
|
+
// Note: Write-through cache (storage.writeCache) is NOT cleared here
|
|
3084
|
+
// Cache persists indefinitely for read-after-write consistency
|
|
3085
|
+
// Provides safety net for:
|
|
3086
|
+
// - Cloud storage eventual consistency (S3, GCS, Azure, R2)
|
|
3087
|
+
// - Filesystem buffer cache timing
|
|
3088
|
+
// - Type cache warming period (nounTypeCache population)
|
|
3089
|
+
// Cache entries are removed only when explicitly deleted (deleteObjectFromBranch)
|
|
3090
|
+
// Memory footprint is negligible for typical workloads (<10MB for 100k entities)
|
|
3083
3091
|
]);
|
|
3084
3092
|
const elapsed = Date.now() - startTime;
|
|
3085
3093
|
console.log(`✅ All indexes flushed to disk in ${elapsed}ms`);
|
|
@@ -75,10 +75,11 @@ export class BaseStorage extends BaseStorageAdapter {
|
|
|
75
75
|
this.isInitialized = false;
|
|
76
76
|
this.readOnly = false;
|
|
77
77
|
// v5.7.2: Write-through cache for read-after-write consistency
|
|
78
|
+
// v5.7.3: Extended lifetime - persists until explicit flush() call
|
|
78
79
|
// Guarantees that immediately after writeObjectToBranch(), readWithInheritance() returns the data
|
|
79
80
|
// Cache key: resolved branchPath (includes branch scope for COW isolation)
|
|
80
|
-
// Cache lifetime: write start →
|
|
81
|
-
// Memory footprint:
|
|
81
|
+
// Cache lifetime: write start → flush() call (provides safety net for batch operations)
|
|
82
|
+
// Memory footprint: Bounded by batch size (typically <1000 items during imports)
|
|
82
83
|
this.writeCache = new Map();
|
|
83
84
|
this.currentBranch = 'main';
|
|
84
85
|
this.cowEnabled = false;
|
|
@@ -360,16 +361,13 @@ export class BaseStorage extends BaseStorageAdapter {
|
|
|
360
361
|
async writeObjectToBranch(path, data, branch) {
|
|
361
362
|
const branchPath = this.resolveBranchPath(path, branch);
|
|
362
363
|
// v5.7.2: Add to write cache BEFORE async write (guarantees read-after-write consistency)
|
|
364
|
+
// v5.7.3: Cache persists until flush() is called (extended lifetime for batch operations)
|
|
363
365
|
// This ensures readWithInheritance() returns data immediately, fixing "Source entity not found" bug
|
|
364
366
|
this.writeCache.set(branchPath, data);
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
// v5.7.2: Remove from cache after write completes (success or failure)
|
|
370
|
-
// Small memory footprint: cache only holds in-flight writes (typically <10 items)
|
|
371
|
-
this.writeCache.delete(branchPath);
|
|
372
|
-
}
|
|
367
|
+
// Write to storage (async)
|
|
368
|
+
await this.writeObjectToPath(branchPath, data);
|
|
369
|
+
// v5.7.3: Cache is NOT cleared here anymore - persists until flush()
|
|
370
|
+
// This provides a safety net for immediate queries after batch writes
|
|
373
371
|
}
|
|
374
372
|
/**
|
|
375
373
|
* Read object with inheritance from parent branches (COW layer)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "5.7.
|
|
3
|
+
"version": "5.7.4",
|
|
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",
|