telltale_machine/exec_api.rs
1//! Generic execution-result API aligned with the Lean ProtocolMachine execution model.
2
3use crate::engine::ObsEvent;
4
5/// Execution status after one step/round.
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum ExecStatus<G = ()> {
8 /// Coroutine continues execution.
9 Continue,
10 /// Coroutine blocked on a guard/policy reason.
11 Blocked(G),
12 /// Coroutine/session halted.
13 Halted,
14 /// Runtime detected a fault.
15 Faulted,
16}
17
18/// One execution event emitted by a step.
19#[derive(Debug, Clone, PartialEq, Eq)]
20pub enum StepEvent<E = ()> {
21 /// Observable ProtocolMachine event.
22 Obs(ObsEvent),
23 /// Internal effect/policy event payload.
24 Internal(E),
25}
26
27/// Structured result of one execution step.
28#[derive(Debug, Clone, PartialEq, Eq)]
29pub struct ExecResult<G = (), E = ()> {
30 /// Status after applying one step.
31 pub status: ExecStatus<G>,
32 /// Optional emitted event.
33 pub event: Option<StepEvent<E>>,
34}
35
36/// Generic execution pack carrying updated coroutine state plus step result.
37#[derive(Debug, Clone, PartialEq, Eq)]
38pub struct StepPack<G = (), E = ()> {
39 /// Coroutine identifier after the step.
40 pub coro_id: usize,
41 /// Step result.
42 pub res: ExecResult<G, E>,
43}