pikelet-wasm 0.15.0 → 0.17.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +314 -0
  2. package/FORMAT.md +52 -59
  3. package/README.md +11 -11
  4. package/complete/builder.d.ts +27 -8
  5. package/complete/builder.mjs +28 -38
  6. package/complete/fusion.mjs +20 -4
  7. package/complete/grounding.mjs +5 -9
  8. package/complete/index.d.ts +31 -32
  9. package/complete/index.mjs +116 -298
  10. package/complete/inline-transformer.mjs +0 -64
  11. package/complete/layer-append.mjs +6 -32
  12. package/complete/layer-chain.mjs +7 -53
  13. package/complete/layer-compact.mjs +4 -5
  14. package/complete/layer-encoder.mjs +17 -123
  15. package/complete/layer-manifest.mjs +2 -1
  16. package/complete/layer-reader.mjs +28 -149
  17. package/complete/layer-rebase.mjs +1 -1
  18. package/complete/sources.mjs +1 -1
  19. package/complete/wordpiece.mjs +0 -22
  20. package/dist/engine.js +1 -1
  21. package/dist/engine.scalar.js +1 -1
  22. package/dist/engine.scalar.wasm +0 -0
  23. package/dist/engine.wasm +0 -0
  24. package/package.json +1 -5
  25. package/src/artifact/pikelet-artifact-common.js +27 -0
  26. package/src/artifact/pikelet-artifact-sketch.js +86 -150
  27. package/src/artifact/pikelet-artifact.d.ts +4 -29
  28. package/src/artifact/pikelet-artifact.js +5 -8
  29. package/src/core/pikelet-core.js +6 -3
  30. package/src/pikelet.d.ts +2 -186
  31. package/src/pikelet.js +1 -9
  32. package/src/pikelet.node.mjs +1 -9
  33. package/src/pikelet.web.d.ts +0 -8
  34. package/src/pikelet.web.mjs +1 -2
  35. package/src/pikelet.workerd.mjs +1 -2
  36. package/complete/retrieval-abstention.mjs +0 -232
  37. package/complete/student-abstention.mjs +0 -102
  38. package/complete/student-embedder.mjs +0 -231
  39. package/src/artifact/pikelet-artifact-range.js +0 -806
@@ -4,6 +4,23 @@
4
4
  * the same objects the reader uses (complete/format.mjs).
5
5
  */
6
6
 
7
+ import type { SketchArtifactBuildManifest, SketchArtifactBuildOptions } from '../src/pikelet.js';
8
+ import type { SketchRowSource } from '../src/artifact/pikelet-artifact.js';
9
+
10
+ /** Build a sketch index (spec/SKETCH_PROFILE.md) from uint8 engine snapshot bytes. */
11
+ export declare function buildSketchArtifactBytes(
12
+ snapshot: Uint8Array | ArrayBufferLike,
13
+ options?: SketchArtifactBuildOptions
14
+ ): { bytes: Uint8Array; manifest: SketchArtifactBuildManifest };
15
+ /** Build a sketch index from quantized rows; with outPath null, returns its bytes. */
16
+ export declare function exportSketchArtifact(
17
+ index: SketchRowSource,
18
+ outPath: string | null,
19
+ options?: SketchArtifactBuildOptions
20
+ ): SketchArtifactBuildManifest | { bytes: Uint8Array; manifest: SketchArtifactBuildManifest };
21
+ /** Ceiling on a sketch header's recommendedRerank (readers' default rerank depth). */
22
+ export declare const MAX_RECOMMENDED_RERANK: number;
23
+
7
24
  export declare const MAGIC: number;
8
25
  export declare const HEADER_BYTES: number;
9
26
  export declare const TABLE_ENTRY_BYTES: number;
@@ -15,16 +32,17 @@ export declare function canonicalJson(value: unknown): string;
15
32
  export declare const align16: (n: number) => number;
16
33
 
17
34
  /** Manifest profile strings and the header formatVersion each one implies. */
18
- export declare const PROFILE_V1: 'pikelet-complete-v1';
19
35
  export declare const PROFILE_V2: 'pikelet-complete-v2';
