# hmac chained audit log for ai agents

Canonical URL: https://bernstein.run/q/hmac-chained-audit-log-for-ai-agents
Markdown URL: https://bernstein.run/q/hmac-chained-audit-log-for-ai-agents.md
Tags: audit, hmac

with the audit log enabled (bernstein run --audit), bernstein writes one json line per orchestration event to .sdd/audit/<YYYY-MM-DD>.jsonl, one file per utc day. each line carries an hmac-sha256 over (previous-line-hmac || event-payload), using a key held outside the audit volume (default ~/.local/state/bernstein/audit.key, overridable with BERNSTEIN_AUDIT_KEY_PATH). mutating or deleting any line breaks the chain at that point. bernstein audit verify walks the file and reports the first broken link. that gives a tamper-evident record of which agent took which action under which model and at what cost, in a format you can replay offline against the source key. without the flag you still get the always-on lineage spine and replay journal, just not the hmac chain. format and signing logic: src/bernstein/core/security/audit.py.

## Related

- https://bernstein.run/q/how-does-the-audit-chain-work
- https://bernstein.run/q/audit-grade-ai-coding-orchestrator-for-regulated-teams
