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 an 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.
§Entry formats
Format v1 (the default) signs a mixed binary/JSON layout with the runtime
key and is verified against the key embedded in each entry. Format v2
(entry_v2) signs a canonical CBOR body covering every field with a
dedicated audit key, carries a per-chain sequence number, and is verified
against a cross-signed key registry, so a rewritten chain signed under
some other key no longer verifies. AuditLog::enable_entry_v2 switches
a log to v2; v1 history stays as it is and is hash-linked into the v2
chains that follow it.
§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();
// The read/write surface is async; drive it on a current-thread runtime.
// 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(),
).await.unwrap();
// Verify chain integrity
let result = log.verify_chain(&session_id).await.unwrap();
assert!(result.valid);Re-exports§
pub use entry_v2::AuditActor;pub use entry_v2::ChainStart;pub use entry_v2::ChainVerifier;pub use entry_v2::EntryV2Seal;pub use entry_v2::KeyRegistry;pub use entry_v2::KeyRegistryRecord;pub use entry_v2::KeyRole;
Modules§
- entry_
v2 - Audit entry format v2: canonical, fully signed entries verified against a key registry.
- host_
call - Host-call records written by the kernel’s host-audit lane.
- prelude
- Prelude module - commonly used types for convenient import.
Structs§
- Audit
Anchor Mark Result - Result of
AuditLog::mark_anchored. - Audit
Anchor Watermark - A chain’s anchored watermark.
- Audit
Chain Anchor Status - One chain’s anchoring state, as listed by
AuditLog::anchor_status. - Audit
Chain Head - Committed head of one audit chain, as read by
AuditLog::heads_snapshot. - Audit
Chain Prune State - Latest prune receipt of one chain.
- Audit
Chain Stats - Bounded O(1) accounting for the active segment of one audit chain.
- Audit
Entry - A single audit log entry.
- Audit
Entry Id - Unique identifier for an audit entry (used for linking).
- Audit
Global Stats - O(1) system-wide audit accounting and retention state.
- Audit
Log - Audit log for recording and verifying security events.
- Audit
Prune Receipt - Signed receipt for an omitted archive prefix.
- Audit
Retention Policy - Operator-selected bounded retention for one audit chain.
- Capsule
Actor - Code identity of the capsule a host-observed entry is attributed to.
- Chain
Verification Result - Result of chain verification.
- Entry
V2Config - How to sign format-v2 entries.
- Legacy
Audit Import Report - Result of importing a legacy principal-home audit database.
- Provider
Request Id - A provider request id taken from an HTTP response header.
Enums§
- Approval
Scope - Scope of an approval.
- Audit
Action - Actions that can be audited.
- Audit
Entry Format - Signed layout of an audit entry.
- Audit
Error - Errors that can occur with audit logging.
- Audit
Outcome - Outcome of an audited action.
- Authorization
Proof - How an action was authorized.
- Chain
Issue - An issue found during chain verification.
Traits§
- Audit
Archive Writer - One archive being written.
- Audit
Archiver - Receives the entries a prune removes, before the prune deletes any.
- Audit
Capacity Provider - Supplies media-native free capacity for destructive legacy audit imports.
- Principal
UidResolver - Resolves a principal alias to its durable UID for v2 chain ids.
Type Aliases§
- Audit
Result - Result type for audit operations.