Audit Trail

HMAC-SHA256 hash-chained audit trail for tamper-evident AI agent logging. EU AI Act Article 12 compliant.

HMAC-SHA256 hash-chained audit logging. Every event's hash includes the previous event's hash, creating an immutable chain where any tampering is immediately detectable. Satisfies EU AI Act Article 12 record-keeping requirements.

Setup

ts

Warning: The signing key is used to compute HMAC hashes. If it is compromised, an attacker could forge valid hashes. Store it as an environment variable and rotate it periodically.

Automatic Audit Logging

Every gov.enforce() call automatically writes an audit event. You don't need to log enforcement decisions manually.

ts

Custom Events

Log additional events for business logic, tool execution results, or any other auditable action.

ts

Note: Events are serialized deterministically (all keys recursively sorted) before hashing. This ensures the same event always produces the same hash regardless of property insertion order.

Chain Verification

Verify the entire audit chain at any time. The verifier recomputes every hash from scratch and checks chain continuity. If any event has been modified, inserted, deleted, or reordered, it reports the exact location.

ts

Tamper Detection

AttackHow It's Detected
Event modificationHash mismatch — recomputed hash differs from stored hash
Event insertionMissing integrity record for the inserted event
Event deletionChain break — previousHash of event N+1 doesn't match hash of event N
Event reorderingChain continuity break at the reordered position

Export & Statistics

Export the full chain for compliance review, external auditors, or archival. Filter by agent, time range, or event type.

ts

Known Limitations

Warning: In-memory chain: The hash chain state is held in process memory. It does not survive process restarts without re-hydrating from persistent storage. Use the PostgreSQL storage adapter for durable audit.

Warning: Concurrent writes: The chain uses an internal serialization queue to prevent hash forks from concurrent log() calls. This means writes are serialized within a single process.