pikelet-wasm 0.14.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/FORMAT.md ADDED
@@ -0,0 +1,500 @@
1
+ # The `.pikelet` format
2
+
3
+ A `.pikelet` file is a searchable corpus in one file. It holds the source
4
+ text, a vector index, an optional keyword (BM25) index, the neural encoder
5
+ that turns a question into a vector, and the tests the pack was built to
6
+ pass. A
7
+ single SHA-256 digest, the file's **identity**, commits to all of it.
8
+
9
+ The layout is designed for byte-range reads. A reader fetches a small
10
+ prefix to open the file, then only the rows and records a query touches,
11
+ so the same file serves from a local disk, an object store or any static
12
+ HTTP host that honours `Range`.
13
+
14
+ This document describes the format as it exists in `pikelet-wasm` and is
15
+ written by `pikelet compile` today. The normative texts are the
16
+ specifications in [`spec/`](spec/) and
17
+ [`LAYERED_PROFILE.md`](LAYERED_PROFILE.md); the reference reader is
18
+ [`packages/pikelet-wasm/complete/`](packages/pikelet-wasm/complete/).
19
+ Where this page simplifies, those win.
20
+
21
+ **Status: not frozen.** The format is versioned and every released version
22
+ stays readable (see [Compatibility](#compatibility)), but new versions may
23
+ still be added before 1.0.
24
+
25
+ ## Contents
26
+
27
+ - [What is in a pack](#what-is-in-a-pack)
28
+ - [Binary structure](#binary-structure)
29
+ - [Identity and integrity](#identity-and-integrity)
30
+ - [The embedded encoder](#the-embedded-encoder)
31
+ - [Indexes](#indexes)
32
+ - [Layers: updating a pack](#layers-updating-a-pack)
33
+ - [Versioning](#versioning)
34
+ - [Compatibility](#compatibility)
35
+ - [Operational limitations](#operational-limitations)
36
+ - [Specifications and code](#specifications-and-code)
37
+
38
+ ## What is in a pack
39
+
40
+ Two packs built by the current compiler, for scale:
41
+
42
+ | Segment | 3-record folder | Simple English Wikipedia (456,153 records) |
43
+ | --- | ---: | ---: |
44
+ | Query interpretation (encoder + calibration) | 24.5 MiB | 24.9 MiB |
45
+ | Index (vector sketch + rows) | 2.0 KiB | 220.1 MiB |
46
+ | Corpus (records + digests) | 2.4 KiB | 334.4 MiB |
47
+ | Lexical (BM25) | 1.1 KiB | 69.2 MiB |
48
+ | Evaluation | 2.2 KiB | under 0.1 MiB |
49
+ | **File** | **24.5 MiB** | **648.5 MiB** |
50
+
51
+ The encoder is a fixed cost: every pack carries it, so the smallest pack
52
+ is about 25 MiB. Above that, the size grows with the corpus.
53
+
54
+ A reader never needs the whole file. Opening the Wikipedia pack reads the
55
+ header, manifest, segment tables and the index's 46.1 MiB resident prefix;
56
+ the encoder (~25 MiB) loads with the first query; each later query reads
57
+ roughly 0.5–1.1 MiB of rows and records
58
+ ([measured](docs/wikipedia-demonstration.md)).
59
+
60
+ ## Binary structure
61
+
62
+ All integers are little-endian and all offsets are absolute.
63
+
64
+ ```
65
+ [0, 64) header
66
+ [64, ...) manifest canonical JSON, manifestBytes long
67
+ [...] segment table segmentCount entries of 48 bytes
68
+ [...] segments each at a 16-byte-aligned offset; padding is zero
69
+ ```
70
+
71
+ ### Header (64 bytes)
72
+
73
+ | Offset | Type | Field | Meaning |
74
+ | ---: | --- | --- | --- |
75
+ | 0 | u32 | magic | `0x31465350`, the bytes `PSF1` |
76
+ | 4 | u32 | formatVersion | `1` or `2`; `pikelet compile` writes `2` |
77
+ | 8 | u32 | manifestBytes | length of the manifest; at most 16 MiB |
78
+ | 12 | u32 | segmentCount | 1 to 64 |
79
+ | 16 | u64 | fileBytes | total file size; must equal the actual size |
80
+ | 24 | 32 bytes | manifestSha256 | SHA-256 of the manifest bytes: **the identity** |
81
+ | 56 | 8 bytes | reserved | zero |
82
+
83
+ ### Manifest
84
+
85
+ UTF-8 JSON with sorted keys and no insignificant whitespace, so it has one
86
+ byte serialization and one digest. Abridged from a pack compiled today:
87
+
88
+ ```jsonc
89
+ {
90
+ "profile": "pikelet-complete-v2",
91
+ "corpus": {
92
+ "records": 3,
93
+ "provenance": { "source": "folder", "name": "src" }, // plus "license" when compiled with --license
94
+ "ingest": { "chunker": "pikelet-section-v1", "targetTokens": 256, "overlapPercent": 15, "minTokens": 25 },
95
+ "layout": "records-v2", "pageRecords": 256, "pages": 1,
96
+ "recordDigest": "sha256", "pageTableSha256": "0c25…"
97
+ },
98
+ "dim": 384,
99
+ "metric": "cosine",
100
+ "encoder": { "kind": "inline-transformer-v1", "model": "sentence-transformers/all-MiniLM-L6-v2",
101
+ "pooling": "mean", "normalized": true, "maxTokens": 512 },
102
+ "index": { "headerSha256": "7c7f…" },
103
+ "lexical": { "layout": "bm25-v1", "docCount": 3, "terms": 36, "totalTokens": 120 },
104
+ "recommendedRerank": 3,
105
+ "sampleQueries": [],
106
+ "segments": [
107
+ { "kind": "index", "bytes": 2016, "sha256": "7283…" },
108
+ { "kind": "corpus", "bytes": 2478, "sha256": "8949…" },
109
+ { "kind": "query-interp", "bytes": 25724590, "sha256": "6c28…" },
110
+ { "kind": "evaluation", "bytes": 2265, "sha256": "dbd2…" },
111
+ { "kind": "lexical", "bytes": 1156, "sha256": "f509…" }
112
+ ]
113
+ }
114
+ ```
115
+
116
+ `segments` lists every segment's length and SHA-256 in table order.
117
+ Readers ignore manifest fields they do not know; those fields are still
118
+ covered by the identity.
119
+
120
+ ### Segment table (48 bytes per entry)
121
+
122
+ | Offset | Type | Field |
123
+ | ---: | --- | --- |
124
+ | 0 | u32 | kind |
125
+ | 4 | u32 | reserved, zero |
126
+ | 8 | u64 | offset, 16-byte aligned |
127
+ | 16 | u64 | bytes |
128
+ | 24 | 24 bytes | reserved, zero |
129
+
130
+ ### Segment kinds
131
+
132
+ | Kind | Name | In a complete pack | Read |
133
+ | ---: | --- | --- | --- |
134
+ | 1 | index | required | resident prefix at open, rows per query |
135
+ | 2 | corpus | required | tables at open, one record per hydrated result |
136
+ | 3 | query-interp | required | calibration at open; encoder before the first query |
137
+ | 4 | evaluation | required for conformance | only by `verify_pack` and tests |
138
+ | 5 | lexical | optional; written by default | whole at open, or lazily above 8 MiB |
139
+ | 6 | tombstones | layers only | whole at mount |
140
+ | 7 | lineage | compacted bases only | whole at mount |
141
+ | 8 | row map | optional (`--sentence-windows`) | whole at open |
142
+
143
+ A reader skips kinds it does not know; their bytes are still committed by
144
+ the manifest. At most one segment of each known kind may be present.
145
+
146
+ ### Corpus segment (kind 2), layout `records-v2`
147
+
148
+ ```
149
+ u32 count
150
+ u32 pageRecords P, 256 by default
151
+ u64 offsets[count + 1] record i is bytes [offsets[i], offsets[i+1])
152
+ 32-byte pageSha256[pages] SHA-256 of the record digests in page p
153
+ 32-byte recordSha256[count] SHA-256 of each record's bytes
154
+ records UTF-8 JSON objects, one per record
155
+ ```
156
+
157
+ A record carries at least `title`, `text` and `sourcePath`, and optionally
158
+ `preview`, `anchor`, `url` and source-specific metadata (a commit, a
159
+ conversation turn, a journal note). Records are stored uncompressed.
160
+ Record `i` is the vector index's row `i` (or, with a
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. Format-1 files use layout v1: the same
163
+ count and offsets, with no page table or record digests.
164
+
165
+ ### Query-interpretation segment (kind 3)
166
+
167
+ ```
168
+ u32 version 1
169
+ u32 kind 1 student-inline-v1, 2 external-transformers-v1,
170
+ 3 inline-transformer-v1, 4 inherited-v1 (layers only)
171
+ u32 encoderBytes
172
+ u32 calibrationBytes
173
+ encoder per kind (see The embedded encoder)
174
+ calibration UTF-8 JSON
175
+ ```
176
+
177
+ The encoder and the calibration share a segment and a version because
178
+ the calibration is fit to that encoder's outputs; neither can change
179
+ without the other.
180
+
181
+ Packs compiled after 0.14.0 carry an empty calibration
182
+ (`{"kind":"retrieval-signals-v1","asset":null,"vocabBloomBase64":""}`),
183
+ and the reference reader reports their `matchQuality` as `unscored`. A
184
+ query on any pack also returns `grounding`, the question's words the best
185
+ of the top five passages contains and lacks, computed from the passages'
186
+ text alone ([how a query runs](docs/how-a-query-runs.md#grounding-which-question-words-the-passages-contain)).
187
+
188
+ Packs compiled by 0.14.0 and earlier may carry a fitted calibration
189
+ (`retrieval-signals-v1`): a small model plus a base64 bloom filter of the
190
+ corpus vocabulary. At query time it scores the search's distance signals
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.
199
+
200
+ ### Evaluation segment (kind 4)
201
+
202
+ UTF-8 JSON: the golden queries the pack was built with (each a question
203
+ and the record or title it must retrieve in the top 10) and the
204
+ recall-versus-rerank-depth sweep that chose `recommendedRerank`; packs
205
+ compiled by 0.14.0 and earlier also hold expected verdicts and the
206
+ calibration's fit metrics. `compile` keeps only goldens the assembled
207
+ pack passes, and `verify_pack` (MCP) replays them on demand. A reader can serve queries
208
+ without ever reading this segment.
209
+
210
+ ## Identity and integrity
211
+
212
+ **Identity** is `manifestSha256`. The manifest commits to each segment's
213
+ digest, and some segments commit further to their own parts, so the
214
+ identity transitively commits to every byte of content. Two files with the
215
+ same identity hold the same corpus, indexes, encoder and calibration.
216
+
217
+ **Pinning.** A reader can be told the identity it expects:
218
+ `openPikeletFile(url, { expectedIdentity })`, `pikelet mcp --pack
219
+ <location>#<sha256>`, or a pin in a shelf file. The reader checks the
220
+ 64-byte header against the pin before downloading anything else, and
221
+ refuses a mismatch.
222
+
223
+ **What is checked, and when.** Integrity is enforced per read, so a reader
224
+ never has to download a whole large segment to trust the part it uses:
225
+
226
+ | Bytes | Committed by | Checked |
227
+ | --- | --- | --- |
228
+ | Manifest | the identity | at open |
229
+ | Query interpretation | manifest digest | at open; a segment over 4 MiB is fetched in the background and checked whole before the first query result, with the slices used at open compared against it |
230
+ | Corpus tables and page table | manifest (`pageTableSha256`) | at open |
231
+ | Each record | its digest, in a digest page anchored by the page table | on every read, before the record is returned; a failure fails the query |
232
+ | Index header (256 bytes) | manifest (`index.headerSha256`) | at open |
233
+ | Index resident prefix | the header's `residentSha256` | at open |
234
+ | Index rows | per-row digests in 16-row blocks, anchored by a page-hash table in the resident prefix | on every read that fetches them |
235
+ | Lexical segment up to 8 MiB | manifest digest | whole, at open |
236
+ | Lexical segment over 8 MiB | manifest digest | **not per read**; only by a full pass (`verifyLexical()`, or `verify_pack` with `full: true`) |
237
+ | Evaluation, row map | manifest digest | whole, when read |
238
+
239
+ `info()` reports the stance of each part (`corpusIntegrity`,
240
+ `indexRowIntegrity`, `lexical.integrity`, `lexical.verified`,
241
+ `encoderVerified`) so a host can tell what has been checked.
242
+
243
+ **What integrity does not mean.** A verified pack is exactly the pack its
244
+ identity names; it says nothing about whether its text is true or safe.
245
+ There are no signatures: an identity proves which bytes you have, not who
246
+ produced them. Trust in a publisher has to come from where you got the
247
+ identity.
248
+
249
+ **Hostile input.** Every offset, length and count is validated before it
250
+ is used: reads must lie inside the file and the segment they belong to,
251
+ u64 fields above 2^53 − 1 are refused, short reads fail, and reads are
252
+ capped (256 MiB per open-path read by default, 16 MiB per record, 2 GiB
253
+ absolute). A reader never executes code from a pack; the encoder is data
254
+ run by kernels that ship with the reader.
255
+
256
+ ## The embedded encoder
257
+
258
+ 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. Three
260
+ query-interpretation kinds exist, each giving up one of self-contained,
261
+ small and full-quality:
262
+
263
+ | Kind | Name | Encoder bytes | Trade-off |
264
+ | ---: | --- | --- | --- |
265
+ | 3 | `inline-transformer-v1` | the quantized transformer itself, ~24 MiB | the default; self-contained and full quality, but large |
266
+ | 1 | `student-inline-v1` | a distilled student model, small | self-contained and small, lower quality; not appendable. Built only by releases before 0.16, which still reads it |
267
+ | 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, which still reads it; `pikelet mcp` refuses it |
268
+
269
+ **Kind 3**, which `pikelet compile` writes, holds three length-prefixed
270
+ regions:
271
+
272
+ ```
273
+ u32 declBytes, u32 vocabBytes, u32 blobBytes
274
+ declaration JSON: model and revision, license and attribution, pooling,
275
+ normalization, maxTokens, query/passage prefixes, test
276
+ vectors, and the weight layout (V, P, T, D, F, L, H, B, Q)
277
+ vocab WordPiece vocabulary, one token per line
278
+ weight blob block-quantized matrices and f32 norm parameters
279
+ ```
280
+
281
+ The default encoder is `sentence-transformers/all-MiniLM-L6-v2`
282
+ (Apache-2.0): 6 layers, 384 dimensions, mean pooling, normalized, with
283
+ weights quantized to u8 in blocks of 64 (a 24.3 MiB blob and a
284
+ 30,522-token vocabulary). Text longer than the 512-token window is embedded in windows
285
+ whose vectors are mean-pooled (`longInputs: "windowed-mean-pool"`).
286
+ Packs compiled before that declared `maxTokens: 128`.
287
+ The vocabulary is bert-base-uncased's (Apache-2.0, Google), unmodified.
288
+ A pack therefore redistributes both under Apache-2.0; the repository's
289
+ NOTICE file credits them.
290
+
291
+ The declaration carries **test vectors**: query texts with the embeddings
292
+ the build produced. When the reader loads the encoder it embeds each one
293
+ and refuses to serve if any component differs beyond the declared
294
+ tolerance, so a kernel that computes differently from the one that built
295
+ the index is caught before it answers (`info().encoderVerified`).
296
+
297
+ The reader's kernels (C++ compiled to WebAssembly, integer GEMM) run a
298
+ BERT-shaped encoder with a fixed shape: vocabulary 30,522, 512 positions,
299
+ hidden size 384, 12 heads, feed-forward 1,536, and 1 to 12 layers, with
300
+ u8 weights in blocks of 64 or u4 weights in blocks of 32. A pack
301
+ declaring any other shape is refused as unsupported. The kernels are
302
+ bit-identical across Node and the three major browser engines, which is
303
+ what lets test vectors use a tight tolerance.
304
+
305
+ **Kind 2** is for hosts that already run an encoder. Its declaration pins
306
+ the model and carries test vectors; a reader given a host encoder must
307
+ pass every vector before the first query, and a reader without one
308
+ refuses to serve the pack rather than falling back.
309
+
310
+ ## Indexes
311
+
312
+ ### Vector index (kind 1)
313
+
314
+ The index segment is a complete `.pikelet-sketch` file embedded verbatim
315
+ ([`spec/SKETCH_PROFILE.md`](spec/SKETCH_PROFILE.md)), magic `PSA1`. It is
316
+ built for range reads: one round of parallel fetches per query, instead
317
+ of the sequential hops a graph index needs.
318
+
319
+ ```
320
+ [0, 256) sketch header: metric, dim, count, sketch geometry,
321
+ residentSha256, vectorsSha256, recommendedRerank,
322
+ per-row digest geometry
323
+ resident prefix per-row scales and offsets, then one compressed sketch per row
324
+ (192 dimensions at 4 bits by default), then the page-hash table
325
+ vectors every row as dim u8 values (affine-quantized), in blocks of
326
+ 16 rows each preceded by its 16 per-row digests
327
+ ```
328
+
329
+ A query embeds the question, scans every row's sketch in memory (in
330
+ WebAssembly where available), takes the best `C` candidates
331
+ (`recommendedRerank`, chosen at build time from the evaluation sweep:
332
+ 200 on the Wikipedia pack), fetches those rows by range in one coalesced
333
+ round, verifies them, and reranks by exact distance. Metric is cosine (or
334
+ L2); vectors are normalized before quantization.
335
+
336
+ ### Keyword index (kind 5, `bm25-v1`)
337
+
338
+ A static BM25 inverted index over the records:
339
+
340
+ ```
341
+ 64-byte header version, docCount, termCount, totalTokens, region offsets
342
+ doclens u32 per record
343
+ term table 24 bytes per term: 64-bit term hash, postings offset,
344
+ postings length, document frequency; sorted by hash
345
+ postings per term: varint doc-id deltas and term frequencies
346
+ ```
347
+
348
+ Terms are stored only as hashes (two FNV-1a-32 seeds), and the sorted,
349
+ uniform hashes let a reader find a term by interpolation without loading
350
+ the table. Up to 8 MiB the segment is read whole; above that only the
351
+ header and doclens are read at open, and term windows and postings are
352
+ fetched per query (see [integrity](#identity-and-integrity) for the cost).
353
+
354
+ The tokenizer keeps lowercase `[a-z0-9']` runs of 2–32 characters. The
355
+ same rule drives a fitted calibration's word coverage; `grounding` grades
356
+ words of three letters or more, or any word holding a digit. BM25 parameters are
357
+ k1 = 1.2, b = 0.75.
358
+
359
+ ### How the indexes combine
360
+
361
+ BM25's top candidates join the vector rerank, so they are scored by true
362
+ vector distance like any other candidate; the final order fuses the vector
363
+ ranking and the BM25 ranking by reciprocal rank. The fusion constants,
364
+ BM25 parameters and cut-offs belong to the reader version, not the file:
365
+ they are the same for every pack a given reader opens.
366
+
367
+ ### Row map (kind 8)
368
+
369
+ With `compile --sentence-windows <n>`, the index holds each record's own
370
+ vector plus one vector per run of `n` sentences, so a single answering
371
+ sentence is not averaged away by the rest of its chunk. The row map
372
+ (`u32 offsets[records + 1]`) says which rows belong to which record;
373
+ results, citations and the corpus stay per record. The manifest declares
374
+ the policy as `index.rowMap`.
375
+
376
+ ## Layers: updating a pack
377
+
378
+ A pack is immutable. Changes ship as **layers**: small `.pikelet` files
379
+ (profile `pikelet-layer-v1`, format version 2) that each name their
380
+ parent's identity and add records, delete records, or supersede one record
381
+ with another. `pikelet append` writes a layer, and a reader mounts the
382
+ chain from its newest member, the **head**, whose identity commits to every
383
+ ancestor.
384
+
385
+ - A layer's new records take the next global ids, so ids never change
386
+ and are never reused; citations made against an earlier head still
387
+ resolve.
388
+ - Deletions are a cumulative tombstone bitset (kind 6); supersessions are
389
+ `(oldId, newId)` pairs in the same segment.
390
+ - A layer carries no encoder. Its query-interpretation segment is kind 4
391
+ (`inherited-v1`), which names the base's identity and the digest of the
392
+ base's encoder segment; when the base is calibrated, its calibration
393
+ region holds a bloom filter of the layer's own vocabulary.
394
+ - 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
+ - `pikelet compact` folds a chain into a new base whose lineage segment
401
+ (kind 7) translates every earlier head's ids forward.
402
+
403
+ The full rules are in [`LAYERED_PROFILE.md`](LAYERED_PROFILE.md).
404
+
405
+ ## Versioning
406
+
407
+ Versions sit at several levels, and each is checked by the reader:
408
+
409
+ | Level | Where | Values |
410
+ | --- | --- | --- |
411
+ | Container | header `formatVersion` + manifest `profile` | `1` = `pikelet-complete-v1`; `2` = `pikelet-complete-v2` or `pikelet-layer-v1` |
412
+ | Corpus layout | manifest `corpus.layout` | absent (v1, format 1 only) or `records-v2` (format 2 only) |
413
+ | Vector index | sketch header `formatVersion` | `1` (whole-segment digests) or `2` (per-row digests) |
414
+ | Encoder and calibration | query-interp `version` and `kind` | version 1; kinds 1–4 |
415
+ | Keyword index | manifest `lexical.layout` + segment version | `bm25-v1` |
416
+ | Other segments | their own version words | tombstones, lineage and row map: 1 |
417
+ | Ingestion | manifest `corpus.ingest.chunker` | `pikelet-section-v1` |
418
+
419
+ A reader refuses a container or segment version it does not know, and a
420
+ manifest whose profile or corpus layout disagrees with the header. A new
421
+ segment *kind* does not need a new container version: readers skip kinds
422
+ they do not know.
423
+
424
+ Format 2 with a version-2 sketch has been what the compiler writes since
425
+ 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.
427
+
428
+ ## Compatibility
429
+
430
+ - **Old files open.** Readers open format 1 and 2, sketch format 1 and 2,
431
+ and every query-interpretation kind. Each part reports the integrity
432
+ stance it actually has instead of claiming the strongest.
433
+ - **The Pancake era.** The project was called Pancake until September
434
+ 2026. Readers accept the old profile strings `pancake-complete-v1` and
435
+ `-v2`, and dispatch on magic bytes, not file extensions, so `.pancake`
436
+ files open unchanged ([history](docs/history.md)).
437
+ - **Older readers and newer files.** A reader that predates the keyword
438
+ index skips it and serves vector-only results from the same file. A
439
+ reader that predates row maps refuses a file that carries one (its
440
+ row count no longer matches the record count), rather than misreading
441
+ it. A reader that predates layers refuses a layer.
442
+ - **Identity is stable under reading, not rebuilding.** Recompiling the
443
+ same inputs with the same compiler version gives the same identity
444
+ (releases up to 0.14.0 need `SOURCE_DATE_EPOCH` set for this). A
445
+ different compiler version can change chunking, calibration or
446
+ defaults, and with them the identity.
447
+ - **Transport.** Over HTTP the host must answer `Range` requests with
448
+ `206 Partial Content`. If the file's validator (`ETag`) changes while it
449
+ is open, reads fail with `ARTIFACT_CHANGED` instead of mixing bytes from
450
+ two files.
451
+
452
+ ## Operational limitations
453
+
454
+ - **About 25 MiB minimum.** The encoder is in every pack, and the first
455
+ query on a remote pack downloads it.
456
+ - **English-shaped text processing.** The keyword index and the word
457
+ coverage behind `grounding` keep only `[a-z0-9']` runs, so accented words are
458
+ split (`café` is indexed as `caf`) and Greek, Cyrillic and CJK text
459
+ produce no keywords. The default encoder was trained on English.
460
+ Chunking needs whitespace-separated words and at least 25 of them, so
461
+ unsegmented scripts produce no chunks. See the
462
+ [Limitations](packages/pikelet/README.md#limitations) section of the
463
+ CLI reference.
464
+ - **One encoder shape.** The kernels run only the 384-dimensional
465
+ BERT-shaped encoder described above. A different model needs kind 2 (a
466
+ host encoder) or new kernels.
467
+ - **Large keyword indexes are not checked per read.** Above 8 MiB, BM25
468
+ reads are confined to their segment but not verified one by one; until a
469
+ full pass, altered postings could change which authentic records rank
470
+ highly (record text and vector rows are still verified). Format-1
471
+ files have the same gap for records and rows.
472
+ - **Retrieval behaviour is partly in the reader.** The file fixes the
473
+ encoder, the indexes and the calibration. The fusion rule, BM25
474
+ parameters and cut-offs come from the reader, so two reader versions
475
+ may rank the same pack differently.
476
+ - **No metadata filters, no compression.** There is no filter or facet
477
+ index, and records are stored as raw JSON.
478
+ - **Size limits.** At most 2^31 − 1 records per pack or chain; a manifest
479
+ of at most 16 MiB and at most 64 segments; reads capped as above. The
480
+ kind-3 encoder is loaded whole (about 25 MiB of memory per open pack).
481
+ - **Updates are append-only.** Layers grow a chain up to 16 deep, and
482
+ each adds a file to fetch and an index to search until a compaction
483
+ folds the chain into one base.
484
+ A pack with a row map cannot be layered.
485
+ - **No signatures.** Identity establishes which bytes you have, not who
486
+ made them.
487
+ - **One implementation.** The reference reader and builder are the only
488
+ implementation. The specifications are written to allow others, but
489
+ none has been tested against them.
490
+
491
+ ## Specifications and code
492
+
493
+ | Document | Covers |
494
+ | --- | --- |
495
+ | [`spec/SEARCH_ARTIFACT_CONTRACT.md`](spec/SEARCH_ARTIFACT_CONTRACT.md) | the behavioural contract: identity, tolerance, evaluation, calibration |
496
+ | [`spec/COMPLETE_PROFILE.md`](spec/COMPLETE_PROFILE.md) | the `.pikelet` container and its segments |
497
+ | [`spec/SKETCH_PROFILE.md`](spec/SKETCH_PROFILE.md) | the embedded vector index |
498
+ | [`LAYERED_PROFILE.md`](LAYERED_PROFILE.md) | layers, chains, compaction and rebase |
499
+ | [`packages/pikelet-wasm/complete/`](packages/pikelet-wasm/complete/) | the reference reader and builder (`format.mjs` holds the shared constants) |
500
+ | [`test/complete_profile.mjs`](test/complete_profile.mjs), [`test/layered_profile.mjs`](test/layered_profile.mjs) | conformance suites, including tampered and hostile files |
package/NOTICE CHANGED
@@ -3,3 +3,28 @@ Copyright 2026 Matthew Noonan
3
3
 
4
4
  This product includes software and file-format specifications developed as
5
5
  part of the Pikelet project (https://github.com/mcn92/pikelet).
6
+
7
+ ------------------------------------------------------------------------
8
+ Third-party material redistributed in every compiled .pikelet pack
9
+ ------------------------------------------------------------------------
10
+
11
+ `pikelet compile` embeds a query encoder in each pack it writes, and the
12
+ pikelet package downloads the same encoder on first use. A pack therefore
13
+ redistributes the following, each under the Apache License, Version 2.0
14
+ (the same license as Pikelet; see LICENSE):
15
+
16
+ all-MiniLM-L6-v2
17
+ Model weights from sentence-transformers/all-MiniLM-L6-v2
18
+ (https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2),
19
+ licensed under the Apache License, Version 2.0.
20
+ Modified: the weights are quantized to 8-bit integers in blocks of 64
21
+ and repacked into Pikelet's encoder blob format. Packs compiled with
22
+ --encoder-model carry that model instead, under its own license.
23
+
24
+ BERT WordPiece vocabulary
25
+ vocab.txt from bert-base-uncased (https://github.com/google-research/bert,
26
+ https://huggingface.co/google-bert/bert-base-uncased), Copyright Google,
27
+ licensed under the Apache License, Version 2.0. Redistributed unmodified.
28
+
29
+ The content a pack is compiled from is the compiler's user's, under
30
+ whatever license they record with --license.