Skip to content

eBPF-based security platform

ci: run the proofs after every push to main

Daniel Borkmanne54740fdf666
diff --git a/.agents/skills/pre-submit/SKILL.md b/.agents/skills/pre-submit/SKILL.md
index 3b438710..b702025e 100644
--- a/.agents/skills/pre-submit/SKILL.md
+++ b/.agents/skills/pre-submit/SKILL.md
@@ -1,6 +1,6 @@
---
name: pre-submit
-description: Run the checks CI runs on a series of shirudo commits before handing it over, and the proofs CI does not run. Covers each commit built on its own, checkpatch, sign-offs, Coccinelle, sparse, SPDX and the documentation check, both compilers, the sanitizer and fuzz runs, the proofs that read the code the series changed, and the VM families the change reaches. Use before saying a change is ready, after rebasing or reordering a series, and to reproduce a CI failure.
+description: Run the checks CI runs on a series of shirudo commits before handing it over, and the proofs CI runs only once a series is on main. Covers each commit built on its own, checkpatch, sign-offs, Coccinelle, sparse, SPDX and the documentation check, both compilers, the sanitizer and fuzz runs, the proofs that read the code the series changed, and the VM families the change reaches. Use before saying a change is ready, after rebasing or reordering a series, and to reproduce a CI failure.
---
# Pre-submit checks
@@ -81,8 +81,10 @@ written without `le32_to_cpu()`, `cpu_to_le32()` or their kin, and
scan-build what clang's static analyzer proves on some path: a NULL or
uninitialized value used, a leak, a use after free, a store never read.
-CI does not run the proofs, so this run is the only one a series gets
-before it lands. `CHANGED` takes what `git diff` takes and runs the CBMC
+CI runs the proofs only after a push to main, in the `Proofs` workflow,
+so this run is the only one a series gets before it lands, and the only
+one at all of a proof `testing/proofs/cbmc/ci-skip.list` names, which CI
+leaves out. `CHANGED` takes what `git diff` takes and runs the CBMC
proofs whose harness reads a file changed there, all of them after a
change to `run.sh` or `proofs.list`. A proof that fails, or that passes
and no longer states what the changed code does, is brought back in
diff --git a/.agents/skills/proofs/SKILL.md b/.agents/skills/proofs/SKILL.md
index 89d8925a..16bb54ca 100644
--- a/.agents/skills/proofs/SKILL.md
+++ b/.agents/skills/proofs/SKILL.md
@@ -24,15 +24,29 @@ make proofs-cbmc PROOFS="string-number hex" # some CBMC proofs
make proofs-cbmc CHANGED=origin/main..HEAD # those reading a changed file
testing/proofs/cbmc/run.sh -v <proof> # whole output and traces
make proofs-lean4 # the Lean 4 proofs
+.github/scripts/proofs.sh run 3 8 # CI's shard 3 of 8
```
-CI does not run the proofs, as all of them take about an hour: run the
+The `Proofs` workflow runs them after a push to main, never on a pull
+request, as they take hours of CPU: before a change is sent, run the
ones covering the code you changed, which `CHANGED` picks from what
each harness includes, and all of them after a change to `proof.h` or
`run.sh`, which `CHANGED` does too. Cap the memory of a long run, `ulimit
-v 24000000` in the shell that starts it: a proof that grows past a few
gigabytes is one to reshape, not to wait for.
+CI splits `proofs.list` into eight shards and runs each proof alone
+under the 14 GB and 60 minutes `.github/scripts/proofs.sh` caps it at;
+a proof added there has to fit both. It leaves out the proofs
+`testing/proofs/cbmc/ci-skip.list` names, each with why, which no run
+checks unless a developer starts it: run one by hand after a change to
+what it reads, and take it off the list once it fits. A proof that
+fails in CI prints its whole output, trace included, in its shard's
+job log and leaves it in the `cbmc-logs-<k>` artifact. `proofs.sh`
+pins CBMC 5.95.1 and elan, and Lean is the release `lean-toolchain`
+names; `proofs.sh install-cbmc` unpacks the same CBMC into `build/cbmc`
+without root.
+
## Write
- `testing/proofs/cbmc/<name>.c` includes `"proof.h"` and the `.c` it
diff --git a/.agents/skills/security-audit/SKILL.md b/.agents/skills/security-audit/SKILL.md
index 38994505..bfe8535f 100644
--- a/.agents/skills/security-audit/SKILL.md
+++ b/.agents/skills/security-audit/SKILL.md
@@ -276,11 +276,13 @@ before rating it; the page changes with the fix either way.
## Proofs against the code
The proofs of `testing/proofs/` are evidence only while they hold for
-the code as it is, and CI does not run them. An audit runs all of them
-at the commit it audits, `make proofs`, about an hour, so start it
-first as the `proofs` skill says, and reports the commit and the
-result. A failure is sorted like any candidate: a bug in the code, a
-harness that assumed too little, or a proof the code left behind.
+the code as it is, and CI runs them only after a push to main, without
+the CBMC proofs `testing/proofs/cbmc/ci-skip.list` names. An audit runs
+all of them at the commit it audits, `make proofs`, those on that list
+for hours each, so start it first as the `proofs` skill says, and
+reports the commit and the result. A failure is sorted like any
+candidate: a bug in the code, a harness that assumed too little, or a
+proof the code left behind.
A proof that passes can still prove less than its row in
`Documentation/contribute/testing/proof-coverage.rst` says. For each
diff --git a/.github/scripts/proofs.sh b/.github/scripts/proofs.sh
new file mode 100755
index 00000000..134071b7
--- /dev/null
+++ b/.github/scripts/proofs.sh
@@ -0,0 +1,182 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+#
+# .github/scripts/proofs.sh -- install the pinned CBMC into build/cbmc or
+# elan and Lean into ELAN_HOME, without root, and list or run the CBMC
+# proofs of shard <k> of <n>: every <n>th of proofs.list from the <k>th,
+# but those ci-skip.list names, each alone under a memory and time cap.
+#
+# .github/scripts/proofs.sh install-cbmc|install-lean
+# .github/scripts/proofs.sh list|run <k> <n>
+
+set -eu
+
+# Diffblue's package of CBMC for Ubuntu 22.04 runs unpacked, without
+# root, on later releases and other distributions; Ubuntu 26.04 packages
+# CBMC 6.6.
+CBMC_VERSION=5.95.1
+CBMC_SHA256=bdfce55b828a45e19d685f7569e3569657ce80faa20c79a99f1791b5d5b852bc
+ELAN_VERSION=4.2.4
+ELAN_SHA256=42b94d4244e8353142c456ec0e4ca6528fd898a6c604d4059f494e706e431f63
+
+# A runner has 16 GB, and the slowest proof CI runs takes 15 minutes on
+# a fast host: a proof past either cap is one to reshape.
+PROOF_MEMORY_KB=14000000
+PROOF_MINUTES=60
+
+cd "$(git rev-parse --show-toplevel)"
+proofs=testing/proofs/cbmc
+
+work=$(mktemp -d)
+trap 'rm -rf "$work"' EXIT
+
+die() {
+ printf 'proofs: %s\n' "$*" >&2
+ exit 1
+}
+
+annotate() {
+ [ -z "${GITHUB_ACTIONS:-}" ] || printf '::%s\n' "$*"
+}
+
+# Prints a directory to put on PATH and puts it on the job's.
+add_path() {
+ printf '%s\n' "$1"
+ [ -z "${GITHUB_PATH:-}" ] || printf '%s\n' "$1" >>"$GITHUB_PATH"
+}
+
+fetch() {
+ curl -fsSL --retry 3 -o "$1" "$2"
+ printf '%s %s\n' "$3" "$1" | sha256sum -c --quiet
+}
+
+# The pinned packages are built for x86_64 only.
+check_arch() {
+ [ "$(uname -m)" = x86_64 ] || die "the pinned packages are for x86_64"
+}
+
+install_cbmc() {
+ check_arch
+ dir=$PWD/build/cbmc
+ if ! "$dir/usr/bin/cbmc" --version 2>/dev/null |
+ grep -q "^$CBMC_VERSION "; then
+ rm -rf "$dir"
+ mkdir -p "$dir"
+ url=https://github.com/diffblue/cbmc/releases/download
+ deb=ubuntu-22.04-cbmc-$CBMC_VERSION-Linux.deb
+ fetch "$work/cbmc.deb" "$url/cbmc-$CBMC_VERSION/$deb" \
+ "$CBMC_SHA256"
+ dpkg-deb -x "$work/cbmc.deb" "$dir"
+ fi
+ add_path "$dir/usr/bin"
+}
+
+install_lean() {
+ check_arch
+ home=${ELAN_HOME:-$HOME/.elan}
+ if ! "$home/bin/elan" --version 2>/dev/null |
+ grep -q "^elan $ELAN_VERSION "; then
+ url=https://github.com/leanprover/elan/releases/download
+ fetch "$work/elan.tar.gz" \
+ "$url/v$ELAN_VERSION/elan-x86_64-unknown-linux-gnu.tar.gz" \
+ "$ELAN_SHA256"
+ tar -xzf "$work/elan.tar.gz" -C "$work"
+ ELAN_HOME=$home "$work/elan-init" -y --no-modify-path \
+ --default-toolchain none
+ fi
+ ELAN_HOME=$home "$home/bin/elan" toolchain install \
+ "$(cat testing/proofs/lean4/lean-toolchain)"
+ add_path "$home/bin"
+}
+
+names() {
+ grep -v '^[[:space:]]*\(#\|$\)' "$1" | awk '{ print $1 }'
+}
+
+shard() {
+ case $1:$2 in
+ *[!0-9:]* | :* | *:) die "list and run take <k> <n>, 1 <= k <= n" ;;
+ esac
+ if [ "$1" -lt 1 ] || [ "$1" -gt "$2" ]; then
+ die "list and run take <k> <n>, 1 <= k <= n"
+ fi
+ names "$proofs/proofs.list" >"$work/all"
+ names "$proofs/ci-skip.list" >"$work/skip"
+ while read -r name; do
+ grep -qxF "$name" "$work/all" ||
+ die "ci-skip.list names $name, which proofs.list does not"
+ done <"$work/skip"
+ grep -vxF -f "$work/skip" "$work/all" |
+ awk -v k="$1" -v n="$2" '(NR - 1) % n == k - 1'
+}
+
+# A proof stopped at its time cap leaves run.sh's CBMC logs behind; the
+# newest is that of the length it was on.
+prove() {
+ name=$1
+ log=build/proofs/$name.log
+ mkdir -p "$work/$name"
+ status=0
+ TMPDIR=$work/$name timeout "$((PROOF_MINUTES * 60))" \
+ "$proofs/run.sh" -v "$name" </dev/null >"$log" 2>&1 || status=$?
+ if [ "$status" -eq 0 ]; then
+ grep '^ok' "$log"
+ rm -f "$log"
+ return 0
+ fi
+ why=$(sed -n 's/^FAILED [^ ]* \((.*)\)$/failed \1/p' "$log" | head -n 1)
+ [ -n "$why" ] || why=failed
+ if [ "$status" -eq 124 ]; then
+ why="no result in $PROOF_MINUTES minutes"
+ # shellcheck disable=SC2012
+ last=$(ls -t "$work/$name"/*/*.log 2>/dev/null | head -n 1)
+ if [ -n "$last" ]; then
+ len=${last##*/"$name".}
+ len=${len%.log}
+ [ "$len" = - ] || why="$why (-DLEN=$len)"
+ cat "$last" >>"$log"
+ fi
+ elif grep -qi 'out of memory' "$log"; then
+ why="out of memory at $((PROOF_MEMORY_KB / 1000000)) GB"
+ fi
+ printf 'FAILED %s: %s\n' "$name" "$why"
+ annotate "error title=CBMC proof $name::$why"
+ grep -E 'FAILURE|ERROR|error:|no body for function|[Oo]ut of memory' \
+ "$log" | head -n 20 | sed 's/^/ /' || :
+ annotate "group::Output of $name"
+ cat "$log"
+ annotate "endgroup::"
+ return 1
+}
+
+run() {
+ shard "$1" "$2" >"$work/shard"
+ printf 'proofs: shard %s of %s runs %s\n' "$1" "$2" \
+ "$(paste -sd ' ' "$work/shard")"
+ # dash and bash both take -v.
+ # shellcheck disable=SC3045
+ ulimit -v "$PROOF_MEMORY_KB"
+ rm -rf build/proofs
+ mkdir -p build/proofs
+ ran=0
+ failed=0
+ while read -r name; do
+ ran=$((ran + 1))
+ prove "$name" || failed=$((failed + 1))
+ done <"$work/shard"
+ [ "$ran" -gt 0 ] || die "shard $1 of $2 has no proof"
+ if [ "$failed" -gt 0 ]; then
+ printf 'proofs: %d of %d failed\n' "$failed" "$ran" >&2
+ exit 1
+ fi
+ printf 'proofs: %d hold\n' "$ran"
+}
+
+case ${1:-} in
+install-cbmc) install_cbmc ;;
+install-lean) install_lean ;;
+list) shard "${2:-}" "${3:-}" ;;
+run) run "${2:-}" "${3:-}" ;;
+*) die "usage: proofs.sh install-cbmc|install-lean|list|run <k> <n>" ;;
+esac
diff --git a/.github/workflows/proofs.yml b/.github/workflows/proofs.yml
new file mode 100644
index 00000000..4626ba48
--- /dev/null
+++ b/.github/workflows/proofs.yml
@@ -0,0 +1,109 @@
+name: Proofs
+
+# The proofs take hours of CPU, longer than a pull request should wait:
+# they run on what lands on main, and a series runs the ones its change
+# reaches before it is sent, as Documentation/contribute/testing/proofs.rst
+# says.
+on:
+ push:
+ branches:
+ - main
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+# A push while the proofs run queues its run behind them rather than
+# cancelling them: pushes closer together than a run takes would leave
+# main without a finished one. GitHub keeps only the newest run waiting.
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: false
+
+jobs:
+ # Shard <k> of <n> runs every <n>th proof of proofs.list from the
+ # <k>th, but those ci-skip.list names, one at a time: the runner's
+ # 16 GB is for one proof, not four. proofs.sh caps each proof's memory
+ # and time well within the job's. CBMC reads the C library's headers
+ # through the runner's gcc, so the job runs on the Ubuntu release the
+ # proofs are developed on, not the one ubuntu-latest moves to next.
+ cbmc:
+ name: CBMC
+ runs-on: ubuntu-24.04
+ timeout-minutes: 180
+ strategy:
+ fail-fast: false
+ matrix:
+ shard: [1, 2, 3, 4, 5, 6, 7, 8]
+
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+
+ # Fetching the package from GitHub takes seconds, as long as a
+ # cache restore would, so it is not cached.
+ - name: Install CBMC
+ run: .github/scripts/proofs.sh install-cbmc
+
+ - name: Run the CBMC proofs of shard ${{ matrix.shard }}
+ run: .github/scripts/proofs.sh run ${{ matrix.shard }} ${{ strategy.job-total }}
+
+ - name: Upload the output of the failed proofs
+ if: failure()
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ with:
+ name: cbmc-logs-${{ matrix.shard }}
+ path: build/proofs/
+ if-no-files-found: ignore
+
+ lean4:
+ name: Lean4
+ runs-on: ubuntu-latest
+ timeout-minutes: 60
+
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+
+ # The toolchain is 600 MB to fetch and 3 GB unpacked. The key
+ # takes proofs.sh, which pins elan's version.
+ - name: Restore elan and the Lean toolchain
+ id: elan
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: ~/.elan
+ key: elan-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('testing/proofs/lean4/lean-toolchain', '.github/scripts/proofs.sh') }}
+
+ - name: Install elan and the Lean toolchain
+ id: install
+ run: .github/scripts/proofs.sh install-lean
+
+ # Lake rebuilds each module whose source, imports, options or
+ # toolchain differ from the build it restores.
+ - name: Restore the Lean build
+ id: lake
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: testing/proofs/lean4/.lake
+ key: lake-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('testing/proofs/lean4/lean-toolchain', 'testing/proofs/lean4/lakefile.toml', 'testing/proofs/lean4/lake-manifest.json', 'testing/proofs/lean4/**/*.lean') }}
+ restore-keys: lake-${{ runner.os }}-${{ runner.arch }}-
+
+ - name: Check the Lean 4 proofs
+ id: lean
+ run: make proofs-lean4
+
+ - name: Save elan and the Lean toolchain
+ if: always() && steps.install.outcome == 'success' && steps.elan.outputs.cache-hit != 'true'
+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: ~/.elan
+ key: ${{ steps.elan.outputs.cache-primary-key }}
+
+ # Only a build that passed is kept, so a later run never starts
+ # from one that did not.
+ - name: Save the Lean build
+ if: always() && steps.lean.outcome == 'success' && steps.lake.outputs.cache-hit != 'true'
+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: testing/proofs/lean4/.lake
+ key: ${{ steps.lake.outputs.cache-primary-key }}
diff --git a/AGENTS.md b/AGENTS.md
index 7d4a06aa..551b2dc9 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -87,10 +87,11 @@ grep -n '<file>.c\|<function>' testing/proofs/cbmc`), or to an algorithm
a Lean 4 model of `testing/proofs/lean4/` follows, adapts the harness or
the model in the same commit, with its line in `proofs.list` and its row
in `Documentation/contribute/testing/proof-coverage.rst`, and runs the
-proofs it touches (`make proofs-cbmc CHANGED=<range>` picks them). A
-proof that no longer matches the code, or no longer holds, is a security
-bug: a threat's fact box or a coverage row then claims an assurance the
-tree does not have.
+proofs it touches (`make proofs-cbmc CHANGED=<range>` picks them), as
+CI runs them only once the change is on main. A proof that no longer
+matches the code, or no longer holds, is a security bug: a threat's
+fact box or a coverage row then claims an assurance the tree does not
+have.
New documentation extends an existing page or adds one to its section's
toctree, and follows `Documentation/contribute/documentation/writing-docs.rst`. Only
@@ -349,11 +350,13 @@ one usually still compiles and passes tests.
- `make proofs` runs the CBMC proofs of `testing/proofs/cbmc/`, which
check parsers and emitters for every input within a bound, and the Lean
4 proofs of `testing/proofs/lean4/`, which prove models of algorithms
- for every input. CI does not run them: a full run takes about an hour.
- A change to code a proof covers, or to an algorithm a model follows,
- runs those proofs by name, all of them after a change to `proof.h` or
- `run.sh`, and a new parser gets a proof where CBMC can carry one; the
- `proofs` skill says how.
+ for every input. They take hours of CPU, so CI runs them after a push
+ to main, in the `Proofs` workflow, never on a pull request, and leaves
+ out the CBMC proofs `testing/proofs/cbmc/ci-skip.list` names, which
+ take hours each. A change to code a proof covers, or to an algorithm
+ a model follows, runs those proofs by name before it is sent, all of
+ them after a change to `proof.h` or `run.sh`, and a new parser gets a
+ proof where CBMC can carry one; the `proofs` skill says how.
- CI runs `.github/scripts/build-commits.sh`, `check-style.sh`,
`check-dco.sh`, `check-coccinelle.sh`, `check-sparse.sh`,
`check-spdx.sh`, `check-unused.sh`, `scan-build.sh` and the
diff --git a/Documentation/contribute/code/developer-guide.rst b/Documentation/contribute/code/developer-guide.rst
index 2b8d6d2e..000e360c 100644
--- a/Documentation/contribute/code/developer-guide.rst
+++ b/Documentation/contribute/code/developer-guide.rst
@@ -548,6 +548,16 @@ the commit at ``HEAD`` alone without them.
only host test dependencies. The arm64 job uses this to run unit,
``ci-checks`` and host functional tests without target VMs.
Meant for CI runners, which are discarded afterwards.
+ * - ``proofs.sh install-cbmc|install-lean``,
+ ``proofs.sh list|run <k> <n>``
+ - Installs the CBMC and the elan CI pins, each verified by its
+ SHA-256, and Lean, all without root: CBMC into ``build/cbmc``,
+ elan and the toolchain ``lean-toolchain`` names into
+ ``ELAN_HOME``. Prints the directory to put on ``PATH``. ``run``
+ runs the CBMC proofs of shard ``<k>`` of ``<n>`` as the ``CBMC``
+ jobs of the ``Proofs`` workflow do, each alone under a memory and
+ time cap, and ``list`` prints them. See
+ :doc:`/contribute/testing/proofs`.
``check-style.sh`` fetches the kernel's ``checkpatch.pl`` at a pinned
tag into ``build/checkpatch/`` and verifies its SHA-256. Set
diff --git a/Documentation/contribute/testing/proof-coverage.rst b/Documentation/contribute/testing/proof-coverage.rst
index 759f6f06..0d157da3 100644
--- a/Documentation/contribute/testing/proof-coverage.rst
+++ b/Documentation/contribute/testing/proof-coverage.rst
@@ -11,7 +11,10 @@ Proof coverage
This page lists the CBMC proofs under :src:`testing/proofs/cbmc/` and the
Lean 4 proofs under :src:`testing/proofs/lean4/`, what each one proves and
for which inputs, the source files no proof reads and the parsers no
-proof covers yet. :doc:`proofs` explains how to run and write them.
+proof covers yet. :doc:`proofs` explains how to run and write them. CI
+runs every proof after a push to main but the CBMC proofs
+:src:`testing/proofs/cbmc/ci-skip.list` names, which take hours each:
+only a run a developer starts checks those.
CBMC proofs
-----------
diff --git a/Documentation/contribute/testing/proofs.rst b/Documentation/contribute/testing/proofs.rst
index 216fa24a..65b2d533 100644
--- a/Documentation/contribute/testing/proofs.rst
+++ b/Documentation/contribute/testing/proofs.rst
@@ -38,7 +38,8 @@ length, and :doc:`proof-coverage` says which is which.
Before you begin
----------------
-- CBMC 5.95 or newer, packaged as ``cbmc`` by Debian and Ubuntu.
+- CBMC 5.95 or newer, packaged as ``cbmc`` by Debian and Ubuntu. CI
+ uses 5.95.1, as `Run the proofs as CI does`_ shows.
- For the Lean 4 proofs, elan, packaged as ``elan``, and the toolchain
:src:`testing/proofs/lean4/lean-toolchain` names:
@@ -60,11 +61,11 @@ Run the proofs
Each CBMC line names a proof, the number of checks CBMC made and the
time it took, and ``proofs: <n> hold`` ends a run in which all of them
- held. ``Build completed successfully`` ends the Lean 4 run. CI does
- not run the proofs: all of them take about an hour, a few of them
- minutes and gigabytes each. Run the ones that cover the code you
- change, as the next step shows, and all of them after a change to
- ``proof.h`` or ``run.sh``.
+ held. ``Build completed successfully`` ends the Lean 4 run. The
+ proofs take hours of CPU, a few of them minutes and gigabytes each,
+ and CI runs them only once a change is on main. Before you send a
+ change, run the ones that cover the code you change, as the next step
+ shows, and all of them after a change to ``proof.h`` or ``run.sh``.
2. Run one kind, some CBMC proofs by name, or the CBMC proofs that read
a file you changed:
@@ -93,6 +94,48 @@ Run the proofs
check: the input that breaks it and the steps that lead there. Lean
prints the theorem and the goal it could not close.
+Run the proofs as CI does
+-------------------------
+
+The ``Proofs`` workflow, :src:`.github/workflows/proofs.yml`, runs after
+every push to main, never on a pull request, so the run before you send
+a change is the only one it gets before it lands. Its ``Lean4`` job runs
+``make proofs-lean4`` with the toolchain ``lean-toolchain`` names. Its
+``CBMC`` job runs in eight shards: shard ``<k>`` takes every eighth proof
+of :src:`testing/proofs/cbmc/proofs.list` from the ``<k>``-th and runs
+each alone, under a cap of 14 GB and 60 minutes, so a proof you add has
+to fit both on a runner. CI pins CBMC 5.95.1 and elan in
+:src:`.github/scripts/proofs.sh`.
+
+1. Install the same CBMC into ``build/cbmc``, without root, and put it
+ on your ``PATH``:
+
+ .. code-block:: console
+
+ $ export PATH="$(.github/scripts/proofs.sh install-cbmc):$PATH"
+
+2. List the proofs of a shard, or run them:
+
+ .. code-block:: console
+
+ $ .github/scripts/proofs.sh list 3 8
+ $ .github/scripts/proofs.sh run 3 8
+
+ A proof that holds prints its ``ok`` line. One that fails prints
+ ``FAILED <proof>:`` and why, then CBMC's whole output with the trace,
+ which ``run`` keeps in ``build/proofs/<proof>.log``. In CI that output
+ is in the shard's job log and in its ``cbmc-logs-<k>`` artifact.
+
+CI leaves out the proofs :src:`testing/proofs/cbmc/ci-skip.list` names,
+each with why: each needs hours, some more memory than a runner has. No
+run checks them but one you start. After a change to a file one of them
+reads, which ``CHANGED`` finds, run it by hand with its memory capped:
+
+.. code-block:: console
+
+ $ ulimit -v 24000000
+ $ make proofs-cbmc PROOFS=bpm-tree-recovery-model
+
Write a CBMC proof
------------------
diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rst
index 832231b8..6685d4ba 100644
--- a/Documentation/contribute/testing/testing.rst
+++ b/Documentation/contribute/testing/testing.rst
@@ -96,13 +96,14 @@ Test tiers
- ``make -C testing fuzz``, ``make -C testing afl``
* - Proofs
- :src:`testing/proofs/`
- - On the build host, with CBMC and Lean 4, about an hour for all
+ - On the build host, with CBMC and Lean 4, hours of CPU for all
- ``make proofs``
``make tests`` in the checkout root, or ``make -C testing``, runs the
unit, CI check, functional and end-to-end tiers in that order. The fuzz
-targets and the proofs run on their own, and CI does not run the
-proofs: :doc:`proofs` says which to run for a change.
+targets and the proofs run on their own. CI runs the proofs only after
+a push to main, in the ``Proofs`` workflow, never on a pull request:
+:doc:`proofs` says which to run for a change.
Each functional family with target tests gets a fresh VM. The VM runner
caches the generated dracut initrd in ``build/test-vm/cache/initrd/``
diff --git a/README.md b/README.md
index a298fb5d..42214dac 100644
--- a/README.md
+++ b/README.md
@@ -7,6 +7,7 @@
[![Build packages](https://github.com/shirudo-dev/shirudo/actions/workflows/packages.yml/badge.svg?branch=main)](https://github.com/shirudo-dev/shirudo/actions/workflows/packages.yml)<br/>
[![CI suite](https://github.com/shirudo-dev/shirudo/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/shirudo-dev/shirudo/actions/workflows/tests.yml)<br/>
[![Sanitizers](https://github.com/shirudo-dev/shirudo/actions/workflows/sanitizers.yml/badge.svg?branch=main)](https://github.com/shirudo-dev/shirudo/actions/workflows/sanitizers.yml)<br/>
+[![Proofs](https://github.com/shirudo-dev/shirudo/actions/workflows/proofs.yml/badge.svg?branch=main)](https://github.com/shirudo-dev/shirudo/actions/workflows/proofs.yml)<br/>
[![CodeQL](https://github.com/shirudo-dev/shirudo/actions/workflows/codeql.yml/badge.svg?branch=main)](https://github.com/shirudo-dev/shirudo/actions/workflows/codeql.yml)<br/>
[![Documentation](https://github.com/shirudo-dev/shirudo/actions/workflows/docs.yml/badge.svg?branch=main)](https://github.com/shirudo-dev/shirudo/actions/workflows/docs.yml)<br/>
[![Coverage Status](https://coveralls.io/repos/github/shirudo-dev/shirudo/badge.svg?branch=main)](https://coveralls.io/github/shirudo-dev/shirudo?branch=main)<br/>
diff --git a/testing/proofs/cbmc/ci-skip.list b/testing/proofs/cbmc/ci-skip.list
new file mode 100644
index 00000000..6f7be4e0
--- /dev/null
+++ b/testing/proofs/cbmc/ci-skip.list
@@ -0,0 +1,10 @@
+# The proofs of proofs.list the Proofs workflow leaves out, each with
+# why: CI gives a proof the 14 GB and 60 minutes .github/scripts/proofs.sh
+# caps it at, and these need more on a 16-core host. Run each by hand
+# after a change to what it reads, make proofs-cbmc PROOFS=<proof> under
+# the memory cap of the proofs skill, and take it off once it fits.
+bpm-tree-sync-model no result after 7 hours, past 15 GB
+bpm-tree-sync-application no result after 7 hours, past 15 GB
+bpm-tree-sync-pending no result after 7 hours, past 15 GB
+bpm-tree-sync-walk no result after 7 hours, past 15 GB
+bpm-tree-recovery-model 76 to 97 minutes, once no result in 2 hours