AGENT SKILL

event-sourcing

Use when the system needs an audit log, temporal queries, or event-driven state reconstruction. Do not use when a simple relational model is enough or when strong immediate consistency is required.

License 许可
MIT
最近更新
2026-10-08
Stars
★ 0
Forks
0

01 前言 Front Matter

name
event-sourcing
license
MIT
metadata
{ "owner": "Harley Bartles", "status": "active", "use_when": [ "the system needs an audit log, temporal queries, or event-driven state reconstruction." ], "source-id": "event-sourcing", "source-path": "skills/event-sourcing/SKILL.md", "related_skills": [ "cqrs" ], "do_not_use_when": [ "a simple relational model is enough or when strong immediate consistency is required." ], "provenance-name": "Event Sourcing first-party skill", "source-category": "first_party" }
description
Use when the system needs an audit log, temporal queries, or event-driven state reconstruction. Do not use when a simple relational model is enough or when strong immediate consistency is required.

02 资源文件 5

03 SKILL.md 正文

Event Sourcing

Overview

Event sourcing persists the state of a system as a sequence of immutable events, making the event store the source of truth. Current state is reconstructed by replaying events.

When to Use

  • Use when an immutable audit trail and temporal querying are required.
  • Use when reconstructing past states or diagnosing why a state changed is valuable.
  • Use when event-driven integrations need a reliable history.
  • Do not use when simple relational queries and strong immediate consistency are sufficient.

Core Pattern

  1. Record every state change as an append-only event with identity, type, payload, and timestamp.
  2. Organize events into streams keyed by aggregate or entity.
  3. Build projections (read models) by folding events into views; use snapshots to speed replay.
  4. Version events carefully and evolve schemas without breaking historical streams.

Common Mistakes

  • Modifying or deleting events instead of appending compensating events.
  • Reconstructing state on every read without projections or snapshots.
  • Ignoring concurrency conflicts and idempotency.

04 同仓库更多 Skills