pub struct AuditEvent {
pub timestamp: DateTime<Utc>,
pub event_id: String,
pub event_type: AuditEventType,
pub actor: Option<Actor>,
pub action: Option<Action>,
pub result: Option<ExecutionResult>,
pub security: SecurityContext,
pub agent_alias: Option<String>,
pub sequence: u64,
pub prev_hash: String,
pub entry_hash: String,
pub signature: Option<String>,
}Expand description
Complete audit event with Merkle hash-chain fields.
Fields§
§timestamp: DateTime<Utc>§event_id: String§event_type: AuditEventType§actor: Option<Actor>§action: Option<Action>§result: Option<ExecutionResult>§security: SecurityContext§agent_alias: Option<String>Owning agent’s alias. None on system-level events (boot,
migration, scheduler ticks not bound to any specific agent) and
on legacy entries written before the field existed. Audit
storage stays at <install>/audit/ (global, not per-agent), so
an agent delete does NOT remove its prior audit trail; this
field lets queries reconstruct per-agent activity after the
fact.
sequence: u64Monotonically increasing sequence number.
prev_hash: StringSHA-256 hash of the previous entry (genesis uses GENESIS_PREV_HASH).
entry_hash: StringSHA-256 hash of (prev_hash || canonical JSON of this entry’s content fields).
signature: Option<String>Optional HMAC-SHA256 signature over entry_hash (present only when sign_events enabled)
Implementations§
Source§impl AuditEvent
impl AuditEvent
Sourcepub fn new(event_type: AuditEventType) -> Self
pub fn new(event_type: AuditEventType) -> Self
Create a new audit event
Sourcepub fn with_actor(
self,
channel: String,
user_id: Option<String>,
username: Option<String>,
) -> Self
pub fn with_actor( self, channel: String, user_id: Option<String>, username: Option<String>, ) -> Self
Set the actor
Sourcepub fn with_agent_alias(self, agent_alias: impl Into<String>) -> Self
pub fn with_agent_alias(self, agent_alias: impl Into<String>) -> Self
Set the owning agent’s alias for multi-agent attribution. Builder method so existing AuditEvent construction sites can add the alias without an explicit field assignment. Pass the alias bound at agent-loop entry.
Sourcepub fn with_action(
self,
command: String,
risk_level: String,
approved: bool,
allowed: bool,
) -> Self
pub fn with_action( self, command: String, risk_level: String, approved: bool, allowed: bool, ) -> Self
Set the action
Sourcepub fn with_result(
self,
success: bool,
exit_code: Option<i32>,
duration_ms: u64,
error: Option<String>,
) -> Self
pub fn with_result( self, success: bool, exit_code: Option<i32>, duration_ms: u64, error: Option<String>, ) -> Self
Set the result
Sourcepub fn with_security(self, sandbox_backend: Option<String>) -> Self
pub fn with_security(self, sandbox_backend: Option<String>) -> Self
Set security context
Trait Implementations§
Source§impl Clone for AuditEvent
impl Clone for AuditEvent
Source§fn clone(&self) -> AuditEvent
fn clone(&self) -> AuditEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AuditEvent
impl Debug for AuditEvent
Source§impl<'de> Deserialize<'de> for AuditEvent
impl<'de> Deserialize<'de> for AuditEvent
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>,
Auto Trait Implementations§
impl Freeze for AuditEvent
impl RefUnwindSafe for AuditEvent
impl Send for AuditEvent
impl Sync for AuditEvent
impl Unpin for AuditEvent
impl UnsafeUnpin for AuditEvent
impl UnwindSafe for AuditEvent
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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 more