aien-receipts
Append-only AIEN verification receipts, indexed by repository and exact source commit. Read verdicts, signatures and retained logs before making a claim.
Brought by drakestapleton
aien-receipts / docs / receipt-index.md
| 1 | # Receipt index and replay |
| 2 | |
| 3 | Linear DRA-167. Status: proposed on branch `feat/dra-167-receipt-index` as a draft pull request. |
| 4 | It changes the layout of this repository, so under `AGENTS.md` ("Safety and approvals") it needs |
| 5 | explicit maintainer approval and a change to the ADR 0033 doctrine in `aien-architecture`. |
| 6 | Drake Stapleton has delegated merge judgment to Queen, the Completion Hive coordinator (DRA-162, |
| 7 | 59767dce); Queen's approval of this pull request is the maintainer approval. The ADR 0033 |
| 8 | amendment is drafted [below](#adr-0033-amendment-draft) and lands in `aien-architecture` |
| 9 | before this pull request merges. Neither has happened yet. |
| 10 | |
| 11 | `index/receipt_index.json` lists receipts that may be cited as evidence. For each one it pins |
| 12 | where the bytes live, what they hash to, which correction applies and what verdict follows. |
| 13 | `tools/replay_receipt.py` rebuilds every entry from the pinned commits, checks the shelf HEAD |
| 14 | for a later correction, and refuses an entry whose recomputed fields differ from the file or |
| 15 | that carries a field the tool does not check. |
| 16 | |
| 17 | ## What an entry records |
| 18 | |
| 19 | | Field | Meaning | |
| 20 | |---|---| |
| 21 | | `id` | Entry name (no `:`). | |
| 22 | | `issue_or_gate` | The issue or gate the receipt evidences: `value`, `basis` and `verified`. Derived from the receipt where it names one: for signed bundles the repository and the gate of every required check, for Omega receipts `milestone` and `contract_id`. A receipt that names neither carries operator text with `verified: false`, and replay prints it as UNVERIFIED. | |
| 23 | | `kind` | `signed-bundle` (this shelf) or `omega-qualification-receipt` (`aien-dev/omega-evidence`). | |
| 24 | | `shelf` | Repository, commit, path, SHA-256 and byte length of the receipt bytes at that commit. | |
| 25 | | `source` | The verified repository and commit. For Omega receipts also: the field that named the commit, whether it resolves upstream, and the result for every artifact digest (`match`, `mismatch`, `absent`, `commit-unresolved`, `not-recoverable (build output)`). | |
| 26 | | `trust_anchor` | Signed bundles: the first parent of the source commit, with its `.aien/verify.pub` and `.aien/always`. | |
| 27 | | `correction` | The adjacent `<basename>.correction.json` at the shelf commit, which must be byte-identical at the shelf HEAD: path, SHA-256, id, `supersedes_historical_status_for_admission`, `qualification_claim`. `null` when none exists at either. | |
| 28 | | `historical_verdict`, `effective_verdict`, `effective_basis` | The status the receipt states, the verdict after the admission check, and which rule decided it. | |
| 29 | | `replay` | The command that replays the entry: exactly `python3 tools/replay_receipt.py replay <id>`. | |
| 30 | |
| 31 | Any other field, in an entry or at the top level of the index, is REJECTED (`UNKNOWN_FIELD`): |
| 32 | a claim the tool does not check cannot sit in the index. The descriptive top-level fields |
| 33 | (`issue`, `generated_by`, `independence`, `admission_check`, `precedence`, `exit_codes`, `scope`, |
| 34 | `excluded`, `generated_utc`) are known but not recomputed; see "Values taken on trust". |
| 35 | |
| 36 | ## The admission check |
| 37 | |
| 38 | Applied in this order. The first rule that decides wins. |
| 39 | |
| 40 | 1. **Bytes.** The file at `shelf.repository@shelf.commit:shelf.path` must hash to `shelf.sha256`. |
| 41 | Otherwise the entry is REJECTED (`DIGEST_MISMATCH`). |
| 42 | 2. **Correction.** The adjacent `<basename>.correction.json` must be byte-identical at the shelf |
| 43 | commit and at the current HEAD of the shelf repository; a correction added or changed after |
| 44 | the indexed commit is REJECTED (`STALE_CORRECTION`) until the entry is re-admitted at the |
| 45 | HEAD. If the correction exists, its `corrects` member must name this repository, path and |
| 46 | SHA-256. Otherwise REJECTED (`CORRECTION_UNBOUND`). When it sets |
| 47 | `supersedes_historical_status_for_admission`, its `qualification_claim` is the effective |
| 48 | verdict. The receipt bytes are never changed. Signed bundles have no correction rule yet, so |
| 49 | a `bundle.correction.json` is REJECTED (`CORRECTION_UNSUPPORTED`) rather than ignored. Each |
| 50 | kind lives on one shelf (`signed-bundle` in this repository, `omega-qualification-receipt` |
| 51 | in `aien-dev/omega-evidence`); any other shelf is REJECTED (`SHELF_REPOSITORY`). |
| 52 | 3. **Signed bundles.** The key must equal `.aien/verify.pub` from the first parent of the source |
| 53 | commit, never a key found only in the bundle. The Ed25519 signature must verify over the |
| 54 | canonical bytes without `signature`. The repository and commit must match the shelf path, |
| 55 | `executor.id` must be the SHA-256 of the key, every gate in `.aien/always` must be present and |
| 56 | required, and the declared verdict must equal the computed one (FAIL if any required check |
| 57 | failed; PASS if every required check ran or was cached with PASS; NOT_RUN otherwise). Any |
| 58 | failure is REJECTED with the `aien-test` reason code. Otherwise the bundle verdict stands. |
| 59 | 4. **Omega receipts without a superseding correction.** The named implementation commit |
| 60 | (`qualified_implementation_commit`, else `git_commit`) must exist in the source repository, |
| 61 | and every recoverable source artifact must hash to its recorded digest at that commit. |
| 62 | Otherwise the effective verdict is `REFUSED_SOURCE_PROVENANCE`. `build/` outputs cannot be |
| 63 | recovered and are not counted. The `receipt_commit` field is recorded but does not decide. |
| 64 | 5. **Index drift.** Every field except `id` and `replay` is recomputed, `issue_or_gate` |
| 65 | included, and `replay` must be the exact command for the `id`. Any difference from the |
| 66 | index is REJECTED (`INDEX_DRIFT`); an unknown field is REJECTED (`UNKNOWN_FIELD`). An index |
| 67 | whose entry was edited to claim, say, "hardware qualified on GB10" fails here. |
| 68 | |
| 69 | The shelf HEAD is printed on every replay but not stored, so a new publish on the shelf does not |
| 70 | change the index unless it touches a correction. |
| 71 | |
| 72 | A historical `QUALIFIED / PASS` is therefore never admitted on its own text. |
| 73 | |
| 74 | ## Replaying |
| 75 | |
| 76 | Needs network access to GitHub, Python 3, Git and OpenSSL 3. Each run uses a fresh temporary Git |
| 77 | cache unless `--cache DIR` is given. |
| 78 | |
| 79 | ```bash |
| 80 | python3 tools/replay_receipt.py replay spark-rsi@f72209e6 # one entry |
| 81 | python3 tools/replay_receipt.py replay --all # the whole index |
| 82 | python3 tools/replay_receipt.py replay spark-rsi@f72209e6 --bytes /tmp/copy.json # control |
| 83 | ``` |
| 84 | |
| 85 | The last line is the result, for example `REPLAY omega-evidence/M8: REFUSED_UNSUPPORTED_PROVENANCE rc=4`. |
| 86 | |
| 87 | | Exit | Meaning | |
| 88 | |---|---| |
| 89 | | 0 | PASS | |
| 90 | | 1 | FAIL: an authenticated FAIL verdict | |
| 91 | | 2 | NOT_RUN: an input could not be reached, or a usage error | |
| 92 | | 3 | REJECTED: bytes, signature, binding, correction binding, stale correction, unknown field or index drift | |
| 93 | | 4 | REFUSED: by a shelf correction or by the source-provenance check | |
| 94 | |
| 95 | `replay --all` exits 0 only when every entry reproduces exactly as indexed, whatever its verdict. |
| 96 | Never treat a nonzero exit of a single replay as a pass. |
| 97 | |
| 98 | Keep negative controls outside this checkout. `--bytes` replays a local copy instead of the |
| 99 | fetched file, so a byte-corrupted copy must end in `REJECTED DIGEST_MISMATCH` with exit 3. |
| 100 | |
| 101 | The offline tests build disposable repositories and serve them over `file://`: |
| 102 | |
| 103 | ```bash |
| 104 | python3 -m unittest discover -s tests -v |
| 105 | ``` |
| 106 | |
| 107 | ## Admitting a new receipt |
| 108 | |
| 109 | Every later receipt goes through the same check. `admit` computes the entry from pinned commits |
| 110 | and prints it; it exits 3 instead when rule 1, 2 or 3 rejects the receipt. Admit at the shelf |
| 111 | HEAD: an older commit fails rule 2 whenever a correction has landed since. |
| 112 | |
| 113 | ```bash |
| 114 | python3 tools/replay_receipt.py admit --kind signed-bundle \ |
| 115 | --shelf aien-dev/aien-receipts@<shelf-commit>:<repo>/<sha>/bundle.json --id <repo>@<short-sha> |
| 116 | python3 tools/replay_receipt.py admit --kind omega-qualification-receipt \ |
| 117 | --shelf aien-dev/omega-evidence@<shelf-commit>:<receipt>.json --source-repo aien-dev/omega-mv \ |
| 118 | --id omega-evidence/<milestone> |
| 119 | ``` |
| 120 | |
| 121 | `--issue-or-gate "<text>"` is accepted only for a receipt that names no issue or gate; the text |
| 122 | is recorded with `verified: false`. For a receipt that names one, the option is a usage error |
| 123 | (exit 2). |
| 124 | |
| 125 | Append the printed object to `entries`, increase `index_version` when the schema changes, and run |
| 126 | `replay --all`. Never write an entry by hand: a hand-typed digest, verdict or issue fails rule 5. |
| 127 | |
| 128 | ## Values taken on trust |
| 129 | |
| 130 | The tool cannot recompute these from the pinned bytes. A reader relies on them as stated: |
| 131 | |
| 132 | - **`source.repository` of an Omega receipt.** The receipts do not name their implementation |
| 133 | repository, so it comes from the index (`--source-repo` at admission). The tool checks only |
| 134 | that it is an `aien-dev/<name>` repository and that the named commit and artifact digests |
| 135 | hold there. A wrong repository shows as `REFUSED_SOURCE_PROVENANCE`, but the index cannot |
| 136 | prove that the receipt meant that repository. |
| 137 | - **The signed-bundle basis "this shelf has no correction records".** `effective_basis` of a |
| 138 | signed bundle reads `authenticated bundle verdict (this shelf has no correction records)`. |
| 139 | The tool checks the part it can see: no `bundle.correction.json` beside the bundle at the |
| 140 | pinned commit or at the shelf HEAD. It cannot see corrections recorded anywhere else, such as |
| 141 | issues, ADRs or `audit/` stamps. |
| 142 | - **Descriptive top-level fields** (`issue`, `generated_by`, `independence`, `precedence`, |
| 143 | `exit_codes`, `scope`, `excluded`, `generated_utc`). They describe the index and are not |
| 144 | recomputed; `precedence` and `exit_codes` restate this document. |
| 145 | - **An `issue_or_gate` marked `verified: false`.** Operator text. Version 2 has none. |
| 146 | |
| 147 | ## Version 2 contents |
| 148 | |
| 149 | Version 1 was generated on 2026-11-06 by Receipts167. Version 2 was regenerated by `admit` at |
| 150 | the same pinned shelf commits; only `issue_or_gate` changed, every digest and verdict is |
| 151 | identical. Replayed on the Spark on 2026-11-06: `replay --all` 16/16 entries reproduce, and |
| 152 | every `issue_or_gate` is derived from its receipt. |
| 153 | |
| 154 | | Entry | Effective verdict | Basis | |
| 155 | |---|---|---| |
| 156 | | `spark-rsi@68528eca` | FAIL | Signed bundle; RSI-TEST FAIL. DRA-167 source anchor (recorded here, not in the index). | |
| 157 | | `spark-rsi@f72209e6`, `aien-architecture@1a359434` | PASS | Signed bundles. | |
| 158 | | `omega-evidence/M4`, `M10`, `M11`, `M12`, `M13`, `M14`, `M15`, `M17` | PASS | Named commit resolves; source digests match. | |
| 159 | | `omega-evidence/M8`, `M9` | REFUSED_UNSUPPORTED_PROVENANCE | Shelf corrections recorded 2026-10-26. | |
| 160 | | `omega-evidence/M5` | REFUSED_SOURCE_PROVENANCE | `git_commit` does not exist in `aien-dev/omega-mv`. No shelf correction yet. | |
| 161 | | `omega-evidence/M6` | REFUSED_SOURCE_PROVENANCE | At the named commit, `src/omega_self_host.c` is absent and both AArch64 sources differ. No shelf correction yet. | |
| 162 | | `omega-evidence/M7` | REFUSED_SOURCE_PROVENANCE | At the named commit, `src/omega_verify.c` is absent and `src/omega_validate.c` differs. No shelf correction yet. | |
| 163 | |
| 164 | Also recorded, not deciding: |
| 165 | - M12's `receipt_commit` does not resolve, as its non-superseding correction says. |
| 166 | - M14's `receipt_commit` does not resolve either, and no correction says so yet. |
| 167 | - M10, M11 and M13 carry the placeholder `pending-receipt-commit`. |
| 168 | |
| 169 | `index.excluded` lists the omega-evidence receipts in other layouts, which are not yet covered. |
| 170 | |
| 171 | ## Limits |
| 172 | |
| 173 | - **Not independent.** The author of the index and the author of the tool are the same agent. An |
| 174 | independent replay needs a different operator, or `aien-test verify-bundle` for signed bundles |
| 175 | as in `docs/verify-one-bundle.md`. |
| 176 | - **Not `aien-test`.** The signature check uses OpenSSL Ed25519, not `ed25519-dalek` |
| 177 | `verify_strict`. The canonical encoder is a Python port of `evidence::canonical` |
| 178 | (aien-sovereign-core@c26f4d7ac3156088469b27462390f5b08ef4f436); the tests use that file's |
| 179 | golden cases. |
| 180 | - **Omega PASS is narrow.** Omega receipts carry no signature. PASS here means the pinned bytes, |
| 181 | a resolving named commit and matching source digests. The binary and the run were not |
| 182 | recovered, and nothing here is hardware qualification. |
| 183 | - **Signed PASS is narrow.** A valid signature authenticates the recorded statement, not the |
| 184 | sufficiency of the tests behind it. All three bundles in version 2 ran on the `host` backend. |
| 185 | - **Host dependencies.** Observed on the Spark: Python 3.12.3, Git 2.43.0, OpenSSL 3.0.13. |
| 186 | They fetch commits, compute SHA-256 and verify Ed25519. No Omega replacement exists; porting |
| 187 | the check to seeded Omega is an open proposal, in line with `audit/tools`, which is also Python. |
| 188 | |
| 189 | ## ADR 0033 amendment (draft) |
| 190 | |
| 191 | To be added to `docs/adr/0033-aien-verification-pipeline.md` in `aien-dev/aien-architecture` |
| 192 | (drafted against ad8d1eb), after the 2026-10-26 amendment and before "Not decided here": |
| 193 | |
| 194 | > ## Amendment 2026-11-06 (receipt index on the receipts shelf) |
| 195 | > |
| 196 | > Approved for the maintainer by Queen, the Completion Hive coordinator, under Drake |
| 197 | > Stapleton's delegation of merge judgment (DRA-162, 59767dce), with aien-dev/aien-receipts#12 |
| 198 | > (DRA-167). Nothing in Decisions 1 to 14 or in the earlier amendments changes, and published |
| 199 | > `<repo>/<sha>/bundle.json` files keep their bytes, layout and meaning. |
| 200 | > |
| 201 | > 1. **A receipt index on the same shelf.** `aien-dev/aien-receipts` gains `index/receipt_index.json`, |
| 202 | > the replay tool `tools/replay_receipt.py`, its offline tests `tests/test_replay.py` and the |
| 203 | > description `docs/receipt-index.md`. The index lists the receipts that may be cited: |
| 204 | > signed bundles from this shelf and Omega qualification receipts from |
| 205 | > `aien-dev/omega-evidence`, each with the pinned shelf commit, SHA-256, the correction that |
| 206 | > applies and the effective verdict. |
| 207 | > 2. **Written only by the tool.** Entries are written only by `tools/replay_receipt.py admit`. |
| 208 | > Replay recomputes every entry except its name and command, and rejects any difference, any |
| 209 | > field it does not check, and any correction that differs between the indexed commit and the |
| 210 | > shelf HEAD. |
| 211 | > 3. **Corrections outrank historical status.** A `.correction.json` that supersedes a receipt's |
| 212 | > historical status decides the effective verdict; a historical `QUALIFIED / PASS` is never |
| 213 | > admitted on its own text. Omega receipts without a superseding correction must also match |
| 214 | > their named source commit. |
| 215 | > 4. **Bundles unchanged.** Signed bundles are checked as in Decision 6 (key from the source |
| 216 | > commit's first parent, verdict algebra of Decision 7). The index does not re-sign or move |
| 217 | > them, and a bundle correction file is refused until a rule for it is decided. |
| 218 | > 5. **Not a gate.** The index is a citation aid. It is not an input to `aien-test |
| 219 | > verify-bundle`, the AIEN Alpha job or any merge gate, and a replay by the index's author is |
| 220 | > not an independent review. |