Effect Event-Sourced Aggregate
State as a fold over facts, with optimistic concurrency on the stream. Storing just the current balance forgets how it got there: no audit trail, no dispute history, no way to replay a bug. Event sourcing stores the ordered facts and derives state by folding them, so history is the source of truth and any past state is reproducible by folding a prefix. Two commands that both load version 7 and append event 8 would lose one; compare-and-append expects a version and fails with a typed ConcurrencyConflict if the stream advanced, so the log never loses or double-applies a fact. The demo shows time-travel to any version and a refused stale append. Pinned to effect 4.0.0-beta.98.
npx shadcn@latest add https://ui.aryank.space/r/effect-event-sourced-aggregate.jsonInstalls from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.
Storing just the current balance forgets how it got there. A corrupted value has no audit trail and cannot be replayed, and a concurrent write overwrites history.