Event Sourcing: Fold Over an Append-Only Log

State is a fold over an immutable event log; corrections are new events, never edits

Event Sourcing: Fold Over an Append-Only Log State is a fold over an immutable event log; corrections are new events, never edits 01 / Intent 02 / Source of truth 03 / Fold 04 / Read models 05 / Consumers Commands · actions / intent · 01 / Intent Commands actions / intent Event Log · append-only, immutable · 02 / Source of truth · source of truth Event Log append-only, immutable source of truth Reducer · fold over events · 03 / Fold Reducer fold over events Projections · current balances · 04 / Read models · derived Projections current balances derived Consumers · queries, reports, audit · 05 / Consumers Consumers queries, reports, audit Correction · reversal = new event · 02 / Source of truth Correction reversal = new event append event immutable replay events in order fold to state rebuildable read model derived view append, never edit new event Legend primary data policy / PII async batch data store

The Log Is Truth

  • • Events are appended, never mutated or deleted
  • • The ordered log is the single source of truth
  • • Full history is retained for audit and replay

State Is Derived

  • • Balances are a fold over the event stream
  • • Projections are disposable and rebuildable
  • • Replay the log to reconstruct any read model

Corrections

  • • A reversal is a new compensating event
  • • Nothing is ever edited in place
  • • The mistake and its fix both stay on record