> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tracelane.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Action Receipt, version 0

> An open record format for one agent action: the events, the hash chain, the signatures and the offline steps that check them. Describes what Tracelane writes today, field by field.

Version 0, Draft. Licence: Apache-2.0. The reference verifier is `packages/verifier-rust` in the open-source repository; Python and TypeScript verifiers read the ledger layer (see [Conformance](#conformance)).

An **agent action receipt** is the evidence that one agent action happened the way the record says: what was proposed, which policy decided it, who approved it, and whether it ran. Anyone can check it offline with a public key they obtained separately. This page describes the format that Tracelane's action-control export writes **today**. Where the code does something narrower than you might hope, this page says so.

> [!NOTE]
>
> Action control is a **Preview**, off until a workspace turns it on. It covers **protected** tool calls that go through the gateway. A call that never reaches the gateway is not in the record.

## What a receipt is, in v0

The smallest unit the exporter writes is an **action bundle**: one ZIP holding a workspace's ledger from its first row to a signed head. A receipt for one action is that bundle read for one `action_id`: the events that carry that id, plus the policy and contract artifacts they cite, plus everything needed to check the chain around them. v0 has no per-action slice and no inclusion-proof members; a verifier always replays the full range from row 0. A smaller form is future work and is not part of v0.

## Versioning

| Item | Value |
| - | - |
| Bundle domain string | `tracelane.action-bundle.v1` (in `manifest.json`) |
| Head domain string | `tracelane.action-head.v1`, `schema_version` 1 (the exporter writes 1; verifiers also accept 2, which adds `tree_size` and `tree_root`) |
| Envelope `schema_version` | 1, 2 or 3, fixed per event type (see [Events](#events)) |
| Row `format` | `v2.1` is the only form an action bundle accepts |

The domain strings are the wire identifiers. "Receipt v0" names this document, not a field. A verifier refuses an unknown domain, an unknown member, or an unknown field in a strict record.

## Bundle members

A bundle is a ZIP using only the STORE method, no extra fields, comments or encryption. Names may contain only `A-Z a-z 0-9 / _ . -`. Any other member is refused.

| Member | Required | Meaning |
| - | - | - |
| `manifest.json` | yes | `{"domain": "tracelane.action-bundle.v1", "files": {name: sha256-hex}}`, canonical JSON, one SHA-256 for every other member |
| `ledger.ndjson` | yes | One JSON object per line: ledger rows, then batch-signature records |
| `checkpoint.json` | yes | The signed head statement (canonical JSON) |
| `checkpoint.sig` | yes | 64 raw bytes, Ed25519 over the exact bytes of `checkpoint.json` |
| `checkpoint.cose` | no | The same statement in a COSE\_Sign1 envelope; when present it must be exactly the expected encoding and verify |
| `tree-checkpoint.note` | no | A C2SP signed-note checkpoint over all row hashes (see [Checkpoint and tree](#checkpoint-and-tree)) |
| `checkpoints.ndjson` | no | Recent signed heads, oldest first, ending at the covering head: `{"statement": <string>, "signature": <hex>}` per line |
| `checkpoint.tsr`, `timestamps/<sha256>.tsr` | no | RFC 3161 timestamp tokens, checked only against pinned TSA certificates |
| `artifacts/<sha256>.json` | per event | Original policy and tool-contract documents, named by the SHA-256 of their bytes |

The manifest is **not signed**. It detects accidental damage and lets a verifier reject a member that was swapped without resealing. An attacker can reseal it, so trust comes only from the signed head and the row chain.

## Canonical JSON

These texts must be RFC 8785 (JCS): `manifest.json`, `checkpoint.json`, each `checkpoints.ndjson` statement, the `payload` of every **action row** (the event types in the table below), and each file in `artifacts/`. They follow these narrowing rules, enforced on read:

* Object keys sort by UTF-16 code unit. No duplicate keys. Nesting depth below 128.
* Numbers are integers within +/- (2^53 - 1). A float, an exponent or an out-of-range integer is refused.
* A text must already be canonical: a verifier recomputes the canonical form and requires byte equality.

The export holds every row of the workspace ledger, not only action rows. Other rows (for example guardrail verdicts, which can carry float scores) are not JCS: they are hashed as the stored bytes and checked only by the chain. `tool_approval.*` rows are a separate record family with their own checks and report counts; this page does not define them.

## Ledger rows

Each non-anchor line of `ledger.ndjson`:

| Field | Type | Meaning |
| - | - | - |
| `format` | string | Must be `v2.1` |
| `tenant_id` | UUID string | The workspace; must equal the head's `tenant_id` |
| `seq` | integer | 0, 1, 2 ... with no gap |
| `event_time` | string | Informational. **Not covered by the row hash**; do not rely on it. The authenticated time is `occurred_at` inside the payload |
| `event_type` | string | Snake-case event name; must equal the payload's `event_type` |
| `actor` | string | The agent key id (UUID) when the envelope has one, otherwise a system label |
| `payload` | string | The row's text, hashed byte for byte. For an action row it is the envelope below, as canonical JSON; other rows keep their stored bytes |
| `rekor_entry_id` | string, optional | Written on a row that has been anchored; identifies the anchor batch. Not part of the row hash |
| `prev_hash` | hex | Row hash of the row before; for `seq` 0 the genesis hash |
| `row_hash` | hex | SHA-256 over the row preimage |

**Genesis:** `SHA-256("tracelane-audit-v2-genesis\0" || tenant_uuid_bytes)`.

**Row hash:** `SHA-256("tracelane-audit-row-v2\0" || lp(tenant_uuid_bytes) || seq_u64_be || lp(event_type) || lp(actor) || lp(payload) || lp(prev_hash))`, where `lp(x)` is the 8-byte big-endian length of `x` followed by `x`.

## Events

The `payload` of an action row is an **envelope**:

| Field | Type | Meaning |
| - | - | - |
| `schema_version` | integer | 1; 2 for a proposal that carries a `principal` and for refusals with a principal reason; 3 for a chat-channel approval decision |
| `event_id` | UUID | Unique in the bundle |
| `action_id` | UUID | Groups the events of one action. For `policy_activated` it is the policy id |
| `tenant_id` | UUID | Must equal the bundle's workspace |
| `agent_key_id` | UUID or null | The authenticated agent key; required on the proposal and repeated on decision, approval request, consume and execution events |
| `occurred_at` | RFC 3339 time | Signed time of the event; non-decreasing within an action |
| `request_digest` | hex | SHA-256 binding. Equal on every event of one action (the digest of the call); for `policy_activated` it equals the policy hash |
| `body` | object | The event, tagged by `event_type` |

`event_type` values and their body fields:

| `event_type` | Body fields |
| - | - |
| `policy_activated` | `policy_id`, `version`, `policy_hash`, `publisher_digest`, `tool_ref`, `contract_version`, `contract_hash`, `protected` |
| `action_proposed` | `tool_ref`, `contract_version`, `args_digest`, `evidence_fields`, `agent_claimed_labels`, optional `principal` |
| `decision_made` | `decision` (`allow`, `deny`, `require_approval`), `rule_id`, `reason_codes`, `policy_id`, `policy_version`, `policy_hash` |
| `approval_requested` | `approval_id`, `required_role`, `expires_at`, optional `approvals_required` (2 or more) |
| `approval_granted`, `approval_denied` | `approval_id`, `decider_digest`, `note_digest`, optional `channel`, `link_digest` |
| `approval_attempt_rejected` | `approval_id`, `decider_digest`, `reason`, optional `channel`, `link_digest` |
| `approval_consumed`, `approval_expired`, `approval_invalidated` | `approval_id` |
| `execution_started` | `execution_id`, `idempotency_key`, `attestation_key_id`, optional `receipt_expected` |
| `execution_succeeded` | `execution_id`, `receipt_digest`, optional `countersignature` |
| `execution_failed` | `execution_id`, `receipt_digest` |
| `execution_unknown` | `execution_id`, optional `receipt_digest` |
| `denied_runtime` | `reason` |
| `legacy_forward_attempted` | `server_id`, `activation_epoch` |
| `tool_receipt_key_registered` | `server_id`, `receipt_key_id`, `public_key` |

Records are strict: an unknown field is refused. Arguments are never in the record; `evidence_fields` holds only fields the tool contract marks as evidence, each stored in the clear, as an HMAC token with last four characters, or as a digest only. `reason_codes` is a closed vocabulary.

### What binds an approval to a call

* `request_digest` is the same on the proposal, the decision, the approval and the execution rows of an action; a row with another digest is refused.
* `decision_made.policy_hash` must name a `policy_activated` row in the same bundle, and the original policy document in `artifacts/` must hash to it. A verifier replays the policy over the recorded evidence and checks the recorded decision (fields marked tokenized or digest-only cannot be replayed and are reported as such).
* An approval event must refer to an approval that was requested for that action, has not expired, and is consumed at most once.
* A tool server may countersign a success: `execution_started.receipt_expected` names its key, `execution_succeeded.countersignature` carries an Ed25519 signature over a fixed statement (domain `tracelane.tool-receipt.v3`) that binds execution, tenant, action, request digest and server.

## Signatures

**Batch signature record** (a `ledger.ndjson` line with `"type": "anchor"`):

| Field | Meaning | | | | |
| - | - | - | - | - | - |
| `tenant_id`, `batch_start_seq`, `batch_end_seq` | The rows covered | | | | |
| `merkle_root` | RFC 6962 tree hash over the covered `row_hash` values | | | | |
| `anchor_state` | `unanchored` or `anchored` | | | | |
| `ed25519.signature`, `ed25519.pubkey` | base64; signature over \`"tracelane-audit-ed25519-v1\0" | | merkle\_root | | commitment\` |

`commitment` is the single byte `0x00` when unanchored. When `anchor_state` is `anchored` it is `0x01 || SHA-256(SPKI DER of the Rekor entry's ECDSA signing key) || SHA-256(log URL) || log index (u64, big-endian)`, taken from the record's Rekor entry, so the signature also binds the public log entry. Signing is per batch and happens when a workspace signing key is configured. **A receipt without batch signatures is valid, and a verifier says so**: the chain and the signed head still verify, and the report shows zero batch signatures.

**Trust.** The verifier never trusts a key found inside the bundle. You supply the workspace's Ed25519 public key (32 bytes) from another channel. An embedded key that differs from it is a trust failure.

## Checkpoint and tree

`checkpoint.json` (JCS):

| Field | Meaning |
| - | - |
| `domain` | `tracelane.action-head.v1` |
| `schema_version` | 1 or 2 |
| `tenant_id` | The workspace |
| `seq`, `head_hash` | Decimal-string sequence and hex hash of the last row; both null for an empty ledger |
| `created_at` | Time the head was signed |
| `key_id` | SHA-256 hex of the signing public key; must equal the SHA-256 of the pinned key |
| `previous_checkpoint_digest` | Digest of the previous head, or null |
| `tree_size`, `tree_root` | Schema 2 only |

`tree-checkpoint.note` follows C2SP `tlog-checkpoint` and `signed-note`: three lines (origin `tracelane.dev/action-ledger/<tenant-uuid>`, tree size, base64 root), a blank line, then one signature line by a key named like the origin. The tree is the RFC 6962 Merkle tree whose leaves are `SHA-256(0x00 || row_hash)`. A verifier recomputes it from the rows and requires equality. The note signature lines of other keys are ignored.

v0 bundles carry **no inclusion or consistency proofs**. The verifier recomputes the whole tree, so the proof is the rows themselves.

## Verification, step by step

Input: the ZIP and the workspace's pinned public key. Any failure ends verification with a failure; there is no partial pass.

1. Read the ZIP strictly (STORE only, CRC and structure re-encoded byte for byte; the CLI refuses a file over 64 MiB). Refuse an unknown member.
2. Require `manifest.json` in canonical form, its domain, and a matching SHA-256 for every other member.
3. Parse `checkpoint.json`; require canonical form, the known domain and schema, and `key_id` equal to SHA-256 of the pinned key.
4. Verify `checkpoint.sig` over the exact bytes of `checkpoint.json` under the pinned key. If `checkpoint.cose` exists, rebuild it from the statement and verify it too.
5. Walk `ledger.ndjson` from the genesis hash. For each row require `format` `v2.1`, the workspace, the next `seq`, `prev_hash` equal to the running hash, and `row_hash` equal to the recomputed hash. Require action payloads to be canonical, `event_type` to match the payload, and `actor` to equal `agent_key_id` when one is present.
6. Require the head's `seq` and `head_hash` to equal the final row (or both null if there are no rows).
7. Verify every batch signature record: recompute `merkle_root` from the covered rows, require its key to be the pinned key, and verify the signature.
8. If `tree-checkpoint.note` exists, verify it under the pinned key and recompute the tree from the rows. A signed head of schema 2 requires the note.
9. Replay the action semantics: references stay inside the range, digests and times are consistent, policy artifacts hash to their ids, recorded decisions match the replayed policy, approvals are used once and in time, countersignatures verify.
10. If `checkpoints.ndjson` exists, verify each head under the pinned key, check the links and report the longest interval; optionally report gaps longer than a maximum you set.
11. If a timestamp token exists, verify it only against TSA certificates you pinned; without a pin it is reported as unpinned, not as a pass.

The reference command is `tracelane-audit verify --file bundle.zip --pubkey tenant.pub`. Exit code 4 means the format or chain failed, 5 means something did not verify under, or match, your pinned key: the head or its COSE envelope, the tree-checkpoint note, a head in `checkpoints.ndjson`, or a batch record's embedded key (a bad batch signature under the pinned key is 4), 6 means the action semantics failed.

## What a receipt proves, and what it does not

**It proves** that the rows in the bundle are in the order written, none was changed, removed or reordered inside the range `0..=head`, and the workspace's signing key signed that head. With action semantics, it shows the recorded decision follows from the recorded policy and evidence, and each approval covered the call it was spent on.

**It does not prove:**

* **Completeness.** A hash chain shows integrity of the recorded range, not that every action was recorded. A gap in the record is indistinguishable from silence unless signed heartbeat heads show the recorder was alive.
* **Calls that bypass the gateway.** Only traffic the gateway sees is recorded.
* **Truth of what was recorded.** The gateway attests the identity and the evidence fields. The receipt shows what the gateway recorded, not that the facts were correct.
* **A good policy.** Replay shows consistency with the recorded policy, not that the policy was right.
* **Who holds a countersigning key.** A valid countersignature shows the registered key signed.
* **Time**, unless a timestamp token verifies under a TSA certificate you pinned. `event_time` is not authenticated.

**Public anchoring (Rekor).** A batch may be anchored to a public transparency log. Read all four caveats together: anchoring is **best-effort**, **partial** (not every batch is anchored), **per batch** (not per event), and a batch signed but **unanchored is still valid**. Anchoring adds public evidence that a root existed by some time; its absence does not invalidate the receipt.

## Reserved for a future external witness

These are **reserved and not implemented in v0**. A v0 verifier does not produce, require or check them, and an unknown bundle member is refused, so a bundle carrying one is not a v0 bundle.

* A bundle member for a witness cosignature over the checkpoint. The C2SP signed-note format already allows additional signature lines on `tree-checkpoint.note`; v0 ignores signature lines from keys other than the pinned one, so a witness line can be added without breaking v0 readers.
* A `witness` list in a future head `schema_version`.

Until a witness exists, the workspace key is the only signer of the head.

## Conformance

Test vectors live in `evals/action-receipt-v0/`: one valid bundle and five variants (an edited field, a removed event, a reordered pair, a corrupted batch signature, and a head signed by another key). The Rust verifier reads the whole ZIP. The Python and TypeScript verifiers read the ledger layer (`<name>.ledger.ndjson`: chain and batch signature under the pinned key), not the ZIP and not the action semantics. All three give the same PASS or FAIL for every vector in `expected.json`. The ZIPs are generated by the Rust writer helpers; the generator is the test `receipt_vectors_match_committed_and_rust_verdicts`.

## Standards this builds on

RFC 8785 (JSON canonicalization), RFC 6962 (Merkle tree hashing), C2SP signed-note and tlog-checkpoint, RFC 9052 (COSE\_Sign1), RFC 3161 (timestamps). v0 is not a SCITT Transparent Statement and is not submitted to any standards body.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.