Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/proofs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
name: Core proofs and expected rejections
runs-on: ubuntu-latest
timeout-minutes: 15
container: debian:trixie-slim

Check warning on line 32 in .github/workflows/proofs.yml

View workflow job for this annotation

GitHub Actions / Hypatia neurosymbolic scan

[hypatia] workflow .github/workflows/proofs.yml:32 pins container `debian:trixie-slim` by tag — tag is mutable; pin by sha256 digest instead
steps:
- name: Install the pinned prover
run: |
Expand Down Expand Up @@ -187,3 +187,43 @@
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
13 changes: 13 additions & 0 deletions .machine_readable/coverage-exemption.toml
Original file line number Diff line number Diff line change
@@ -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"]
12 changes: 12 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
45 changes: 45 additions & 0 deletions scripts/check-coverage-exemption.sh
Original file line number Diff line number Diff line change
@@ -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)"
35 changes: 35 additions & 0 deletions scripts/ci-gate.sh
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions src/planted.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}

Check warning on line 1 in src/planted.rs

View workflow job for this annotation

GitHub Actions / Hypatia neurosymbolic scan

[hypatia] Source file missing SPDX-License-Identifier header
35 changes: 35 additions & 0 deletions tests/workflows/ci_gate_test.sh
Original file line number Diff line number Diff line change
@@ -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
Loading