Skip to main content

AuditCapture

Struct AuditCapture 

Source
pub struct AuditCapture { /* private fields */ }
Expand description

Captures audit context across a single proxied request lifecycle.

§Usage

let compiled = redaction_config.compile();
let mut capture = AuditCapture::begin_compiled(Arc::new(compiled));
capture.set_agent_id("agent-1");
capture.set_tool_called("/tools/call");
// … proxy the request …
let entry = capture.finalize(Some(200));
audit_sink.write(&entry).await?;

Implementations§

Source§

impl AuditCapture

Source

pub fn begin(redaction_config: RedactionConfig) -> Self

Begin a new audit capture with a fresh request ID.

Compiles redaction patterns on each call. For hot-path usage, prefer begin_compiled with a pre-compiled config.

Source

pub fn begin_compiled(compiled: Arc<CompiledRedaction>) -> Self

Begin a new audit capture with pre-compiled redaction patterns.

Source

pub fn begin_with_id( request_id: Uuid, redaction_config: RedactionConfig, ) -> Self

Begin a new audit capture with a caller-supplied request ID.

Source

pub fn begin_with_id_compiled( request_id: Uuid, compiled: Arc<CompiledRedaction>, ) -> Self

Begin a new audit capture with a caller-supplied request ID and pre-compiled redaction patterns.

Source

pub fn set_agent_id(&mut self, agent_id: impl Into<String>)

Source

pub fn set_delegation_chain(&mut self, chain: impl Into<String>)

Source

pub fn set_task_session_id(&mut self, session_id: impl Into<String>)

Source

pub fn set_tool_called(&mut self, tool: impl Into<String>)

Source

pub fn set_arguments(&mut self, args: Value)

Source

pub fn set_authorization_decision(&mut self, decision: impl Into<String>)

Source

pub fn set_policy_matched(&mut self, policy: impl Into<String>)

Source

pub fn set_anomaly_flags(&mut self, flags: Vec<String>)

Source

pub fn set_failure_category(&mut self, category: impl Into<String>)

Source

pub fn add_inspection_findings(&mut self, findings: Vec<String>)

Source

pub fn finalize(self, upstream_status: Option<u16>) -> AuditEntry

Finalize the capture: compute latency, apply redaction, return the entry.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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