Skip to main content

Kernel

Struct Kernel 

Source
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: KernelMode

Execution mode: Normal, Record, Replay, or Verify. Replay/Verify trap clock, randomness, spawn.

Implementations§

Source§

impl<S: KernelState> Kernel<S>

Source

pub fn determinism_guard(&self) -> DeterminismGuard

Returns a determinism guard for the current mode. Use before clock, randomness, or spawn in Replay/Verify.

Source

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).

Source

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.

Source

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).

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<S> Freeze for Kernel<S>

§

impl<S> !RefUnwindSafe for Kernel<S>

§

impl<S> Send for Kernel<S>

§

impl<S> Sync for Kernel<S>

§

impl<S> Unpin for Kernel<S>

§

impl<S> UnsafeUnpin for Kernel<S>

§

impl<S> !UnwindSafe for Kernel<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.