Skip to main content

everruns_host/
in_process_execution.rs

1//! Immediate in-process implementation of the engine execution contract.
2
3use chrono::{DateTime, Utc};
4use everruns_engine::{
5    ActivityOutcome, Execution, ExecutionTransition, HostFacts, TurnExecution, TurnState,
6};
7
8/// Turn execution whose state lives in the current process.
9///
10/// The host performs each planned phase immediately. All semantic state
11/// advancement remains delegated to [`TurnExecution`] in `everruns-engine`.
12#[derive(Debug, Clone)]
13pub struct InProcessExecution {
14    inner: TurnExecution,
15}
16
17impl InProcessExecution {
18    /// Start an in-process execution from the common engine state.
19    pub fn new(state: TurnState) -> Self {
20        Self {
21            inner: TurnExecution::new(state),
22        }
23    }
24
25    /// Consume this driver and return the common checkpoint value.
26    pub fn into_state(self) -> TurnState {
27        self.inner.into_state()
28    }
29}
30
31impl Execution for InProcessExecution {
32    fn state(&self) -> &TurnState {
33        self.inner.state()
34    }
35
36    fn advance(
37        &mut self,
38        outcome: ActivityOutcome,
39        pending_user_message_count: usize,
40        now: DateTime<Utc>,
41        facts: HostFacts,
42    ) -> ExecutionTransition {
43        self.inner
44            .advance(outcome, pending_user_message_count, now, facts)
45    }
46}