Expand description
Systematic Event Sourcing
Provides from_events() reconstruction for all core entities,
extending the pattern established in agent_state.rs.
ยงDesign
The EventSourced trait defines a common interface for entities that can be
reconstructed from their event history. Each entity implementation:
- Sorts events by timestamp to handle out-of-order delivery
- Filters for relevant event kinds using
relevant_event_kinds() - Applies events in order via
apply_event()to build up state - Returns
Nonefromfrom_events()if the creation event is missing
ยงEntities
- Trajectory: TRAJECTORY_CREATED -> TRAJECTORY_UPDATED -> TRAJECTORY_COMPLETED/FAILED/DELETED
- Scope: SCOPE_CREATED -> SCOPE_UPDATED -> SCOPE_CLOSED
- Artifact: ARTIFACT_CREATED -> ARTIFACT_UPDATED -> ARTIFACT_DELETED
- Note: NOTE_CREATED -> NOTE_UPDATED -> NOTE_DELETED
Traitsยง
- Event
Sourced - Trait for entities that can be reconstructed from their event history.
Functionsยง
- extract_
i32 ๐ - Extract an i32 from a JSON payload field, with a default.
- extract_
id ๐ - Extract a typed ID from a JSON payload field.
- extract_
optional_ ๐i32 - Extract an i32 from a JSON payload field, returning None if absent.
- extract_
optional_ ๐string - Extract an optional string from a JSON payload field.
- extract_
string ๐ - Extract a string from a JSON payload field.
- sorted_
relevant_ ๐events - Sort events by timestamp (ascending), then filter for relevant kinds.
- timestamp_
to_ ๐datetime - Convert a microsecond timestamp to a chrono DateTime.