Created by: AI service unspecified
Status: working draft, adopted 27 November 2026 — not frozen.
This layout is the working draft for the STREAM compact header. It is not the Rust kernel, not Loom, and not a wire-format freeze. No real log should be treated as permanently committed to this layout until the gates in section 10 pass.
1. The decision
The 5+5 layout built and verified in the STREAM Bitpack Header Lab is adopted as the working draft for the compact header.
A log line carries a fixed-width header block in front of its payload:
- Short header — 5 characters, 30 bits. The common case. Covers type, phase, who is present, timing, and the estimate and change flags.
- Extended header — 5 + 5 characters, 60 bits in total. Used only when the short header sets its extended-follows bit. Adds the kind of absence for each role, a dictionary index, and check bits.
The point of the header is not compression alone. A reader can decide from the header bits whether a line can match a query and skip the payload unread. The header also makes absence a first-class, typed part of the fact: unknown and withheld are different facts, with different headers and different hashes, not two spellings of blank.
2. Form at a glance
| Form | Characters | Bits | When used |
|---|---|---|---|
| Short header | 5 | 30 | Default for every line |
| Extended header | 10 | 60 | Short header has extended-follows = 1 |
Each character carries 6 bits over a 64-symbol alphabet, so the arithmetic is exact: 5 × 6 = 30 and 10 × 6 = 60. For reference, the same alphabet gives 24 bits in 4 characters and 48 bits in 8 characters.
The payload follows the header and carries only what the header cannot: the values that actually vary, such as the measure, and any names not already covered by shared context or a dictionary index.
3. Alphabet and canonical encoding
The alphabet is 64 symbols:
A-Z a-z 0-9 - _
Rules that keep the encoding canonical:
- One fact has exactly one header. Field order, bit order and alphabet order are fixed by this draft and by the lab implementation. The same fact packed two ways would hash two ways and look like two different entries, which would break deduplication and merging.
- Case is alphabet position, not a separate free bit.
Aandaare different symbols because they sit in different positions in the alphabet. The earlier caps-as-change idea therefore has no spare channel inside this alphabet and needs a separate home if it is kept. It is not part of this draft. - A header is read at fixed width. A reader that sees extended-follows = 0 reads 5 characters and no more; a reader that sees extended-follows = 1 reads 10.
- Short headers carry no check bits. Error detection for a short header rests on the segment seal, as in the current log. Only the extended header carries its own check bits, in section 5.
4. Short header layout — 30 bits
Fields are packed in the order listed, totalling 30 bits.
| Field | Bits | Meaning |
|---|---|---|
| Position | 7 | Position in the 128-position map |
| Phase | 2 | Instant, begin, end, or sample |
| Modality | 1 | Modality of the fact |
| Direction | 1 | Direction of the fact |
| Role presence | 4 | One bit per role: present or not |
| Estimate | 1 | 1 if a value is an estimate, as with the ~ marker |
| Change | 1 | 1 if the shared context changes at this line |
| Time delta | 12 | Time since the previous entry, in the unit fixed for the log |
| Extended-follows | 1 | 1 if five more header characters follow |
| Total | 30 | 5 characters |
Notes on the short header:
- The 12-bit time delta covers 0–4,095 units. With a one-second unit that is about 68 minutes. The extended header adds no further time bits, so a line further from its predecessor than the range allows needs an absolute time in the payload or a new segment. The unit is a property of the log, not of the header, and the overflow behaviour is a freeze gate in section 10.
- Role presence says only whether a role is filled. It does not say why a role is empty. That distinction lives in the extended header, so a short-header line can say “this role is absent” but not which kind of absence it is.
5. Extended header layout — 30 more bits
When extended-follows = 1, five more characters follow, totalling 60 bits for the full header.
| Field | Bits | Meaning |
|---|---|---|
| Absence kind, role 0 | 3 | Kind of absence for role 0, from section 6 |
| Absence kind, role 1 | 3 | Kind of absence for role 1 |
| Absence kind, role 2 | 3 | Kind of absence for role 2 |
| Absence kind, role 3 | 3 | Kind of absence for role 3 |
| Object / kind index | 12 | Index into the log’s dictionary of objects and kinds |
| Check bits | 6 | XOR-fold check over the header |
| Total added | 30 | 5 more characters, 60 in total |
Role order in the absence fields matches role order in the short header’s presence bitmap. The role slots themselves — actor and measure among them, as in the presets in section 8 — are fixed by the kernel and pack in use and must not be reordered without a new version of this draft.
The 12-bit dictionary index addresses 0–4,095 dictionary entries. It lets a common object or kind be named by number in the header instead of by name in the payload.
6. Typed absence
Absence is recorded per role, inside the record, at the atomic level. Each role carries one 3-bit code:
| Code | Kind | Meaning |
|---|---|---|
| 0 | Present | The piece is here |
| 1 | Not-yet | It will arrive; the record is open in time |
| 2 | Unknown | It could be known, and is not |
| 3 | Withheld | It is known, and not shared |
| 4 | Not-applicable | This fact has no such piece by nature |
| 5 | Refused | It was asked for, and refused |
| 6 | Ambiguous | More than one candidate, not yet resolved |
| 7 | Reserved | Not used in v0.1 |
These kinds are not interchangeable, and a fold must not treat them as interchangeable. A balance with an unknown leg cannot close as if the leg were zero. A withheld actor is not an invitation to search harder; a not-applicable role is not a gap to fill at all. A missing piece is completed later by appending an entry that refers back to the first, so the log keeps both the gap and its closing.
An estimated value is handled separately, by the estimate flag in the short header, because an estimate is a present value with a qualification, not an absent one.
7. Filtering by header alone
Because the header is fixed-width and its fields sit in fixed positions, a reader can test a line against a query — position, phase, role presence, absence kind, time delta — without decoding the payload. Lines that cannot match are eliminated by their header bits alone.
The lab demonstrates this with a six-header filter test in which payloads are skipped unread on header bits alone.
That is not the whole of fast search at scale. Header filtering makes each check cheap and exact, with no text parsing and no substring false positives, but a line-by-line check is still a scan. Fast search across a very large log still needs segment summaries that let whole segments be skipped, secondary indexes, and cached views for the common questions. The header is what makes those buildable; it does not replace them.
8. Presets and test vectors
These three encodings from the lab are the reference vectors for v0.1. Any second implementation must reproduce them exactly, in both directions.
| Preset | Header | Form |
|---|---|---|
| ACT, end phase, steel transfer | QToB4 | Short, 5 characters |
| ATTEND, begin phase, measure unknown | UpgALACAHT | Extended, 10 characters |
| FAIL, sample phase, actor withheld | I5wlhYAADe | Extended, 10 characters |
Verification recorded for the lab implementation:
- All three presets encode and decode back to the same fields.
- 2,000 random field combinations round-trip with zero failures.
- A one-character corruption of an extended header is rejected by the check bits.
The vectors above are necessary but not sufficient for a freeze. A published vector set must also include invalid headers — bad check bits, reserved absence code 7, and out-of-range combinations — with the expected rejection for each.
9. Limits of this draft
- The check bits are an XOR fold, not a cyclic redundancy check (CRC). They detect every single-character error, as verified in the lab, but multi-character errors can cancel. That is acceptable for a draft and for sealed logs; it should be reconsidered before use on a noisy link.
- There is no version field. Nothing in the header yet announces that it is v0.1, or how a v0.2 header would announce itself. That decision is open and must be taken before anyone writes a long-lived log in this format.
- Absence code 7 is the only reserved code. Reserved use must stay unused in v0.1 so it remains available.
- The header layout is the schema. In the same way that packed encodings such as ASN.1 PER only work when both sides share the schema exactly, this header only works when both sides share this layout exactly. Changing a field’s size or position is a version change, not a tweak.
- Readability is traded for density.
ACT)tells a human something at a glance; a packed header does not, until it is decoded. Tooling, not eyeballing, is the expected way to read these lines.
10. Gates before freezing
This draft becomes a frozen format only when all of the following pass:
- A second, independent implementation — a Rust decoder in
stream-codec— agrees with the lab on every published vector, valid and invalid. - The full test-vector set is published with this draft, including the invalid-header cases named in section 8.
- A filter test runs against a real STREAM log, not only lab headers, and shows payloads skipped unread by header bits alone at that scale.
- The versioning question in section 9 is answered in writing: which bits, if any, are reserved for version, and how a later version announces itself.
- The time-delta unit and overflow behaviour in section 4 are fixed for the log that first uses this header.
Until then, changes to this draft are made by editing this document and noting them in section 11. Implementations should treat the layout as movable.
11. Record
| Date | Change |
|---|---|
| 26 November 2026 | Layout built and verified in the STREAM Bitpack Header Lab: 5-character short header, 5-character extension, three presets, 2,000 random round-trips, single-character corruption rejected. |
| 27 November 2026 | Adopted as working draft v0.1 in this document. Not frozen. |
Appendix: where the method comes from
Bitpacking itself is classical, which is a strength of this draft rather than a weakness. The closest parallels are ASN.1 PER, which packs presence bitmaps and small values at bit level when the schema is already shared; CBOR, which puts type and count in a head byte with a “more follows” escape; and Ascii85, which represents binary data in five-character groups. Protocol headers in IPv4, TCP and DNS use the same head-first pattern: fixed bitfields up front for routing and filtering, variable payload after.
What is distinctive here is the application, not the method: a log fact’s position, phase, modality, direction, role presence and absence kind, packed into a fixed ASCII header that doubles as a search filter. No parallel above packs typed absence into the header.