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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,16 @@ jobs:
# The default-features surface consumers without the optional backends
# actually compile against.
- run: cargo test --lib --tests
# The kernels' proofs (src/kernels, `verus!` blocks): Verus pinned in dev/verus/VERSION.env, a fresh target dir, no
# errors. A normal build erases the proofs, so no other job needs Verus.
verify:
name: Verify (Verus)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: ~/.cache/verus
key: verus-${{ hashFiles('dev/verus/VERSION.env') }}
- run: dev/scripts/verify.sh
19 changes: 19 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,25 @@ A start with no cursor repairs first when the fold holds data anyway (a re-list

The per-key restore decision: take the artifact's entry unless the local one is newer (never a move backward), and delete a key the artifact lacks unless the bucket lists it live (never a phantom delete). `tests/model_repair.rs` catches both pre-fix variants as kernel mutation features (`mut_restore_ignores_versions`, `mut_restore_ignores_listing`).

### What is proven (Verus, `mise run verify`)

The kernels are checked twice: Stateright finds counterexamples in a bounded world, and Verus proves the kernel's own decisions for every input, with no bound. The proofs live inside `verus!` blocks in `src/kernels/`; a normal `cargo build` (and a published crate) erases them, so nothing but the `vstd` macro crate is added. `mise run verify` (CI job `Verify (Verus)`) runs `cargo verus verify` with the Verus release pinned in `dev/verus/VERSION.env`, in a fresh target dir, and must report 0 errors. No `assume`, `admit` or `external_body` stands in for kernel logic. Every `mut_*` feature turns at least one obligation red (`mise run verify -- -- --features mut_x`).

`src/kernels/protocol.rs`: each function has an `ensures` giving exactly what it decides (`*_spec` is the readable table; Verus checks the code equals it), and these theorems:

| Theorem | Where | Says |
| --- | --- | --- |
| `a_publish_never_regresses_the_pointer` | `protocol.rs:91` | an admitted publish never lowers a parseable pointer: its rank is monotone |
| `a_publish_at_or_above_the_pointer_is_admitted` | `protocol.rs:104` | liveness: a publish at or above the pointer (or over an open or corrupt slot) is always admitted |
| `a_pruned_payload_is_never_published_after` | `protocol.rs:162` | what the prune guard deletes can never be published later: no dangling pointer, at any timing |
| `the_target_and_unknown_objects_are_never_pruned` | `protocol.rs:178` | the pointer's target and unparseable objects are never pruned |
| `a_fresh_artifact_is_always_restorable` | `protocol.rs:315` | liveness: an artifact ahead of the fold and inside the window is always admitted |
| `only_an_explicit_relist_can_be_refused` | `protocol.rs:451` | liveness: `Auto` and `Restore` are never refused; a refusal exists only for an explicit `Relist` on a listing known not to be the truth |
| `restore_key` ensures | `protocol.rs:526` | a newer local entry is kept (never backward); a key listed live is never deleted; a delete needs a local entry the artifact lacks |
| `resume_window_ok` / `resume_start_sequence` ensures | `protocol.rs:215`, `:625` | the window and the next sequence are exact in unbounded integers; no wrap at `u64::MAX` |

Proving `gap_holds_no_eviction` found a real overflow: with `max_age = cursor_age = u64::MAX` the saturating multiply made the check pass for a cursor older than the retention. It now compares `age <= max / 2`.

### Export Round State Machine

```
Expand Down
84 changes: 78 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ time = { version = "0.3", features = ["parsing"] }
tokio = { version = "1", features = ["macros", "rt", "sync", "time"] }
tracing = "0.1"
url = "2"
# The `verus!` macro and the spec library. A normal build erases every proof (the macro expands to the plain Rust),
# so production pays nothing; only `cargo verus` checks them (`mise run verify`). Pinned to the release in
# dev/verus/VERSION.env.
vstd = "=0.0.0-2026-11-01-0251"

[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
Expand Down Expand Up @@ -103,3 +107,9 @@ mut_restore_ignores_versions = []
mut_restore_ignores_listing = []
# The fold forgets that it saw retention evict current values.
mut_no_eviction_memo = []

[package.metadata.verus]
verify = true

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(verus_only)'] }
26 changes: 26 additions & 0 deletions dev/scripts/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# Prove the kernels (src/kernels) with the pinned Verus (dev/verus/VERSION.env): `cargo verus verify` on the crate.
# Installs Verus and its Rust toolchain on first use under $VERUS_HOME (default ~/.cache/verus), checked by sha256.
# Extra args go to `cargo verus verify` (e.g. `--features mut_drop_failed_batch` to see the proof go red).
set -euo pipefail
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
# shellcheck source=/dev/null
. "$root/dev/verus/VERSION.env"
home=${VERUS_HOME:-$HOME/.cache/verus}
dir=$home/verus-$VERUS_VERSION
if [[ ! -x $dir/verus-x86-linux/cargo-verus ]]; then
mkdir -p "$home"
tmp=$(mktemp -d "$home/dl.XXXXXX")
trap 'rm -rf "$tmp"' EXIT
curl -fsSL -o "$tmp/verus.zip" \
"https://github.com/verus-lang/verus/releases/download/release/$VERUS_VERSION/verus-$VERUS_VERSION-x86-linux.zip"
echo "$VERUS_SHA256 $tmp/verus.zip" | sha256sum -c - >&2
unzip -q "$tmp/verus.zip" -d "$tmp/x"
rm -rf "$dir" && mv "$tmp/x" "$dir"
fi
rustup toolchain list | grep -q "^$VERUS_RUST_TOOLCHAIN-" || rustup toolchain install "$VERUS_RUST_TOOLCHAIN" --profile minimal
export PATH=$dir/verus-x86-linux:$PATH
# Its own target dir: the Verus build must not share artifacts with the normal one.
export CARGO_TARGET_DIR=${VERUS_TARGET_DIR:-${CARGO_TARGET_DIR:-$root/target}-verus}
cd "$root"
cargo verus verify "$@"
8 changes: 8 additions & 0 deletions dev/verus/VERSION.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The pinned Verus release (https://github.com/verus-lang/verus/releases), linux x86-64 build, and the Rust
# toolchain it was built against (its `version.json`). The vstd crate version in the crate's Cargo.toml
# must be the one this release ships (`cargo verus new` writes it). Change all three together.
VERUS_VERSION=0.2026.11.02.8bf68ee
VERUS_COMMIT=8bf68ee741df833ea5d0fe6a2255126fdea87e47
VERUS_SHA256=f3a0119292df8855e4435da8130bee1873b0e6a60c306accf81a08ea687bba3c
VERUS_RUST_TOOLCHAIN=1.99.1
VERUS_VSTD=0.0.0-2026-11-01-0251
4 changes: 4 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ run = "dprint fmt"
[tasks."format:check"]
description = "Verify code formatting without making changes (CI-friendly)"
run = "dprint check"

[tasks.verify]
description = "Prove the kernels (src/kernels) with the pinned Verus (dev/verus/VERSION.env): `cargo verus verify`, no axioms. Installs Verus under ~/.cache/verus on first use. Pass `-- --features mut_x` to watch a mutation turn the proof red."
run = "dev/scripts/verify.sh"
Loading
Loading