Skip to main content

AuditRecord

Struct AuditRecord 

Source
pub struct AuditRecord {
Show 15 fields pub seq: u64, pub prev_hash: [u8; 32], pub ts_unix_nanos: u128, pub decision: Decision, pub generation: u64, pub policy_hash: Option<[u8; 32]>, pub subject_type: SubjectType, pub subject_clearance: SecurityLabel, pub on_behalf_of: Option<DelegationPrincipal>, pub object_type: ObjectType, pub object_label: SecurityLabel, pub action: Action, pub reason: DecisionReason, pub subject_id: Option<String>, pub object_id: Option<String>,
}
Expand description

A single authorization decision, as recorded by the audit store. This is the unit of tamper-evidence: it is content-addressed (BLAKE3 over canonical CBOR), signed, and append-logged.

Provenance is carried explicitly:

  • generation — the policy generation (lattice version) that produced the decision; binds the record to the exact compiled policy in force.
  • policy_hash — the BLAKE3 of the crate::mac::compiled::CompiledPolicy that governed this decision, when known (None for ad-hoc evaluators).
  • subject_* / object_* — the resolved security contexts (TE type + S1 label) the PDP actually saw, not caller-asserted strings.
  • on_behalf_of — for a delegated decision, the delegator principal (#680/#681); None for an ordinary single-principal decision.
  • reason — why the PDP decided as it did (floor failure, TE miss, token gate, audit-fail-closed, …).

MAC labels are carried as the structured SecurityLabel on the subject (clearance) and object (label) — the audit store is itself MAC-relevant content (a rollup of decisions), so it carries the labels of the decisions it records.

Fields§

§seq: u64

Monotonic sequence number within this store’s journal, assigned by the store. A gap in the on-disk sequence exposes a middle deletion; a deleted tail is caught instead by prev_hash chaining plus the signed checkpoint (see WalAuditStore).

§prev_hash: [u8; 32]

Hash-chain link: the BLAKE3 content hash of the previous record in this store’s journal ([0; 32] for the genesis record). Assigned by the store under the same lock that assigns seq, and covered by this record’s own signature (it is part of the hashed content). Reordering, or deleting/altering any record, breaks the successor’s link — so the journal is an append-only chain, not just a sequence of independent signed lines.

§ts_unix_nanos: u128

Wall-clock nanos since UNIX epoch when the decision was recorded.

§decision: Decision

The decision the PDP returned (Permit / Deny / Escalate).

§generation: u64

The policy generation in force (lattice version). Provenance.

§policy_hash: Option<[u8; 32]>

Optional BLAKE3 of the governing CompiledPolicy (None for ad-hoc evaluators that were not loaded from a signed policy).

§subject_type: SubjectType

TE subject type (SELinux domain).

§subject_clearance: SecurityLabel

The subject’s clearance label (S1). MAC provenance for the subject. On a delegated decision this is the effective meet(delegator, actor) clearance the PDP evaluated (assurance clamped to the actor’s signer key, #548/#681); the delegator half is recorded in Self::on_behalf_of.

§on_behalf_of: Option<DelegationPrincipal>

For a delegated decision (#680/#681), the delegator principal — the source of authority on whose behalf subject_* acted. None for an ordinary single-principal decision.

Versioned by omission: serialized only when Some, so a single-principal record’s canonical bytes (and therefore its content hash and its successor’s prev_hash link) are byte-identical to the pre-delegation schema — the hash chain is preserved across the upgrade.

§object_type: ObjectType

TE object type.

§object_label: SecurityLabel

The object’s content-bound label (S1). MAC provenance for the object.

§action: Action

The action / op being authorized.

§reason: DecisionReason

Human-readable decision reason (which gate denied, or “permit”).

§subject_id: Option<String>

Independently verified application principal, when the enforcement plane has a stable identifier. Omitted for legacy/type-only records.

§object_id: Option<String>

Concrete tenant-qualified object/track, when known. Omitted for legacy/type-only records.

Implementations§

Source§

impl AuditRecord

Source

pub fn canonical_bytes(&self) -> Result<Vec<u8>, AuditError>

Canonical CBOR encoding for hashing/signing.

Fu6/#677: this is real canonical CBOR via [ciborium] (the same CBOR runtime the UCAN grant / COSE layers use), not serde_json. The module docs, the WAL journal framing, and the S7 signed checkpoint all describe the content-addressed digest as taken over canonical CBOR; the previous serde_json::to_vec impl made the docs a lie and pinned the hash to JSON’s incidental field order — a hash-stability hazard on any struct evolution that touched serde representation.

Determinism: ciborium emits map keys in serde struct-field order, so the same AuditRecord always serializes to identical bytes for a given binary. This matches the canonical-CBOR convention used by the UCAN grant’s signing_bytes — see the golden_content_hash_is_stable test, which pins a known record to a fixed BLAKE3 so any drift in the canonical encoding is caught.

Source

pub fn content_hash(&self) -> Result<[u8; 32], AuditError>

BLAKE3 content hash of the canonical bytes — the content-addressed key under which this record is stored in the CAS layer. Same decision ⇒ same hash (the test asserts this).

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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 Eq for AuditRecord

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
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

impl<T> Identity for T
where T: ?Sized,

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> JaggedSlice<T> for T

§

type Index = Index2

§

fn push_into(self, array: &mut Jagged<T>)

§

fn insert_into(self, index: <T as JaggedSlice<T>>::Index, array: &mut Jagged<T>)

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

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

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<E> ResultError for E
where E: Send + Debug + Sync,

§

impl<T> ResultType for T
where T: Send + Clone + Sync + Debug,

§

impl<T> RpcMessage for T
where T: Debug + Serialize + DeserializeOwned + Send + Sync + Unpin + 'static,

§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,

Source§

impl<T> TerminalState for T
where T: Clone + Send + Sync,