From e81c46f02c4bc79f705f0207f6fa1c424833fb21 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 01:24:52 +0000 Subject: [PATCH 1/5] ci: pin the Agda job's container image by digest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PROOF-POLICY §8.2 counts a proof leg toward PWG-1 only if its checker ran isolated, in an image pinned by digest, with the receipt naming the image. The Agda job ran in debian:trixie-slim with no digest. Pin it, print the image reference in the receipt step summary, and update the DEVIATION note. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_013CuBToxr5h9catptGiTsFX --- .github/workflows/proofs.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/proofs.yml b/.github/workflows/proofs.yml index 3ad5320..a806661 100644 --- a/.github/workflows/proofs.yml +++ b/.github/workflows/proofs.yml @@ -9,13 +9,15 @@ name: Agda proofs # # DEVIATION (PROOF-POLICY §6), state: open. # Leg: the Agda leg of every theorem in docs/status/PROOF-STATUS.adoc. +# Image: the job runs in debian:trixie-slim pinned by digest (§8.2: isolated, +# the receipt names the image). # Tool: Debian trixie agda-bin 2.6.4.3-1+b2, asserted below; apt checks # the .deb against Debian's signed Packages index, and the receipt # step prints that index's SHA256 for the package and the digest of # the installed binary. -# Why: this repository has no Guix manifest and no proof container yet; -# the hosted runner has no Guix. The Debian package is an exact, -# signature-checked pin. +# Why: this repository has no Guix manifest and no proof container of its +# own yet; the hosted runner has no Guix. The digest-pinned Debian +# image and the exact, signature-checked package are the pin. # Closes: when a Guix manifest (or the repo's container) provides Agda and # this job installs from it. on: @@ -29,7 +31,8 @@ jobs: name: Core proofs and expected rejections runs-on: ubuntu-latest timeout-minutes: 15 - container: debian:trixie-slim + # Pinned by digest (PROOF-POLICY §8.2); re-pin deliberately. + container: debian:trixie-slim@sha256:a29215f6a35e51e22adffa17f89e9d2ef06214e64a2bad10d765c46aea49f11f steps: - name: Install the pinned prover run: | @@ -60,6 +63,7 @@ jobs: echo "" echo "- source commit: \`$SOURCE_SHA\`" echo "- checker: \`$(agda --version)\`" + echo "- image: \`debian:trixie-slim@sha256:a29215f6a35e51e22adffa17f89e9d2ef06214e64a2bad10d765c46aea49f11f\` (isolated, pinned by digest)" echo "- package: \`agda-bin $(dpkg-query -W -f='${Version}' agda-bin)\`, index SHA256 \`$(apt-cache show agda-bin=2.6.4.3-1+b2 | sed -n 's/^SHA256: //p' | head -1)\`" echo "- binary SHA256: \`$(sha256sum "$(command -v agda)" | cut -d' ' -f1)\`" echo "- invocation: \`$(sed -n 's/^flags=(\(.*\))$/\1/p' scripts/check-agda.sh)\`" From c68ac07da490505631356d73bf7bcfe5aec04dd2 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 01:25:31 +0000 Subject: [PATCH 2/5] proofs: build the Lean leg under lake (script, package, manifest, test) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PROOF-POLICY §8.2 names `lean` under `lake` as the qualifying Lean run and asks for a committed lake-manifest.json as a pinned input. Add a dependency-free Lake package for ResourceAlgebra.lean, the canonical (I-JSON/JCS) manifest lake writes, and scripts/check-lean-leg.sh, which builds a copy under lake and takes the axiom census from that build. The test plants each failure through a stub lake and checks the reason. The workflow is wired in the following commit. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_013CuBToxr5h9catptGiTsFX --- scripts/check-lean-leg.sh | 54 ++++++++++++++++++++ tests/check_lean_leg_test.sh | 46 +++++++++++++++++ verification/proofs/lean4/lake-manifest.json | 1 + verification/proofs/lean4/lakefile.toml | 12 +++++ 4 files changed, 113 insertions(+) create mode 100755 scripts/check-lean-leg.sh create mode 100755 tests/check_lean_leg_test.sh create mode 100644 verification/proofs/lean4/lake-manifest.json create mode 100644 verification/proofs/lean4/lakefile.toml diff --git a/scripts/check-lean-leg.sh b/scripts/check-lean-leg.sh new file mode 100755 index 0000000..b206143 --- /dev/null +++ b/scripts/check-lean-leg.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell +# +# check-lean-leg.sh: the Lean recheck leg under lake (PROOF-POLICY §8.2 names +# `lean` under `lake` as the qualifying kernel run). It builds the Lake package +# in verification/proofs/lean4 from a copy in a temporary directory, so no +# .lake/ build output lands in the tree, and takes the axiom census from that +# build. Lake prints each `#print axioms` report as an +# `info: :::` line. +# +# It fails loudly when: the build fails; any report says `depends on axioms`; +# the reports attributed to ResourceAlgebra.lean that say `does not depend on +# any axioms` differ in number from the `#print axioms` commands in the file +# (or there are none); or the build rewrote lake-manifest.json. +# LAKE overrides the lake binary. +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." + +lake="${LAKE:-lake}" +src=verification/proofs/lean4 +file=ResourceAlgebra.lean + +work="$(mktemp -d)" +trap 'rm -rf "$work"' EXIT +for f in lakefile.toml lake-manifest.json lean-toolchain "$file"; do + cp -- "$src/$f" "$work/" +done + +if ! out="$(cd "$work" && "$lake" build 2>&1)"; then + printf '%s\n' "$out" >&2 + echo "ERROR: the Lean leg does not build under lake" >&2 + exit 1 +fi +printf '%s\n' "$out" + +if grep -q 'depends on axioms' <<<"$out"; then + echo "ERROR: a printed theorem depends on axioms" >&2 + exit 1 +fi + +n_print="$(grep -cE '^[[:space:]]*#print[[:space:]]+axioms[[:space:]]' "$src/$file" || true)" +n_free="$(grep -cE "^info: ${file//./\\.}:[0-9]+:[0-9]+: .* does not depend on any axioms\$" <<<"$out" || true)" +if [ "$n_print" -eq 0 ] || [ "$n_free" != "$n_print" ]; then + echo "ERROR: only $n_free of $n_print printed theorems are axiom-free" >&2 + exit 1 +fi + +if ! cmp -s "$src/lake-manifest.json" "$work/lake-manifest.json"; then + echo "ERROR: the build rewrote lake-manifest.json; commit the manifest lake writes" >&2 + exit 1 +fi + +echo "PASS: Lean leg under lake; $n_free of $n_print printed theorems depend on no axiom" diff --git a/tests/check_lean_leg_test.sh b/tests/check_lean_leg_test.sh new file mode 100755 index 0000000..a940ed6 --- /dev/null +++ b/tests/check_lean_leg_test.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell +# scripts/check-lean-leg.sh must fail when a printed theorem depends on an +# axiom, when the build fails, when nothing is printed, and when the build +# rewrites lake-manifest.json. A stub lake (LAKE=) misreports the build, once +# each way, and each case must fail for the stated reason. +set -uo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +stub=$(mktemp -d); trap 'rm -rf "$stub"' EXIT +n=$(grep -cE '^[[:space:]]*#print[[:space:]]+axioms[[:space:]]' verification/proofs/lean4/ResourceAlgebra.lean) + +# $1 name, $2 shell body of the stub, run in the build directory +make_stub() { printf '#!/usr/bin/env bash\n%s\n' "$2" > "$stub/$1"; chmod +x "$stub/$1"; } + +# n axiom-free reports, as lake prints them +free_reports="for i in \$(seq 1 $n); do echo \"info: ResourceAlgebra.lean:\$i:0: 'RA.t\$i' does not depend on any axioms\"; done" + +fails=0 +expect_fail() { # $1 stub, $2 message the script must give + out=$(LAKE="$stub/$1" bash scripts/check-lean-leg.sh 2>&1); rc=$? + if [[ $rc -eq 0 ]] || grep -q '^PASS:' <<<"$out"; then + printf 'FAIL: %s: the script passed (exit %s)\n%s\n' "$1" "$rc" "$out" >&2; fails=1; return + fi + if ! grep -q -- "$2" <<<"$out"; then + printf 'FAIL: %s: the script stopped for another reason (exit %s)\n%s\n' "$1" "$rc" "$out" >&2; fails=1; return + fi + echo "PASS: $1 makes the script fail ($2)" +} + +make_stub axiom "echo \"info: ResourceAlgebra.lean:1:0: 'RA.t' depends on axioms: [propext]\"; exit 0" +expect_fail axiom 'a printed theorem depends on axioms' + +make_stub broken "echo 'error: ResourceAlgebra.lean:1:0: unknown identifier'; exit 1" +expect_fail broken 'does not build under lake' + +make_stub silent "echo 'Build completed successfully (3 jobs).'; exit 0" +expect_fail silent 'printed theorems are axiom-free' + +make_stub short "$free_reports | head -n $((n - 1)); exit 0" +expect_fail short 'printed theorems are axiom-free' + +make_stub rewrite "$free_reports; echo '{}' > lake-manifest.json; exit 0" +expect_fail rewrite 'rewrote lake-manifest.json' + +exit $fails diff --git a/verification/proofs/lean4/lake-manifest.json b/verification/proofs/lean4/lake-manifest.json new file mode 100644 index 0000000..35b0575 --- /dev/null +++ b/verification/proofs/lean4/lake-manifest.json @@ -0,0 +1 @@ +{"fixedToolchain":false,"lakeDir":".lake","name":"resourceAlgebraLean","packages":[],"packagesDir":".lake/packages","version":"1.3.0"} diff --git a/verification/proofs/lean4/lakefile.toml b/verification/proofs/lean4/lakefile.toml new file mode 100644 index 0000000..305bc51 --- /dev/null +++ b/verification/proofs/lean4/lakefile.toml @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: MPL-2.0 +# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell +# +# The Lean recheck leg as a Lake package: scripts/check-lean-leg.sh runs +# `lake build` on a copy of this directory (PROOF-POLICY §8.2 names `lean` +# under `lake` as the qualifying kernel run). No dependencies, no Mathlib. +name = "resourceAlgebraLean" +defaultTargets = ["ResourceAlgebra"] + +[[lean_lib]] +name = "ResourceAlgebra" +roots = ["ResourceAlgebra"] From 22e7b150f2eb0cdc99839871cde979ad1bde7dc3 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 01:26:32 +0000 Subject: [PATCH 3/5] ci: run the Lean leg and the M-2 bridge under lake in a digest-pinned image The lean-leg job now runs in ubuntu:24.04 pinned by digest, installs the sha256-checked Lean 4.35.0 archive, asserts lean and lake versions, takes the axiom census and receipt from scripts/check-lean-leg.sh (lake build), and runs the new leg test beside the bridge test. The receipts name the image, the lake invocation and every input file. scripts/check-lean-bridge.sh builds ResourceAlgebra, the pinned TropicalSessionTypes and TropicalBridge as a dependency-free Lake package (committed lakefile.toml and lake-manifest.json) in a work directory. The tropical-types pin and its fetch-and-verify are unchanged; all failure conditions are kept, and a rewritten manifest now fails. Only reports attributed to TropicalBridge.lean count towards the bridge census. The bridge test plants each failure through a stub lake. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_013CuBToxr5h9catptGiTsFX --- .github/workflows/proofs.yml | 70 +++++++++++++------ scripts/check-lean-bridge.sh | 55 +++++++++------ tests/check_lean_bridge_test.sh | 47 ++++++++----- .../bridges/tropical-types/lake-manifest.json | 1 + .../bridges/tropical-types/lakefile.toml | 14 ++++ 5 files changed, 125 insertions(+), 62 deletions(-) create mode 100644 verification/bridges/tropical-types/lake-manifest.json create mode 100644 verification/bridges/tropical-types/lakefile.toml diff --git a/.github/workflows/proofs.yml b/.github/workflows/proofs.yml index a806661..7c468f5 100644 --- a/.github/workflows/proofs.yml +++ b/.github/workflows/proofs.yml @@ -73,61 +73,82 @@ jobs: } >> "$GITHUB_STEP_SUMMARY" # Lean recheck leg (PROOF-POLICY §2): re-proved by hand, Lean core only. + # The qualifying run is `lake build` (§8.2, owner ruling 2026-11-17), in a + # container image pinned by digest, which the receipt names (§8.2, owner + # ruling 2026-11-16). # DEVIATION (§6), state: open. # Leg: the Lean leg of every theorem in docs/status/PROOF-STATUS.adoc. - # Tool: Lean 4.35.0, the upstream release archive, checked against the - # SHA256 below; the version is asserted against lean-toolchain. + # Image: ubuntu:24.04 pinned by digest (the same digest as januskey's + # recheck job). + # Tool: Lean 4.35.0 with Lake, the upstream release archive, checked + # against the SHA256 below; the version is asserted against + # lean-toolchain, and Lake's version is asserted too. # Why: no Guix manifest or proof container provides Lean here yet. # Closes: when a Guix manifest (or the repo's container) provides Lean. lean-leg: name: Lean recheck leg runs-on: ubuntu-latest timeout-minutes: 15 + # ubuntu:24.04, resolved 2026-11-16; re-pin deliberately. Job containers + # run as root, so apt needs no sudo. + container: ubuntu:24.04@sha256:73b999393d07f2bf65a40373778a44dc9a6d54ad7718d29247d8ff9413c4d6a8 env: LEAN_VERSION: '4.35.0' LEAN_SHA256: '7289597a44543246c9227b8cae501767e095ce17f6d448b95fc4a8dc97268f6d' + DEBIAN_FRONTEND: noninteractive + defaults: + run: + shell: bash steps: - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - name: Install the pinned Lean run: | set -euo pipefail + apt-get update + apt-get install --no-install-recommends -y ca-certificates curl git zstd curl --proto '=https' --tlsv1.2 --fail --silent --show-error --location \ --output "$RUNNER_TEMP/lean.tar.zst" \ "https://github.com/leanprover/lean4/releases/download/v${LEAN_VERSION}/lean-${LEAN_VERSION}-linux.tar.zst" echo "${LEAN_SHA256} $RUNNER_TEMP/lean.tar.zst" | sha256sum --check --strict - tar --zstd -xf "$RUNNER_TEMP/lean.tar.zst" -C "$RUNNER_TEMP" - echo "$RUNNER_TEMP/lean-${LEAN_VERSION}-linux/bin" >> "$GITHUB_PATH" - - name: Verify the checked Lean version + mkdir -p /opt/lean + tar --zstd -xf "$RUNNER_TEMP/lean.tar.zst" -C /opt/lean + rm "$RUNNER_TEMP/lean.tar.zst" + echo "/opt/lean/lean-${LEAN_VERSION}-linux/bin" >> "$GITHUB_PATH" + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + - name: Verify the checked Lean and Lake versions run: | set -euo pipefail test "$(cat verification/proofs/lean4/lean-toolchain)" = "leanprover/lean4:v${LEAN_VERSION}" lean --version | grep -F "version ${LEAN_VERSION}," + lake --version | grep -F "Lean version ${LEAN_VERSION})" - name: Lean leg run: bash scripts/check-proofs.sh lean4 - - name: Axioms and receipt + - name: Leg check fails on a failed build, an axiom or a rewritten manifest + run: bash tests/check_lean_leg_test.sh + - name: Axioms under lake, and receipt env: SOURCE_SHA: ${{ github.sha }} run: | set -euo pipefail - out="$(cd verification/proofs/lean4 && lean ResourceAlgebra.lean 2>&1)" # A counted witness lists its axioms (§8.4). The leg is recorded as - # axiom-free, so every printed theorem must say so. - n_print="$(grep -c '^#print axioms' verification/proofs/lean4/ResourceAlgebra.lean)" - n_free="$(grep -c 'does not depend on any axioms' <<<"$out" || true)" - if [ "$n_free" != "$n_print" ]; then - echo "::error::only $n_free of $n_print theorems are axiom-free"; echo "$out"; exit 1 - fi + # axiom-free, so every printed theorem must say so; the script takes + # that census from `lake build`. + result="$(bash scripts/check-lean-leg.sh | tee /dev/stderr | tail -1)" + src=verification/proofs/lean4 { echo "## Lean leg receipt" echo "" echo "- source commit: \`$SOURCE_SHA\`" - echo "- checker: \`$(lean --version)\`" + echo "- image: \`ubuntu:24.04@sha256:73b999393d07f2bf65a40373778a44dc9a6d54ad7718d29247d8ff9413c4d6a8\` (isolated, pinned by digest)" + echo "- checker: \`$(lean --version)\`, \`$(lake --version)\`" echo "- archive SHA256: \`$LEAN_SHA256\`" - echo "- invocation: \`lean ResourceAlgebra.lean\` in \`verification/proofs/lean4\` (core only, no Mathlib)" - echo "- input SHA256: \`$(sha256sum verification/proofs/lean4/ResourceAlgebra.lean | cut -d' ' -f1)\`" - echo "- axioms: $n_free of $n_print printed theorems depend on no axiom" + echo "- invocation: \`lake build\` in a copy of \`$src\` made by \`bash scripts/check-lean-leg.sh\` (core only, no Mathlib, no dependencies)" + for f in ResourceAlgebra.lean lakefile.toml lake-manifest.json lean-toolchain; do + echo "- input \`$f\` SHA256: \`$(sha256sum "$src/$f" | cut -d' ' -f1)\`" + done + echo "- script SHA256: \`$(sha256sum scripts/check-lean-leg.sh | cut -d' ' -f1)\`" + echo "- axioms: ${result#PASS: Lean leg under lake; }" } >> "$GITHUB_STEP_SUMMARY" - name: Bridge check fails on a broken or axiom-dependent bridge run: bash tests/check_lean_bridge_test.sh @@ -142,14 +163,19 @@ jobs: set -euo pipefail out="$(bash scripts/check-lean-bridge.sh)" echo "$out" + br=verification/bridges/tropical-types { echo "## M-2 bridge receipt" echo "" echo "- source commit: \`$SOURCE_SHA\`" - echo "- checker: \`$(lean --version)\`" - echo "- invocation: \`bash scripts/check-lean-bridge.sh\`" + echo "- image: \`ubuntu:24.04@sha256:73b999393d07f2bf65a40373778a44dc9a6d54ad7718d29247d8ff9413c4d6a8\` (isolated, pinned by digest)" + echo "- checker: \`$(lean --version)\`, \`$(lake --version)\`" + echo "- invocation: \`lake build\` in a work directory made by \`bash scripts/check-lean-bridge.sh\`" sed -n 's/^import: \(.*\) \(.*\) \(.*\) \(.*\)$/- import: `\1` at `\2`, `\3` SHA256 `\4`/p' <<<"$out" sed -n 's/^bridge: \(.*\) \(.*\)$/- bridge: `\1` SHA256 `\2`/p' <<<"$out" + for f in "$br/lakefile.toml" "$br/lake-manifest.json" verification/proofs/lean4/lean-toolchain verification/proofs/lean4/ResourceAlgebra.lean scripts/check-lean-bridge.sh; do + echo "- input \`$f\` SHA256: \`$(sha256sum "$f" | cut -d' ' -f1)\`" + done sed -n 's/^PASS: .*; \(.*\)$/- axioms: \1/p' <<<"$out" } >> "$GITHUB_STEP_SUMMARY" diff --git a/scripts/check-lean-bridge.sh b/scripts/check-lean-bridge.sh index 7f69761..ea9e924 100755 --- a/scripts/check-lean-bridge.sh +++ b/scripts/check-lean-bridge.sh @@ -10,9 +10,17 @@ # only place the pin lives (PROOF-POLICY §8.5.1, imported repositories), so a # repin changes this file and with it the home input digest. # +# The three files are built as a dependency-free Lake package (PROOF-POLICY +# §8.2 names `lean` under `lake` as the qualifying run): the lakefile and its +# lake-manifest.json sit beside the bridge, and `lake build` runs in a work +# directory so no .lake/ output lands in the tree. The tropical-types pin stays +# here, not in a lake `require`. +# # It fails loudly when: the pinned commit cannot be fetched or is not what was -# checked out; either module or the bridge does not compile; or any printed -# theorem depends on an axiom. On success it prints the facts a receipt needs. +# checked out; any module or the bridge does not build; any printed theorem +# depends on an axiom; the bridge prints no theorem or not all axiom-free; or +# the build rewrote lake-manifest.json. On success it prints the facts a +# receipt needs. LAKE overrides the lake binary. set -euo pipefail cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." @@ -20,11 +28,13 @@ TT_REPOSITORY=hyperpolymath/tropical-types TT_COMMIT=f2e465c966d14d4986dfc492875cc54653d9751e TT_FILE=TropicalSessionTypes.lean BRIDGE=verification/bridges/tropical-types/TropicalBridge.lean -lean="${LEAN:-lean}" +BRIDGE_DIR=verification/bridges/tropical-types +RA_FILE=verification/proofs/lean4/ResourceAlgebra.lean +TOOLCHAIN=verification/proofs/lean4/lean-toolchain +lake="${LAKE:-lake}" work="$(mktemp -d)" trap 'rm -rf "$work"' EXIT -mkdir -p "$work/build" git init -q "$work/tt" git -C "$work/tt" fetch -q --depth 1 "https://github.com/$TT_REPOSITORY" "$TT_COMMIT" \ @@ -36,28 +46,31 @@ got="$(git -C "$work/tt" rev-parse HEAD)" [ -f "$work/tt/$TT_FILE" ] \ || { echo "ERROR: $TT_FILE is not in $TT_REPOSITORY at $TT_COMMIT" >&2; exit 1; } -compile() { # $1 dir, $2 file, $3 olean - local out - if ! out="$(cd "$1" && "$lean" -o "$3" "$2" 2>&1)" || grep -q 'error:' <<<"$out"; then - printf '%s\n' "$out" >&2 - echo "ERROR: $2 does not compile" >&2 - exit 1 - fi -} -compile "$work/tt" "$TT_FILE" "$work/build/TropicalSessionTypes.olean" -compile verification/proofs/lean4 ResourceAlgebra.lean "$work/build/ResourceAlgebra.olean" +mkdir -p "$work/pkg" +cp -- "$BRIDGE_DIR/lakefile.toml" "$BRIDGE_DIR/lake-manifest.json" "$BRIDGE" \ + "$RA_FILE" "$TOOLCHAIN" "$work/tt/$TT_FILE" "$work/pkg/" -if ! out="$(cd "$(dirname "$BRIDGE")" && LEAN_PATH="$work/build" "$lean" "$(basename "$BRIDGE")" 2>&1)" \ - || grep -q 'error:' <<<"$out"; then +if ! out="$(cd "$work/pkg" && "$lake" build 2>&1)" || grep -q 'error:' <<<"$out"; then + printf '%s\n' "$out" >&2 + echo "ERROR: the bridge package does not build under lake" >&2 + exit 1 +fi +if grep -q 'depends on axioms' <<<"$out"; then printf '%s\n' "$out" >&2 - echo "ERROR: the bridge does not compile" >&2 + echo "ERROR: a printed theorem depends on axioms" >&2 + exit 1 +fi +if ! cmp -s "$BRIDGE_DIR/lake-manifest.json" "$work/pkg/lake-manifest.json"; then + echo "ERROR: the build rewrote lake-manifest.json; commit the manifest lake writes" >&2 exit 1 fi -# A counted witness lists its axioms (§8.4): every printed theorem must say -# it depends on none. -n_print="$(grep -c '^#print axioms' "$BRIDGE")" -n_free="$(grep -c 'does not depend on any axioms' <<<"$out" || true)" +# A counted witness lists its axioms (§8.4): every theorem the bridge prints +# must say it depends on none. Lake prints each report as an +# `info: :::` line; count those attributed to the bridge. +bridge_name="$(basename -- "$BRIDGE")" +n_print="$(grep -cE '^#print axioms' "$BRIDGE" || true)" +n_free="$(grep -cE "^info: ${bridge_name//./\\.}:[0-9]+:[0-9]+: .* does not depend on any axioms\$" <<<"$out" || true)" if [ "$n_print" -eq 0 ] || [ "$n_free" != "$n_print" ]; then printf '%s\n' "$out" >&2 echo "ERROR: only $n_free of $n_print bridge theorems are axiom-free" >&2 diff --git a/tests/check_lean_bridge_test.sh b/tests/check_lean_bridge_test.sh index b7137d9..ffc96e0 100755 --- a/tests/check_lean_bridge_test.sh +++ b/tests/check_lean_bridge_test.sh @@ -1,26 +1,25 @@ #!/usr/bin/env bash # SPDX-License-Identifier: MPL-2.0 -# scripts/check-lean-bridge.sh must fail when the bridge does not compile and -# when a bridge theorem depends on an axiom. A stub lean (LEAN=) compiles the -# two imported modules and then misreports the bridge, once each way. The -# script fetches tropical-types at its pin, so this test needs the network. +# scripts/check-lean-bridge.sh must fail when the bridge package does not +# build, when a bridge theorem depends on an axiom, when nothing is printed, +# and when the build rewrites lake-manifest.json. A stub lake (LAKE=) +# misreports the build, once each way, and each case must fail for the stated +# reason. The script fetches tropical-types at its pin, so this test needs the +# network. set -uo pipefail cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." stub=$(mktemp -d); trap 'rm -rf "$stub"' EXIT +n=$(grep -c '^#print axioms' verification/bridges/tropical-types/TropicalBridge.lean) -make_stub() { # $1 name, $2 what the stub prints when checking the bridge, $3 its exit code - cat > "$stub/$1" < "\$2"; exit 0; fi -printf '%s\n' "$2" -exit $3 -FAKE_LEAN - chmod +x "$stub/$1" -} +# $1 name, $2 shell body of the stub, run in the build directory +make_stub() { printf '#!/usr/bin/env bash\n%s\n' "$2" > "$stub/$1"; chmod +x "$stub/$1"; } + +# n axiom-free reports for the bridge, as lake prints them +free_reports="for i in \$(seq 1 $n); do echo \"info: TropicalBridge.lean:\$i:0: 'RA.TropicalBridge.t\$i' does not depend on any axioms\"; done" fails=0 expect_fail() { # $1 stub, $2 message the script must give - out=$(LEAN="$stub/$1" bash scripts/check-lean-bridge.sh 2>&1); rc=$? + out=$(LAKE="$stub/$1" bash scripts/check-lean-bridge.sh 2>&1); rc=$? if [[ $rc -eq 0 ]] || grep -q '^PASS:' <<<"$out"; then printf 'FAIL: %s: the script passed (exit %s)\n%s\n' "$1" "$rc" "$out" >&2; fails=1; return fi @@ -30,13 +29,23 @@ expect_fail() { # $1 stub, $2 message the script must give echo "PASS: $1 makes the script fail ($2)" } -make_stub axiom "'RA.TropicalBridge.rmax_eq_max' depends on axioms: [propext]" 0 -expect_fail axiom 'bridge theorems are axiom-free' +make_stub axiom "echo \"info: TropicalBridge.lean:1:0: 'RA.TropicalBridge.rmax_eq_max' depends on axioms: [propext]\"; exit 0" +expect_fail axiom 'a printed theorem depends on axioms' -make_stub broken "TropicalBridge.lean:1:0: error: unknown module prefix" 1 -expect_fail broken 'the bridge does not compile' +make_stub broken "echo 'error: TropicalBridge.lean:1:0: unknown module prefix'; exit 1" +expect_fail broken 'does not build under lake' -make_stub silent "" 0 +make_stub silent "echo 'Build completed successfully (5 jobs).'; exit 0" expect_fail silent 'bridge theorems are axiom-free' +make_stub short "$free_reports | head -n $((n - 1)); exit 0" +expect_fail short 'bridge theorems are axiom-free' + +# Reports for another file do not count towards the bridge's own. +make_stub otherfile "$free_reports | sed 's/TropicalBridge.lean/ResourceAlgebra.lean/'; exit 0" +expect_fail otherfile 'bridge theorems are axiom-free' + +make_stub rewrite "$free_reports; echo '{}' > lake-manifest.json; exit 0" +expect_fail rewrite 'rewrote lake-manifest.json' + exit $fails diff --git a/verification/bridges/tropical-types/lake-manifest.json b/verification/bridges/tropical-types/lake-manifest.json new file mode 100644 index 0000000..14613d9 --- /dev/null +++ b/verification/bridges/tropical-types/lake-manifest.json @@ -0,0 +1 @@ +{"fixedToolchain":false,"lakeDir":".lake","name":"resourceAlgebraTropicalBridge","packages":[],"packagesDir":".lake/packages","version":"1.3.0"} diff --git a/verification/bridges/tropical-types/lakefile.toml b/verification/bridges/tropical-types/lakefile.toml new file mode 100644 index 0000000..4cd983a --- /dev/null +++ b/verification/bridges/tropical-types/lakefile.toml @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: MPL-2.0 +# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell +# +# The M-2 bridge as a Lake package: scripts/check-lean-bridge.sh copies +# ResourceAlgebra.lean, the pinned TropicalSessionTypes.lean and +# TropicalBridge.lean into a work directory with this file and runs +# `lake build` there. No dependencies: the tropical-types pin lives in the +# script, not in a `require`. +name = "resourceAlgebraTropicalBridge" +defaultTargets = ["Bridge"] + +[[lean_lib]] +name = "Bridge" +roots = ["ResourceAlgebra", "TropicalSessionTypes", "TropicalBridge"] From 3256914e35fdb6cd8ea323eda879b5614b14e391 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 01:27:15 +0000 Subject: [PATCH 4/5] docs: describe the isolated Agda job and the Lean leg and bridge under lake Change only the statements the CI change makes false (how the Lean leg and the M-2 bridge are invoked, the Agda image) and add a changelog entry. No grade, census or receipt changes. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_013CuBToxr5h9catptGiTsFX --- CHANGELOG.adoc | 16 ++++++++++++++++ docs/status/PROOF-STATUS.adoc | 21 ++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 6410b14..9283c5e 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -1,5 +1,21 @@ == Changelog +== 2026-11-18 — Agda, Lean and the M-2 bridge run isolated + +* The Agda job runs in `debian:trixie-slim` pinned by digest. The Lean leg + and the M-2 bridge run in `ubuntu:24.04` pinned by digest, under `lake + build` (PROOF-POLICY §8.2). Their receipt summaries name the image and the + invocation. The Rocq job was already pinned by digest. +* `verification/proofs/lean4/lakefile.toml` and `lake-manifest.json`, and + `verification/bridges/tropical-types/lakefile.toml` and + `lake-manifest.json`, are dependency-free Lake packages whose manifests + are committed in I-JSON/JCS form. `scripts/check-lean-leg.sh` builds the + leg under lake and counts its axiom reports; `scripts/check-lean-bridge.sh` + now builds the bridge under lake, with the tropical-types pin unchanged. + `tests/check_lean_leg_test.sh` and the updated + `tests/check_lean_bridge_test.sh` plant each failure through a stub lake. +* No grade changes: a grade moves only with a new receipt. + == 2026-11-17 — C-4b and M-2 proved * C-4b: `src/ResourceAlgebra/Instances/Diamond.agda` adds the diamond diff --git a/docs/status/PROOF-STATUS.adoc b/docs/status/PROOF-STATUS.adoc index f03fda8..eaa428c 100644 --- a/docs/status/PROOF-STATUS.adoc +++ b/docs/status/PROOF-STATUS.adoc @@ -69,8 +69,10 @@ to show that it does. The receipt lists the four names and bindings. and checks the proofs. It then writes a receipt to the run summary with the source commit, `agda --version`, the package version and its SHA256 from Debian's signed index, the digest of the installed binary, the flags read -from the script, and the import cone. Installing Agda from Debian rather -than Guix is a §6 deviation, recorded in `proofs.yml`; its state is `open`. +from the script, and the import cone. The job runs in `debian:trixie-slim` +pinned by digest, and the receipt names that image. Installing Agda from +Debian rather than Guix is a §6 deviation, recorded in `proofs.yml`; its +state is `open`. * *History.* Until 2026-11-09 the gate ran `--safe --without-K --no-libraries --double-check`. That profile passed in CI from 2026-10-14 (resource-algebra#4). Under §2.1 those runs are historical evidence, not @@ -180,9 +182,12 @@ the strict flag set and `⊕-least` all changed after it. === The legs: where, how checked, toolchains * *Lean.* `verification/proofs/lean4/ResourceAlgebra.lean`, checked by -`lean` 4.35.0 (pinned by `lean-toolchain`). CI installs the upstream -release archive against a SHA256 and asserts the version: a §6 deviation, -recorded in `proofs.yml`, state `open`. The arithmetic is proved by +`lake build` (Lean 4.35.0, pinned by `lean-toolchain`) on a copy of the +Lake package `verification/proofs/lean4/lakefile.toml`, which has no +dependencies; `lake-manifest.json` is committed. CI runs it through +`scripts/check-lean-leg.sh` in `ubuntu:24.04` pinned by digest, installs +the upstream release archive against a SHA256 and asserts the Lean and Lake +versions: a §6 deviation, recorded in `proofs.yml`, state `open`. The arithmetic is proved by structural recursion, as in Agda's Prelude, so no theorem depends on `propext` or `Quot.sound`. CI fails if any printed theorem depends on an axiom. @@ -370,8 +375,10 @@ these are the `+`, `*`, `0` and `1` of the instance. * *Pin.* `scripts/check-lean-bridge.sh` fetches `hyperpolymath/tropical-types` at `f2e465c966d14d4986dfc492875cc54653d9751e`, checks the fetched commit, -compiles both modules with the pinned `lean` 4.35.0 and checks the bridge. -It fails on any error, on any printed theorem that depends on an axiom, and +builds both modules and the bridge as a Lake package +(`verification/bridges/tropical-types/lakefile.toml`, no dependencies, the +pin stays in the script) with `lake build` under the pinned Lean 4.35.0, in +the same digest-pinned image as the Lean leg. It fails on any error, on any printed theorem that depends on an axiom, and when no theorem is printed (`tests/check_lean_bridge_test.sh`). It prints the SHA256 of the imported file and of the bridge, for a receipt's `(import …)` clause (§8.5.1). From 187f267a291bddf8b683fcac7076083f2737077f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 01:27:33 +0000 Subject: [PATCH 5/5] chore: ignore Lake build output The Lean legs build in a temporary copy, but a local `lake build` in a package directory would leave .lake/; keep it out of commits. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_013CuBToxr5h9catptGiTsFX --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 5376c8c..c7c6ed9 100644 --- a/.gitignore +++ b/.gitignore @@ -148,3 +148,6 @@ verification/proofs/agda/*.agdai # Agda interface files are build output (the gate runs --ignore-interfaces). *.agdai + +# Lake build output (the Lean legs build in a temp copy; never commit it) +.lake/