pub struct InMemoryAuditTrail { /* private fields */ }Expand description
In-memory audit trail backed by parking_lot::RwLock<Vec<AuditRecord>>.
Lock is never held across .await — all operations are synchronous inside
the lock, then wrapped in Box::pin(async { ... }). parking_lot is used
(not std::sync::RwLock) for ~2× faster uncontended read acquisition on
the audit hot path (every turn, every tool call); see T2 in
tasks/performance-audit-heartbit-core-2026-05-06.md.
Implementations§
Trait Implementations§
Source§impl AuditTrail for InMemoryAuditTrail
impl AuditTrail for InMemoryAuditTrail
Source§fn record(
&self,
entry: AuditRecord,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>
fn record( &self, entry: AuditRecord, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>
Record a single audit entry. Best-effort: failures are logged, never abort the agent.
Source§fn entries(
&self,
scope: &TenantScope,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<AuditRecord>, Error>> + Send + '_>>
fn entries( &self, scope: &TenantScope, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<AuditRecord>, Error>> + Send + '_>>
Tenant-scoped read. Returns the most recent
limit entries whose
tenant_id matches scope.tenant_id. Single-tenant scope (empty
tenant_id) returns rows where tenant_id is None or "".Source§fn entries_unscoped(
&self,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<AuditRecord>, Error>> + Send + '_>>
fn entries_unscoped( &self, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<AuditRecord>, Error>> + Send + '_>>
Cross-tenant admin read. Renamed from the previous unscoped
entries()
so call sites must explicitly opt in to cross-tenant visibility.
Returns the most recent limit entries.Source§fn entries_since(
&self,
scope: &TenantScope,
since: DateTime<Utc>,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<AuditRecord>, Error>> + Send + '_>>
fn entries_since( &self, scope: &TenantScope, since: DateTime<Utc>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<AuditRecord>, Error>> + Send + '_>>
Time-windowed scoped read. Returns the most recent
limit entries for
the given scope where timestamp >= since.Auto Trait Implementations§
impl !Freeze for InMemoryAuditTrail
impl !RefUnwindSafe for InMemoryAuditTrail
impl Send for InMemoryAuditTrail
impl Sync for InMemoryAuditTrail
impl Unpin for InMemoryAuditTrail
impl UnsafeUnpin for InMemoryAuditTrail
impl UnwindSafe for InMemoryAuditTrail
Blanket Implementations§
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
Mutably borrows from an owned value. Read more