# Verification receipts, version 1

A receipt is a portable claim about a verification, including failures. It is not
proof that verification occurred. The first release uses self-contained links,
optional Ed25519 signatures, and self-asserted timestamps. It has no registry,
independent-person tally, automatic anchoring, or public submission endpoint.

## Commands

```sh
# BUNDLE is an agent_verifier.py bundle directory, not a solver certificate.
guldo verify BUNDLE --trusted KEYS --receipt OUT.json
# Equivalent, with optional receipt signing and additional audit policy:
guldo agent-receipt make BUNDLE --trusted KEYS --out OUT.json \
  --party-keys PARTY_KEYS --verifier-party verifier --require-registry \
  --require-joint --sign-key RECEIPT_SIGNING_KEY
# Offline integrity/signature checking (does not re-run):
guldo agent-receipt verify OUT.json
# Offline Python replay using the recorded public trust keys and options:
guldo agent-receipt verify OUT.json --bundle BUNDLE
# Self-contained URL, optionally also a local static badge:
guldo agent-receipt link OUT.json --badge receipt.svg
guldo agent-receipt show OUT.json
```

The source equivalent is `python3 agent_verification_receipt.py COMMAND ...`.
`make` writes failure/incomplete receipts before exiting nonzero. Exit status is
0 for pass/narrow-pass, 1 for fail, 2 for incomplete or invalid input. `verify`
without `--bundle` returns 0 for an intact receipt even if its claimed outcome is
fail; integrity and a successful audit are different questions. Replay returns
0 reproduced, 1 differs, 2 cannot reproduce/invalid. Existing output files are
not overwritten; write receipts outside the original bundle.

`guldo verify --receipt` dispatches to the agent-bundle audit. Legacy solver
certificate verification, remote `--round/--id`, solver execution, and its
machine-local submission receipts are separate and do not gain this format.

The Python receipt profile calls `agent_verifier.audit`, including instance and
session replay and certificate regeneration. It records verifier, party and log
pins; registry/joint/log requirements; and the verifier party. The log witness
minimum equals the number of pinned witnesses. Hardware PCR/source flags are
not wired into this first receipt profile; that omission is explicit. Thus a
successful Python receipt from this profile is also narrow-pass. The format
supports full pass only when no checks are skipped and no omissions declared.
The browser always has narrower coverage, including no Python task replay.

Replay requires the original verifier version and source fingerprint. Python
receipts replay in Python; browser receipts replay on the receipt page. A source
mismatch reports **cannot reproduce**, not a fabricated agreement. Identical
inputs do not guarantee that arbitrary environmental faults, external tools or
existing nondeterminism in the underlying verifier cannot affect a run. Such
differences must remain visible; a receipt adds no determinism to the audit.

## Exact schema

The JSON object has exactly these fields; unknown fields are rejected:

- `format`: `guldo-verification-receipt-v1`.
- `subject`: `manifest_sha256` (SHA-256 of exact BUNDLE.json bytes, or null if
  absent), `round_id`, `domain`, `certificate_path`, and
  `certificate_statement_sha256` (or null if unreadable). The certificate is
  the first filename in sorted order in `certificates/`; the manifest binds
  every other certificate. Missing textual identifiers are empty strings.
- `verifier`: `name`, `version` (string), `implementation` (`python` or `browser`),
  `source_hashes` (1–16 name-to-SHA-256 entries). Names are claims. Only a valid
  receipt signature authenticates a signing key, never a human identity.
- `inputs`: `trusted`, `party_keys`, `log_witnesses` (sorted unique public-key
  arrays); `verifier_party` (string); `log_key` (key or null);
  `require_registry`, `require_joint`, `require_log`, `complete` (booleans);
  `key_source` (`you`, `site`, `link`, or `none`). Keys in a receipt are the
  author's choices, not automatically trusted by its reader. `complete` records
  whether the original browser input enumerated a local directory or fetched
  only manifest-listed files.
- `checks`: 1–512 objects with exactly `name`, `state`, `detail`. States are
  `pass`, `fail`, `info`, `skip`; details are strings. Array order is significant.
- `outcome`: derived by the rule below.
- `not_checked`: up to 512 strings, shown prominently alongside the outcome.
- `claimed_at`: UTC `YYYY-MM-DDTHH:MM:SSZ`, a valid calendar date, self-asserted.
- `claim_limit`: exactly:

> This receipt records claimed checks, not proof that they ran or that a model produced the results; keys do not establish a person's identity or independence, and claimed_at is self-asserted.

