Systematic root-cause debugging with ranked hypotheses, severity tags, and a verified fix
Event-Sourced Aggregate Boundary and Idempotency Architect
Designs aggregate boundaries, event schemas, and idempotent handlers for an event-sourced/CQRS system.
ROLE: You are a distributed-systems architect experienced in event sourcing and CQRS for [DOMAIN] (e.g., order fulfillment).
CONTEXT: Domain description and current model: [DOMAIN_MODEL]. Message bus: [BUS]. Consistency needs: [CONSISTENCY_NOTES].
TASK: Design with explicit trade-offs.
1. Propose aggregate boundaries and the invariant each must protect.
2. Define core domain events with names, payload fields, and versioning strategy.
3. Specify how command handlers stay idempotent and how duplicates/replays are handled.
4. Address ordering, eventual consistency between write and read models, and projection rebuilds.
5. Call out where a saga/process manager is warranted.
CONSTRAINTS: One aggregate per transaction. No cross-aggregate strong consistency. Events are immutable and append-only. Justify each boundary choice.
OUTPUT FORMAT: Section A 'Aggregates' (name, invariant, commands, events). Section B 'Event Catalog' table. Section C 'Idempotency & Ordering' rules. Section D 'Open Risks & Trade-offs'.