Systems Specification

Append-Only Event Ledger

A durable, replayable record of everything a distributed agent system did, and the sufficient state to reconstruct why.

Document
DOC-SPEC-014
Revision
2026.09 (rev H)
Status
Draft
Classification
Internal
Supersedes
DOC-SPEC-011
Pages
1 of 1
Abstract

An event ledger is an append-only, immutable log of every externally observable action a system takes: each tool result, environment observation, and state mutation, recorded with the parameters needed to reproduce it. This specification defines the record format, the ordering and durability guarantees, the replay procedure, and the operational limits. The design goal is a sufficient statistic: given the ledger up to step n−1, step n can be re-executed deterministically at zero upstream cost. Nothing here depends on a model; every guarantee is enforced by a program.

Principles

Five constraints shape every decision below. They are stated first so the rest of the document can be read as their consequences rather than as a list of features.

P1 · Append-only

A record, once written, is never mutated or deleted. History is a fact, not a mutable view. Corrections are new records that reference the old, so the trail of what was believed at each step survives.

P2 · Self-describing

Each record carries its own schema tag, actor, and causal parent. A reader reconstructs the graph from the records alone, with no side table and no external index required to make sense of them.

P3 · Content-addressed

Large payloads are stored once and referenced by hash. The ledger holds the causal skeleton; the bodies live beside it, so a record stays small and a replay verifies integrity for free.

P4 · Deterministic replay

Every model call records its seed and sampling parameters. A failure that cannot be replayed cannot be engineered away, so replayability is a property of the record, not of the harness that produced it.

P5 · Verify by log, not by claim

An actor's narration is evidence of intent, never of outcome. A claim is grounded against the recorded execution or it is clipped. Judgment lives in a deterministic verifier, never in a model.

Non-goal This is not a message bus. The ledger is a record of what happened, read after the fact by verifiers and replayers. Live coordination between actors is a separate concern with separate guarantees.

Architecture

The write path

Actors never touch the ledger file directly. Each mutation passes through a write-ahead entry, so a crash between the intent and the effect is recoverable rather than a silent gap.

   actor                     ledger                   reader
  ┌─────────┐  append ┌──────────────────┐          ┌──────────┐
  │   tool  │────────>│   write-ahead    │          │ replayer │
  │   call  │         │   then commit    │ <────────│ verifier │
  └─────────┘         └───────┬──────────┘  read    └──────────┘
                              │ seal at close
                              v
                      refs/ledger/<run>   (immutable, git-object)
write-ahead on the way in, sealed to an immutable object on the way out.

The same lifecycle reads more like a datapath as a flow rail. Both figures are first-class in this style: reach for the ASCII diagram when the shape is spatial (branches, boundaries, a grid of cells), and for .flow when the shape is a single path a record travels down.

append()client call
record
Validateschema + span class
checked
Write-aheadWAL append
flushed
Commitfsync, offset returned
at close
Sealrefs/ledger/<run>
Live segment · mutable
Sealed · immutable
the write path as a .flow grid: node cards, labeled edges, and bands grouping the mutable stages against the sealed one.

Trust boundaries

Spans are classed at registration, never inferred from output text. A read-only span replays freely; a mutating span is fenced behind the write-ahead log and, in replay, behind a sandbox.

  ┌─────────────── READ-ONLY (replayable) ───────────────┐
  │        query_store    read_file    web_search        │
  └──────────────────────────────────────────────────────┘
  ┌─────────────── MUTATING (WAL-fenced) ────────────────┐
  │      write_store    exec_shell    send_message       │
  └──────────────────────────────────────────────────────┘
side-effect class is a static tag, set in code at tool registration.

Data model

One record is one line: a JSON object terminated by a newline. Its identity is its byte offset in the ledger file, so no field carries an id the reader could disagree with.

// one ledger record. field names are short: readers pay per byte.
{
  "ts":     "2026-09-14T22:04:02.104Z",   // wall clock, display only
  "mono":   3937119184239575,               // monotonic ns, ordering
  "actor":  "reviewer-security",
  "kind":   "tool_result",
  "parent": 40318,                          // byte offset of the causal parent
  "class":  "READ_ONLY",
  "call":   { "model":"sonnet", "seed":88213, "temp":0.0 },
  "body":   "sha256:e3b0c442…b7852b855"     // content-addressed, stored beside
}

