Event sourced orchestration with decider projector
Skill kjuhwa/skills-hub/skills/architecture/event-sourced-orchestration-with-decider-projector
Self-correcting knowledge corpus for Claude Code — 9 stable shape clusters, bias-correction pipeline baked into contribution flow. 47 papers, 45 techniques, 1.1k skills.
npx -y skills add kjuhwa/skills-hub --skill event-sourced-orchestration-with-decider-projectorAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Use event sourcing for domain state with pure decider (commands->events) and projector (events->read model) functions
SKILL.md
2.7 KB, 479 tokens by cl100k_base, as published. Nobody here has run it
When to Apply
- You need an audit trail of all state changes (threads, turns, checkpoints, approvals)
- You want to replay history without re-running external agents
- You need to support concurrent requests and rollback failed operations
- You want domain logic (commands + events) separate from read model updates
Steps
- Define command schemas:
Thread.Create,Thread.Turn.Start,Thread.Checkpoint.Revert(in contracts) - Define event schemas:
ThreadCreated,MessageSent,TurnDiffCompleted(in contracts) - Implement decider function:
- Input: command + current aggregate state
- Output: list of events or error
- Pure function; no side effects
- Implement projector function:
- Input: event + current read model
- Output: updated read model
- Also pure
- Orchestration engine:
- Receives command from client
- Validates via
commandInvariants - Calls decider to produce events
- Appends events to event log (durable storage)
- Calls projector to update in-memory read model
- Returns new projected state to client
- On startup, replay event log through projector to rebuild read model
Example
const decider = (command, state) => {
if (command.type === 'thread.create') {
if (state.threads.has(command.threadId)) return Err('thread exists')
return Ok([{ type: 'thread.created', threadId: command.threadId, title: command.title }])
}
return Err('unknown command')
}
const projector = (event, readModel) => {
if (event.type === 'thread.created') {
readModel.threads.set(event.threadId, { id: event.threadId, title: event.title })
}
return readModel
}
const engine = new OrchestrationEngine()
const [events, newState] = yield* engine.dispatch(command)
Counter / Caveats
- Event log grows unbounded; implement snapshot/compaction strategy
- Projector must be deterministic; any randomness breaks replay
- Decider can be slow for large aggregates; consider per-thread vs global state
- Concurrent commands to same aggregate need optimistic locking or version checks
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.