Skip to main content

AuditRecord

Struct AuditRecord 

Source
pub struct AuditRecord {
    pub ts: String,
    pub kind: AuditKind,
    pub peer: Option<String>,
    pub service: Option<String>,
    pub method: Option<String>,
    pub tool: Option<String>,
    pub args_hash: Option<String>,
    pub bytes_out: Option<u64>,
    pub status: Option<String>,
    pub latency_ms: Option<u64>,
    pub event: Option<String>,
    pub target: Option<String>,
}
Expand description

One audit record — the union of the event classes, and the record payload of a StreamFrame::Event. ONE schema for the on-disk JSONL log and the live stream. Every field beyond ts/kind is optional and elided when absent (skip_serializing_if), so each class serializes to just its relevant keys (a session record has no method; a trust record has no bytes_out).

PRIVACY: the proxied-request record carries method + tool (NAME only) + args_hash ("blake3:<hex>"), and NEVER the raw arguments, the request/response content, or any tool-output bytes — only a bytes_out COUNT and a status.

Fields§

§ts: String

RFC3339 UTC with millisecond precision, e.g. "2026-07-03T14:02:11.480Z". The YYYY-MM prefix also selects the monthly file (the rotation boundary), so it is always present.

§kind: AuditKind§peer: Option<String>

The gate-resolved authenticated peer (attributed by the endpoint_id-keyed trust gate). Absent on local-only events with no remote peer (a manual roster install).

§service: Option<String>§method: Option<String>§tool: Option<String>

The tool NAME only (never its arguments or output) — e.g. "read_file" for a tools/call.

§args_hash: Option<String>

"blake3:<hex>" of the request arguments. The raw arguments are NEVER stored.

§bytes_out: Option<u64>

Byte COUNT of the response sent back to the peer — a count, never the content.

§status: Option<String>

"ok" / "error" (proxied request) or "ok" / "denied" (blob fetch).

§latency_ms: Option<u64>§event: Option<String>

Trust-event verb: "pair" / "unpair" / "roster_install" / "revoke" (kind == Trust).

§target: Option<String>

A reference, NEVER content: a blob hash (BlobFetch) or a trust-event target such as a petname or org/serial (Trust).

Implementations§

Source§

impl AuditRecord

Source

pub fn session_open(ts: String, peer: Option<String>, service: String) -> Self

Source

pub fn with_status(self, status: &str) -> Self

Set the record’s status ("ok"/"error"/"denied"), returning self for chaining. Marks a synthesized failure record — e.g. the session_open for a FAILED dial, which reaches no backend and so is never audited by the far side’s session guard — without a dedicated constructor. DRY: reuses the existing optional status field.

Source

pub fn session_close(ts: String, peer: Option<String>, service: String) -> Self

Source

pub fn proxied_request( ts: String, peer: Option<String>, service: String, method: String, tool: Option<String>, args_hash: String, bytes_out: u64, status: String, latency_ms: u64, ) -> Self

A completed (request→response correlated) proxied line: method + tool NAME + args_hash, plus the response’s bytes_out COUNT, status, and latency_ms. PRIVACY: args_hash is a digest; no raw arguments, request/response content, or tool-output bytes are ever passed in.

Source

pub fn proxied_notification( ts: String, peer: Option<String>, service: String, method: String, tool: Option<String>, args_hash: String, ) -> Self

A proxied NOTIFICATION line (no id, so no response correlates): method + tool + args_hash, no bytes_out/status/latency_ms. The line is still recorded — every proxied request is audited.

Source

pub fn blob_fetch( ts: String, peer: Option<String>, hash: String, status: String, ) -> Self

Source

pub fn trust(ts: String, event: String, target: Option<String>) -> Self

Trait Implementations§

Source§

impl Clone for AuditRecord

Source§

fn clone(&self) -> AuditRecord

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AuditRecord

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AuditRecord

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for AuditRecord

Source§

fn eq(&self, other: &AuditRecord) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for AuditRecord

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AuditRecord

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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