pub struct Kernel<S: KernelState> {
pub events: Box<dyn EventStore>,
pub snaps: Option<Box<dyn SnapshotStore<S>>>,
pub reducer: Box<dyn Reducer<S>>,
pub exec: Box<dyn ActionExecutor>,
pub step: Box<dyn StepFn<S>>,
pub policy: Box<dyn Policy>,
pub effect_sink: Option<Box<dyn EffectSink>>,
pub mode: KernelMode,
}Expand description
Kernel: event store, optional snapshot store, reducer, executor, step fn, policy, optional effect sink, execution mode.
Fields§
§events: Box<dyn EventStore>§snaps: Option<Box<dyn SnapshotStore<S>>>§reducer: Box<dyn Reducer<S>>§exec: Box<dyn ActionExecutor>§step: Box<dyn StepFn<S>>§policy: Box<dyn Policy>§effect_sink: Option<Box<dyn EffectSink>>When set, every runtime effect (LLM/tool call, state write, interrupt) is recorded here.
mode: KernelModeExecution mode: Normal, Record, Replay, or Verify. Replay/Verify trap clock, randomness, spawn.
Implementations§
Source§impl<S: KernelState> Kernel<S>
impl<S: KernelState> Kernel<S>
Sourcepub fn determinism_guard(&self) -> DeterminismGuard
pub fn determinism_guard(&self) -> DeterminismGuard
Returns a determinism guard for the current mode. Use before clock, randomness, or spawn in Replay/Verify.
Sourcepub fn run_until_blocked(
&self,
run_id: &RunId,
initial_state: S,
) -> Result<RunStatus, KernelError>
pub fn run_until_blocked( &self, run_id: &RunId, initial_state: S, ) -> Result<RunStatus, KernelError>
Runs until the step returns Complete or Interrupt/WaitSignal. Returns run status. State is obtained by replaying the event log (or initial_state if the run has no events yet).
Sourcepub fn resume(
&self,
run_id: &RunId,
initial_state: S,
signal: Signal,
) -> Result<RunStatus, KernelError>
pub fn resume( &self, run_id: &RunId, initial_state: S, signal: Signal, ) -> Result<RunStatus, KernelError>
Resumes a blocked run with a signal (e.g. resume value or external signal). Appends Resumed (or Signal) event, then runs until blocked or complete.
Sourcepub fn replay(&self, run_id: &RunId, initial_state: S) -> Result<S, KernelError>
pub fn replay(&self, run_id: &RunId, initial_state: S) -> Result<S, KernelError>
Replays the run from the event log without executing external actions; returns final state.
Scans all events for the run (from seq 1), applies each with the Reducer in order. Does not call ActionExecutor; any ActionRequested is satisfied by the following ActionSucceeded/ActionFailed already stored in the log (reducer applies them).
Sourcepub fn replay_from_snapshot(
&self,
run_id: &RunId,
initial_state: S,
) -> Result<S, KernelError>
pub fn replay_from_snapshot( &self, run_id: &RunId, initial_state: S, ) -> Result<S, KernelError>
Replays from a snapshot if available, otherwise from initial state.
If snaps is set and load_latest(run_id) returns a snapshot, state starts at
snap.state and only events with seq > snap.at_seq are applied; otherwise
starts at initial_state and replays from seq 1.
Sourcepub fn run_timeline(&self, run_id: &RunId) -> Result<RunTimeline, KernelError>
pub fn run_timeline(&self, run_id: &RunId) -> Result<RunTimeline, KernelError>
Builds a run timeline (event list + final status) for audit/debugging. Serialize to JSON for UI/CLI.