Skip to main content

GuardedToolRuntime

Struct GuardedToolRuntime 

Source
pub struct GuardedToolRuntime<S> { /* private fields */ }
Expand description

In-process Host reference monitor and execution gate.

The policy ceiling, registry, call ledger, and approval verifier are all Host-owned. Callers can grant less authority per Run but cannot replace the ceiling or a registered descriptor.

Implementations§

Source§

impl<S: ApprovalCapabilityStore> GuardedToolRuntime<S>

Source

pub async fn freeze_model_observations( &self, run_id: &RunId, observations: &ModelToolObservations, pending_calls: &[ToolCallId], ) -> Result<FrozenToolObservations, ToolOutcome>

Source§

impl<S: ApprovalCapabilityStore> GuardedToolRuntime<S>

Source

pub fn new( host_ceiling: HostToolPolicy, approval_verifier: HostApprovalVerifier<S>, ) -> Result<Self, ToolRuntimeError>

Source

pub fn new_with_effect_journal( host_ceiling: HostToolPolicy, approval_verifier: HostApprovalVerifier<S>, effect_journal: Arc<dyn ToolEffectJournalStore>, ) -> Result<Self, ToolRuntimeError>

Source

pub fn new_with_effect_journal_and_artifacts( host_ceiling: HostToolPolicy, approval_verifier: HostApprovalVerifier<S>, effect_journal: Arc<dyn ToolEffectJournalStore>, artifact_store: ToolArtifactStore, ) -> Result<Self, ToolRuntimeError>

Source

pub fn with_permission_policy( self, policy: Arc<dyn ToolPermissionPolicy>, ) -> Self

Replaces the immutable invocation permission policy before the runtime is shared or registered with an Agent composition root.

Source

pub fn register( &self, descriptor: ToolDescriptor, executor: Arc<dyn GuardedToolExecutor>, ) -> Result<(), ToolRuntimeError>

Registers an immutable descriptor and policy-aware executor.

Source

pub fn execution_contract_digest(&self) -> Result<Digest, ToolRuntimeError>

Digests only the declared execution boundary. Executor pointers, approval signing material, and mutable invocation state are intentionally excluded.

Source

pub fn project_model_output( &self, invocation: &ToolInvocation, output: &Value, ) -> Result<Value, ToolRuntimeError>

Source

pub fn model_tool_schemas( &self, ) -> Result<Vec<ModelToolSchema>, ToolRuntimeError>

Projects only the model-facing schema. Host policy, effect declarations, approval state, and executor details cannot enter this return type.

Source

pub fn resolve_tool_id( &self, model_name: &str, ) -> Result<Option<ToolId>, ToolRuntimeError>

Source

pub fn activity_evidence( &self, invocation: &ToolInvocation, outcome: Option<&ToolOutcome>, ) -> Result<Vec<ToolActivityEvidence>, ToolRuntimeError>

Source

pub async fn recover_outcome( &self, invocation: ToolInvocation, run_grant: RunToolGrant, ) -> Result<Option<ToolOutcome>, ToolOutcomeRecoveryError>

Replays only durable Tool state. This path can close an Observed result or classify an orphaned Invoked effect as unknown, but it never creates Prepared/Invoked records and never enters an executor.

Source

pub async fn invoke( &self, invocation: ToolInvocation, run_grant: RunToolGrant, approval: Option<ApprovalCapability>, run_cancellation: CancellationToken, ) -> GuardedToolResult

Executes the fixed guarded pipeline:

invocation/input schema → effective policy → operation planning → permission decision/approval → concurrency gate/executor → output schema and output limit.

Source

pub async fn invoke_with_yield( &self, invocation: ToolInvocation, run_grant: RunToolGrant, approval: Option<ApprovalCapability>, run_cancellation: CancellationToken, yield_requested: CancellationToken, ) -> GuardedToolResult

Runs the same guarded, journaled invocation while allowing an executor to yield an observation when new Host input arrives.

