refocus on LLM mistakes, not textbook definitions

Based on actual review findings:
- Replay determinism: DateTime.utc_now() in apply, random in state
- Event design: OrderUpdated with changes map (CRUD-in-disguise)
- Projections as source of truth
- Suggesting event 'fixes' instead of compensating events
- Missing idempotency in handlers

Added Elixir/OTP specific patterns (handle_continue for replay,
Process dictionary for test isolation).

Anti-patterns table for quick flagging.
This commit is contained in:
Aaron Weiker
2026-05-11 00:29:58 -07:00
parent d68d1697aa
commit b72c14f370
2 changed files with 113 additions and 129 deletions
+20 -19
View File
@@ -1,31 +1,32 @@
# DDD & Event Sourcing Patterns
Review guidance for domain-driven design and event sourcing. Focus on subtle mistakes models make and patterns they get wrong.
## Contents
- `DDD-CHECKLIST.md` - The review checklist covering:
- Aggregate Design (boundaries, invariants, identity)
- Event Sourcing (immutability, naming, content, reconstruction)
- Domain vs Integration Events
- Eventual Consistency
- Projections (read models)
- Snapshotting
- Process Managers / Sagas
- Value Objects
- Anti-Patterns to Flag
What LLMs get subtly wrong in event-sourced systems. Based on actual code review findings.
## Why This Exists
Models know the textbook definitions but often get the nuances wrong:
- Making aggregates too large (data grouping vs consistency boundary)
LLMs know the textbook definitions of event sourcing and DDD. But they make subtle mistakes:
- Adding `DateTime.utc_now()` in apply functions (breaks replay determinism)
- Creating `OrderUpdated` events with a changes map (CRUD-in-disguise)
- Treating projections as source of truth
- Suggesting "fixes" to immutable events
- Mixing domain and integration events
- Expecting synchronous read model updates
- Snapshotting prematurely
- Making aggregates too large (data grouping vs consistency boundary)
- Multi-aggregate coordination in services without saga patterns
This checklist catches those mistakes.
## Contents
- `DDD-CHECKLIST.md` - Review prompts covering:
- Replay Determinism (CRITICAL)
- Event Design
- Aggregate Boundaries
- Projections
- Idempotency
- Process Managers / Sagas
- Elixir/OTP Specific
- Anti-patterns table
## Integration
```yaml