The audit trail
Optional: hand this page to your coding agentThe steps work by hand too.Show the whole prompt
Read https://intentius.io/terragucci/reference/audit-trail/.
Download audit.jsonl from the top of my reports prefix with a read-only identity, run the queries
under "Query the record", and tell me, per project, every approval with its approver, plan digest
and time, every policy override with its reason, every refused wave and every failed apply in the
last 30 days, each with its evidence link.
Read only: do not run `terragucci audit` without `--check`, and write nothing to the bucket.
Never apply, approve (a pull request review or `terragucci approve`), override a policy denial (`terragucci override`), use `--mode apply`, or merge; never touch `.chant/allowed_signers` or `chant/lifecycle`.terragucci audit writes the record as JSON lines in your reports bucket. It reads the approval ledger on chant/lifecycle in each repo, the wave reports in the bucket, and the list of versions each root’s state bucket keeps; no terragucci server or account holds a copy.
Write it
Section titled “Write it”-
Run it where the estate page job runs, before
terragucci estate:Terminal window npx --yes @intentius/terragucci auditnpx --yes @intentius/terragucci estateRun from Projects Ledger read from Reports read from Record written to a control repo its projects:each project’s repo: its url, elsehttps://<key>, with the forge token when the job has oneeach project’s reportsdefaults.reportsone repo the checkout’s own originthe repo’s reportsthe same bucket -
Give the job what it reads. On top of the estate job’s identity:
Reads Why chant/lifecycleof each project, with its historyevery approval, override and revocation <prefix>/<project>/**/tf-apply-wave-*/report.jsonevery apply and its result, every refused wave <prefix>/audit.jsonl, and writes it,audit.htmlandaudit.jsonthe record, its page and its summary <prefix>/<project>/states.jsonthe state versions each root’s waves recorded the list of versions of each root’s state object: s3:ListBucketVersionson an S3 state bucket,storage.objects.liston a GCS one, list on an Azure containerunrecorded writes; the list holds ids and times, and no state is read with audit_log_group,logs:FilterLogEventson that groupthe writer of an unrecorded version The forge token is the project’s
token_env, elseGITHUB_TOKEN,GITLAB_TOKENorFORGEJO_TOKEN, with read access to the repo. The state buckets are listed with the job’s own credentials, the variables Reports names. -
Read the log:
audit: 214 entries, 3 added2026-10-08T09:12:44.000Z github.com/acme/network approval wave-2 by dana sha256:4be1...: unsigned2026-10-08T09:20:03.000Z github.com/acme/network apply wave-2 by dana sha256:4be1...: applied2026-10-08T10:01:17.000Z gitlab.example.com/platform/data refused wave-1 by lee sha256:9c07...: changed-after-approvalwrote terragucci-audit/audit.jsonl, terragucci-audit/audit.html, terragucci-audit/audit.jsoncopied to s3://acme-terragucci/reports/audit.jsonl, reports/audit.html, reports/audit.jsonlink, until 2026-10-09T10:05:00.000Z:https://acme-terragucci.s3.us-east-1.amazonaws.com/reports/audit.html?X-Amz-Algorithm=AWS4-HMAC-SHA256&...A project whose ledger, index or
states.jsoncannot be read makes the job exit 1 and is named on the page. The entries it could read still land. A root whose state’s versions cannot be listed is named in the log and on the page, and leaves the exit code alone.
The estate page links audit.html once audit.json is beside it, and its resource history names each apply’s approver from the record. Flags are on CLI commands.
Storage
Section titled “Storage”| Object | What it is |
|---|---|
<prefix>/audit.jsonl |
the record: one entry per line, oldest first within each run’s additions |
<prefix>/audit.html |
the page: counts by kind, each project’s ledger state, the newest 1000 entries with their evidence links |
<prefix>/audit.json |
the summary, terragucci.audit-summary/v1: how many entries, how many the last run added, counts by kind, and each project’s ledger state and states (the roots whose versions were checked, skipped with why, or not listed with the error, and how many versions were too new to judge) |
Entry fields
Section titled “Entry fields”Every line is terragucci.audit/v1 (JSON Schema in the package as dist/audit.schema.json), and holds these fields in this order:
| Field | What it holds |
|---|---|
schema |
terragucci.audit/v1; a new field never changes an existing one |
id |
sha256: over where the entry came from: the ledger line, the report’s path and finish time, or the state’s location and version id |
kind |
what happened; see the next table |
project |
<host>/<path> of the repo |
at |
when: the ledger line’s timestamp, the commit that removed a line, the run’s finish, or when the store says a version was written |
who |
the approver, the overrider, whoever removed the line, for an apply the approver it applied under, or for an unrecorded write the writer the bucket’s log names; null when nobody did or no log names one |
what |
the gate: wave-<k>, a migration’s name, or for an override, a lock’s release or an unrecorded write the root |
digest |
the plan digest: the wave’s set digest, or the digest an override binds; null when a root failed to plan |
result |
the outcome; see the next table |
evidence |
source (ledger, report or state); for the ledger branch, path and commit; for a report bucket, key and job_url; for a state its location and version_id; url, the commit’s page or the run’s report.html, when it is known; deleted: true on a report entry whose report was deleted, which has no url and which the page lists without a link |
detail |
what else the source says, by kind |
Kinds and results
Section titled “Kinds and results”kind |
From | result |
detail |
|---|---|---|---|
approval-requested |
a pending line in _gates/tf-apply.jsonl, _gates/tf-migrate.jsonl for a migration, _gates/tf-unlock.jsonl for a state lock’s release, _gates/tf-state-export.jsonl for a state export, or _gates/tf-ephemeral.jsonl for a pull request’s ephemeral copy planned by terragucci 0.4.42 or earlier |
waiting |
expires, run_id, description, roots, excluded |
approval |
an approval line in _gates/tf-apply.jsonl, _gates/tf-migrate.jsonl, _gates/tf-unlock.jsonl, _gates/tf-state-export.jsonl, _gates/pr-<n>.jsonl (an ephemeral copy’s gate pr-env) or _gates/tf-ephemeral.jsonl |
unsigned, sealed or review |
signer (sealed), via, pr, head, reviewers (review), relayed_by, committed_by, excluded |
approval-revoked |
an approval line a commit removed | revoked |
approved_by, approved_at, signer (sealed) |
override-requested |
a denial a wave recorded in _gates/policy-override.jsonl |
denied |
expires, run_id, description, rules, plan_digest |
override |
an override line in _gates/policy-override.jsonl |
unsigned or sealed |
reason, rules, plan_digest, signer, relayed_by, committed_by |
override-revoked |
an override line a commit removed | revoked |
approved_by, approved_at, signer (sealed) |
apply |
a tf-apply wave report |
applied, failed or waiting |
wave, commit, roots, gate, approval (the id of the approval entry it applied under), approvals and approvers (under approval_rules, the id of each approval entry the rules counted and every approver they counted), policy (the outcome, held or unattended, the rules and the commit, when the policy’s hold and allow_unattended rules decided the gate), excluded, changes, failed, overrides, pull_request, actor, state_versions (each root’s state location, version_id and versioning) |
migration |
a line in _gates/tf-migrate/done.jsonl, written when a state migration wrote its states |
applied or failed |
roots (each root’s location and state version before and after, and both digests), file_digest, error, commit, run_id |
unlock |
a line in _gates/tf-unlock/done.jsonl, or with a chant that has gated requests a finished line in _gates/tf-unlock/applied.jsonl, written when terragucci unlock-state released a state lock; who is who released it and what the root |
released |
location, lock_id, operation, locked_by, locked_at (the lock as the binary wrote it), approved_by, approved_at, commit |
state-export |
a line in _gates/tf-state-export/done.jsonl, or with a chant that has gated requests a finished line in _gates/tf-state-export/applied.jsonl, written by terragucci state export before it writes the file; who is the person who exported, what the root |
exported |
location, version_id, approved_by, approved_at, content_digest (the digest of the bytes written, never the bytes) |
ephemeral-apply |
an up line in _pr-envs/records.jsonl, written when a pull request’s ephemeral copy applied; who is the forge’s actor for the job, what the environment pr-<n>, digest the copy’s plans. Copies applied by terragucci 0.4.42 or earlier come from _gates/tf-ephemeral/done.jsonl |
applied or failed |
pull_request, suffix, roots (each root’s state location), expires, approved_by, commit, run_url |
ephemeral-destroy |
a down line in _pr-envs/records.jsonl, written when a copy was destroyed, or a line in _gates/tf-ephemeral/done.jsonl from 0.4.42 or earlier |
destroyed, or incomplete when a root was left (failed in the older file) |
pull_request, suffix, reason (closed or expired), destroyed and failed (how many roots), commit (the code the destroy ran), run_url |
agent-run |
a line in _gates/agent-runs.jsonl, or with a chant that has the agent job a run record in local/runs__terragucci-agent.jsonl (-drift-agent, -review, -refused-wave), written when an agent.comment or agent.drift push job, a review.agent note or a refused-wave summary finished (Agent runs); who is the agent’s forge identity, what the feature, digest the prompt’s |
pushed, opened, posted, summarized, refused, stopped (the money limit) or failed |
actor (kind, principal and signals), model, cost (usd, input_tokens, output_tokens), commit, pull_request, requested_by, reason, run_url |
request |
a line in _gates/template-requests.jsonl, written when terragucci request opened a pull request adding an app’s root or an add-on to an app; who is the run’s actor, what the app, digest null |
opened |
template, version, app, addon (for an add-on), claimed_by (who the client said asked, which the forge does not vouch for), via (form, mcp or cli), branch, pull_request, url |
unrecorded-write |
a version a root’s state store lists that no wave or migration recorded (Unrecorded writes); what is the root, at when the store says it was written, digest null |
unrecorded |
location, recorded_version (the newest version terragucci recorded before it, or null), current_version (the version written), current_written_at, latest (whether the store serves it now), deleted (an S3 delete marker), who_source (how who was found, or why it is null) |
refused |
a tf-apply wave report’s waves[].refused |
changed-after-approval, changed-after-review, changed-after-override, denied-by-policy, held-by-another-apply or superseded-by-a-newer-push |
wave, commit, roots, pull_request, approved (the digest approved), moved or denied (the roots), rules (by root, for a denial), hard_mandatory (the denying rules no override can pass), actor, holder (the run applying them, for held-by-another-apply) |
result on an approval says how it was signed. Whether it counted is the wave’s decision under the approval: mode at base, and the apply or refused entry of that wave records it.
| The entry says | What it proves, by mode |
|---|---|
who on an approval |
ledger: the name the approver gave; anyone who can push to chant/lifecycle can write any name, and detail.committed_by is the commit’s author |
detail.signer |
sealed: the seal’s signer; the wave checks it against .chant/allowed_signers at base |
detail.via, pr, reviewers |
pr-review: the apply job recorded a review of that head by a writer who had no hand in the change |
detail.excluded |
each person whose approval the wave left out because they had a hand in the change, with the login and the reason, such as bob asked for abc1234 (Eligible approvers). On an approval-requested entry, the people whose approvals made the wave record a new pending fact; on an apply entry, those its wave left out. An apply entry never names an approval by someone it left out |
detail.relayed_by |
the line’s relayedBy: a service, such as a chat bot, wrote it for the person who names. ledger and pr-review: the relayer’s word that who approved; the line counts like any other, and committed_by is the account that pushed it. sealed: the seal still decides; the line counts only when its seal verifies for who, and the seal covers the relayer’s name |
Completeness
Section titled “Completeness”| Property | How |
|---|---|
| Append-only | each run reads audit.jsonl, keeps every line, and appends the entries whose id it lacks; the write is conditional on the copy read, so two runs at once both land |
| Re-derivable | the ledger is read from its git history every run, and the same records give the same ids; a new record built from the same sources holds the same entries |
| Checked | terragucci audit --check builds the entries again, writes nothing, and exits 1 naming each one the record lacks, such as an approval on the ledger after the last run |
| Revocations kept | removing a line from the ledger revokes it before its wave runs; the record keeps the approval and adds an approval-revoked entry with the commit that removed it |
| Writes outside terragucci | each run lists the versions of every root’s state and adds an unrecorded-write entry for each one no wave or migration recorded, one per version, so a later wave that records a newer version leaves the earlier write in the record (Unrecorded writes) |
| Replaced reports | a second run of the same wave on the same commit replaces its report in the bucket; the record keeps the entry of the first run when an audit ran between them, so schedule the audit at least as often as waves run |
Query the record
Section titled “Query the record”jq -r 'select(.kind == "approval") | [.at, .project, .what, .digest, .who, .result] | @tsv' audit.jsonljq -r 'select(.kind == "override") | [.at, .project, .what, .who, (.detail.rules | join(",")), .detail.reason] | @tsv' audit.jsonljq -r 'select(.kind == "refused" or .result == "failed") | [.at, .project, .what, .result, .evidence.url // .evidence.key] | @tsv' audit.jsonljq -c 'select(.project == "github.com/acme/network" and .what == "wave-2") | {at, kind, who, digest, result}' audit.jsonljq -r 'select(.kind == "unrecorded-write") | [.at, .project, .what, .detail.current_version, (.who // "unknown"), .detail.who_source] | @tsv' audit.jsonljq -r 'select(.kind == "apply" and .result == "applied" and .detail.gate == "approved" and .detail.approval == null) | [.at, .project, .what, .digest] | @tsv' audit.jsonlFetch the record with the store’s own CLI, such as aws s3 cp s3://acme-terragucci/reports/audit.jsonl ., or open the link the job prints for the page.
The records it reads
Section titled “The records it reads”| Record | Where | What it says | Written by |
|---|---|---|---|
| A wave asking for approval | _gates/tf-apply.jsonl on chant/lifecycle, a "kind":"pending" line |
the wave, the plan digest it asks for, when, and when the request expires | the apply job, when the wave waits |
| An approval | _gates/tf-apply.jsonl, any other line, in a commit of its own |
the wave, the plan digest it binds, who (resolvedBy) and when (timestamp) |
terragucci approve; under approval: pr-review, the apply job |
| A policy override | _gates/policy-override.jsonl |
the root, its plan digest, the rules it overrides, who, when and the reason | terragucci override |
| A run’s report | the bucket, under one path per commit and stage | every root’s plan digest and changes, each wave’s set digest, approval state and, when it applied nothing, why (waves[].refused) |
every tf-plan, tf-apply wave and tf-drift run |
| The index | index.json at the project’s path |
one row per run; terragucci audit reads its tf-apply rows to find the reports |
|
| The state versions | states.json at the project’s path |
each root’s state location and the versions its waves recorded, with when each wave started and finished | every tf-apply wave’s upload |
| A migration’s writes | _gates/tf-migrate/done.jsonl on chant/lifecycle |
each root’s state version before and after the migration wrote it | the apply job, when a state migration writes |
| A state’s versions | the state’s own bucket or container, through its list of versions | each version’s id, when it was written, and whether it is current | your backend, and anything else that writes the state |
A wave’s report names its approval record’s branch and path (waves[].gate) and never copies it. Report JSON schema has every field. Without a bucket, each report is a CI artifact of its job and terragucci audit has nothing to read; Keep reports in a bucket sets one up.
Unrecorded writes
Section titled “Unrecorded writes”Each tf-apply wave records the version of each root’s state it left, and each state migration the version after its write. An apply from a laptop, or anything else holding the state bucket’s credentials, writes a version neither recorded. It shows up in a plan only when the result differs from the code; terragucci audit finds it from the versions the bucket keeps.
For each root in a project’s states.json or its migrations, the run lists the versions of the state where it is now: the location the newest wave recorded, or the one a newer migration moved it to. It reads ids and times from the store’s list call and never the state. A version gets an unrecorded-write entry when it is:
| Test | Why |
|---|---|
| newer than the oldest version terragucci recorded for the root that the store still lists | versions from before terragucci recorded the root are not judged |
neither a version a wave recorded in states.json nor one a migration recorded after its write |
those are terragucci’s own |
| not written while a wave that recorded the root was running, from its report’s start to its finish | the binary can write the state more than once during an apply, and the wave records the version it left |
| written more than 6 hours before the run | a wave still applying has that long to upload its report; the run counts a younger version in audit.json and judges it on a later run |
A root is skipped, and counted with why in audit.json, when its backend keeps no versions (versioning: off), terragucci does not read them (unknown), the state is not in s3://, gs:// or az://, or the store lists no versions of it, such as an Azure container with blob versioning off.
The estate page lists each root’s unrecorded writes among its state versions, marked written outside a wave or migration, with the writer when one is named. terragucci notify unrecorded, run after terragucci audit, posts the ones the run added to Slack and Teams.
The writer
Section titled “The writer”who names a writer only from a log of the bucket’s object writes:
| State | who |
|---|---|
S3, with audit_log_group set |
the principal of the write in that CloudWatch Logs group whose x-amz-version-id is the version’s, read through the aws CLI in audit_region as drift attribution reads CloudTrail; the group is where a CloudTrail trail delivers the state buckets’ S3 data events |
| S3, without it | null: CloudTrail’s event history, which drift attribution reads, keeps no S3 object writes |
| GCS or Azure | null: terragucci reads no log of their object writes |
detail.who_source says which write named the writer, or why who is null, such as the aws CLI missing from the job’s image or no write in the group naming the version.
Matching an apply to its approval
Section titled “Matching an apply to its approval”| Step | Read | Match |
|---|---|---|
| 1 | the apply entry: digest, detail.commit |
the digest the wave applied, and the commit it applied from |
| 2 | detail.approval |
the id of the approval entry whose what and digest it applied under |
| 3 | that entry’s evidence.commit |
the commit on chant/lifecycle that added the approval line |
A wave whose plans moved after approval applied nothing and exited 4: its entry is refused, with the digest approved and the roots that moved (Fix a refused wave).
Retention
Section titled “Retention”| Record | Kept |
|---|---|
| The audit record | your bucket’s lifecycle rule; leave audit.jsonl out of any expiry |
| The ledger | as long as the chant/lifecycle branch; every change is a commit. Protect it against force pushes and deletion (per forge) |
| Reports and the index in a bucket | your bucket’s lifecycle rule; an index keeps its newest 500 rows and the newest of each stage and wave |
| Traces and metrics | your telemetry backend’s retention (Traces and metrics) |
terragucciHelp setting it up: Intentius
These docs count page views and clicks with PostHog. They set no cookies, store nothing in your browser, and send nothing when your browser asks not to be tracked.