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 thecrate::mac::compiled::CompiledPolicythat governed this decision, when known (Nonefor 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);Nonefor 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: u64Monotonic 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: u128Wall-clock nanos since UNIX epoch when the decision was recorded.
decision: DecisionThe decision the PDP returned (Permit / Deny / Escalate).
generation: u64The 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: SubjectTypeTE subject type (SELinux domain).
subject_clearance: SecurityLabelThe 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: ObjectTypeTE object type.
object_label: SecurityLabelThe object’s content-bound label (S1). MAC provenance for the object.
action: ActionThe action / op being authorized.
reason: DecisionReasonHuman-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
impl AuditRecord
Sourcepub fn canonical_bytes(&self) -> Result<Vec<u8>, AuditError>
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.
Sourcepub fn content_hash(&self) -> Result<[u8; 32], AuditError>
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
impl Clone for AuditRecord
Source§fn clone(&self) -> AuditRecord
fn clone(&self) -> AuditRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AuditRecord
impl Debug for AuditRecord
Source§impl<'de> Deserialize<'de> for AuditRecord
impl<'de> Deserialize<'de> for AuditRecord
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for AuditRecord
impl PartialEq for AuditRecord
Source§fn eq(&self, other: &AuditRecord) -> bool
fn eq(&self, other: &AuditRecord) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for AuditRecord
impl Serialize for AuditRecord
impl Eq for AuditRecord
impl StructuralPartialEq for AuditRecord
Auto Trait Implementations§
impl Freeze for AuditRecord
impl RefUnwindSafe for AuditRecord
impl Send for AuditRecord
impl Sync for AuditRecord
impl Unpin for AuditRecord
impl UnsafeUnpin for AuditRecord
impl UnwindSafe for AuditRecord
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§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> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request