Loom pack format: PACK/1
BabbCreated by: AI service unspecified
A pack is a hashed bundle of declarations, adopted into a log with one BIND
entry. It is the unit Loom compiles to. This page describes the format ascrates/stream-log/src/pack.rs and crates/stream-log/src/lib.rs implement
it today; where the code and this page disagree, the code is right and this
page is wrong.
Bytes
A pack is a UTF-8 text file of LF-terminated lines.
PACK/1 name=si-units@1
0 CREATE unit:J {"base":true,"conserved":true,"dimension":"energy","kind":"unit","rec":"pack:si-units@1"}
0 CREATE unit:kWh {"conserved":true,"dimension":"energy","equals":"3600000 J","kind":"unit","rec":"pack:si-units@1"}
- Header. The first line is exactly
PACK/1 name=<name>. The name is not
empty and contains no space. By convention it is<name>@<version>. - Declarations. Every later line is one entry in the kernel's grammar,
and: - it is canonical (the kernel's
checkpasses); - its verb is CREATE;
- its
recispack:<name>, the pack's own name.
The payload's kind, with the object, names what is declared. The parser
does not require kind; a declaration without one is filed under an
empty kind.
3. No blank lines. A blank line is not an entry and makes the pack invalid.
4. One meaning per name. The same (kind, object) may appear more than
once only if the lines are byte for byte identical.
5. Time. Each line needs a valid time to be an entry. The bundled packs
use 0; the time is not used when the pack is adopted.
Identity
A pack's identity is the SHA-256 of its bytes, in lowercase hex. Changing one
byte, including a trailing newline, makes a different pack. A log stores the
bytes under that hash (blobs/<sha256> in a directory store) and never
changes them.
Adoption
A pack enters a log through one BIND entry:
1795484682.53 BIND log {"name":"si-units@1","pack":"sha256:42cefac1…","rec":"human:ops-lead"}
- Authority. BIND needs a root or an admin grant.
- Stored first. The pack's bytes must already be stored under the hash
the entry names, or the BIND is refused. - Conflicts are refused. If any declaration names a
(kind, object)the
Register already holds with a different payload (ignoringrec), the BIND
is refused, naming the declaration and where the existing one came from.
Declaring the same thing identically is not a conflict, so adopting the
same pack twice is accepted. - Effect. Each declaration enters the Register at the BIND's address,
marked with the pack's name. Later entries are read under it.
What Loom adds
Today a pack holds only CREATE declarations of units, profiles and views.
The Loom design draft (docs/loom/LOOM-DESIGN-v0.1.md) compiles kinds,
views, rules, acts, screens and automations into packs. Those declarations
need kinds the log does not yet act on, such as rule and screen, and rules
need the log to run them at submission. Until then, a pack can carry them
only as declarations that nothing enforces.