From 9aa9f47db1efe8cd551261e3424ad9c7b03b382a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 22:16:47 +0000 Subject: [PATCH 1/3] fix(proofs): run Agda with --without-K --cubical-compatible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PROOF-POLICY §2.1: Agda theory proofs run under --safe --without-K --cubical-compatible. Change the DihedralQuandle pragma and the krl-verification workflow invocation to match. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0165rGu3tsKmJtevmrdMVyfJ --- .github/workflows/krl-verification.yml | 8 ++++---- verification/proofs/agda/DihedralQuandle.agda | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/krl-verification.yml b/.github/workflows/krl-verification.yml index f2e8f06..91ded86 100644 --- a/.github/workflows/krl-verification.yml +++ b/.github/workflows/krl-verification.yml @@ -155,20 +155,20 @@ jobs: # runner user that invokes `agda`. sudo chmod -R a+rwX /usr/share/agda-stdlib - - name: Check Agda proofs under --safe + - name: Check Agda proofs under --safe --without-K --cubical-compatible run: | set -e shopt -s nullglob found=0 for f in $(find verification/proofs/agda -name '*.agda' 2>/dev/null); do - echo "── agda --safe $f" + echo "── agda --safe --without-K --cubical-compatible $f" # Run from the file's own directory so the top-level module name # (e.g. `DihedralQuandle`) matches the file name as Agda requires. - ( cd "$(dirname "$f")" && LC_ALL=C.UTF-8 agda --safe "$(basename "$f")" ) + ( cd "$(dirname "$f")" && LC_ALL=C.UTF-8 agda --safe --without-K --cubical-compatible "$(basename "$f")" ) found=1 done if [ "$found" = "0" ]; then echo "No Agda proofs found"; exit 1; fi - echo "PASS: all Agda proofs check under --safe" + echo "PASS: all Agda proofs check under --safe --without-K --cubical-compatible" tlaplus-model-check: name: TLA+ model check (TLC) diff --git a/verification/proofs/agda/DihedralQuandle.agda b/verification/proofs/agda/DihedralQuandle.agda index 870e15f..43de5c3 100644 --- a/verification/proofs/agda/DihedralQuandle.agda +++ b/verification/proofs/agda/DihedralQuandle.agda @@ -1,9 +1,9 @@ -{-# OPTIONS --safe #-} +{-# OPTIONS --safe --without-K --cubical-compatible #-} -- SPDX-License-Identifier: MPL-2.0 -- Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) -- -- =========================================================================== --- Dihedral (Takasaki) quandle axioms — machine-checked under `agda --safe` +-- Dihedral (Takasaki) quandle axioms — machine-checked under `agda --safe --without-K --cubical-compatible` -- =========================================================================== -- -- Discharges the algebraic core of obligation M1 ("Quandle axioms preserved") From dfcaf8c0ff2d1334d9f79c6c79d39f2904e6d107 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 00:05:14 +0000 Subject: [PATCH 2/3] fix(ci): pin agda-stdlib v2.3 for the Agda proofs job The job overwrote the packaged standard-library.agda-lib with `include: .`. Since ubuntu-latest moved to a release whose agda-stdlib ships its own manifest with `include: src`, that overwrite pointed Agda at a directory with no modules, and every proof died with FileNotFound Data.Integer (run 40175699464). Install only agda-bin from apt, clone agda-stdlib v2.3 (tag checked against commit 8326c74), write a project-local libraries file and pass it with --library-file and -l standard-library. Nothing under ~/.agda is used. Flags stay --safe; a UTF-8 locale is kept or set to C.UTF-8. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0165rGu3tsKmJtevmrdMVyfJ --- .github/workflows/krl-verification.yml | 44 ++++++++++++++++++-------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/.github/workflows/krl-verification.yml b/.github/workflows/krl-verification.yml index f2e8f06..4a65967 100644 --- a/.github/workflows/krl-verification.yml +++ b/.github/workflows/krl-verification.yml @@ -139,32 +139,50 @@ jobs: - name: Checkout uses: actions/checkout@v7.0.1 - - name: Install Agda + standard library + - name: Install Agda + pinned standard library run: | set -euo pipefail + # Agda binary from apt; the standard library is NOT taken from apt. + # The packaged agda-stdlib differs between runner images: noble ships + # no .agda-lib, resolute ships one with `include: src`. Overwriting it + # with `include: .` (the previous step) made every `import Data.*` + # fail with FileNotFound once ubuntu-latest moved to resolute. sudo apt-get update - sudo apt-get install -y --no-install-recommends agda agda-stdlib - # Ubuntu ships the stdlib source but omits its .agda-lib registration. - printf 'name: standard-library\ninclude: .\n' \ - | sudo tee /usr/share/agda-stdlib/standard-library.agda-lib >/dev/null - mkdir -p "$HOME/.agda" - echo /usr/share/agda-stdlib/standard-library.agda-lib > "$HOME/.agda/libraries" - echo standard-library > "$HOME/.agda/defaults" - # Agda writes interface (.agdai) files into the library's _build dir; - # the apt stdlib is root-owned, so make it writable for the (non-root) - # runner user that invokes `agda`. - sudo chmod -R a+rwX /usr/share/agda-stdlib + sudo apt-get install -y --no-install-recommends agda-bin + # Pinned agda-stdlib v2.3: the tag is checked against its commit, so + # a moved tag fails here instead of changing what the proofs check. + STDLIB_TAG=v2.3 + STDLIB_COMMIT=8326c7475af1fa456ca04a0203c168d5d7ff842b + AGDA_ROOT="$RUNNER_TEMP/agda" + mkdir -p "$AGDA_ROOT" + git -c advice.detachedHead=false clone -q --depth 1 --branch "$STDLIB_TAG" \ + https://github.com/agda/agda-stdlib.git "$AGDA_ROOT/agda-stdlib" + have="$(git -C "$AGDA_ROOT/agda-stdlib" rev-parse HEAD)" + [ "$have" = "$STDLIB_COMMIT" ] || { echo "::error::agda-stdlib $STDLIB_TAG is $have, expected $STDLIB_COMMIT"; exit 1; } + # Project-local libraries file, passed with --library-file below; + # nothing under ~/.agda is read or written. + printf '%s\n' "$AGDA_ROOT/agda-stdlib/standard-library.agda-lib" > "$AGDA_ROOT/libraries" + echo "AGDA_LIBRARIES=$AGDA_ROOT/libraries" >> "$GITHUB_ENV" + agda --version | head -1 - name: Check Agda proofs under --safe run: | set -e shopt -s nullglob + # Agda prints non-ASCII identifiers in its diagnostics; under a POSIX + # locale it dies with "commitBuffer: invalid argument" (exit 42) + # instead of reporting. Keep the caller's locale when it is UTF-8. + case "${LC_ALL:-${LC_CTYPE:-${LANG:-}}}" in + *[Uu][Tt][Ff]-8* | *[Uu][Tt][Ff]8*) ;; + *) export LC_ALL=C.UTF-8 ;; + esac found=0 for f in $(find verification/proofs/agda -name '*.agda' 2>/dev/null); do echo "── agda --safe $f" # Run from the file's own directory so the top-level module name # (e.g. `DihedralQuandle`) matches the file name as Agda requires. - ( cd "$(dirname "$f")" && LC_ALL=C.UTF-8 agda --safe "$(basename "$f")" ) + # `-i .` keeps that directory a source root next to the library. + ( cd "$(dirname "$f")" && agda --safe -i . --library-file="$AGDA_LIBRARIES" --no-default-libraries -l standard-library "$(basename "$f")" ) found=1 done if [ "$found" = "0" ]; then echo "No Agda proofs found"; exit 1; fi From f2cc131305ecdbaf9d881f25c8c971e13f95ec12 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 00:16:01 +0000 Subject: [PATCH 3/3] ci(agda): use the shared pinned stdlib provisioning script Replace the inline agda-stdlib clone with scripts/provision-agda-stdlib.sh, copied byte-identically from rsr-template-repo at 4a72fe74b83593dd636d9535154bf16060005221. Same v2.3 pin; adds an Agda version print and a 2.7.0 minimum-compiler check. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0165rGu3tsKmJtevmrdMVyfJ Signed-off-by: Claude --- .github/workflows/krl-verification.yml | 21 ++--- scripts/provision-agda-stdlib.sh | 107 +++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 14 deletions(-) create mode 100755 scripts/provision-agda-stdlib.sh diff --git a/.github/workflows/krl-verification.yml b/.github/workflows/krl-verification.yml index 99222e0..0afa34e 100644 --- a/.github/workflows/krl-verification.yml +++ b/.github/workflows/krl-verification.yml @@ -149,20 +149,13 @@ jobs: # fail with FileNotFound once ubuntu-latest moved to resolute. sudo apt-get update sudo apt-get install -y --no-install-recommends agda-bin - # Pinned agda-stdlib v2.3: the tag is checked against its commit, so - # a moved tag fails here instead of changing what the proofs check. - STDLIB_TAG=v2.3 - STDLIB_COMMIT=8326c7475af1fa456ca04a0203c168d5d7ff842b - AGDA_ROOT="$RUNNER_TEMP/agda" - mkdir -p "$AGDA_ROOT" - git -c advice.detachedHead=false clone -q --depth 1 --branch "$STDLIB_TAG" \ - https://github.com/agda/agda-stdlib.git "$AGDA_ROOT/agda-stdlib" - have="$(git -C "$AGDA_ROOT/agda-stdlib" rev-parse HEAD)" - [ "$have" = "$STDLIB_COMMIT" ] || { echo "::error::agda-stdlib $STDLIB_TAG is $have, expected $STDLIB_COMMIT"; exit 1; } - # Project-local libraries file, passed with --library-file below; - # nothing under ~/.agda is read or written. - printf '%s\n' "$AGDA_ROOT/agda-stdlib/standard-library.agda-lib" > "$AGDA_ROOT/libraries" - echo "AGDA_LIBRARIES=$AGDA_ROOT/libraries" >> "$GITHUB_ENV" + # Shared pinned provisioning script, copied byte-identically from + # hyperpolymath/rsr-template-repo scripts/provision-agda-stdlib.sh + # (template commit 4a72fe74b83593dd636d9535154bf16060005221). It clones + # agda-stdlib v2.3, checks the tag against its commit, writes a project + # libraries file, appends AGDA_LIBRARIES to GITHUB_ENV, and fails when + # Agda is older than 2.7.0. Nothing under ~/.agda is read or written. + bash scripts/provision-agda-stdlib.sh "$RUNNER_TEMP/agda/agda-stdlib" agda --version | head -1 - name: Check Agda proofs under --safe --without-K --cubical-compatible diff --git a/scripts/provision-agda-stdlib.sh b/scripts/provision-agda-stdlib.sh new file mode 100755 index 0000000..51bfcf2 --- /dev/null +++ b/scripts/provision-agda-stdlib.sh @@ -0,0 +1,107 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) +# +# provision-agda-stdlib.sh [DIR] +# +# The one shared, pinned way an estate repo gets the Agda standard library. +# Repos copy this file byte-identically from rsr-template-repo; do not fork it. +# +# Why it exists: each Agda repo wrote its own stdlib setup, and Ubuntu's apt +# agda-stdlib package now ships standard-library.agda-lib with `include: src`. +# Workflows that overwrote that file with `include: .` made Agda search a +# directory holding no modules. This script never reads or writes apt's copy +# and never touches ~/.agda: it clones a tag, verifies the commit, and writes +# a private libraries file. +# +# Environment (all optional): +# AGDA_STDLIB_VERSION tag to clone (default v2.3) +# AGDA_STDLIB_COMMIT full commit SHA the tag must resolve to +# (default 8326c7475af1fa456ca04a0203c168d5d7ff842b) +# AGDA_STDLIB_REPO clone URL (default https://github.com/agda/agda-stdlib) +# AGDA_MIN_VERSION minimum Agda compiler; fails below it (default 2.7.0, +# the oldest compiler agda-stdlib v2.3 documents as tested) +# RUNNER_TEMP base for the default directory +# GITHUB_ENV when set, AGDA_LIBRARIES= is appended to it +# +# A repo that must stay on another release overrides VERSION and COMMIT together; +# changing one without the other fails the commit check, loudly. +# +# Output: the libraries-file path on stdout (export it as AGDA_LIBRARIES). +# Exit: 0 ok; 1 provisioning or pin failure; 2 misuse. + +set -euo pipefail + +VERSION="${AGDA_STDLIB_VERSION:-v2.3}" +COMMIT="${AGDA_STDLIB_COMMIT:-8326c7475af1fa456ca04a0203c168d5d7ff842b}" +REPO="${AGDA_STDLIB_REPO:-https://github.com/agda/agda-stdlib}" +AGDA_MIN="${AGDA_MIN_VERSION:-2.7.0}" + +if [ "$#" -gt 1 ]; then + echo "usage: $(basename "$0") [DIR]" >&2 + exit 2 +fi +if [[ ! "$COMMIT" =~ ^[0-9a-f]{40}$ ]]; then + echo "FAIL: AGDA_STDLIB_COMMIT must be a full 40-character lowercase SHA, got '$COMMIT'" >&2 + exit 2 +fi + +if ! command -v agda >/dev/null 2>&1; then + echo "FAIL: 'agda' not found on PATH; install the compiler first." >&2 + exit 1 +fi +AGDA_VERSION_LINE="$(agda --version | head -1)" +echo "$AGDA_VERSION_LINE" >&2 +AGDA_ACTUAL="$(grep -oE '[0-9]+(\.[0-9]+)+' <<<"$AGDA_VERSION_LINE" | head -1 || true)" +if [ -z "$AGDA_ACTUAL" ]; then + echo "FAIL: cannot read an Agda version from '$AGDA_VERSION_LINE'." >&2 + exit 1 +fi +if [ "$(printf '%s\n%s\n' "$AGDA_MIN" "$AGDA_ACTUAL" | sort -V | head -1)" != "$AGDA_MIN" ]; then + { + echo "FAIL: Agda $AGDA_ACTUAL is older than $AGDA_MIN, the minimum for agda-stdlib $VERSION." + echo " (Ubuntu apt's agda-bin can be 2.6.3.) Install a newer compiler, or set" + echo " AGDA_MIN_VERSION together with AGDA_STDLIB_VERSION/COMMIT if you know better." + } >&2 + exit 1 +fi + +if [ "$#" -eq 1 ]; then + DIR="$1" +else + DIR="$(mktemp -d "${RUNNER_TEMP:-${TMPDIR:-/tmp}}/agda-stdlib.XXXXXX")/agda-stdlib" +fi + +if [ -e "$DIR" ] && [ -n "$(ls -A "$DIR" 2>/dev/null)" ]; then + echo "FAIL: $DIR exists and is not empty; refusing to reuse an unverified tree." >&2 + exit 1 +fi +mkdir -p "$(dirname "$DIR")" +DIR="$(cd "$(dirname "$DIR")" && pwd)/$(basename "$DIR")" + +git -c advice.detachedHead=false clone --quiet --depth 1 --branch "$VERSION" "$REPO" "$DIR" >&2 +ACTUAL="$(git -C "$DIR" rev-parse HEAD)" +if [ "$ACTUAL" != "$COMMIT" ]; then + { + echo "FAIL: agda-stdlib $VERSION resolved to $ACTUAL, expected $COMMIT." + echo " The tag moved or the pin is wrong; not using this tree." + } >&2 + rm -rf "$DIR" + exit 1 +fi +if [ ! -f "$DIR/src/Data/Nat.agda" ]; then + echo "FAIL: $DIR/src/Data/Nat.agda missing; the clone is not a stdlib source tree." >&2 + exit 1 +fi + +LIBS="$DIR/libraries" +printf '%s\n' "$DIR/standard-library.agda-lib" >"$LIBS" +# Written by us, with `include: src`, so no other file can redirect the search. +printf 'name: standard-library\ninclude: src\n' >"$DIR/standard-library.agda-lib" + +echo "agda-stdlib $VERSION ($ACTUAL) provisioned at $DIR" >&2 +if [ -n "${GITHUB_ENV:-}" ]; then + printf 'AGDA_LIBRARIES=%s\n' "$LIBS" >>"$GITHUB_ENV" +fi +echo "export AGDA_LIBRARIES=$LIBS" >&2 +printf '%s\n' "$LIBS"