An AI Act audit log format you can actually implement
Article 12 does not specify a schema, which is why most implementations fail an audit for the same three reasons: no actor, no model version, no integrity. This is a format that fixes all three without building a SIEM.
Design constraints first
- One record per event, append-only. No updates, no deletes; corrections are new events.
- The record must be understandable without the application: plain field names, ISO 8601 UTC timestamps, no opaque enums.
- Personal data is minimised at write time, not at export time.
- The record commits to its predecessor, so a gap or an edit is detectable.
- The export is one file per period, in a format a third party can read: JSON Lines is enough.
The event taxonomy
| Type | When it fires | Why the Act cares |
|---|---|---|
| inference | A model call that produces an output | The primary activity to monitor (Art. 12(2)(b), Art. 72) |
| approval_request | A human decision is needed | Oversight workflow (Art. 14) |
| approval_decision | The human decides | Proof that oversight happened |
| human_review | A person inspects or edits an output | Oversight in practice |
| data_access | Personal or sensitive data is read | Data governance (Art. 10), minimisation |
| model_change | Model or prompt version changes | Substantial modification (Art. 3(23)) |
| error | A failed call, guardrail block or timeout | Robustness (Art. 15), incident precursors |
The record
| Field | Type | Required | Notes |
|---|---|---|---|
| id | uuid | yes | Stable, never reused |
| seq | integer | yes | Monotonic per system; proves completeness |
| occurred_at | ISO 8601 UTC | yes | When the event happened, not when it was written |
| received_at | ISO 8601 UTC | yes | When the platform stored it; the difference is a clock signal |
| actor | string | yes | Person or named service, never a shared key |
| event_type | enum | yes | From the taxonomy above |
| model | object | for inference | provider, name, version |
| data_categories | string[] | yes | Labels, not values |
| input_summary | string | yes | Masked, truncated to ~320 chars |
| output_summary | string | yes | Masked, truncated |
| decision_id | string | optional | Joins the log to the business record |
| approval_id | string | optional | Joins the log to the oversight record |
| prev_hash | hex | yes | Hash of the previous record |
| hash | hex | yes | Hash of this record including prev_hash |
A hash chain proves nothing was changed. A monotonic sequence proves nothing was removed from the middle. Auditors check both, and a missing seq is the first thing they notice.
Chaining, in twenty lines
import { createHash } from "node:crypto";
// Deterministic JSON: sorted keys, no whitespace.
function canonical(value: unknown): string {
if (value === null || typeof value !== "object") return JSON.stringify(value);
if (Array.isArray(value)) return "[" + value.map(canonical).join(",") + "]";
const obj = value as Record<string, unknown>;
return "{" + Object.keys(obj).sort()
.map((k) => JSON.stringify(k) + ":" + canonical(obj[k]))
.join(",") + "}";
}
const sha256 = (input: string) => createHash("sha256").update(input).digest("hex");
export function append(prevHash: string, event: Record<string, unknown>) {
const hash = sha256(prevHash + "|" + canonical(event));
return { ...event, prev_hash: prevHash, hash };
}Two details make or break this. The canonical form must be stable across languages and versions, otherwise verification fails for reasons that have nothing to do with tampering. And the chain must be per system, not global: a shared chain across tenants leaks ordering information and makes verification expensive.
Verification an auditor can run
- 1Export the period as JSON Lines, with the chain head and record count in a header line.
- 2Recompute each hash from prev_hash plus the canonical record; compare.
- 3Check that seq is contiguous and that the last hash equals the published chain head.
- 4Optionally, verify a signed digest of the chain head with the issuer's public key — this is what proves the export was not regenerated.
The signed digest is the step most implementations skip, and it is the one that matters when the export itself is challenged. A hash chain proves internal consistency; a signature over the chain head proves the issuer stood behind it at a point in time.
Storage choices
| Option | Pros | Cons |
|---|---|---|
| Postgres table + hash chain | Simple, queryable, cheap | Needs discipline: no UPDATE grants, no manual deletes |
| Append-only file per day | Trivially immutable, easy to export | Harder to query, needs object storage lifecycle |
| Object storage with retention lock | WORM guarantees, good for years | Latency, cost, one more system |
| Third-party SIEM | Search and alerting | Retention often 30–90 days; usually not evidence-grade |
For most teams under a thousand events a day, a database table with a restricted role plus a daily signed digest written to object storage is enough. The digest is small, cheap to keep for ten years, and answers the only question that matters: was this the state of the log at that time?
TraceSeal accepts OpenAI, Azure OpenAI, Ollama or custom events, masks personal data, chains every record and exports a signed pack. The schema above is the one it uses.
Try it on your logsFrequently asked
Do we need a blockchain?
No. A hash chain with a signed periodic digest gives the same tamper-evidence for this use case without the operational cost. Blockchain adds distributed trust you do not need when you are the issuer.
JSON Lines or CSV for export?
JSON Lines. It preserves nested fields and types, streams well, and is readable by any auditor with a text editor or a ten-line script. CSV loses structure and invites manual editing.
What if the clock is wrong?
Then every timestamp is wrong and the log loses evidential value. Use NTP, record received_at alongside occurred_at, and monitor drift. The gap between the two is your early warning.
How large can a record get?
Keep it small. Summaries of a few hundred characters, category labels instead of values, and a hash of the original payload if you need to prove exact content. Large payloads create retention and GDPR problems you do not want.
Sources
Keep reading
A practical reading of Article 12 of the EU AI Act: automatic event recording, the minimum fields, retention under Articles 19 and 26(6), and the traps that make logs unusable as evidence.
An AI Act evidence pack is the fixed record an operator shows when asked how a high-risk AI system is governed: classification, controls, logs, human oversight and a way to prove nothing was edited.