pub struct ProtectedPathGuard { /* private fields */ }Expand description
Refuses a call whose declared paths hold secrets or must not be changed.
Paths are resolved through the ExecutionBackend the tool uses, and
symlinks are followed, so a link to a secret is judged as the secret.
Implementations§
Source§impl ProtectedPathGuard
impl ProtectedPathGuard
pub fn new( backend: Arc<dyn ExecutionBackend>, policy: Arc<dyn FilePolicy>, ) -> Self
Sourcepub fn for_workspace(workspace: Workspace) -> Self
pub fn for_workspace(workspace: Workspace) -> Self
The guard for the bundled file tools confined to workspace.
Trait Implementations§
Source§impl Hook for ProtectedPathGuard
impl Hook for ProtectedPathGuard
Source§fn before_tool<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
call: &'life3 ToolCall,
tool: &'life4 ToolInfo,
) -> Pin<Box<dyn Future<Output = ToolDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn before_tool<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
call: &'life3 ToolCall,
tool: &'life4 ToolInfo,
) -> Pin<Box<dyn Future<Output = ToolDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Decide whether a call may run. The first
Deny, Interrupt or
Answer wins;
Rewrite changes the arguments seen by later hooks and the tool.Source§fn safeguards(&self) -> &'static [Safeguard]
fn safeguards(&self) -> &'static [Safeguard]
The safeguards this hook enforces.
crate::AgentBuilder::build
requires every Safeguard::REQUIRED one to be covered by a hook
or an attestation.Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
How this hook is named in events and in a saved interruption. Stable
across restarts of the same build; override it to keep a hook’s
identity across a rename.
Source§fn redactor(&self) -> Option<&dyn Redact>
fn redactor(&self) -> Option<&dyn Redact>
What this hook hides from everything that leaves the kernel. The
kernel applies it, with the secrets registered in
crate::redaction, to model requests, events, receipts, the
question put to the owner and the saved state. Default: nothing.Source§fn timeout(&self) -> Option<Duration>
fn timeout(&self) -> Option<Duration>
How long one call of this hook may take, in place of
crate::Limits::hook_timeout. The wall-clock budget still applies.The authority this hook enforces, if it enforces one. Passed to
tools so a tool that starts another run can hold it to the same.
Source§fn on_run_start<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn on_run_start<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
A new run is about to take its first turn: load what the other hooks
will need. Resuming a paused run is not a start. A process that dies
before the first turn starts the run again, so make this repeatable.
Source§fn edit_transcript<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
) -> Pin<Box<dyn Future<Output = Option<Vec<Message>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn edit_transcript<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
) -> Pin<Box<dyn Future<Output = Option<Vec<Message>>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Replace the stored transcript at the start of a turn, for example
with a summary. Prefer a
before_model edit, which changes one
request and loses nothing; use this when the shortened history should
be what later turns and resumes start from. Read moreSource§fn before_model<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_request: &'life3 mut ModelRequest,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn before_model<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_request: &'life3 mut ModelRequest,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Edit the request before it is sent: trim context, inject memory,
change the model or tool choice.
Source§fn answer_model<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_request: &'life3 ModelRequest,
) -> Pin<Box<dyn Future<Output = Option<ModelResponse>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn answer_model<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_request: &'life3 ModelRequest,
) -> Pin<Box<dyn Future<Output = Option<ModelResponse>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Answer in the model’s place, for example from a cache. It runs after
every
before_model hook, so it sees the final request. The first
answer wins; the response is treated as the model’s, after_model
included, and the turn counts.Source§fn after_model<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_response: &'life3 mut ModelResponse,
) -> Pin<Box<dyn Future<Output = ModelDecision> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn after_model<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_response: &'life3 mut ModelResponse,
) -> Pin<Box<dyn Future<Output = ModelDecision> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
The model replied. Check or rewrite the response before it is
recorded or acted on; the first
Reject or Stop wins. Calls a hook adds or
changes face the same validation and before_tool hooks as any
other. Streamed text has already gone out as events, and the tokens
are already counted.Source§fn on_model_error<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_error: &'life3 ProviderError,
) -> Pin<Box<dyn Future<Output = ModelErrorDecision> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn on_model_error<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_error: &'life3 ProviderError,
) -> Pin<Box<dyn Future<Output = ModelErrorDecision> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
A model call failed after whatever retries its provider does itself.
Every hook is asked: an
Abort beats everything, then the first
Recover or Retry wins. With none, the run ends.Source§fn on_limit<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_limit: LimitKind,
) -> Pin<Box<dyn Future<Output = LimitDecision> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn on_limit<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_limit: LimitKind,
) -> Pin<Box<dyn Future<Output = LimitDecision> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
The run reached a limit in
crate::Limits. Every hook is asked: a
Forbid beats any grant, then the first Extend wins, is recorded in crate::RunState::limit_grants, and lasts for
this run. crate::HARD_TURN_CAP cannot be extended and is never
put to a hook. A model call cut off by the wall clock is lost and
runs again if the limit is extended.Source§fn after_tool<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_receipt: &'life3 Receipt,
_output: &'life4 mut ToolOutput,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
fn after_tool<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_receipt: &'life3 Receipt,
_output: &'life4 mut ToolOutput,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
Inspect or reshape a result before the model sees it (redaction,
injection screening). The receipt is already final.
Source§fn on_stop<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_final_text: &'life3 str,
) -> Pin<Box<dyn Future<Output = StopDecision> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn on_stop<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_final_text: &'life3 str,
) -> Pin<Box<dyn Future<Output = StopDecision> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
The model produced a final answer. Check it against receipts, a
checklist, tests, anything. Every hook is asked: a
Halt beats
everything, then the first Continue wins. More than
crate::Limits::max_idle_continuations in a row with no new
successful call ends the run unmet.Source§fn on_run_end<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_outcome: &'life3 RunOutcome,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn on_run_end<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_outcome: &'life3 RunOutcome,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
The run ended, with any status: fires once per
run or resume that
returns (a pause returns too), after the
outcome is final and every on_stop check has had its say, so it is
the place for after-the-fact work such as writing memory. It cannot
change the outcome. A run_resolving call is one run: the
interruptions it settles are not run ends.Source§fn on_stuck<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_signal: &'life3 StuckSignal,
) -> Pin<Box<dyn Future<Output = Option<StuckDecision>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn on_stuck<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 HookContext<'life2>,
_signal: &'life3 StuckSignal,
) -> Pin<Box<dyn Future<Output = Option<StuckDecision>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
The stuck detector fired.
None means “no opinion”; if every hook
abstains, the default policy nudges and then stops.Auto Trait Implementations§
impl !RefUnwindSafe for ProtectedPathGuard
impl !UnwindSafe for ProtectedPathGuard
impl Forget for ProtectedPathGuard
impl Freeze for ProtectedPathGuardwhere
*const ArcInner<dyn ExecutionBackend> is !null: Freeze,
PhantomData<ArcInner<dyn ExecutionBackend>>: Freeze,
*const ArcInner<dyn FilePolicy> is !null: Freeze,
PhantomData<ArcInner<dyn FilePolicy>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<(String, FileGuard)>: Freeze,
impl Move for ProtectedPathGuard
impl Send for ProtectedPathGuardwhere
Arc<dyn ExecutionBackend>: Send,
Arc<dyn FilePolicy>: Send,
RawTable<(String, FileGuard)>: Send,
impl Sync for ProtectedPathGuardwhere
Arc<dyn ExecutionBackend>: Sync,
Arc<dyn FilePolicy>: Sync,
RawTable<(String, FileGuard)>: Sync,
impl Unpin for ProtectedPathGuard
impl UnsafeUnpin for ProtectedPathGuardwhere
*const ArcInner<dyn ExecutionBackend> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ExecutionBackend>>: UnsafeUnpin,
*const ArcInner<dyn FilePolicy> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn FilePolicy>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<(String, FileGuard)>: UnsafeUnpin,
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