@delali/narsil 0.2.4-next.50 → 0.2.4-next.52

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.
Files changed (55) hide show
  1. package/README.md +27 -25
  2. package/dist/{capabilities-JrVQOwi4.d.ts → capabilities-CuTSXvbN.d.ts} +2 -2
  3. package/dist/{chunk-BEIK3EOZ.mjs → chunk-2FO7KZ6K.mjs} +5468 -3837
  4. package/dist/{chunk-XE6XR2OE.mjs → chunk-3GWP2TO6.mjs} +1 -1
  5. package/dist/{chunk-KMMJMDUA.mjs → chunk-3L4U6EJQ.mjs} +15 -10
  6. package/dist/{chunk-MHE7YWAU.mjs → chunk-72AXTIBW.mjs} +2 -2
  7. package/dist/{chunk-CV5H7XL7.mjs → chunk-EY2ULUMT.mjs} +30 -7
  8. package/dist/chunk-IFBKLBGB.mjs +7 -0
  9. package/dist/{chunk-WYJXSLER.mjs → chunk-POWOTUKJ.mjs} +7 -1
  10. package/dist/chunk-T62YOSGS.mjs +4280 -0
  11. package/dist/chunk-U36IDJN7.mjs +366 -0
  12. package/dist/{chunk-ND34I3SV.mjs → chunk-ULJ36FK4.mjs} +3502 -2383
  13. package/dist/{chunk-RP23PWMV.mjs → chunk-WFKIGEBY.mjs} +3 -3
  14. package/dist/{chunk-CMVG2UEF.mjs → chunk-WM7IS45M.mjs} +55 -517
  15. package/dist/chunk-Y3L5MDRV.mjs +96 -0
  16. package/dist/{chunk-ZHUQKZBE.mjs → chunk-YPYULM5E.mjs} +20 -4
  17. package/dist/chunk-ZJ4CSAB2.mjs +13 -0
  18. package/dist/chunk-ZT5BRDFW.mjs +513 -0
  19. package/dist/{client-CBOVHdjp.d.ts → client-BMJWVxOP.d.ts} +5 -5
  20. package/dist/client.d.ts +8 -8
  21. package/dist/{config-OON7IJ_B.d.ts → config-BcYZkdMw.d.ts} +2 -2
  22. package/dist/{config-Czh2YNDi.d.ts → config-qMLpi5T4.d.ts} +2 -2
  23. package/dist/direct-executor-UJC36S2D.mjs +12 -0
  24. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  25. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  26. package/dist/distribution.d.ts +8 -8
  27. package/dist/distribution.mjs +30 -15
  28. package/dist/{engine-9PtFY50q.d.ts → engine-zhms1qId.d.ts} +2 -2
  29. package/dist/index.browser.mjs +12845 -7766
  30. package/dist/index.d.ts +9 -21
  31. package/dist/index.mjs +13 -12
  32. package/dist/{memory-Bzd5xcEW.d.ts → memory-OmgkX_Z2.d.ts} +11 -1
  33. package/dist/persistence/durability/checkpoint-worker.d.ts +138 -3
  34. package/dist/persistence/durability/checkpoint-worker.mjs +31 -17
  35. package/dist/react.d.ts +6 -6
  36. package/dist/{schema-BqRx9t4E.d.ts → schema-OSWaaZzx.d.ts} +30 -6
  37. package/dist/serialization/crc32-worker.mjs +2 -1
  38. package/dist/server.d.ts +10 -10
  39. package/dist/server.mjs +80 -36
  40. package/dist/simd-DW5AtJ6B.d.ts +41 -0
  41. package/dist/{tasks-Bn4R1NPN.d.ts → tasks-DiF1c9v2.d.ts} +20 -1
  42. package/dist/{thread-PZLEO6JL.mjs → thread-TLCX43WV.mjs} +129 -41
  43. package/dist/{types-DXPxaXPO.d.ts → types-LEzMyjVX.d.ts} +1 -1
  44. package/dist/vector/search-worker.d.ts +292 -128
  45. package/dist/vector/search-worker.mjs +70 -54
  46. package/dist/workers/entry.mjs +10 -7
  47. package/package.json +52 -31
  48. package/dist/brute-force-DbHYCTc3.d.ts +0 -8
  49. package/dist/chunk-CBLS46IE.mjs +0 -10
  50. package/dist/chunk-PIWKZPP7.mjs +0 -64
  51. package/dist/chunk-PMBHH44R.mjs +0 -492
  52. package/dist/chunk-X6YZO4MQ.mjs +0 -1572
  53. package/dist/direct-executor-OREXU72C.mjs +0 -12
  54. package/dist/vector/hnsw-build-worker.d.ts +0 -105
  55. package/dist/vector/hnsw-build-worker.mjs +0 -123
