Skip to content

Commit da1ae55

Browse files
Merge branch 'main' into claude/compassionate-fermat-9x7vpe-proofdrift-lines
Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
2 parents 7bf8fa9 + d4a68ed commit da1ae55

26 files changed

Lines changed: 2171 additions & 225 deletions

‎.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

‎.github/workflows/verify.yml‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,32 @@ jobs:
242242
assert any(i.get('status') not in ('analyzed', 'excluded') for i in coverage['inputs']), coverage
243243
print(f"coverage={coverage['status']} (gap recorded)")
244244
PY
245+
246+
# The generation-publish protocol (src/publish.rs) is model-checked with TLC,
247+
# PROOF-POLICY §4's worked exception for concurrency protocols. Results are
248+
# TESTED with the bounds in each .cfg, never PROVEN. Every config states its
249+
# expected outcome; the expected violations (the documented mirror limit and
250+
# three mutants) show the invariants can fail.
251+
#
252+
# Deviation (PROOF-POLICY §6), state: open. Leg: protocol model check. Tool:
253+
# tla2tools.jar v1.7.4 (TLC 2.19), SHA-256 below, checked by check.sh. Why not
254+
# Guix or the container: neither provides TLC yet. Java comes from the runner.
255+
tlaplus:
256+
name: TLA+ model check (GenerationPublish)
257+
runs-on: ubuntu-latest
258+
timeout-minutes: 20
259+
steps:
260+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
261+
with:
262+
persist-credentials: false
263+
- name: Fetch the pinned TLC and model-check every config
264+
shell: bash
265+
run: |
266+
set -euo pipefail
267+
java -version
268+
tools_dir=$(mktemp -d)
269+
trap 'rm -rf "$tools_dir"' EXIT
270+
curl --fail --silent --show-error --location --max-time 120 \
271+
https://github.com/tlaplus/tlaplus/releases/download/v1.7.4/tla2tools.jar \
272+
--output "$tools_dir/tla2tools.jar"
273+
TLA2TOOLS="$tools_dir/tla2tools.jar" bash verification/proofs/tlaplus/check.sh

‎CHANGELOG.adoc‎

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,23 @@
22

33
=== [Unreleased]
44

5-
==== Changed — Lean and Isabelle `+sorry+` findings are line-anchored
6-
7-
* Each `+sorry+` in a Lean or Isabelle file is now its own ProofDrift finding
8-
with a `+line+`, instead of one finding per file with a count and no line.
9-
A file with three `+sorry+` therefore reports three Critical findings; the
10-
pass/fail outcome of a severity gate is unchanged.
11-
* Because the findings now carry a line, an inline
12-
`+panic-attack: accepted+` marker on the same or previous line suppresses
13-
that occurrence, and only that one. Before, these findings could only be
14-
suppressed through the retired A2ML classification registry, which matches a
15-
whole file and category.
16-
* The comment strippers behind the proof detectors now keep every newline of
17-
a removed comment or Isabelle prose block, so line numbers taken from the
18-
stripped text are line numbers in the file. A property test checks this.
19-
20-
==== Added — `+(*+` marker leader
21-
22-
* `+(* panic-attack: accepted … *)+` is recognised at the start of a line, for
23-
Isabelle, Coq/Rocq, OCaml, SML and F*. The trailing `+*)+` is dropped from the
24-
recorded reason. Mid-line `+(*+` is not a leader, because it is also a C
25-
dereference or a Python splat.
26-
27-
==== Fixed — inline markers when the scan root is not the working directory
28-
29-
* `+assail <dir>+` run from anywhere but `+<dir>+` ignored every inline marker.
30-
Finding locations are relative to the scan root, but the marker pass read them
31-
relative to the process working directory, so the read failed silently.
32-
Locations are now resolved against the scan root first.
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.
3322

3423
==== Added — `+assail --output-format kyaml+` writes a KYAML copy
3524

@@ -41,6 +30,10 @@ may be the same file: a symbolic link at any of their paths, or two existing
4130
paths that are hard links to one file, is refused before anything is written.
4231
So is a path that exists but is not a regular file (a directory, say) or that
4332
cannot be looked up, such as a derived name over the filesystem's length limit.
33+
Each output is also opened for writing before anything is written (an absent
34+
one is created and removed again), so a read-only copy or sidecar, or a
35+
directory the caller cannot create files in, is refused too, instead of
36+
failing after the report has been replaced.
4437
These checks run before the writes, so a link swapped in between a check and
4538
its write is not caught, and a crash can leave a partial file: the planned
4639
generation-directory publish is meant to close both.

‎Cargo.lock‎

Lines changed: 9 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎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: 53 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
@@ -66,11 +81,37 @@ obligation. The gateway octad projection is lossy by design, so this property
6681
also does not establish a faithful hexad↔octad map.
6782
|===
6883

84+
=== Model-Checked (TESTED, bounded)
85+
86+
[width="100%",cols="26%,30%,44%",options="header",]
87+
|===
88+
|Obligation |Artefact |Status and bounds
89+
|Generation-publish protocol P1–P3 (prototype, `src/publish.rs`;
90+
design `docs/design/GENERATION-PUBLISH.adoc`) |`verification/proofs/tlaplus/GenerationPublish.tla`
91+
(TLC 2.19, tla2tools v1.7.4, run by `verify.yml` job `tlaplus`) and
92+
`tests/publish_model.rs` (independent explicit-state checker) |*TESTED*: up to
93+
3 writers, 1 reader, 2 files, crash at every writer step, collection of crashed
94+
and live writers' partial generations, `keep` 0 and 1. P1 (`CURRENT` names a
95+
complete generation), P2 (never moves backwards) and P3 (manifest reader never
96+
fails) hold. P4 (mirrors consistent once quiet) holds without crashes and
97+
*fails* after a crash, the documented limit. Three mutants each violate P1 or
98+
P2, so the invariants are not vacuous. *PROOF-POLICY §4 exception*: a
99+
concurrency protocol over crash interleavings, which Creusot and Verus do not
100+
state. *§6 deviation (open)*: TLC is fetched from its release, digest-checked,
101+
because neither Guix nor the container provides it yet.
102+
|===
103+
69104
=== What Still Needs Proving
70105

71106
[width="100%",cols="51%,27%,22%",options="header",]
72107
|===
73108
|Component |What |Why
109+
|Generation publish: pure decisions (`src/publish.rs`) |*OPEN* (PROOF-POLICY
110+
§1.2): Creusot/Pearlite and Verus contracts for the supersede comparison and
111+
the collect selection (never removes the current or a newer generation; keeps
112+
the `keep` newest older ones) |The model check covers the protocol, not the Rust
113+
code; these tie the implementation to P1 and P2
114+
74115
|*Layer 1.0 — stripBlockComments + Strings + Composition +
75116
Position-Preservation* (issue #114) |Block-comment (`+/* */+`) and
76117
string-literal (`+"..."+`) strippers with same mutual-recursive shape;

0 commit comments

Comments
 (0)