pub struct AuditedPolicy { /* private fields */ }tool-loop only.Expand description
A ToolPolicy that records every call before it runs.
It asks the policy it wraps first (every call is allowed when it wraps none),
then writes a tool.action record: the tool, the call’s id, whether it is
read-only or was recovered from text, the decision, the authenticated caller,
the task, and a SHA-256 digest of the arguments, never the arguments. The
record goes to the chain of the request’s tenant, with the call’s other
records.
detail.decision is one of:
allow: the call is allowed and runs once this record is in the store, written before the call, not spooled for later: if the store refuses it, the call is answered as an error the model can read and is not run.deny: it is not run. A record the store refuses is kept as any other record of a required log is; the call was not going to run.approval_required: the wrapped policy sent it to a person, and it does not run now. Kept like a denial: nothing runs on it. Written again when the run resumes, since the policy is asked again.approved: a person approved exactly this call (detail.approvedBy, the identity the approval gate verified, whichAuditPrivacyseals) and it is about to run. Written durably likeallow, immediately before the call (ToolPolicy::approved): an approved call whose record the store refuses is not run (adversarial review N02, 2026-11-13; until then an approved call ran with no record of running, and a healthy store saiddenyfor it).
Install it with ToolLoop::with_policy.
Records are written by the loop’s own task, in the tenant of the request,
which is what ToolLoopExecutor sets.
Implementations§
Source§impl AuditedPolicy
impl AuditedPolicy
Sourcepub fn new(log: Arc<AuditLog>) -> AuditedPolicy
pub fn new(log: Arc<AuditLog>) -> AuditedPolicy
Records every call to log and decides nothing else: each is allowed
that the log can record.
Sourcepub fn wrapping(self, inner: impl ToolPolicy) -> AuditedPolicy
pub fn wrapping(self, inner: impl ToolPolicy) -> AuditedPolicy
Asks inner first. A call it denies is recorded as denied and not run;
one it allows is recorded and then run.
Trait Implementations§
Source§impl Debug for AuditedPolicy
impl Debug for AuditedPolicy
Auto Trait Implementations§
impl !RefUnwindSafe for AuditedPolicy
impl !UnwindSafe for AuditedPolicy
impl Forget for AuditedPolicy
impl Freeze for AuditedPolicy
impl Move for AuditedPolicy
impl Send for AuditedPolicy
impl Sync for AuditedPolicy
impl Unpin for AuditedPolicy
impl UnsafeUnpin for AuditedPolicy
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].