@soulcraft/brainy 3.37.0 → 3.37.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.
- package/CHANGELOG.md +12 -0
- package/dist/coreTypes.d.ts +1 -0
- package/dist/storage/adapters/fileSystemStorage.d.ts +4 -2
- package/dist/storage/adapters/fileSystemStorage.js +28 -4
- package/dist/storage/adapters/gcsStorage.d.ts +2 -0
- package/dist/storage/adapters/gcsStorage.js +27 -2
- package/dist/storage/adapters/memoryStorage.d.ts +4 -2
- package/dist/storage/adapters/memoryStorage.js +18 -17
- package/dist/storage/adapters/opfsStorage.d.ts +3 -1
- package/dist/storage/adapters/opfsStorage.js +23 -3
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +2 -0
- package/dist/storage/adapters/s3CompatibleStorage.js +26 -2
- 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
|
+
### [3.37.2](https://github.com/soulcraftlabs/brainy/compare/v3.37.1...v3.37.2) (2025-10-10)
|
|
6
|
+
|
|
7
|
+
- fix: ensure GCS storage initialization before pagination (2565685)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### [3.37.1](https://github.com/soulcraftlabs/brainy/compare/v3.37.0...v3.37.1) (2025-10-10)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### 🐛 Bug Fixes
|
|
14
|
+
|
|
15
|
+
* combine vector and metadata in getNoun/getVerb internal methods ([cb1e37c](https://github.com/soulcraftlabs/brainy/commit/cb1e37c0e8132f53be0f359feaef5dcf342462d2))
|
|
16
|
+
|
|
5
17
|
### [3.37.0](https://github.com/soulcraftlabs/brainy/compare/v3.36.1...v3.37.0) (2025-10-10)
|
|
6
18
|
|
|
7
19
|
- fix: implement 2-file storage architecture for GCS scalability (59da5f6)
|
package/dist/coreTypes.d.ts
CHANGED
|
@@ -161,7 +161,8 @@ export declare class FileSystemStorage extends BaseStorage {
|
|
|
161
161
|
*/
|
|
162
162
|
protected saveNoun_internal(noun: HNSWNoun): Promise<void>;
|
|
163
163
|
/**
|
|
164
|
-
* Get a noun from storage
|
|
164
|
+
* Get a noun from storage (internal implementation)
|
|
165
|
+
* Combines vector data from getNode() with metadata from getNounMetadata()
|
|
165
166
|
*/
|
|
166
167
|
protected getNoun_internal(id: string): Promise<HNSWNoun | null>;
|
|
167
168
|
/**
|
|
@@ -177,7 +178,8 @@ export declare class FileSystemStorage extends BaseStorage {
|
|
|
177
178
|
*/
|
|
178
179
|
protected saveVerb_internal(verb: HNSWVerb): Promise<void>;
|
|
179
180
|
/**
|
|
180
|
-
* Get a verb from storage
|
|
181
|
+
* Get a verb from storage (internal implementation)
|
|
182
|
+
* Combines vector data from getEdge() with metadata from getVerbMetadata()
|
|
181
183
|
*/
|
|
182
184
|
protected getVerb_internal(id: string): Promise<HNSWVerb | null>;
|
|
183
185
|
/**
|
|
@@ -863,10 +863,22 @@ export class FileSystemStorage extends BaseStorage {
|
|
|
863
863
|
return this.saveNode(noun);
|
|
864
864
|
}
|
|
865
865
|
/**
|
|
866
|
-
* Get a noun from storage
|
|
866
|
+
* Get a noun from storage (internal implementation)
|
|
867
|
+
* Combines vector data from getNode() with metadata from getNounMetadata()
|
|
867
868
|
*/
|
|
868
869
|
async getNoun_internal(id) {
|
|
869
|
-
|
|
870
|
+
// Get vector data (lightweight)
|
|
871
|
+
const node = await this.getNode(id);
|
|
872
|
+
if (!node) {
|
|
873
|
+
return null;
|
|
874
|
+
}
|
|
875
|
+
// Get metadata (entity data in 2-file system)
|
|
876
|
+
const metadata = await this.getNounMetadata(id);
|
|
877
|
+
// Combine into complete noun object
|
|
878
|
+
return {
|
|
879
|
+
...node,
|
|
880
|
+
metadata: metadata || {}
|
|
881
|
+
};
|
|
870
882
|
}
|
|
871
883
|
/**
|
|
872
884
|
* Get nouns by noun type
|
|
@@ -887,10 +899,22 @@ export class FileSystemStorage extends BaseStorage {
|
|
|
887
899
|
return this.saveEdge(verb);
|
|
888
900
|
}
|
|
889
901
|
/**
|
|
890
|
-
* Get a verb from storage
|
|
902
|
+
* Get a verb from storage (internal implementation)
|
|
903
|
+
* Combines vector data from getEdge() with metadata from getVerbMetadata()
|
|
891
904
|
*/
|
|
892
905
|
async getVerb_internal(id) {
|
|
893
|
-
|
|
906
|
+
// Get vector data (lightweight)
|
|
907
|
+
const edge = await this.getEdge(id);
|
|
908
|
+
if (!edge) {
|
|
909
|
+
return null;
|
|
910
|
+
}
|
|
911
|
+
// Get metadata (relationship data in 2-file system)
|
|
912
|
+
const metadata = await this.getVerbMetadata(id);
|
|
913
|
+
// Combine into complete verb object
|
|
914
|
+
return {
|
|
915
|
+
...edge,
|
|
916
|
+
metadata: metadata || {}
|
|
917
|
+
};
|
|
894
918
|
}
|
|
895
919
|
/**
|
|
896
920
|
* Get verbs by source
|
|
@@ -148,6 +148,7 @@ export declare class GcsStorage extends BaseStorage {
|
|
|
148
148
|
private saveNodeDirect;
|
|
149
149
|
/**
|
|
150
150
|
* Get a noun from storage (internal implementation)
|
|
151
|
+
* Combines vector data from getNode() with metadata from getNounMetadata()
|
|
151
152
|
*/
|
|
152
153
|
protected getNoun_internal(id: string): Promise<HNSWNoun | null>;
|
|
153
154
|
/**
|
|
@@ -196,6 +197,7 @@ export declare class GcsStorage extends BaseStorage {
|
|
|
196
197
|
private saveEdgeDirect;
|
|
197
198
|
/**
|
|
198
199
|
* Get a verb from storage (internal implementation)
|
|
200
|
+
* Combines vector data from getEdge() with metadata from getVerbMetadata()
|
|
199
201
|
*/
|
|
200
202
|
protected getVerb_internal(id: string): Promise<HNSWVerb | null>;
|
|
201
203
|
/**
|
|
@@ -359,9 +359,21 @@ export class GcsStorage extends BaseStorage {
|
|
|
359
359
|
}
|
|
360
360
|
/**
|
|
361
361
|
* Get a noun from storage (internal implementation)
|
|
362
|
+
* Combines vector data from getNode() with metadata from getNounMetadata()
|
|
362
363
|
*/
|
|
363
364
|
async getNoun_internal(id) {
|
|
364
|
-
|
|
365
|
+
// Get vector data (lightweight)
|
|
366
|
+
const node = await this.getNode(id);
|
|
367
|
+
if (!node) {
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
// Get metadata (entity data in 2-file system)
|
|
371
|
+
const metadata = await this.getNounMetadata(id);
|
|
372
|
+
// Combine into complete noun object
|
|
373
|
+
return {
|
|
374
|
+
...node,
|
|
375
|
+
metadata: metadata || {}
|
|
376
|
+
};
|
|
365
377
|
}
|
|
366
378
|
/**
|
|
367
379
|
* Get a node from storage
|
|
@@ -619,9 +631,21 @@ export class GcsStorage extends BaseStorage {
|
|
|
619
631
|
}
|
|
620
632
|
/**
|
|
621
633
|
* Get a verb from storage (internal implementation)
|
|
634
|
+
* Combines vector data from getEdge() with metadata from getVerbMetadata()
|
|
622
635
|
*/
|
|
623
636
|
async getVerb_internal(id) {
|
|
624
|
-
|
|
637
|
+
// Get vector data (lightweight)
|
|
638
|
+
const edge = await this.getEdge(id);
|
|
639
|
+
if (!edge) {
|
|
640
|
+
return null;
|
|
641
|
+
}
|
|
642
|
+
// Get metadata (relationship data in 2-file system)
|
|
643
|
+
const metadata = await this.getVerbMetadata(id);
|
|
644
|
+
// Combine into complete verb object
|
|
645
|
+
return {
|
|
646
|
+
...edge,
|
|
647
|
+
metadata: metadata || {}
|
|
648
|
+
};
|
|
625
649
|
}
|
|
626
650
|
/**
|
|
627
651
|
* Get an edge from storage
|
|
@@ -758,6 +782,7 @@ export class GcsStorage extends BaseStorage {
|
|
|
758
782
|
* Iterates through UUID-based shards for consistent pagination
|
|
759
783
|
*/
|
|
760
784
|
async getNodesWithPagination(options) {
|
|
785
|
+
await this.ensureInitialized(); // CRITICAL: Must initialize before using this.bucket
|
|
761
786
|
const limit = options.limit || 100;
|
|
762
787
|
const useCache = options.useCache !== false;
|
|
763
788
|
try {
|
|
@@ -28,7 +28,8 @@ export declare class MemoryStorage extends BaseStorage {
|
|
|
28
28
|
*/
|
|
29
29
|
protected saveNoun_internal(noun: HNSWNoun): Promise<void>;
|
|
30
30
|
/**
|
|
31
|
-
* Get a noun from storage
|
|
31
|
+
* Get a noun from storage (internal implementation)
|
|
32
|
+
* Combines vector data from nouns map with metadata from getNounMetadata()
|
|
32
33
|
*/
|
|
33
34
|
protected getNoun_internal(id: string): Promise<HNSWNoun | null>;
|
|
34
35
|
/**
|
|
@@ -77,7 +78,8 @@ export declare class MemoryStorage extends BaseStorage {
|
|
|
77
78
|
*/
|
|
78
79
|
protected saveVerb_internal(verb: HNSWVerb): Promise<void>;
|
|
79
80
|
/**
|
|
80
|
-
* Get a verb from storage
|
|
81
|
+
* Get a verb from storage (internal implementation)
|
|
82
|
+
* Combines vector data from verbs map with metadata from getVerbMetadata()
|
|
81
83
|
*/
|
|
82
84
|
protected getVerb_internal(id: string): Promise<HNSWVerb | null>;
|
|
83
85
|
/**
|
|
@@ -63,7 +63,8 @@ export class MemoryStorage extends BaseStorage {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
* Get a noun from storage
|
|
66
|
+
* Get a noun from storage (internal implementation)
|
|
67
|
+
* Combines vector data from nouns map with metadata from getNounMetadata()
|
|
67
68
|
*/
|
|
68
69
|
async getNoun_internal(id) {
|
|
69
70
|
// Get the noun directly from the nouns map
|
|
@@ -73,20 +74,23 @@ export class MemoryStorage extends BaseStorage {
|
|
|
73
74
|
return null;
|
|
74
75
|
}
|
|
75
76
|
// Return a deep copy to avoid reference issues
|
|
76
|
-
// CRITICAL: Only return lightweight vector data (no metadata)
|
|
77
|
-
// Metadata is retrieved separately via getNounMetadata() (2-file system)
|
|
78
77
|
const nounCopy = {
|
|
79
78
|
id: noun.id,
|
|
80
79
|
vector: [...noun.vector],
|
|
81
80
|
connections: new Map(),
|
|
82
81
|
level: noun.level || 0
|
|
83
|
-
// NO metadata field - retrieved separately for scalability
|
|
84
82
|
};
|
|
85
83
|
// Copy connections
|
|
86
84
|
for (const [level, connections] of noun.connections.entries()) {
|
|
87
85
|
nounCopy.connections.set(level, new Set(connections));
|
|
88
86
|
}
|
|
89
|
-
|
|
87
|
+
// Get metadata (entity data in 2-file system)
|
|
88
|
+
const metadata = await this.getNounMetadata(id);
|
|
89
|
+
// Combine into complete noun object
|
|
90
|
+
return {
|
|
91
|
+
...nounCopy,
|
|
92
|
+
metadata: metadata || {}
|
|
93
|
+
};
|
|
90
94
|
}
|
|
91
95
|
/**
|
|
92
96
|
* Get nouns with pagination and filtering
|
|
@@ -237,7 +241,8 @@ export class MemoryStorage extends BaseStorage {
|
|
|
237
241
|
// since HNSWVerb doesn't contain type information
|
|
238
242
|
}
|
|
239
243
|
/**
|
|
240
|
-
* Get a verb from storage
|
|
244
|
+
* Get a verb from storage (internal implementation)
|
|
245
|
+
* Combines vector data from verbs map with metadata from getVerbMetadata()
|
|
241
246
|
*/
|
|
242
247
|
async getVerb_internal(id) {
|
|
243
248
|
// Get the verb directly from the verbs map
|
|
@@ -246,16 +251,6 @@ export class MemoryStorage extends BaseStorage {
|
|
|
246
251
|
if (!verb) {
|
|
247
252
|
return null;
|
|
248
253
|
}
|
|
249
|
-
// Create default timestamp if not present
|
|
250
|
-
const defaultTimestamp = {
|
|
251
|
-
seconds: Math.floor(Date.now() / 1000),
|
|
252
|
-
nanoseconds: (Date.now() % 1000) * 1000000
|
|
253
|
-
};
|
|
254
|
-
// Create default createdBy if not present
|
|
255
|
-
const defaultCreatedBy = {
|
|
256
|
-
augmentation: 'unknown',
|
|
257
|
-
version: '1.0'
|
|
258
|
-
};
|
|
259
254
|
// Return a deep copy of the HNSWVerb
|
|
260
255
|
const verbCopy = {
|
|
261
256
|
id: verb.id,
|
|
@@ -266,7 +261,13 @@ export class MemoryStorage extends BaseStorage {
|
|
|
266
261
|
for (const [level, connections] of verb.connections.entries()) {
|
|
267
262
|
verbCopy.connections.set(level, new Set(connections));
|
|
268
263
|
}
|
|
269
|
-
|
|
264
|
+
// Get metadata (relationship data in 2-file system)
|
|
265
|
+
const metadata = await this.getVerbMetadata(id);
|
|
266
|
+
// Combine into complete verb object
|
|
267
|
+
return {
|
|
268
|
+
...verbCopy,
|
|
269
|
+
metadata: metadata || {}
|
|
270
|
+
};
|
|
270
271
|
}
|
|
271
272
|
/**
|
|
272
273
|
* Get verbs with pagination and filtering
|
|
@@ -53,7 +53,8 @@ export declare class OPFSStorage extends BaseStorage {
|
|
|
53
53
|
*/
|
|
54
54
|
protected saveNoun_internal(noun: HNSWNoun_internal): Promise<void>;
|
|
55
55
|
/**
|
|
56
|
-
* Get a noun from storage
|
|
56
|
+
* Get a noun from storage (internal implementation)
|
|
57
|
+
* Combines vector data from file with metadata from getNounMetadata()
|
|
57
58
|
*/
|
|
58
59
|
protected getNoun_internal(id: string): Promise<HNSWNoun_internal | null>;
|
|
59
60
|
/**
|
|
@@ -86,6 +87,7 @@ export declare class OPFSStorage extends BaseStorage {
|
|
|
86
87
|
protected saveEdge(edge: Edge): Promise<void>;
|
|
87
88
|
/**
|
|
88
89
|
* Get a verb from storage (internal implementation)
|
|
90
|
+
* Combines vector data from getEdge() with metadata from getVerbMetadata()
|
|
89
91
|
*/
|
|
90
92
|
protected getVerb_internal(id: string): Promise<HNSWVerb | null>;
|
|
91
93
|
/**
|
|
@@ -173,7 +173,8 @@ export class OPFSStorage extends BaseStorage {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
|
-
* Get a noun from storage
|
|
176
|
+
* Get a noun from storage (internal implementation)
|
|
177
|
+
* Combines vector data from file with metadata from getNounMetadata()
|
|
177
178
|
*/
|
|
178
179
|
async getNoun_internal(id) {
|
|
179
180
|
await this.ensureInitialized();
|
|
@@ -193,12 +194,19 @@ export class OPFSStorage extends BaseStorage {
|
|
|
193
194
|
for (const [level, nounIds] of Object.entries(data.connections)) {
|
|
194
195
|
connections.set(Number(level), new Set(nounIds));
|
|
195
196
|
}
|
|
196
|
-
|
|
197
|
+
const node = {
|
|
197
198
|
id: data.id,
|
|
198
199
|
vector: data.vector,
|
|
199
200
|
connections,
|
|
200
201
|
level: data.level || 0
|
|
201
202
|
};
|
|
203
|
+
// Get metadata (entity data in 2-file system)
|
|
204
|
+
const metadata = await this.getNounMetadata(id);
|
|
205
|
+
// Combine into complete noun object
|
|
206
|
+
return {
|
|
207
|
+
...node,
|
|
208
|
+
metadata: metadata || {}
|
|
209
|
+
};
|
|
202
210
|
}
|
|
203
211
|
catch (error) {
|
|
204
212
|
// Noun not found or other error
|
|
@@ -333,9 +341,21 @@ export class OPFSStorage extends BaseStorage {
|
|
|
333
341
|
}
|
|
334
342
|
/**
|
|
335
343
|
* Get a verb from storage (internal implementation)
|
|
344
|
+
* Combines vector data from getEdge() with metadata from getVerbMetadata()
|
|
336
345
|
*/
|
|
337
346
|
async getVerb_internal(id) {
|
|
338
|
-
|
|
347
|
+
// Get vector data (lightweight)
|
|
348
|
+
const edge = await this.getEdge(id);
|
|
349
|
+
if (!edge) {
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
// Get metadata (relationship data in 2-file system)
|
|
353
|
+
const metadata = await this.getVerbMetadata(id);
|
|
354
|
+
// Combine into complete verb object
|
|
355
|
+
return {
|
|
356
|
+
...edge,
|
|
357
|
+
metadata: metadata || {}
|
|
358
|
+
};
|
|
339
359
|
}
|
|
340
360
|
/**
|
|
341
361
|
* Get an edge from storage
|
|
@@ -222,6 +222,7 @@ export declare class S3CompatibleStorage extends BaseStorage {
|
|
|
222
222
|
protected saveNode(node: HNSWNode): Promise<void>;
|
|
223
223
|
/**
|
|
224
224
|
* Get a noun from storage (internal implementation)
|
|
225
|
+
* Combines vector data from getNode() with metadata from getNounMetadata()
|
|
225
226
|
*/
|
|
226
227
|
protected getNoun_internal(id: string): Promise<HNSWNoun | null>;
|
|
227
228
|
/**
|
|
@@ -297,6 +298,7 @@ export declare class S3CompatibleStorage extends BaseStorage {
|
|
|
297
298
|
protected saveEdge(edge: Edge): Promise<void>;
|
|
298
299
|
/**
|
|
299
300
|
* Get a verb from storage (internal implementation)
|
|
301
|
+
* Combines vector data from getEdge() with metadata from getVerbMetadata()
|
|
300
302
|
*/
|
|
301
303
|
protected getVerb_internal(id: string): Promise<HNSWVerb | null>;
|
|
302
304
|
/**
|
|
@@ -787,9 +787,21 @@ export class S3CompatibleStorage extends BaseStorage {
|
|
|
787
787
|
}
|
|
788
788
|
/**
|
|
789
789
|
* Get a noun from storage (internal implementation)
|
|
790
|
+
* Combines vector data from getNode() with metadata from getNounMetadata()
|
|
790
791
|
*/
|
|
791
792
|
async getNoun_internal(id) {
|
|
792
|
-
|
|
793
|
+
// Get vector data (lightweight)
|
|
794
|
+
const node = await this.getNode(id);
|
|
795
|
+
if (!node) {
|
|
796
|
+
return null;
|
|
797
|
+
}
|
|
798
|
+
// Get metadata (entity data in 2-file system)
|
|
799
|
+
const metadata = await this.getNounMetadata(id);
|
|
800
|
+
// Combine into complete noun object
|
|
801
|
+
return {
|
|
802
|
+
...node,
|
|
803
|
+
metadata: metadata || {}
|
|
804
|
+
};
|
|
793
805
|
}
|
|
794
806
|
/**
|
|
795
807
|
* Get a node from storage
|
|
@@ -1170,9 +1182,21 @@ export class S3CompatibleStorage extends BaseStorage {
|
|
|
1170
1182
|
}
|
|
1171
1183
|
/**
|
|
1172
1184
|
* Get a verb from storage (internal implementation)
|
|
1185
|
+
* Combines vector data from getEdge() with metadata from getVerbMetadata()
|
|
1173
1186
|
*/
|
|
1174
1187
|
async getVerb_internal(id) {
|
|
1175
|
-
|
|
1188
|
+
// Get vector data (lightweight)
|
|
1189
|
+
const edge = await this.getEdge(id);
|
|
1190
|
+
if (!edge) {
|
|
1191
|
+
return null;
|
|
1192
|
+
}
|
|
1193
|
+
// Get metadata (relationship data in 2-file system)
|
|
1194
|
+
const metadata = await this.getVerbMetadata(id);
|
|
1195
|
+
// Combine into complete verb object
|
|
1196
|
+
return {
|
|
1197
|
+
...edge,
|
|
1198
|
+
metadata: metadata || {}
|
|
1199
|
+
};
|
|
1176
1200
|
}
|
|
1177
1201
|
/**
|
|
1178
1202
|
* Get an edge from storage
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "3.37.
|
|
3
|
+
"version": "3.37.2",
|
|
4
4
|
"description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. 31 nouns × 40 verbs for infinite expressiveness.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|