// SPDX-License-Identifier: CC-BY-SA-4.0 = Design note: proven-ness derived from receipts :toc: macro Status: *design ruled; receipt reader built, writer not started*. This note records the problem, the owner's rulings so far, the evidence from two experiments, and the questions still open. toc::[] == The problem `docs/arghda-spec.adoc` says a lint hard-block "forbids `working → proven`". Two things break that today: . `arghda promote` is a plain file move (`Workspace::transition`). It runs neither the lint pack nor the prover. . `reason::workspace_verdicts` gives `Verdict::Proven` to any file whose basename is in `proven/`. Location is treated as evidence. Reproduced on 2026-11-24 (agda 2.6.3). A lint-clean module that does not typecheck (`x : N; x = Set`) is promoted. `arghda check` on it says `rejected`, and `arghda reason proven --workspace ws` reports it, and `All` which imports it, as `proven`. Lint caps catch some cases: a promoted postulate reads `postulated`, and an edited file reads `unknown` through the content-hash closure. But nothing catches a file the prover rejects. == Owner rulings (2026-11-24) * Proven-ness is *derived from recorded evidence*. It is never inferred from where a file sits. * `proven/` stays as an *untrusted view*: files still move there, and nothing reads the location as evidence. * Receipts reuse the *estate receipt schema*: the proof-receipt praxis deed of standards `3-practice/PROOF-POLICY.adoc` §8.5.1. arghda does not invent a format. * `arghda check` applies the reasoning graph's lint caps (done in hyperpolymath/arghda-core#66). == Owner rulings (2026-11-25) * *Gap 3:* the lint-capped verdict and any lint hard block become fields of the proof-receipt profile, proposed *upstream* in `metadatastician/standards` (deed spec and `deed_lint.js`). arghda does not carry a side record. A receipt then states its own verdict, so a reader can evaluate the receipt rule from the receipt alone. That does not make the recorded result true: a row records a claim, it does not establish it (PROOF-POLICY §8). A reader that will not trust the writer re-runs the receipt's `:checker` and `:invocation` on the files its `(inputs-manifest …)` names and compares the verdict; the receipt is exactly the data that makes that re-run possible. * *Gap 1:* uncommitted local runs get a *workspace-receipt profile*, also proposed upstream, keyed by the input digest instead of a commit. It goes in the same standards change as gap 3. * *Migration:* both. A file in `proven/` with no matching receipt reads `unknown` until it is promoted again through `check`. An `arghda migrate` command is also offered: it re-checks each such file once and writes receipts only for those that pass. Until the standards change lands, arghda writes no receipts; the reader side can be built and tested against fixtures in the proposed shape. Second round, same day: * *Order of work: fixture-first.* arghda's receipt reader is built first, against fixture receipts in the proposed shape. The standards proposal follows, with a working consumer as its evidence. * *Gap 2:* one `claim` per module, `:id` the module name, which also *lists* the module's headline theorems without grading them. Listing them needs a field the profile lacks, so it joins the upstream proposal. * *Location:* canonical receipts are `verification/receipts/*_praxis.deed` in the workspace's own repository, where other estate readers find them. `.arghda/` holds only a derived index for speed; it is never evidence, and a reader that finds the two disagreeing trusts the receipt and rebuilds the index. * *Binding:* the snapshot rule, plus a digest taken before and after `check` on the snapshot as an extra guard. A mismatch writes no receipt. == Evidence Measured in a container with real provers, using the debug build. These are synthetic workloads; they do not stand for a real corpus. .Single-file `arghda check` on a small proven fixture (ms) |=== |Backend |Cold |Re-run |Re-run |agda |173 |52 |39 |agda-cubical |61 |41 |50 |idris2 |712 |709 |625 |lean4 |484 |237 |257 |coq |98 |70 |68 |mizar |17 |9 |11 |z3 |29 |16 |19 |cvc5 |29 |13 |8 |=== .Agda import chain of N modules, `arghda check` on the top module (ms) |=== |N |Cold |Unchanged re-run |After editing the root |After editing the top |10 |145 |72 |130 |71 |50 |829 |182 |570 |150 |200 |13015 |2175 |8752 |2384 |=== .Deriving instead of re-proving: import graph plus manifest digest (ms) |=== |N |`arghda dag` |sorted `sha256sum` manifest digest |200 |11 |12 |1000 |56 |22 |3000 |135 |48 |=== Conclusions: * *Never re-prove to answer "is it proven?"* At 200 modules even an unchanged re-check costs about 2 s, because Agda reloads every interface. A receipt plus a digest comparison costs about 0.2 s at 3000 modules. * *Running the prover once at promotion is affordable.* That cost is paid once per change, not on every query. === echo-types, measured 2026-11-25 `hyperpolymath/echo-types` at `140002f1079a2527301735a3621b169b75df4622`, `proofs/agda`, release build. echo-types is *not* an arghda workspace: it has no `proven/` directory and no proof-receipt deeds (`docs/receipts/` holds logs). So "in `proven/`" against "has a matching receipt" is zero against zero there, and cannot be measured as first planned. What was measured: .Cost of deriving, on a real corpus |=== |Step |Result |Modules, import edges |152, 552 |`arghda scan` (lint all modules) |2.06 s |`arghda dag` |1.83 s |§8.5.1 digest of every module's input set (cone plus `echo-types.agda-lib`) |10–17 ms for all 152 |Input-set size (files) |min 2, median 5, max 113 |=== One digest (`AntiEcho`) was recomputed with the standards shell line, which takes one path per input line (`printf '%s\n' PATH… | LC_ALL=C sort | xargs -d '\n' sha256sum -- | sha256sum`), and matched; the command actually run used the same `xargs -d '\n'`. Hashing is negligible; the import graph dominates. `dag` took 1.83 s here against 135 ms for 3000 synthetic modules, so the real files' size, not the module count, drives it. That is not yet profiled. .What a receipt would record (lint pack, all 152 modules) |=== |Finding |Files |any hard block |12 |`orphan-module` (hard block) |12 |`missing-safe-pragma` (hard block) |2 |`unjustified-postulate` (hard block) |1 |`unpinned-headline` (warn) |78 |=== * The two pragma findings and the postulate are the cubical module and the quarantined postulate module that echo-types' own `PROOF-STATUS.adoc` already declares outside the `--without-K` suite. The lint agrees with the repository's own account. * Of the 12 orphans, 2 are checked by CI through their own invocations (`NarrowingSmoke` in `scripts/check-grade3.sh`, the cubical module in `.github/workflows/agda.yml`). arghda's default roots (`All`/`Smoke`) do not see those, so a receipt writer must take the CI's entry points (`--entry`) or it will block modules that CI does check. * The other 10 are reached by no root and named in no CI file, yet all 10 are named in the docs. One, `EchoFidelity`, is described as "type-checked under Agda 2.6.3 / stdlib 2.3 on 2026-10-19", a dated claim that nothing re-checks. That is the disagreement the receipt rule is for: under receipts, that claim would read `unknown` as soon as an input changed. .The prover on every module (2026-11-25) |=== |Result |Modules |Accepted by Agda |151 |Rejected by Agda |1 |*Lint-clean but rejected* |*0* |Hard-blocked by lint but accepted by Agda |11 |=== Toolchain exactly as echo-types' CI pins it, through its own `scripts/setup-agda.sh`: Agda 2.7.0.1 (release archive SHA-256 checked), agda-stdlib `8326c7475af1fa456ca04a0203c168d5d7ff842b`, absolute-zero `8a3162a24c8524735b464bedb9747517dc8b0467`. Each of the 152 modules was checked on its own with CI's flags (`--safe --without-K --cubical-compatible`; `--safe --cubical` for the cubical module), after `All.agda` warmed the interface cache (148 s; per-module pass 604 s). * The one rejection is the quarantined postulate module ("Cannot postulate … with safe flag"), which the lint also hard-blocks. * *No module is lint-clean and rejected by Agda.* On this corpus the lint and the prover agree wherever the lint is silent, so the bug that motivates this note (a rejected file read as proven) does not occur here *today*. The rule still matters: nothing re-checks a file once it sits in `proven/`. * The 11 hard-blocked modules that Agda accepts are all orphans, among them `EchoFidelity`. Its dated "type-checked" claim is true under 2.7.0.1 today, but no root or receipt records it (departure row in metadatastician/standards#1706). === echidna, measured 2026-11-25 `hyperpolymath/echidna` at `14ada6d`, read-only copy, release build of arghda. `arghda check --json` ran on all 122 prover files in seven backends. Each file ran on its own, with `--include-root` derived from its module header. This is the multi-backend corpus that echo-types is not. .First pass, `arghda check` verdict by backend |=== |Backend |Files |proven-eligible |unknown |refuted |rejected |unavailable |Agda |26 |0 |0 |0 |26 |0 |Coq |9 |7 |0 |0 |2 |0 |Idris2 |38 |36 |0 |0 |2 |0 |Isabelle |6 |0 |0 |0 |0 |6 |Lean 4 |16 |1 |12 |0 |3 |0 |Mizar |5 |1 |0 |0 |4 |0 |Z3 |22 |15 |0 |7 |0 |0 |*Total* |*122* |*60* |*12* |*7* |*37* |*6* |=== 81 of 122 files exit 0, but only 60 are proven-eligible. The 21 that exit 0 and are not proven-eligible are the point of the verdict layer: * *7 Z3 files are `sat`*, which means refuted (for example `tests/live_goals/contradiction.smt2` and `proofs/z3/basic.smt2`). A reader that took exit code 0 as "proven" would promote all seven. * *12 Lean files read `unknown`.* That is an arghda defect, and it fails closed. The axiom audit looks declarations up by their unqualified names, so it never finds a declaration inside a `namespace`. Checked by hand with qualified names: - `EchidnaPareto.TrustLevel.value_pos` depends on `[propext]`. - `EchidnaPareto.dominates_transitive` depends on `[propext, Quot.sound]`. Both would be Proven. The defect costs completeness, not soundness. After the oracle fix (#66, `88f0d27`), the 16 Lean files re-run as follows: - 9 proven (was 1): the 8 that moved were `unknown`. - 3 rejected, as before. - The 2 `lakefile.lean` files read `postulated`. Lake's DSL generates declarations that depend on `Lake.ModuleData.o` axioms, so the verdict is accurate, but a lakefile is configuration and should not be audited as a proof at all. - 2 files define no constants of their own and stay `unknown`, marked `degraded`. * *2 Agda files* (`proofs/agda/Basic.agda`, `tests/live_goals/Identity.agda`) exit 0 but are hard-blocked by `missing-safe-pragma`. echidna's CI passes `--safe` on the command line, not in the file. This mirrors echo-types' orphan finding: the lint has to know the CI's invocation, flags as well as entry points, or it blocks files that CI checks under `--safe`. The 24 other Agda rejections were not proof failures. The first pass ran without a UTF-8 locale (Agda exits on the Unicode in the sources) and against one stdlib, while echidna pins two Agda tracks. arghda classed the locale failure as a rejection, which is a second arghda defect: an environment failure reads as a proof failure. Agda was re-run directly on echidna's own pins, with `LC_ALL=C.UTF-8`: .Agda, on echidna's pinned tracks |=== |Track |Toolchain and flags |Files |Accepted |`meta-checker/` |Agda 2.7.0.1, stdlib v2.1, `--no-default-libraries --library-file … --safe --without-K --cubical-compatible` |10 |10 |`proofs/agda/` and `tests/` |Agda 2.6.3, stdlib v1.7.3, `--safe --without-K --cubical-compatible` |16 |14 |=== Both rejections are by design: * `tests/live_goals/Broken.agda` is a deliberate type error. * `tests/chapel_fixtures/agda_trivial.agda` declares `module Trivial` because echidna's Chapel runner writes it to `Trivial.agda` before checking (`filenameOverride`). Every Agda module that `docs/PROOF-STATUS.adoc` cites and that exists in this tree is accepted on its track. That is 7 modules (5 in the meta-checker, `ProofComposition` and `SoundnessPreservation`). These are prover results, not arghda verdicts. A pinned-toolchain arghda run of those 24 files has not been made yet. The stdlib sources were fetched by git tag because the release tarballs returned 403 through this session's proxy, so the tarball SHA-256 was not checked. The 11 non-Agda rejections: |=== |Cause |Files |By design: a negative fixture (`tests/live_goals/broken.v`), a renamed fixture (`idris2_trivial.idr`), or a documented non-proof fixture (`tests/fixtures/non-proof/NeSyAssistTesting.idr`, which "does not parse") |3 |Lean import path: `proofs/lean/ECHIDNA.lean` (`Basic`) and `verification/proofs/lean4/ParetoStrongMaximality.lean` (`ParetoMaximality`) need the sibling modules on the search path, which the per-file run did not supply |2 |Needs Mathlib (`tests/corpus_fixtures/minif2f/algebra.lean`), which estate policy excludes |1 |Real failure under Coq 8.18.0: `examples/simple_proof.v`, "Found no subterm matching `m + n' * m`". echidna's dogfood CI prints `coqc --version` but pins no version |1 |Mizar checker errors (`.err` codes 203, 11, 55, 253), cause not diagnosed |4 |=== *No file that arghda called proven-eligible is rejected by its prover.* The risk on this corpus was the exit-code reading, and the verdict layer caught it: 7 refuted files exit 0. Defects found, to fix in arghda: * Lean axiom audit: it missed declarations inside a `namespace`. *Fixed* on #66 (owner ruling 2026-11-25: oracle plus fallback). A copy of the file is compiled, and a separate program imports it, lists the constants whose home module is the copy, and collects their axioms, on nonce-marked lines. The text scanner runs only when the oracle cannot, and the output then says `degraded`. * File discovery treats `lakefile.lean` as a proof file. It should be skipped, as configuration. * An environment failure, such as a locale error, was classed as rejected. *Fixed* on #66 (owner ruling 2026-11-25: a canary, lazy on failure). When a file errors, the backend's known-good canary runs in a directory named `canary-⊤`. If the canary fails too, the file reads `backend-unavailable`, with "environment failure" in its output. The fix was checked on two real cases: Agda under `LC_ALL=C`, and Agda 2.6.3 reading 2.7.0.1's data directory. The canary imports nothing, so a missing library still reads `rejected`. * The lint takes no account of the CI's invocation (command-line `--safe`, entry points). A receipt writer must record that invocation anyway (`:invocation`), so the lint should read it from there. == Design === Receipts `promote` runs `check` and writes a receipt row. A file *is proven* exactly when it has a receipt whose state is `current` and which satisfies all of the following: * its `:inputs-sha256` equals the digest of the file's current *input set*. This is the §8.5.1 input set for the backend: the import cone plus every configuration file the run reads (for example `.agda-lib` and `libraries`; `_CoqProject`, `dune`, `dune-project`; `lakefile.lean` or `lakefile.toml`, `lean-toolchain`, `lake-manifest.json`). An import cone alone is not enough; a changed toolchain pin must make the receipt stale; * the check that produced its result read exactly the bytes that digest covers (see "Binding the result to its inputs" below); * its result is `proven` after lint caps (`reason::cap_by_lints`); * it records no lint hard-block (but see gap 3: the schema cannot yet hold this); * its `:checker` names the backend and tool version. A receipt becomes `stale` when the digest of its input set no longer matches, which is the PROOF-POLICY §8.4 lineage state. `superseded` and `regressed` follow §8.4 too. `reason::workspace_verdicts` reads receipts instead of directory membership. The input digest follows §8.5.1 exactly: a manifest with one line per file, ` `, with the lines sorted by *path* in bytewise (C locale) order, then hashed with SHA-256, using the reference implementation `scripts/proof-inputs-sha256.sh` in `metadatastician/standards` (last changed at `2c7467bde91bf35d6a26d1838154db50680d3cdb`; an implementation must pin the commit it follows, since the script at HEAD can change). It replaces arghda's own `closure_hash`, so anyone can recompute a receipt with git alone. That script reads git blobs at a commit, so it cannot hash a new file or the edited state of a committed one. A *workspace receipt* (gap 1) therefore digests the bytes of the checked snapshot itself, with the same manifest format: one ` ` line per snapshot file, sorted bytewise by path, then SHA-256. The receipt reader (hyperpolymath/arghda-core#67) implements this as `receipt::worktree_manifest`. For a file whose snapshot bytes equal its committed blob, both routes give the same digest, which is what lets a workspace receipt be checked again once the file is committed. The standards files this note was checked against (PROOF-POLICY §8.5.1 and `1-formats/deed/tools/deed_lint.js`) were read at `metadatastician/standards@f7c5e201f78f822f0711762a231e69867e8d4a59`. === Binding the result to its inputs If a file in the input set is edited after `check` reads it but before `promote` records the digest, the receipt pairs an old `proven` result with new bytes. The receipt must make that impossible. Candidate rules, not yet chosen: * *Snapshot (preferred):* stage the input set into a fresh private directory, make the staged copy immutable (read-only, written by nothing else) before `check` starts, run `check` on that copy, and digest that same copy. The guarantee holds only while the copy cannot change between the check and the digest; given that, result and digest refer to the same bytes by construction. `tests/verdicts.rs` already stages fixtures into a temp directory, but does not make them read-only. * *Digest twice:* digest the input set before and after `check`, and refuse to write a receipt if the two differ. *Not sufficient on its own:* an input changed during `check` and restored before the second digest passes both. At most an extra guard alongside the snapshot. * *Lock:* hold a lock on the input set across `check` and digest recording. This depends on every editor honouring the lock, so it is the weakest. === Fit with the proof-receipt deed, and the gaps Checked against standards `1-formats/deed/tools/deed_lint.js`: * *Fits:* receipt fields (`:checker`, `:invocation`, `:inputs-sha256`, `:state`, `(inputs-manifest …)`, `(axioms …)`); lineage states; and `:pwg ungraded`, which the linter accepts. arghda checks files, not theory theorems, so it records no PWG grade (policy §8.1). * *Gap 1, uncommitted local runs.* `:source-commit` and each receipt's `:commit` must be a full 40-character commit, and each receipt's `:run` is required. Files in `inbox/` and `working/` are usually uncommitted, and a local `promote` has no CI run to cite. *Ruled 2026-11-25:* a workspace-receipt profile, proposed upstream. * *Gap 2, granularity.* A receipt sits in a per-theorem `claim`, while arghda's unit is a file. The proposal is one `claim` per module, with the module name as `:id`. * *Gap 3, lint evidence.* The receipt's field set is closed: `:run`, `:commit`, `:checker`, `:invocation`, `:inputs-sha256`, `:state`, `:reason`, `:image`, and the `(axioms …)`, `(inputs-manifest …)` and `(import …)` clauses. The linter rejects any other field. A receipt therefore cannot record that the lint pack ran and found no hard block, and a clean result cannot be told apart from missing lint evidence. Nor does a receipt record a *verdict*: `:state` is lineage (`current`, `stale`, `superseded`, `regressed`), so a `current` receipt does not by itself show the check was `proven`. The receipt rule above cannot be evaluated from a receipt until one of these is chosen: ** add fields for the lint-capped verdict and for any lint hard block (an upstream change to the proof-receipt profile); or ** write a receipt only for a check whose lint-capped verdict is `proven` with no hard block, and have every reader enforce that rule (the receipt's existence then carries the verdict, which a reader cannot verify on its own). *Ruled 2026-11-25: the first.* The fields are proposed upstream, and the linter validates them. * *Gap 4, non-Agda modules* (found while building the reader, 2026-11-25). `deed_lint.js` refuses a `claim` with no `agda` leg, and only the `agda` leg may have `:route source`. Those rules fit theory theorems, where Agda is the source of truth (PROOF-POLICY §2). An arghda workspace can hold Idris2, Lean, Coq, Isabelle, Mizar or SMT modules, whose only leg is not Agda. *Ruled 2026-11-25: both profiles.* The proposal lets a claim in either `workspace-receipt` or `proof-receipt` have the module's own prover as its single leg, which also covers engineering claims (Idris2 ABIs, SPARK). This touches the PWG theory rules, so the proposal must keep §8 grading unchanged for theory claims: a claim without an Agda source leg stays `ungraded` and can never derive a `PWG-` grade. * *Order (ruled 2026-11-25):* measure echo-types before the proposal goes upstream, so the proposal carries real disagreement numbers. === The reader (built 2026-11-25, fixture-first) `src/receipt/` reads proof-receipt deeds and the proposed shape, and derives a module's verdict: * `sexp.rs` is a small fail-closed reader for the deed syntax. * `mod.rs` checks the §8.5.1 manifest rules (bytewise order, no repeats, path rules, 64-hex digests, the digest rebuilt from the manifest), closed field sets, lineage states, and at most one current receipt per leg. `ReceiptDeed::derive` gives `proven` only when the receipt rule holds; anything missing gives `unknown`, and a hard block is never better than `unknown`. * The tests cross-check the digest against the standards worked example, cover each refusal for its own reason, and check the rule exhaustively over 320 receipt shapes. Nine mutations of the checks were each caught. Not done yet: the `.arghda/` index, wiring into `workspace_verdicts`, and the writer. None of them should land before the standards change, because until then every `proven/` file would read `unknown` with no way to re-promote it. === The invariant, and how to prove it ---- ∀ f. derived_proven(f) ⇒ ∃ r ∈ receipts. r.state = current ∧ r.inputs_sha256 = digest(inputs(f)) ∧ r.inputs_sha256 = digest(bytes_checked(r)) ∧ capped(r) = Proven ∧ ¬ r.hard_block ---- This is the statement to carry as a Creusot contract (Pearlite) and as a Verus proof on the derivation function. Neither verifier has been run on arghda yet; both scopes are open. The lint-cap step is a monotone (deflationary) map on the finite verdict order, so it is idempotent and order-independent. That is a small lemma to prove next to it, and `cap_by_lints_agrees_with_the_graph` already tests it. == Open questions for the owner All six questions were ruled on 2026-11-25 (above). None is open. == Plan . Receipt reader, against fixture receipts in the proposed shape, with known-answer tests: the lint-clean-but-rejected case above as a regression test; `unknown` for a `proven/` file with no matching receipt; a stale digest; a receipt with a hard block; an `.arghda/` index that disagrees with its receipt. . Measure disagreement on a real workspace (echo-types), using the current-behaviour reproduction above as the test. . Propose upstream in `metadatastician/standards`, with the reader as evidence: the verdict and hard-block fields (gap 3), the workspace-receipt profile (gap 1), the theorem list (gap 2) and single non-Agda legs (gap 4), with positive and negative `deed_lint.js` tests. . Receipt writer once the standards change lands: snapshot plus digest-twice binding; `promote` gated on `check`; `workspace_verdicts` reading receipts; `arghda migrate`. . Creusot (Pearlite) and Verus scopes for the invariant, recorded in `docs/status/PROOF-STATUS.adoc`.