20
36
  export declare const FORMAT_VERSIONS: Record<string, number>;
21
37
  /** Corpus layout name for format 2 (per-record digests behind a page table). */
22
38
  export declare const CORPUS_LAYOUT_V2: 'records-v2';
23
39
  export declare const DEFAULT_CORPUS_PAGE_RECORDS: number;
24
40
 
25
- export declare function buildQueryInterpSegment(kind: number, encoderBytes: Buffer | Uint8Array, calibrationBytes: Buffer | Uint8Array): Buffer;
26
- /** Corpus layout v1 (format 1): count + offsets + records, whole-segment integrity only. */
27
- export declare function buildCorpusSegmentFromBuffers(records: Array<Buffer | Uint8Array>): Buffer;
41
+ /**
42
+ * The query-interp segment: header, encoder region, then the reserved
43
+ * calibration region (readers ignore it; omit it to write the default).
44
+ */
45
+ export declare function buildQueryInterpSegment(kind: number, encoderBytes: Buffer | Uint8Array, calibrationBytes?: Buffer | Uint8Array): Buffer;
28
46
  /**
29
47
  * Corpus layout v2 (format 2): count, pageRecords, offsets, a page table of
30
48
  * SHA-256s over runs of record digests, one SHA-256 per record, then the
@@ -47,9 +65,9 @@ export declare function buildInlineTransformerEncoderSegment(input: {
47
65
  weightBytes: Buffer | Uint8Array;
48
66
  }): Buffer;
49
67
  /**
50
- * Writes the container. manifestFields.profile selects the header format
51
- * version (PROFILE_V1 -> 1 with a v1 corpus, PROFILE_V2 -> 2 with a
52
- * buildCorpusSegment() corpus); mismatches throw. Segments with a kind this
68
+ * Writes the container (header format version 2). manifestFields.profile is
69
+ * PROFILE_V2 with a buildCorpusSegment() corpus, or a layer profile;
70
+ * mismatches throw. Segments with a kind this
53
71
  * spec does not name must carry an explicit kindNumber (readers skip them).
54
72
  */
