Overview
Domain events represent facts about what has happened in the system. They are the single source of truth and are persisted to the event store. The read model is derived by projecting these events.Event Structure
All events share these base fields:Global event sequence number (monotonically increasing)
Unique event identifier (UUID)
Type of aggregate root
Aggregate instance identifier (projectId or threadId)
Event type discriminator (e.g.,
"project.created")ISO 8601 timestamp when event occurred
Command that caused this event (null for spontaneous events)
Event that caused this event (for cascading effects)
Original command ID for tracking related events
Additional event metadata
Event-specific data
Push Event Format
Events are broadcast to clients via theorchestration.domainEvent channel:
Project Events
project.created
A new project has been created.project.meta-updated
Project metadata has been updated.project.deleted
A project has been soft-deleted.Thread Lifecycle Events
thread.created
A new thread has been created.thread.deleted
A thread has been soft-deleted.thread.meta-updated
Thread metadata has been updated.thread.runtime-mode-set
Thread runtime mode has changed.thread.interaction-mode-set
Thread interaction mode has changed.Message Events
thread.message-sent
A message has been added to the thread.Assistant messages may be sent incrementally with
streaming: true, followed by a final event with streaming: false.Turn Events
thread.turn-start-requested
A user has requested to start a new turn.thread.turn-interrupt-requested
A user has requested to interrupt the active turn.thread.turn-diff-completed
A turn has completed and its checkpoint/diff has been recorded.Session Events
thread.session-set
Provider session state has been updated.thread.session-stop-requested
A user has requested to stop the session.Approval & User Input Events
thread.approval-response-requested
A user has responded to a provider approval request.thread.user-input-response-requested
A user has responded to a provider user input request.Checkpoint Events
thread.checkpoint-revert-requested
A user has requested to revert to a previous checkpoint.thread.reverted
A checkpoint revert has been completed.Activity Events
thread.activity-appended
A new activity log entry has been added to the thread.thread.proposed-plan-upserted
A provider has proposed or updated a plan.Event Ordering
Events are guaranteed to be:- Globally ordered by sequence number
- Per-aggregate ordered within their stream
- Causally ordered via causationEventId and correlationId
Event Replay
Use theorchestration.replayEvents method to replay events:
- Building read models
- Catching up after reconnection
- Debugging state issues
- Implementing event handlers
Source Code
Event schemas are defined in:- Contracts:
packages/contracts/src/orchestration.ts:557-982 - Event Store:
apps/server/src/orchestration/Services/EventStore.ts - Projections:
apps/server/src/orchestration/Projections/ - Push Broadcast:
apps/server/src/wsServer.ts:577-583
Next Steps
Commands
Learn about commands that generate events
Orchestration API
Explore the full orchestration API
WebSocket Protocol
Understand the transport layer