- `signer`: null for unsigned receipts, otherwise a lowercase 32-byte Ed25519
  public key in hex. This is inside the hashed and signed body.
- `receipt_id`: lowercase SHA-256 hex of the canonical body.
- `signature`: present if and only if `signer` is non-null; exactly
  `public_key` (equal to signer) and `value` (64-byte Ed25519 signature in hex).

The **body** is the entire receipt except `receipt_id` and `signature`.
Signatures cover the exact canonical body bytes, using `agent_sig`'s Ed25519
primitives. Including `signer` in the body means stripping a signature fails
schema validation; changing signer to null changes the ID. An attacker can
always create a *new unsigned receipt with a new ID*. Readers must compare the
expected ID or pin an independently obtained signing key. An unkeyed hash alone
never establishes authenticity or that a claimed audit actually occurred.

Outcome derivation, in order:

1. Any failed check gives **fail**, even if other checks could not finish.
2. No passed checks, or a check named `audit incomplete`, gives **incomplete**.
3. Browser implementation, any skipped check, or nonempty `not_checked` gives
   **narrow-pass**.
4. Otherwise the outcome is **pass** (full declared coverage).

A successful receipt also requires a non-null manifest hash. Rehashing a body
with a contradictory outcome does not make it valid. Schema validation cannot
prove a claimed checklist is complete: replay is how readers check that claim.

## Canonical bytes and bounds

Receipt values are objects with fixed ASCII keys, arrays, strings, booleans, or
null; there are **no numbers**. This avoids floating-point serialization drift.
Canonicalization is Python `json.dumps(sort_keys=True, separators=(',', ':'),
ensure_ascii=True, allow_nan=False)` and browser `GuldoVerify.canon`. Strings
escape non-ASCII and DEL with lowercase `\u` escapes, supplementary characters
with surrogate pairs, and the JSON short control escapes normally. Unicode
normalization is not applied. Unpaired surrogates and duplicate keys are rejected.
Object keys sort by Unicode code point. Source hash map names are strings.

Certificate statement fingerprints use the existing verifier's lexical-number
canonical JSON: whitespace is removed, object keys sort by code point, strings
use the same escaping, and JSON number tokens retain their original spelling.
This is separate from the number-free receipt body and avoids JS precision loss.

Input and canonical JSON each have a 128 KiB cap. Names/details/options are
bounded by the implementations (string lengths measured in UTF-16 units);
check names 1024, details/omissions 4096, subject strings 512, verifier name 128,
version 64, and public-key lists 64. Canonical vectors in
`verification_receipt_vectors.json` are shared by Python and Node tests.

The Python source fingerprint hashes a canonical map of the package's top-level
runtime `.py` files and shipped `agent_domains/*.py`. It excludes test/dev-only
and held-back files using the package rules. It is an implementation fingerprint,
not proof of the interpreter, OS, or dependencies. Browser fingerprints name
`guldo_verify.js` and `verification_receipt.js` served with the page. Claimed
source hashes alone do not establish what code actually executed.

## Links, badges and privacy

Links are `https://guldo.org/receipt.html#r1=TOKEN`, where TOKEN is unpadded
base64url of zlib-wrapped DEFLATE of canonical receipt JSON. Receivers cap both
compressed input and decompressed output. The fragment is not in the HTTP
request; recipients do receive all receipt text and public trust keys. Links may
be too long for a chat service; the JSON download is the fallback. No bundle or
secret key is embedded. The browser never uploads the bundle.

The receipt page uses `textContent` for untrusted data, no remote receipt fetch,
no analytics, and a restrictive CSP. It does not automatically fetch a subject
URL or execute bundle code. Browser replay uses only the existing browser
verifier. A Python audit can use local trusted domain implementations; inspect
untrusted bundles and the existing audit's scope before running it.

A badge is a static, self-contained SVG with `full` or `narrow`, the outcome and
complete receipt ID. It has no external resources or script. Copy badge produces
an HTML link wrapping the inline SVG; Download badge/`--badge` produces the SVG
alone, with `link` printing its destination. A badge is a claimed label; readers
must open its receipt and check it. Failures use the same actions as passes.

## Release and review status

The receipt implementation and adversarial tests are written for review. Do not
interpret this document as a claim that tests, browser layout review, preview,
production deployment or live checks have passed. The handoff requires a review
gate before test execution; follow that gate and record actual results separately.
Registry, `/v/<id>` pages, independent receipt counts, reproduced-result
attestations, browser receipt signing, automatic anchoring, TEE receipt-profile
flags, and cross-implementation audit replay are not wired in this release.
