Prove it / The decision ledger
The decision ledger
Every decision, every refusal at the door and every change to rules, keys, agents and records, in one append-only chain kept for a year. Each record carries the hash of the one before it, so an edit, a gap or a reorder shows.
What goes in
| Source | Records |
|---|---|
opa | every decision the engine makes, with the rule that made it, the input, and OPA's decision_id |
pdp | every evaluation refused at the door: no key, a wrong or revoked key, a wrong agent key |
backend | every change made in Caroline: rule saves and AI drafts applied, pack switches, keys issued and revoked, gateway bindings, directory and vocabulary edits, agent settings and approvals, ledger exports |
ledger | the ledger's own housekeeping: retention and repair |
Each admin record names the installation, the request id and the author who signed in. A rule save's git commit carries the same operation id, so the history in git and the ledger meet.
Written first
- Before a change, its intent; after it, how it ended: committed, applied, failed, or unknown. Both share one
op_id. - No record, no change. When the ledger cannot record an intent, the change is refused (
503 ledger_unavailable) and nothing changes. - Except what takes access away. Suspending an agent and revoking a key act at once and are recorded straight after, held until the ledger can take them, so an emergency never waits on a disk.
The chain
{"seq": 3213, "received": "2026-11-29T10:41:07.118Z", "source": "opa",
"event": { ... }, "prev": "3ea6cd54...", "hash": "cda65019..."}
hash is SHA-256 over prev and the canonical JSON of the other four fields. The first record's prev is 64 zeros. One file per UTC day, one writer at a time: the backend holds an exclusive lock for its whole life, so a second copy cannot fork the chain.
Verify it
caroline ledger verify
Recomputes the whole retained chain and names any problem by file and line: a line that does not parse or is not exactly as written, a gap in the sequence, a broken link, a record whose content no longer matches its hash, or a last record that is not the head Caroline holds. It runs beside ingest; decisions keep landing while it checks.
What it proves, and what it does not
An edit, deletion, insertion or reorder inside the retained files breaks verify at that line. It does not stop someone with write access to the ledger's disk from rewriting the chain from their edit onwards: recomputing SHA-256 is arithmetic, not a secret. Nor does it prove every decision arrived: during a ledger outage the engine keeps unsent decisions in a bounded in-memory buffer (128 slots, lost if it restarts), and the PDP forwards refusals on a best-effort queue whose drops are counted.
Export every day to a system the installation's operator cannot write. A later rewrite then disagrees with your copy. Anchoring the head outside the installation is not built yet.
Export
| How | Gives |
|---|---|
caroline ledger export 2026-11-29GET /api/audit/export/2026-11-29 | one UTC day, verbatim, as NDJSON: what a SIEM ingests |
caroline ledger export --allGET /api/audit/exportDecisions › Export › The whole record, with its proof | the whole retained ledger as one zip: the day files, a manifest with each file's SHA-256, and verify.py, which checks it all again offline with nothing but Python |
An export is itself recorded (ledger_exported: by whom, how many records, the head, the zip's SHA-256), so the next export shows who took this one.
Read it
Newest first, a page at a time. caroline decisions reads the decisions the same way, from the last hour, a window, one by id, or as they arrive.
Retention
365 days. On the first record of each UTC day, whole days older than that are removed, in an order that keeps the chain checkable: the last removed record's sequence and hash are written down first, a retention record goes on the chain, and only then are the files deleted. A wall clock set far ahead cannot delete the retained year: the newest day is never removed, and what is held back is counted.
Personal data
A record holds what the engine and the PDP saw, subject and resource ids included. Nothing is masked. Reading the ledger needs an author's sign-in; a viewer is refused. Keep exports where only authors can read them.
Watch it
| Metric | Alert when |
|---|---|
backend_ledger_write_failures_total | it rises: changes are being refused |
backend_ledger_events_dropped_total | it rises: an event could not be stored |
pdp_ledger_forwards_total{outcome="dropped"} | it rises: refusals did not reach the ledger |
backend_ledger_ingest_refused_total | it rises: something without the ingest token is posting |
backend_ledger_retention_held_back_total | it jumps: the clock is ahead; fix it within the day |