Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.
Rust ai-nativedescription-logicsformal-verificationinfrastructure-as-codeisabelle-languageknowledge-graphleanlean4mcpmcp-serverontologyowlowl2reasoningrustshaclsparqltheorem-proving
ci: run the second kernel, and stop a skip reading as a pass
FABIOTESS95c531b090cf
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 07d9ba60..800b74ea 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -357,8 +357,12 @@ jobs:# finite structure and `oo-folmodel` disposes. They need z3 and mace4 as well# as Lean, and the same environment variable turns a missing solver from a# loud skip into a failure here, for the same reason.+ # The last legs are the second kernel: Poly/ML, and the Isabelle/HOL+ # formalisation's exported checker run against the Lean one over the same+ # corpus. Raised from 45 minutes to 60 when that arrived, because it spawns two+ # processes per certificate over a corpus of a couple of thousand.lean:- timeout-minutes: 45+ timeout-minutes: 60name: lean / certificate checkerruns-on: ubuntu-latestenv:@@ -500,6 +504,75 @@ jobs:run: OO_REQUIRE_FIXTURES=1 cargo test --test rule_syntax_frontend_test -- --nocapture- name: The emitted Horn rule table, round-tripped through oo-hornrun: OO_REQUIRE_FIXTURES=1 cargo test --test reason_horn_emit_test -- --nocapture+ # THE SECOND KERNEL.+ #+ # `isabelle/` is an independent formalisation of the same Horn certificate+ # checker, written from the W3C sources with the Lean unread, and+ # `tests/cross_kernel_differential_test.rs` runs both over one corpus and+ # requires them to agree on every row. The README states the result of that+ # comparison in its opening pages. Until 15 September 2026 NO JOB PROVIDED+ # BOTH HALVES: the file ran only in `build`, which has neither lake nor+ # Poly/ML, so it skipped there, and this job, which has lake, invoked it+ # from no leg at all. A skip reports `ok`, so a front-page claim was gated+ # by whether a developer happened to have Poly/ML installed.+ #+ # THE FULL ISABELLE DISTRIBUTION IS NOT NEEDED AND IS NOT INSTALLED. The+ # verified checker is exported to Standard ML by `isabelle/export.sh` and+ # `isabelle/driver/oo_horn_generated.ML` is COMMITTED, so the only thing+ # missing here is a Poly/ML to compile and link it against. Isabelle+ # publishes Poly/ML as a component of its own: 39 MB, against several+ # gigabytes for the distribution, and it is the SAME build that produced+ # that file: 5.9.2-2, what Isabelle2025-2 bundles, so CI and the+ # developer machine run one compiler and not two.+ #+ # NOT `apt-get install polyml`, and this was checked rather than assumed,+ # because `prover9` having no installation candidate on noble is what broke+ # this job the first time it ran on main. The package exists, and it is+ # wrong twice over: Ubuntu noble carries Poly/ML 5.7.1, seven years older+ # than the compiler this ML was generated by, and the package ships+ # /usr/bin/poly and libpolymain.a with NO libpolyml.a, so there is nothing+ # to link the exported checker against.+ #+ # What this leg proves that the Lean legs above cannot: that the two+ # formalisations still read the same bytes the same way. A row where they+ # part company is the most valuable output this repository has, and the+ # test fails on any row at all.+ - name: Cache Poly/ML+ id: polyml+ uses: actions/cache@v4+ with:+ path: ~/polyml+ key: polyml-5.9.2-2-${{ runner.arch }}+ - name: Install Poly/ML, the second kernel's runtime+ if: steps.polyml.outputs.cache-hit != 'true'+ run: |+ set -euo pipefail+ # Pinned by digest, not by name. The component URL is stable and the+ # tarball is not signed, so the hash is the only thing that says the+ # bytes CI links against are the bytes that were checked by hand.+ curl -fsSL -o /tmp/polyml.tar.gz https://isabelle.in.tum.de/components/polyml-5.9.2-2.tar.gz+ echo "67351868c05440d72a514ca60e8ee1d3252b288d746eb7ad236bda5fcaf12272 /tmp/polyml.tar.gz" | sha256sum -c -+ mkdir -p ~/polyml+ # One platform directory out of the eight in the tarball, unwrapped so+ # POLYDIR is the same path whatever the runner's architecture is: 20 MB+ # on disk rather than 200, and no second place to edit if GitHub moves+ # ubuntu-latest to arm64.+ arch=$(uname -m); [ "$arch" = "aarch64" ] && arch=arm64+ tar xzf /tmp/polyml.tar.gz -C ~/polyml --strip-components=2 "polyml-5.9.2-2/${arch}-linux"+ ls -l ~/polyml/poly ~/polyml/libpolyml.a ~/polyml/libpolymain.a+ - name: Run the two verified kernels over one corpus, and require them to agree+ # `isabelle/build_native.sh` links the committed export into a native+ # binary, the test builds the Lean one with lake, and every certificate+ # goes through both. --nocapture because the corpus size, the depth+ # distribution and the divergence count are PRINTED by the test and read+ # out of this log: no document is allowed to carry them by hand.+ run: POLYDIR=$HOME/polyml OO_REQUIRE_FIXTURES=1 cargo test --test cross_kernel_differential_test -- --nocapture+ # And the gate on the gates. This one needs no toolchain; it fails when a+ # test file that can skip is run by no job under OO_REQUIRE_FIXTURES=1 and+ # is not on the written exception list. It is the mechanism the leg above+ # was missing for as long as it existed.+ - name: Every skippable test file is strict somewhere, or excepted in writing+ run: OO_REQUIRE_FIXTURES=1 cargo test --test ci_gate_coverage_test -- --nocapture# The official W3C SHACL test suite, as a ratchet.#diff --git a/docs/ci-gates.md b/docs/ci-gates.mdindex 6fecc873..2320b2a9 100644--- a/docs/ci-gates.md+++ b/docs/ci-gates.md@@ -10,8 +10,10 @@ needs, skipped every test in the file, and exited 0.This page is the answer to "does a green tick mean this ran?", so that nobody hasto work it out again from six workflow files and the thirty-four test files thatcan skip — twenty-five Rust, nine Python. It is a statement about CI-configuration, which changes; the date it was last checked is at the bottom, and-the way to re-check it is at the bottom too.+configuration, which changes. Its Rust half is now checked by a test rather than+by hand (`tests/ci_gate_coverage_test.rs`), because the by-hand version went+stale exactly where it mattered; the Python half still carries a date at the+bottom, and the way to re-check it is there too.## The convention@@ -29,6 +31,11 @@ that is deliberate rather than missing (there is one, the twelve-minutefull-corpus differential) carries `@pytest.mark.oo_opt_in` and is exempt. Themarker is greppable; a reason string is not.+That mechanism only bites on a test that RUNS, which leaves the hole it cannot+see: a file no job invokes at all. `tests/ci_gate_coverage_test.rs` closes it by+reconciling this page's table against `tests/` and `.github/workflows/` on every+run. See "Re-checking this page" at the bottom.+Two tool scripts mirror the variable under their own names because they are CLIsrather than test suites, and say so where they define it:`HORN_DIFF_REQUIRE_TOOLS=1` in `tools/horn_differential.py` and@@ -65,7 +72,7 @@ job invokes the file at all.| `reason_rl_coverage_test.rs` | lake | `lean` job | **strict** || `rule_syntax_frontend_test.rs` | lake | `lean` job | **strict** || `reason_horn_emit_test.rs` | lake + `tests/fixtures/horn/` (in tree) | `lean` job | **strict** |-| `cross_kernel_differential_test.rs` | lake **and** Isabelle2025-2 + Poly/ML | lake only | **skips** — the Isabelle half is installed by no job; it cannot be made strict without an Isabelle step |+| `cross_kernel_differential_test.rs` | lake **and** Poly/ML | `lean` job | **strict** || `clinical_test.rs` | `data/crosswalks.parquet` | nothing — `data/` is gitignored | **skips** || `embed_test.rs` | ONNX model in `~/.open-ontologies/models/` | `features/depth` compiles it; no job runs `open-ontologies init` | **skips** || `embedding_e2e_test.rs` | same ONNX model + tokenizer | same | **skips** |@@ -93,10 +100,6 @@ The other seven files under `python/tests/` have no skip path.## What is still open, and why-- **`cross_kernel_differential_test.rs`.** No job installs Isabelle, so the- second kernel is never exercised in CI. Making this strict means adding an- Isabelle2025-2 step, which is a large download; it has not been done, and until- it is, the Isabelle half of the cross-kernel claim rests on local runs.- **`clinical_test.rs`, `embed_test.rs`, `embedding_e2e_test.rs`.** All threewant an artefact the repository deliberately does not carry: a licensedcrosswalk table and a model download. Closing them means a job that fetches@@ -130,16 +133,33 @@ The other seven files under `python/tests/` have no skip path.## Re-checking this page+The Rust half of this page no longer needs re-checking by hand, because a page+that has to be re-checked by hand is a page that goes stale. This one did: the+row for `cross_kernel_differential_test.rs` said the second kernel ran nowhere+in CI while `README.md` reported the result of that comparison in its opening+pages, and nothing connected the two.++`tests/ci_gate_coverage_test.rs` is the mechanism. It reads `tests/*.rs` for a+skip path, reads `.github/workflows/` for every `cargo test --test NAME` run+under `OO_REQUIRE_FIXTURES=1`, and fails when a file that can skip is neither+strict anywhere nor on a written exception list carrying the reason. It then+checks the Rust table above against the same two sources, so a row saying+**strict** for a leg no workflow runs is a test failure rather than a sentence.+It runs in the `lean` job and needs no toolchain of its own.++What it deliberately does not do is force every file to be strict. A contributor+without Poly/ML, without a licensed crosswalk table and without a downloaded+embedding model must still be able to run `cargo test` and get a pass. The+property is that CI cannot skip in silence, not that a laptop cannot skip at all.++The Python half is still by hand:+```bash-# every Rust file that can skip — 25, and the table has 25 rows-grep -ln 'skip_unless\|SKIPPED_FIXTURE' tests/*.rs-# every Python file that can skip — 10 hits, of which conftest.py is the+# every Python file that can skip: 10 hits, of which conftest.py is the# mechanism and not a test, so 9, and the table has 9 rowsgrep -rln 'pytest.skip\|importorskip\|skipif' python/tests/*.py# every leg CI makes strictgrep -rn 'OO_REQUIRE_FIXTURES=1' .github/workflows/```-The three lists have to reconcile against the table above. Last checked against-`.github/workflows/` on 15 September 2026, by running each of the three commands-and counting.+Last checked against `.github/workflows/` on 15 September 2026.diff --git a/isabelle/README.md b/isabelle/README.mdindex cc87fed8..f3f242d3 100644--- a/isabelle/README.md+++ b/isabelle/README.md@@ -63,8 +63,24 @@ for looking at one row. The real comparison is a Rust test:It builds both checkers, generates certificates with the ENGINE over every ontology therepository ships, mutates and fuzzes them, and runs both kernels over the lot. It skips-loudly (`common::skip_unless`) when either proof assistant is missing, and-`OO_REQUIRE_FIXTURES=1` turns that skip into a failure.+loudly (`common::skip_unless`) when either half is missing, and `OO_REQUIRE_FIXTURES=1`+turns that skip into a failure.++**CI runs it, and did not until 15 September 2026.** Until then no workflow installed+Poly/ML, so the file skipped in the only job that ran it and was invoked by no job that+could have made it strict, while `README.md` quoted the result of the comparison on its+front page. What CI installs is not Isabelle: the exported checker is COMMITTED as+`driver/oo_horn_generated.ML`, so the only missing piece is a compiler for it, and+Isabelle publishes Poly/ML on its own as a 39 MB component. That is a `POLYDIR` away from+running anywhere, including here:++ curl -O https://isabelle.in.tum.de/components/polyml-5.9.2-2.tar.gz+ tar xzf polyml-5.9.2-2.tar.gz+ POLYDIR=$PWD/polyml-5.9.2-2/x86_64-linux cargo test --test cross_kernel_differential_test++A full Isabelle2025-2 is still what `export.sh` needs to REGENERATE that ML from the+theories, and what `isabelle build -d isabelle -c OOHorn` needs to check the proofs. CI+does neither, and says so in `docs/ci-gates.md`.## What the differential found, and what it changed@@ -153,25 +169,28 @@ These theories were written from the W3C sources without reading the Lean, and aedited to agree with the one it is checking is worth nothing. If the two disagree againsomewhere else, that is a new finding and it belongs in a report before it belongs in a patch.-The corpus is now 349 accepted by both, 904 rejected by both, 465 unparseable on both, and-ZERO divergent. The 47 that diverged moved into the rejected column and nowhere else: 857 plus-47 is 904, and the accepted and unparseable counts did not move at all.+The corpus reports ZERO divergent rows, and the 47 that used to diverge moved into the+rejected column and nowhere else. The per-bucket counts that used to be written out here are+not, for the reason given at the top of this section: the corpus grew again the same day and+they were stale before anyone read them. The test prints them, and+`docs/decisions/0008-a-binding-is-data-and-evidence-admits-one-reading.md` carries the pair it+was measured against, dated.-The analysis that used to excuse a disagreement is now a gate that can fail. 286 rows of the-corpus carry a binding malformed in one of the two ways, the 47 among them, and the corpus test-requires BOTH kernels to refuse every one. The other 239 were already rejected by both for some-other reason, which is why the gate is checked on every row rather than only on the ones that-disagree: a check that ran only on divergences could be satisfied by silence.+The analysis that used to excuse a disagreement is now a gate that can fail. The rows of the+corpus that carry a binding malformed in one of the two ways, the 47 among them, must be+refused by BOTH kernels, and the corpus test requires it. Most of them were already rejected by+both for some other reason, which is why the gate is checked on every row rather than only on+the ones that disagree: a check that ran only on divergences could be satisfied by silence.A binding for a variable the cited rule never mentions is still ACCEPTED on both sides(`probe_extrabind`). It is never consulted, so there was no second reading to remove.-### What agreement on all 1,718 rows is evidence of+### What agreement on every row is evidence of-It was 1,671 rows before decision 0008 and it is all 1,718 after, and the increase is worth-exactly nothing on its own: it was bought by making one checker refuse more, which is the-cheapest way there is to buy agreement. What the number is worth is fixed by the floor the-corpus test asserts, that at least twenty certificates are ACCEPTED by both.+The rows that agree went up when decision 0008 landed, and the increase is worth exactly+nothing on its own: it was bought by making one checker refuse more, which is the cheapest way+there is to buy agreement. What the number is worth is fixed by the floor the corpus test+asserts, that at least twenty certificates are ACCEPTED by both.Checking a Horn certificate is purely syntactic. Neither kernel consults its semantics, sotwo checkers built on contradictory model theories agree on every certificate and everydiff --git a/isabelle/build_native.sh b/isabelle/build_native.shindex addf2ecc..db970fab 100755--- a/isabelle/build_native.sh+++ b/isabelle/build_native.sh@@ -14,13 +14,29 @@# directory that does not exist on this machine. The bundled runtime directory holds# libgmp.10.dylib but no libgmp.dylib, so the linker cannot find it there either. The two# steps below are what polyc does, with the gmp search path pointed somewhere real.+#+# LINUX. This script was macOS-only until 15 September 2026: it looked for `libgmp.dylib`+# and for an Isabelle app bundle under /Applications, so the whole Isabelle half of the+# cross-kernel differential could only run on a developer's Mac, and the README claim it+# backs was therefore gated by nothing in CI. The full Isabelle distribution is NOT needed+# to run it, because `driver/oo_horn_generated.ML` is committed. Only Poly/ML is, and Isabelle+# publishes that on its own as a ~39 MB component carrying every platform. So CI sets+# POLYDIR at .../polyml-5.9.2-2/x86_64-linux and this script links there. See+# .github/workflows/ci.yml, the "second kernel" steps of the `lean` job.+#+# Two things differ on Linux and both have bitten this repository before. GNU ld resolves+# libraries strictly left to right, so the object file comes first and `-lpolymain` before+# `-lpolyml`, which is also the order Poly/ML's own `polyc` uses. And the runtime needs+# `-lpthread -lm -ldl` there, which `polyml.pc` lists and macOS does not have as separate+# libraries at all: passing `-ldl` to Apple's linker fails, because libdl is inside+# libSystem. The link line is therefore built per platform rather than shared.set -eHERE=$(cd "$(dirname "$0")" && pwd)OUT=${1:-$HERE/build/oo-horn-isabelle}-# Where Poly/ML lives. Ask Isabelle first, because ISABELLE_HOME is the only answer that-# is right on a machine that is not this one; fall back to the macOS app bundle, and let-# POLYDIR override both.+# Where Poly/ML lives. POLYDIR wins; then Isabelle, because ISABELLE_HOME is the only+# answer that is right on a machine that is not this one; then the macOS app bundle; then+# a Poly/ML on PATH that was built from source, whose libraries sit beside its binary.ARCH=$(uname -m); [ "$ARCH" = "aarch64" ] && ARCH=arm64OS=$(uname -s | tr 'A-Z' 'a-z')if [ -z "$POLYDIR" ] && command -v isabelle >/dev/null 2>&1; then@@ -28,20 +44,46 @@ if [ -z "$POLYDIR" ] && command -v isabelle >/dev/null 2>&1; then[ -n "$IHOME" ] && POLYDIR=$(ls -d "$IHOME"/contrib/polyml-*/"$ARCH-$OS" 2>/dev/null | head -1)fiPOLYDIR=${POLYDIR:-$(ls -d /Applications/Isabelle*.app/contrib/polyml-*/"$ARCH-$OS" 2>/dev/null | head -1)}+if [ -z "$POLYDIR" ] && command -v poly >/dev/null 2>&1; then+ CAND=$(dirname "$(command -v poly)")+ [ -f "$CAND/libpolyml.a" ] && POLYDIR=$CAND+fi[ -x "$POLYDIR/poly" ] || { echo "poly not found; set POLYDIR=/path/to/polyml/arch-dir" >&2; exit 3; }+# The archives are what this script LINKS, and a directory holding `poly` without them is+# the shape Ubuntu's `polyml` package has: it ships /usr/bin/poly and libpolymain.a and no+# libpolyml.a at all, so the failure would otherwise land in the linker with no+# explanation of what is missing.+for lib in libpolymain.a libpolyml.a; do+ [ -f "$POLYDIR/$lib" ] || {+ echo "$POLYDIR has poly but no $lib, so there is nothing to link against." >&2+ echo "Point POLYDIR at a full Poly/ML library directory: an Isabelle contrib/polyml-*" >&2+ echo "platform directory, or the target/ of a from-source build." >&2+ exit 3+ }+done-# Where libgmp actually lives on this machine. Homebrew first, then the copy Isabelle-# bundles (which has only the versioned name, so it is linked by full path).+# Where libgmp actually lives on this machine. A system copy first, then the one Isabelle+# bundles, which carries only the versioned name and is therefore linked by full path.if [ -f /opt/homebrew/lib/libgmp.dylib ]; thenGMP="-L/opt/homebrew/lib -lgmp"elif [ -f /usr/local/lib/libgmp.dylib ]; thenGMP="-L/usr/local/lib -lgmp"elif [ -f "$POLYDIR/libgmp.10.dylib" ]; thenGMP="$POLYDIR/libgmp.10.dylib"+elif ls /usr/lib/*/libgmp.so >/dev/null 2>&1 || [ -f /usr/lib/libgmp.so ]; then+ GMP="-lgmp"+elif [ -f "$POLYDIR/libgmp.so.10" ]; then+ GMP="$POLYDIR/libgmp.so.10"else- echo "libgmp not found; install gmp or set GMP=..." >&2; exit 3+ echo "libgmp not found; install gmp (libgmp-dev on Debian) or set GMP=..." >&2; exit 3fi+# The platform's own runtime libraries. `polyml.pc` says -lpthread -lgmp -lm -ldl -lstdc++.+case "$OS" in+ darwin) SYSLIBS="-lstdc++" ;;+ *) SYSLIBS="-lpthread -lm -ldl -lstdc++" ;;+esac+mkdir -p "$(dirname "$OUT")"OBJ=$(mktemp "${TMPDIR:-/tmp}/oo_horn_obj.XXXXXX").o@@ -51,8 +93,19 @@ printf 'val () = use "%s";\nval () = use "%s";\nval () = PolyML.export("%s", mai| "$POLYDIR/poly" -q --error-exit# 2. Link it against the Poly/ML runtime.-g++ -std=gnu++11 -O2 "$OBJ" -o "$OUT" \- -L"$POLYDIR" -Wl,-rpath,"$POLYDIR" -lpolymain -lpolyml $GMP -lstdc++ 2>/dev/null+#+# The linker's stderr used to go to /dev/null, which hid the ONE message that ever+# matters here. It is captured instead and printed only when the link fails, so a+# successful build stays quiet and a broken one says why.+LOG=$(mktemp "${TMPDIR:-/tmp}/oo_horn_link.XXXXXX")+if ! g++ -std=gnu++11 -O2 "$OBJ" -o "$OUT" \+ -L"$POLYDIR" -Wl,-rpath,"$POLYDIR" -lpolymain -lpolyml $GMP $SYSLIBS 2>"$LOG"; then+ echo "link failed against POLYDIR=$POLYDIR" >&2+ cat "$LOG" >&2+ rm -f "$LOG" "$OBJ"+ exit 3+fi+rm -f "$LOG"rm -f "$OBJ"-echo "wrote $OUT"+echo "wrote $OUT (POLYDIR=$POLYDIR)"diff --git a/tests/ci_gate_coverage_test.rs b/tests/ci_gate_coverage_test.rsnew file mode 100644index 00000000..de626e3c--- /dev/null+++ b/tests/ci_gate_coverage_test.rs@@ -0,0 +1,283 @@+//! A test that can skip everywhere it runs, and runs nowhere it could not skip, is a+//! gate in name only. This file is the gate on that.+//!+//! `tests/common/mod.rs` already solved half the problem: `skip_unless` prints a marker+//! and, under `OO_REQUIRE_FIXTURES=1`, panics instead of skipping. Any job that installs+//! a toolchain sets the variable, and the suite cannot then quietly shrink inside it.+//!+//! That mechanism only bites on a test that RUNS. It says nothing about a test file that+//! no job invokes at all, and `tests/cross_kernel_differential_test.rs` was exactly that+//! for as long as it existed: it needs Poly/ML as well as lake, no job installed Poly/ML,+//! so it skipped in `build` (the only job that ran it) and was invoked by no leg of+//! `lean` (the only job where it could have been strict). The README states the result of+//! that comparison in its opening pages. A front-page claim was gated by whether a+//! developer happened to have Isabelle installed.+//!+//! `docs/ci-gates.md` recorded the hole in prose, in an open-questions list, with a shell+//! snippet at the bottom for re-checking the page by hand. Prose does not fail. This is+//! that snippet as a test:+//!+//! * every `tests/*.rs` that can skip is either run by some workflow under+//! `OO_REQUIRE_FIXTURES=1`, or is on `NOT_STRICT_ON_PURPOSE` below with a reason;+//! * every entry on that list is a real file that really can skip, so the list cannot rot+//! into a blanket exemption;+//! * `docs/ci-gates.md` has a row for each such file whose verdict matches what the+//! workflows actually say, so the page cannot go stale the way the numbers did;+//! * and no test prints the `SKIPPED_FIXTURE:` marker by hand, which would be counted by+//! the `build` job and would not panic under `OO_REQUIRE_FIXTURES=1`.+//!+//! It deliberately does NOT require every file to be strict. A contributor without+//! Isabelle, without a licensed crosswalk table and without a downloaded embedding model+//! must still be able to run `cargo test` and get a pass. The property being defended is+//! narrower and is the one that was violated: CI cannot skip in silence.++use std::collections::{BTreeMap, BTreeSet};+use std::path::PathBuf;++fn repo() -> PathBuf {+ PathBuf::from(env!("CARGO_MANIFEST_DIR"))+}++/// Files that can skip and are not run strictly anywhere, each with the reason. A file+/// belongs here when the thing it needs is one CI deliberately does not provide; it does+/// NOT belong here because wiring it up looked like work.+///+/// Keep this list in step with the "What is still open" section of `docs/ci-gates.md`.+const NOT_STRICT_ON_PURPOSE: &[(&str, &str)] = &[+ (+ "clinical_test.rs",+ "needs data/crosswalks.parquet, a licensed table the repository deliberately does \+ not carry and `data/` is gitignored",+ ),+ (+ "embed_test.rs",+ "needs the ONNX embedding model `open-ontologies init` downloads; no job downloads it",+ ),+ (+ "embedding_e2e_test.rs",+ "needs the same ONNX model and its tokenizer",+ ),+ (+ "claimcheck_pizza_bench.rs",+ "needs /tmp/pizza_compiled.json from CompileOntology.java; only benchmark.yml has a \+ JDK, it is workflow_dispatch, and it does not produce the file",+ ),+ (+ "reasoner_budget_corpus_bench.rs",+ "its one test is #[ignore]: a wall-clock measurement run by hand, not a gate",+ ),+];++/// Every `tests/*.rs` with a skip path. `tests/common/mod.rs` defines the mechanism and+/// lives a directory down, so the glob does not reach it.+fn files_that_can_skip() -> BTreeSet<String> {+ let dir = repo().join("tests");+ let mut out = BTreeSet::new();+ for entry in std::fs::read_dir(&dir).expect("tests/ must be readable") {+ let path = entry.expect("readable dir entry").path();+ if path.extension().and_then(|e| e.to_str()) != Some("rs") {+ continue;+ }+ let text = std::fs::read_to_string(&path).expect("test file must be readable");+ // The CALL and not the identifier. This file names `skip_unless` a dozen times in+ // prose and calls it never, so a bare substring match would put the gate on the+ // gates into its own list of things to worry about.+ if text.contains("skip_unless(") {+ out.insert(path.file_name().expect("file name").to_string_lossy().into_owned());+ }+ }+ out+}++/// Every `--test NAME` a workflow runs with `OO_REQUIRE_FIXTURES=1`, with the workflow it+/// is in.+///+/// Backslash continuations are joined FIRST. Without that the scan is wrong in the one+/// direction that matters: a leg written across two lines, with the variable on the first+/// and the `cargo test` on the second, is strict and would be read as not strict, so the+/// gate would fail on a leg that is correct. Both shapes are in the tree.+///+/// Carriage returns go before that. `.gitattributes` pins LF on the certificate formats+/// and on RDF, and says why, but not on YAML: the hosted Windows runner checks out with+/// `core.autocrlf=true`, the continuation is then `\ CR LF` rather than `\ LF`, and a join+/// that looked for the second would silently fail to join on one leg of the matrix only.+fn strict_legs() -> BTreeMap<String, String> {+ let dir = repo().join(".github").join("workflows");+ let mut out = BTreeMap::new();+ for entry in std::fs::read_dir(&dir).expect(".github/workflows/ must be readable") {+ let path = entry.expect("readable dir entry").path();+ let ext = path.extension().and_then(|e| e.to_str()).unwrap_or("");+ if ext != "yml" && ext != "yaml" {+ continue;+ }+ let workflow = path.file_name().expect("file name").to_string_lossy().into_owned();+ let text = std::fs::read_to_string(&path).expect("workflow must be readable");+ let joined = text.replace("\r\n", "\n").replace("\\\n", " ");+ for line in joined.lines() {+ if !line.contains("OO_REQUIRE_FIXTURES=1") {+ continue;+ }+ for (i, _) in line.match_indices("--test ") {+ let rest = &line[i + "--test ".len()..];+ let name: String =+ rest.chars().take_while(|c| c.is_alphanumeric() || *c == '_').collect();+ if !name.is_empty() {+ out.insert(format!("{name}.rs"), workflow.clone());+ }+ }+ }+ }+ out+}++/// The verdict column of the Rust table in `docs/ci-gates.md`, per file.+fn ci_gates_rows() -> BTreeMap<String, String> {+ let text = std::fs::read_to_string(repo().join("docs").join("ci-gates.md"))+ .expect("docs/ci-gates.md must exist: this test checks claims against it");+ let mut out = BTreeMap::new();+ for line in text.lines() {+ let line = line.trim();+ let Some(rest) = line.strip_prefix("| `") else { continue };+ let Some(end) = rest.find('`') else { continue };+ let name = &rest[..end];+ if !name.ends_with(".rs") {+ continue;+ }+ out.insert(name.to_string(), line.to_string());+ }+ out+}++#[test]+fn no_test_file_can_skip_in_ci_without_saying_so_in_advance() {+ let skippable = files_that_can_skip();+ assert!(+ skippable.len() > 10,+ "only {} test files were found to have a skip path, which means the scan is \+ broken rather than that the suite got tidy",+ skippable.len()+ );++ let strict = strict_legs();+ let excepted: BTreeMap<&str, &str> = NOT_STRICT_ON_PURPOSE.iter().copied().collect();++ let mut ungated = Vec::new();+ for file in &skippable {+ if strict.contains_key(file) || excepted.contains_key(file.as_str()) {+ continue;+ }+ ungated.push(file.clone());+ }++ assert!(+ ungated.is_empty(),+ "These test files can skip, and no workflow runs them under \+ OO_REQUIRE_FIXTURES=1:\n {}\n\nA skipped test reports `ok`, so each of these can \+ go quiet in CI without turning a tick red. Either add a leg that runs the file \+ with OO_REQUIRE_FIXTURES=1 in a job that installs what it needs, or add it to \+ NOT_STRICT_ON_PURPOSE in tests/ci_gate_coverage_test.rs with the reason CI does \+ not provide that thing. Do not add it to the list to make this pass.",+ ungated.join("\n ")+ );++ // The other direction. An exception for a file that no longer exists, or that no+ // longer has a skip path, is a licence for the next one.+ let mut rotten = Vec::new();+ for (file, _) in NOT_STRICT_ON_PURPOSE {+ if !skippable.contains(*file) {+ rotten.push(format!("{file}: no such file under tests/, or it can no longer skip"));+ }+ if let Some(workflow) = strict.get(*file) {+ rotten.push(format!("{file}: excepted here, but {workflow} runs it strictly"));+ }+ }+ assert!(+ rotten.is_empty(),+ "NOT_STRICT_ON_PURPOSE has gone stale:\n {}",+ rotten.join("\n ")+ );+}++/// The marker belongs to `tests/common/mod.rs` and to nothing else.+///+/// A test that prints `SKIPPED_FIXTURE:` by hand is counted by the `build` job's skip+/// counter and is invisible to `OO_REQUIRE_FIXTURES=1`, because the panic lives in the+/// helper and not in the string. That is not hypothetical: `claimcheck_pizza_bench.rs`+/// printed its own `SKIP:` line and was invisible to both, which is why it now goes+/// through the helper. This keeps the route closed.+#[test]+fn only_the_helper_emits_the_skip_marker() {+ let mut printed = Vec::new();+ for entry in std::fs::read_dir(repo().join("tests")).expect("tests/ must be readable") {+ let path = entry.expect("readable dir entry").path();+ if path.extension().and_then(|e| e.to_str()) != Some("rs") {+ continue;+ }+ let text = std::fs::read_to_string(&path).expect("test file must be readable");+ for line in text.lines() {+ let t = line.trim_start();+ if t.starts_with("//") {+ continue;+ }+ if (t.contains("println!") || t.contains("print!") || t.contains("write!"))+ && line.contains("SKIPPED_FIXTURE")+ {+ printed.push(format!(+ "{}: {}",+ path.file_name().expect("file name").to_string_lossy(),+ line.trim()+ ));+ }+ }+ }+ assert!(+ printed.is_empty(),+ "These lines print the skip marker without going through \+ common::skip_unless:\n {}\n\nThe marker is what the `build` job counts and the \+ panic under OO_REQUIRE_FIXTURES=1 is in the helper, so a hand-printed marker is \+ a skip that looks accounted for and is not.",+ printed.join("\n ")+ );+}++/// `docs/ci-gates.md` is the page somebody reads to answer "does a green tick mean this+/// ran?". It had the right answer and no way to notice when it stopped having it.+#[test]+fn the_ci_gates_page_says_what_the_workflows_say() {+ let skippable = files_that_can_skip();+ let strict = strict_legs();+ let rows = ci_gates_rows();++ let mut wrong = Vec::new();+ for file in &skippable {+ let Some(row) = rows.get(file) else {+ wrong.push(format!("{file}: can skip and has no row in the Rust table"));+ continue;+ };+ let says_strict = row.contains("**strict**");+ let is_strict = strict.contains_key(file);+ if says_strict != is_strict {+ wrong.push(format!(+ "{file}: the workflows make it {}, the page says {}\n {row}",+ if is_strict { "strict" } else { "not strict" },+ if says_strict { "strict" } else { "not strict" },+ ));+ }+ }++ // A row for a file that cannot skip is not an error, since `fol_model_ingest_test.rs`+ // is named in the prose for exactly that reason, so only rows for missing files are.+ for name in rows.keys() {+ if !repo().join("tests").join(name).exists() {+ wrong.push(format!("{name}: has a row and no file"));+ }+ }++ assert!(+ wrong.is_empty(),+ "docs/ci-gates.md and .github/workflows/ disagree:\n {}\n\nThe workflows are the \+ measurement and the page is the claim, so correct the page, unless the \+ workflows are what is wrong, in which case correct those.",+ wrong.join("\n ")+ );+}diff --git a/tests/cross_kernel_differential_test.rs b/tests/cross_kernel_differential_test.rsindex ca14ed8b..fae897d8 100644--- a/tests/cross_kernel_differential_test.rs+++ b/tests/cross_kernel_differential_test.rs@@ -106,14 +106,37 @@ fn lake_available() -> bool {.unwrap_or(false)}+/// A Poly/ML library directory is one this test can actually LINK against, which is+/// three files and not one. Ubuntu's `polyml` package is the reason the distinction is+/// checked rather than assumed: it installs `/usr/bin/poly` and `libpolymain.a` and no+/// `libpolyml.a` at all, so a search that stopped at `poly` would report the Isabelle+/// half available and then fail in the linker with nothing saying what was missing.+fn poly_usable(dir: &Path) -> bool {+ dir.join("poly").exists()+ && dir.join("libpolymain.a").exists()+ && dir.join("libpolyml.a").exists()+}+/// The Isabelle side needs Poly/ML to link the exported checker, and the exported/// checker itself, which `isabelle/export.sh` writes out of the session and which is/// committed so this test does not need a full Isabelle build to run.///-/// The same search `isabelle/build_native.sh` does, and for the same reason: asking-/// `isabelle getenv ISABELLE_HOME` is the only answer that is right on a machine that is-/// not this one, and the macOS app bundle is only the fallback.+/// The same search `isabelle/build_native.sh` does, in the same order and for the same+/// reasons. `POLYDIR` wins, because it is the answer that is right on a machine nobody+/// anticipated and it is how CI points at the Poly/ML component it unpacks. This test+/// was macOS-only until 15 September 2026, and an `/Applications` scan is not a search+/// on a Linux runner. Then `isabelle getenv ISABELLE_HOME`, then the macOS app bundle,+/// then a `poly` on PATH with its libraries beside it.fn poly_dir() -> Option<PathBuf> {+ // Whatever build_native.sh would link against, this test must agree with, or the+ // skip decision and the build decision are made on different evidence.+ if let Ok(dir) = std::env::var("POLYDIR")+ && !dir.is_empty()+ {+ let dir = PathBuf::from(dir);+ return poly_usable(&dir).then_some(dir);+ }+let arch = if cfg!(target_arch = "aarch64") { "arm64" } else { "x86_64" };let os = if cfg!(target_os = "macos") { "darwin" } else { "linux" };let platform = format!("{arch}-{os}");@@ -138,14 +161,25 @@ fn poly_dir() -> Option<PathBuf> {for c in cs.flatten() {if c.file_name().to_string_lossy().starts_with("polyml-") {let d = c.path().join(&platform);- if d.join("poly").exists() {+ if poly_usable(&d) {found.push(d);}}}}found.sort();- found.pop()+ if let Some(d) = found.pop() {+ return Some(d);+ }++ // A from-source Poly/ML keeps its archives next to its binary.+ let out = Command::new("sh").args(["-c", "command -v poly"]).output().ok()?;+ if !out.status.success() {+ return None;+ }+ let exe = PathBuf::from(String::from_utf8_lossy(&out.stdout).trim());+ let dir = exe.parent()?.to_path_buf();+ poly_usable(&dir).then_some(dir)}fn isabelle_available() -> bool {@@ -165,10 +199,13 @@ fn skip() -> bool {}common::skip_unless(isabelle_available(),- "Poly/ML (bundled with Isabelle) and isabelle/driver/oo_horn_generated.ML, \- for the Isabelle half of the differential",- "install Isabelle2025-2 from https://isabelle.in.tum.de; the generated ML is \- committed, and isabelle/export.sh regenerates it from the session",+ "Poly/ML and isabelle/driver/oo_horn_generated.ML, for the Isabelle half of the \+ differential",+ "the generated ML is committed, so the full Isabelle distribution is NOT needed: \+ unpack https://isabelle.in.tum.de/components/polyml-5.9.2-2.tar.gz and set \+ POLYDIR to its platform directory, which is what CI does. Installing \+ Isabelle2025-2 also works and is what isabelle/export.sh needs to regenerate \+ the ML from the session",)}