Skip to main content

CodeModeRuntime

Struct CodeModeRuntime 

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

Portable deterministic replay and approval state machine.

Implementations§

Source§

impl CodeModeRuntime

Source

pub fn new(store: Arc<dyn RuntimeStore>) -> Self

Creates a runtime over a persistence implementation.

Source

pub fn with_artifacts( store: Arc<dyn RuntimeStore>, artifacts: Arc<dyn ArtifactStore>, ) -> Self

Creates a runtime with an explicit oversized-value store.

Source

pub async fn begin( &self, code: impl Into<String>, connectors: Vec<String>, now: u64, ) -> Result<String, RuntimeError>

Starts a fresh execution and prunes old terminal history.

Source

pub async fn begin_with_capabilities( &self, code: &str, capabilities: CapabilitySnapshot, now: u64, ) -> Result<String, RuntimeError>

Creates a durable execution with an immutable capability snapshot.

Source

pub async fn resume( &self, id: &str, now: u64, ) -> Result<ExecutionState, RuntimeError>

Moves a paused execution back to running for a replay pass.

Source

pub async fn cancel(&self, id: &str, now: u64) -> Result<bool, RuntimeError>

Cancels a running or paused execution.

Source

pub async fn event( &self, id: &str, event: ExecutionEvent, ) -> Result<(), RuntimeError>

Appends one bounded execution event.

Source

pub async fn artifact( &self, execution_id: &str, artifact_id: &str, ) -> Result<Option<Value>, RuntimeError>

Loads an artifact value by owning execution and artifact identifiers.

Source

pub async fn decide( &self, id: &str, seq: u64, connector: &str, method: &str, arguments: Value, requires_approval: bool, ephemeral: bool, now: u64, ) -> Result<ToolDecision, RuntimeError>

Decides whether the next call replays, executes, or pauses.

Source

pub async fn record_result( &self, id: &str, seq: u64, result: Value, now: u64, ) -> Result<(), RuntimeError>

Records a completed connector call for deterministic replay.

Source

pub async fn complete( &self, id: &str, result: Value, logs: Vec<String>, now: u64, ) -> Result<(), RuntimeError>

Marks an execution completed and records bounded audit output.

Source

pub async fn fail( &self, id: &str, error: impl Into<String>, logs: Vec<String>, now: u64, ) -> Result<(), RuntimeError>

Marks an execution failed.

Source

pub async fn approve( &self, id: &str, seq: u64, now: u64, ) -> Result<bool, RuntimeError>

Approves a pending action without racing a stale second approval.

Source

pub async fn reject( &self, id: &str, seq: u64, now: u64, ) -> Result<bool, RuntimeError>

Rejects a pending action and terminates its execution.

Source

pub async fn pending( &self, id: Option<&str>, ) -> Result<Vec<PendingAction>, RuntimeError>

Lists actionable approvals, optionally scoped to one execution.

Source

pub async fn actions_to_revert( &self, id: &str, ) -> Result<Vec<LogEntry>, RuntimeError>

Returns applied connector actions in reverse order for compensation.

Source

pub async fn mark_reverted( &self, id: &str, seq: u64, now: u64, ) -> Result<(), RuntimeError>

Marks one compensated action reverted.

Source

pub async fn finish_rollback( &self, id: &str, now: u64, ) -> Result<(), RuntimeError>

Marks an execution rolled back after compensation completes.

Source

pub async fn expire( &self, now: u64, max_age_ms: u64, ) -> Result<Vec<String>, RuntimeError>

Expires abandoned paused and running executions.

Source

pub async fn execution( &self, id: &str, ) -> Result<Option<ExecutionState>, RuntimeError>

Loads one execution.

Source

pub async fn execution_snapshot( &self, id: &str, ) -> Result<Option<ExecutionState>, RuntimeError>

Loads one bounded execution snapshot with artifact references intact.

Source

pub async fn executions(&self) -> Result<Vec<ExecutionState>, RuntimeError>

Lists executions newest first.

Source

pub async fn prune(&self, keep: usize) -> Result<usize, RuntimeError>

Prunes terminal history while retaining every live execution.

Source

pub async fn save_snippet( &self, name: impl Into<String>, description: impl Into<String>, execution_id: &str, input_schema: Option<Value>, now: u64, ) -> Result<Snippet, RuntimeError>

Saves a working execution as a reusable snippet.

Source

pub async fn snippets(&self) -> Result<Vec<Snippet>, RuntimeError>

Lists snippets in stable name order.

Source

pub async fn delete_snippet(&self, name: &str) -> Result<bool, RuntimeError>

Deletes one snippet.

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.