pub struct AuditLog { /* private fields */ }Expand description
Audit log for recording and verifying security events.
Implementations§
Source§impl AuditLog
impl AuditLog
Sourcepub fn open(path: impl AsRef<Path>, runtime_key: KeyPair) -> AuditResult<Self>
pub fn open(path: impl AsRef<Path>, runtime_key: KeyPair) -> AuditResult<Self>
Create a new audit log with SurrealKV persistence.
§Errors
Returns an error if the storage backend fails to open at the given path.
Sourcepub fn append(
&self,
session_id: SessionId,
action: AuditAction,
authorization: AuthorizationProof,
outcome: AuditOutcome,
) -> AuditResult<AuditEntryId>
pub fn append( &self, session_id: SessionId, action: AuditAction, authorization: AuthorizationProof, outcome: AuditOutcome, ) -> AuditResult<AuditEntryId>
Append a new audit entry.
§Errors
Returns an error if the entry cannot be stored or the chain head cannot be updated.
Sourcepub fn append_with_principal(
&self,
session_id: SessionId,
principal: PrincipalId,
action: AuditAction,
authorization: AuthorizationProof,
outcome: AuditOutcome,
) -> AuditResult<AuditEntryId>
pub fn append_with_principal( &self, session_id: SessionId, principal: PrincipalId, action: AuditAction, authorization: AuthorizationProof, outcome: AuditOutcome, ) -> AuditResult<AuditEntryId>
Append a new audit entry tagged with the acting principal.
Use this when the action was performed on behalf of a specific user (e.g., cross-principal KV write, tool execution). The principal is included in the cryptographic signing data.
§Errors
Returns an error if the entry cannot be stored or the chain head cannot be updated.
Sourcepub fn get(&self, id: &AuditEntryId) -> AuditResult<Option<AuditEntry>>
pub fn get(&self, id: &AuditEntryId) -> AuditResult<Option<AuditEntry>>
Sourcepub fn get_session_entries(
&self,
session_id: &SessionId,
) -> AuditResult<Vec<AuditEntry>>
pub fn get_session_entries( &self, session_id: &SessionId, ) -> AuditResult<Vec<AuditEntry>>
Get all entries for a session.
§Errors
Returns an error if the storage backend fails to retrieve entries.
Sourcepub fn verify_chain(
&self,
session_id: &SessionId,
) -> AuditResult<ChainVerificationResult>
pub fn verify_chain( &self, session_id: &SessionId, ) -> AuditResult<ChainVerificationResult>
Verify the integrity of all audit chains in a session.
Each principal (and the system chain) is verified independently. A session with entries from principals “alice” and “bob” plus system entries will verify three independent chains.
§Errors
Returns an error if entries cannot be retrieved from storage.
Sourcepub fn verify_principal_chain(
&self,
session_id: &SessionId,
principal: Option<&PrincipalId>,
) -> AuditResult<ChainVerificationResult>
pub fn verify_principal_chain( &self, session_id: &SessionId, principal: Option<&PrincipalId>, ) -> AuditResult<ChainVerificationResult>
Verify the integrity of a single principal’s chain within a session.
Pass None to verify the system chain (entries without a principal).
§Errors
Returns an error if entries cannot be retrieved from storage.
Sourcepub fn get_principal_entries(
&self,
session_id: &SessionId,
principal: Option<&PrincipalId>,
) -> AuditResult<Vec<AuditEntry>>
pub fn get_principal_entries( &self, session_id: &SessionId, principal: Option<&PrincipalId>, ) -> AuditResult<Vec<AuditEntry>>
Get entries for a specific principal within a session.
Pass None to get system entries (no principal).
§Errors
Returns an error if entries cannot be retrieved from storage.
Sourcepub fn verify_all(
&self,
) -> AuditResult<Vec<(SessionId, ChainVerificationResult)>>
pub fn verify_all( &self, ) -> AuditResult<Vec<(SessionId, ChainVerificationResult)>>
Verify the entire audit log (all sessions).
§Errors
Returns an error if sessions cannot be listed or verified.
Sourcepub fn count(&self) -> AuditResult<usize>
pub fn count(&self) -> AuditResult<usize>
Sourcepub fn count_session(&self, session_id: &SessionId) -> AuditResult<usize>
pub fn count_session(&self, session_id: &SessionId) -> AuditResult<usize>
Sourcepub fn list_sessions(&self) -> AuditResult<Vec<SessionId>>
pub fn list_sessions(&self) -> AuditResult<Vec<SessionId>>
Sourcepub fn flush(&self) -> AuditResult<()>
pub fn flush(&self) -> AuditResult<()>
Sourcepub fn runtime_public_key(&self) -> PublicKey
pub fn runtime_public_key(&self) -> PublicKey
Get the runtime public key.