pub struct PolicyGateExecutor<T: ToolExecutor> { /* private fields */ }Expand description
Wraps an inner ToolExecutor, evaluating PolicyEnforcer before delegating.
Policy is only applied to execute_tool_call / execute_tool_call_confirmed.
Legacy execute / execute_confirmed bypass policy — see CRIT-03 note above.
Implementations§
Source§impl<T: ToolExecutor> PolicyGateExecutor<T>
impl<T: ToolExecutor> PolicyGateExecutor<T>
Sourcepub fn new(
inner: T,
enforcer: Arc<PolicyEnforcer>,
context: Arc<RwLock<PolicyContext>>,
) -> Self
pub fn new( inner: T, enforcer: Arc<PolicyEnforcer>, context: Arc<RwLock<PolicyContext>>, ) -> Self
Create a new PolicyGateExecutor.
Sourcepub fn with_audit(self, audit: Arc<AuditLogger>) -> Self
pub fn with_audit(self, audit: Arc<AuditLogger>) -> Self
Attach an audit logger to record every policy decision.
Sourcepub fn update_context(&self, new_ctx: PolicyContext)
pub fn update_context(&self, new_ctx: PolicyContext)
Write the current context (called by the agent loop when trust level changes).
Trait Implementations§
Source§impl<T: ToolExecutor + Debug> Debug for PolicyGateExecutor<T>
impl<T: ToolExecutor + Debug> Debug for PolicyGateExecutor<T>
Source§impl<T: ToolExecutor> ToolExecutor for PolicyGateExecutor<T>
impl<T: ToolExecutor> ToolExecutor for PolicyGateExecutor<T>
async fn execute( &self, _response: &str, ) -> Result<Option<ToolOutput>, ToolError>
Source§async fn execute_confirmed(
&self,
_response: &str,
) -> Result<Option<ToolOutput>, ToolError>
async fn execute_confirmed( &self, _response: &str, ) -> Result<Option<ToolOutput>, ToolError>
Execute bypassing confirmation checks (called after user approves).
Default: delegates to
execute.Source§fn tool_definitions(&self) -> Vec<ToolDef>
fn tool_definitions(&self) -> Vec<ToolDef>
Return tool definitions this executor can handle.
Source§async fn execute_tool_call(
&self,
call: &ToolCall,
) -> Result<Option<ToolOutput>, ToolError>
async fn execute_tool_call( &self, call: &ToolCall, ) -> Result<Option<ToolOutput>, ToolError>
Execute a structured tool call. Returns
None if tool_id is not handled.Source§async fn execute_tool_call_confirmed(
&self,
call: &ToolCall,
) -> Result<Option<ToolOutput>, ToolError>
async fn execute_tool_call_confirmed( &self, call: &ToolCall, ) -> Result<Option<ToolOutput>, ToolError>
Execute a structured tool call bypassing confirmation checks. Read more
Source§fn set_skill_env(&self, env: Option<HashMap<String, String>>)
fn set_skill_env(&self, env: Option<HashMap<String, String>>)
Inject environment variables for the currently active skill. No-op by default.
Source§fn set_effective_trust(&self, level: SkillTrustLevel)
fn set_effective_trust(&self, level: SkillTrustLevel)
Set the effective trust level for the currently active skill. No-op by default.
Auto Trait Implementations§
impl<T> Freeze for PolicyGateExecutor<T>where
T: Freeze,
impl<T> !RefUnwindSafe for PolicyGateExecutor<T>
impl<T> Send for PolicyGateExecutor<T>
impl<T> Sync for PolicyGateExecutor<T>
impl<T> Unpin for PolicyGateExecutor<T>where
T: Unpin,
impl<T> UnsafeUnpin for PolicyGateExecutor<T>where
T: UnsafeUnpin,
impl<T> !UnwindSafe for PolicyGateExecutor<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> ErasedToolExecutor for Twhere
T: ToolExecutor,
impl<T> ErasedToolExecutor for Twhere
T: ToolExecutor,
fn execute_erased<'a>( &'a self, response: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutput>, ToolError>> + Send + 'a>>
fn execute_confirmed_erased<'a>( &'a self, response: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutput>, ToolError>> + Send + 'a>>
fn tool_definitions_erased(&self) -> Vec<ToolDef>
fn execute_tool_call_erased<'a>( &'a self, call: &'a ToolCall, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutput>, ToolError>> + Send + 'a>>
fn execute_tool_call_confirmed_erased<'a>( &'a self, call: &'a ToolCall, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutput>, ToolError>> + Send + 'a>>
Source§fn set_skill_env(&self, env: Option<HashMap<String, String>>)
fn set_skill_env(&self, env: Option<HashMap<String, String>>)
Inject environment variables for the currently active skill. No-op by default.
Source§fn set_effective_trust(&self, level: SkillTrustLevel)
fn set_effective_trust(&self, level: SkillTrustLevel)
Set the effective trust level for the currently active skill. No-op by default.
Source§fn is_tool_retryable_erased(&self, tool_id: &str) -> bool
fn is_tool_retryable_erased(&self, tool_id: &str) -> bool
Whether the executor can safely retry this tool call on a transient error.