@soulcraft/brainy 3.43.3 → 3.45.0
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 +6 -0
- package/README.md +36 -4
- package/dist/augmentations/KnowledgeAugmentation.d.ts +40 -0
- package/dist/augmentations/KnowledgeAugmentation.js +251 -0
- package/dist/graph/graphAdjacencyIndex.d.ts +23 -22
- package/dist/graph/graphAdjacencyIndex.js +106 -121
- package/dist/graph/lsm/BloomFilter.d.ts +188 -0
- package/dist/graph/lsm/BloomFilter.js +278 -0
- package/dist/graph/lsm/LSMTree.d.ts +168 -0
- package/dist/graph/lsm/LSMTree.js +443 -0
- package/dist/graph/lsm/SSTable.d.ts +228 -0
- package/dist/graph/lsm/SSTable.js +290 -0
- package/dist/neural/embeddedTypeEmbeddings.d.ts +1 -1
- package/dist/neural/embeddedTypeEmbeddings.js +2 -2
- package/dist/storage/adapters/typeAwareStorageAdapter.d.ts +210 -0
- package/dist/storage/adapters/typeAwareStorageAdapter.js +626 -0
- package/dist/storage/storageFactory.d.ts +23 -2
- package/dist/storage/storageFactory.js +28 -7
- package/dist/types/brainyDataInterface.d.ts +52 -0
- package/dist/types/brainyDataInterface.js +10 -0
- package/dist/types/graphTypes.d.ts +132 -0
- package/dist/types/graphTypes.js +172 -0
- package/dist/utils/metadataIndex.d.ts +14 -1
- package/dist/utils/metadataIndex.js +93 -72
- package/dist/vfs/ConceptSystem.d.ts +203 -0
- package/dist/vfs/ConceptSystem.js +545 -0
- package/dist/vfs/EntityManager.d.ts +75 -0
- package/dist/vfs/EntityManager.js +216 -0
- package/dist/vfs/EventRecorder.d.ts +84 -0
- package/dist/vfs/EventRecorder.js +269 -0
- package/dist/vfs/GitBridge.d.ts +167 -0
- package/dist/vfs/GitBridge.js +537 -0
- package/dist/vfs/KnowledgeLayer.d.ts +35 -0
- package/dist/vfs/KnowledgeLayer.js +443 -0
- package/dist/vfs/PersistentEntitySystem.d.ts +165 -0
- package/dist/vfs/PersistentEntitySystem.js +503 -0
- package/dist/vfs/SemanticVersioning.d.ts +105 -0
- package/dist/vfs/SemanticVersioning.js +309 -0
- package/package.json +2 -1
|
@@ -6,6 +6,7 @@ import { MemoryStorage } from './adapters/memoryStorage.js';
|
|
|
6
6
|
import { OPFSStorage } from './adapters/opfsStorage.js';
|
|
7
7
|
import { S3CompatibleStorage, R2Storage } from './adapters/s3CompatibleStorage.js';
|
|
8
8
|
import { GcsStorage } from './adapters/gcsStorage.js';
|
|
9
|
+
import { TypeAwareStorageAdapter } from './adapters/typeAwareStorageAdapter.js';
|
|
9
10
|
// FileSystemStorage is dynamically imported to avoid issues in browser environments
|
|
10
11
|
import { isBrowser } from '../utils/environment.js';
|
|
11
12
|
/**
|
|
@@ -38,10 +39,11 @@ export async function createStorage(options = {}) {
|
|
|
38
39
|
console.warn('FileSystemStorage is not available in browser environments, falling back to memory storage');
|
|
39
40
|
return new MemoryStorage();
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
const fsPath = getFileSystemPath(options);
|
|
43
|
+
console.log(`Using file system storage (forced): ${fsPath}`);
|
|
42
44
|
try {
|
|
43
45
|
const { FileSystemStorage } = await import('./adapters/fileSystemStorage.js');
|
|
44
|
-
return new FileSystemStorage(
|
|
46
|
+
return new FileSystemStorage(fsPath);
|
|
45
47
|
}
|
|
46
48
|
catch (error) {
|
|
47
49
|
console.warn('Failed to load FileSystemStorage, falling back to memory storage:', error);
|
|
@@ -77,10 +79,11 @@ export async function createStorage(options = {}) {
|
|
|
77
79
|
console.warn('FileSystemStorage is not available in browser environments, falling back to memory storage');
|
|
78
80
|
return new MemoryStorage();
|
|
79
81
|
}
|
|
80
|
-
|
|
82
|
+
const fsPath = getFileSystemPath(options);
|
|
83
|
+
console.log(`Using file system storage: ${fsPath}`);
|
|
81
84
|
try {
|
|
82
85
|
const { FileSystemStorage } = await import('./adapters/fileSystemStorage.js');
|
|
83
|
-
return new FileSystemStorage(
|
|
86
|
+
return new FileSystemStorage(fsPath);
|
|
84
87
|
}
|
|
85
88
|
catch (error) {
|
|
86
89
|
console.warn('Failed to load FileSystemStorage, falling back to memory storage:', error);
|
|
@@ -154,6 +157,23 @@ export async function createStorage(options = {}) {
|
|
|
154
157
|
console.warn('GCS native storage configuration is missing, falling back to memory storage');
|
|
155
158
|
return new MemoryStorage();
|
|
156
159
|
}
|
|
160
|
+
case 'type-aware': {
|
|
161
|
+
console.log('Using Type-Aware Storage (type-first architecture)');
|
|
162
|
+
// Create underlying storage adapter
|
|
163
|
+
const underlyingType = options.typeAwareStorage?.underlyingType || 'auto';
|
|
164
|
+
const underlyingOptions = options.typeAwareStorage?.underlyingOptions || {};
|
|
165
|
+
// Recursively create the underlying storage
|
|
166
|
+
const underlying = await createStorage({
|
|
167
|
+
...underlyingOptions,
|
|
168
|
+
type: underlyingType
|
|
169
|
+
});
|
|
170
|
+
// Wrap with TypeAwareStorageAdapter
|
|
171
|
+
// Cast to BaseStorage since all concrete storage adapters extend BaseStorage
|
|
172
|
+
return new TypeAwareStorageAdapter({
|
|
173
|
+
underlyingStorage: underlying,
|
|
174
|
+
verbose: options.typeAwareStorage?.verbose || false
|
|
175
|
+
});
|
|
176
|
+
}
|
|
157
177
|
default:
|
|
158
178
|
console.warn(`Unknown storage type: ${options.type}, falling back to memory storage`);
|
|
159
179
|
return new MemoryStorage();
|
|
@@ -230,10 +250,11 @@ export async function createStorage(options = {}) {
|
|
|
230
250
|
if (typeof process !== 'undefined' &&
|
|
231
251
|
process.versions &&
|
|
232
252
|
process.versions.node) {
|
|
233
|
-
|
|
253
|
+
const fsPath = getFileSystemPath(options);
|
|
254
|
+
console.log(`Using file system storage (auto-detected): ${fsPath}`);
|
|
234
255
|
try {
|
|
235
256
|
const { FileSystemStorage } = await import('./adapters/fileSystemStorage.js');
|
|
236
|
-
return new FileSystemStorage(
|
|
257
|
+
return new FileSystemStorage(fsPath);
|
|
237
258
|
}
|
|
238
259
|
catch (fsError) {
|
|
239
260
|
console.warn('Failed to load FileSystemStorage, falling back to memory storage:', fsError);
|
|
@@ -266,7 +287,7 @@ export async function createStorage(options = {}) {
|
|
|
266
287
|
/**
|
|
267
288
|
* Export storage adapters
|
|
268
289
|
*/
|
|
269
|
-
export { MemoryStorage, OPFSStorage, S3CompatibleStorage, R2Storage, GcsStorage };
|
|
290
|
+
export { MemoryStorage, OPFSStorage, S3CompatibleStorage, R2Storage, GcsStorage, TypeAwareStorageAdapter };
|
|
270
291
|
// Export FileSystemStorage conditionally
|
|
271
292
|
// NOTE: FileSystemStorage is now only imported dynamically to avoid fs imports in browser builds
|
|
272
293
|
// export { FileSystemStorage } from './adapters/fileSystemStorage.js'
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BrainyInterface - Modern API Only
|
|
3
|
+
*
|
|
4
|
+
* This interface defines the MODERN methods from Brainy 3.0.
|
|
5
|
+
* Used to break circular dependencies while enforcing modern API usage.
|
|
6
|
+
*
|
|
7
|
+
* NO DEPRECATED METHODS - Only clean, modern API patterns.
|
|
8
|
+
*/
|
|
9
|
+
import { Vector } from '../coreTypes.js';
|
|
10
|
+
import { AddParams, RelateParams, Result, Entity, FindParams, SimilarParams } from './brainy.types.js';
|
|
11
|
+
export interface BrainyInterface<T = unknown> {
|
|
12
|
+
/**
|
|
13
|
+
* Initialize the database
|
|
14
|
+
*/
|
|
15
|
+
init(): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Modern add method - unified entity creation
|
|
18
|
+
* @param params Parameters for adding entities
|
|
19
|
+
* @returns The ID of the created entity
|
|
20
|
+
*/
|
|
21
|
+
add(params: AddParams<T>): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Modern relate method - unified relationship creation
|
|
24
|
+
* @param params Parameters for creating relationships
|
|
25
|
+
* @returns The ID of the created relationship
|
|
26
|
+
*/
|
|
27
|
+
relate(params: RelateParams<T>): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Modern find method - unified search and discovery
|
|
30
|
+
* @param query Search query or parameters object
|
|
31
|
+
* @returns Array of search results
|
|
32
|
+
*/
|
|
33
|
+
find(query: string | FindParams<T>): Promise<Result<T>[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Modern get method - retrieve entities by ID
|
|
36
|
+
* @param id The entity ID to retrieve
|
|
37
|
+
* @returns Entity or null if not found
|
|
38
|
+
*/
|
|
39
|
+
get(id: string): Promise<Entity<T> | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Modern similar method - find similar entities
|
|
42
|
+
* @param params Parameters for similarity search
|
|
43
|
+
* @returns Array of similar entities with scores
|
|
44
|
+
*/
|
|
45
|
+
similar(params: SimilarParams<T>): Promise<Result<T>[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Generate embedding vector from text
|
|
48
|
+
* @param text The text to embed
|
|
49
|
+
* @returns Vector representation of the text
|
|
50
|
+
*/
|
|
51
|
+
embed(text: string): Promise<Vector>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BrainyInterface - Modern API Only
|
|
3
|
+
*
|
|
4
|
+
* This interface defines the MODERN methods from Brainy 3.0.
|
|
5
|
+
* Used to break circular dependencies while enforcing modern API usage.
|
|
6
|
+
*
|
|
7
|
+
* NO DEPRECATED METHODS - Only clean, modern API patterns.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=brainyDataInterface.js.map
|
|
@@ -428,4 +428,136 @@ export declare const VerbType: {
|
|
|
428
428
|
readonly Competes: "competes";
|
|
429
429
|
};
|
|
430
430
|
export type VerbType = (typeof VerbType)[keyof typeof VerbType];
|
|
431
|
+
/**
|
|
432
|
+
* Noun type enum for O(1) lookups and type safety
|
|
433
|
+
* Maps each noun type to a unique index (0-30)
|
|
434
|
+
* Used for fixed-size array operations and bitmap indices
|
|
435
|
+
*/
|
|
436
|
+
export declare enum NounTypeEnum {
|
|
437
|
+
person = 0,
|
|
438
|
+
organization = 1,
|
|
439
|
+
location = 2,
|
|
440
|
+
thing = 3,
|
|
441
|
+
concept = 4,
|
|
442
|
+
event = 5,
|
|
443
|
+
document = 6,
|
|
444
|
+
media = 7,
|
|
445
|
+
file = 8,
|
|
446
|
+
message = 9,
|
|
447
|
+
content = 10,
|
|
448
|
+
collection = 11,
|
|
449
|
+
dataset = 12,
|
|
450
|
+
product = 13,
|
|
451
|
+
service = 14,
|
|
452
|
+
user = 15,
|
|
453
|
+
task = 16,
|
|
454
|
+
project = 17,
|
|
455
|
+
process = 18,
|
|
456
|
+
state = 19,
|
|
457
|
+
role = 20,
|
|
458
|
+
topic = 21,
|
|
459
|
+
language = 22,
|
|
460
|
+
currency = 23,
|
|
461
|
+
measurement = 24,
|
|
462
|
+
hypothesis = 25,
|
|
463
|
+
experiment = 26,
|
|
464
|
+
contract = 27,
|
|
465
|
+
regulation = 28,
|
|
466
|
+
interface = 29,
|
|
467
|
+
resource = 30
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Verb type enum for O(1) lookups and type safety
|
|
471
|
+
* Maps each verb type to a unique index (0-39)
|
|
472
|
+
* Used for fixed-size array operations and bitmap indices
|
|
473
|
+
*/
|
|
474
|
+
export declare enum VerbTypeEnum {
|
|
475
|
+
relatedTo = 0,
|
|
476
|
+
contains = 1,
|
|
477
|
+
partOf = 2,
|
|
478
|
+
locatedAt = 3,
|
|
479
|
+
references = 4,
|
|
480
|
+
precedes = 5,
|
|
481
|
+
succeeds = 6,
|
|
482
|
+
causes = 7,
|
|
483
|
+
dependsOn = 8,
|
|
484
|
+
requires = 9,
|
|
485
|
+
creates = 10,
|
|
486
|
+
transforms = 11,
|
|
487
|
+
becomes = 12,
|
|
488
|
+
modifies = 13,
|
|
489
|
+
consumes = 14,
|
|
490
|
+
owns = 15,
|
|
491
|
+
attributedTo = 16,
|
|
492
|
+
createdBy = 17,
|
|
493
|
+
belongsTo = 18,
|
|
494
|
+
memberOf = 19,
|
|
495
|
+
worksWith = 20,
|
|
496
|
+
friendOf = 21,
|
|
497
|
+
follows = 22,
|
|
498
|
+
likes = 23,
|
|
499
|
+
reportsTo = 24,
|
|
500
|
+
supervises = 25,
|
|
501
|
+
mentors = 26,
|
|
502
|
+
communicates = 27,
|
|
503
|
+
describes = 28,
|
|
504
|
+
defines = 29,
|
|
505
|
+
categorizes = 30,
|
|
506
|
+
measures = 31,
|
|
507
|
+
evaluates = 32,
|
|
508
|
+
uses = 33,
|
|
509
|
+
implements = 34,
|
|
510
|
+
extends = 35,
|
|
511
|
+
inherits = 36,
|
|
512
|
+
conflicts = 37,
|
|
513
|
+
synchronizes = 38,
|
|
514
|
+
competes = 39
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Total number of noun types (for array allocations)
|
|
518
|
+
*/
|
|
519
|
+
export declare const NOUN_TYPE_COUNT = 31;
|
|
520
|
+
/**
|
|
521
|
+
* Total number of verb types (for array allocations)
|
|
522
|
+
*/
|
|
523
|
+
export declare const VERB_TYPE_COUNT = 40;
|
|
524
|
+
/**
|
|
525
|
+
* Type utilities for O(1) conversions between string types and numeric indices
|
|
526
|
+
* Enables efficient fixed-size array operations and bitmap indexing
|
|
527
|
+
*/
|
|
528
|
+
export declare const TypeUtils: {
|
|
529
|
+
/**
|
|
530
|
+
* Get numeric index for a noun type
|
|
531
|
+
* @param type - NounType string (e.g., 'person')
|
|
532
|
+
* @returns Numeric index (0-30)
|
|
533
|
+
*/
|
|
534
|
+
getNounIndex: (type: NounType) => number;
|
|
535
|
+
/**
|
|
536
|
+
* Get numeric index for a verb type
|
|
537
|
+
* @param type - VerbType string (e.g., 'relatedTo')
|
|
538
|
+
* @returns Numeric index (0-39)
|
|
539
|
+
*/
|
|
540
|
+
getVerbIndex: (type: VerbType) => number;
|
|
541
|
+
/**
|
|
542
|
+
* Get noun type string from numeric index
|
|
543
|
+
* @param index - Numeric index (0-30)
|
|
544
|
+
* @returns NounType string or 'thing' as default
|
|
545
|
+
*/
|
|
546
|
+
getNounFromIndex: (index: number) => NounType;
|
|
547
|
+
/**
|
|
548
|
+
* Get verb type string from numeric index
|
|
549
|
+
* @param index - Numeric index (0-39)
|
|
550
|
+
* @returns VerbType string or 'relatedTo' as default
|
|
551
|
+
*/
|
|
552
|
+
getVerbFromIndex: (index: number) => VerbType;
|
|
553
|
+
};
|
|
554
|
+
/**
|
|
555
|
+
* Type-specific metadata for optimization hints
|
|
556
|
+
* Provides per-type configuration for bloom filters, chunking, and indexing
|
|
557
|
+
*/
|
|
558
|
+
export declare const TypeMetadata: Record<NounType, {
|
|
559
|
+
expectedFields: number;
|
|
560
|
+
bloomBits: number;
|
|
561
|
+
avgChunkSize: number;
|
|
562
|
+
}>;
|
|
431
563
|
export {};
|
package/dist/types/graphTypes.js
CHANGED
|
@@ -258,4 +258,176 @@ export const VerbType = {
|
|
|
258
258
|
Synchronizes: 'synchronizes', // Coordination, timing, synchronized operations
|
|
259
259
|
Competes: 'competes' // Competition, rivalry, competing relationships
|
|
260
260
|
};
|
|
261
|
+
/**
|
|
262
|
+
* Noun type enum for O(1) lookups and type safety
|
|
263
|
+
* Maps each noun type to a unique index (0-30)
|
|
264
|
+
* Used for fixed-size array operations and bitmap indices
|
|
265
|
+
*/
|
|
266
|
+
export var NounTypeEnum;
|
|
267
|
+
(function (NounTypeEnum) {
|
|
268
|
+
NounTypeEnum[NounTypeEnum["person"] = 0] = "person";
|
|
269
|
+
NounTypeEnum[NounTypeEnum["organization"] = 1] = "organization";
|
|
270
|
+
NounTypeEnum[NounTypeEnum["location"] = 2] = "location";
|
|
271
|
+
NounTypeEnum[NounTypeEnum["thing"] = 3] = "thing";
|
|
272
|
+
NounTypeEnum[NounTypeEnum["concept"] = 4] = "concept";
|
|
273
|
+
NounTypeEnum[NounTypeEnum["event"] = 5] = "event";
|
|
274
|
+
NounTypeEnum[NounTypeEnum["document"] = 6] = "document";
|
|
275
|
+
NounTypeEnum[NounTypeEnum["media"] = 7] = "media";
|
|
276
|
+
NounTypeEnum[NounTypeEnum["file"] = 8] = "file";
|
|
277
|
+
NounTypeEnum[NounTypeEnum["message"] = 9] = "message";
|
|
278
|
+
NounTypeEnum[NounTypeEnum["content"] = 10] = "content";
|
|
279
|
+
NounTypeEnum[NounTypeEnum["collection"] = 11] = "collection";
|
|
280
|
+
NounTypeEnum[NounTypeEnum["dataset"] = 12] = "dataset";
|
|
281
|
+
NounTypeEnum[NounTypeEnum["product"] = 13] = "product";
|
|
282
|
+
NounTypeEnum[NounTypeEnum["service"] = 14] = "service";
|
|
283
|
+
NounTypeEnum[NounTypeEnum["user"] = 15] = "user";
|
|
284
|
+
NounTypeEnum[NounTypeEnum["task"] = 16] = "task";
|
|
285
|
+
NounTypeEnum[NounTypeEnum["project"] = 17] = "project";
|
|
286
|
+
NounTypeEnum[NounTypeEnum["process"] = 18] = "process";
|
|
287
|
+
NounTypeEnum[NounTypeEnum["state"] = 19] = "state";
|
|
288
|
+
NounTypeEnum[NounTypeEnum["role"] = 20] = "role";
|
|
289
|
+
NounTypeEnum[NounTypeEnum["topic"] = 21] = "topic";
|
|
290
|
+
NounTypeEnum[NounTypeEnum["language"] = 22] = "language";
|
|
291
|
+
NounTypeEnum[NounTypeEnum["currency"] = 23] = "currency";
|
|
292
|
+
NounTypeEnum[NounTypeEnum["measurement"] = 24] = "measurement";
|
|
293
|
+
NounTypeEnum[NounTypeEnum["hypothesis"] = 25] = "hypothesis";
|
|
294
|
+
NounTypeEnum[NounTypeEnum["experiment"] = 26] = "experiment";
|
|
295
|
+
NounTypeEnum[NounTypeEnum["contract"] = 27] = "contract";
|
|
296
|
+
NounTypeEnum[NounTypeEnum["regulation"] = 28] = "regulation";
|
|
297
|
+
NounTypeEnum[NounTypeEnum["interface"] = 29] = "interface";
|
|
298
|
+
NounTypeEnum[NounTypeEnum["resource"] = 30] = "resource";
|
|
299
|
+
})(NounTypeEnum || (NounTypeEnum = {}));
|
|
300
|
+
/**
|
|
301
|
+
* Verb type enum for O(1) lookups and type safety
|
|
302
|
+
* Maps each verb type to a unique index (0-39)
|
|
303
|
+
* Used for fixed-size array operations and bitmap indices
|
|
304
|
+
*/
|
|
305
|
+
export var VerbTypeEnum;
|
|
306
|
+
(function (VerbTypeEnum) {
|
|
307
|
+
VerbTypeEnum[VerbTypeEnum["relatedTo"] = 0] = "relatedTo";
|
|
308
|
+
VerbTypeEnum[VerbTypeEnum["contains"] = 1] = "contains";
|
|
309
|
+
VerbTypeEnum[VerbTypeEnum["partOf"] = 2] = "partOf";
|
|
310
|
+
VerbTypeEnum[VerbTypeEnum["locatedAt"] = 3] = "locatedAt";
|
|
311
|
+
VerbTypeEnum[VerbTypeEnum["references"] = 4] = "references";
|
|
312
|
+
VerbTypeEnum[VerbTypeEnum["precedes"] = 5] = "precedes";
|
|
313
|
+
VerbTypeEnum[VerbTypeEnum["succeeds"] = 6] = "succeeds";
|
|
314
|
+
VerbTypeEnum[VerbTypeEnum["causes"] = 7] = "causes";
|
|
315
|
+
VerbTypeEnum[VerbTypeEnum["dependsOn"] = 8] = "dependsOn";
|
|
316
|
+
VerbTypeEnum[VerbTypeEnum["requires"] = 9] = "requires";
|
|
317
|
+
VerbTypeEnum[VerbTypeEnum["creates"] = 10] = "creates";
|
|
318
|
+
VerbTypeEnum[VerbTypeEnum["transforms"] = 11] = "transforms";
|
|
319
|
+
VerbTypeEnum[VerbTypeEnum["becomes"] = 12] = "becomes";
|
|
320
|
+
VerbTypeEnum[VerbTypeEnum["modifies"] = 13] = "modifies";
|
|
321
|
+
VerbTypeEnum[VerbTypeEnum["consumes"] = 14] = "consumes";
|
|
322
|
+
VerbTypeEnum[VerbTypeEnum["owns"] = 15] = "owns";
|
|
323
|
+
VerbTypeEnum[VerbTypeEnum["attributedTo"] = 16] = "attributedTo";
|
|
324
|
+
VerbTypeEnum[VerbTypeEnum["createdBy"] = 17] = "createdBy";
|
|
325
|
+
VerbTypeEnum[VerbTypeEnum["belongsTo"] = 18] = "belongsTo";
|
|
326
|
+
VerbTypeEnum[VerbTypeEnum["memberOf"] = 19] = "memberOf";
|
|
327
|
+
VerbTypeEnum[VerbTypeEnum["worksWith"] = 20] = "worksWith";
|
|
328
|
+
VerbTypeEnum[VerbTypeEnum["friendOf"] = 21] = "friendOf";
|
|
329
|
+
VerbTypeEnum[VerbTypeEnum["follows"] = 22] = "follows";
|
|
330
|
+
VerbTypeEnum[VerbTypeEnum["likes"] = 23] = "likes";
|
|
331
|
+
VerbTypeEnum[VerbTypeEnum["reportsTo"] = 24] = "reportsTo";
|
|
332
|
+
VerbTypeEnum[VerbTypeEnum["supervises"] = 25] = "supervises";
|
|
333
|
+
VerbTypeEnum[VerbTypeEnum["mentors"] = 26] = "mentors";
|
|
334
|
+
VerbTypeEnum[VerbTypeEnum["communicates"] = 27] = "communicates";
|
|
335
|
+
VerbTypeEnum[VerbTypeEnum["describes"] = 28] = "describes";
|
|
336
|
+
VerbTypeEnum[VerbTypeEnum["defines"] = 29] = "defines";
|
|
337
|
+
VerbTypeEnum[VerbTypeEnum["categorizes"] = 30] = "categorizes";
|
|
338
|
+
VerbTypeEnum[VerbTypeEnum["measures"] = 31] = "measures";
|
|
339
|
+
VerbTypeEnum[VerbTypeEnum["evaluates"] = 32] = "evaluates";
|
|
340
|
+
VerbTypeEnum[VerbTypeEnum["uses"] = 33] = "uses";
|
|
341
|
+
VerbTypeEnum[VerbTypeEnum["implements"] = 34] = "implements";
|
|
342
|
+
VerbTypeEnum[VerbTypeEnum["extends"] = 35] = "extends";
|
|
343
|
+
VerbTypeEnum[VerbTypeEnum["inherits"] = 36] = "inherits";
|
|
344
|
+
VerbTypeEnum[VerbTypeEnum["conflicts"] = 37] = "conflicts";
|
|
345
|
+
VerbTypeEnum[VerbTypeEnum["synchronizes"] = 38] = "synchronizes";
|
|
346
|
+
VerbTypeEnum[VerbTypeEnum["competes"] = 39] = "competes";
|
|
347
|
+
})(VerbTypeEnum || (VerbTypeEnum = {}));
|
|
348
|
+
/**
|
|
349
|
+
* Total number of noun types (for array allocations)
|
|
350
|
+
*/
|
|
351
|
+
export const NOUN_TYPE_COUNT = 31;
|
|
352
|
+
/**
|
|
353
|
+
* Total number of verb types (for array allocations)
|
|
354
|
+
*/
|
|
355
|
+
export const VERB_TYPE_COUNT = 40;
|
|
356
|
+
/**
|
|
357
|
+
* Type utilities for O(1) conversions between string types and numeric indices
|
|
358
|
+
* Enables efficient fixed-size array operations and bitmap indexing
|
|
359
|
+
*/
|
|
360
|
+
export const TypeUtils = {
|
|
361
|
+
/**
|
|
362
|
+
* Get numeric index for a noun type
|
|
363
|
+
* @param type - NounType string (e.g., 'person')
|
|
364
|
+
* @returns Numeric index (0-30)
|
|
365
|
+
*/
|
|
366
|
+
getNounIndex: (type) => {
|
|
367
|
+
return NounTypeEnum[type];
|
|
368
|
+
},
|
|
369
|
+
/**
|
|
370
|
+
* Get numeric index for a verb type
|
|
371
|
+
* @param type - VerbType string (e.g., 'relatedTo')
|
|
372
|
+
* @returns Numeric index (0-39)
|
|
373
|
+
*/
|
|
374
|
+
getVerbIndex: (type) => {
|
|
375
|
+
return VerbTypeEnum[type];
|
|
376
|
+
},
|
|
377
|
+
/**
|
|
378
|
+
* Get noun type string from numeric index
|
|
379
|
+
* @param index - Numeric index (0-30)
|
|
380
|
+
* @returns NounType string or 'thing' as default
|
|
381
|
+
*/
|
|
382
|
+
getNounFromIndex: (index) => {
|
|
383
|
+
const entry = Object.entries(NounTypeEnum).find(([_, idx]) => idx === index);
|
|
384
|
+
return entry ? entry[0] : NounType.Thing;
|
|
385
|
+
},
|
|
386
|
+
/**
|
|
387
|
+
* Get verb type string from numeric index
|
|
388
|
+
* @param index - Numeric index (0-39)
|
|
389
|
+
* @returns VerbType string or 'relatedTo' as default
|
|
390
|
+
*/
|
|
391
|
+
getVerbFromIndex: (index) => {
|
|
392
|
+
const entry = Object.entries(VerbTypeEnum).find(([_, idx]) => idx === index);
|
|
393
|
+
return entry ? entry[0] : VerbType.RelatedTo;
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
/**
|
|
397
|
+
* Type-specific metadata for optimization hints
|
|
398
|
+
* Provides per-type configuration for bloom filters, chunking, and indexing
|
|
399
|
+
*/
|
|
400
|
+
export const TypeMetadata = {
|
|
401
|
+
person: { expectedFields: 10, bloomBits: 256, avgChunkSize: 100 },
|
|
402
|
+
organization: { expectedFields: 12, bloomBits: 256, avgChunkSize: 80 },
|
|
403
|
+
document: { expectedFields: 8, bloomBits: 256, avgChunkSize: 100 },
|
|
404
|
+
event: { expectedFields: 6, bloomBits: 128, avgChunkSize: 50 },
|
|
405
|
+
location: { expectedFields: 7, bloomBits: 128, avgChunkSize: 60 },
|
|
406
|
+
thing: { expectedFields: 5, bloomBits: 128, avgChunkSize: 50 },
|
|
407
|
+
concept: { expectedFields: 4, bloomBits: 128, avgChunkSize: 40 },
|
|
408
|
+
media: { expectedFields: 6, bloomBits: 128, avgChunkSize: 50 },
|
|
409
|
+
file: { expectedFields: 5, bloomBits: 128, avgChunkSize: 50 },
|
|
410
|
+
message: { expectedFields: 7, bloomBits: 128, avgChunkSize: 60 },
|
|
411
|
+
content: { expectedFields: 5, bloomBits: 128, avgChunkSize: 50 },
|
|
412
|
+
collection: { expectedFields: 4, bloomBits: 128, avgChunkSize: 40 },
|
|
413
|
+
dataset: { expectedFields: 6, bloomBits: 128, avgChunkSize: 50 },
|
|
414
|
+
product: { expectedFields: 8, bloomBits: 256, avgChunkSize: 70 },
|
|
415
|
+
service: { expectedFields: 7, bloomBits: 128, avgChunkSize: 60 },
|
|
416
|
+
user: { expectedFields: 9, bloomBits: 256, avgChunkSize: 80 },
|
|
417
|
+
task: { expectedFields: 6, bloomBits: 128, avgChunkSize: 50 },
|
|
418
|
+
project: { expectedFields: 8, bloomBits: 256, avgChunkSize: 70 },
|
|
419
|
+
process: { expectedFields: 5, bloomBits: 128, avgChunkSize: 50 },
|
|
420
|
+
state: { expectedFields: 3, bloomBits: 128, avgChunkSize: 30 },
|
|
421
|
+
role: { expectedFields: 4, bloomBits: 128, avgChunkSize: 40 },
|
|
422
|
+
topic: { expectedFields: 4, bloomBits: 128, avgChunkSize: 40 },
|
|
423
|
+
language: { expectedFields: 3, bloomBits: 128, avgChunkSize: 30 },
|
|
424
|
+
currency: { expectedFields: 3, bloomBits: 128, avgChunkSize: 30 },
|
|
425
|
+
measurement: { expectedFields: 4, bloomBits: 128, avgChunkSize: 40 },
|
|
426
|
+
hypothesis: { expectedFields: 6, bloomBits: 128, avgChunkSize: 50 },
|
|
427
|
+
experiment: { expectedFields: 7, bloomBits: 128, avgChunkSize: 60 },
|
|
428
|
+
contract: { expectedFields: 8, bloomBits: 256, avgChunkSize: 70 },
|
|
429
|
+
regulation: { expectedFields: 6, bloomBits: 128, avgChunkSize: 50 },
|
|
430
|
+
interface: { expectedFields: 5, bloomBits: 128, avgChunkSize: 50 },
|
|
431
|
+
resource: { expectedFields: 5, bloomBits: 128, avgChunkSize: 50 }
|
|
432
|
+
};
|
|
261
433
|
//# sourceMappingURL=graphTypes.js.map
|
|
@@ -70,7 +70,6 @@ export declare class MetadataIndexManager {
|
|
|
70
70
|
private activeLocks;
|
|
71
71
|
private lockPromises;
|
|
72
72
|
private lockTimers;
|
|
73
|
-
private sparseIndices;
|
|
74
73
|
private chunkManager;
|
|
75
74
|
private chunkingStrategy;
|
|
76
75
|
private idMapper;
|
|
@@ -80,6 +79,12 @@ export declare class MetadataIndexManager {
|
|
|
80
79
|
* This must be called after construction and before any queries
|
|
81
80
|
*/
|
|
82
81
|
init(): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Warm the cache by preloading common field sparse indices (v3.44.1)
|
|
84
|
+
* This improves cache hit rates by loading frequently-accessed fields at startup
|
|
85
|
+
* Target: >80% cache hit rate for typical workloads
|
|
86
|
+
*/
|
|
87
|
+
warmCache(): Promise<void>;
|
|
83
88
|
/**
|
|
84
89
|
* Acquire an in-memory lock for coordinating concurrent metadata index writes
|
|
85
90
|
* Uses in-memory locks since MetadataIndexManager doesn't have direct file system access
|
|
@@ -122,15 +127,18 @@ export declare class MetadataIndexManager {
|
|
|
122
127
|
private saveSparseIndex;
|
|
123
128
|
/**
|
|
124
129
|
* Get IDs for a value using chunked sparse index with roaring bitmaps (v3.43.0)
|
|
130
|
+
* v3.44.1: Now fully lazy-loaded via UnifiedCache (no local sparseIndices Map)
|
|
125
131
|
*/
|
|
126
132
|
private getIdsFromChunks;
|
|
127
133
|
/**
|
|
128
134
|
* Get IDs for a range using chunked sparse index with zone maps and roaring bitmaps (v3.43.0)
|
|
135
|
+
* v3.44.1: Now fully lazy-loaded via UnifiedCache (no local sparseIndices Map)
|
|
129
136
|
*/
|
|
130
137
|
private getIdsFromChunksForRange;
|
|
131
138
|
/**
|
|
132
139
|
* Get roaring bitmap for a field-value pair without converting to UUIDs (v3.43.0)
|
|
133
140
|
* This is used for fast multi-field intersection queries using hardware-accelerated bitmap AND
|
|
141
|
+
* v3.44.1: Now fully lazy-loaded via UnifiedCache (no local sparseIndices Map)
|
|
134
142
|
* @returns RoaringBitmap32 containing integer IDs, or null if no matches
|
|
135
143
|
*/
|
|
136
144
|
private getBitmapFromChunks;
|
|
@@ -155,10 +163,12 @@ export declare class MetadataIndexManager {
|
|
|
155
163
|
}>): Promise<string[]>;
|
|
156
164
|
/**
|
|
157
165
|
* Add value-ID mapping to chunked index
|
|
166
|
+
* v3.44.1: Now fully lazy-loaded via UnifiedCache (no local sparseIndices Map)
|
|
158
167
|
*/
|
|
159
168
|
private addToChunkedIndex;
|
|
160
169
|
/**
|
|
161
170
|
* Remove ID from chunked index
|
|
171
|
+
* v3.44.1: Now fully lazy-loaded via UnifiedCache (no local sparseIndices Map)
|
|
162
172
|
*/
|
|
163
173
|
private removeFromChunkedIndex;
|
|
164
174
|
/**
|
|
@@ -275,11 +285,14 @@ export declare class MetadataIndexManager {
|
|
|
275
285
|
getCountForCriteria(field: string, value: any): Promise<number>;
|
|
276
286
|
/**
|
|
277
287
|
* Get index statistics with enhanced counting information
|
|
288
|
+
* v3.44.1: Sparse indices now lazy-loaded via UnifiedCache
|
|
289
|
+
* Note: This method may load sparse indices to calculate stats
|
|
278
290
|
*/
|
|
279
291
|
getStats(): Promise<MetadataIndexStats>;
|
|
280
292
|
/**
|
|
281
293
|
* Rebuild entire index from scratch using pagination
|
|
282
294
|
* Non-blocking version that yields control back to event loop
|
|
295
|
+
* v3.44.1: Sparse indices now lazy-loaded via UnifiedCache (no need to clear Map)
|
|
283
296
|
*/
|
|
284
297
|
rebuild(): Promise<void>;
|
|
285
298
|
/**
|