diff --git a/.github/workflows/coq-proof-gate.yml b/.github/workflows/coq-proof-gate.yml index b3a156d8..eec87ab5 100644 --- a/.github/workflows/coq-proof-gate.yml +++ b/.github/workflows/coq-proof-gate.yml @@ -143,27 +143,56 @@ jobs: # Coq job: the recipe fails if `agda` is absent, and every `*.agda` under # formal/agda/ is checked without being listed. # - # NOT the estate's pinned Agda. The proof lanes pin Agda 2.7.0.1 (mathesis - # `agda-proof-policy.yml`); this job runs Ubuntu 24.04's `agda-bin`, 2.6.3, - # and asserts that version so a silent package change fails the job. A run - # here is a real check under the canonical flags but is not receipt-grade. - # Provisioning 2.7.0.1 is an open owner decision (formal/agda/README.adoc). + # The estate's pinned Agda, 2.7.0.1 (mathesis `agda-proof-policy.yml`, + # AGDA_VERSION): the official static Linux binary from the agda/agda v2.7.0.1 + # release, verified against a SHA-256 pinned here before it is unpacked. + # The usability check from `--cubical` uses agda/cubical v0.8 (the last + # release supporting 2.7.0.1), fetched by commit SHA and asserted. + # A green run is a real check on the pinned version; it is still not a + # receipt (no recorded receipt, no Lean leg — formal/agda/README.adoc). agda-proofs: runs-on: ubuntu-24.04 - timeout-minutes: 15 + timeout-minutes: 20 defaults: run: shell: bash env: - AGDA_CI_VERSION: "2.6.3" + AGDA_CI_VERSION: "2.7.0.1" + AGDA_TARBALL_URL: "https://github.com/agda/agda/releases/download/v2.7.0.1/Agda-v2.7.0.1-linux.tar.xz" + AGDA_TARBALL_SHA256: "975b515a14877ab6bce5bfc641e16c4a3ee52ca5d7f846577dee80aa2145db8a" + CUBICAL_REPO: "https://github.com/agda/cubical" + CUBICAL_COMMIT: "3291fc1d8cae1409cc54d4f9cca7366158b573d7" # tag v0.8 steps: - uses: actions/checkout@v7.0.1 - - name: Install Agda and just (Ubuntu packages) + - name: Install just (Ubuntu package) run: | set -euo pipefail sudo apt-get update -qq - sudo apt-get install -y -qq agda-bin just + sudo apt-get install -y -qq just + + - name: Install Agda 2.7.0.1 (release binary, SHA-256 pinned) + run: | + set -euo pipefail + d="$RUNNER_TEMP/agda-dl"; mkdir -p "$d" + curl -fsSL --proto =https --proto-redir =https --retry 3 -o "$d/agda.tar.xz" "$AGDA_TARBALL_URL" + echo "${AGDA_TARBALL_SHA256} $d/agda.tar.xz" | sha256sum -c - + tar -xJf "$d/agda.tar.xz" -C "$RUNNER_TEMP" + root="$RUNNER_TEMP/Agda-v${AGDA_CI_VERSION}" + echo "$root/bin" >> "$GITHUB_PATH" + # The static binary's built-in data dir is the release builder's + # path; point it at the unpacked primitives. + echo "Agda_datadir=$root/data" >> "$GITHUB_ENV" + + - name: Fetch agda/cubical v0.8 (by commit SHA) + run: | + set -euo pipefail + c="$RUNNER_TEMP/cubical" + git init -q "$c" + git -C "$c" fetch -q --depth 1 "$CUBICAL_REPO" "$CUBICAL_COMMIT" + git -C "$c" checkout -q FETCH_HEAD + test "$(git -C "$c" rev-parse HEAD)" = "$CUBICAL_COMMIT" + echo "CUBICAL_DIR=$c" >> "$GITHUB_ENV" - name: Record and assert the prover version run: | @@ -177,3 +206,9 @@ jobs: - name: Planted controls — each must fail the gate run: just -f formal/justfile check-agda-controls + + - name: Usability from --cubical (agda/cubical v0.8) + run: just -f formal/justfile check-agda-cubical + + - name: Planted controls — each must fail the --cubical check + run: just -f formal/justfile check-agda-cubical-controls diff --git a/.gitignore b/.gitignore index 857aa43a..ddd90b77 100644 --- a/.gitignore +++ b/.gitignore @@ -126,3 +126,5 @@ tools/vendor/ /affinescript-router/e2e/node_modules/ /tests/codegen-bun/collision/*.log /tests/codegen-bun/collision/*.bun.js +# Agda >= 2.7 interface cache next to an .agda-lib +formal/agda-cubical/_build/ diff --git a/formal/agda-cubical/CubicalCompat.agda b/formal/agda-cubical/CubicalCompat.agda new file mode 100644 index 00000000..78420f0a --- /dev/null +++ b/formal/agda-cubical/CubicalCompat.agda @@ -0,0 +1,51 @@ +{-# OPTIONS --safe --cubical #-} +-- SPDX-License-Identifier: MPL-2.0 +-- SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell (hyperpolymath) +-- +-- CubicalCompat.agda +-- ══════════════════ +-- Usability witness: the `formal/agda/` theory sources, which are checked +-- under the estate's canonical `--safe --without-K --cubical-compatible`, +-- import cleanly into a FULL `--cubical` development built on the agda/cubical +-- library (v0.8, the last release supporting Agda 2.7.0.1), and their +-- theorems are usable there as cubical paths. +-- +-- This module proves nothing new about AffineScript. It is a compatibility +-- fixture: if either source loses `--cubical-compatible`, or starts using a +-- construct `--cubical` rejects, this module stops checking. +-- +-- Checked by `just -f formal/justfile check-agda-cubical`. + +module CubicalCompat where + +open import Cubical.Foundations.Prelude using (Type; Path) +open import Cubical.Data.Equality.Conversion using (eqToPath; pathToEq) +open import Agda.Builtin.Maybe using (Maybe; nothing) +import Agda.Builtin.Equality as Eq + +import QttSemiring as Q +import BorrowProvenance as B + +-- Re-exported unchanged, in their inductive-equality (`Agda.Builtin`) form. +open Q public using (qplus-comm; qof-plus) +open B public using (safety; stuck-rejected; K1-rejected-by-theorem) + +-- QttSemiring, as a cubical path … +qplus-comm-path : ∀ p q → Path Q.quant (Q.qplus p q) (Q.qplus q p) +qplus-comm-path p q = eqToPath (Q.qplus-comm p q) + +-- … and as a path between FUNCTIONS. Function extensionality is not +-- available under `--without-K` alone; in cubical Agda it is a lambda over +-- the interval. This is the use a `--cubical` client gets that the source +-- cannot state itself. +qplus-flip-path : Path (Q.quant → Q.quant → Q.quant) Q.qplus (λ p q → Q.qplus q p) +qplus-flip-path i p q = qplus-comm-path p q i + +-- The round trip lands back on the original theorem (inductive equality). +qplus-comm-roundtrip : ∀ p q → Q.qplus p q Eq.≡ Q.qplus q p +qplus-comm-roundtrip p q = pathToEq (qplus-comm-path p q) + +-- BorrowProvenance: the K-1 (#554) verdict obtained from the rejection +-- theorem, as a cubical path. +K1-rejected-path : Path (Maybe B.CState) (B.chk B.initC B.K1) nothing +K1-rejected-path = eqToPath B.K1-rejected-by-theorem diff --git a/formal/agda-cubical/affinescript-cubical-compat.agda-lib b/formal/agda-cubical/affinescript-cubical-compat.agda-lib new file mode 100644 index 00000000..9690ad15 --- /dev/null +++ b/formal/agda-cubical/affinescript-cubical-compat.agda-lib @@ -0,0 +1,5 @@ +-- SPDX-License-Identifier: MPL-2.0 +-- SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell (hyperpolymath) +name: affinescript-cubical-compat +include: . ../agda +depend: cubical-0.8 diff --git a/formal/agda/BORROW-PROVENANCE-EXPERIMENT.adoc b/formal/agda/BORROW-PROVENANCE-EXPERIMENT.adoc index 2d3b3e4b..57efdece 100644 --- a/formal/agda/BORROW-PROVENANCE-EXPERIMENT.adoc +++ b/formal/agda/BORROW-PROVENANCE-EXPERIMENT.adoc @@ -387,8 +387,11 @@ implemented refuted on three programs.* One result of each kind. [#controls] == What was run -All under Agda 2.6.3 (Ubuntu 24.04 `agda-bin`). The pinned 2.7.0.1 was not -available, so these are checks and not receipt-grade runs. +All under Agda 2.6.3 (Ubuntu 24.04 `agda-bin`); the two gate runs below were +repeated unchanged on the pinned Agda 2.7.0.1 (release binary) on 2026-12-01 +with the same result, and the module also imports into a `--safe --cubical` +module (`formal/agda-cubical/`, see `README.adoc`). The nine mutations were +run on 2.6.3 only. No receipt exists, so none of this is receipt-grade. * `just -f formal/justfile check-agda`: 2 modules, exit 0, no warning. * `just -f formal/justfile check-agda-controls`: all 5 planted controls fail diff --git a/formal/agda/README.adoc b/formal/agda/README.adoc index 1cc991ce..fa726877 100644 --- a/formal/agda/README.adoc +++ b/formal/agda/README.adoc @@ -22,14 +22,16 @@ file, checked from this directory. | `QttSemiring.agda` | The QTT quantity semiring `{0, 1, ω}`: 21 statements, the same as `formal/QttSemiring.v` (obligation P-4) -| Checks clean under the canonical flags on Agda 2.6.3. *Not yet checked on - the pinned Agda 2.7.0.1.* No Lean leg. No receipt. So still `ungraded`. +| Checks clean under the canonical flags on the pinned Agda 2.7.0.1 (and on + 2.6.3); imports into a `--safe --cubical` module. No Lean leg. No receipt. + So still `ungraded`. | `BorrowProvenance.agda` | *Experiment* (#553, ADR-028 option G): on a toy reference calculus, the checker's tracked loan set contains the provenance fibre for every program in the second-class cut D; exclusivity and rejection for D+R4 -| Checks clean under the canonical flags on Agda 2.6.3. A toy model, not +| Checks clean under the canonical flags on the pinned Agda 2.7.0.1 (and on + 2.6.3); imports into a `--safe --cubical` module. A toy model, not `lib/borrow.ml`. No Rocq or Lean leg, no receipt: `ungraded`. Record: `BORROW-PROVENANCE-EXPERIMENT.adoc`. |=== @@ -40,6 +42,9 @@ file, checked from this directory. ---- just -f formal/justfile check-agda # the gate just -f formal/justfile check-agda-controls # five planted failures; each must fail the gate +# usability from full --cubical; needs an agda/cubical checkout at v0.8: +CUBICAL_DIR=/path/to/cubical just -f formal/justfile check-agda-cubical +CUBICAL_DIR=/path/to/cubical just -f formal/justfile check-agda-cubical-controls ---- The gate fails when `agda` is missing, when a module lacks the canonical @@ -47,9 +52,63 @@ pragma, contains `postulate`, exits non-zero, or prints anything but `Checking` lines (so a warning fails). Every `*.agda` under this directory is checked; nothing is listed by hand. -CI runs both recipes in the `agda-proofs` job of -`.github/workflows/coq-proof-gate.yml`, on Ubuntu 24.04's `agda-bin` package -(Agda 2.6.3). +CI runs all four recipes in the `agda-proofs` job of +`.github/workflows/coq-proof-gate.yml`, on the pinned toolchain below. + +=== Pinned toolchain + +[cols="2,5",options="header"] +|=== +| Component | Pin + +| Agda +| 2.7.0.1, the official static Linux binary + `Agda-v2.7.0.1-linux.tar.xz` from the agda/agda `v2.7.0.1` release + (tag object `f24f2aaf…`, commit `a6fc20c27ae953149b53a8997ba4a1c8b17d628a`). + SHA-256 `975b515a14877ab6bce5bfc641e16c4a3ee52ca5d7f846577dee80aa2145db8a`; + CI verifies it before unpacking. The binary's built-in data directory is + the release builder's path, so `Agda_datadir` must point at the unpacked + `data/`. + +| agda/cubical +| `v0.8`, commit `3291fc1d8cae1409cc54d4f9cca7366158b573d7` (library name + `cubical-0.8`). Its README's compatibility table pairs v0.8 with Agda + 2.6.4.1 and 2.7.0.1; v0.9 (the latest tag, `b150186d…`) and `master` + require Agda 2.8.0, so v0.8 is the latest release usable with the pin. + CI fetches it by commit SHA and asserts `HEAD`. Used only by the + `--cubical` usability check; the theory sources import no library. +|=== + +=== Usability from `--cubical` + +`formal/agda-cubical/CubicalCompat.agda` is a `--safe --cubical` module, in +its own library (`affinescript-cubical-compat`, `depend: cubical-0.8`), that +imports every module under this directory. It re-exports one or more theorems +of each unchanged, then uses them as cubical paths through the library's +`eqToPath` / `pathToEq`: + +* `qplus-comm-path` — `QttSemiring.qplus-comm` as a `Path`; +* `qplus-flip-path` — a `Path` between the *functions* `qplus` and its flip: + function extensionality, which `--without-K` alone does not give; +* `qplus-comm-roundtrip` — back to the inductive `_≡_`; +* `K1-rejected-path` — `BorrowProvenance.K1-rejected-by-theorem` (the #554 + verdict from the rejection theorem) as a `Path`. + +`check-agda-cubical` fails if any module under this directory is not imported +by the fixture, so a new theory module must join it. Its controls show the +check is load-bearing: a source whose pragma drops `--cubical-compatible` +(keeping `--safe --without-K`) is refused by Agda with "Importing module +QttSemiring not using the --cubical-compatible flag from a module which +does", and a source with K available is refused for `--without-K` as well. + +Decision: the sources stay at the canonical `--cubical-compatible`; nothing +was ported to full `--cubical`. `--cubical-compatible` is what makes a module +importable from cubical developments, so usability is proved by the import +rather than bought by changing the lane. Porting would move the modules out +of the PROOF-POLICY theory lane, add a library to their import cone, and cut +the Rocq and Lean legs for any statement using a cubical primitive (see the +comparison under "Extrapolation" below). A cubical client gets paths and +funext over these theorems for free, as the fixture shows. == What is and is not established @@ -67,17 +126,37 @@ Established, by runs in this session (2026-12-01, container Ubuntu 24.04): definitions. A mutated table entry made the Agda check fail. * The gate fails on each of five planted controls. +Established on the pinned Agda 2.7.0.1 (a later session, 2026-12-01, same +container image; toolchain pinned as in the table above): + +* Both modules, unchanged, check with exit 0 and *no* output other than + `Checking` lines under `agda --safe --without-K --cubical-compatible` + (`check-agda`). No repair was needed; no statement or proof text changed. + Neither draws `UnsupportedIndexedMatch` on 2.7.0.1. +* `check-agda-controls`: all five planted controls still fail the gate on + 2.7.0.1; the `indexed` control fails for the intended reason (2.7.0.1 + prints `-W[no]UnsupportedIndexedMatch` and exits 0, and the gate rejects + the output). +* `check-agda-cubical`: `CubicalCompat.agda` checks against agda/cubical + v0.8 with exit 0 and no diagnostic, loading both sources; + `check-agda-cubical-controls`: all five controls fail it. +* All four recipes were replayed from a fresh download and a fresh cubical + fetch, exactly as the CI job runs them. + Not established: -* *The pinned Agda 2.7.0.1.* It could not be installed in the session. The - official release binary was downloaded (SHA-256 - `975b515a14877ab6bce5bfc641e16c4a3ee52ca5d7f846577dee80aa2145db8a`, taken - from the download itself and not checked against an independent record), - but the session's permission policy refused to run it. A build from Hackage - failed because `cabal-install` 3.8.1 (Ubuntu) no longer verifies Hackage's - root keys; building around that check was refused too, correctly. So the - result above is a real check on a different Agda version, and it is *not* - receipt-grade. +* *An independent record of the Agda binary's digest.* The SHA-256 above was + computed from the download (twice, identical) and is pinned in CI from + then on (trust on first use). It was not compared with a digest published + by the Agda project: the release page and API were not reachable from the + session. Anyone with access can confirm it against the release asset's + `digest` field on GitHub. (An earlier session's attempt to build 2.7.0.1 + from Hackage failed on `cabal-install` 3.8.1's root-key check; this + session used the release binary instead.) +* *The nine `BorrowProvenance` mutations* were run on 2.6.3 only, not + repeated on 2.7.0.1 (they are not scripted). +* *CI on the pin.* The job was replayed locally; its first GitHub Actions + run is on the PR that introduced it. * *A Lean leg.* Lean 4.15.0 and 4.13.0 were downloaded and their SHA-256 digests match the ones `docs/COMPLETION-PLAN.adoc` §5.0 records (`af71a256…`, `44ceeac7…`), but running them was refused in this session. @@ -324,8 +403,10 @@ What drives the uncertainty, largest first: . *The prelude.* No stdlib means ℕ and list lemmas are re-proved. `lia` is used only 4 times across the seven files, so this is bounded, but `QttDynamic`'s one `lia` closes 27 cases at once. -. *The pinned version.* Nothing here has run on Agda 2.7.0.1. Unification and - warning behaviour changed between 2.6.3 and 2.7; the files may need edits. +. *The pinned version.* The two committed modules needed no edit on Agda + 2.7.0.1. The probe files above were measured on 2.6.3 only; unification and + warning behaviour changed between 2.6.3 and 2.7, so further files may still + need edits. . *The other two legs.* Each Agda source also needs its statement comparison with the Rocq leg and a new Lean leg (no Mathlib). The Lean leg was not measured at all. @@ -404,9 +485,11 @@ and the cross-prover comparison. | Measured (Agda 2.6.3): the committed module checks unchanged with its pragma replaced by `--safe --cubical`, because it uses only the inductive `_≡_`. `--cubical` does not remove F1: the direct indexed match draws the same - `UnsupportedIndexedMatch` warning under `--safe --cubical`. Not measured: - restating the laws over `Path`, which is what a cubical development would - actually use, and which needs the two equalities bridged. + `UnsupportedIndexedMatch` warning under `--safe --cubical`. Measured on + Agda 2.7.0.1 with agda/cubical v0.8: the bridge works without restating + anything — `CubicalCompat.agda` turns the `_≡_` theorems into `Path`s with + the library's `eqToPath`, including a funext path. Not measured: proofs + written natively over `Path`. | Other legs | Rocq and Lean state the same thing. @@ -475,10 +558,11 @@ admission record and any shared grade signature are estate-level items. == Open decisions for the owner -. How to provision the pinned Agda 2.7.0.1 for this repository's CI: the - mathesis route (Guix time-machine with its `build/channels.scm`), or the - checksum-pinned official release binary. Until then the CI job runs - Agda 2.6.3 and says so. +. _Decided 2026-12-01:_ provisioning of the pinned Agda 2.7.0.1. The owner + asked for 2.7.0.1 plus the latest compatible agda/cubical; CI now uses the + checksum-pinned official release binary. The mathesis route (Guix + time-machine with its `build/channels.scm`) remains the alternative if the + estate wants one provisioning path for every lane. . Whether `UnsupportedIndexedMatch` fails the gate (as here) or passes (as in mathesis's `check-proofs.sh`). . Whether to port the remaining theory files as they stand, or first repair diff --git a/formal/justfile b/formal/justfile index 3d20b6a7..34432a46 100644 --- a/formal/justfile +++ b/formal/justfile @@ -27,7 +27,8 @@ check: # Remove Coq build artifacts. clean: rm -f *.vo *.vok *.vos *.glob .*.aux .coqdeps.d - find agda -name "*.agdai" -delete + find agda agda-cubical -name "*.agdai" -delete + rm -rf agda-cubical/_build # ── Agda (theory source of truth, PROOF-POLICY §1) ────────────────────────── # The Agda version the estate proof lanes pin (mathesis @@ -99,3 +100,82 @@ check-agda-controls: echo "control '$c': gate failed as it must ($(grep -m1 -o '::error.*' "$t/$c.log" | cut -c1-90))" done echo "OK: all 5 planted controls fail the Agda gate." + +# ── Agda: usability from a full `--cubical` development ───────────────────── +# The agda/cubical release this check pins. v0.8 is the last release that +# supports Agda 2.7.0.1 (its README table: v0.8 ↔ 2.6.4.1 / 2.7.0.1; v0.9 needs +# 2.8.0). Tag v0.8 = commit 3291fc1d8cae1409cc54d4f9cca7366158b573d7. +cubical_tag := "v0.8" +cubical_commit := "3291fc1d8cae1409cc54d4f9cca7366158b573d7" + +# Check `agda-cubical/CubicalCompat.agda` — a `--safe --cubical` module that +# imports every theory source under SRC (default `agda/`) through the +# agda/cubical library. CUBICAL is a git checkout of agda/cubical at exactly +# `cubical_commit` (env `CUBICAL_DIR`). Fail-closed: a missing agda, a wrong +# Agda version (cubical v0.8 does not support others), a missing or wrong +# cubical checkout, a source module the fixture does not import, a postulate, +# or any diagnostic other than `Checking` lines fails the recipe. +check-agda-cubical SRC="agda" COMPAT="agda-cubical" CUBICAL=env_var_or_default("CUBICAL_DIR", ""): + #!/usr/bin/env bash + set -euo pipefail + export LC_ALL=C.UTF-8 + cd "{{justfile_directory()}}" + command -v agda >/dev/null || { echo "::error:: agda is not installed — the gate cannot run, so it fails"; exit 1; } + ver="$(agda --version | head -1)"; echo "$ver" + [ "$ver" = "Agda version {{agda_pin}}" ] || { echo "::error:: cubical {{cubical_tag}} needs Agda {{agda_pin}}; got '$ver'"; exit 1; } + cub="{{CUBICAL}}" + [ -n "$cub" ] && [ -f "$cub/cubical.agda-lib" ] || { echo "::error:: CUBICAL_DIR must point at an agda/cubical checkout (got '$cub')"; exit 1; } + head="$(git -C "$cub" rev-parse HEAD 2>/dev/null || true)" + [ "$head" = "{{cubical_commit}}" ] || { echo "::error:: agda/cubical checkout is at '$head', not {{cubical_tag}} = {{cubical_commit}}"; exit 1; } + grep -qx 'name: cubical-0.8' "$cub/cubical.agda-lib" || { echo "::error:: $cub/cubical.agda-lib is not cubical-0.8"; exit 1; } + fx="{{COMPAT}}/CubicalCompat.agda" + [ -f "$fx" ] || { echo "::error:: $fx missing"; exit 1; } + [ "$(head -1 "$fx")" = '{-# OPTIONS --safe --cubical #-}' ] || { echo "::error file=$fx:: first line is not '{-# OPTIONS --safe --cubical #-}'"; exit 1; } + if perl -0pe 's/\{-.*?-\}//gs; s/--.*$//gm' "$fx" | grep -qw postulate; then echo "::error file=$fx:: contains a postulate"; exit 1; fi + n=0 + while IFS= read -r m; do + n=$((n+1)); name="$(basename "$m" .agda)" + grep -qE "^import +$name( |$)" "$fx" || { echo "::error file=$fx:: does not import $name — every module under {{SRC}} must be shown usable from --cubical"; exit 1; } + done < <(find "{{SRC}}" -name '*.agda' | LC_ALL=C sort) + [ "$n" -gt 0 ] || { echo "::error:: no Agda module under {{SRC}}"; exit 1; } + ad="$(mktemp -d)"; trap 'rm -rf "$ad"' EXIT + printf '%s\n' "$(cd "$cub" && pwd)/cubical.agda-lib" > "$ad/libraries" + find "{{SRC}}" "{{COMPAT}}" -name '*.agdai' -delete; rm -rf "{{COMPAT}}/_build" "{{SRC}}/_build" + echo "== agda (AGDA_DIR → cubical {{cubical_tag}}) $fx ==" + set +e + out="$(cd "{{COMPAT}}" && AGDA_DIR="$ad" agda CubicalCompat.agda 2>&1)"; rc=$? + set -e + printf '%s\n' "$out" | grep -vE '^ +Checking (Cubical|Agda)\.' || true + if [ "$rc" -ne 0 ]; then echo "::error file=$fx:: agda exited $rc"; exit 1; fi + if printf '%s\n' "$out" | grep -qvE '^ *(Checking|Finished) |^$'; then echo "::error file=$fx:: agda printed a warning or other diagnostic"; exit 1; fi + echo "OK: $n theory module(s) under {{SRC}} import into a --safe --cubical module (agda/cubical {{cubical_tag}}, Agda {{agda_pin}})." + +# Planted controls for `check-agda-cubical`: each must make it FAIL. Run on a +# scratch copy of `agda/` + `agda-cubical/` with one fault planted. +check-agda-cubical-controls CUBICAL=env_var_or_default("CUBICAL_DIR", ""): + #!/usr/bin/env bash + set -euo pipefail + here="{{justfile_directory()}}" + t="$(mktemp -d)"; trap 'rm -rf "$t"' EXIT + mk() { mkdir -p "$t/$1"; cp -r "$here/agda" "$here/agda-cubical" "$t/$1/"; rm -rf "$t/$1/agda-cubical/_build"; find "$t/$1" -name '*.agdai' -delete; } + # 1. a theory source loses --cubical-compatible (keeps --safe --without-K) + mk nocc; sed -i '1s/.*/{-# OPTIONS --safe --without-K #-}/' "$t/nocc/agda/QttSemiring.agda" + # 2. a theory source with no flags at all (K available) + mk nok; sed -i '1s/.*/{-# OPTIONS --safe #-}/' "$t/nok/agda/QttSemiring.agda" + # 3. a new theory module the fixture does not import + mk unused; printf '%s\n' '{-# OPTIONS --safe --without-K --cubical-compatible #-}' 'module Extra where' > "$t/unused/agda/Extra.agda" + # 4. the fixture is not --cubical + mk notcub; sed -i '1s/.*/{-# OPTIONS --safe --without-K #-}/' "$t/notcub/agda-cubical/CubicalCompat.agda" + for c in nocc nok unused notcub; do + if just -f "{{justfile()}}" check-agda-cubical "$t/$c/agda" "$t/$c/agda-cubical" "{{CUBICAL}}" >"$t/$c.log" 2>&1; then + echo "::error:: control '$c' PASSED check-agda-cubical — the gate is broken"; cat "$t/$c.log"; exit 1 + fi + why="$(grep -m1 -oE 'Importing module [^ ]+ not using the [^ ]+' "$t/$c.log" || grep -m1 -o '::error.*' "$t/$c.log")" + echo "control '$c': failed as it must (${why:0:110})" + done + # 5. no cubical checkout + if just -f "{{justfile()}}" check-agda-cubical agda agda-cubical "/nonexistent" >"$t/nocub.log" 2>&1; then + echo "::error:: control 'nocub' PASSED — the gate is broken"; exit 1 + fi + echo "control 'nocub': failed as it must ($(grep -m1 -o '::error.*' "$t/nocub.log" | cut -c1-90))" + echo "OK: all 5 planted controls fail check-agda-cubical."