pub struct YoAgentState<S: EventStore> { /* private fields */ }Implementations§
Source§impl<S: EventStore> YoAgentState<S>
impl<S: EventStore> YoAgentState<S>
pub async fn load(store: S) -> Result<Self, StateError>
pub fn store(&self) -> Arc<S>
Sourcepub async fn resume_open_run(&self) -> Result<Option<RunId>, StateError>
pub async fn resume_open_run(&self) -> Result<Option<RunId>, StateError>
Recover the open-run marker from the committed log: the last
run.started with no matching run.finished becomes the current run,
so auto-chaining and correlation continue across process boundaries
(load itself never sets the marker — readers stay side-effect free).
Returns the resumed run id, or None when every run is closed.
Sourcepub async fn record_event(&self, event: Event) -> Result<EventId, StateError>
pub async fn record_event(&self, event: Event) -> Result<EventId, StateError>
Append one event. Events recorded without an explicit causation_id
while a run is open (between record_run_started and
record_run_finished) are chained to the run’s start event, and
events without an explicit correlation_id are correlated to the
run’s id. Provided all activity happens inside runs within a single
process lifetime, this keeps the causation graph rooted at
*.created / *.started — events recorded with no open run become
roots of whatever kind they are and carry no run correlation, and the
open-run marker is not recovered by load.
pub async fn apply_ops( &self, actor: ActorRef, ops: Vec<StateOp>, ) -> Result<EventId, StateError>
Sourcepub async fn apply_ops_caused_by(
&self,
actor: ActorRef,
ops: Vec<StateOp>,
caused_by: Option<EventId>,
) -> Result<EventId, StateError>
pub async fn apply_ops_caused_by( &self, actor: ActorRef, ops: Vec<StateOp>, caused_by: Option<EventId>, ) -> Result<EventId, StateError>
Append a state.ops_applied event carrying the domain event that caused
it, per the GASP pairing rule: ops that materialize a domain event set
causation_id to that event’s id, keeping the audit layer and the
folded graph mechanically linked.