diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index b66d3df..01427de 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -74,6 +74,8 @@ jobs: uses: editorconfig-checker/action-editorconfig-checker@v3.0.0 - name: Gate falsifiability canaries (R10) run: bash scripts/test-gate-falsifiability.sh + - name: Aspect tests (SPDX and banned-construct scans) + run: bash tests/aspect_tests.sh - name: Workflow and gate regression tests run: | bash tests/workflows/review_regressions_test.sh diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index af0500c..9f2631a 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -10,6 +10,44 @@ https://semver.org/spec/v2.0.0.html[Semantic Versioning]. ==== Fixed +* *The aspect lane runs, grades stand only on what the policy admits, and four +status claims are narrowed (2026-11-17).* ++ +_Aspect lane._ `+just aspect+` was the mint template: it ran nothing and printed +"Aspect tests passed!", and `+test-all+` depends on it. `+tests/aspect_tests.sh+` was +invoked by nothing, so the hardening of it recorded further down this file was to +a script no lane ran. Its Idris2 scan read `+src/interface/Abi/+` only (3 of 16 +files) and dropped every hit containing "test". The recipe and the quality +workflow now run the script; the scan reads every Idris2 source through the +comment stripper, adds `+assert_smaller+`, `+unsafePerformIO+`, `+idris_crash+` and +`+postulate+`, and fails when it finds no Idris2 file. Canaries 32–34. ++ +_Grade derivation_ (`+scripts/pwg-derive.sh+`). No published grade moves; the +census stays `+PWG-3+` 18, `+ungraded+` 10 of 28. (a) A leg whose current receipt +reports an axiom counts only when each axiom has disposition `+c+`, recorded on +the receipt as `+axiom_dispositions+`; none recorded means inadmissible (§8.4 +rule 6, §8.5.1). No disposition is recorded on the live Lean receipts: that is a +trusted-base decision for the owner, and those legs are `+BRIDGE-PENDING+` either +way. (b) The derived axiom list is the union over every witness the grade stands +on, where it was the Agda receipt's alone. (c) Each `+agda+` command in a recorded +invocation must be exactly the three §2.1 flags and one module, where one +canonical command used to vouch for a second with no flags. (d) +`+foundation-diverse+` needs an accepted, `+RECONCILED+`, receipted witness, where +any non-null value used to publish it (§8.3). `+scripts/pwg-check.sh+` rejects a +disposition outside `+c|b|debt+` and one for an axiom the receipt does not report. +Canaries 35–43; each fails against the code before it. The suite stands at +*43/43*. ++ +_Status claims._ `+deceptiveDuals+` is a tuple value and is no longer cited as +evidence for "exactly three". `+verdictSound+` is stated over a grade-shaped floor, +as its source says, not over the use-model floor. The tier-2 row names the +ratified iff. The README no longer says `+PROOF-STATUS.adoc+` and `+pwg.json+` "agree +row for row": the gate checks the grade table and census, not the prose rows. +In `+grade-factorisation+`, the README verdict is marked as the pre-ratification +result and lists `+GradeFactorisationR.lean+`, and `+REPORT.adoc+` states the measured +axiom bound (`+propext+` and `+Quot.sound+` over 184 declarations, CI run +43981767344) where it had quoted the audit's allowlist. + * *The comment stripper nests where the languages nest, and `+psiBond+` separation is stated in general (2026-11-16).* Lean `+/- -/+`, Agda and Idris2 `+{- -}+` and Coq `+(* *)+` block comments nest; `+tests/lib/strip-proof-comments.awk+` closed on the @@ -18,7 +56,7 @@ dangerous-construct scan, and an unterminated nested comment exited `+0+` (a truncated scan reported as complete). A depth counter per open token fixes both; C-style `+/* */+` stays flat, and over all 38 tracked sources the output is unchanged. Canaries 30–31 plant both cases and fail against the old stripper; the -suite stands at *31/31*. Separately, `+psiBond_separates_all_honest+` +suite stood at *31/31* at that point (43/43 after the entry above). Separately, `+psiBond_separates_all_honest+` (`+GradeFactorisation.lean+`) states that every bond other than `+misbound+` is separated from it, by `+cases+` over `+Q_ne_unknown+` and `+total_ne_unknown+`, with a `+#print axioms+` line; its kernel check is the CI `+lean-build+` job. diff --git a/Justfile b/Justfile index a6d1099..205e2eb 100644 --- a/Justfile +++ b/Justfile @@ -147,18 +147,11 @@ test-smoke: e2e: trope-build bash tests/e2e.sh -# Run aspect tests (cross-cutting concern validation) +# Run aspect tests (cross-cutting concern validation): SPDX headers and the +# banned-construct scans over every Idris2 and proof source. The recipe used +# to be the mint template: it ran nothing and printed "Aspect tests passed!". aspect: - @echo "Running aspect tests..." - # TODO: Replace with your aspect test command. Examples: - # bash tests/aspect_tests.sh # Shell-based aspect tests - # cargo test --test aspects # Rust aspect tests - # Aspect tests validate architectural invariants: - # - Thread safety (mutex in FFI modules) - # - ABI/FFI contract (declarations match exports) - # - SPDX compliance (all files have license headers) - # - No dangerous patterns (believe_me, assert_total, etc.) - @echo "Aspect tests passed!" + bash tests/aspect_tests.sh # Run benchmarks (performance regression detection) bench: diff --git a/README.adoc b/README.adoc index 1e1d3a0..8072a51 100644 --- a/README.adoc +++ b/README.adoc @@ -162,7 +162,9 @@ The grade-level cancellation boundary (left-cancellative iff ε on the unquotiented carrier) is proved in Lean; Agda proves finite-fidelity cancellation and selected non-cancellation counterexamples, not the exhaustive iff. `docs/status/PROOF-STATUS.adoc` and -`verification/pwg.json` are the per-result record, and they agree row for row. +`verification/pwg.json` are the per-result record. `scripts/pwg-check.sh` checks that the +grade table and census published in the first are the ones derived from the second; the +prose rows of the status file are written by hand and are not checked against the ledger. Only *L1* and *L4* carry a statement in all three, and of the ten results *eight* lack one entirely. Lean does not state L2, L5, Honest Generation or Veridicality; Idris2 does not state L3, L6, conicality or the cancellation boundary; L5 is diff --git a/docs/status/PROOF-STATUS.adoc b/docs/status/PROOF-STATUS.adoc index 8c3a8b9..b3a316e 100644 --- a/docs/status/PROOF-STATUS.adoc +++ b/docs/status/PROOF-STATUS.adoc @@ -56,8 +56,8 @@ toc::[] | Idris2 `Trope.Soundness.{fateDroppedLtePredicated,fatePredicatedNotLteDropped}`; Agda `TB.Order.{fateDroppedLtePredicated,fatePredicatedNotLteDropped}`. | Veridicality Derivation -| Exactly three deceptive duals, one per coordinate kind (`Falsified`, `Misbound`, `Conflated`), each the unique deceptive inhabitant of its coordinate. -| Idris2 `Trope.Veridicality.{fateDeceptiveUnique,bondDeceptiveUnique,mergeDeceptiveUnique,deceptiveDuals}`; Agda `TB.Honest.{fateDeceptiveUnique,bondDeceptiveUnique,mergeDeceptiveUnique,deceptiveDuals}`. +| Exactly three deceptive duals, one per coordinate kind (`Falsified`, `Misbound`, `Conflated`), each the unique deceptive inhabitant of its coordinate. The uniqueness of each is a theorem. "Exactly three" is not stated as one proposition: it follows from the three uniqueness lemmas and the construction of `Grade` as their product. `deceptiveDuals` in both provers is a tuple value, states no proposition, and is not cited as evidence. +| Idris2 `Trope.Veridicality.{fateDeceptiveUnique,bondDeceptiveUnique,mergeDeceptiveUnique}`; Agda `TB.Honest.{fateDeceptiveUnique,bondDeceptiveUnique,mergeDeceptiveUnique}`. | Honest Generation | The five atoms `attenuate`, `predicate`, `drop`, `sever`, `fuse` with stem:[\varepsilon] generate exactly the honest fragment of each coordinate and never produce a deceptive dual; honesty is closed under stem:[\triangleright]. @@ -79,7 +79,7 @@ toc::[] | Tier-2 membership, exhaustive | In the unquotiented model, every honest-but-lossy element is individually witnessed non-cancellative (finite attenuation regains cancellation on A3 normal forms), `Withheld` and `Fused` included; the per-element witnesses feed the iff. -| Lean `TierTwoComplete.lean`: `Bond.withheld_honest_not_cancel`, `Merge.fused_honest_not_cancel`, `Fate.atten_not_cancel`, the `*.leftCancelWitness` family, `Grade.grade_leftCancel_iff`. Agda states six of the per-element witnesses and the positive right-cancellation, all in `TB.Tier`: `unknown-not-cancel`, `total-honest-not-cancel`, `falsified-not-cancel`, `dropped-honest-not-cancel`, `predicated-honest-not-cancel`, `severed-honest-not-cancel`, `Q-cancelʳ`. What Agda does *not* state is the exhaustive step: there is no Agda counterpart of `grade_leftCancel_iff`, and no Agda witness on the merge coordinate, which is why the ledger's Agda token for this row is `OPEN` rather than the row being Lean-only. +| Lean `TierTwoComplete.lean`: `Bond.withheld_honest_not_cancel`, `Merge.fused_honest_not_cancel`, `Fate.atten_not_cancel`, the `*.leftCancelWitness` family (`FateA.leftCancelWitness` on the ratified fate), and the exhaustive iff, `GradeR.gradeR_leftCancel_iff` on the ratified carrier (`Grade.grade_leftCancel_iff` is the same statement over the historical pre-ratification carrier, kept as history). Agda states six of the per-element witnesses and the positive right-cancellation, all in `TB.Tier`: `unknown-not-cancel`, `total-honest-not-cancel`, `falsified-not-cancel`, `dropped-honest-not-cancel`, `predicated-honest-not-cancel`, `severed-honest-not-cancel`, `Q-cancelʳ`. What Agda does *not* state is the exhaustive step: there is no Agda counterpart of `grade_leftCancel_iff`, and no Agda witness on the merge coordinate, which is why the ledger's Agda token for this row is `OPEN` rather than the row being Lean-only. | C3 (partition; tier closure is not a homomorphism) | `Dropped`, `Total`, `Severed`, `Predicated`, `Withheld`, `Fused` are honest non-cancellative elements; `Falsified`, `Misbound`, `Conflated`, `Unknown` are the deceptive ones. `tierOf (g ▷ h) = tierOf g ⊓ tierOf h` is false on fate; tier preservation is closure. @@ -124,7 +124,7 @@ toc::[] | Idris2 `Trope.Soundness.subSound`. | Verdict soundness (corollary) -| stem:[\mathrm{floor}(U) \sqsubseteq g \wedge g \sqsubseteq \rho \Rightarrow \mathrm{floor}(U) \sqsubseteq \rho]. +| stem:[f \sqsubseteq g \wedge g \sqsubseteq \rho \Rightarrow f \sqsubseteq \rho] for a *grade-shaped* floor stem:[f], which is how the source states it. It is not a statement about the use-model floor stem:[\mathrm{floor}(U)]: the shipped checker's floor is a partial per-coordinate demand, a different type decided by a different predicate, and no lemma connects the two (see _Modelling notes_). | Idris2 `Trope.Soundness.verdictSound`. | Grade soundness, β/let core diff --git a/scripts/pwg-check.sh b/scripts/pwg-check.sh index 51cab5d..c6b89aa 100755 --- a/scripts/pwg-check.sh +++ b/scripts/pwg-check.sh @@ -84,7 +84,13 @@ badr=$(jq -r ' (if ($v.result == "pass" or $v.result == "fail") then empty else "\($k): result must be pass|fail (8.2 -- the derivation reads it; an unrecognised value must not be treated as a pass)" end), (if ($v.evidence // "" | length) > 0 then empty else "\($k): no evidence pointer" end), (if ($v.state // "" | test("\\A(current|superseded|regressed)\\z")) then empty else "\($k): state must be current|superseded|regressed (8.4 rule 5)" end), - (if ($v | has("axioms")) then empty else "\($k): no axioms list (8.4 rule 6 — axioms travel with the grade)" end) ] + (if ($v | has("axioms")) then empty else "\($k): no axioms list (8.4 rule 6 — axioms travel with the grade)" end), + (($v.axiom_dispositions // {}) | to_entries[] + | select((.value | IN("c", "b", "debt")) | not) + | "\($k): disposition of \(.key) must be c|b|debt (8.5.1)"), + (($v.axiom_dispositions // {}) | keys[] as $n + | select((($v.axioms // []) | index($n)) == null) + | "\($k): disposition recorded for \($n), which the receipt does not report as an axiom") ] | .[]' "$LEDGER") \ || die "rule 3 (receipt completeness) could not be evaluated over this ledger: malformed theorem/leg/receipt shape" [ -n "$badr" ] && die "incomplete receipt(s):"$'\n'"$badr" diff --git a/scripts/pwg-derive.sh b/scripts/pwg-derive.sh index 20c50bc..396c61d 100755 --- a/scripts/pwg-derive.sh +++ b/scripts/pwg-derive.sh @@ -65,6 +65,28 @@ DERIVE=' | map(select(.state == "current" and .result == "pass" and (.commit | test("\\A[0-9a-f]{40}\\z")))) | length > 0; + # 2.1: every Agda entrypoint in the recorded invocation is the canonical one. + # The invocation may join several commands with ";". Each command that runs + # agda must be exactly: agda, the three flags as whole words, and one module. + # The earlier test searched the whole string for the three flag substrings, + # so one canonical command vouched for a second command that carried none of + # them, and any further option rode along unseen. Measured 2026-11-17: with + # the second entrypoint reduced to "agda Smoke.agda" the census did not move. + def canonical_agda: + [ split(";")[] | [splits("[[:space:]]+")] | map(select(length > 0)) | select(length > 0 and .[0] == "agda") ] + | length > 0 + and all(.[]; + (.[1:] | map(select(startswith("-"))) | sort) == ["--cubical-compatible", "--safe", "--without-K"] + and (.[1:] | map(select(startswith("-") | not)) | length) == 1); + + # 8.4 rule 6 and 8.5.1: a witness whose current receipt reports an axiom + # without disposition c does not count. Dispositions are recorded on the + # receipt as axiom_dispositions {name: c|b|debt}; an axiom with none recorded + # is not admissible (fail closed). A receipt reporting no axiom is admissible. + def axioms_admissible($rs): $rs + | map(select(.state == "current")) + | all(.[]; . as $r | all(($r.axioms // [])[]; ($r.axiom_dispositions // {})[.] == "c")); + # 8.2 PWG-3 additionally requires the receipt to record the checker version, # the standard-library pin, the flags actually in force, and the import cone (1.1). def pwg3_receipt($rs): $rs @@ -75,9 +97,7 @@ DERIVE=' and (.checker_version // "" | length > 0) and (.stdlib_pin // "" | length > 0) and (.import_cone // "" | length > 0) - and (.invocation // "" | test("--safe")) - and (.invocation // "" | test("--without-K")) - and (.invocation // "" | test("--cubical-compatible")) + and (.invocation // "" | canonical_agda) )) | length > 0; @@ -90,7 +110,20 @@ DERIVE=' ($leg.token | accepted) and $leg.state == "RECONCILED" and ($leg.route != "waived" and $leg.route != "unavailable") - and usable_receipt([$leg.receipts[] | $receipts[.]]); + and usable_receipt([$leg.receipts[] | $receipts[.]]) + and axioms_admissible([$leg.receipts[] | $receipts[.]]); + + # 8.3: the tag needs a kernel-checked witness whose statement correspondence + # is recorded as in 2.2. A witness is {token, state, receipts}; it earns the + # tag on the same terms a leg counts. The earlier test was "the field is not + # null", so any value at all -- a note, a plan -- published the tag. + def diverse($w; $receipts): + ($w | type) == "object" + and (($w.token // "") | accepted) + and $w.state == "RECONCILED" + and (($w.receipts // []) | length > 0) + and usable_receipt([$w.receipts[] | $receipts[.]]) + and axioms_admissible([$w.receipts[] | $receipts[.]]); # 8.2 PWG-1 / 8.5.2: a receipt DESCRIBES the source commit when its commit is # the source commit of the ledger. (8.5.2 also admits an echo chain to it; this @@ -109,7 +142,7 @@ DERIVE=' | ($t.legs.rocq) as $c | ($t.legs.lean) as $l | ([$a.receipts[] | $R[.]]) as $ar - | (($a.token | accepted) and $a.state == "AGDA-VERIFIED" and pwg3_receipt($ar)) as $agda_ok + | (($a.token | accepted) and $a.state == "AGDA-VERIFIED" and pwg3_receipt($ar) and axioms_admissible($ar)) as $agda_ok | (if counts($c; $R) then 1 else 0 end) as $nc | (if counts($l; $R) then 1 else 0 end) as $nl | ($nc + $nl) as $legs @@ -135,10 +168,15 @@ DERIVE=' kind: $t.kind, pwg: $grade, # 8.3: a non-DTT witness is a TAG beside the grade, never a leg. - foundation_diverse: (($t.foundation_diverse_witness // null) != null), + foundation_diverse: diverse($t.foundation_diverse_witness // null; $R), counting_legs: $legs, agda_receipt_complete: $agda_ok, - axioms: ([ $ar[]? | .axioms[]? ] | unique), + # 8.4 rule 6: the axioms of EVERY witness the grade stands on, not of the + # Agda leg alone. A counting Rocq or Lean leg used to contribute its + # count and none of its axioms. + axioms: ([ ($ar[]? | .axioms[]?), + (if counts($c; $R) then ($c.receipts[] | $R[.] | .axioms[]?) else empty end), + (if counts($l; $R) then ($l.receipts[] | $R[.] | .axioms[]?) else empty end) ] | unique), legs: { agda: {route: $a.route, token: $a.token, state: $a.state, counts: (counts($a; $R))}, rocq: {route: $c.route, token: $c.token, state: $c.state, counts: (counts($c; $R))}, diff --git a/scripts/test-gate-falsifiability.sh b/scripts/test-gate-falsifiability.sh index 4d7597f..77cd470 100755 --- a/scripts/test-gate-falsifiability.sh +++ b/scripts/test-gate-falsifiability.sh @@ -282,6 +282,16 @@ pwg_canaries() { pwg_case reject "a witness with a tab-joined suffix does not resolve" \ '(.theorems[] | select(.id == "L1") | .legs.agda.declarations) |= map(. + "\tjunk")' \ "resolve to no declaration" + + # 8.5.1: a disposition is c, b or debt. The derivation treats anything but c + # as inadmissible, so a typo would silently stop a leg counting; the gate must + # name it instead. Both FAIL against the gate before these checks existed. + pwg_case reject "an axiom disposition outside c|b|debt is rejected" \ + '.receipts["lean-boundary-c0eb4f1"].axiom_dispositions = {"propext": "C"}' \ + "must be c|b|debt" + pwg_case reject "a disposition for an axiom the receipt does not report is rejected" \ + '.receipts["lean-boundary-c0eb4f1"].axiom_dispositions = {"funext": "c"}' \ + "does not report as an axiom" } # --- the top of the ladder: PWG-2ii and PWG-1 are different rungs ---------- @@ -295,8 +305,9 @@ derive_case() { local want="$1" label="$2" commit="$3" d got d=$(scratch) if ! jq -cS --arg c "$commit" ' - .receipts["rocq-canary"] = (.receipts["lean-boundary-c0eb4f1"] + {commit: $c}) - | .receipts["lean-boundary-c0eb4f1"].commit = $c + (.receipts["lean-boundary-c0eb4f1"] + |= (. + {commit: $c, axiom_dispositions: (.axioms | map({key: ., value: "c"}) | from_entries)})) + | .receipts["rocq-canary"] = .receipts["lean-boundary-c0eb4f1"] | (.theorems[] | select(.id == "L1") | .legs) |= (.lean.state = "RECONCILED" | .rocq = {declarations: [], receipts: ["rocq-canary"], route: "re-proved", state: "RECONCILED", token: "PROVEN"})' \ @@ -315,6 +326,48 @@ ladder_canaries() { "$(printf '%040d' 0 | tr 0 f)" } +# --- what a grade stands on: axioms, the invocation, the diversity tag ------ +# Each canary edits the live ledger and reads one DERIVED field of L1. Measured +# 2026-11-17 against the pre-fix derivation: a leg reporting axioms with no +# recorded disposition counted (PWG-1); the derived axiom list was the Agda +# list alone; a second entrypoint with no flags, and an extra option, both kept +# PWG-3; and any non-null value published +foundation-diverse. The five +# non-control canaries FAIL against it. +field_case() { + # $1 = expected JSON value, $2 = label, $3 = jq edit of the ledger, $4 = jq read of the L1 row + local want="$1" label="$2" edit="$3" read="$4" d got + d=$(scratch) + if ! jq -cS "$edit" "$ROOT/verification/pwg.json" > "$d/pwg.json" 2>/dev/null; then + rm -rf "$d"; bad "$label (the canary's OWN jq transform failed)"; return + fi + got=$(bash "$ROOT/scripts/pwg-derive.sh" --ledger "$d/pwg.json" --json 2>/dev/null | jq -c ".[] | select(.id == \"L1\") | $read") + rm -rf "$d" + if [ "$got" = "$want" ]; then ok "$label"; else bad "$label (derived $got, expected $want)"; fi +} +standing_canaries() { + local both disp + # Both recheck legs of L1 made to count, receipts on the source commit. + both='(.theorems[] | select(.id == "L1") | .legs) |= + (.lean.state = "RECONCILED" + | .rocq = {declarations: [], receipts: ["lean-boundary-c0eb4f1"], route: "re-proved", state: "RECONCILED", token: "PROVEN-WITH-AXIOMS"}) + | .receipts["lean-boundary-c0eb4f1"].commit = .commit' + disp='.receipts["lean-boundary-c0eb4f1"] |= (. + {axiom_dispositions: (.axioms | map({key: ., value: "c"}) | from_entries)})' + field_case '"3"' "a leg whose receipt reports axioms with no disposition does not count" \ + "$both" '.pwg' + field_case '"3"' "a leg whose receipt reports an axiom of disposition debt does not count" \ + "$both | $disp | .receipts[\"lean-boundary-c0eb4f1\"].axiom_dispositions[\"Classical.choice\"] = \"debt\"" '.pwg' + field_case '["Classical.choice","Quot.sound","propext"]' "the derived axioms include those of every counting leg" \ + "$both | $disp" '.axioms' + field_case '"ungraded"' "an Agda entrypoint without the canonical flags ungrades the row" \ + '.receipts["agda-c0eb4f1"].invocation = "agda --safe --without-K --cubical-compatible All.agda ; agda Smoke.agda"' '.pwg' + field_case '"ungraded"' "an Agda entrypoint carrying an option outside the canonical three ungrades the row" \ + '.receipts["agda-c0eb4f1"].invocation = "agda --safe --without-K --cubical-compatible --allow-unsolved-metas All.agda"' '.pwg' + field_case 'false' "a foundation-diverse field that is not a checked witness earns no tag" \ + '(.theorems[] | select(.id == "L1")).foundation_diverse_witness = "Isabelle/HOL, planned"' '.foundation_diverse' + field_case 'true' "a reconciled, receipted non-DTT witness earns the tag (control)" \ + '(.theorems[] | select(.id == "L1")).foundation_diverse_witness = {token: "PROVEN", state: "RECONCILED", receipts: ["agda-c0eb4f1"]}' '.foundation_diverse' +} + # --- the comment stripper every dangerous-construct gate reads through ------ # Lean /- -/, Agda/Idris2 {- -} and Coq (* *) block comments NEST. Measured # 2026-11-16 against the pre-fix stripper: a forbidden word inside a nested @@ -341,6 +394,47 @@ strip_canaries() { rm -rf "$d" } +# --- the aspect lane (`just aspect`, tests/aspect_tests.sh) -------------------- +# Measured 2026-11-17 against the pre-fix tree: the Idris2 scan read +# src/interface/Abi/ only and dropped every hit containing "test", so a banned +# construct in src/idris2/Checker/ passed; a tree with no Idris2 at all passed; +# and the `aspect` recipe ran nothing and printed a pass. All three canaries +# FAIL against the pre-fix tree. The fixture word is assembled at runtime. +aspect_case() { + # $1 = scratch root already holding src/; copies the scan in and runs it. + mkdir -p "$1/tests/lib" + cp "$ROOT/tests/aspect_tests.sh" "$1/tests/" + cp "$ROOT/tests/lib/strip-proof-comments.awk" "$1/tests/lib/" + bash "$1/tests/aspect_tests.sh" >/dev/null 2>&1 +} +aspect_canaries() { + local d w body + w="believe""_me" + d=$(scratch); mkdir -p "$d/src/idris2/Checker" + printf -- '-- SPDX-License-Identifier: MPL-2.0\nmodule Checker.Selftest\nbad : a -> b\nbad = %s\n' "$w" > "$d/src/idris2/Checker/Selftest.idr" + if aspect_case "$d"; then + bad "a banned Idris2 construct outside src/interface/Abi, in a path containing 'test', passes the aspect scan" + else + ok "a banned Idris2 construct in any Idris2 source fails the aspect scan" + fi + rm -rf "$d" + d=$(scratch); mkdir -p "$d/src" + if aspect_case "$d"; then + bad "an aspect scan that read no Idris2 file reported a pass" + else + ok "an aspect scan that finds no Idris2 file fails" + fi + rm -rf "$d" + # The recipe body: every line after `aspect:` up to the next blank line. + body=$(awk '/^aspect:/{on=1; next} on && /^$/{exit} on' "$ROOT/Justfile") + if printf '%s\n' "$body" | grep -q 'tests/aspect_tests\.sh' \ + && ! printf '%s\n' "$body" | grep -qi 'echo.*passed'; then + ok "the aspect recipe runs the scan and prints no unconditional pass" + else + bad "the aspect recipe does not run tests/aspect_tests.sh, or prints a pass it did not earn" + fi +} + # --- META (R10 applied to R10): the suite must detect breakage in ITS OWN fixtures. # A canary whose jq program is broken writes an empty ledger; the gate then rejects # it for being invalid JSON rather than for the planted drift, and the canary passes @@ -367,12 +461,13 @@ meta_canary() { wellknown_canaries; valid_canary; live_canary c_weak_crypto; c_plaintext_http; c_secret -pwg_canaries; ladder_canaries; strip_canaries +pwg_canaries; ladder_canaries; standing_canaries; strip_canaries +aspect_canaries meta_canary echo # A canary group that silently stops running used to report "10/10" and exit 0. # The count is part of the claim. -EXPECTED_CASES=31 +EXPECTED_CASES=43 if [ "$((PASS+FAIL))" -ne "$EXPECTED_CASES" ]; then echo "gate falsifiability canaries: $((PASS+FAIL)) cases ran, $EXPECTED_CASES expected — a canary group did not run" exit 1 diff --git a/tests/aspect_tests.sh b/tests/aspect_tests.sh index 47cb0c3..b4ddd24 100755 --- a/tests/aspect_tests.sh +++ b/tests/aspect_tests.sh @@ -68,12 +68,41 @@ fi bold "Aspect 2: Dangerous patterns" # Idris2 dangerous patterns -DANGEROUS_IDRIS=$(grep -rn 'believe_me\|assert_total\|really_believe_me' src/interface/Abi/ 2>/dev/null | grep -v "^Binary" | grep -v "test" || true) -if [ -n "$DANGEROUS_IDRIS" ]; then +# +# Every Idris2 source under src/ and verification/, with comments stripped. +# The previous form scanned src/interface/Abi/ only (3 of the 16 files) and +# piped the matches through `grep -v "test"`, which dropped any hit whose PATH +# or text contained "test". Both made the scan pass on code it never read. +# A scan that finds no Idris2 file at all fails: nothing read, nothing passes. +IDRIS_STRIP_LOG="${TMPDIR:-/tmp}/aspect-idris-strip-failed.$$" +IDRIS_COUNT_LOG="${TMPDIR:-/tmp}/aspect-idris-count.$$" +: > "$IDRIS_COUNT_LOG" +DANGEROUS_IDRIS=$( + while IFS= read -r f; do + printf '%s\n' "$f" >> "$IDRIS_COUNT_LOG" + if ! stripped=$(awk -f tests/lib/strip-proof-comments.awk "$f"); then + printf '%s\n' "$f" >> "$IDRIS_STRIP_LOG" + continue + fi + printf '%s\n' "$stripped" \ + | grep -nE '\b(believe_me|really_believe_me|assert_total|assert_smaller|unsafePerformIO|idris_crash)\b|^[[:space:]]*postulate\b' \ + | sed "s|^|$f:|" || true + done < <(find src verification -type f -name '*.idr' 2>/dev/null | sort || true) +) +IDRIS_FILES=$(wc -l < "$IDRIS_COUNT_LOG" | tr -d ' ') +rm -f "$IDRIS_COUNT_LOG" +if [ -f "$IDRIS_STRIP_LOG" ]; then + fail "Comment stripper could not scan these Idris2 files (truncated input, not a clean scan):" + head -5 "$IDRIS_STRIP_LOG" + rm -f "$IDRIS_STRIP_LOG" +fi +if [ "$IDRIS_FILES" -eq 0 ]; then + fail "No Idris2 source found under src/ or verification/: nothing was scanned" +elif [ -n "$DANGEROUS_IDRIS" ]; then fail "Dangerous Idris2 patterns found:" echo "$DANGEROUS_IDRIS" | head -5 else - pass "No dangerous Idris2 patterns (believe_me, assert_total)" + pass "No dangerous Idris2 patterns in $IDRIS_FILES file(s) (believe_me, assert_total, assert_smaller, unsafePerformIO, idris_crash, postulate)" fi # Coq/Lean dangerous patterns diff --git a/verification/proofs/lean4/grade-factorisation/README.adoc b/verification/proofs/lean4/grade-factorisation/README.adoc index 0d8c94a..9c12cda 100644 --- a/verification/proofs/lean4/grade-factorisation/README.adoc +++ b/verification/proofs/lean4/grade-factorisation/README.adoc @@ -12,9 +12,14 @@ sharing that build through a symlinked `.lake/packages`. == Verdict -*(B) FACTORS but VERIDICALITY-BLIND.* A nontrivial monoid homomorphism `π : Grade → Δ` -onto the commutative fidelity carrier exists, but *every* such map is forced to identify -the honest `dropped` with the deceptive `falsified`. Tropical captures the *fidelity* +*(B) FACTORS but VERIDICALITY-BLIND, on the pre-ratification carrier.* A nontrivial +monoid homomorphism `π : Grade → Δ` onto the commutative fidelity carrier exists, but on +that carrier *every* such map is forced to identify the honest `dropped` with the +deceptive `falsified` (`forced_collapse_general`, stated over the pre-ratification +`Fate.comp`). On the *ratified* carrier (ADR 0004, R-2026-07-07) this no longer holds: +`GradeFactorisationR.lean` exhibits a homomorphism that separates them (`phiR_sighted`, +`piR_sighted`), verdict *(B′) FACTORS AND VERIDICALITY-SIGHTED*. The rest of this +paragraph describes the pre-ratification result. Tropical captures the *fidelity* sub-grade only; specifically the *fate-axis* honest/deceptive distinction needs separate, non-tropical handling, while the commutative `Bond`/`Merge` deceptions stay tropically separable. The blindness is co-located exactly with the non-commutativity. See @@ -32,6 +37,10 @@ addressed; that stays parked behind an operational model (CO-1). See the firelin (D2), nontriviality (D3), the forced-collapse impossibility (D4), complement/F2 confinement (D5), falsifier harness (D6), and an axiom audit. +| `GradeFactorisationR.lean` | The re-run on the ratified carrier (R-2026-07-07): the + sighted homomorphism (`phiR_sighted`, `piR_sighted`) and + the naive-candidate breaker (`phiId_not_hom`). Built and + asserted by `just falsify`. | `REPORT.adoc` | The three-way verdict, witnesses, and the necessary-not- sufficient guard verbatim. | `justfile` | `just build`, `just falsify`, `just axioms`, `just verdict`. diff --git a/verification/proofs/lean4/grade-factorisation/REPORT.adoc b/verification/proofs/lean4/grade-factorisation/REPORT.adoc index a736be5..0e0b91e 100644 --- a/verification/proofs/lean4/grade-factorisation/REPORT.adoc +++ b/verification/proofs/lean4/grade-factorisation/REPORT.adoc @@ -327,9 +327,14 @@ exactly what was impossible for the fate axis before. === Axiom audit -All re-run theorems depend on at most `propext`, `Classical.choice`, -`Quot.sound` — no `sorryAx`, no user axiom, no `native`-evaluator `decide` -bypass. `just falsify` additionally asserts `piR_sighted` and `phiId_not_hom` +All re-run theorems depend on at most `propext` and `Quot.sound` — no +`sorryAx`, no `Classical.choice`, no user axiom, no `native`-evaluator `decide` +bypass. This is the same bound as the audit above, and it is measured: the CI +axiom audit over both modules of this package reported exactly `propext` and +`Quot.sound` across 184 declarations (trope-checker run 43981767344, commit +`7b71c31`). The allowlist that audit enforces also admits `Classical.choice`, +because it is shared with `grade-boundary`, where three theorems use it; an +earlier version of this paragraph quoted the allowlist as if it were the result. `just falsify` additionally asserts `piR_sighted` and `phiId_not_hom` are live verified theorems. === Reproduction