pub struct CodeModeRuntime { /* private fields */ }Expand description
Portable deterministic replay and approval state machine.
Implementations§
Source§impl CodeModeRuntime
impl CodeModeRuntime
Sourcepub fn new(store: Arc<dyn RuntimeStore>) -> Self
pub fn new(store: Arc<dyn RuntimeStore>) -> Self
Creates a runtime over a persistence implementation.
Sourcepub fn with_artifacts(
store: Arc<dyn RuntimeStore>,
artifacts: Arc<dyn ArtifactStore>,
) -> Self
pub fn with_artifacts( store: Arc<dyn RuntimeStore>, artifacts: Arc<dyn ArtifactStore>, ) -> Self
Creates a runtime with an explicit oversized-value store.
Sourcepub async fn begin(
&self,
code: impl Into<String>,
connectors: Vec<String>,
now: u64,
) -> Result<String, RuntimeError>
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.
Sourcepub async fn begin_with_capabilities(
&self,
code: &str,
capabilities: CapabilitySnapshot,
now: u64,
) -> Result<String, RuntimeError>
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.
Sourcepub async fn resume(
&self,
id: &str,
now: u64,
) -> Result<ExecutionState, RuntimeError>
pub async fn resume( &self, id: &str, now: u64, ) -> Result<ExecutionState, RuntimeError>
Moves a paused execution back to running for a replay pass.
Sourcepub async fn cancel(&self, id: &str, now: u64) -> Result<bool, RuntimeError>
pub async fn cancel(&self, id: &str, now: u64) -> Result<bool, RuntimeError>
Cancels a running or paused execution.
Sourcepub async fn event(
&self,
id: &str,
event: ExecutionEvent,
) -> Result<(), RuntimeError>
pub async fn event( &self, id: &str, event: ExecutionEvent, ) -> Result<(), RuntimeError>
Appends one bounded execution event.
Sourcepub async fn artifact(
&self,
execution_id: &str,
artifact_id: &str,
) -> Result<Option<Value>, RuntimeError>
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.
Sourcepub async fn decide(
&self,
id: &str,
seq: u64,
connector: &str,
method: &str,
arguments: Value,
requires_approval: bool,
ephemeral: bool,
now: u64,
) -> Result<ToolDecision, RuntimeError>
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.
Sourcepub async fn record_result(
&self,
id: &str,
seq: u64,
result: Value,
now: u64,
) -> Result<(), RuntimeError>
pub async fn record_result( &self, id: &str, seq: u64, result: Value, now: u64, ) -> Result<(), RuntimeError>
Records a completed connector call for deterministic replay.
Sourcepub async fn complete(
&self,
id: &str,
result: Value,
logs: Vec<String>,
now: u64,
) -> Result<(), RuntimeError>
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.
Sourcepub async fn fail(
&self,
id: &str,
error: impl Into<String>,
logs: Vec<String>,
now: u64,
) -> Result<(), RuntimeError>
pub async fn fail( &self, id: &str, error: impl Into<String>, logs: Vec<String>, now: u64, ) -> Result<(), RuntimeError>
Marks an execution failed.
Sourcepub async fn approve(
&self,
id: &str,
seq: u64,
now: u64,
) -> Result<bool, RuntimeError>
pub async fn approve( &self, id: &str, seq: u64, now: u64, ) -> Result<bool, RuntimeError>
Approves a pending action without racing a stale second approval.
Sourcepub async fn reject(
&self,
id: &str,
seq: u64,
now: u64,
) -> Result<bool, RuntimeError>
pub async fn reject( &self, id: &str, seq: u64, now: u64, ) -> Result<bool, RuntimeError>
Rejects a pending action and terminates its execution.
Sourcepub async fn pending(
&self,
id: Option<&str>,
) -> Result<Vec<PendingAction>, RuntimeError>
pub async fn pending( &self, id: Option<&str>, ) -> Result<Vec<PendingAction>, RuntimeError>
Lists actionable approvals, optionally scoped to one execution.
Sourcepub async fn actions_to_revert(
&self,
id: &str,
) -> Result<Vec<LogEntry>, RuntimeError>
pub async fn actions_to_revert( &self, id: &str, ) -> Result<Vec<LogEntry>, RuntimeError>
Returns applied connector actions in reverse order for compensation.
Sourcepub async fn mark_reverted(
&self,
id: &str,
seq: u64,
now: u64,
) -> Result<(), RuntimeError>
pub async fn mark_reverted( &self, id: &str, seq: u64, now: u64, ) -> Result<(), RuntimeError>
Marks one compensated action reverted.
Sourcepub async fn finish_rollback(
&self,
id: &str,
now: u64,
) -> Result<(), RuntimeError>
pub async fn finish_rollback( &self, id: &str, now: u64, ) -> Result<(), RuntimeError>
Marks an execution rolled back after compensation completes.
Sourcepub async fn expire(
&self,
now: u64,
max_age_ms: u64,
) -> Result<Vec<String>, RuntimeError>
pub async fn expire( &self, now: u64, max_age_ms: u64, ) -> Result<Vec<String>, RuntimeError>
Expires abandoned paused and running executions.
Sourcepub async fn execution(
&self,
id: &str,
) -> Result<Option<ExecutionState>, RuntimeError>
pub async fn execution( &self, id: &str, ) -> Result<Option<ExecutionState>, RuntimeError>
Loads one execution.
Sourcepub async fn execution_snapshot(
&self,
id: &str,
) -> Result<Option<ExecutionState>, RuntimeError>
pub async fn execution_snapshot( &self, id: &str, ) -> Result<Option<ExecutionState>, RuntimeError>
Loads one bounded execution snapshot with artifact references intact.
Sourcepub async fn executions(&self) -> Result<Vec<ExecutionState>, RuntimeError>
pub async fn executions(&self) -> Result<Vec<ExecutionState>, RuntimeError>
Lists executions newest first.
Sourcepub async fn prune(&self, keep: usize) -> Result<usize, RuntimeError>
pub async fn prune(&self, keep: usize) -> Result<usize, RuntimeError>
Prunes terminal history while retaining every live execution.
Sourcepub 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>
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.
Sourcepub async fn snippets(&self) -> Result<Vec<Snippet>, RuntimeError>
pub async fn snippets(&self) -> Result<Vec<Snippet>, RuntimeError>
Lists snippets in stable name order.
Sourcepub async fn delete_snippet(&self, name: &str) -> Result<bool, RuntimeError>
pub async fn delete_snippet(&self, name: &str) -> Result<bool, RuntimeError>
Deletes one snippet.