Skip to content

EventLog v0

P0 test traces use one batch per JSONL line:

{"version":0,"batch_hex":"000000000000000000000000"}

This example is an empty MAIN/Agent batch (principal 0, no client transaction ID). The reader accepts the canonical key order shown above, surrounding line whitespace, blank lines, and either hex case. Unknown versions, extra fields, malformed hex, truncation, invalid tags, duplicate/unordered map or set entries and trailing binary bytes are rejected. It is a canonical trace reader, not a general JSON parser.

The encoder emits lowercase hex. Binary layout:

  • Integers: unsigned little endian; ID width follows SPEC §6.1.
  • bool: one byte 0 or 1. Option: bool presence then value when present.
  • byte arrays: raw fixed-width bytes. String: UTF-8 bytes with u32 byte length.
  • Vec/set/map: u32 element count followed by elements; set/map keys strictly sorted.
  • Struct fields: declaration order in model. Tuples: left to right.
  • Enum: u8 tag followed by fields in declaration order. Existing tags are frozen; future variants append. Op tags 0–13 correspond to CreateLogical, AddRevision, SetHead, AssertBase, RetractBase, AddRule, SetRuleEnabled, Rebind, RecordValidation, SetPolicy, ObserverWatermark, SetMetadata, OpenArtifact, ResolveArtifact. v1 (P6) adds tags 14–17: CreateBranch, ArchiveBranch, ExpectHeads, Merge, and non-main batches. v2 (P7, ADR 0015 §9) adds tag 18 RecordValidation4 (RecordValidation's fields, then meta: Option<[u8;32]>, if_absent: bool) and tag 19 ResolveArtifact4 (id, then note: Option<[u8;32]>). They are used only when a new field is set: tag 18 with meta = None and if_absent = false is rejected, as is tag 19 with note = None. v3 (P9, ADR 0017 §10) adds tag 20 SetAccess (doc: AccessDoc: version: u16, owner, principals: map<name, u32>, groups: map<name, set<name>>, lanes: map<name, LaneEntry>, code_lanes, personal_egress: bool, default_lane; LaneEntry is members, writers, curators (sets of strings), egress: bool, grants: map<string, set<string>>, deny: set<(string, string)>). v4 (P10, SPEC §6.1 contract 16, SD21.7) adds tag 22 CreateLogical with a replica origin (tag 0's fields, then team: [u8;16]), tag 23 MirrorAttach (key: string, head: [u8;32], base: bool), tag 24 ObserverWatermark with gap = true (tag 10's fields; tag 10 always means gap = false), Channel Replica = 3, and [team_lanes] in SetAccess: bit 1 of the personal_egress byte (so the byte is 0–3) marks a team_lanes: LaneEntry after default_lane. A Local create keeps tag 0, a gap = false watermark tag 10 and an access document without [team_lanes] its v3 bytes, so their bytes are unchanged. In a Logical record a replica origin sets the RecordKind byte's high bit (kind | 0x80) and appends the team after it. Each line carries the lowest version that can represent it.
  • Edge tags: Ref=0, Pin=1, Sem=2, Cur=3. Channel: Agent=0, Observer=1, Admin=2, Replica=3 (v4).
  • RecordKind: Fact, Assumption, Decision, Plan, Convention, Procedure, Artifact, Evidence, CodeAnchor, Summary (0–9).
  • References: Existing=0, New=1; LogicalRef additionally has Key=1, New=2.
  • Verdict: Verified=0, Rejected=1, Pending=2. ArtifactType: Conflict=0, PendingReview=1, ImportBroken=2, AnchorBroken=3, DriftReport=4.

Decode limits: 16 MiB per binary value, 1,000,000 elements per collection, 32 MiB per JSONL document. Invalid batches can round-trip: semantic validation happens only in InputModel/core. Limits protect this test import boundary; in-memory transaction APIs have the checked ID limits in SPEC, not a u16 batch-size limit.

Wire also serializes input and derived snapshots for deterministic comparison and digesting. Those encodings are not a durable storage/recovery API. P2 will define its durable op_log envelope separately, including compatibility and crash behavior.