Skip to content
Home/Learn/AI Act audit log format
article-12schemaengineering

An AI Act audit log format you can actually implement

Updated 2026-11-16·10 min read·TraceSeal research

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

TypeWhen it firesWhy the Act cares
inferenceA model call that produces an outputThe primary activity to monitor (Art. 12(2)(b), Art. 72)
approval_requestA human decision is neededOversight workflow (Art. 14)
approval_decisionThe human decidesProof that oversight happened
human_reviewA person inspects or edits an outputOversight in practice
data_accessPersonal or sensitive data is readData governance (Art. 10), minimisation
model_changeModel or prompt version changesSubstantial modification (Art. 3(23))
errorA failed call, guardrail block or timeoutRobustness (Art. 15), incident precursors

The record

FieldTypeRequiredNotes
iduuidyesStable, never reused
seqintegeryesMonotonic per system; proves completeness
occurred_atISO 8601 UTCyesWhen the event happened, not when it was written
received_atISO 8601 UTCyesWhen the platform stored it; the difference is a clock signal
actorstringyesPerson or named service, never a shared key
event_typeenumyesFrom the taxonomy above
modelobjectfor inferenceprovider, name, version
data_categoriesstring[]yesLabels, not values
input_summarystringyesMasked, truncated to ~320 chars
output_summarystringyesMasked, truncated
decision_idstringoptionalJoins the log to the business record
approval_idstringoptionalJoins the log to the oversight record
prev_hashhexyesHash of the previous record
hashhexyesHash of this record including prev_hash
Why seq matters as much as 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

  1. 1Export the period as JSON Lines, with the chain head and record count in a header line.
  2. 2Recompute each hash from prev_hash plus the canonical record; compare.
  3. 3Check that seq is contiguous and that the last hash equals the published chain head.
  4. 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

OptionProsCons
Postgres table + hash chainSimple, queryable, cheapNeeds discipline: no UPDATE grants, no manual deletes
Append-only file per dayTrivially immutable, easy to exportHarder to query, needs object storage lifecycle
Object storage with retention lockWORM guarantees, good for yearsLatency, cost, one more system
Third-party SIEMSearch and alertingRetention 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?

Skip the build

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 logs

Frequently 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

This article is technical information, not legal advice. It reflects Regulation (EU) 2024/1689 as amended by Regulation (EU) 2026/1744 and the sources listed above, as of 2026-11-16. Confirm obligations with qualified counsel for your specific system.

Keep reading