Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ADR-0003: A format header as the first frame

Status: Accepted (the 8-byte layout and the pinned encoding are proposed)
Date: 2026-11-21
Deciders: Format author

Context

The container's own signature, MOZFRM, says "mopenzl framed container", not "book". A file manager, a library scanner or file(1) needs to recognise an mbook file, and a reader needs the format version before it interprets anything else.

Decision

Resource 0 is a format header: the prefix MBOOK and a zero byte, then major and minor, 8 bytes in total. It is written with the store graph and a pinned encoding, so its bytes appear unchanged at file offset 47.

Options considered

DimensionA: stored 8-byte frameB: metadata field on resource 0C: version key in the meta table
Reader complexityDecode one tiny frameRead a record headerDecode and search a table
Detection without OpenZLYes, fixed offset 47Yes, fixed offset 32No
IntegrityFrame checksums cover the versionHeader checksum covers the fieldFrame checksums cover the table
CompatibilityOrdinary frameUses the container's metadata for format semanticsOrdinary frame
EvolutionFixed size; growth needs a new majorFree-form valueFree-form value

Chosen: A.

Trade-off analysis

  • C hides the version inside compressed data whose shape depends on the version being read.
  • B is the smallest change, but it puts format semantics into the container's metadata layer, and the header cannot be handled like every other resource.
  • A costs 56 bytes and one constraint on writers: store graph, OpenZL format version 27, both checksums on, no metadata. Without the pinned encoding a different frame header could move the prefix. In return the first 53 bytes of every file are constant.

Consequences

  • Easier: one-line detection rules; a version that is decoded and checksummed like everything else.
  • Harder: writers must reproduce the pinned encoding exactly.
  • To revisit: the pinned OpenZL format version, when OpenZL defines a newer one.

Action items

  1. Add the 64-byte prefix of a 1.0 file as a test vector in mbook.
  2. Implement detection by fixed offsets and full validation by decoding.
  3. Test that a file with a greater major is rejected and a greater minor is accepted.