pub struct InferenceAuditLog {
pub entries: Mutex<Vec<AuditEntry>>,
pub next_sequence: AtomicU64,
pub max_entries: usize,
pub stats: AuditStats,
}Expand description
Immutable, append-only audit trail for distributed inference queries.
§Thread Safety
All public methods are &self and safe to call from multiple threads
concurrently. Sequence assignment and entry insertion are performed under
a single Mutex to guarantee ordering; stat counters use relaxed/acquire
atomics for low-overhead reads.
§Capacity
When entry_count() equals max_entries, append returns
AuditError::CapacityExceeded. Call trim_before to free space.
Fields§
§entries: Mutex<Vec<AuditEntry>>Ordered list of audit entries guarded by a mutex.
next_sequence: AtomicU64Monotonically increasing sequence counter.
max_entries: usizeMaximum number of entries the log will hold before rejecting appends.
stats: AuditStatsAggregate statistics.
Implementations§
Source§impl InferenceAuditLog
impl InferenceAuditLog
Sourcepub fn new(max_entries: usize) -> Self
pub fn new(max_entries: usize) -> Self
Creates a new InferenceAuditLog with the given capacity.
Sourcepub fn append(
&self,
trace_id: &str,
event: AuditEvent,
) -> Result<u64, AuditError>
pub fn append( &self, trace_id: &str, event: AuditEvent, ) -> Result<u64, AuditError>
Appends a new audit event to the log and returns its sequence number.
§Errors
Returns AuditError::CapacityExceeded if the log is full.
Sourcepub fn entries_for_trace(&self, trace_id: &str) -> Vec<AuditEntry>
pub fn entries_for_trace(&self, trace_id: &str) -> Vec<AuditEntry>
Returns all audit entries whose trace_id matches the given string.
Entries are returned in insertion (sequence) order.
Sourcepub fn events_since(&self, sequence: u64) -> Vec<AuditEntry>
pub fn events_since(&self, sequence: u64) -> Vec<AuditEntry>
Returns all entries with sequence > given.
Useful for tailing the log from a known checkpoint.
Sourcepub fn trim_before(&self, sequence: u64) -> usize
pub fn trim_before(&self, sequence: u64) -> usize
Removes all entries with sequence < given and returns how many were removed.
This operation is O(n) in the number of current entries. It updates the
total_trimmed stat by the number of entries actually removed.
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Returns the current number of entries in the log.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for InferenceAuditLog
impl RefUnwindSafe for InferenceAuditLog
impl Send for InferenceAuditLog
impl Sync for InferenceAuditLog
impl Unpin for InferenceAuditLog
impl UnsafeUnpin for InferenceAuditLog
impl UnwindSafe for InferenceAuditLog
Blanket Implementations§
impl<T> Allocation for T
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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