Skip to content

Commit 94fe849

Browse files
committed
fix(abi): type-check the Idris2 proofs in CI and re-prove line-comment stripping
No CI job had ever type-checked src/abi/, and with Idris2 0.7.0 none of the five modules checked as committed. PROOF-NEEDS.adoc marked them ✅ with no receipt. - scripts/ci/check-idris-abi.sh: stages a module-path view of the unchanged files (they declare PanicAttack.ABI.* but live flat) and type-checks each one. It fails on a type error, a missing %default total, or believe_me / assert_total / assert_smaller / postulate / idris_crash in code. Verified both ways: it passes here, fails on main's Stripping and Types, and fails on a planted believe_me. - proven-tests.yml: a blocking `idris-abi` job builds Idris2 from the v0.7.0 tag (commit checked), caches it, and runs the script. It records a PROOF-POLICY §6 deviation; actionlint is clean; it uses only already-locked action pins. - Stripping.idr: the 2026-06-02 proof never type-checked (unsolved constraint in the // case, decEq not imported). It is re-proved through stripIsIdOnClean (identity on //-free text) and stripIsClean / bodyIsClean (output is //-free, mutual induction). stripLineCommentsIdempotent and bodyIsFixedPoint follow. The strippers use explicit Bool steps. An exhaustive differential run over all 29,524 strings of length ≤ 9 on {/, x, \n} matches the previous definitions, and a mutant blanking with '/' is rejected. - Types.idr: adds the Eq Severity that Ord needs and fixes the LangId declaration syntax. - PROOF-NEEDS.adoc, EXPLAINME.adoc and CHANGELOG.adoc now record that the earlier claims had no receipt, and name the new one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PFaqv6iBXrt3W5Akd1Fq5k
1 parent f2a6a70 commit 94fe849

7 files changed

Lines changed: 359 additions & 181 deletions

File tree

