Audit Trails for AI-Generated Code
Last updated: 2026-11-044 min read
Sources checked 2026-11-04no external figures
An audit trail for AI-generated code records per change what no git log holds: which tool acted, on what written task, what changed, what was validated with which result, and who approved. It is an engineering control pattern, not a legal safe harbour. The dated source map below separates the primary duties from the editorial inference and states what each linked artifact can and cannot establish.
Contents
Why the question suddenly arrives in audits
Legal status: 4 November 2026. This article describes regulation for orientation and is not legal advice; what your auditors accept is their call and your counsel’s.
No single law says “keep an AI code audit trail”. The relevant duties have different scopes. NIS2 Articles 20 and 21 address management oversight and risk-based supply-chain and secure-development measures. The Product Liability Directive includes software in its product definition and, after its corrigendum of 7 May 2026, applies to products placed on the market or put into service after December 8, 2026. Neither source prescribes this page’s record format. The mapping below is a bounded control design that an accountable owner must test against the actual legal, contractual and audit criteria.
What the trail must record – and where git ends
Artifact, owner and proof boundary
| Task | Run record | Validation receipt | Approval | Retention link | |
|---|---|---|---|---|---|
| Accountable owner | Product/change ownerEditorial control mapping · 2026-11-04 | Engineering ownerEditorial control mapping · 2026-11-04 | Control owner or independent reviewerEditorial control mapping · 2026-11-04 | Named accountable roleEditorial control mapping · 2026-11-04 | Repository/records ownerEditorial control mapping · 2026-11-04 |
| Establishes | Intended goal and boundariesEditorial control mapping · 2026-11-04 | Tool, scope and observed changeEditorial control mapping · 2026-11-04 | Command, outcome and timeEditorial control mapping · 2026-11-04 | Who made which decision and whenEditorial control mapping · 2026-11-04 | Link to code version and retention locationEditorial control mapping · 2026-11-04 |
| Does not establish | Not that implementation is correctEditorial control mapping · 2026-11-04 | Not authorship of every lineEditorial control mapping · 2026-11-04 | Not correctness or complianceEditorial control mapping · 2026-11-04 | Not independent assuranceEditorial control mapping · 2026-11-04 | Not legally sufficient retention durationEditorial control mapping · 2026-11-04 |
The gap is structural, not a git flaw: version control records outcomes, not mandates and checks. Commit messages and PR threads hold fragments: unstructured, inconsistent, and scattered across platforms that may not be part of your retention. For an auditor, that is the difference between evidence and archaeology.
Building the trail without a bureaucracy project
- One written task per AI run. Goal, boundaries, criteria, in a checkable form. This is the mandate the trail refers back to.
- One structured record per run. Tool and version, diff scope, validations with results, skips, uncertainties, approver: machine-readable, generated as a byproduct of the workflow, not typed up afterwards. How such records can be chained so a later reader can tell they were not edited afterwards is described under the run record and its digest chain.
- Stored with the code. The repository is the one place that shares the code’s lifetime and retention; trails in chat threads and ticket comments do not survive tool migrations.
- Anchored in policy. A line in your AI coding policy that says agent changes carry evidence, so the trail is a rule, not a habit that erodes under deadline pressure.
The trail records a check that is expected anyway: in the joint BSI/ANSSI report on AI coding assistants (2024, checked 4 November 2026), generated source code should generally be checked and reproduced by the developers. A per-run record makes that check visible to someone who was not there.
Where Reality Graph fits
Reality Graph produces this record for each AI coding run. It checks the run against its written task, runs the approved checks itself and writes the outcome (changes, validations, results, skips, open points) into an evidence report on your own machine. Whether that record satisfies a specific auditor or regulation is their assessment and your counsel’s: Reality Graph supplies the documentation, not the legal judgement.
A linked trail provides
- Task, change, check and decision per run
- Named owners for each artifact
- Time and version linkage
- A starting point for incident and audit questions
It does not provide
- A legal-duty checklist
- A universally accepted format
- Correctness or compliance
- Provenance for historical code without records
FAQ
- How do you prove to auditors what an AI tool did in your codebase?
- With a per-change record that answers five questions. Which tool and version acted, on what task with which boundaries, what changed, what was validated with which result, and who approved it. Git answers only the third question. To answer all five, keep one structured record per AI run next to the code, the same pattern auditors know from build provenance and change management.
- Which regulations actually demand an audit trail for AI code?
- None of the primary sources reviewed here names an 'AI code audit trail' verbatim. NIS2 Articles 20 and 21 address management oversight, supply-chain security and secure development. The Product Liability Directive counts software as a product and, as corrected on 7 May 2026, applies to products placed on the market or put into service after 8 December 2026. Mapping those duties to a per-run record is a control-design choice, not a statement that law requires this exact format.
- Isn't git history enough?
- Git records what changed and who committed. It does not record what the task was, what the tool was allowed to touch, what validation ran, what it found, or who reviewed the result. Commit messages and PR comments hold fragments of this, unstructured and inconsistently. For an auditor, that is the difference between evidence and archaeology.
- What fields does a usable audit trail entry contain?
- The working set: timestamp; tool and model version; the written task including boundaries; scope of the change (files, diff stats). Validations run and their results, including what was skipped; open uncertainties; and the human who approved. Machine-readable, one record per run, stored with the repository. Teams that keep evidence reports per run get this as a byproduct instead of a project.
- Do we have to disclose which code is AI-generated?
- AI Act Article 50 sets transparency duties for providers and deployers of certain AI systems. The provider of a system that generates synthetic text or other content must mark its output in a machine-readable way; the article does not ask a team to label ordinary commercial source code line by line. That descriptive reading is current to 4 November 2026 and is not legal advice. Contracts, sector rules or internal policy may impose separate provenance duties; the assessment stays with your counsel and the accountable control owners.
- How do we start without boiling the ocean?
- Start with one bounded change class: agent runs that modify code. Assign owners for the task, run record, validation receipt, approval and retention link. Pilot the chain on one repository, then ask your internal audit, legal and records owners whether its integrity, access and retention fit the applicable criteria.
Keep reading
Sources
- NIS2 Directive (EU) 2022/2555 – Article 20 (management bodies approve and oversee the risk-management measures) and Article 21(2)(d) and (e) (supply-chain security; security in acquisition, development and maintenance) (EUR-Lex, checked 4 November 2026)
- Directive (EU) 2024/2853, corrigendum of 7 May 2026 (OJ L 2026/90364): Article 2(1) applies to products placed on the market or put into service after 8 December 2026 (EUR-Lex, checked 4 November 2026)
- EU AI Act – Regulation (EU) 2024/1689, Article 50: transparency obligations for providers and deployers of certain AI systems; Article 50(2) unchanged by the Digital Omnibus, Regulation (EU) 2026/1744, which gives systems already on the market until 2 December 2026 (EUR-Lex, checked 4 November 2026)
- BSI/ANSSI – AI Coding Assistants, joint report (last updated September 2024): generated source code should generally be checked and reproduced by the developers (checked 4 November 2026)