Record kinds

The set is closed. A new kind is a decision, not a convenience, because every verifier switches on it.

the six record kinds and how each is consumed
kindemitted byread byreplayable
sayany actorhumansn/a
findreviewersthe tallyn/a
evidchecksthe verifieryes
tool_resultthe harnessthe replayeryes
mutationthe harnessthe sandboxfenced
askany actora humann/a
Invariant A record is exactly the fields above and no others; a reader that finds an extra top-level key rejects the record rather than guessing. The field count is fixed so a line parser cannot silently mis-split.

Protocol

Ordering

Two questions have two answers. In what order did records land? is the byte offset, exact and free. When did each happen? is the monotonic stamp, which is send-time and may disagree with landing order by a sub-millisecond margin under contention.

order(a, b)  =  sgn(offseta − offsetb) (4.1)

Replay throughput is bounded by the slower of parse and integrity check. With batched hashing the check dominates only for large bodies:

Treplay  =  Nrparse  +  Brhash (4.2)

State trace

A task's stage is not stored; it is folded from the records. The trace below reconstructs one task's path from its ledger slice.

  offset   kind          actor               stage after
  ──────   ────          ─────               ───────────
  00000    say           developer           building
  40318    tool_result   harness             building
  40961    find          reviewer-security   revise        <- blocker
  41502    say           developer           building
  42088    find          reviewer-security   merged        <- cleared
stage is a fold over the record stream, never a stored field.

Operation

Replay walkthrough

Drag the control to step a failed run to the record before the fault. Up to the cursor, cached results are served from the ledger; the cursor step runs live. Everything before it costs nothing.

Record at cursor

Timeline of a fault

t+0.0sStep 2 subagent emits a schema, syntactically valid, semantically wrong. Reports OK.
t+3.1sStep 8 a downstream span parses the bad payload without complaint.
t+9.4sStep 14 an unhandled parse error crashes the run. The origin is 12 steps back.
offlineBack-trace walk the causal edges from the crash to the origin span; the fix is one clip.

Operator checklist

  • Ledger sealed to refs/ledger/<run> at task close.
  • Seed and sampling params present on every model span.
  • Mutating spans fenced behind the write-ahead log.
  • Tail-based sampling retains 100% of error traces.
  • Secret and PII scrubbing verified on the collector.
Recovery from a torn write
A crash between the write-ahead entry and the commit leaves an intent with no effect. On restart, the recovery pass finds any write-ahead entry without a matching commit, re-executes it under the sandbox, and appends the commit. The ledger is never left with a half-record because the record is one atomic append.
Circuit breaker on a runaway loop
Degenerate retry loops collapse output-token entropy across consecutive spans with matching arguments. When the variance falls below threshold for four spans, the breaker trips and the run halts before it burns budget. The check is arithmetic over the record stream, not a model call, so it fires in sub-millisecond time.

Experiments

Each row is a claim about the design tested against the reference implementation. Status is measured, not asserted.

design claims and their verification status
claimmethodresultstatus
Concurrent append never tears a record 8 writers × 200 records 1600 / 1600 intact Implemented
Replay reproduces a failure at zero cost cached prefix, live tail step exact, $0 upstream Implemented
Grounding cuts fabricated claims clip against execution log 90% → 4%1 Partial
Cross-VLAN causal back-trace walk data-dependency edges origin found in 1 pass Implemented
Distillation reuses learned strategy contrastive pivot extraction2 not yet built Critical gap
Open Trace-to-memory distillation is unbuilt and is the one row that blocks a self-improving loop. Everything above it holds; this is where the next work goes. See references for prior art.

Implementation

The reference implementation is three small programs: the record primitive (append, read, seal), the folder that reconstructs state, and the verifier that grounds claims. Each is under a few hundred lines and depends only on the kernel, git, and the standard library. See the reference tree and the conformance suite.

References

  1. Execution-log grounding for autonomous research agents. Prior art, unverified citation. Confirm before quoting the figure.
  2. Contrastive trajectory distillation into reusable strategy memory. Prior art, unverified citation.
  3. Knight, J. C. and Leveson, N. G. An experimental evaluation of the assumption of independence in multiversion programming. IEEE TSE, 1986.
  4. Lamport, L. Time, clocks, and the ordering of events in a distributed system. CACM, 1978.