55
73
  export declare function assemblePikeletFile(
@@ -60,7 +78,8 @@ export declare function assemblePikeletFile(
60
78
 
61
79
  /** Measured recall-vs-rerank operating point (SKETCH_PROFILE.md section 5). */
62
80
  export declare function measureRecommendedRerank(input: {
63
- artifactModule: unknown;
81
+ /** The sketch artifact module (default: this package's own). */
82
+ artifactModule?: unknown;
64
83
  sketchBytes: Uint8Array | ArrayBufferLike;
65
84
  queryVectors?: Float32Array[] | null;
66
85
  snapshotBytes?: Uint8Array | ArrayBufferLike | null;
@@ -6,6 +6,12 @@ export { buildRowMapSegment } from './rowmap.mjs';
6
6
 
7
7
  export { MAGIC, HEADER_BYTES, TABLE_ENTRY_BYTES, KINDS, KIND_NAMES };
8
8
 
9
+ // The sketch index every pack carries (spec/SKETCH_PROFILE.md), built from an
10
+ // engine snapshot or from quantized rows. The artifact module has no export
11
+ // subpath of its own; builders reach it here.
12
+ import artifactContract from '../src/artifact/pikelet-artifact.js';
13
+ export const { buildSketchArtifactBytes, exportSketchArtifact, MAX_RECOMMENDED_RERANK } = artifactContract;
14
+
9
15
  // The inline-transformer kernel via the web glue with an explicitly read
10
16
  // wasm binary — the form that works under both native ESM and jiti's CJS
11
17
  // transform (the node glue's createRequire bootstrap breaks there). Node
@@ -28,7 +34,8 @@ export function canonicalJson(value) {
28
34
  }
29
35
  if (value && typeof value === 'object') {
30
36
  const parts = [];
31
- for (const k of Object.keys(value).sort()) {
37
+ // Code-unit order, not localeCompare: key order is part of the pack identity.
38
+ for (const k of Object.keys(value).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))) {
32
39
  const serialized = canonicalJson(value[k]);
33
40
  if (serialized !== undefined) parts.push(`${JSON.stringify(k)}:${serialized}`);
34
41
  }
@@ -37,7 +44,14 @@ export function canonicalJson(value) {
37
44
  return JSON.stringify(value);
38
45
  }
39
46
 
40
- export function buildQueryInterpSegment(kind, encoderBytes, calibrationBytes) {
47
+ // The query-interp segment's second region was the fitted matchQuality
48
+ // calibration until 0.17. It is reserved now: readers ignore it, and this is
49
+ // what producers write there, the same bytes compile has written since it
50
+ // stopped fitting one, so pack identities do not move.
51
+ const RESERVED_CALIBRATION_REGION = new TextEncoder().encode(
52
+ JSON.stringify({ kind: 'retrieval-signals-v1', asset: null, vocabBloomBase64: '' }));
53
+
54
+ export function buildQueryInterpSegment(kind, encoderBytes, calibrationBytes = RESERVED_CALIBRATION_REGION) {
41
55
  const out = Buffer.alloc(16 + encoderBytes.length + calibrationBytes.length);
42
56
  out.writeUInt32LE(1, 0);
43
57
  out.writeUInt32LE(kind, 4);
@@ -78,8 +92,8 @@ export function buildQueryInterpSegment(kind, encoderBytes, calibrationBytes) {
78
92
  // Interrogatives (how/does/what/...) are stopped here too: otherwise a
79
93
  // question's scaffolding scores BM25 matches against literal dialogue ("How
80
94
  // does Georgiana get on, Darcy?") and pushes correct chunks out of the fused
81
- // top-10. calibrate.mjs's COVERAGE_STOPWORDS is not reused: it also stops
82
- // words ("history", "overview") that are real content in passage text.
95
+ // top-10. grounding.mjs's list is not reused: it also stops words
96
+ // ("history", "overview") that are real content in passage text.
83
97
  const LEXICAL_LAYOUT = 'bm25-v1';
84
98
  const LEXICAL_STOPWORDS = new Set(['the', 'a', 'an', 'and', 'or', 'but', 'of', 'to', 'in', 'on', 'at', 'by', 'for', 'with', 'from', 'into', 'is', 'are', 'was', 'were', 'be', 'been', 'being', 'it', 'its', 'this', 'that', 'these', 'those', 'as', 'their', 'they', 'them', 'his', 'her', 'has', 'have', 'had', 'not', 'can', 'will', 'if', 'we', 'you', 'your', 'i',
85
99
  'how', 'does', 'did', 'do', 'what', 'who', 'why', 'where', 'when', 'which']);
@@ -225,26 +239,6 @@ export function buildLexicalSegment(texts) {
225
239
  };
226
240
  }
227
241
 
228
- // Corpus layout v1 (format 1, profile pikelet-complete-v1): count + offsets +
229
- // records, integrity by whole-segment digest only. Kept for producing
230
- // format-1 files (compatibility fixtures, readers that predate format 2);
231
- // new artifacts use buildCorpusSegment() below.
232
- export function buildCorpusSegmentFromBuffers(records) {
233
- const count = records.length;
234
- const prefix = 4 + 8 * (count + 1);
235
- const total = prefix + records.reduce((sum, b) => sum + b.length, 0);
236
- const out = Buffer.alloc(total);
237
- out.writeUInt32LE(count, 0);
238
- let cursor = prefix;
239
- for (let id = 0; id < count; id++) {
240
- out.writeBigUInt64LE(BigInt(cursor), 4 + 8 * id);
241
- out.set(records[id], cursor); // set(), not copy(): records may be plain Uint8Arrays
242
- cursor += records[id].length;
243
- }
244
- out.writeBigUInt64LE(BigInt(cursor), 4 + 8 * count);
245
- return out;
246
- }
247
-
248
242
  // Corpus layout v2 (format 2, profile pikelet-complete-v2): per-record
249
243
  // integrity that a reader can check on the single range read that hydrates
250
244
  // a record, without fetching the rest of the segment (contract 4.1 / 7):
@@ -333,7 +327,8 @@ export function buildInlineTransformerEncoderSegment({ declaration, vocabBytes,
333
327
  // (MAX_RECOMMENDED_RERANK), so a pack never records a recall it would not be
334
328
  // served at; targetReached says whether the target was met below it.
335
329
  export async function measureRecommendedRerank({
336
- artifactModule,
330
+ // The sketch artifact module; defaults to this package's own.
331
+ artifactModule = artifactContract,
337
332
  sketchBytes,
338
333
  queryVectors = null,
339
334
  snapshotBytes = null,
@@ -434,12 +429,10 @@ function selfQueriesFromSnapshot(graph, maxQueries) {
434
429
  return queries;
435
430
  }
436
431
 
437
- // Container format version follows the profile string: pikelet-complete-v1
438
- // files carry corpus layout v1 and header version 1; pikelet-complete-v2
432
+ // Container format version follows the profile string: pikelet-complete-v2
439
433
  // files carry corpus layout records-v2 (buildCorpusSegment) and header
440
- // version 2, so readers that predate per-record integrity reject them
441
- // explicitly instead of misreading the corpus tables.
442
- export const PROFILE_V1 = 'pikelet-complete-v1';
434
+ // version 2. Format 1 (pikelet-complete-v1, corpus layout v1 without
435
+ // per-record digests) was dropped in 0.17.
443
436
  export const PROFILE_V2 = 'pikelet-complete-v2';
444
437
  // A layer is a complete-profile container under formatVersion 2 with its own
445
438
  // manifest profile string (LAYERED_PROFILE.md 4.1). A reader that predates the
@@ -447,37 +440,34 @@ export const PROFILE_V2 = 'pikelet-complete-v2';
447
440
  // existing "unsupported profile" error, which is the intended behavior: a layer
448
441
  // opened alone would silently serve a fraction of a corpus.
449
442
  export const PROFILE_LAYER = 'pikelet-layer-v1';
450
- export const FORMAT_VERSIONS = { [PROFILE_V1]: 1, [PROFILE_V2]: 2, [PROFILE_LAYER]: 2 };
443
+ export const FORMAT_VERSIONS = { [PROFILE_V2]: 2, [PROFILE_LAYER]: 2 };
451
444
 
452
445
  export function assemblePikeletFile(manifestFields, segments, outPath) {
453
446
  const formatVersion = FORMAT_VERSIONS[manifestFields.profile];
454
447
  if (!formatVersion) {
455
- throw new Error(`manifest.profile must be ${PROFILE_V1} or ${PROFILE_V2}, got ${manifestFields.profile}`);
448
+ throw new Error(`manifest.profile must be ${PROFILE_V2} or ${PROFILE_LAYER}, got ${manifestFields.profile}`);
456
449
  }
457
450
  const isLayer = manifestFields.profile === PROFILE_LAYER;
458
451
  const layout = manifestFields.corpus?.layout;
459
452
  // A tombstone-only layer (4.1) carries a corpus object with records 0 and
460
453
  // MUST omit the layout fields, because it has no corpus segment to describe.
461
454
  const tombstoneOnlyLayer = isLayer && manifestFields.corpus?.records === 0;
462
- if (formatVersion === 2 && !tombstoneOnlyLayer && layout !== CORPUS_LAYOUT_V2) {
455
+ if (!tombstoneOnlyLayer && layout !== CORPUS_LAYOUT_V2) {
463
456
  throw new Error(`${manifestFields.profile} requires manifest.corpus from buildCorpusSegment() (layout ${CORPUS_LAYOUT_V2})`);
464
457
  }
465
458
  if (tombstoneOnlyLayer && layout !== undefined) {
466
459
  throw new Error('a tombstone-only layer must omit corpus.layout');
467
460
  }
468
- if (formatVersion === 1 && layout !== undefined) {
469
- throw new Error(`${PROFILE_V1} carries corpus layout v1 (buildCorpusSegmentFromBuffers); got layout ${layout}`);
470
- }
471
461
  if (!Number.isInteger(manifestFields.corpus?.records) || manifestFields.corpus.records < 0) {
472
462
  throw new Error('manifest.corpus.records must be a non-negative integer');
473
463
  }
474
- // Format 2 additionally commits to the embedded sketch's 256-byte header
464
+ // The manifest commits to the embedded sketch's 256-byte header
475
465
  // under the identity. The header carries the sketch's metric/dim/count and
476
466
  // its residentSha256 / vectorsSha256, so anchoring the header anchors the
477
467
  // sketch's own integrity chain to the complete identity without forcing a
478
468
  // whole-segment read at open (the index segment stays lazy).
479
469
  let indexCommitment;
480
- if (formatVersion >= 2 && !tombstoneOnlyLayer) {
470
+ if (!tombstoneOnlyLayer) {
481
471
  const index = segments.find((s) => s.kind === 'index');
482
472
  if (!index || index.bytes.length < 256) {
483
473
  throw new Error('index segment must carry a 256-byte sketch header');
@@ -1,8 +1,7 @@
1
1
  // Vector/lexical rank fusion for hybrid retrieval — the one definition the
2
- // reader (index.mjs), the calibrator (pikelet/src/calibrate.mjs, which fits
3
- // coverage on the passage fusion ranks first) and the BEIR ladder
4
- // (benchmarks/beir/query-E.mjs) all call, so a fit-time or benchmark
5
- // ranking is the ranking the reader serves.
2
+ // reader (index.mjs), the chain reader (layer-reader.mjs) and the BEIR
3
+ // ladder (benchmarks/beir/query-E.mjs) all call, so a benchmark ranking is
4
+ // the ranking the reader serves.
6
5
  //
7
6
  // Reciprocal-rank fusion over the exact-reranked vector order and the BM25
8
7
  // order: score = 1/(K + vRank) + lexicalWeight/(K + lexRank), lexical term
@@ -24,6 +23,23 @@ export const FUSION_DEFAULTS = Object.freeze({
24
23
  guardMargin: 0.05,
25
24
  });
26
25
 
26
+ // Per-encoder overrides of FUSION_DEFAULTS, keyed by the encoder model a
27
+ // pack declares. A stronger encoder needs BM25 to compensate less: with
28
+ // BGE-small, lexicalWeight 0.25 beat 0.5 on FiQA (nDCG@10 +0.010) and
29
+ // TREC-COVID judged-only (+0.023) and was never worse on SciFact, NFCorpus
30
+ // or ArguAna, while MiniLM lost 0.039 on TREC-COVID at 0.25, so MiniLM
31
+ // keeps 0.5. The guard margin measured the same for both (0.02-0.1 equal;
32
+ // only 0 hurts), so it is not overridden.
33
+ export const ENCODER_FUSION_DEFAULTS = Object.freeze({
34
+ 'BAAI/bge-small-en-v1.5': Object.freeze({ lexicalWeight: 0.25 }),
35
+ });
36
+
37
+ // The fusion defaults for a pack whose encoder declares this model.
38
+ export function fusionDefaultsFor(model) {
39
+ const override = typeof model === 'string' ? ENCODER_FUSION_DEFAULTS[model] : undefined;
40
+ return override ? Object.freeze({ ...FUSION_DEFAULTS, ...override }) : FUSION_DEFAULTS;
41
+ }
42
+
27
43
  /**
28
44
  * @param {Array<{id: number, distance: number}>} vectorOrder hits sorted by
29
45
  * exact distance ascending (the rerank output), including every lexical
@@ -1,16 +1,12 @@
1
1
  // Grounding: which of the query's content words the best of the top
2
2
  // passages contains (covered) and which none of them does (uncovered). It
3
3
  // needs nothing from the pack but the passages' text, so every pack gets
4
- // it, calibrated or not; an agent reads `uncovered` to tell "the passage is
5
- // about this" from "the passage states this".
4
+ // it; an agent reads `uncovered` to tell "the passage is about this" from
5
+ // "the passage states this".
6
6
  //
7
- // The word rules follow the calibrated coverage term
8
- // (retrieval-abstention.mjs) — possessives stripped, light suffix stemming,
9
- // plural forms, heading-only matches at half credit — with two
10
- // differences: a token holding a digit counts whatever its length ("v8",
11
- // "3d", "4"), and every word weighs the same (the calibrated term discounts
12
- // corpus-common words through a bloom only a calibration asset carries).
13
- // The calibrated verdict keeps its own coverage term unchanged.
7
+ // Word rules: possessives stripped, light suffix stemming, plural forms,
8
+ // heading-only matches at half credit, a token holding a digit counted
9
+ // whatever its length ("v8", "3d", "4"), and every word weighing the same.
14
10
 
15
11
  // How many passages grounding reads, in fused order.
16
12
  export const GROUNDING_PASSAGES = 5;
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * pikelet-wasm/complete — reader for complete .pikelet artifacts
3
- * (spec/COMPLETE_PROFILE.md, profile pikelet-complete-v1). Opens any kind
4
- * (1 student-inline, 2 declared-external, 3 inline-transformer) from a file
5
- * path in Node or a range source anywhere.
3
+ * (spec/COMPLETE_PROFILE.md, profile pikelet-complete-v2). Opens either
4
+ * encoder kind (3 inline-transformer, the default; 2 host-supplied encoder)
5
+ * from a file path in Node or a range source anywhere. Files from before
6
+ * 0.17 (format 1, Pancake-era profiles, the student encoder) are refused.
6
7
  */
7
8
 
8
9
  /** A byte-range source: local file, HTTP, memory, or anything else. */
@@ -138,16 +139,6 @@ export declare const DEFAULT_BLOB_CACHE_BYTES: number;
138
139
  export declare const DEFAULT_SMALL_CACHE_BYTES: number;
139
140
 
140
141
  export interface CompleteQueryResult {
141
- /**
142
- * The pack's calibrated verdict on this retrieval. On packs calibrated
143
- * by pikelet 0.10 or later (evaluation calibration.target 'relevance')
144
- * it measures retrieval relevance: 'none' means the pack does not appear
145
- * to cover the query's topic, 'strong' that it does — not that a
146
- * returned passage states the specific fact asked for. 'unscored': the
147
- * pack ships no fitted calibrator, as every pack compiled after 0.14.0.
148
- */
149
- matchQuality: 'strong' | 'weak' | 'none' | 'unscored';
150
- confidence?: number;
151
142
  /**
152
143
  * Each result is the hydrated corpus record plus the search's `id` and
153
144
  * `distance`. Those two names are reserved: they always come from the
@@ -158,9 +149,8 @@ export interface CompleteQueryResult {
158
149
  /**
159
150
  * Which of the query's content words the best of the top five passages
160
151
  * (the one containing the most of them) contains (covered) and lacks
161
- * (uncovered). Computed for every pack, calibrated or not; absent only
162
- * when the query has no gradable word. An asked-for value in `uncovered`
163
- * is one the best passage does not state, whatever matchQuality says.
152
+ * (uncovered). Absent only when the query has no gradable word. An
153
+ * asked-for value in `uncovered` is one the best passage does not state.
164
154
  */
165
155
  grounding?: {
166
156
  /** Id of the passage that covered the most query words. */
@@ -177,9 +167,9 @@ export interface CompleteQueryResult {
177
167
  export interface CompleteSearch {
178
168
  info(): {
179
169
  identity: string;
180
- /** Container header formatVersion (1 or 2). */
170
+ /** Container header formatVersion (2). */
181
171
  formatVersion: number;
182
- /** Manifest profile: 'pikelet-complete-v1' | 'pikelet-complete-v2'. */
172
+ /** Manifest profile: 'pikelet-complete-v2'. */
183
173
  profile: string;
184
174
  /**
185
175
  * Human-readable pack name from the identity-verified manifest
@@ -209,13 +199,17 @@ export interface CompleteSearch {
209
199
  * unverified; it resolves before the first query completes). While
210
200
  * deferred, `encoder` serves the identity-verified manifest declaration
211
201
  * with `deferred: true`, replaced by the full declaration on arrival.
212
- * Kind 1: null (inline student encoder, nothing external to verify).
213
202
  */
214
203
  encoderVerified: boolean | null;
215
204
  /**
216
- * 'per-record-sha256' on format 2 (each hydrated record verified on its
217
- * own range read); 'segment-sha256' on format 1 (whole-segment digests
218
- * only, lazy record reads not independently verifiable).
205
+ * The rank-fusion parameters query() applies by default: FUSION_DEFAULTS
206
+ * overridden for the pack's encoder model (ENCODER_FUSION_DEFAULTS).
207
+ */
208
+ fusion: Readonly<Required<FusionOptions>>;
209
+ /**
210
+ * 'per-record-sha256': each hydrated record is verified on its own range
211
+ * read ('per-record-sha256 (unverified by option)' with verifyRecords:
212
+ * false).
219
213
  */
220
214
  corpusIntegrity: string;
221
215
  fileBytes: number;
@@ -284,17 +278,15 @@ export interface CompleteSearch {
284
278
  * metric). Abstention scores identically in every mode.
285
279
  */
286
280
  retrieval?: 'hybrid' | 'vector' | 'lexical' | 'augmented';
281
+ /**
282
+ * Rank-fusion parameters for this call, merged over the pack's defaults
283
+ * (info().fusion). Hybrid retrieval only.
284
+ */
285
+ fusion?: FusionOptions;
287
286
  rerank?: number;
288
287
  parallelism?: number;
289
288
  gap?: number;
290
289
  maxRangeBytes?: number;
291
- /**
292
- * A matchQuality: 'none' verdict withholds results by default. Set
293
- * true to see the raw retrieval anyway (e.g. to inspect why the
294
- * classifier abstained) — matchQuality and confidence are unaffected,
295
- * this only controls whether results is populated. Default false.
296
- */
297
- showAbstained?: boolean;
298
290
  }): Promise<CompleteQueryResult>;
299
291
  /** Hydrate one corpus record by id (verified per record on format 2). */
300
292
  record(id: number): Promise<Record<string, unknown>>;
@@ -331,8 +323,8 @@ export declare function openPikeletFile(
331
323
  * Kind-3 artifacts open lazily: the ~25 MiB inline-encoder region is not
332
324
  * read at open, and by default starts downloading in the background the
333
325
  * moment open resolves (the first query awaits it; the whole segment is
334
- * digest-verified on arrival, and the header/calibration slices used at
335
- * open are byte-compared against it before any result is returned).
326
+ * digest-verified on arrival, and the header read at open is
327
+ * byte-compared against it before any result is returned).
336
328
  * Set false to defer the transfer entirely to the first query. Default
337
329
  * true.
338
330
  */
@@ -401,7 +393,7 @@ export declare function openPikeletFile(
401
393
  /** Header formatVersion -> manifest profile accepted by this reader. */
402
394
  export declare const SUPPORTED_PROFILES: Readonly<Record<number, string>>;
403
395
 
404
- /** Rank-fusion parameters shared by the reader, the calibrator and the BEIR ladder. */
396
+ /** Rank-fusion parameters shared by the reader, the chain reader and the BEIR ladder. */
405
397
  export interface FusionOptions {
406
398
  /** Reciprocal-rank-fusion constant (default 60). */
407
399
  rrfK?: number;
@@ -414,6 +406,13 @@ export interface FusionOptions {
414
406
  guardMargin?: number;
415
407
  }
416
408
  export declare const FUSION_DEFAULTS: Readonly<Required<FusionOptions>>;
409
+ /**
410
+ * Per-encoder overrides of FUSION_DEFAULTS, keyed by the declared encoder
411
+ * model (BAAI/bge-small-en-v1.5: lexicalWeight 0.25).
412
+ */
413
+ export declare const ENCODER_FUSION_DEFAULTS: Readonly<Record<string, Readonly<FusionOptions>>>;
414
+ /** The fusion defaults for a pack whose encoder declares this model. */
415
+ export declare function fusionDefaultsFor(model: string | null | undefined): Readonly<Required<FusionOptions>>;
417
416
  /**
418
417
  * Fuse the exact-reranked vector order (every lexical candidate included) with the BM25 order.
419
418
  * Returns the same hit objects, reordered.