Append-only Log

A data structure where historical records are never overwritten or deleted, but instead continuously appended to the tail. It preserves a complete audit trail, enabling forensic investigation and state recovery.

General Meaning

An append-only log is a storage structure that strictly avoids in-place updates or deletions, recording every new state mutation or business event sequentially at the end of the log.

Classic examples include Git commit histories, event sourcing designs, and database write-ahead logs (WAL). Because previous states remain permanently immutable, append-only logs provide an uncompromised audit trail, dramatically simplifying incident troubleshooting and enabling point-in-time state reconstruction whenever systems fail.

Why It Matters

  • Preventing historical context loss from in-place mutation: Overwriting current values erases how a state evolved and masks transient failure events.
  • Localizing storage corruption during crashes: While power loss during an in-place overwrite can destroy entire files, crashes during an append-only write simply require truncating partial trailing records.
  • Delivering high-throughput sequential writes: Appending sequentially to persistent storage avoids costly random I/O operations, yielding significantly higher write performance.

How the Site Factory Uses It

In the Site Factory, all major autonomous patrol loop events (such as merged, ticket, hold, error, deploy, revert, refill, and runner-switch) are recorded sequentially to ops/watchdog/history.jsonl in JSON Lines format.

Unlike volatile heartbeat files that overwrite past states, this log enforces the Site Factory's operational rule that failure history must not be erased within 24 hours. The log preserves the latest MAX = 500 entries in ops/watchdog/history.py, skipping malformed rows during reads and bundling patrol records into unified commits (Watchdog: patrol ...) alongside regular workspace changes.

Caveats & Operational Rules

  • Never erase failure histories for convenience: Removing error logs simply because a service has returned to normal destroys the evidentiary trail required for root-cause analysis and recurrence prevention.
  • Guard against unbounded log growth: Append-only logs grow continuously if unmonitored; maintain fixed caps (such as the 500-line cap in history.py) or scheduled log rotations.
  • Deriving current state requires a read pass: Accessing current state requires scanning trailing entries or materializing projections rather than performing direct random key lookups.

Related Terms

References

  • Book: Martin Kleppmann, Designing Data-Intensive Applications, Chapter 3 (Storage and Retrieval: Log-Structured Storage)

Verified: 2026-11-08