@@ -1,4 +1,20 @@
1
- import { V as VectorMetric } from '../brute-force-DbHYCTc3.js';
1
+ import { d as VectorQuantizationMode } from '../schema-OSWaaZzx.js';
2
+ import { A as ArenaSimd } from '../simd-DW5AtJ6B.js';
3
+ import '../adapters-79OIa4xm.js';
4
+
5
+ /**
6
+ * Similarity metric a vector search ranks by.
7
+ *
8
+ * @internal
9
+ */
10
+ type VectorMetric = 'cosine' | 'dotProduct' | 'euclidean';
11
+
12
+ /**
13
+ * Each dimension of a document code holds this many bits.
14
+ *
15
+ * @internal
16
+ */
17
+ type OsqBits = 1 | 2 | 4 | 8;
2
18
 
3
19
  /**
4
20
  * A filter over store ordinals, one bit per ordinal, with the number of set
@@ -18,74 +34,199 @@ interface OrdinalFilter {
18
34
  }
19
35
 
20
36
  /**
21
- * Every stored vector in the form the engine hands to another thread.
37
+ * This buffer grows in place, so a typed array built over it without an
38
+ * explicit length reports the new length after every growth, on every thread
39
+ * that holds it.
22
40
  *
23
41
  * @internal
24
42
  */
