Cohesive Systems logoCOHESIVE SYSTEMS

Event Sourcing

Event sourcing is a realization pattern in which an entity's durable history is represented by committed events rather than only by current-state records.

In the Cohesive System Model, event-sourced events are not merely time-bearing values. They are committed endogenous events: events accepted within an observer boundary as the result of a valid transition. Once committed, they can be treated as state actions:

event : State -> State

Reconstitution then folds the committed event schedule from an initial state or snapshot to recover current entity state:

initial state + committed endogenous events -> current state

The word committed is essential. Event sourcing is interested in committed events because they maintain consistency:

  • Only committed events advance the entity version.
  • Rejected commands do not produce committed events for the target entity.
  • Nil endogenous events record no domain transition for the target entity.
  • Expected-version checks, transactions, actor serialization, or compare-and-swap operations ensure that only valid successors enter the history.
  • Reconstitution, projections, audit, recovery, and downstream publication must be based on the committed history, not merely on attempted inputs.

Exogenous events, messages, commands, retries, telemetry, and rejection records may be persisted elsewhere, but they are not automatically part of the entity's event-sourced state history. They become part of that history only if interpreted and committed as endogenous events for the entity boundary.

Event sourcing therefore realizes several concepts together:

  • Persistence as durable committed event history.
  • Reconstitution as replay or snapshot-plus-replay.
  • Concurrency Control as protection of the versioned event schedule.
  • Event-State Duality as the relation between committed event history and state history.
  • Behavior as the trajectory obtained by folding committed events and applying a hold or interpolation rule.

Event sourcing is often combined with CQRS, but the patterns are distinct. Event sourcing chooses committed event history as authoritative persistence; CQRS separates command-side consistency from query-side reconstitution and projection.

Relationship to Outbox

Event sourcing can also act as a coordination substrate when the committed event history is the source from which projections, process managers, subscribers, and outbound publications are driven.

This gives an atomic unification of persistence and orchestration:

committed endogenous event history
  -> reconstitute entity state
  -> drive projections and follow-up processes
  -> publish output events

The event append is the local commit that makes both state history and follow-up responsibility observable. Publication and downstream processing still have their own delivery semantics, acknowledgments, retry, and idempotency requirements, but the trigger for that work is durably tied to the authoritative transition.

If an event-sourced system appends the event and separately writes an unrelated broker message with no recovery link, it reintroduces the dual-write problem. A separate outbox may still be useful, but it must either be committed atomically with the event append or derived reliably from the committed event history.

ARIES is relevant by analogy and contrast. In a database, the transaction log is often an internal write-ahead recovery structure used for redo, undo, checkpoints, and crash recovery. In event-sourced systems, the event log is usually an addressable, first-class primitive of the application model: committed events define entity history, version succession, reconstitution, projection, audit, and sometimes publication.

The logs therefore have different semantics. ARIES log records are recovery records for a storage engine. Event-sourced records are committed domain events for an entity boundary. Both make durable ordered history central to persistence, reconstitution, and recovery.

External References

Related concepts: event, state, transition, entity, version, persistence, reconstitution, recovery, write-ahead logging, commit boundaries, effects, delivery semantics, acknowledgments, concurrency control, event-state duality, behavior, outbox, transactional outbox, dual-write problem, CQRS, storage systems, realization.