pikelet-wasm 0.15.0 → 0.16.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 +184 -0
- package/FORMAT.md +2 -2
- package/README.md +9 -9
- package/complete/builder.d.ts +19 -1
- package/complete/builder.mjs +10 -2
- package/complete/fusion.mjs +17 -0
- package/complete/index.d.ts +17 -0
- package/complete/index.mjs +24 -12
- package/complete/layer-append.mjs +1 -1
- package/complete/layer-compact.mjs +1 -1
- package/complete/layer-manifest.mjs +2 -1
- package/complete/layer-reader.mjs +8 -2
- package/complete/sources.mjs +1 -1
- package/package.json +1 -5
- package/src/artifact/pikelet-artifact-common.js +27 -0
- package/src/artifact/pikelet-artifact-sketch.js +38 -26
- package/src/artifact/pikelet-artifact.d.ts +4 -29
- package/src/artifact/pikelet-artifact.js +5 -8
- package/src/pikelet.d.ts +2 -186
- package/src/pikelet.js +1 -9
- package/src/pikelet.node.mjs +1 -9
- package/src/pikelet.web.d.ts +0 -8
- package/src/pikelet.web.mjs +1 -2
- package/src/pikelet.workerd.mjs +1 -2
- package/src/artifact/pikelet-artifact-range.js +0 -806
|
@@ -462,6 +462,32 @@ async function sha256BytesAsync(bytes) {
|
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
464
|
|
|
465
|
+
// Node's synchronous createHash, resolved once; null where require('crypto')
|
|
466
|
+
// is unavailable (browsers, bundles that stub it).
|
|
467
|
+
let nodeCreateHash;
|
|
468
|
+
function syncCreateHash() {
|
|
469
|
+
if (nodeCreateHash === undefined) {
|
|
470
|
+
nodeCreateHash = null;
|
|
471
|
+
try {
|
|
472
|
+
const c = require('crypto');
|
|
473
|
+
if (c && typeof c.createHash === 'function') nodeCreateHash = c.createHash;
|
|
474
|
+
} catch { /* fall back to crypto.subtle */ }
|
|
475
|
+
}
|
|
476
|
+
return nodeCreateHash;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// Digests of many small inputs, such as one query's rerank rows and their
|
|
480
|
+
// digest pages. Each crypto.subtle.digest call is an async round trip
|
|
481
|
+
// (~0.1 ms in Node), so awaiting a few hundred of them in turn cost more
|
|
482
|
+
// than the rest of the query. Where Node's createHash is reachable the
|
|
483
|
+
// inputs are hashed synchronously; elsewhere the subtle calls are issued
|
|
484
|
+
// together. An entry is null when no crypto backend exists.
|
|
485
|
+
async function sha256ManyAsync(inputs) {
|
|
486
|
+
const createHash = syncCreateHash();
|
|
487
|
+
if (createHash) return inputs.map((b) => new Uint8Array(createHash('sha256').update(b).digest()));
|
|
488
|
+
return Promise.all(inputs.map((b) => sha256BytesAsync(b)));
|
|
489
|
+
}
|
|
490
|
+
|
|
465
491
|
// Read-through cache for bytes a pack commits to by sha256: the whole
|
|
466
492
|
// regions a mount reads (the sketch's resident prefix, a pack's query-interp
|
|
467
493
|
// segment) and the pieces a query reads (rerank rows, corpus records, the
|
|
@@ -592,6 +618,7 @@ module.exports = {
|
|
|
592
618
|
parseUint8Snapshot,
|
|
593
619
|
sha256Bytes,
|
|
594
620
|
sha256BytesAsync,
|
|
621
|
+
sha256ManyAsync,
|
|
595
622
|
blobCacheGet,
|
|
596
623
|
blobCachePut,
|
|
597
624
|
verifySha256,
|
|
@@ -17,6 +17,7 @@ const {
|
|
|
17
17
|
parseUint8Snapshot,
|
|
18
18
|
sha256Bytes,
|
|
19
19
|
sha256BytesAsync,
|
|
20
|
+
sha256ManyAsync,
|
|
20
21
|
blobCacheGet,
|
|
21
22
|
blobCachePut,
|
|
22
23
|
verifySegmentSha256,
|
|
@@ -852,42 +853,53 @@ class PikeletSketchArtifact {
|
|
|
852
853
|
this.rangeBytes += length;
|
|
853
854
|
return { r, bytes };
|
|
854
855
|
});
|
|
856
|
+
const pages = [];
|
|
857
|
+
const fetched = [];
|
|
855
858
|
for (const { r, bytes } of buffers) {
|
|
856
859
|
for (const b of r.blocks) {
|
|
857
860
|
const rel = vectorsOffset + b * blockBytes - r.start;
|
|
858
861
|
const page = bytes.subarray(rel, rel + pageBytes);
|
|
859
|
-
|
|
860
|
-
const pageDigest = await sha256BytesAsync(page);
|
|
861
|
-
if (!pageDigest) {
|
|
862
|
-
throw pikeletError(PIKELET_ERROR_CODES.SNAPSHOT_INVALID,
|
|
863
|
-
'Sketch artifact row verification requested but no crypto backend is available; pass verify:false to skip');
|
|
864
|
-
}
|
|
865
|
-
const expected = this.pageTable.subarray(b * 32, b * 32 + 32);
|
|
866
|
-
for (let i = 0; i < 32; i++) {
|
|
867
|
-
if (pageDigest[i] !== expected[i]) {
|
|
868
|
-
throw pikeletError(PIKELET_ERROR_CODES.SNAPSHOT_INVALID, 'Sketch artifact row digest page failed hash verification', { block: b });
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
if (cache) blobCachePut(cache, hexOf(expected), page.slice());
|
|
872
|
-
}
|
|
862
|
+
pages.push({ b, page });
|
|
873
863
|
for (const id of blocks.get(b).ids) {
|
|
874
864
|
const idx = id - b * rowsPerBlock;
|
|
875
865
|
const row = new Uint8Array(bytes.subarray(rel + pageBytes + idx * dim, rel + pageBytes + (idx + 1) * dim));
|
|
876
|
-
|
|
877
|
-
const digest = await sha256BytesAsync(row);
|
|
878
|
-
const slot = page.subarray(idx * rowDigestBytes, (idx + 1) * rowDigestBytes);
|
|
879
|
-
for (let i = 0; i < rowDigestBytes; i++) {
|
|
880
|
-
if (digest[i] !== slot[i]) {
|
|
881
|
-
throw pikeletError(PIKELET_ERROR_CODES.SNAPSHOT_INVALID, 'Sketch artifact row failed digest verification', { id });
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
if (cache) blobCachePut(cache, hexOf(slot), row);
|
|
885
|
-
}
|
|
886
|
-
if (rows.has(id)) rows.set(id, row);
|
|
887
|
-
this.cacheRow(id, row);
|
|
866
|
+
fetched.push({ id, row, slot: page.subarray(idx * rowDigestBytes, (idx + 1) * rowDigestBytes) });
|
|
888
867
|
}
|
|
889
868
|
}
|
|
890
869
|
}
|
|
870
|
+
// Every page and row is checked before any row is returned or
|
|
871
|
+
// cached. The digests are computed as one batch (sha256ManyAsync).
|
|
872
|
+
if (this.verifyRows) {
|
|
873
|
+
const pageDigests = await sha256ManyAsync(pages.map((p) => p.page));
|
|
874
|
+
pages.forEach(({ b, page }, n) => {
|
|
875
|
+
const pageDigest = pageDigests[n];
|
|
876
|
+
if (!pageDigest) {
|
|
877
|
+
throw pikeletError(PIKELET_ERROR_CODES.SNAPSHOT_INVALID,
|
|
878
|
+
'Sketch artifact row verification requested but no crypto backend is available; pass verify:false to skip');
|
|
879
|
+
}
|
|
880
|
+
const expected = this.pageTable.subarray(b * 32, b * 32 + 32);
|
|
881
|
+
for (let i = 0; i < 32; i++) {
|
|
882
|
+
if (pageDigest[i] !== expected[i]) {
|
|
883
|
+
throw pikeletError(PIKELET_ERROR_CODES.SNAPSHOT_INVALID, 'Sketch artifact row digest page failed hash verification', { block: b });
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
if (cache) blobCachePut(cache, hexOf(expected), page.slice());
|
|
887
|
+
});
|
|
888
|
+
const rowDigests = await sha256ManyAsync(fetched.map((f) => f.row));
|
|
889
|
+
fetched.forEach(({ id, row, slot }, n) => {
|
|
890
|
+
const digest = rowDigests[n];
|
|
891
|
+
for (let i = 0; i < rowDigestBytes; i++) {
|
|
892
|
+
if (digest[i] !== slot[i]) {
|
|
893
|
+
throw pikeletError(PIKELET_ERROR_CODES.SNAPSHOT_INVALID, 'Sketch artifact row failed digest verification', { id });
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
if (cache) blobCachePut(cache, hexOf(slot), row);
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
for (const { id, row } of fetched) {
|
|
900
|
+
if (rows.has(id)) rows.set(id, row);
|
|
901
|
+
this.cacheRow(id, row);
|
|
902
|
+
}
|
|
891
903
|
return rows;
|
|
892
904
|
}
|
|
893
905
|
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
// Types for
|
|
2
|
-
// holding the
|
|
3
|
-
//
|
|
1
|
+
// Types for src/artifact/pikelet-artifact.js, the engine-free CJS module
|
|
2
|
+
// holding the sketch artifact reader, builders, and snapshot parser. It is
|
|
3
|
+
// internal (no package export subpath); unlike the entrypoints, it provides
|
|
4
|
+
// these as named exports.
|
|
4
5
|
|
|
5
6
|
import type {
|
|
6
7
|
NodeFileRangeSourceConstructor,
|
|
7
|
-
PikeletRangeArtifactConstructor,
|
|
8
8
|
PikeletSketchArtifact,
|
|
9
9
|
PikeletSketchArtifactConstructor,
|
|
10
|
-
RangeArtifactBuildManifest,
|
|
11
|
-
RangeArtifactBuildOptions,
|
|
12
10
|
SketchArtifactBuildManifest,
|
|
13
11
|
SketchArtifactBuildOptions,
|
|
14
12
|
SketchScanner,
|
|
@@ -50,7 +48,6 @@ export interface SketchRowSource {
|
|
|
50
48
|
readonly offsets: Float32Array;
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
export declare const PikeletRangeArtifact: PikeletRangeArtifactConstructor;
|
|
54
51
|
export declare const PikeletSketchArtifact: PikeletSketchArtifactConstructor;
|
|
55
52
|
export declare const NodeFileRangeSource: NodeFileRangeSourceConstructor;
|
|
56
53
|
|
|
@@ -64,28 +61,6 @@ export declare function createSketchScanner(
|
|
|
64
61
|
options?: SketchScannerOptions
|
|
65
62
|
): Promise<SketchScanner>;
|
|
66
63
|
|
|
67
|
-
/**
|
|
68
|
-
* @deprecated The `.pikelet-range` profile is deprecated
|
|
69
|
-
* (spec/SEARCH_ARTIFACT_CONTRACT.md 9.2); build a `.pikelet-sketch`
|
|
70
|
-
* artifact instead. Readers stay supported for existing artifacts.
|
|
71
|
-
*/
|
|
72
|
-
export declare function buildRangeArtifact(
|
|
73
|
-
snapshot: Uint8Array | ArrayBufferLike,
|
|
74
|
-
outPath: string,
|
|
75
|
-
opts?: RangeArtifactBuildOptions
|
|
76
|
-
): RangeArtifactBuildManifest;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @deprecated The `.pikelet-range` profile is deprecated
|
|
80
|
-
* (spec/SEARCH_ARTIFACT_CONTRACT.md 9.2); build a `.pikelet-sketch`
|
|
81
|
-
* artifact instead. Readers stay supported for existing artifacts.
|
|
82
|
-
*/
|
|
83
|
-
export declare function buildRangeArtifactFile(
|
|
84
|
-
snapshotPath: string,
|
|
85
|
-
outPath: string,
|
|
86
|
-
opts?: RangeArtifactBuildOptions
|
|
87
|
-
): RangeArtifactBuildManifest;
|
|
88
|
-
|
|
89
64
|
export declare function buildSketchArtifact(
|
|
90
65
|
snapshot: Uint8Array | ArrayBufferLike,
|
|
91
66
|
outPath: string,
|
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// The sketch artifact layer (spec/SKETCH_PROFILE.md): the index profile a
|
|
3
|
+
// .pikelet's vector search runs on. Internal to the package (no export
|
|
4
|
+
// subpath); the engine entry points expose it as Pikelet.SketchArtifact and
|
|
5
|
+
// friends, and complete/builder re-exports what the CLI builds packs with.
|
|
4
6
|
// pikelet-artifact-common.js read budgets + range validation, range sources
|
|
5
7
|
// (NodeFileRangeSource), result heap, snapshot
|
|
6
8
|
// parsing (parseUint8Snapshot), SHA-256 helpers
|
|
7
|
-
// pikelet-artifact-range.js .pikelet-range reader (PikeletRangeArtifact) + builder
|
|
8
9
|
// pikelet-artifact-sketch.js .pikelet-sketch reader (PikeletSketchArtifact),
|
|
9
10
|
// builders, and createSketchScanner
|
|
10
|
-
// The
|
|
11
|
+
// The .pikelet-range profile was retired in 0.16 (archive/v0).
|
|
11
12
|
|
|
12
13
|
const { NodeFileRangeSource, parseUint8Snapshot } = require('./pikelet-artifact-common.js');
|
|
13
|
-
const { PikeletRangeArtifact, buildRangeArtifact, buildRangeArtifactFile } = require('./pikelet-artifact-range.js');
|
|
14
14
|
const {
|
|
15
15
|
PikeletSketchArtifact, MAX_RECOMMENDED_RERANK, createSketchScanner,
|
|
16
16
|
buildSketchArtifact, buildSketchArtifactBytes, buildSketchArtifactFile, exportSketchArtifact,
|
|
17
17
|
} = require('./pikelet-artifact-sketch.js');
|
|
18
18
|
|
|
19
19
|
module.exports = {
|
|
20
|
-
PikeletRangeArtifact,
|
|
21
20
|
PikeletSketchArtifact,
|
|
22
21
|
MAX_RECOMMENDED_RERANK,
|
|
23
22
|
createSketchScanner,
|
|
24
23
|
NodeFileRangeSource,
|
|
25
|
-
buildRangeArtifact,
|
|
26
|
-
buildRangeArtifactFile,
|
|
27
24
|
buildSketchArtifact,
|
|
28
25
|
buildSketchArtifactBytes,
|
|
29
26
|
buildSketchArtifactFile,
|
package/src/pikelet.d.ts
CHANGED
|
@@ -123,124 +123,10 @@ export interface RangeReadSource {
|
|
|
123
123
|
close?(): void | Promise<void>;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
export interface RangeArtifactSearchOptions {
|
|
127
|
-
/** Query-time search breadth. Default: 100. */
|
|
128
|
-
efSearch?: number;
|
|
129
|
-
/** Merge adjacent v1 record runs separated by this many skipped records. Default: 0. */
|
|
130
|
-
gap?: number;
|
|
131
|
-
/** Candidates expanded per fetch round (deeper rounds trade requests for latency). Default: 1. */
|
|
132
|
-
expansionBatch?: number;
|
|
133
|
-
/** Concurrent range reads per fetch round. Default: 1. */
|
|
134
|
-
parallelism?: number;
|
|
135
|
-
/** Overrides `parallelism` for range reads when both are set. */
|
|
136
|
-
rangeParallelism?: number;
|
|
137
|
-
/**
|
|
138
|
-
* Split coalesced record runs at this many bytes (record-aligned, floor
|
|
139
|
-
* one record) so no single range read grows unbounded. Default: 16 MiB.
|
|
140
|
-
*/
|
|
141
|
-
maxRangeBytes?: number;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/** A decoded graph record, as returned by {@link PikeletRangeArtifact.readNode}. */
|
|
145
|
-
export interface RangeArtifactNode {
|
|
146
|
-
readonly id: number;
|
|
147
|
-
readonly level: number;
|
|
148
|
-
readonly base: Uint32Array;
|
|
149
|
-
readonly upper: readonly Uint32Array[];
|
|
150
|
-
readonly qdata: Uint8Array;
|
|
151
|
-
readonly scale: number;
|
|
152
|
-
readonly offset: number;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export interface RangeArtifactStats {
|
|
156
|
-
readonly rangeRequests: number;
|
|
157
|
-
readonly rangeBytes: number;
|
|
158
|
-
readonly rangeNodesDecoded: number;
|
|
159
|
-
readonly cachedNodes: number;
|
|
160
|
-
readonly lazyCacheBytes: number;
|
|
161
|
-
readonly routerResident: {
|
|
162
|
-
readonly records: number;
|
|
163
|
-
readonly bytes: number;
|
|
164
|
-
};
|
|
165
|
-
/**
|
|
166
|
-
* Which segments have passed their v3 whole-segment digests. Always false
|
|
167
|
-
* for pre-v3 artifacts (which carry no digests) and under verify:false;
|
|
168
|
-
* base becomes true only after a successful verifyBaseSegment().
|
|
169
|
-
*/
|
|
170
|
-
readonly segmentVerified: {
|
|
171
|
-
readonly idMap: boolean;
|
|
172
|
-
readonly router: boolean;
|
|
173
|
-
readonly base: boolean;
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export interface RangeArtifactRound {
|
|
178
|
-
readonly ids: number;
|
|
179
|
-
readonly requests: number;
|
|
180
|
-
readonly bytes: number;
|
|
181
|
-
readonly rangeBytes: readonly number[];
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export interface RangeArtifactSearchResult {
|
|
185
|
-
readonly results: SearchResult[];
|
|
186
|
-
readonly rounds: RangeArtifactRound[];
|
|
187
|
-
readonly stats: RangeArtifactStats;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export interface RangeArtifactOpenOptions {
|
|
191
|
-
/** Eagerly load the v2 router segment. Default: true. */
|
|
192
|
-
loadRouter?: boolean;
|
|
193
|
-
/**
|
|
194
|
-
* Verify the id map and router segments against the header digests at open
|
|
195
|
-
* (v3 artifacts only; pre-v3 artifacts carry no digests and open
|
|
196
|
-
* unverified either way). Default: true.
|
|
197
|
-
*/
|
|
198
|
-
verify?: boolean;
|
|
199
|
-
/**
|
|
200
|
-
* Budget for any single open-path read (id map, router segment), honored
|
|
201
|
-
* strictly: a budget below what the artifact's resident segments need
|
|
202
|
-
* fails the open with SNAPSHOT_INVALID. Default: 256 MiB; Infinity defers
|
|
203
|
-
* to the 2 GiB absolute backstop. Other non-positive or non-numeric
|
|
204
|
-
* values throw INVALID_ARGUMENT.
|
|
205
|
-
*/
|
|
206
|
-
maxReadBytes?: number;
|
|
207
|
-
/**
|
|
208
|
-
* Byte budget for the lazily-fetched record cache (LRU eviction; the
|
|
209
|
-
* resident router segment is not counted). Default: 64 MiB. Pass Infinity
|
|
210
|
-
* for the pre-0.3 unbounded behavior. Budgets below 64 records are raised
|
|
211
|
-
* to that floor; other non-positive or non-numeric values throw
|
|
212
|
-
* INVALID_ARGUMENT.
|
|
213
|
-
*/
|
|
214
|
-
maxCacheBytes?: number;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export interface RangeArtifactBuildOptions {
|
|
218
|
-
/** Deterministic base-layer layout. Default: 'rcm'. */
|
|
219
|
-
layout?: 'rcm' | 'identity';
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export interface RangeArtifactBuildManifest {
|
|
223
|
-
readonly format: 'pikelet-range-artifact';
|
|
224
|
-
readonly formatVersion: number;
|
|
225
|
-
/** Hex SHA-256 whole-segment digests stamped into the v3 header. */
|
|
226
|
-
readonly integrity: Readonly<{
|
|
227
|
-
idMapSha256: string;
|
|
228
|
-
routerSha256: string;
|
|
229
|
-
baseSha256: string;
|
|
230
|
-
}>;
|
|
231
|
-
readonly file: string;
|
|
232
|
-
readonly sizeBytes: number;
|
|
233
|
-
readonly kind: string;
|
|
234
|
-
readonly metric: Metric;
|
|
235
|
-
readonly layout: Readonly<Record<string, unknown>>;
|
|
236
|
-
readonly graph: Readonly<Record<string, number>>;
|
|
237
|
-
readonly addressing: Readonly<Record<string, number>>;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
126
|
/**
|
|
241
127
|
* Node-only file-backed range source. This is NOT a named runtime export of
|
|
242
128
|
* any entrypoint: reach the constructor via the Node API object
|
|
243
|
-
* (`Pikelet.NodeFileRangeSource`)
|
|
129
|
+
* (`Pikelet.NodeFileRangeSource`).
|
|
244
130
|
*/
|
|
245
131
|
export interface NodeFileRangeSource extends RangeReadSource {
|
|
246
132
|
readonly filePath: string;
|
|
@@ -254,58 +140,6 @@ export interface NodeFileRangeSourceConstructor {
|
|
|
254
140
|
readonly prototype: NodeFileRangeSource;
|
|
255
141
|
}
|
|
256
142
|
|
|
257
|
-
/**
|
|
258
|
-
* A range-readable Search Artifact reader. The class is NOT a named runtime
|
|
259
|
-
* export of any entrypoint: reach it via `Pikelet.RangeArtifact` or the
|
|
260
|
-
* `pikelet-wasm/artifact` subpath.
|
|
261
|
-
*/
|
|
262
|
-
export interface PikeletRangeArtifact {
|
|
263
|
-
readonly version: number;
|
|
264
|
-
readonly kind: number;
|
|
265
|
-
readonly dim: number;
|
|
266
|
-
readonly count: number;
|
|
267
|
-
readonly entryPoint: number;
|
|
268
|
-
readonly maxLevel: number;
|
|
269
|
-
readonly M: number;
|
|
270
|
-
readonly M0: number;
|
|
271
|
-
readonly metric: number;
|
|
272
|
-
readonly recordBytes: number;
|
|
273
|
-
readonly routerCount: number;
|
|
274
|
-
readonly baseCount: number;
|
|
275
|
-
readonly routerResident: { readonly records: number; readonly bytes: number };
|
|
276
|
-
search(query: VectorInput, k: number, options?: RangeArtifactSearchOptions): Promise<RangeArtifactSearchResult>;
|
|
277
|
-
stats(): RangeArtifactStats;
|
|
278
|
-
/**
|
|
279
|
-
* Verify the lazily-read base segment against the v3 header digest (not a
|
|
280
|
-
* query-path operation). Streams the segment in bounded chunks where a
|
|
281
|
-
* streaming hash exists (Node); other runtimes fall back to one read
|
|
282
|
-
* bounded by maxReadBytes. Resolves true on match; throws
|
|
283
|
-
* SNAPSHOT_INVALID on mismatch, INVALID_ARGUMENT for pre-v3 artifacts,
|
|
284
|
-
* which carry no digests.
|
|
285
|
-
*/
|
|
286
|
-
verifyBaseSegment(options?: { chunkBytes?: number }): Promise<true>;
|
|
287
|
-
resetStats(): void;
|
|
288
|
-
clearCache(options?: { reloadRouter?: boolean }): Promise<{ records: number; bytes: number }>;
|
|
289
|
-
/** Fetch (and cache) the given node ids in coalesced ranges. Returns the number of range reads issued. */
|
|
290
|
-
prefetch(ids: readonly number[], options?: { gap?: number; parallelism?: number; maxRangeBytes?: number }): Promise<number>;
|
|
291
|
-
/** Read a single node, fetching it if not cached. */
|
|
292
|
-
readNode(id: number): Promise<RangeArtifactNode>;
|
|
293
|
-
/** Byte offset of a node's record within the artifact. */
|
|
294
|
-
recordAddressForId(id: number): number;
|
|
295
|
-
/** Mark the current position in the range-read log (see rangesSince). */
|
|
296
|
-
markRanges(): number;
|
|
297
|
-
/** Ranges read since a markRanges() mark, as [start, end) byte offsets. */
|
|
298
|
-
rangesSince(mark: number): Array<[number, number]>;
|
|
299
|
-
close(): Promise<void>;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
export interface PikeletRangeArtifactConstructor {
|
|
303
|
-
open(source: RangeReadSource, options?: RangeArtifactOpenOptions): Promise<PikeletRangeArtifact>;
|
|
304
|
-
/** Node entrypoints only. */
|
|
305
|
-
openFile(filePath: string, options?: RangeArtifactOpenOptions): Promise<PikeletRangeArtifact>;
|
|
306
|
-
readonly prototype: PikeletRangeArtifact;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
143
|
/** Resident sketch tier: the coarse staged-boot tier or the full tier. */
|
|
310
144
|
export type SketchTier = 'micro' | 'full';
|
|
311
145
|
|
|
@@ -489,8 +323,7 @@ export interface SketchArtifactBuildManifest {
|
|
|
489
323
|
|
|
490
324
|
/**
|
|
491
325
|
* A sketch Search Artifact reader. The class is NOT a named runtime export of
|
|
492
|
-
* any entrypoint: reach it via `Pikelet.SketchArtifact
|
|
493
|
-
* `pikelet-wasm/artifact` subpath.
|
|
326
|
+
* any entrypoint: reach it via `Pikelet.SketchArtifact`.
|
|
494
327
|
*/
|
|
495
328
|
export interface PikeletSketchArtifact {
|
|
496
329
|
readonly metric: number;
|
|
@@ -622,7 +455,6 @@ export interface PikeletIndex {
|
|
|
622
455
|
export interface PikeletApi {
|
|
623
456
|
readonly PikeletError: typeof PikeletError;
|
|
624
457
|
readonly PIKELET_ERROR_CODES: typeof PIKELET_ERROR_CODES;
|
|
625
|
-
readonly RangeArtifact: PikeletRangeArtifactConstructor;
|
|
626
458
|
readonly SketchArtifact: PikeletSketchArtifactConstructor;
|
|
627
459
|
/** Build a WASM-backed SIMD scanner for a sketch artifact's resident tier. */
|
|
628
460
|
createSketchScanner(artifact: PikeletSketchArtifact, options?: SketchScannerOptions): Promise<SketchScanner>;
|
|
@@ -648,22 +480,6 @@ export interface PikeletApi {
|
|
|
648
480
|
*/
|
|
649
481
|
export interface NodePikeletApi extends PikeletApi {
|
|
650
482
|
readonly NodeFileRangeSource: NodeFileRangeSourceConstructor;
|
|
651
|
-
/**
|
|
652
|
-
* Build a range-readable Search Artifact from a uint8 Pikelet snapshot.
|
|
653
|
-
* @deprecated The `.pikelet-range` profile is deprecated
|
|
654
|
-
* (spec/SEARCH_ARTIFACT_CONTRACT.md 9.2); build a `.pikelet-sketch`
|
|
655
|
-
* artifact instead. Readers stay supported for existing artifacts.
|
|
656
|
-
*/
|
|
657
|
-
buildRangeArtifact(snapshot: Uint8Array | ArrayBufferLike, outPath: string, opts?: RangeArtifactBuildOptions): RangeArtifactBuildManifest;
|
|
658
|
-
/**
|
|
659
|
-
* Build a range-readable Search Artifact from a uint8 Pikelet snapshot file.
|
|
660
|
-
* @deprecated The `.pikelet-range` profile is deprecated
|
|
661
|
-
* (spec/SEARCH_ARTIFACT_CONTRACT.md 9.2); build a `.pikelet-sketch`
|
|
662
|
-
* artifact instead. Readers stay supported for existing artifacts.
|
|
663
|
-
*/
|
|
664
|
-
buildRangeArtifactFile(snapshotPath: string, outPath: string, opts?: RangeArtifactBuildOptions): RangeArtifactBuildManifest;
|
|
665
|
-
/** Open a range-readable Search Artifact from a local file. */
|
|
666
|
-
openRangeArtifactFile(filePath: string, opts?: RangeArtifactOpenOptions): Promise<PikeletRangeArtifact>;
|
|
667
483
|
/** Build a sketch Search Artifact from a uint8 Pikelet snapshot. */
|
|
668
484
|
buildSketchArtifact(snapshot: Uint8Array | ArrayBufferLike, outPath: string, opts?: SketchArtifactBuildOptions): SketchArtifactBuildManifest;
|
|
669
485
|
/** Build a sketch Search Artifact from a uint8 Pikelet snapshot file. */
|
package/src/pikelet.js
CHANGED
|
@@ -4,7 +4,7 @@ const loadEngine = require('../dist/engine.js');
|
|
|
4
4
|
const loadScalarEngine = require('../dist/engine.scalar.js');
|
|
5
5
|
const createPikeletApi = require('./core/pikelet-core.js');
|
|
6
6
|
const { PikeletError, PIKELET_ERROR_CODES, pikeletError } = require('./errors/pikelet-errors.js');
|
|
7
|
-
const {
|
|
7
|
+
const { PikeletSketchArtifact, createSketchScanner, NodeFileRangeSource, buildSketchArtifact, buildSketchArtifactBytes, buildSketchArtifactFile } = require('./artifact/pikelet-artifact.js');
|
|
8
8
|
const { createCachedModuleLoader } = require('./loader/pikelet-loader.js');
|
|
9
9
|
const _path = require('path');
|
|
10
10
|
const _fs = require('fs');
|
|
@@ -190,15 +190,7 @@ async function loadNodeEngine() {
|
|
|
190
190
|
|
|
191
191
|
const Pikelet = createPikeletApi(loadNodeEngine);
|
|
192
192
|
|
|
193
|
-
Pikelet.RangeArtifact = PikeletRangeArtifact;
|
|
194
193
|
Pikelet.NodeFileRangeSource = NodeFileRangeSource;
|
|
195
|
-
Pikelet.buildRangeArtifact = buildRangeArtifact;
|
|
196
|
-
Pikelet.buildRangeArtifactFile = buildRangeArtifactFile;
|
|
197
|
-
|
|
198
|
-
Pikelet.openRangeArtifactFile = async function openRangeArtifactFile(filePath, opts) {
|
|
199
|
-
validateFilePath(filePath, 'openRangeArtifactFile');
|
|
200
|
-
return PikeletRangeArtifact.openFile(filePath, opts);
|
|
201
|
-
};
|
|
202
194
|
|
|
203
195
|
Pikelet.SketchArtifact = PikeletSketchArtifact;
|
|
204
196
|
Pikelet.createSketchScanner = (artifact, options) => createSketchScanner(loadNodeEngine, artifact, options);
|
package/src/pikelet.node.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import loaderContract from './loader/pikelet-loader.js';
|
|
|
9
9
|
import artifactContract from './artifact/pikelet-artifact.js';
|
|
10
10
|
const { PikeletError, PIKELET_ERROR_CODES, pikeletError } = errorContract;
|
|
11
11
|
const { createCachedModuleLoader } = loaderContract;
|
|
12
|
-
const {
|
|
12
|
+
const { PikeletSketchArtifact, createSketchScanner, NodeFileRangeSource, buildSketchArtifact, buildSketchArtifactBytes, buildSketchArtifactFile } = artifactContract;
|
|
13
13
|
|
|
14
14
|
const __filename = fileURLToPath(import.meta.url);
|
|
15
15
|
const __dirname = path.dirname(__filename);
|
|
@@ -196,15 +196,7 @@ async function loadNodeEngine() {
|
|
|
196
196
|
const Pikelet = createPikeletApi(loadNodeEngine);
|
|
197
197
|
export { PikeletError, PIKELET_ERROR_CODES };
|
|
198
198
|
|
|
199
|
-
Pikelet.RangeArtifact = PikeletRangeArtifact;
|
|
200
199
|
Pikelet.NodeFileRangeSource = NodeFileRangeSource;
|
|
201
|
-
Pikelet.buildRangeArtifact = buildRangeArtifact;
|
|
202
|
-
Pikelet.buildRangeArtifactFile = buildRangeArtifactFile;
|
|
203
|
-
|
|
204
|
-
Pikelet.openRangeArtifactFile = async function openRangeArtifactFile(filePath, opts) {
|
|
205
|
-
validateFilePath(filePath, 'openRangeArtifactFile');
|
|
206
|
-
return PikeletRangeArtifact.openFile(filePath, opts);
|
|
207
|
-
};
|
|
208
200
|
|
|
209
201
|
Pikelet.SketchArtifact = PikeletSketchArtifact;
|
|
210
202
|
Pikelet.createSketchScanner = (artifact, options) => createSketchScanner(loadNodeEngine, artifact, options);
|
package/src/pikelet.web.d.ts
CHANGED
|
@@ -22,14 +22,6 @@ export type {
|
|
|
22
22
|
ResolvedConfig,
|
|
23
23
|
PikeletIndex,
|
|
24
24
|
RangeReadSource,
|
|
25
|
-
RangeArtifactSearchOptions,
|
|
26
|
-
RangeArtifactNode,
|
|
27
|
-
RangeArtifactStats,
|
|
28
|
-
RangeArtifactRound,
|
|
29
|
-
RangeArtifactSearchResult,
|
|
30
|
-
RangeArtifactOpenOptions,
|
|
31
|
-
PikeletRangeArtifact,
|
|
32
|
-
PikeletRangeArtifactConstructor,
|
|
33
25
|
SketchTier,
|
|
34
26
|
SketchStageEvent,
|
|
35
27
|
SketchArtifactOpenOptions,
|
package/src/pikelet.web.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import loaderContract from './loader/pikelet-loader.js';
|
|
|
8
8
|
import artifactContract from './artifact/pikelet-artifact.js';
|
|
9
9
|
const { PikeletError, PIKELET_ERROR_CODES, pikeletError } = errorContract;
|
|
10
10
|
const { createCachedModuleLoader } = loaderContract;
|
|
11
|
-
const {
|
|
11
|
+
const { PikeletSketchArtifact, createSketchScanner } = artifactContract;
|
|
12
12
|
let engineVariantPromise = null;
|
|
13
13
|
|
|
14
14
|
function makeLoadError(message, error) {
|
|
@@ -72,7 +72,6 @@ async function loadWebEngine() {
|
|
|
72
72
|
const Pikelet = createPikeletApi(loadWebEngine);
|
|
73
73
|
export { PikeletError, PIKELET_ERROR_CODES };
|
|
74
74
|
|
|
75
|
-
Pikelet.RangeArtifact = PikeletRangeArtifact;
|
|
76
75
|
Pikelet.SketchArtifact = PikeletSketchArtifact;
|
|
77
76
|
Pikelet.createSketchScanner = (artifact, options) => createSketchScanner(loadWebEngine, artifact, options);
|
|
78
77
|
|
package/src/pikelet.workerd.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import loaderContract from './loader/pikelet-loader.js';
|
|
|
8
8
|
import artifactContract from './artifact/pikelet-artifact.js';
|
|
9
9
|
const { PikeletError, PIKELET_ERROR_CODES, pikeletError } = errorContract;
|
|
10
10
|
const { createCachedModuleLoader } = loaderContract;
|
|
11
|
-
const {
|
|
11
|
+
const { PikeletSketchArtifact, createSketchScanner } = artifactContract;
|
|
12
12
|
|
|
13
13
|
let engineVariantPromise = null;
|
|
14
14
|
|
|
@@ -56,7 +56,6 @@ async function loadWorkerdEngine() {
|
|
|
56
56
|
const Pikelet = createPikeletApi(loadWorkerdEngine);
|
|
57
57
|
export { PikeletError, PIKELET_ERROR_CODES };
|
|
58
58
|
|
|
59
|
-
Pikelet.RangeArtifact = PikeletRangeArtifact;
|
|
60
59
|
Pikelet.SketchArtifact = PikeletSketchArtifact;
|
|
61
60
|
Pikelet.createSketchScanner = (artifact, options) => createSketchScanner(loadWorkerdEngine, artifact, options);
|
|
62
61
|
|