25
- interface VectorStoreSnapshot {
26
- /** Each vector carries this many components. */
43
+ type GrowableBuffer = SharedArrayBuffer | ArrayBuffer;
44
+
45
+ /**
46
+ * This geometry gives the byte offset of every region inside one block. A
47
+ * block begins with one query scratch for each thread slot, and the slots
48
+ * follow them, each holding one record of a fixed stride.
49
+ *
50
+ * @internal
51
+ */
52
+ interface BlockGeometry {
53
+ /** Each thread's query scratch spans this many bytes. */
54
+ scratchStride: number;
55
+ /** The slots start at this byte offset. */
56
+ slotsOffset: number;
57
+ /** Each slot spans this many bytes. */
58
+ slotStride: number;
59
+ /** The block holds this many slots at most. */
60
+ capacity: number;
61
+ }
62
+ /**
63
+ * This is the geometry of a block holding float32 vectors, one per slot.
64
+ *
65
+ * @internal
66
+ */
67
+ interface VectorBlockLayout extends BlockGeometry {
68
+ /** Every vector of the field has this many components. */
27
69
  dimension: number;
28
- /** The store spans this many ordinals, deleted ones included. */
29
- slots: number;
30
- /** This holds every vector end to end, `slots * dimension` components long. */
31
- vectors: Float32Array;
32
- /** Each ordinal's vector length, so a reader need not recompute it. */
33
- magnitudes: Float64Array;
34
- /** The document at each ordinal, `null` where the ordinal holds none. */
35
- docIds: Array<string | null>;
70
+ }
71
+ /**
72
+ * One block keeps its bytes in a shared WebAssembly memory that every thread
73
+ * binds the distance kernels to, in a private WebAssembly memory where the
74
+ * runtime shares no memory, or in plain bytes where the runtime offers no
75
+ * WebAssembly.
76
+ *
77
+ * @internal
78
+ */
79
+ type VectorBlockStorage = {
80
+ kind: 'shared-memory';
81
+ memory: WebAssembly.Memory;
82
+ } | {
83
+ kind: 'private-memory';
84
+ simd: ArenaSimd;
85
+ } | {
86
+ kind: 'bytes';
87
+ buffer: GrowableBuffer;
88
+ };
89
+ /**
90
+ * This handle names one block of a field, which every thread holding the
91
+ * field opens on its own side.
92
+ *
93
+ * @internal
94
+ */
95
+ interface VectorBlockHandle<Layout extends BlockGeometry = BlockGeometry> {
96
+ /** The block follows this layout. */
97
+ layout: Layout;
98
+ /** The block keeps its bytes here. */
99
+ storage: VectorBlockStorage;
100
+ }
101
+
102
+ /**
103
+ * This is the geometry of a block holding one code record per slot: the packed code
104
+ * with its lower, upper, correction, and sum inline, so a comparison reads
105
+ * one contiguous record. Each thread's scratch holds one staged query.
106
+ *
107
+ * @internal
108
+ */
109
+ interface VectorCodeBlockLayout extends BlockGeometry {
110
+ /** Every vector of the field has this many components. */
111
+ dimension: number;
112
+ /** Each level of a document code holds this many bits. */
113
+ bits: OsqBits;
114
+ /** Each level of a query code holds this many bits. */
115
+ queryBits: OsqBits;
116
+ /** A packed document code spans this many bytes. */
117
+ codeBytes: number;
118
+ /** A staged query spans this many bytes. */
119
+ queryBytes: number;
36
120
  }
37
121
 
38
122
  /**
39
- * The two constants a scalar quantizer turns a vector component into a byte
40
- * with, and turns that byte back into a distance with.
123
+ * A thread opens these handles so that it can read one field's vectors,
124
+ * codes, and document ids in place. They name the blocks holding the vectors,
125
+ * the blocks holding the code records, the side tables that hold one entry
126
+ * per ordinal, and the checkpoint files that hold the vectors of the
127
+ * ordinals a field on disk has released from memory.
41
128
  *
42
- * A worker holding a copy of a vector field receives these rather than deriving
43
- * its own, because a copy taken after a delete would otherwise measure a
44
- * narrower range of values and answer the same query differently from the
45
- * thread that built the index.
129
+ * The main thread appends ordinals, and because the tables grow in place, a
130
+ * thread that opened the handles once goes on reading the current state.
131
+ * Adding a block, releasing one, or adding a file is a structural change, so
132
+ * the main thread bumps the layout revision and sends the handles again.
46
133
  *
47
134
  * @internal
48
135
  */
49
- interface ScalarQuantizerCalibration {
50
- /** Each step of the byte scale spans this much of the component range. */
51
- alpha: number;
52
- /** The byte scale starts at this component value. */
53
- offset: number;
136
+ interface SharedVectorStoreHandles {
137
+ /** Every vector of the field has this many components. */
138
+ dimension: number;
139
+ /** Each level of a document code holds this many bits, and null where the field keeps no codes. */
140
+ codeBits: OsqBits | null;
141
+ /** Every float block of the field follows this layout. */
142
+ layout: VectorBlockLayout;
143
+ /** Every code block of the field follows this layout, and null where the field keeps no codes. */
144
+ codeLayout: VectorCodeBlockLayout | null;
145
+ /** The main thread raises this on every structural change, so a thread compares it against what it opened. */
146
+ layoutRevision: number;
147
+ /** Every thread reads these counters through atomics. */
148
+ header: Int32Array;
149
+ /** These blocks hold the vectors, in ordinal order, with null where the store released a block to disk or never filled it. */
150
+ blocks: Array<VectorBlockHandle<VectorBlockLayout> | null>;
151
+ /** These blocks hold the code records, in ordinal order. */
152
+ codeBlocks: VectorBlockHandle<VectorCodeBlockLayout>[];
153
+ /** These are the paths of the checkpoint files holding vectors, with an empty string where no ordinal reads a file any more. */
154
+ vectorFiles: string[];
155
+ /** This holds each ordinal's vector magnitude. */
156
+ magnitudes: GrowableBuffer;
157
+ /** This holds one byte per ordinal, which reads 1 where the ordinal holds a live vector. */
158
+ present: GrowableBuffer;
159
+ /** This holds each ordinal's partition, or a negative marker where the store knows none. */
160
+ partitions: GrowableBuffer;
161
+ /** This holds every document id, UTF-8 encoded end to end in ordinal order. */
162
+ docIdBytes: GrowableBuffer;
163
+ /** This holds the byte each ordinal's id starts at, with one closing offset after the last. */
164
+ docIdOffsets: GrowableBuffer;
165
+ /** This holds one byte per ordinal, which reads 1 where the ordinal holds a code record. */
166
+ codePresent: GrowableBuffer;
167
+ /** This holds the index into `vectorFiles` of the file holding each ordinal's vector, or -1 where a block holds it. */
168
+ diskFile: GrowableBuffer;
169
+ /** This holds the byte offset of each ordinal's vector inside its file. */
170
+ diskOffset: GrowableBuffer;
171
+ /** This holds the centroid the quantizer takes every code against. */
172
+ centroid: Float32Array;
54
173
  }
55
174
 
56
175
  /**
57
- * Every node's neighbours in the flat form the engine hands to another thread.
176
+ * The engine clones a field's vectors to another thread in this form, which
177
+ * it uses where the runtime shares no memory between threads.
58
178
  *
59
179
  * @internal
60
180
  */
61
- interface AdjacencySnapshot {
62
- /** Each node keeps this many neighbours per layer above the base. */
63
- m: number;
64
- /** Each node keeps this many neighbours on the base layer. */
65
- mMax0: number;
66
- /** The arrays span this many ordinals. */
67
- capacity: number;
68
- /** No node sits at an ordinal at or above this. */
181
+ interface VectorStoreSnapshot {
182
+ /** Every vector of the field has this many components. */
183
+ dimension: number;
184
+ /** The store spans this many ordinals, deleted ones included. */
69
185
  slots: number;
70
- /** The upper-layer arena holds this many entries in use. */
71
- upperUsed: number;
72
- /** Each ordinal's top layer, or -1 where no node sits there. */
73
- nodeLevels: Int8Array;
74
- /** The base layer's neighbours, a count followed by neighbours per ordinal. */
75
- level0: Int32Array;
76
- /** Where each ordinal's upper layers start, or -1 where it has none. */
77
- upperBase: Int32Array;
78
- /** Every upper layer's neighbours, a count followed by neighbours per layer. */
79
- upper: Int32Array;
186
+ /** This holds every vector end to end, `slots * dimension` components long. */
187
+ vectors: Float32Array;
188
+ /** This holds each ordinal's vector length, so a reader takes it from here. */
189
+ magnitudes: Float64Array;
190
+ /** This names the document at each ordinal, and it reads `null` where the ordinal holds none. */
191
+ docIds: Array<string | null>;
192
+ }
193
+
194
+ /**
195
+ * A thread opens these handles so that it can search or extend one graph in
196
+ * place. They name the counters every thread reads through atomics, the
197
+ * adjacency arrays that grow without moving, the lock word of every node, and
198
+ * the record of the locks each thread holds, which the main thread reads to
199
+ * release what a dead thread left behind.
200
+ *
201
+ * @internal
202
+ */
203
+ interface SharedGraphHandles {
204
+ /** This holds the entry point, the layer count, the node counts, the arena cursor, and the graph's shape. */
205
+ header: Int32Array;
206
+ /** This holds each ordinal's top layer plus one, and it reads zero where the graph holds no node there. */
207
+ nodeLevels: GrowableBuffer;
208
+ /** This holds the base layer's neighbours, a count followed by that many neighbours for each ordinal. */
209
+ level0: GrowableBuffer;
210
+ /** This holds where each ordinal's upper layers start plus one, and it reads zero where the ordinal reaches none. */
211
+ upperBase: GrowableBuffer;
212
+ /** This holds every upper layer's neighbours, a count followed by that many neighbours for each layer. */
213
+ upper: GrowableBuffer;
214
+ /** This holds one lock word per ordinal. */
215
+ locks: GrowableBuffer;
216
+ /** This holds one byte per ordinal, which reads 1 once a caller removes the document. */
217
+ tombstones: GrowableBuffer;
218
+ /** This records the node lock and the graph lock each thread slot holds right now. */
219
+ heldLocks: Int32Array;
80
220
  }
81
221
 
82
222
  /**
83
- * A built graph in the form the engine hands to another thread.
223
+ * This holds a built graph copied out flat, which the engine sends to another
224
+ * thread where the runtime shares no memory.
84
225
  *
85
226
  * @internal
86
227
  */
87
228
  interface HNSWSnapshot {
88
- /** Each vector carries this many components. */
229
+ /** Every vector of the field has this many components. */
89
230
  dimension: number;
90
231
  /** Each node keeps this many neighbours per layer. */
91
232
  m: number;
@@ -93,16 +234,24 @@ interface HNSWSnapshot {
93
234
  efConstruction: number;
94
235
  /** The graph ranks by this metric. */
95
236
  metric: VectorMetric;
96
- /** This holds every node's neighbours, laid out flat. */
97
- adjacency: AdjacencySnapshot;
98
- /** A byte per ordinal, set to 1 where the document has been deleted. */
237
+ /** Every node of the graph lies below this ordinal. */
238
+ slots: number;
239
+ /** The upper-layer arena holds this many entries in use. */
240
+ upperUsed: number;
241
+ /** This holds each ordinal's top layer plus one, and it reads zero where the graph holds no node there. */
242
+ nodeLevels: Uint8Array;
243
+ /** This holds the base layer's neighbours, a count followed by that many neighbours for each ordinal. */
244
+ level0: Int32Array;
245
+ /** This holds where each ordinal's upper layers start plus one, and it reads zero where the ordinal reaches none. */
246
+ upperBase: Int32Array;
247
+ /** This holds every upper layer's neighbours, a count followed by that many neighbours for each layer. */
248
+ upper: Int32Array;
249
+ /** This holds one byte per ordinal, which reads 1 once a caller removes the document. */
99
250
  tombstones: Uint8Array;
100
- /** This many ordinals are tombstoned. */
251
+ /** The graph holds this many tombstoned ordinals. */
101
252
  tombstoneCount: number;
102
253
  /** The graph holds this many nodes, tombstoned ones included. */
103
254
  nodeCount: number;
104
- /** The graph's own arrays span this many ordinals. */
105
- capacity: number;
106
255
  /** Every search starts at this ordinal, and it is -1 while the graph is empty. */
107
256
  entryPointOrd: number;
108
257
  /** The graph reaches this many layers. */
@@ -110,93 +259,76 @@ interface HNSWSnapshot {
110
259
  }
111
260
 
112
261
  /**
113
- * Where each region of a frozen generation sits inside its shared memory.
262
+ * A thread opens these handles so that it can search one vector field in
263
+ * place and place vectors in its graph, and they name the store's shared
264
+ * structures alongside the graph's.
114
265
  *
115
- * The memory opens with one float32 query scratch slot and one code query
116
- * scratch slot per worker, so concurrent searches never write over each
117
- * other, followed by the float32 vector arena and the quantised code arena.
266
+ * The main thread sends them once, and again only when a block joins the
267
+ * store or a fresh graph replaces the old one, because every other change
268
+ * grows the shared buffers in place.
118
269
  *
119
270
  * @internal
120
271
  */
121
- interface SharedGenerationLayout {
122
- /** Each vector carries this many components. */
272
+ interface SharedVectorFieldHandles {
273
+ /** Every vector of the field has this many components. */
123
274
  dimension: number;
124
- /** The arenas span this many ordinals. */
125
- slots: number;
126
- /** The memory holds this many per-worker scratch slot pairs. */
127
- workerSlots: number;
128
- /** Each worker's float32 query scratch spans this many bytes. */
129
- float32ScratchStride: number;
130
- /** Each worker's code query scratch spans this many bytes. */
131
- codeScratchStride: number;
132
- /** The code query scratch slots start at this byte offset. */
133
- codeScratchOffset: number;
134
- /** The float32 vector arena starts at this byte offset. */
135
- vectorsOffset: number;
136
- /** The quantised code arena starts at this byte offset. */
137
- codesOffset: number;
138
- /** The memory spans this many bytes, a whole number of pages. */
139
- totalBytes: number;
275
+ /** The threads estimate distances from code records under any mode but `none`. */
276
+ quantization: VectorQuantizationMode;
277
+ /** The quantizer takes the codes under this metric, which the graph also ranks by. */
278
+ metric: VectorMetric;
279
+ /** These are the store's shared structures. */
280
+ store: SharedVectorStoreHandles;
281
+ /** These are the graph's shared structures, and they read null while the field answers by exact comparison. */
282
+ graph: SharedGraphHandles | null;
283
+ /** A thread answers by exact comparison where a filter admits a smaller share of the live vectors than this. */
284
+ filterThreshold: number;
285
+ /** This reads true where searches on the thread answer from the graph, and false while the threads build it. */
286
+ searchable: boolean;
140
287
  }
141
288
  /**
142
- * One frozen copy of a vector field, shared across every search thread.
143
- *
144
- * The typed arrays are views over shared buffers, so posting this to a worker
145
- * hands over the same bytes rather than a copy, and nothing in it is written
146
- * after the freeze apart from the per-worker scratch slots inside `memory`.
289
+ * A thread reports this after placing a batch of vectors in a graph.
147
290
  *
148
291
  * @internal
149
292
  */
150
- interface SharedGenerationSnapshot {
151
- /** Each vector carries this many components. */
152
- dimension: number;
153
- /** The workers compute quantised distances when this reads `sq8`. */
154
- quantization: 'sq8' | 'none';
155
- /** The constants every code was derived with, present when quantised. */
156
- calibration: ScalarQuantizerCalibration | null;
157
- /** The shared memory holding the scratch slots and both arenas. */
158
- memory: WebAssembly.Memory;
159
- /** Where each region sits inside the shared memory. */
160
- layout: SharedGenerationLayout;
161
- /** Each ordinal's vector magnitude. */
162
- magnitudes: Float64Array;
163
- /** Each ordinal's code sum, present when quantised. */
164
- codeSums: Float64Array;
165
- /** Each ordinal's reconstructed code magnitude, present when quantised. */
166
- codeMagnitudes: Float64Array;
167
- /** A byte per ordinal, 1 where codes exist, present when quantised. */
168
- codePresent: Uint8Array;
169
- /** The built graph, its arrays backed by shared buffers. */
170
- graph: HNSWSnapshot;
171
- /**
172
- * Each ordinal's document id rank in code point order, or
173
- * the absent-document rank where the ordinal holds no document.
174
- */
175
- rankByOrdinal: Uint32Array;
293
+ interface GraphInsertOutcome {
294
+ /** The thread placed this many vectors the graph did not hold before. */
295
+ placed: number;
176
296
  }
177
297
 
178
298
  /**
179
- * One vector field's searchable state in the form the engine clones to a
180
- * worker, used where the runtime cannot share memory.
299
+ * The code records of one field copied out flat, which the engine sends to
300
+ * a worker that shares no memory with it.
301
+ *
302
+ * @internal
303
+ */
304
+ interface WorkerCopyCodes {
305
+ /** The centroid the quantizer takes every record against. */
306
+ centroid: Float32Array;
307
+ /** This holds one record per ordinal, end to end. */
308
+ records: Uint8Array;
309
+ /** This holds one byte per ordinal, which reads 1 where the ordinal holds a record. */
310
+ present: Uint8Array;
311
+ }
312
+ /**
313
+ * The engine clones one vector field's searchable state to a worker in this
314
+ * form, which it uses where the runtime shares no memory.
181
315
  *
182
316
  * @internal
183
317
  */
184
318
  interface WorkerCopySnapshot {
185
- /** Each vector carries this many components. */
319
+ /** Every vector of the field has this many components. */
186
320
  dimension: number;
187
- /** The worker rebuilds a quantizer when this reads `sq8`. */
188
- quantization: 'sq8' | 'none';
189
- /**
190
- * The constants the calling thread quantizes with, carried so that the worker
191
- * derives the same codes rather than recalibrating over a set that a delete
192
- * has already narrowed.
193
- */
194
- calibration: ScalarQuantizerCalibration | null;
321
+ /** The worker estimates from code records under any mode but `none`. */
322
+ quantization: VectorQuantizationMode;
323
+ /** The quantizer takes the codes under this metric. */
324
+ metric: VectorMetric;
325
+ /** The records the calling thread wrote, so the worker rewrites none, or null where the field holds no codes. */
326
+ codes: WorkerCopyCodes | null;
195
327
  /** This holds every vector and the document id at each ordinal. */
196
328
  store: VectorStoreSnapshot;
197
329
  /** This holds the built graph. */
198
330
  graph: HNSWSnapshot;
199
- /** These documents have been deleted and must not be returned. */
331
+ /** The worker leaves these deleted documents out of every result. */
200
332
  tombstones: string[];
201
333
  }
202
334
 
@@ -220,21 +352,21 @@ interface VectorLoadRequest {
220
352
  snapshot: WorkerCopySnapshot;
221
353
  }
222
354
  /**
223
- * Asks the search worker to open a frozen shared copy under a handle.
355
+ * Asks the search worker to open a field in place under a handle.
224
356
  *
225
357
  * @internal
226
358
  */
227
- interface SharedCopyLoadRequest {
228
- /** This marks the message as a shared copy load. */
359
+ interface SharedFieldLoadRequest {
360
+ /** This marks the message as a shared field load. */
229
361
  type: 'loadShared';
230
362
  /** The reply carries this back so the engine can match it to its caller. */
231
363
  requestId: string;
232
- /** Later messages name the copy by this handle. */
364
+ /** Later messages name the field by this handle. */
233
365
  handle: string;
234
366
  /** The worker writes query scratch into this reserved slot alone. */
235
367
  scratchSlot: number;
236
- /** The frozen copy, its buffers shared rather than cloned. */
237
- snapshot: SharedGenerationSnapshot;
368
+ /** These are the field's shared structures. */
369
+ handles: SharedVectorFieldHandles;
238
370
  }
239
371
  /**
240
372
  * Asks the search worker to release a copy it holds.
@@ -249,6 +381,21 @@ interface VectorDropRequest {
249
381
  /** The worker releases the copy held under this handle. */
250
382
  handle: string;
251
383
  }
384
+ /**
385
+ * Asks the search worker to place vectors in the graph of a field it holds.
386
+ *
387
+ * @internal
388
+ */
389
+ interface VectorInsertRequest {
390
+ /** This marks the message as a graph insertion. */
391
+ type: 'insertOrdinals';
392
+ /** The reply carries this back so the engine can match it to its caller. */
393
+ requestId: string;
394
+ /** The worker places the vectors in the field held under this handle. */
395
+ handle: string;
396
+ /** The ordinals to place, whose vectors the shared store already holds. */
397
+ ordinals: Int32Array;
398
+ }
252
399
  /**
253
400
  * Asks the search worker to answer one nearest-neighbour query from a cloned
254
401
  * copy.
@@ -274,19 +421,21 @@ interface VectorSearchRequest {
274
421
  filter?: OrdinalFilter;
275
422
  /** The worker explores this many candidates, or its own default when absent. */
276
423
  efSearch?: number;
424
+ /** The worker re-scores this many times the requested count against full precision, or its own default when absent. */
425
+ oversample?: number;
277
426
  }
278
427
  /**
279
428
  * Asks the search worker to answer one nearest-neighbour query from a shared
280
- * copy, returning ordinals for the engine to map back to document ids.
429
+ * field, returning ordinals for the engine to map back to document ids.
281
430
  *
282
431
  * @internal
283
432
  */
284
433
  interface VectorOrdinalSearchRequest {
285
- /** This marks the message as a search over a shared copy. */
434
+ /** This marks the message as a search over a shared field. */
286
435
  type: 'searchOrdinals';
287
436
  /** The reply carries this back so the engine can match it to its caller. */
288
437
  requestId: string;
289
- /** The worker searches the copy held under this handle. */
438
+ /** The worker searches the field held under this handle. */
290
439
  handle: string;
291
440
  /** The worker ranks against this query vector. */
292
441
  query: Float32Array;
@@ -300,13 +449,15 @@ interface VectorOrdinalSearchRequest {
300
449
  filter?: OrdinalFilter;
301
450
  /** The worker explores this many candidates, or its own default when absent. */
302
451
  efSearch?: number;
452
+ /** The worker re-scores this many times the requested count against full precision, or its own default when absent. */
453
+ oversample?: number;
303
454
  }
304
455
  /**
305
456
  * Every message the engine posts to the search worker.
306
457
  *
307
458
  * @internal
308
459
  */
309
- type VectorWorkerRequest = VectorLoadRequest | SharedCopyLoadRequest | VectorDropRequest | VectorSearchRequest | VectorOrdinalSearchRequest;
460
+ type VectorWorkerRequest = VectorLoadRequest | SharedFieldLoadRequest | VectorDropRequest | VectorInsertRequest | VectorSearchRequest | VectorOrdinalSearchRequest;
310
461
  /**
311
462
  * What the search worker returns once a copy is loaded or released.
312
463
  *
@@ -320,6 +471,19 @@ interface VectorAckResponse {
320
471
  /** This names the copy the acknowledgement belongs to. */
321
472
  handle: string;
322
473
  }
474
+ /**
475
+ * The search worker returns this once it has placed a batch of vectors.
476
+ *
477
+ * @internal
478
+ */
479
+ interface VectorInsertResponse {
480
+ /** This marks the message as a completed insertion. */
481
+ type: 'inserted';
482
+ /** This matches the request the engine sent. */
483
+ requestId: string;
484
+ /** This is what the worker observed while placing the batch. */
485
+ outcome: GraphInsertOutcome;
486
+ }
323
487
  /**
324
488
  * What the search worker returns for a completed search over a cloned copy.
325
489
  *
@@ -336,7 +500,7 @@ interface VectorSearchResponse {
336
500
  scores: Float64Array;
337
501
  }
338
502
  /**
339
- * What the search worker returns for a completed search over a shared copy.
503
+ * The search worker returns this for a completed search over a shared field.
340
504
  *
341
505
  * @internal
342
506
  */
@@ -368,6 +532,6 @@ interface VectorWorkerError {
368
532
  *
369
533
  * @internal
370
534
  */
371
- type VectorWorkerMessage = VectorAckResponse | VectorSearchResponse | VectorOrdinalSearchResponse | VectorWorkerError;
535
+ type VectorWorkerMessage = VectorAckResponse | VectorInsertResponse | VectorSearchResponse | VectorOrdinalSearchResponse | VectorWorkerError;
372
536
 
373
- export { type AdjacencySnapshot, type HNSWSnapshot, type OrdinalFilter, type ScalarQuantizerCalibration, type SharedCopyLoadRequest, type SharedGenerationLayout, type SharedGenerationSnapshot, type VectorAckResponse, type VectorDropRequest, type VectorLoadRequest, VectorMetric, type VectorOrdinalSearchRequest, type VectorOrdinalSearchResponse, type VectorSearchRequest, type VectorSearchResponse, type VectorStoreSnapshot, type VectorWorkerError, type VectorWorkerMessage, type VectorWorkerRequest, type WorkerCopySnapshot };
537
+ export { ArenaSimd, type BlockGeometry, type GraphInsertOutcome, type GrowableBuffer, type HNSWSnapshot, type OrdinalFilter, type OsqBits, type SharedFieldLoadRequest, type SharedGraphHandles, type SharedVectorFieldHandles, type SharedVectorStoreHandles, type VectorAckResponse, type VectorBlockHandle, type VectorBlockLayout, type VectorBlockStorage, type VectorCodeBlockLayout, type VectorDropRequest, type VectorInsertRequest, type VectorInsertResponse, type VectorLoadRequest, type VectorMetric, type VectorOrdinalSearchRequest, type VectorOrdinalSearchResponse, type VectorSearchRequest, type VectorSearchResponse, type VectorStoreSnapshot, type VectorWorkerError, type VectorWorkerMessage, type VectorWorkerRequest, type WorkerCopyCodes, type WorkerCopySnapshot };