# SPDX-License-Identifier: MPL-2.0 # The Agda proof gate. Pattern: choreographic-types .github/workflows/proofs.yml, # a digest-pinned Debian 13 container with the prover apt-pinned to one # package version. The development uses Agda builtins only, so neither the # standard library nor any sibling is fetched. # # Every `uses:` is a full commit SHA with its tag in a comment, and the lock # record lives in .github/workflows/actions.lock (scripts/check-lock-sync.sh). name: Agda proofs on: push: branches: [main] pull_request: workflow_dispatch: permissions: contents: read # Container jobs default to `sh`, not `bash` (measured 2026-11-01: PIPESTATUS and # ${var:0:n} are bashisms, and a dash shell exits 2 on both). Declare it. defaults: run: shell: bash concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: LANG: C.UTF-8 LC_ALL: C.UTF-8 # The commit a receipt names (PROOF-POLICY §8.2, PWG-1: "on the exact source # commit"). On a pull request this is the head of the branch, not the # merge commit GitHub would check out by default, because the merge commit # is not on any branch and a receipt that names it cannot be reproduced. SOURCE_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }} jobs: proofs: name: Core proofs, countermodels, expected rejections, minimal-laws certificate runs-on: ubuntu-24.04 timeout-minutes: 30 container: debian:13-slim@sha256:a29215f6a35e51e22adffa17f89e9d2ef06214e64a2bad10d765c46aea49f11f outputs: row: ${{ steps.row.outputs.row }} steps: # git is installed so that the checkout is a real clone and the commit # under test can be read back, not assumed. - name: Install the pinned prover run: | apt-get update apt-get install --no-install-recommends -y ca-certificates git agda-bin=2.6.4.3-1+b2 - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ env.SOURCE_COMMIT }} persist-credentials: false # actions/checkout marks the workspace as a safe directory only under a # temporary HOME, so in this container a later git call refuses the # clone ("dubious ownership"; run 43447816480). Mark it for this job. - name: Verify the checked Agda version and the commit under test run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" test "$(agda --version)" = 'Agda version 2.6.4.3' test "$(git rev-parse HEAD)" = "$SOURCE_COMMIT" # The gate surfaces its own failure twice: once in the log, and once as a # check annotation. The annotation matters because the job log is not # always reachable (GitHub serves it from a blob host that some agent # sandboxes cannot fetch), and a gate nobody can read is a gate that gets # admin-overridden. Doctrine: fail loudly. # The gate writes its log and its exit code to /tmp; the step that follows # always runs and publishes them as check annotations. Two reasons: # this runner drops annotations emitted by a step that then fails # (measured 2026-11-01), and job logs are served from a host some agent # sandboxes cannot reach, so a red gate was unreadable from the session # that has to fix it. - name: Core proofs, countermodels and expected rejections run: | set +e bash scripts/check.sh 2>&1 | tee /tmp/check.log echo "${PIPESTATUS[0]}" > /tmp/check.rc exit "$(cat /tmp/check.rc)" - name: Publish the gate failure reason if: always() run: | set +e rc="$(cat /tmp/check.rc 2>/dev/null || echo unknown)" printf '::notice title=gate exited::rc=%s bytes=%s\n' "$rc" "$(wc -c < /tmp/check.log 2>/dev/null || echo missing)" if [ "$rc" != "0" ]; then out="$(tr '\n' '~' < /tmp/check.log | cut -c1-3400)" printf '::error title=Agda gate failed (rc=%s)::%s\n' "$rc" "$out" fi exit 0 # PROOF-POLICY §8.4: the prover-supplied postulates of the import cone # are exactly the trusted base the receipt lists (scripts/proof-flags.sh). - name: Trusted base of the import cone run: bash scripts/check-trusted-base.sh 2>&1 | tee /tmp/trusted-base.log - name: Which laws generic TINI uses run: bash scripts/minimal-laws.sh # The ledger row of this run's Agda leg: what the receipt job records. # Every field is read from this run: the checker's own version line, the # commit checked out, and the trusted-base lines the gates printed. - name: Ledger row of the Agda leg id: row run: | checker="$(agda --version | head -1) ($(bash scripts/proof-flags.sh provenance), container debian:13-slim)" axioms="--safe; $(grep -h '^PASS: trusted base' /tmp/check.log /tmp/trusted-base.log | sed 's/^PASS: //' | awk 'NR>1{printf "; "} {printf "%s", $0}')" row="$(bash scripts/grade-receipt.sh --run-row agda --run "$RUN_URL" --commit "$(git rev-parse HEAD)" --checker "$checker" --axioms "$axioms")" printf '%s\n' "$row" printf 'row=%s\n' "$row" >> "$GITHUB_OUTPUT" # The Rocq and Lean recheck legs (PROOF-POLICY §2), re-proved by hand from # the Agda statements (verification/legs/README.adoc gives the route and the # statement correspondence). Both provers are pinned: Coq by its Ubuntu # package version, Lean by its release tarball's sha256. Neither leg may use # an axiom or a library; scripts/check-legs.sh refuses either. legs: name: Rocq and Lean recheck legs (no axioms, no libraries) runs-on: ubuntu-24.04 timeout-minutes: 30 env: COQ_PACKAGE: coq=8.18.0+dfsg-1build2 LEAN_URL: https://github.com/leanprover/lean4/releases/download/v4.24.0/lean-4.24.0-linux.tar.zst LEAN_SHA256: b14f5e5159219dd1a1956c3b806813319f5e94ccd5bdfd56f54520609a5bb5ec outputs: rocq: ${{ steps.row.outputs.rocq }} lean: ${{ steps.row.outputs.lean }} steps: - name: Install the pinned Coq run: | sudo apt-get update sudo apt-get install --no-install-recommends -y "$COQ_PACKAGE" zstd - name: Install the pinned Lean (release tarball, sha256-checked) run: | set -euo pipefail curl --proto '=https' --proto-redir '=https' --tlsv1.2 -fsSL "$LEAN_URL" -o "$RUNNER_TEMP/lean.tar.zst" echo "$LEAN_SHA256 $RUNNER_TEMP/lean.tar.zst" | sha256sum --check --strict mkdir -p "$RUNNER_TEMP/lean" tar --zstd -xf "$RUNNER_TEMP/lean.tar.zst" -C "$RUNNER_TEMP/lean" echo "$RUNNER_TEMP/lean/lean-4.24.0-linux/bin" >> "$GITHUB_PATH" - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ env.SOURCE_COMMIT }} persist-credentials: false - name: Verify the commit under test run: test "$(git rev-parse HEAD)" = "$SOURCE_COMMIT" - name: Both legs check, with no axioms run: bash scripts/check-legs.sh 2>&1 | tee /tmp/legs.log # The ledger rows of this run's Rocq and Lean legs, read from this run. - name: Ledger rows of the Rocq and Lean legs id: row run: | commit="$(git rev-parse HEAD)" rocq="$(bash scripts/grade-receipt.sh --run-row rocq --run "$RUN_URL" --commit "$commit" \ --checker "$(coqc --version | head -1) (Ubuntu 24.04 $COQ_PACKAGE)" \ --axioms "$(grep '^PASS: Rocq leg' /tmp/legs.log | sed 's/^PASS: //')")" lean="$(bash scripts/grade-receipt.sh --run-row lean --run "$RUN_URL" --commit "$commit" \ --checker "$(lean --version | head -1) (release tarball, sha256 $LEAN_SHA256)" \ --axioms "$(grep '^PASS: Lean leg' /tmp/legs.log | sed 's/^PASS: //')")" printf '%s\n%s\n' "$rocq" "$lean" { printf 'rocq=%s\n' "$rocq"; printf 'lean=%s\n' "$lean"; } >> "$GITHUB_OUTPUT" # The proof receipt (PROOF-POLICY §8.5.1). First the committed receipt must # match the tree and the run ledger, and the pinned reader must accept it. # Then this job writes the receipt for this run: its three ledger rows become # current, and the reader derives each claim's grade. The log shows the rows # to record in scripts/grade-receipt.sh; the receipt is committed from them. receipt: name: Proof receipt (PROOF-POLICY 8.5.1, pinned reader) needs: [proofs, legs] runs-on: ubuntu-24.04 timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ env.SOURCE_COMMIT }} persist-credentials: false - name: Setup Bun uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: bun-version: '1.3.12' - name: Fetch the pinned reader (sha256-checked) run: bash scripts/grade-receipt.sh --fetch-reader - name: The committed receipt matches the tree, and the reader accepts it run: bash scripts/grade-receipt.sh --check - name: The receipt of this run env: AGDA_ROW: ${{ needs.proofs.outputs.row }} ROCQ_ROW: ${{ needs.legs.outputs.rocq }} LEAN_ROW: ${{ needs.legs.outputs.lean }} run: | printf '%s\n%s\n%s\n' "$AGDA_ROW" "$ROCQ_ROW" "$LEAN_ROW" > "$RUNNER_TEMP/rows" mkdir -p "$RUNNER_TEMP/receipt" bash scripts/grade-receipt.sh --emit-run "$RUNNER_TEMP/rows" --out "$RUNNER_TEMP/receipt/agda_praxis.deed" cat "$RUNNER_TEMP/receipt/agda_praxis.deed"