Event Sourcing
How ownership state is versioned using event sourcing in DMTR.
Overview
DMTR uses event sourcing to version ownership state. State changes are recorded as immutable events; the current state is derived by applying the event log. This approach provides auditability, replay capability, and temporal queries. This document describes the model at a conceptual level.
Event log
Each position has an associated event log. Events include: creation, status change, transfer, compliance update, valuation update. Events are append-only and immutable. Event order is preserved; events are keyed by position and sequence.
Lifecycle Timeline
Position state transitions over time
State derivation
The current Position Object is derived by applying events in order. Derivation happens at read time or via materialized views for performance. Historical state can be reconstructed by replaying events up to a point in time. This supports "as-of" queries and audit trails.
Implications
Event sourcing enables strong auditability and compliance. Integrations receive events via webhooks. The event log is the source of truth; the Position Object is a derived view. Schema evolution is handled through event versioning and migration.
position.status_changed
Event recorded when a position transitions between lifecycle states.
| Field | Type | Description |
|---|---|---|
| event_id | string | Unique event identifier |
| position_id | string | Position entity_id |
| sequence | integer | Event sequence number for this position |
| previous_state | string | State before transition |
| new_state | string | State after transition |
| actor | string | Entity that triggered the change |
| timestamp | datetime | When the event occurred |
Was this page helpful?