‎.github/workflows/proven-tests.yml‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
# and it would make every contributor wait on a compiler that cannot change
2323
# for them.
2424
#
25+
# `idris-abi` (every PR, blocking): type-checks this repo's own Idris2 ABI
26+
# proofs in src/abi/. This is a departure from the rule above, made because
27+
# these proofs are claims in PROOF-NEEDS.adoc and a claim needs a receipt on
28+
# every change. Idris2 is built from source once and cached by version and
29+
# commit, so after the first run a PR waits only for the check itself.
30+
#
2531
# WHY THE REPORT IS A FILE, NOT A PARAGRAPH: docs/INTEROP-PANIC-ATTACK.adoc in
2632
# proven-tests-and-benches fixes the mapping in prose; a report plus a verifier
2733
# is the same mapping with something at stake.
@@ -191,3 +197,54 @@ jobs:
191197
path: .proven-tests/build/report/*.json
192198
retention-days: 30
193199
if-no-files-found: warn
200+
201+
# The Idris2 ABI proofs in src/abi/ (PA1, PA2, Layer 1.0 stripping,
202+
# attestation unforgeability, ABI types). Until this job, none was ever
203+
# type-checked. scripts/ci/check-idris-abi.sh fails on any type error,
204+
# a missing `%default total`, or an escape hatch.
205+
#
206+
# Deviation (PROOF-POLICY §6), state: open. Leg: Idris2 ABI proofs. Tool:
207+
# Idris2 0.7.0 built from the v0.7.0 tag (commit checked below) with the
208+
# runner's Chez Scheme. Why not Guix or the container: panic-attack's Guix
209+
# manifest and container do not provide Idris2 yet.
210+
idris-abi:
211+
name: Idris2 ABI proofs type-check
212+
runs-on: ubuntu-latest
213+
timeout-minutes: 45
214+
env:
215+
IDRIS2_COMMIT: 27780073c8631826d846499840b3857d9b9a4fd5
216+
steps:
217+
- name: Checkout this repository
218+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
219+
with:
220+
persist-credentials: false
221+
222+
- name: Cache the Idris2 toolchain built from source
223+
id: idris2-cache
224+
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
225+
with:
226+
path: ~/.idris2-src-build
227+
key: idris2-src-${{ env.IDRIS2_VERSION }}-${{ env.IDRIS2_COMMIT }}-${{ runner.os }}
228+
229+
- name: Build Idris2 from the pinned tag (cache miss only)
230+
if: steps.idris2-cache.outputs.cache-hit != 'true'
231+
shell: bash
232+
run: |
233+
set -euo pipefail
234+
sudo apt-get update -qq
235+
sudo apt-get install -y -qq chezscheme
236+
src=$(mktemp -d)
237+
git clone --quiet --depth 1 --branch "v${IDRIS2_VERSION}" \
238+
https://github.com/idris-lang/Idris2.git "$src"
239+
test "$(git -C "$src" rev-parse HEAD)" = "$IDRIS2_COMMIT"
240+
make -C "$src" bootstrap SCHEME=scheme PREFIX="$HOME/.idris2-src-build"
241+
make -C "$src" install PREFIX="$HOME/.idris2-src-build"
242+
243+
- name: Type-check every module in src/abi
244+
shell: bash
245+
run: |
246+
set -euo pipefail
247+
# The cached build still needs Chez Scheme at run time.
248+
command -v scheme >/dev/null || { sudo apt-get update -qq && sudo apt-get install -y -qq chezscheme; }
249+
export PATH="$HOME/.idris2-src-build/bin:$PATH"
250+
bash scripts/ci/check-idris-abi.sh

‎CHANGELOG.adoc‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
=== [Unreleased]
44

5+
==== Fixed — the Idris2 ABI proofs are type-checked, and the stripping proof is re-proved
6+
7+
* No CI job had ever type-checked `+src/abi/+`, and as committed none of its
8+
five modules checked. A new `+idris-abi+` job (`+proven-tests.yml+`, using
9+
`+scripts/ci/check-idris-abi.sh+`) now checks all five on every PR with Idris2
10+
0.7.0. It fails on a type error, on a missing `+%default total+`, or on
11+
`+believe_me+`, `+assert_total+`, `+assert_smaller+`, `+postulate+` or
12+
`+idris_crash+`.
13+
* `+Stripping.idr+`: the 2026-06-02 proof of `+stripLineCommentsIdempotent+`
14+
never type-checked, so it is re-proved through two facts: stripping is the
15+
identity on text with no `+//+`, and the strippers' output has no `+//+`. The
16+
strippers are restated with explicit `+Bool+` tests. An exhaustive run over
17+
29,524 inputs shows they behave exactly as before.
18+
* `+Types.idr+`: adds the missing `+Eq Severity+` that `+Ord+` needs, and fixes
19+
the `+LangId+` declaration syntax.
20+
* `+PROOF-NEEDS.adoc+` and `+EXPLAINME.adoc+` now say that the earlier claims had
21+
no receipt.
22+
523
==== Added — `+assail --output-format kyaml+` writes a KYAML copy
624

725
* With `+--output-format kyaml+` and `+--output report.json+`, `+assail+` writes

‎EXPLAINME.adoc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ The README makes claims. This file backs them up.
5454
| `src/jit_context.rs` | JIT-framework classifier: Cranelift / Llvm / Wasm / Javascript / None; `transmute_targets_fn_ptr` recogniser for fn-ptr type-punning
5555
| `src/abi/PatternCompleteness.idr` | PA1 Idris2 proof — every Lang/Category has a detector
5656
| `src/abi/ClassificationSoundness.idr` | PA2 Idris2 proof — severity total order + maxSeverity commutativity
57-
| `src/abi/Stripping.idr` | Layer 1.0 partial — line-comment-strip foundation (shape lemma + base cases of `stripLineCommentsIdempotent` Qed-closed)
57+
| `src/abi/Stripping.idr` | Layer 1.0 — line-comment stripping is idempotent (`stripLineCommentsIdempotent`; re-proved 2026-11-09, type-checked by the `idris-abi` CI job)
5858
| `src/kanren/` | Logic engine (unification, fact database, taint, cross-lang)
5959
| `src/kanren/core.rs` | Term, substitution, unification, FactDB, forward chaining
6060
| `src/kanren/taint.rs` | Source→sink tracking (user input, network, deserialization)

‎PROOF-NEEDS.adoc‎

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@
22

33
=== Current State
44

5+
*Receipts (2026-11-09).* Until this date no CI job type-checked
6+
`+src/abi/+`, and as committed none of the five modules checked: their module
7+
names did not match their paths, `+Types.idr+` and `+Stripping.idr+` had syntax
8+
errors, and `+Stripping.idr+`'s main theorem did not type-check at all. The ✅
9+
marks below therefore had no receipt before that date. Each module is now
10+
checked on every PR by the `+idris-abi+` job in
11+
`+.github/workflows/proven-tests.yml+` (`+scripts/ci/check-idris-abi.sh+`, Idris2
12+
0.7.0, `+%default total+`, no `+believe_me+`, `+assert_total+`,
13+
`+assert_smaller+`, `+postulate+` or `+idris_crash+`). PROOF-POLICY §6 deviation,
14+
state open: Idris2 is built from its v0.7.0 tag, because the repo's Guix
15+
manifest and container do not provide it.
16+
517
* **src/abi/*.idr**: 5 files — `+Types.idr+`,
618
`+PatternCompleteness.idr+` (PA1 ✅ 2026-04-11),
719
`+ClassificationSoundness.idr+` (PA2 ✅ 2026-04-11), `+Stripping.idr+`
8-
(PROOF-PROGRAMME Layer 1.0 line-comment slice ✅ 2026-06-02 —
9-
multi-comment semantics + slash-slash closure both Qed via
10-
mutual-recursive `+bodyIsFixedPoint+`),
20+
(PROOF-PROGRAMME Layer 1.0 line-comment slice: claimed 2026-06-02 but
21+
never checked; re-proved and checked 2026-11-09),
1122
`+AttestationUnforgeability.idr+` (PROOF-PROGRAMME §3.2 ✅ 2026-06-04 —
1223
conditional unforgeability from Ed25519 EUF-CMA + chain-hash
1324
collision-resistance hypotheses)
@@ -34,15 +45,19 @@ top-level theorem.
3445
preserves the ordering.
3546

3647
|Layer 1.0 line-comment idempotence |`+src/abi/Stripping.idr+`
37-
|*2026-06-02 close-out (issue #113)*: corrects PR #111’s single-comment
38-
model to multi-comment via mutual recursion
39-
(`+stripLineComments ↔ stripLineCommentBody+` — body calls back into
40-
main after each preserved newline). Qed-closes
41-
`+stripLineCommentsIdempotent+` for ALL cases including the slash-slash
42-
inductive via the load-bearing `+bodyIsFixedPoint+` lemma proved by
43-
mutual induction with the main theorem. 7 sanity-check theorems
44-
including the two-comments-on-different-lines case PR #111 silently
45-
mis-stripped.
48+
|*Re-proved 2026-11-09.* The 2026-06-02 proof (issue #113) never
49+
type-checked: its `+//+` case relied on reductions that do not hold for a
50+
variable character, and it used `+decEq+` without importing it. The new proof
51+
shows `+stripLineCommentsIdempotent+` (stripping twice equals stripping once)
52+
through two facts: stripping is the identity on text with no `+//+`
53+
(`+stripIsIdOnClean+`), and the strippers' output has no `+//+`
54+
(`+stripIsClean+`/`+bodyIsClean+`, by mutual induction). `+bodyIsFixedPoint+`
55+
follows. The strippers are restated with explicit `+Bool+` tests. An
56+
exhaustive differential run over every string of length up to 9 on
57+
`+{/, x, \n}+` (29,524 inputs) found no difference from the previous
58+
definitions. A mutant that blanks with `+/+` instead of a space is rejected.
59+
Nine closed sanity theorems, including two comments on different lines and
60+
`+///+`.
4661

4762
|Attestation chain unforgeability
4863
|`+src/abi/AttestationUnforgeability.idr+` |*PROOF-PROGRAMME §3.2

‎scripts/ci/check-idris-abi.sh‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: MPL-2.0
3+
# SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
4+
#
5+
# Type-check every Idris2 module in src/abi/ and fail loudly on any error or
6+
# escape hatch. This is the receipt for the ABI proofs listed in
7+
# PROOF-NEEDS.adoc: until this ran, none of them had ever been checked.
8+
#
9+
# The files declare `module PanicAttack.ABI.<Name>` but live flat in
10+
# src/abi/, and Idris2 requires a module's path to match its name. Moving
11+
# them would break paths cited in legacy A2ML metadata, which agents may not
12+
# edit, so this script stages a module-path view of the unchanged files as
13+
# symbolic links and checks that. The bytes checked are the committed bytes.
14+
#
15+
# Requirements per module:
16+
# * `idris2 --check` succeeds under the pinned Idris2 version;
17+
# * the file states `%default total`;
18+
# * no believe_me, assert_total, assert_smaller, postulate or idris_crash
19+
# outside comments.
20+
#
21+
# Usage: scripts/ci/check-idris-abi.sh (idris2 0.7.0 on PATH)
22+
set -euo pipefail
23+
24+
IDRIS2_VERSION=0.7.0
25+
root=$(cd "$(dirname "$0")/../.." && pwd)
26+
abi="$root/src/abi"
27+
28+
version=$(idris2 --version)
29+
[[ "$version" == "Idris 2, version $IDRIS2_VERSION"* ]] ||
30+
{ echo "check-idris-abi: need Idris2 $IDRIS2_VERSION, got: $version" >&2; exit 2; }
31+
32+
stage=$(mktemp -d)
33+
trap 'rm -rf "$stage"' EXIT
34+
mkdir -p "$stage/PanicAttack/ABI"
35+
36+
failures=0
37+
shopt -s nullglob
38+
files=("$abi"/*.idr)
39+
[[ ${#files[@]} -gt 0 ]] || { echo "check-idris-abi: no modules in $abi" >&2; exit 2; }
40+
41+
for file in "${files[@]}"; do
42+
name=$(basename "$file" .idr)
43+
declared=$(sed -n 's/^module[[:space:]]\{1,\}\([A-Za-z0-9_.]*\).*/\1/p' "$file" | head -1)
44+
if [[ "$declared" != "PanicAttack.ABI.$name" ]]; then
45+
echo "FAIL $name: declares module '$declared', expected PanicAttack.ABI.$name"
46+
failures=$((failures + 1)); continue
47+
fi
48+
ln -s "$file" "$stage/PanicAttack/ABI/$name.idr"
49+
done
50+
51+
for file in "${files[@]}"; do
52+
name=$(basename "$file" .idr)
53+
[[ -L "$stage/PanicAttack/ABI/$name.idr" ]] || continue
54+
# Code lines only: drop `--` and `|||` comment lines before searching.
55+
code=$(grep -vE '^[[:space:]]*(--|\|\|\|)' "$file" || true)
56+
if ! grep -qE '^%default[[:space:]]+total' <<<"$code"; then
57+
echo "FAIL $name: missing %default total"; failures=$((failures + 1)); continue
58+
fi
59+
if hatch=$(grep -nE '\b(believe_me|assert_total|assert_smaller|postulate|idris_crash)\b' <<<"$code"); then
60+
echo "FAIL $name: escape hatch: $hatch"; failures=$((failures + 1)); continue
61+
fi
62+
if out=$(cd "$stage" && idris2 --no-color --check "PanicAttack/ABI/$name.idr" 2>&1); then
63+
echo "PASS $name"
64+
else
65+
echo "FAIL $name"; printf '%s\n' "$out" | sed -n '1,40p'; failures=$((failures + 1))
66+
fi
67+
done
68+
exit "$failures"

0 commit comments

Comments
 (0)