From 67aa7bbd4dee88f87aa0803541635c7419cbbf90 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 02:09:42 +0000 Subject: [PATCH 1/2] ci: add the required `CI/gate` check and a declared coverage exemption The live Branch-Floor ruleset requires a status check named exactly `CI/gate` but no workflow reported it. Add a gate job to proofs.yml that aggregates the Agda, Lean and Rocq legs and the coverage-exemption check with needs:, and fails on failure, cancellation, skipping or an empty set. Declare the prover-only coverage exemption in .machine_readable/coverage-exemption.toml and verify it in CI. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01J4QvDf74BGYFzth9JRdGby --- .github/workflows/proofs.yml | 40 ++++++++++++++++++++ .machine_readable/coverage-exemption.toml | 13 +++++++ CHANGELOG.adoc | 12 ++++++ scripts/check-coverage-exemption.sh | 45 +++++++++++++++++++++++ scripts/ci-gate.sh | 35 ++++++++++++++++++ tests/workflows/ci_gate_test.sh | 35 ++++++++++++++++++ 6 files changed, 180 insertions(+) create mode 100644 .machine_readable/coverage-exemption.toml create mode 100755 scripts/check-coverage-exemption.sh create mode 100755 scripts/ci-gate.sh create mode 100755 tests/workflows/ci_gate_test.sh diff --git a/.github/workflows/proofs.yml b/.github/workflows/proofs.yml index 46c62f7..0dfef89 100644 --- a/.github/workflows/proofs.yml +++ b/.github/workflows/proofs.yml @@ -187,3 +187,43 @@ jobs: echo "- input SHA256: \`$(sha256sum ResourceAlgebra.v | cut -d' ' -f1)\`" echo "- assumptions: $n_closed of $n_print printed theorems closed under the global context" } >> "$GITHUB_STEP_SUMMARY" + + # Declared coverage exemption (see .machine_readable/coverage-exemption.toml). + # The live Branch-Floor ruleset carries an 80% code_coverage rule; a prover-only + # repository has no runtime code to measure. The exemption is declared in a + # file and checked here, so it cannot go stale silently. + coverage-exemption: + name: Coverage exemption holds + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + - name: Declared exemption is still true + run: bash scripts/check-coverage-exemption.sh + + # The required status check `CI/gate` (live Branch-Floor ruleset 25434034). + # It aggregates every other job in this workflow with `needs:` and fails + # unless ALL of them succeeded: failure, cancellation and skipping all fail, + # so it is never a rubber stamp. `if: always()` makes it run (and fail) when + # a needed job fails instead of being skipped, which a required check would + # report as passing-by-absence. tests/workflows/ci_gate_test.sh fails if a new + # job is added here without being added to `needs:`. + # Read-only permissions; the one `uses:` is the checkout already pinned in actions.lock. + gate: + name: CI/gate + needs: [proofs, lean-leg, rocq-leg, coverage-exemption] + if: ${{ always() }} + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + - name: All required jobs succeeded + env: + NEEDS_JSON: ${{ toJSON(needs) }} + run: bash scripts/ci-gate.sh diff --git a/.machine_readable/coverage-exemption.toml b/.machine_readable/coverage-exemption.toml new file mode 100644 index 0000000..268f2de --- /dev/null +++ b/.machine_readable/coverage-exemption.toml @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: MPL-2.0 +# Declared code-coverage exemption, verified by scripts/check-coverage-exemption.sh +# (job `coverage-exemption` in .github/workflows/proofs.yml, aggregated by CI/gate). +# +# This repository is prover-only: Agda, rechecked in Rocq and Lean. It has no +# runtime code, so a line-coverage percentage is undefined, not 0%. The claim is +# checked, not trusted: the job fails if runtime code appears under a product root. +measurable-runtime-code = false +product-roots = ["src"] +runtime-extensions = ["rs", "zig", "idr", "js", "ts", "py", "go", "c", "h", "cpp", "ex", "res"] +# Shrink-only. The Idris2/Zig ABI/FFI scaffold is still on main and is removed by +# hyperpolymath/resource-algebra#40; delete this entry when that merges. +pending-removal = ["src/interface"] diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index a2dbf89..ca41838 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -1,5 +1,17 @@ == Changelog +== 2026-11-17 — `CI/gate` required check and declared coverage exemption + +* `proofs.yml` gains a job named exactly `CI/gate` (the context the live + Branch-Floor ruleset requires). It aggregates `proofs`, `lean-leg`, `rocq-leg` + and `coverage-exemption` with `needs:` and fails if any failed, was cancelled + or was skipped, or if none were aggregated (`scripts/ci-gate.sh`). +* `.machine_readable/coverage-exemption.toml` declares that the repository has no + measurable runtime code; `scripts/check-coverage-exemption.sh` checks the + claim. `src/interface` is on a declared shrink-only pending list until #40. +* `tests/workflows/ci_gate_test.sh`: positive control, four negative cases, + `needs:` drift and a planted-runtime-code case. + == 2026-11-11 — Proof receipt and grades at f211fc1 * `verification/receipts/resource-algebra-proofs_praxis.deed`: the proof diff --git a/scripts/check-coverage-exemption.sh b/scripts/check-coverage-exemption.sh new file mode 100755 index 0000000..496febe --- /dev/null +++ b/scripts/check-coverage-exemption.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell +# +# check-coverage-exemption.sh — verify the DECLARED code-coverage exemption. +# +# .machine_readable/coverage-exemption.toml declares that this repository has +# no measurable runtime code (it is prover-only: Agda, with Rocq and Lean +# rechecks). A declaration nobody checks is a silent skip, so this script +# makes it falsifiable: it fails if a tracked file under a declared root has a +# runtime-code extension and is not on the declared, shrink-only pending list. +# +# Usage: check-coverage-exemption.sh [REPO_ROOT] +# Exit: 0 declaration holds; 1 it is false or malformed; 2 setup error. +set -euo pipefail +root="${1:-.}" +decl="$root/.machine_readable/coverage-exemption.toml" +[ -f "$decl" ] || { echo "check-coverage-exemption: $decl missing" >&2; exit 2; } +git -C "$root" rev-parse --git-dir >/dev/null 2>&1 || { echo "check-coverage-exemption: $root is not a git tree" >&2; exit 2; } + +# Minimal TOML reader: `key = true|false` and `key = ["a", "b"]` on one line. +scalar() { sed -n "s/^$1[[:space:]]*=[[:space:]]*\(.*[^[:space:]]\)[[:space:]]*$/\1/p" "$decl" | head -1; } +list() { scalar "$1" | tr -d '[]"' | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | sed '/^$/d'; } + +[ "$(scalar measurable-runtime-code)" = "false" ] || { + echo "::error::coverage-exemption: measurable-runtime-code is not false; this exemption does not apply" >&2; exit 1; } +mapfile -t roots < <(list product-roots) +mapfile -t exts < <(list runtime-extensions) +mapfile -t pending < <(list pending-removal) +[ "${#roots[@]}" -gt 0 ] && [ "${#exts[@]}" -gt 0 ] || { + echo "::error::coverage-exemption: product-roots and runtime-extensions must be non-empty" >&2; exit 1; } + +fail=0; seen=0 +while IFS= read -r f; do + seen=$((seen+1)) + ext="${f##*.}" + hit=0; for e in "${exts[@]}"; do [ "$ext" = "$e" ] && hit=1; done + [ "$hit" -eq 1 ] || continue + ok=0; for p in "${pending[@]}"; do case "$f" in "$p"/*|"$p") ok=1;; esac; done + if [ "$ok" -eq 1 ]; then echo "pending-removal (declared): $f"; continue; fi + echo "::error::coverage-exemption: runtime code under a declared root: $f" >&2; fail=1 +done < <(git -C "$root" ls-files -- "${roots[@]}") +[ "$seen" -gt 0 ] || { echo "::error::coverage-exemption: no tracked files under ${roots[*]} (denominator = 0)" >&2; exit 1; } +[ "$fail" -eq 0 ] || exit 1 +echo "coverage-exemption: holds ($seen tracked file(s) under ${roots[*]}, none runtime code outside the declared pending list)" diff --git a/scripts/ci-gate.sh b/scripts/ci-gate.sh new file mode 100755 index 0000000..2fd26cb --- /dev/null +++ b/scripts/ci-gate.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell +# +# ci-gate.sh — the verdict behind the required status check `CI/gate`. +# +# Reads the `needs` context of a GitHub Actions job (toJSON(needs)) from +# $NEEDS_JSON and succeeds only if at least one job was aggregated and EVERY +# one ended `success`. `failure`, `cancelled` and `skipped` all fail: a skipped +# prover leg is a leg that proved nothing, and a gate that counts it as green is +# a rubber stamp (doctrine 3, fail loudly). An empty or unparseable context +# fails too, so a gate pointed at zero jobs cannot pass. +# +# Exit: 0 all aggregated jobs succeeded; 1 a job did not, or none were given; +# 2 setup error (no jq, no NEEDS_JSON). +set -euo pipefail + +command -v jq >/dev/null 2>&1 || { echo "ci-gate: jq is required" >&2; exit 2; } +[ -n "${NEEDS_JSON:-}" ] || { echo "ci-gate: NEEDS_JSON is not set" >&2; exit 2; } + +total="$(jq -e 'length' <<<"$NEEDS_JSON")" || { echo "::error::ci-gate: NEEDS_JSON is not a JSON object"; exit 1; } +if [ "$total" -eq 0 ]; then + echo "::error::CI/gate aggregates no jobs (denominator = 0); refusing to pass." + exit 1 +fi + +echo "CI/gate: ${total} aggregated job(s)" +jq -r 'to_entries[] | " \(.key): \(.value.result)"' <<<"$NEEDS_JSON" + +bad="$(jq -r 'to_entries[] | select(.value.result != "success") | "\(.key)=\(.value.result)"' <<<"$NEEDS_JSON")" +if [ -n "$bad" ]; then + while IFS= read -r line; do echo "::error::CI/gate: required job did not succeed: ${line}"; done <<<"$bad" + exit 1 +fi +echo "CI/gate: all ${total} required job(s) succeeded" diff --git a/tests/workflows/ci_gate_test.sh b/tests/workflows/ci_gate_test.sh new file mode 100755 index 0000000..08188ed --- /dev/null +++ b/tests/workflows/ci_gate_test.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell +# CI/gate must be a verdict, not a rubber stamp. Positive control: all green +# passes. Negative cases: failure, cancelled, skipped, empty and malformed +# input each fail. Drift: the gate's `needs:` must list every other job in +# proofs.yml. Exemption: planting runtime code under src/ makes the declared +# coverage exemption fail. +set -uo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." +fail=0 +chk() { # chk NAME WANT-RC JSON + NEEDS_JSON="$3" bash scripts/ci-gate.sh >/dev/null 2>&1; rc=$? + if [ "$rc" -eq "$2" ]; then echo "ok $1"; else echo "FAIL $1: rc=$rc want $2"; fail=1; fi +} +chk "all success passes" 0 '{"a":{"result":"success"},"b":{"result":"success"}}' +chk "one failure fails" 1 '{"a":{"result":"success"},"b":{"result":"failure"}}' +chk "one cancelled fails" 1 '{"a":{"result":"success"},"b":{"result":"cancelled"}}' +chk "one skipped fails" 1 '{"a":{"result":"success"},"b":{"result":"skipped"}}' +chk "empty needs fails" 1 '{}' +chk "malformed fails" 1 'not json' + +wf=.github/workflows/proofs.yml +jobs="$(sed -n '/^jobs:/,$ s/^ \([a-z0-9-]*\):$/\1/p' "$wf" | grep -vx 'gate' | sort | tr '\n' ' ')" +needs="$(sed -n 's/^ needs: \[\(.*\)\]$/\1/p' "$wf" | tr -d ',' | tr ' ' '\n' | sort | tr '\n' ' ')" +if [ "$jobs" = "$needs" ]; then echo "ok gate needs every other job ($needs)"; else echo "FAIL needs drift: jobs=[$jobs] needs=[$needs]"; fail=1; fi +grep -q '^ name: CI/gate$' "$wf" && echo "ok job name is exactly CI/gate" || { echo "FAIL job name"; fail=1; } + +work=$(mktemp -d); trap 'rm -rf "$work"' EXIT +git ls-files -z | xargs -0 -I{} cp --parents {} "$work" 2>/dev/null +git -C "$work" init -q && git -C "$work" add -A >/dev/null 2>&1 +bash scripts/check-coverage-exemption.sh "$work" >/dev/null 2>&1 && echo "ok exemption holds on the tree" || { echo "FAIL exemption on clean tree"; fail=1; } +mkdir -p "$work/src/ResourceAlgebra" && echo 'fn main(){}' > "$work/src/ResourceAlgebra/planted.rs" && git -C "$work" add -A +bash scripts/check-coverage-exemption.sh "$work" >/dev/null 2>&1 && { echo "FAIL planted runtime code accepted"; fail=1; } || echo "ok planted runtime code rejected" +exit $fail From f8bb847a17b79eac42c16465b7aa6fbf5ada387b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 02:11:48 +0000 Subject: [PATCH 2/2] scratch: plant runtime code to prove CI/gate fails (do not merge) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01J4QvDf74BGYFzth9JRdGby --- src/planted.rs | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/planted.rs diff --git a/src/planted.rs b/src/planted.rs new file mode 100644 index 0000000..f328e4d --- /dev/null +++ b/src/planted.rs @@ -0,0 +1 @@ +fn main() {}