Skip to main content

Crate astrid_audit

Crate astrid_audit 

Source
Expand description

Astrid Audit - Chain-linked cryptographic audit logging.

This crate provides:

  • Cryptographically signed audit entries
  • Chain-linked entries (each contains hash of previous)
  • Persistent storage with SurrealKV
  • Chain integrity verification

§Security Model

Every audit entry is:

  • Signed by the runtime’s ed25519 key
  • Linked to the previous entry via content hash
  • Timestamped
  • Indexed by session

The chain linking provides tamper evidence - any modification to historical entries breaks the chain and is detectable.

§Example

use astrid_audit::{AuditLog, AuditAction, AuditOutcome, AuthorizationProof};
use astrid_core::SessionId;
use astrid_crypto::KeyPair;

// Create an in-memory audit log
let runtime_key = KeyPair::generate();
let user_id = runtime_key.key_id();
let log = AuditLog::in_memory(runtime_key);

// Start a session
let session_id = SessionId::new();

// Record an action
let entry_id = log.append(
    session_id.clone(),
    AuditAction::SessionStarted {
        user_id,
        platform: "cli".to_string(),
    },
    AuthorizationProof::System {
        reason: "session start".to_string(),
    },
    AuditOutcome::success(),
).unwrap();

// Verify chain integrity
let result = log.verify_chain(&session_id).unwrap();
assert!(result.valid);

Modules§

prelude
Prelude module - commonly used types for convenient import.

Structs§

AuditEntry
A single audit log entry.
AuditEntryId
Unique identifier for an audit entry (used for linking).
AuditLog
Audit log for recording and verifying security events.
ChainVerificationResult
Result of chain verification.

Enums§

ApprovalScope
Scope of an approval.
AuditAction
Actions that can be audited.
AuditError
Errors that can occur with audit logging.
AuditOutcome
Outcome of an audited action.
AuthorizationProof
How an action was authorized.
ChainIssue
An issue found during chain verification.

Type Aliases§

AuditResult
Result type for audit operations.