pikelet-wasm 0.16.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.
- package/CHANGELOG.md +130 -0
- package/FORMAT.md +52 -59
- package/README.md +2 -2
- package/complete/builder.d.ts +8 -7
- package/complete/builder.mjs +18 -36
- package/complete/fusion.mjs +3 -4
- package/complete/grounding.mjs +5 -9
- package/complete/index.d.ts +14 -32
- package/complete/index.mjs +94 -288
- package/complete/inline-transformer.mjs +0 -64
- package/complete/layer-append.mjs +5 -31
- package/complete/layer-chain.mjs +7 -53
- package/complete/layer-compact.mjs +3 -4
- package/complete/layer-encoder.mjs +17 -123
- package/complete/layer-reader.mjs +20 -147
- package/complete/layer-rebase.mjs +1 -1
- package/complete/wordpiece.mjs +0 -22
- package/dist/engine.js +1 -1
- package/dist/engine.scalar.js +1 -1
- package/dist/engine.scalar.wasm +0 -0
- package/dist/engine.wasm +0 -0
- package/package.json +1 -1
- package/src/artifact/pikelet-artifact-sketch.js +48 -124
- package/src/core/pikelet-core.js +6 -3
- package/complete/retrieval-abstention.mjs +0 -232
- package/complete/student-abstention.mjs +0 -102
- package/complete/student-embedder.mjs +0 -231
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,136 @@ Through 0.6.0 these were published as `pancake-wasm` and
|
|
|
8
8
|
packages are pre-1.0: a minor bump may carry breaking changes, and each entry lists them
|
|
9
9
|
first.
|
|
10
10
|
|
|
11
|
+
## pikelet-wasm 0.17.0 / pikelet 0.17.0 — 2026-12-02
|
|
12
|
+
|
|
13
|
+
Pikelet removes what the format freeze should not carry. Readers refuse
|
|
14
|
+
files from before format 2's integrity guarantees and from before the
|
|
15
|
+
rename: format 1, format-1 sketches, student-encoder (kind 1) packs and the
|
|
16
|
+
`pancake-complete` profile strings, each with a message to recompile. The
|
|
17
|
+
`matchQuality` verdict, which `compile` stopped fitting in 0.15, leaves the
|
|
18
|
+
library, the CLI, the MCP server and layered chains, along with the drift
|
|
19
|
+
gate and vocabulary blooms that kept an inherited fit valid; `grounding` is
|
|
20
|
+
the relevance signal every query returns. Packs compiled since 0.15 open
|
|
21
|
+
unchanged, and `compile` writes the same bytes as 0.16. Quantized search
|
|
22
|
+
is 1.3-1.8x faster and returns the same results. Both packages move to
|
|
23
|
+
0.17.0 together, and `pikelet` requires `pikelet-wasm` ^0.17.0.
|
|
24
|
+
|
|
25
|
+
### Compatibility
|
|
26
|
+
|
|
27
|
+
- **Files from before 0.17 no longer open** in `pikelet-wasm`, so neither
|
|
28
|
+
`pikelet query` nor `pikelet mcp` can serve them. Each is refused with a
|
|
29
|
+
message naming the release and telling you to recompile from source:
|
|
30
|
+
- format 1 (`pikelet-complete-v1`, corpus layout v1 with no per-record
|
|
31
|
+
digests);
|
|
32
|
+
- an embedded or standalone sketch of format 1 (no per-row digests):
|
|
33
|
+
"Sketch artifact format 1 is no longer supported";
|
|
34
|
+
- query-interpretation kind 1 (`student-inline-v1`, the student encoder
|
|
35
|
+
the 0.15 scaffold could build);
|
|
36
|
+
- the Pancake-era profile strings `pancake-complete-v1` and
|
|
37
|
+
`pancake-complete-v2`. This covers packs that were already format 2
|
|
38
|
+
but kept the old string through the rename.
|
|
39
|
+
|
|
40
|
+
Every pack `compile` has written since 0.5.0 is format 2 with a
|
|
41
|
+
format-2 sketch; packs from before the rename are the ones most likely
|
|
42
|
+
to be refused. The shelf in `packs/packs.json` now points at the
|
|
43
|
+
`shelf-packs-v2` release, recompiled so 0.17 opens them; the Wikipedia
|
|
44
|
+
pack it listed before (`artifact-wiki-inline-v4`) is one that is
|
|
45
|
+
refused.
|
|
46
|
+
- **`matchQuality` and `confidence` are gone from query results.**
|
|
47
|
+
`query()` returns `{ results, grounding }` on a single file and on a
|
|
48
|
+
chain. `showAbstained` is ignored, so a pre-0.15 pack whose fit says
|
|
49
|
+
`none` now returns its results. Chains no longer report
|
|
50
|
+
`calibrationDrift`, `calibrationStatus`, `driftLimit`,
|
|
51
|
+
`producerEnvelope` or `readerLimit` in `info()`, or `calibration` in
|
|
52
|
+
`query()`; `pikelet mcp`'s `list_packs` drops the first two. The
|
|
53
|
+
calibration region of a pack's query-interpretation segment is reserved
|
|
54
|
+
and readers ignore it, whatever it holds.
|
|
55
|
+
- **CLI flags removed with the verdict and the drift gate are refused by
|
|
56
|
+
name**, each with what replaced it: `--calibration`,
|
|
57
|
+
`--skip-calibration`, `--calibration-queries` (use `--golden-queries`),
|
|
58
|
+
`--allow-drift`, `--reader-drift-limit` and `--no-refit`. `append` no
|
|
59
|
+
longer gates on drift; layers carry no vocabulary bloom.
|
|
60
|
+
- **Removed from `pikelet-wasm`:** `chainBloom()`, the `readerDriftLimit`
|
|
61
|
+
option and `CHAIN_DEFAULTS.readerDriftLimit`; `calibrationDrift` and
|
|
62
|
+
`calibrationStatus` from `complete/layer-chain`; `checkAppendDrift` and
|
|
63
|
+
`buildLayerSegments`' `layerBloom` from `complete/layer-append`;
|
|
64
|
+
`unionBloom` and `LAYER_VOCAB_KIND`; `__calibrationEvidence` and
|
|
65
|
+
`base64Bytes`; the inline encoder's `embedWords` and the tokenizer's
|
|
66
|
+
`encodeWithWordMap`; and from `complete/builder`, `PROFILE_V1` and
|
|
67
|
+
`buildCorpusSegmentFromBuffers`. `buildQueryInterpSegment`'s calibration
|
|
68
|
+
argument is optional and defaults to the bytes `compile` has written
|
|
69
|
+
since 0.15. `exportSketchArtifact` refuses `rowIntegrity: false`, and
|
|
70
|
+
sketch row fetches are always verified unless `verify: false`.
|
|
71
|
+
- **`info()` integrity fields narrow.** `corpusIntegrity` is always
|
|
72
|
+
`per-record-sha256`; `indexRowIntegrity` is `per-row-sha256` (or
|
|
73
|
+
`per-row-sha256 (unverified by option)`), never `segment-sha256`. The
|
|
74
|
+
manifest's index header commitment (`index.headerSha256`) is required.
|
|
75
|
+
- **Quantized indexes use more memory, and the capacity guard is
|
|
76
|
+
tighter.** A u8 index now keeps a compact copy of its base-layer
|
|
77
|
+
neighbour ids, about `8*M + 4` bytes per row (about 100 bytes at the
|
|
78
|
+
default M=12), and pads each row to 16 bytes. `create()`'s estimate
|
|
79
|
+
becomes `16*ceil(dim/16) + 24*M + 43` bytes per element, so the largest
|
|
80
|
+
u8 index the 1.5 GiB wasm32 budget accepts is about 15-20% smaller
|
|
81
|
+
(at 384 dimensions and M=16, about 1.98M rows instead of 2.37M).
|
|
82
|
+
|
|
83
|
+
### Changed
|
|
84
|
+
|
|
85
|
+
- **Quantized (u8) search is 1.3-1.8x faster.** Most of a query's time
|
|
86
|
+
was spent waiting on memory, so the base-layer search now reads less
|
|
87
|
+
of it, and reads it in parallel:
|
|
88
|
+
- each row's scale, offset and sums sit in a 16-byte header in front of
|
|
89
|
+
its bytes, so one distance reads one contiguous block where it read
|
|
90
|
+
up to four separate arrays;
|
|
91
|
+
- L2 and cosine distances use the expanded form, with the query's terms
|
|
92
|
+
computed once per query, leaving one multiply-add per dimension. L2
|
|
93
|
+
centres the query on its own mean first, so a large offset shared by
|
|
94
|
+
query and rows cancels exactly instead of swamping float32 precision,
|
|
95
|
+
and a distance too small to trust against the float32 rounding of
|
|
96
|
+
its one remaining dot product (a worst-case bound, computed per row)
|
|
97
|
+
is recomputed per dimension;
|
|
98
|
+
- the search reads 4-byte neighbour ids from a compact list, not the
|
|
99
|
+
8-byte edges that carry graph-maintenance distances;
|
|
100
|
+
- before scoring a node's unvisited neighbours, it touches each one's
|
|
101
|
+
row in a tight loop, so their cache misses overlap (WebAssembly has
|
|
102
|
+
no prefetch instruction).
|
|
103
|
+
|
|
104
|
+
Through the `Pikelet` API on one core, ef 40/100/200 went from 4,840 /
|
|
105
|
+
2,360 / 1,330 to 8,660 / 4,320 / 2,410 queries/s on SIFT-1M (L2) and
|
|
106
|
+
from 4,690 / 2,350 / 1,340 to 7,630 / 4,000 / 2,260 on NYTimes-256
|
|
107
|
+
(cosine). Long rows gain less, because more of their time is arithmetic:
|
|
108
|
+
on DBpedia-50K (1,536 dimensions) ef 40/100/200 went from 2,555 / 1,298
|
|
109
|
+
/ 742 to 3,544 / 1,772 / 997 (L2) and from 2,893 / 1,459 / 837 to 3,611
|
|
110
|
+
/ 1,830 / 1,024 (cosine). Results are unchanged: the whole candidate set
|
|
111
|
+
is re-scored with the same per-dimension distance as before and ordered
|
|
112
|
+
by it before the top k are taken, and on recorded queries (L2 and
|
|
113
|
+
cosine, u8 and float32, after deletes, compaction, a snapshot round trip
|
|
114
|
+
and inserts into a restored index, plus data with large shared offsets
|
|
115
|
+
and exact duplicates) ids, order and distance bits all match 0.16. Graph
|
|
116
|
+
construction is untouched, so snapshots and compiled packs are
|
|
117
|
+
byte-identical. Float32 indexes are unchanged.
|
|
118
|
+
|
|
119
|
+
### Fixed
|
|
120
|
+
|
|
121
|
+
- **The test suites no longer hang at exit on Node 24 and 26.**
|
|
122
|
+
`process.exit()` can deadlock there after WASM-heavy work: it joins
|
|
123
|
+
V8's worker threads while a background Maglev compile waits for the
|
|
124
|
+
main thread to collect garbage. The test files now set
|
|
125
|
+
`process.exitCode` and exit when their event loop drains (one test hung
|
|
126
|
+
in 36 of 300 runs before, 0 of 300 after), and every CI job has a
|
|
127
|
+
timeout. The `pikelet` CLI's error path exits the same way, with a 1 s
|
|
128
|
+
forced exit if something keeps the process alive; the hang was not
|
|
129
|
+
reproduced on the CLI.
|
|
130
|
+
|
|
131
|
+
### Documentation
|
|
132
|
+
|
|
133
|
+
- `FORMAT.md`, `COMPLETE_PROFILE.md`, `LAYERED_PROFILE.md` (sections 3.1,
|
|
134
|
+
4.5, 5.5, 6.1, 6.3, 10-13), `SKETCH_PROFILE.md`, the contract, the
|
|
135
|
+
READMEs and `SECURITY.md` describe the 0.17 reader: format 2 only,
|
|
136
|
+
kinds 2-4, a reserved calibration region and no drift gate.
|
|
137
|
+
`docs/veyra-ablation.md` records the ablation under 0.17's grounding.
|
|
138
|
+
- The docs-corpus spike in `examples/one-file-search` (a kind-1 pack and
|
|
139
|
+
the scripts and browser page built on it) moved to `archive/v0`.
|
|
140
|
+
|
|
11
141
|
## pikelet-wasm 0.16.0 / pikelet 0.16.0 — 2026-11-30
|
|
12
142
|
|
|
13
143
|
Pikelet narrows to the `.pikelet` toolchain. The Cloudflare Worker
|
package/FORMAT.md
CHANGED
|
@@ -41,7 +41,7 @@ Two packs built by the current compiler, for scale:
|
|
|
41
41
|
|
|
42
42
|
| Segment | 3-record folder | Simple English Wikipedia (456,153 records) |
|
|
43
43
|
| --- | ---: | ---: |
|
|
44
|
-
| Query interpretation (encoder
|
|
44
|
+
| Query interpretation (encoder) | 24.5 MiB | 24.9 MiB |
|
|
45
45
|
| Index (vector sketch + rows) | 2.0 KiB | 220.1 MiB |
|
|
46
46
|
| Corpus (records + digests) | 2.4 KiB | 334.4 MiB |
|
|
47
47
|
| Lexical (BM25) | 1.1 KiB | 69.2 MiB |
|
|
@@ -133,7 +133,7 @@ covered by the identity.
|
|
|
133
133
|
| ---: | --- | --- | --- |
|
|
134
134
|
| 1 | index | required | resident prefix at open, rows per query |
|
|
135
135
|
| 2 | corpus | required | tables at open, one record per hydrated result |
|
|
136
|
-
| 3 | query-interp | required |
|
|
136
|
+
| 3 | query-interp | required | header at open; encoder before the first query |
|
|
137
137
|
| 4 | evaluation | required for conformance | only by `verify_pack` and tests |
|
|
138
138
|
| 5 | lexical | optional; written by default | whole at open, or lazily above 8 MiB |
|
|
139
139
|
| 6 | tombstones | layers only | whole at mount |
|
|
@@ -159,43 +159,35 @@ A record carries at least `title`, `text` and `sourcePath`, and optionally
|
|
|
159
159
|
conversation turn, a journal note). Records are stored uncompressed.
|
|
160
160
|
Record `i` is the vector index's row `i` (or, with a
|
|
161
161
|
[row map](#row-map-kind-8), owns a run of rows): the compiler numbers
|
|
162
|
-
them together, so the file has no id map.
|
|
163
|
-
count and offsets, with no page table or record digests.
|
|
162
|
+
them together, so the file has no id map.
|
|
164
163
|
|
|
165
164
|
### Query-interpretation segment (kind 3)
|
|
166
165
|
|
|
167
166
|
```
|
|
168
167
|
u32 version 1
|
|
169
|
-
u32 kind
|
|
170
|
-
|
|
168
|
+
u32 kind 2 external-transformers-v1, 3 inline-transformer-v1,
|
|
169
|
+
4 inherited-v1 (layers only); 1 (student-inline-v1)
|
|
170
|
+
is refused since 0.17
|
|
171
171
|
u32 encoderBytes
|
|
172
172
|
u32 calibrationBytes
|
|
173
173
|
encoder per kind (see The embedded encoder)
|
|
174
|
-
calibration UTF-8 JSON
|
|
174
|
+
calibration reserved; UTF-8 JSON
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
-
The
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
Packs compiled
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
and the query's word coverage into a `matchQuality` verdict: `strong`,
|
|
192
|
-
`weak` or `none`. Packs from the last of those releases also carry a
|
|
193
|
-
second, distance-only model (`gate`) that alone decides `none`; word
|
|
194
|
-
coverage then only separates `strong` from `weak`. Readers that predate
|
|
195
|
-
the gate ignore it. The verdict measures whether the corpus covers the
|
|
196
|
-
question's topic, not whether a passage states the answer.
|
|
197
|
-
[docs/calibration.md](docs/calibration.md) says why `compile` stopped
|
|
198
|
-
fitting it.
|
|
177
|
+
The calibration region is reserved. `compile` writes the placeholder it
|
|
178
|
+
has written since 0.15 (`{"kind":"retrieval-signals-v1","asset":null,"vocabBloomBase64":""}`),
|
|
179
|
+
so removing the verdict in 0.17 moved no pack's identity. Readers ignore
|
|
180
|
+
the region, whatever it holds; its bytes are still covered by the
|
|
181
|
+
segment digest. Packs compiled by 0.14.0 and earlier may hold a fitted
|
|
182
|
+
`retrieval-signals-v1` model there, which turned search signals into a
|
|
183
|
+
`matchQuality` verdict (`strong`, `weak` or `none`); readers since 0.17
|
|
184
|
+
ignore it, so such a pack's results are neither labelled nor withheld.
|
|
185
|
+
[docs/calibration.md](docs/calibration.md) says why the verdict was
|
|
186
|
+
removed.
|
|
187
|
+
|
|
188
|
+
A query returns `grounding`: the question's words the best of the top
|
|
189
|
+
five passages contains and lacks, computed from the passages' text alone
|
|
190
|
+
([how a query runs](docs/how-a-query-runs.md#grounding-which-question-words-the-passages-contain)).
|
|
199
191
|
|
|
200
192
|
### Evaluation segment (kind 4)
|
|
201
193
|
|
|
@@ -203,7 +195,7 @@ UTF-8 JSON: the golden queries the pack was built with (each a question
|
|
|
203
195
|
and the record or title it must retrieve in the top 10) and the
|
|
204
196
|
recall-versus-rerank-depth sweep that chose `recommendedRerank`; packs
|
|
205
197
|
compiled by 0.14.0 and earlier also hold expected verdicts and the
|
|
206
|
-
calibration's fit metrics. `compile` keeps only goldens the assembled
|
|
198
|
+
calibration's fit metrics, which nothing reads since 0.17. `compile` keeps only goldens the assembled
|
|
207
199
|
pack passes, and `verify_pack` (MCP) replays them on demand. A reader can serve queries
|
|
208
200
|
without ever reading this segment.
|
|
209
201
|
|
|
@@ -212,7 +204,7 @@ without ever reading this segment.
|
|
|
212
204
|
**Identity** is `manifestSha256`. The manifest commits to each segment's
|
|
213
205
|
digest, and some segments commit further to their own parts, so the
|
|
214
206
|
identity transitively commits to every byte of content. Two files with the
|
|
215
|
-
same identity hold the same corpus, indexes
|
|
207
|
+
same identity hold the same corpus, indexes and encoder.
|
|
216
208
|
|
|
217
209
|
**Pinning.** A reader can be told the identity it expects:
|
|
218
210
|
`openPikeletFile(url, { expectedIdentity })`, `pikelet mcp --pack
|
|
@@ -256,15 +248,16 @@ run by kernels that ship with the reader.
|
|
|
256
248
|
## The embedded encoder
|
|
257
249
|
|
|
258
250
|
The query encoder is inside the file, so a query needs no model download,
|
|
259
|
-
no embedding API and no network beyond the file itself.
|
|
260
|
-
|
|
261
|
-
small and full-quality:
|
|
251
|
+
no embedding API and no network beyond the file itself. Two query-interpretation kinds open,
|
|
252
|
+
each giving up one of self-contained and small:
|
|
262
253
|
|
|
263
254
|
| Kind | Name | Encoder bytes | Trade-off |
|
|
264
255
|
| ---: | --- | --- | --- |
|
|
265
256
|
| 3 | `inline-transformer-v1` | the quantized transformer itself, ~24 MiB | the default; self-contained and full quality, but large |
|
|
266
|
-
|
|
|
267
|
-
|
|
257
|
+
| 2 | `external-transformers-v1` | a JSON declaration naming the model, plus test vectors | small and full quality, but the host must supply the encoder. Built only by releases before 0.16; `pikelet mcp` refuses it |
|
|
258
|
+
|
|
259
|
+
Kind 1 (`student-inline-v1`), a small distilled student model, was built
|
|
260
|
+
by releases before 0.16; readers since 0.17 refuse it.
|
|
268
261
|
|
|
269
262
|
**Kind 3**, which `pikelet compile` writes, holds three length-prefixed
|
|
270
263
|
regions:
|
|
@@ -351,8 +344,8 @@ the table. Up to 8 MiB the segment is read whole; above that only the
|
|
|
351
344
|
header and doclens are read at open, and term windows and postings are
|
|
352
345
|
fetched per query (see [integrity](#identity-and-integrity) for the cost).
|
|
353
346
|
|
|
354
|
-
The tokenizer keeps lowercase `[a-z0-9']` runs of 2–32 characters.
|
|
355
|
-
|
|
347
|
+
The tokenizer keeps lowercase `[a-z0-9']` runs of 2–32 characters.
|
|
348
|
+
`grounding` grades
|
|
356
349
|
words of three letters or more, or any word holding a digit. BM25 parameters are
|
|
357
350
|
k1 = 1.2, b = 0.75.
|
|
358
351
|
|
|
@@ -389,14 +382,9 @@ ancestor.
|
|
|
389
382
|
`(oldId, newId)` pairs in the same segment.
|
|
390
383
|
- A layer carries no encoder. Its query-interpretation segment is kind 4
|
|
391
384
|
(`inherited-v1`), which names the base's identity and the digest of the
|
|
392
|
-
base's encoder segment;
|
|
393
|
-
|
|
385
|
+
base's encoder segment; its calibration region is reserved, as in a
|
|
386
|
+
base.
|
|
394
387
|
- A chain is at most 16 layers deep; by default `append` stops at 8.
|
|
395
|
-
- A base calibrated by 0.14.0 or earlier keeps its calibration until
|
|
396
|
-
accumulated change (records appended plus records deleted, over the
|
|
397
|
-
base's record count) passes a limit of 0.20; past it the chain is
|
|
398
|
-
served `unscored` and `append` refuses unless given `--allow-drift`. A
|
|
399
|
-
base with no calibration has no such limit.
|
|
400
388
|
- `pikelet compact` folds a chain into a new base whose lineage segment
|
|
401
389
|
(kind 7) translates every earlier head's ids forward.
|
|
402
390
|
|
|
@@ -408,10 +396,10 @@ Versions sit at several levels, and each is checked by the reader:
|
|
|
408
396
|
|
|
409
397
|
| Level | Where | Values |
|
|
410
398
|
| --- | --- | --- |
|
|
411
|
-
| Container | header `formatVersion` + manifest `profile` | `
|
|
412
|
-
| Corpus layout | manifest `corpus.layout` |
|
|
413
|
-
| Vector index | sketch header `formatVersion` | `
|
|
414
|
-
| Encoder
|
|
399
|
+
| Container | header `formatVersion` + manifest `profile` | `2` = `pikelet-complete-v2` or `pikelet-layer-v1` |
|
|
400
|
+
| Corpus layout | manifest `corpus.layout` | `records-v2` |
|
|
401
|
+
| Vector index | sketch header `formatVersion` | `2` (per-row digests) |
|
|
402
|
+
| Encoder | query-interp `version` and `kind` | version 1; kinds 2–4 |
|
|
415
403
|
| Keyword index | manifest `lexical.layout` + segment version | `bm25-v1` |
|
|
416
404
|
| Other segments | their own version words | tombstones, lineage and row map: 1 |
|
|
417
405
|
| Ingestion | manifest `corpus.ingest.chunker` | `pikelet-section-v1` |
|
|
@@ -423,17 +411,23 @@ they do not know.
|
|
|
423
411
|
|
|
424
412
|
Format 2 with a version-2 sketch has been what the compiler writes since
|
|
425
413
|
0.5.0 (2026-08-26). Keyword indexes arrived in 0.6.0, layers in 0.9.0,
|
|
426
|
-
the ingestion declaration in 0.9.2 and row maps in 0.11.0.
|
|
414
|
+
the ingestion declaration in 0.9.2 and row maps in 0.11.0. Readers since
|
|
415
|
+
0.17 refuse format 1, sketch format 1, kind 1 and the Pancake-era profile
|
|
416
|
+
strings.
|
|
427
417
|
|
|
428
418
|
## Compatibility
|
|
429
419
|
|
|
430
|
-
- **
|
|
431
|
-
|
|
432
|
-
|
|
420
|
+
- **Files from before 0.17.** Readers since 0.17 refuse format 1
|
|
421
|
+
(`pikelet-complete-v1`, no per-record digests), sketch format 1 (no
|
|
422
|
+
per-row digests), query-interpretation kind 1 (`student-inline-v1`) and
|
|
423
|
+
the Pancake-era profile strings `pancake-complete-v1` and `-v2`, each
|
|
424
|
+
with a message to recompile from source. Every pack the compiler has
|
|
425
|
+
written since 0.5.0 is format 2 with a version-2 sketch; the profile
|
|
426
|
+
string is what decides most older packs.
|
|
433
427
|
- **The Pancake era.** The project was called Pancake until September
|
|
434
|
-
2026. Readers
|
|
435
|
-
|
|
436
|
-
|
|
428
|
+
2026 ([history](docs/history.md)). Readers dispatch on magic bytes, not
|
|
429
|
+
file extensions, so a `.pancake` file whose profile is
|
|
430
|
+
`pikelet-complete-v2` opens.
|
|
437
431
|
- **Older readers and newer files.** A reader that predates the keyword
|
|
438
432
|
index skips it and serves vector-only results from the same file. A
|
|
439
433
|
reader that predates row maps refuses a file that carries one (its
|
|
@@ -442,8 +436,7 @@ the ingestion declaration in 0.9.2 and row maps in 0.11.0.
|
|
|
442
436
|
- **Identity is stable under reading, not rebuilding.** Recompiling the
|
|
443
437
|
same inputs with the same compiler version gives the same identity
|
|
444
438
|
(releases up to 0.14.0 need `SOURCE_DATE_EPOCH` set for this). A
|
|
445
|
-
different compiler version can change chunking,
|
|
446
|
-
defaults, and with them the identity.
|
|
439
|
+
different compiler version can change chunking or defaults, and with them the identity.
|
|
447
440
|
- **Transport.** Over HTTP the host must answer `Range` requests with
|
|
448
441
|
`206 Partial Content`. If the file's validator (`ETag`) changes while it
|
|
449
442
|
is open, reads fail with `ARTIFACT_CHANGED` instead of mixing bytes from
|
|
@@ -470,7 +463,7 @@ the ingestion declaration in 0.9.2 and row maps in 0.11.0.
|
|
|
470
463
|
highly (record text and vector rows are still verified). Format-1
|
|
471
464
|
files have the same gap for records and rows.
|
|
472
465
|
- **Retrieval behaviour is partly in the reader.** The file fixes the
|
|
473
|
-
encoder
|
|
466
|
+
encoder and the indexes. The fusion rule, BM25
|
|
474
467
|
parameters and cut-offs come from the reader, so two reader versions
|
|
475
468
|
may rank the same pack differently.
|
|
476
469
|
- **No metadata filters, no compression.** There is no filter or facet
|
package/README.md
CHANGED
|
@@ -118,7 +118,7 @@ On a 20-record test pack with a 24.6 MiB base, deleting a record took a 1.2 KiB
|
|
|
118
118
|
|
|
119
119
|
A nearest neighbour is not evidence that a corpus answers a question: every query returns *something*. Pikelet does not try to decide for you. Each result carries its vector `distance` (results come in hybrid order, which also weighs keyword matches, so distances are not always ascending), and each response lists the question's words missing from whichever of the top five passages contains the most of them (`grounding.uncovered`). "How do I keep snapshots forever" against a pack whose snapshot page never mentions keeping them forever comes back with `keep` and `forever` uncovered; the MCP server tells the model to cite only a passage that states the answer.
|
|
120
120
|
|
|
121
|
-
Earlier releases also shipped a relevance verdict (`matchQuality: strong | weak | none`) fitted at build time. On a 1,377-article Wikipedia pack it called 278 of 512 questions whose answer article was not in the pack `strong`, and agents given the verdict declined unanswerable questions no more often than agents without it: they read the passages either way. So `compile`
|
|
121
|
+
Earlier releases also shipped a relevance verdict (`matchQuality: strong | weak | none`) fitted at build time. On a 1,377-article Wikipedia pack it called 278 of 512 questions whose answer article was not in the pack `strong`, and agents given the verdict declined unanswerable questions no more often than agents without it: they read the passages either way. So `compile` stopped fitting one in 0.15, and 0.17 removed the verdict from the library as well. [docs/calibration.md](docs/calibration.md#why-the-verdict-was-dropped-2026-11) has the measurements.
|
|
122
122
|
|
|
123
123
|
None of this is a guarantee that an LLM will never hallucinate.
|
|
124
124
|
|
|
@@ -162,7 +162,7 @@ The **range proof** uses a server that does not understand Pikelet and reports m
|
|
|
162
162
|
|
|
163
163
|
Pikelet is early: the implementation is real, the format is not frozen, and there is one primary author. Prebuilt WASM, local and HTTP readers, the embedded encoder, BM25 hybrid retrieval, content identity with lazy-read verification (except large keyword indexes, as above), query-word grounding, MCP mounting, layered updates, and the experimental journal all ship today. `npm test` runs the engine, artifact-profile, MCP, ingestion, and format-hardening conformance suites.
|
|
164
164
|
|
|
165
|
-
Previously known as **Pancake** (renamed September 2026);
|
|
165
|
+
Previously known as **Pancake** (renamed September 2026); packs that still carry the `pancake-complete` profile string must be recompiled to open with 0.17 or later — see [`docs/history.md`](docs/history.md). Pikelet is unrelated to the Pikelet programming language.
|
|
166
166
|
|
|
167
167
|
## License
|
|
168
168
|
|
package/complete/builder.d.ts
CHANGED
|
@@ -32,16 +32,17 @@ export declare function canonicalJson(value: unknown): string;
|
|
|
32
32
|
export declare const align16: (n: number) => number;
|
|
33
33
|
|
|
34
34
|
/** Manifest profile strings and the header formatVersion each one implies. */
|
|
35
|
-
export declare const PROFILE_V1: 'pikelet-complete-v1';
|
|
36
35
|
export declare const PROFILE_V2: 'pikelet-complete-v2';
|
|
37
36
|
export declare const FORMAT_VERSIONS: Record<string, number>;
|
|
38
37
|
/** Corpus layout name for format 2 (per-record digests behind a page table). */
|
|
39
38
|
export declare const CORPUS_LAYOUT_V2: 'records-v2';
|
|
40
39
|
export declare const DEFAULT_CORPUS_PAGE_RECORDS: number;
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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;
|
|
45
46
|
/**
|
|
46
47
|
* Corpus layout v2 (format 2): count, pageRecords, offsets, a page table of
|
|
47
48
|
* SHA-256s over runs of record digests, one SHA-256 per record, then the
|
|
@@ -64,9 +65,9 @@ export declare function buildInlineTransformerEncoderSegment(input: {
|
|
|
64
65
|
weightBytes: Buffer | Uint8Array;
|
|
65
66
|
}): Buffer;
|
|
66
67
|
/**
|
|
67
|
-
* Writes the container. manifestFields.profile
|
|
68
|
-
*
|
|
69
|
-
*
|
|
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
|
|
70
71
|
* spec does not name must carry an explicit kindNumber (readers skip them).
|
|
71
72
|
*/
|
|
72
73
|
export declare function assemblePikeletFile(
|
package/complete/builder.mjs
CHANGED
|
@@ -44,7 +44,14 @@ export function canonicalJson(value) {
|
|
|
44
44
|
return JSON.stringify(value);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
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) {
|
|
48
55
|
const out = Buffer.alloc(16 + encoderBytes.length + calibrationBytes.length);
|
|
49
56
|
out.writeUInt32LE(1, 0);
|
|
50
57
|
out.writeUInt32LE(kind, 4);
|
|
@@ -85,8 +92,8 @@ export function buildQueryInterpSegment(kind, encoderBytes, calibrationBytes) {
|
|
|
85
92
|
// Interrogatives (how/does/what/...) are stopped here too: otherwise a
|
|
86
93
|
// question's scaffolding scores BM25 matches against literal dialogue ("How
|
|
87
94
|
// does Georgiana get on, Darcy?") and pushes correct chunks out of the fused
|
|
88
|
-
// top-10.
|
|
89
|
-
//
|
|
95
|
+
// top-10. grounding.mjs's list is not reused: it also stops words
|
|
96
|
+
// ("history", "overview") that are real content in passage text.
|
|
90
97
|
const LEXICAL_LAYOUT = 'bm25-v1';
|
|
91
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',
|
|
92
99
|
'how', 'does', 'did', 'do', 'what', 'who', 'why', 'where', 'when', 'which']);
|
|
@@ -232,26 +239,6 @@ export function buildLexicalSegment(texts) {
|
|
|
232
239
|
};
|
|
233
240
|
}
|
|
234
241
|
|
|
235
|
-
// Corpus layout v1 (format 1, profile pikelet-complete-v1): count + offsets +
|
|
236
|
-
// records, integrity by whole-segment digest only. Kept for producing
|
|
237
|
-
// format-1 files (compatibility fixtures, readers that predate format 2);
|
|
238
|
-
// new artifacts use buildCorpusSegment() below.
|
|
239
|
-
export function buildCorpusSegmentFromBuffers(records) {
|
|
240
|
-
const count = records.length;
|
|
241
|
-
const prefix = 4 + 8 * (count + 1);
|
|
242
|
-
const total = prefix + records.reduce((sum, b) => sum + b.length, 0);
|
|
243
|
-
const out = Buffer.alloc(total);
|
|
244
|
-
out.writeUInt32LE(count, 0);
|
|
245
|
-
let cursor = prefix;
|
|
246
|
-
for (let id = 0; id < count; id++) {
|
|
247
|
-
out.writeBigUInt64LE(BigInt(cursor), 4 + 8 * id);
|
|
248
|
-
out.set(records[id], cursor); // set(), not copy(): records may be plain Uint8Arrays
|
|
249
|
-
cursor += records[id].length;
|
|
250
|
-
}
|
|
251
|
-
out.writeBigUInt64LE(BigInt(cursor), 4 + 8 * count);
|
|
252
|
-
return out;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
242
|
// Corpus layout v2 (format 2, profile pikelet-complete-v2): per-record
|
|
256
243
|
// integrity that a reader can check on the single range read that hydrates
|
|
257
244
|
// a record, without fetching the rest of the segment (contract 4.1 / 7):
|
|
@@ -442,12 +429,10 @@ function selfQueriesFromSnapshot(graph, maxQueries) {
|
|
|
442
429
|
return queries;
|
|
443
430
|
}
|
|
444
431
|
|
|
445
|
-
// Container format version follows the profile string: pikelet-complete-
|
|
446
|
-
// files carry corpus layout v1 and header version 1; pikelet-complete-v2
|
|
432
|
+
// Container format version follows the profile string: pikelet-complete-v2
|
|
447
433
|
// files carry corpus layout records-v2 (buildCorpusSegment) and header
|
|
448
|
-
// version 2
|
|
449
|
-
//
|
|
450
|
-
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.
|
|
451
436
|
export const PROFILE_V2 = 'pikelet-complete-v2';
|
|
452
437
|
// A layer is a complete-profile container under formatVersion 2 with its own
|
|
453
438
|
// manifest profile string (LAYERED_PROFILE.md 4.1). A reader that predates the
|
|
@@ -455,37 +440,34 @@ export const PROFILE_V2 = 'pikelet-complete-v2';
|
|
|
455
440
|
// existing "unsupported profile" error, which is the intended behavior: a layer
|
|
456
441
|
// opened alone would silently serve a fraction of a corpus.
|
|
457
442
|
export const PROFILE_LAYER = 'pikelet-layer-v1';
|
|
458
|
-
export const FORMAT_VERSIONS = { [
|
|
443
|
+
export const FORMAT_VERSIONS = { [PROFILE_V2]: 2, [PROFILE_LAYER]: 2 };
|
|
459
444
|
|
|
460
445
|
export function assemblePikeletFile(manifestFields, segments, outPath) {
|
|
461
446
|
const formatVersion = FORMAT_VERSIONS[manifestFields.profile];
|
|
462
447
|
if (!formatVersion) {
|
|
463
|
-
throw new Error(`manifest.profile must be ${
|
|
448
|
+
throw new Error(`manifest.profile must be ${PROFILE_V2} or ${PROFILE_LAYER}, got ${manifestFields.profile}`);
|
|
464
449
|
}
|
|
465
450
|
const isLayer = manifestFields.profile === PROFILE_LAYER;
|
|
466
451
|
const layout = manifestFields.corpus?.layout;
|
|
467
452
|
// A tombstone-only layer (4.1) carries a corpus object with records 0 and
|
|
468
453
|
// MUST omit the layout fields, because it has no corpus segment to describe.
|
|
469
454
|
const tombstoneOnlyLayer = isLayer && manifestFields.corpus?.records === 0;
|
|
470
|
-
if (
|
|
455
|
+
if (!tombstoneOnlyLayer && layout !== CORPUS_LAYOUT_V2) {
|
|
471
456
|
throw new Error(`${manifestFields.profile} requires manifest.corpus from buildCorpusSegment() (layout ${CORPUS_LAYOUT_V2})`);
|
|
472
457
|
}
|
|
473
458
|
if (tombstoneOnlyLayer && layout !== undefined) {
|
|
474
459
|
throw new Error('a tombstone-only layer must omit corpus.layout');
|
|
475
460
|
}
|
|
476
|
-
if (formatVersion === 1 && layout !== undefined) {
|
|
477
|
-
throw new Error(`${PROFILE_V1} carries corpus layout v1 (buildCorpusSegmentFromBuffers); got layout ${layout}`);
|
|
478
|
-
}
|
|
479
461
|
if (!Number.isInteger(manifestFields.corpus?.records) || manifestFields.corpus.records < 0) {
|
|
480
462
|
throw new Error('manifest.corpus.records must be a non-negative integer');
|
|
481
463
|
}
|
|
482
|
-
//
|
|
464
|
+
// The manifest commits to the embedded sketch's 256-byte header
|
|
483
465
|
// under the identity. The header carries the sketch's metric/dim/count and
|
|
484
466
|
// its residentSha256 / vectorsSha256, so anchoring the header anchors the
|
|
485
467
|
// sketch's own integrity chain to the complete identity without forcing a
|
|
486
468
|
// whole-segment read at open (the index segment stays lazy).
|
|
487
469
|
let indexCommitment;
|
|
488
|
-
if (
|
|
470
|
+
if (!tombstoneOnlyLayer) {
|
|
489
471
|
const index = segments.find((s) => s.kind === 'index');
|
|
490
472
|
if (!index || index.bytes.length < 256) {
|
|
491
473
|
throw new Error('index segment must carry a 256-byte sketch header');
|
package/complete/fusion.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// Vector/lexical rank fusion for hybrid retrieval — the one definition the
|
|
2
|
-
// reader (index.mjs), the
|
|
3
|
-
//
|
|
4
|
-
//
|
|
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
|
package/complete/grounding.mjs
CHANGED
|
@@ -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
|
|
5
|
-
//
|
|
4
|
+
// it; an agent reads `uncovered` to tell "the passage is about this" from
|
|
5
|
+
// "the passage states this".
|
|
6
6
|
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
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;
|