Skip to main content

CanonicalOperationDriver

Struct CanonicalOperationDriver 

Source
pub struct CanonicalOperationDriver { /* private fields */ }
Expand description

Reduces the five canonical input classes onto the kernel’s existing semantic mechanisms.

Use it as the plan function of KernelTransaction::prepare:

let preparation = tx.prepare(&envelope, |ctx| driver.plan(ctx));
// ... host CAS-appends the record ...
let committed = tx.commit(&token, &head)?;
driver.note_committed(committed.step_seq)?;

Implementations§

Source§

impl CanonicalOperationDriver

Source

pub fn new() -> Self

Source

pub fn root_kind(&self) -> Option<RootKind>

The operation’s root class. None until the root start commits; immutable afterwards.

Source

pub fn focus(&self) -> Option<&ExecutionFocus>

Where control currently is. Moves only on a committed transition (§7.4).

Source

pub fn workflow_id(&self) -> Option<&WorkflowId>

Source

pub fn attempt_id(&self, task_id: &str) -> Option<&AttemptId>

Return the kernel-issued live attempt for task_id.

Bindings use this read-only projection to correlate a host completion with the live task attempt. The value comes from checkpointed kernel state; hosts must never synthesize it.

Source

pub fn poison(&self) -> Option<&KernelFault>

Source

pub fn engine(&self) -> Option<&LoopStateMachine>

Read-only access to the semantic engine, for tests and host projections.

Source

pub fn lifecycle(&self) -> OperationLifecycle

Where the driver’s own fold says the operation is. The transaction stays the authority on lifecycle; this exists so a host projection never needs a second copy of the rule.

Source

pub fn project_logical_state(&self) -> LogicalStateProjection

Project the three driver-owned partitions of §12.1, plus the two transition fields the driver rather than the transaction owns.

Explicitly a projection, not a serialisation: every value below is read through a named accessor and written into a canonical DTO field. That is the whole point of §12.1 — adding a field to [LoopStateMachine] must not change the checkpoint format, and a checkpoint field must not silently vanish because an internal one was renamed. It is also why the internal enums travel as their label() plus their carried data: TaskLifecycle::Done(reason) and Residency::External { .. } are semantic-kernel shapes, and mirroring them would make the checkpoint a checkpoint of a private layout.

Source

pub fn restore_logical_state( genesis_config: &ResolvedOperationConfig, state: &LogicalKernelState, ) -> Result<Self, KernelFault>

Rebuild a driver from a checkpoint’s logical state (§12.2 line 3).

The exact inverse of Self::project_logical_state, and deliberately nothing more: every value written here is a value the projection reads back, so “did the restore work” is not a judgement call — super::restore::restore_operation re-projects immediately afterwards and compares the digest. A field this function forgets therefore fails the restore rather than producing a runtime that is quietly one field short of the one that crashed.

Task 16b makes every scheduler branch invertible here: workflow source nodes rebuild their private graph indexes, queued signals rebuild priority and dedupe state, and child process identity is restored without re-running permission defaults. Unknown labels and inconsistent relationships still fail closed as CheckpointIncompatible.

Source

pub fn plan( &mut self, context: &PlanContext<'_>, ) -> Result<PlannedStep, KernelFault>

Plan one input.

Pass this to KernelTransaction::prepare. The focus/root-kind fold does not advance here — call Self::note_committed once the host’s append and the transaction’s commit have both succeeded.

Source

pub fn note_committed(&mut self, step_seq: WireU64) -> Result<(), KernelFault>

Install the staged fold after the transaction committed the record (§7.4: a focus moves only on a committed transition).

Source

pub fn fold( &mut self, context: &PlanContext<'_>, ) -> Result<PlannedStep, KernelFault>

Plan and fold in one call — the shape rebuild_from_records needs, where every record it replays is by definition already durable.

Source

pub fn begin_nested_workflow( &mut self, context: &PlanContext<'_>, spec: &WireSpec, ) -> Result<PlannedStep, KernelFault>

Enter a workflow the agent asked for, inside an agent root (§10.2).

This is the P1 reduction point Task 10 wires its SyscallRequest::SubmitWorkflow gate to; the authority rules it enforces are already the final ones:

  • the root kind stays Agent — a syscall never re-roots an operation;
  • the focus moves to WorkflowController { parent_task_id: Some(agent task) };
  • depth is at most 1. Asking for a workflow while the focus already is a WorkflowController is an InvalidAuthority fault with zero mutation — workflows do not stack (§15.4).

Trait Implementations§

Source§

impl Default for CanonicalOperationDriver

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.