@soulcraft/brainy 0.37.0 → 0.38.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/README.md +710 -1642
- package/dist/brainyData.d.ts +37 -0
- package/dist/distributed/configManager.d.ts +97 -0
- package/dist/distributed/domainDetector.d.ts +77 -0
- package/dist/distributed/hashPartitioner.d.ts +77 -0
- package/dist/distributed/healthMonitor.d.ts +110 -0
- package/dist/distributed/index.d.ts +10 -0
- package/dist/distributed/operationalModes.d.ts +104 -0
- package/dist/types/distributedTypes.d.ts +197 -0
- package/dist/types/distributedTypes.d.ts.map +1 -0
- package/dist/unified.js +1383 -2
- package/dist/unified.min.js +991 -991
- package/dist/utils/crypto.d.ts +25 -0
- package/dist/utils/crypto.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Distributed types for Brainy
|
|
3
|
+
* Defines types for distributed operations across multiple instances
|
|
4
|
+
*/
|
|
5
|
+
export type InstanceRole = 'reader' | 'writer' | 'hybrid';
|
|
6
|
+
export type PartitionStrategy = 'hash' | 'semantic' | 'manual';
|
|
7
|
+
export interface DistributedConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Enable distributed mode
|
|
10
|
+
* Can be boolean for auto-detection or specific configuration
|
|
11
|
+
*/
|
|
12
|
+
enabled?: boolean | 'auto';
|
|
13
|
+
/**
|
|
14
|
+
* Role of this instance in the distributed system
|
|
15
|
+
* - reader: Read-only access, optimized for queries
|
|
16
|
+
* - writer: Write-focused, handles data ingestion
|
|
17
|
+
* - hybrid: Can both read and write (requires coordination)
|
|
18
|
+
*/
|
|
19
|
+
role?: InstanceRole;
|
|
20
|
+
/**
|
|
21
|
+
* Unique identifier for this instance
|
|
22
|
+
* Auto-generated if not provided
|
|
23
|
+
*/
|
|
24
|
+
instanceId?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Path to shared configuration file in S3
|
|
27
|
+
* Default: '_brainy/config.json'
|
|
28
|
+
*/
|
|
29
|
+
configPath?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Heartbeat interval in milliseconds
|
|
32
|
+
* Default: 30000 (30 seconds)
|
|
33
|
+
*/
|
|
34
|
+
heartbeatInterval?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Config check interval in milliseconds
|
|
37
|
+
* Default: 10000 (10 seconds)
|
|
38
|
+
*/
|
|
39
|
+
configCheckInterval?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Instance timeout in milliseconds
|
|
42
|
+
* Instances not seen for this duration are considered dead
|
|
43
|
+
* Default: 60000 (60 seconds)
|
|
44
|
+
*/
|
|
45
|
+
instanceTimeout?: number;
|
|
46
|
+
}
|
|
47
|
+
export interface SharedConfig {
|
|
48
|
+
/**
|
|
49
|
+
* Configuration version for compatibility checking
|
|
50
|
+
*/
|
|
51
|
+
version: number;
|
|
52
|
+
/**
|
|
53
|
+
* Last update timestamp
|
|
54
|
+
*/
|
|
55
|
+
updated: string;
|
|
56
|
+
/**
|
|
57
|
+
* Global settings that must be consistent across all instances
|
|
58
|
+
*/
|
|
59
|
+
settings: {
|
|
60
|
+
/**
|
|
61
|
+
* Partitioning strategy
|
|
62
|
+
* - hash: Deterministic hash-based partitioning (recommended for multi-writer)
|
|
63
|
+
* - semantic: Group similar vectors (single writer only)
|
|
64
|
+
* - manual: Explicit partition assignment
|
|
65
|
+
*/
|
|
66
|
+
partitionStrategy: PartitionStrategy;
|
|
67
|
+
/**
|
|
68
|
+
* Number of partitions (for hash strategy)
|
|
69
|
+
*/
|
|
70
|
+
partitionCount: number;
|
|
71
|
+
/**
|
|
72
|
+
* Embedding model name (must be consistent)
|
|
73
|
+
*/
|
|
74
|
+
embeddingModel: string;
|
|
75
|
+
/**
|
|
76
|
+
* Vector dimensions
|
|
77
|
+
*/
|
|
78
|
+
dimensions: number;
|
|
79
|
+
/**
|
|
80
|
+
* Distance metric
|
|
81
|
+
*/
|
|
82
|
+
distanceMetric: 'cosine' | 'euclidean' | 'manhattan';
|
|
83
|
+
/**
|
|
84
|
+
* HNSW parameters (must be consistent for index compatibility)
|
|
85
|
+
*/
|
|
86
|
+
hnswParams?: {
|
|
87
|
+
M: number;
|
|
88
|
+
efConstruction: number;
|
|
89
|
+
maxElements?: number;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Active instances in the distributed system
|
|
94
|
+
*/
|
|
95
|
+
instances: {
|
|
96
|
+
[instanceId: string]: InstanceInfo;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Partition assignments (for manual strategy)
|
|
100
|
+
*/
|
|
101
|
+
partitionAssignments?: {
|
|
102
|
+
[instanceId: string]: string[];
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export interface InstanceInfo {
|
|
106
|
+
/**
|
|
107
|
+
* Instance role
|
|
108
|
+
*/
|
|
109
|
+
role: InstanceRole;
|
|
110
|
+
/**
|
|
111
|
+
* Instance status
|
|
112
|
+
*/
|
|
113
|
+
status: 'active' | 'inactive' | 'unhealthy';
|
|
114
|
+
/**
|
|
115
|
+
* Last heartbeat timestamp
|
|
116
|
+
*/
|
|
117
|
+
lastHeartbeat: string;
|
|
118
|
+
/**
|
|
119
|
+
* Optional endpoint for health checks
|
|
120
|
+
*/
|
|
121
|
+
endpoint?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Instance metrics
|
|
124
|
+
*/
|
|
125
|
+
metrics?: {
|
|
126
|
+
vectorCount?: number;
|
|
127
|
+
cacheHitRate?: number;
|
|
128
|
+
memoryUsage?: number;
|
|
129
|
+
cpuUsage?: number;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Assigned partitions (for manual assignment)
|
|
133
|
+
*/
|
|
134
|
+
assignedPartitions?: string[];
|
|
135
|
+
/**
|
|
136
|
+
* Preferred partitions (for affinity)
|
|
137
|
+
*/
|
|
138
|
+
preferredPartitions?: number[];
|
|
139
|
+
}
|
|
140
|
+
export interface DomainMetadata {
|
|
141
|
+
/**
|
|
142
|
+
* Domain identifier for logical data separation
|
|
143
|
+
*/
|
|
144
|
+
domain?: string;
|
|
145
|
+
/**
|
|
146
|
+
* Additional domain-specific metadata
|
|
147
|
+
*/
|
|
148
|
+
domainMetadata?: Record<string, any>;
|
|
149
|
+
}
|
|
150
|
+
export interface CacheStrategy {
|
|
151
|
+
/**
|
|
152
|
+
* Percentage of memory allocated to hot cache (0-1)
|
|
153
|
+
*/
|
|
154
|
+
hotCacheRatio: number;
|
|
155
|
+
/**
|
|
156
|
+
* Enable aggressive prefetching
|
|
157
|
+
*/
|
|
158
|
+
prefetchAggressive?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Cache time-to-live in milliseconds
|
|
161
|
+
*/
|
|
162
|
+
ttl?: number;
|
|
163
|
+
/**
|
|
164
|
+
* Enable compression to trade CPU for memory
|
|
165
|
+
*/
|
|
166
|
+
compressionEnabled?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Write buffer size for batching
|
|
169
|
+
*/
|
|
170
|
+
writeBufferSize?: number;
|
|
171
|
+
/**
|
|
172
|
+
* Enable write batching
|
|
173
|
+
*/
|
|
174
|
+
batchWrites?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Adaptive caching based on workload
|
|
177
|
+
*/
|
|
178
|
+
adaptive?: boolean;
|
|
179
|
+
}
|
|
180
|
+
export interface OperationalMode {
|
|
181
|
+
/**
|
|
182
|
+
* Whether this mode can read
|
|
183
|
+
*/
|
|
184
|
+
canRead: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Whether this mode can write
|
|
187
|
+
*/
|
|
188
|
+
canWrite: boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Whether this mode can delete
|
|
191
|
+
*/
|
|
192
|
+
canDelete: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Cache strategy for this mode
|
|
195
|
+
*/
|
|
196
|
+
cacheStrategy: CacheStrategy;
|
|
197
|
+
}
|
|
@@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