Source

pub async fn invoke_with_observations( &self, invocation: ToolInvocation, run_grant: RunToolGrant, approval: Option<ApprovalCapability>, run_cancellation: CancellationToken, yield_requested: CancellationToken, observations: &FrozenToolObservations, ) -> GuardedToolResult

Source

pub async fn inspect_effect( &self, key: &ToolEffectKey, ) -> Result<Option<ToolEffectProjection>, ToolOutcomeRecoveryError>

Loads a durable Tool effect without closing Observed or classifying Invoked. This is deliberately read-only so a workflow can perform a global recovery preflight before it dispatches any new work.

Source

pub fn forget_run(&self, run_id: &RunId) -> Result<(), ToolRuntimeError>

Releases replay and per-Run gate state once the owning Agent Run is no longer resumable in this process.

Trait Implementations§

Source§

impl<S> AgentToolRuntime for GuardedToolRuntime<S>
where S: ApprovalCapabilityStore + 'static,

Source§

fn project_model_output( &self, invocation: &ToolInvocation, output: &Value, ) -> Result<Value, ToolRuntimeError>

Source§

fn freeze_model_observations<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, run_id: &'life1 RunId, observations: &'life2 ModelToolObservations, pending_calls: &'life3 [ToolCallId], ) -> Pin<Box<dyn Future<Output = Result<FrozenToolObservations, ToolOutcome>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Source§

fn execution_contract_digest(&self) -> Result<Digest, ToolRuntimeError>

Stable identity of the Host-side execution contract used to decide whether a private Agent checkpoint may continue after restart. Read more
Source§

fn model_tool_schemas(&self) -> Result<Vec<ModelToolSchema>, ToolRuntimeError>

Source§

fn resolve_tool_id( &self, model_name: &str, ) -> Result<Option<ToolId>, ToolRuntimeError>

Source§

fn activity_evidence( &self, invocation: &ToolInvocation, outcome: Option<&ToolOutcome>, ) -> Result<Vec<ToolActivityEvidence>, ToolRuntimeError>

Source§

fn inspect_effect<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 ToolEffectKey, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolEffectProjection>, ToolOutcomeRecoveryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reads one durable effect projection without changing its phase. Workflow recovery uses this to reject an entire replay before any new sibling Tool is dispatched when one prior invocation is unresolved.
Source§

fn recover_outcome<'life0, 'async_trait>( &'life0 self, invocation: ToolInvocation, run_grant: RunToolGrant, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutcome>, ToolOutcomeRecoveryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Recovers an already-started invocation from the durable Effect Journal without ever calling its executor or creating a fresh effect record. Ok(None) means no durable outcome exists. Callers must establish exclusive recovery ownership before using this operation.
Source§

fn invoke<'life0, 'async_trait>( &'life0 self, invocation: ToolInvocation, run_grant: RunToolGrant, approval: Option<ApprovalCapability>, run_cancellation: CancellationToken, ) -> Pin<Box<dyn Future<Output = GuardedToolResult> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn invoke_with_yield<'life0, 'async_trait>( &'life0 self, invocation: ToolInvocation, run_grant: RunToolGrant, approval: Option<ApprovalCapability>, run_cancellation: CancellationToken, yield_requested: CancellationToken, ) -> Pin<Box<dyn Future<Output = GuardedToolResult> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Invoke with a Host signal for cooperative waits. Implementations that do not support yielding retain their normal execution semantics.
Source§

fn invoke_with_observations<'life0, 'life1, 'async_trait>( &'life0 self, invocation: ToolInvocation, run_grant: RunToolGrant, approval: Option<ApprovalCapability>, run_cancellation: CancellationToken, yield_requested: CancellationToken, observations: &'life1 FrozenToolObservations, ) -> Pin<Box<dyn Future<Output = GuardedToolResult> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Uses only observations from the Host’s already-dispatched model request. Runtimes without observation resolution preserve their existing path.

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more