From aeb989ac6171d782835cb173d2ca9da65e1105a9 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 00:44:17 +0000 Subject: [PATCH 1/2] fix(ci): close the partial/covering escape; a failed rev-parse fails the Agda receipt The verif-idris gate (#509) checked only that each module declares `%default total`. A later `partial` or `covering` annotation, or a `%default partial|covering`, turns the totality check off again, and the package still builds. Idris 2 defaults to covering, under which `bad : Void; bad = bad` checks. The gate now rejects both forms. A new step in idris2-abi-ci.yml does the same for src/abi/. Both were tested against the current tree (pass) and against a module with a `covering` or `partial` line (error, exit 1). scripts/ci/check-agda.sh ran `git rev-parse HEAD` inside echo's arguments, where a failure escapes `set -e`. The receipt then named an empty commit and the script passed. The commit is now read on its own line. Requiring `%default total` in every src/abi/ module waits for #513, which moves the one module that lacks it out of src/abi/. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019a95kk88TZ1iegsBK3kox3 --- .github/workflows/dogfood-proofs-ci.yml | 7 +++++ .github/workflows/idris2-abi-ci.yml | 14 ++++++++++ scripts/ci/check-agda.sh | 5 +++- scripts/ci/check-coprocessor-tags.sh | 37 +++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100755 scripts/ci/check-coprocessor-tags.sh diff --git a/.github/workflows/dogfood-proofs-ci.yml b/.github/workflows/dogfood-proofs-ci.yml index 2b3057b9..2b52e380 100644 --- a/.github/workflows/dogfood-proofs-ci.yml +++ b/.github/workflows/dogfood-proofs-ci.yml @@ -235,6 +235,13 @@ jobs: echo "::error file=$f::module lacks %default total" missing=$((missing + 1)) fi + # A `partial` or `covering` annotation, or a later `%default partial` or + # `%default covering`, switches the check off again (Idris 2 defaults to + # covering, under which `bad : Void; bad = bad` checks). + if grep -nE '^[[:space:]]*(partial|covering)\b|^%default[[:space:]]+(partial|covering)\b' "$f"; then + echo "::error file=$f::module declares a partial or covering definition or default" + missing=$((missing + 1)) + fi done [ "$missing" -eq 0 ] diff --git a/.github/workflows/idris2-abi-ci.yml b/.github/workflows/idris2-abi-ci.yml index a2ef75e5..0b1ecbd3 100644 --- a/.github/workflows/idris2-abi-ci.yml +++ b/.github/workflows/idris2-abi-ci.yml @@ -134,6 +134,20 @@ jobs: exit 1 fi + - name: No partial or covering escape in the ABI + # %default total is only a default: a `partial` or `covering` annotation, or + # a module-wide `%default partial|covering`, turns the totality check off for + # what follows and the package still builds. Runs on every event: cheap. + run: | + set -euo pipefail + hits=$({ grep -rnE '^[[:space:]]*(partial|covering)\b|^%default[[:space:]]+(partial|covering)\b' src/abi/ --include="*.idr" || true; }) + if [ -n "$hits" ]; then + printf '%s\n' "$hits" + echo "::error::src/abi/ declares a partial or covering definition or default" + exit 1 + fi + echo "no partial or covering escape under src/abi/" + - name: Count modules and report if: steps.detect.outputs.relevant == 'true' run: | diff --git a/scripts/ci/check-agda.sh b/scripts/ci/check-agda.sh index af1be781..9abff35d 100644 --- a/scripts/ci/check-agda.sh +++ b/scripts/ci/check-agda.sh @@ -38,7 +38,10 @@ echo "$total source modules, $((total - missing)) with fresh interfaces" # Source-bound receipt (PROOF-POLICY ยง8): toolchain, flags and the SHA-256 of # every first-party source and library descriptor this run checked. -echo "receipt: $version; commit $(git -C "$repo_root" rev-parse HEAD)" +# Its own line: inside echo's arguments a failed rev-parse escapes set -e +# and the receipt would name an empty commit. +commit=$(git -C "$repo_root" rev-parse HEAD) +echo "receipt: $version; commit $commit" echo "receipt: flags --safe --without-K --cubical-compatible; library file $AGDA_LIBRARIES_FILE" while IFS= read -r lib; do if [[ -n "$lib" ]]; then diff --git a/scripts/ci/check-coprocessor-tags.sh b/scripts/ci/check-coprocessor-tags.sh new file mode 100755 index 00000000..34462faa --- /dev/null +++ b/scripts/ci/check-coprocessor-tags.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell (hyperpolymath) +# +# The FFI tag of each coprocessor kind is written twice: as an explicit +# discriminant of the Rust `CoprocessorKind` (src/rust/coprocessor/types.rs) +# and as a clause of `coprocessorKindToU8` in src/abi/Coprocessor/Foreign.idr. +# Neither compiler sees the other file, so this compares the two lists as +# "Name=tag" pairs. It fails if either list is empty, if a Rust variant has no +# explicit discriminant, or if the pairs differ. +set -euo pipefail +root=${1:-.} +rs="$root/src/rust/coprocessor/types.rs" +idr="$root/src/abi/Coprocessor/Foreign.idr" + +body=$(awk '/^pub enum CoprocessorKind \{/{f=1;next} f&&/^\}/{exit} f' "$rs") +bare=$({ printf '%s\n' "$body" | grep -E '^[[:space:]]+[A-Z][A-Za-z0-9]*,[[:space:]]*$' || true; }) +if [ -n "$bare" ]; then + echo "::error file=$rs::CoprocessorKind variants without an explicit discriminant:" + printf '%s\n' "$bare" + exit 1 +fi +rust=$({ printf '%s\n' "$body" | grep -oE '^[[:space:]]+[A-Z][A-Za-z0-9]*[[:space:]]*=[[:space:]]*[0-9]+' || true; } \ + | tr -d ' ' | sort) +idris=$({ grep -oE '^coprocessorKindToU8[[:space:]]+[A-Z][A-Za-z0-9]*[[:space:]]*=[[:space:]]*[0-9]+' "$idr" || true; } \ + | sed -E 's/^coprocessorKindToU8[[:space:]]+//' | tr -d ' ' | sort) + +if [ -z "$rust" ] || [ -z "$idris" ]; then + echo "::error::could not read the tags (rust: ${rust:+found}${rust:-none}, idris: ${idris:+found}${idris:-none})" + exit 1 +fi +if [ "$rust" != "$idris" ]; then + echo "::error file=$idr::coprocessorKindToU8 disagrees with the Rust CoprocessorKind discriminants" + diff <(printf '%s\n' "$rust") <(printf '%s\n' "$idris") | sed 's/^/idris/' || true + exit 1 +fi +echo "coprocessor tags agree: $(printf '%s\n' "$rust" | wc -l) kinds" From cd52c7b04d60dac3913e176da99147706d737dd8 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 00:44:28 +0000 Subject: [PATCH 2/2] chore(ci): drop check-coprocessor-tags.sh from this branch It belongs to the separate coprocessor-tags change and was swept in by mistake. Nothing on this branch calls it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019a95kk88TZ1iegsBK3kox3 --- scripts/ci/check-coprocessor-tags.sh | 37 ---------------------------- 1 file changed, 37 deletions(-) delete mode 100755 scripts/ci/check-coprocessor-tags.sh diff --git a/scripts/ci/check-coprocessor-tags.sh b/scripts/ci/check-coprocessor-tags.sh deleted file mode 100755 index 34462faa..00000000 --- a/scripts/ci/check-coprocessor-tags.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: MPL-2.0 -# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell (hyperpolymath) -# -# The FFI tag of each coprocessor kind is written twice: as an explicit -# discriminant of the Rust `CoprocessorKind` (src/rust/coprocessor/types.rs) -# and as a clause of `coprocessorKindToU8` in src/abi/Coprocessor/Foreign.idr. -# Neither compiler sees the other file, so this compares the two lists as -# "Name=tag" pairs. It fails if either list is empty, if a Rust variant has no -# explicit discriminant, or if the pairs differ. -set -euo pipefail -root=${1:-.} -rs="$root/src/rust/coprocessor/types.rs" -idr="$root/src/abi/Coprocessor/Foreign.idr" - -body=$(awk '/^pub enum CoprocessorKind \{/{f=1;next} f&&/^\}/{exit} f' "$rs") -bare=$({ printf '%s\n' "$body" | grep -E '^[[:space:]]+[A-Z][A-Za-z0-9]*,[[:space:]]*$' || true; }) -if [ -n "$bare" ]; then - echo "::error file=$rs::CoprocessorKind variants without an explicit discriminant:" - printf '%s\n' "$bare" - exit 1 -fi -rust=$({ printf '%s\n' "$body" | grep -oE '^[[:space:]]+[A-Z][A-Za-z0-9]*[[:space:]]*=[[:space:]]*[0-9]+' || true; } \ - | tr -d ' ' | sort) -idris=$({ grep -oE '^coprocessorKindToU8[[:space:]]+[A-Z][A-Za-z0-9]*[[:space:]]*=[[:space:]]*[0-9]+' "$idr" || true; } \ - | sed -E 's/^coprocessorKindToU8[[:space:]]+//' | tr -d ' ' | sort) - -if [ -z "$rust" ] || [ -z "$idris" ]; then - echo "::error::could not read the tags (rust: ${rust:+found}${rust:-none}, idris: ${idris:+found}${idris:-none})" - exit 1 -fi -if [ "$rust" != "$idris" ]; then - echo "::error file=$idr::coprocessorKindToU8 disagrees with the Rust CoprocessorKind discriminants" - diff <(printf '%s\n' "$rust") <(printf '%s\n' "$idris") | sed 's/^/idris/' || true - exit 1 -fi -echo "coprocessor tags agree: $(printf '%s\n' "$rust" | wc -l) kinds"