Repository navigation
shared-pool: formal verification of shared-pool-controls v1.0.0 - #31
gabehamilton wants to merge 28 commits into
Conversation
…rmance traces Submodule projects/shared-pool/source-mirror at a4bb5c3 (PR #1 head). conformance/ generates traces of the real pool-core in one Prolog-term format that the model layers replay; trace 0 is the F-1 wedge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… edges Append two traces to the generator (numbers 206 and 207, so the fixture traces keep their numbers): arith (add and envelope overflow at the 1e6 value bound, the 86,400 s horizon accepted / +1 expired, dispatch at expires_at - 1 / expires_at) and full (256 lifetime records, then Full for everyone; cancel and observe free no slot, F-3). The arith term's target sits next to the bound so w*r^2 stays inside TLC's 32-bit integers. Lean REF-5L, Prolog MC-2 (now requires full and arithmetic) and the near-tests shell replay pass on all 208 traces, 8,758 calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… trace TLA+: - TLA-LIVE-F2 (MC_Liveness_F2): with healthy observations only and an executor weakly fair to the honest settle(false), LIVE-2 fails on a credit/hedge config; F2Shape and F2Done hold (every counterexample is the F-2 wedge). TLA-LIVE-1 is re-scoped as the completion path. - Mutants 23-31 (31/31 killed): add bound, envelope overflow, Full and expiry-window edges killed only by the new traces; liveness premise, lost completion and swapped F-2 fairness killed by the liveness checks. - Exact op:result counts over the traces; TLC's 32-bit integer limit documented (ASM-MODEL); PROP tags; SumTo as a recursive function (trace replay 50 s -> 7 s). The TLA+ layer found that releasing a reservation can also fail Arithmetic (F-2's variant): conformance trace 208 reproduces it on the real core (cancel by actor and owner and settle(false) fail, observe is Pending, only settle(true) resolves). TLC, Lean, Prolog MC-2 and the shell replay all 209 traces, 8,771 calls, with equal results and states. Prolog's catalogue gains TLA-LIVE-F2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tests PROP tags strategy.md follows near-approval's layout: target, claims and tiers, scope, threats and TCB, findings (F-1..F-6, F-2b, NT-F1..NT-F4, doc divergences, rejected L-1b), the property catalogue (section 5: the 96 IDs of prolog/requirements/traceability.pl, one table row each), Verus deferred, Prolog, shell/runtime, correspondence through the conformance traces, layout, milestones, CI, risks, open questions, TLA+ and Lean. Kani sections are placeholders until that layer lands. An adversarial check found 10 problems (3 medium); all fixed. .github/workflows/shared-pool.yml: pin, status-lint, conformance --check, TLA+, Lean, Prolog, near-tests (run.sh all) and the sandbox on manual dispatch only; actions pinned by the same SHAs as near-approval.yml. Kani jobs are drafted and added with the layer. near-tests: every test carries its own PROP line, every tag names a catalogue ID (comment-only changes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Append traces 209-211 from the real core: f2-risk (the supplied risk fixture, healthy start, no observe: the executor's honest settle(false) fails Bounds, cancel and observe Pending, only settle(true) resolves), f4-self (validate accepts actor = executor and owner = executor; each settles its own record) and f6-stale (max_age 50: one open record blocks the only snapshot refresh, submit and dispatch fail SnapshotExpired until it settles). TLA+ TraceCheck, Lean REF-5L, Prolog MC-2 and the shell replay all 212 traces, 8,804 calls, with equal results and states. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…traces C-6 compared the catalogue with the git-excluded brief, so in CI it checked nothing. It now reads the committed strategy.md section 5 (first cell and layer cell of every table row) and fails on a missing file, missing/extra/duplicate IDs or a differing layer list. Two requirements mutants (a dropped property row, a changed layer list) are killed only by it; test_mc2 checks that traces 209-211 show F-2, F-4 and F-6. Full prolog/run.sh: all checks pass, 28/28 mutants killed. near-tests/check-tags.py (run first by near-tests/run.sh) requires every test's PROP tags to name catalogue IDs. strategy.md section 4 cites the in-repo reproducers (traces 0, 207-211); README, architecture and the layer RESULTS files give the 212-trace numbers. The CI path filters now include strategy.md, which C-6 reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
82 properties (one module per strategy.md section 5 subsection) and 14 [assumptions.ASM-*] tables. Primary layer = the first layer section 5 lists; 49 in-progress, 33 unverified (31 Kani-first rows until that layer lands, TLA-IND, and LIVE-2 with finding = "F-1, F-2"); nothing past in-progress (unsigned spec, unmerged PR head). Properties that mitigate a threat whose residual is an assumption list it. status-lint: 82 properties, 0 problems, also on the tracked files alone (as CI sees it). An adversarial check found 7 problems (1 medium); fixed or answered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three independent reviews (claims vs artifacts, clean-clone reproducibility, upstream-doc coverage) and one judge: 17 findings, 15 confirmed (4 medium, 11 low), none high (no false result, no certain CI failure, no new defect). - README/architecture: status.toml's properties and assumptions; Lean proofs are about the transcription; TLA+ state count in its universe. - prolog/RESULTS.md: RD-PREVIEW core half, RD-BEST, CFG-2 and NUM-1 are pending Kani, not covered by it. - New SH-11 (wasm export surface: the documented methods plus metadata, no upgrade/migrate/reset export; wasm-surface.sh SURF-1). S-NOADMIN (spec:56) now traces to it and ASM-DEPLOY; transfers/plugins rest on source review (NT-F3). 97 catalogue IDs; C-6 97/97/97; 83 properties. - Finding texts aligned (F-2 cancel Pending once in flight; F-3 low), pin date in UTC, CI state, sandbox toolchain read from the upstream rust-toolchain.toml, storage staking and prepaid gas noted as gaps. Full prolog/run.sh: all checks pass, 28/28 mutants killed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary of ChangesHello @gabehamilton, I'm the pr-review agent. I've reviewed this pull request — here's a summary to help you and other reviewers get up to speed, with the full code review to follow. This PR adds a shared-pool formal-verification workspace: a pinned upstream source mirror, conformance trace generator/replayer, TLA+, Lean, Prolog, NEAR shell/runtime checks, verification documentation, and CI wiring. The review is focused on whether the automation actually executes and fails on cross-layer mismatches, plus the integrity of the pinned source and status claims. Highlights
Changelog
Automated review by the pr-review agent (Codex CLI + GPT-5.6 Terra). Reply on any review thread to discuss a finding. |
gabehamilton
left a comment
There was a problem hiding this comment.
Code Review
This PR establishes a substantial shared-pool verification workspace around a pinned upstream source revision, generated core traces, and TLA+, Lean, Prolog, NEAR shell, and sandbox layers. The high-risk CI paths use commit-pinned actions with read-only permissions, propagate runner failures, and the checked trace converter successfully parsed all 212 traces (8,804 calls). The sandbox job is explicitly manual-dispatch only, consistent with the PR’s stated scope; it is not treated as an automatically enforced PR gate. I found no concrete, merge-blocking defect in the reviewed change set.
Note: GitHub could not serve the diff (over 20,000 lines), so the review ran against a locally generated merge-base diff; coverage focused on CI, runner scripts and trace tooling, and source-dependent runners (cargo, Prolog extraction, sandbox) were not executed because the submodule was not populated. No inline findings were raised.
TLC at TLA_HEAP=5g fits a GitHub-hosted runner: safety 1,300 s (2,306,738 states), liveness and trace pass, and 31/31 spec mutants are killed on the 212 traces in 4 min 10 s. Closes the CI-memory open item and the matching strategy risk row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p (COV-3) New sandbox test res_1_min_prepaid_gas_and_executor_cap, both builds: - least whole-Tgas prepaid gas at the max state: dispatch 70, reconcile 46, executor finish 43 Tgas; every lower amount from 40 Tgas fails out of gas and writes nothing (raw storage byte-identical, no event, record status kept), extending ASM-ATOMIC's evidence to gas failures; - executor holding 256 jobs: execute 2.52 of 30 Tgas, status 1.77 of 10, finish 2.87; a 257th job fails "full". OQ-9 now cites the measured minimums for the upstream api.md note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…antity (COV-2) The conformance generator now also writes traces/reads.txt (core.txt is byte-identical): the real core's preview (allowed, reason, candidate, energy before and after) and best_quantity for 36,797 requests at 1,246 trace states. prolog/tests/test_reads.pl replays every line through the model: 0 divergences. The generator gates 25 read classes and checks preview against submit on a copy of the pool. Vacuity: model mutants m18-m20 (m19 and m20 killed only by test_reads) and a new reads-mutant kind (d01, d02) that patches a scratch copy of the core and regenerates. Prolog mutants: 33 of 33 killed. RD-PREVIEW and RD-BEST stay unverified (layer kani); this is a differential test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Verified: shared-pool-controls v1.0.0 (contract code byte-identical to the pin a4bb5c3). The pin, PR #1's head, is on upstream main; v1.0.0 is 6f61616, and crates/core/src/lib.rs, crates/contract and crates/executor are byte-identical between the two. Upstream PR #4 (v1.1) is not verified. kani/ is a standalone crate over the pinned pool-core (default-features = false): an executable spec written from the brief (spec.rs), dual-mode harness bodies (checks.rs; symbolic under Kani, random in plain mode), REF-1..3 against a transcription of tla/SharedPool.tla (tla.rs), the fixed-capacity Vec models (model.rs), 31 mutants and run.sh. Results (Kani 0.68.0, CBMC 6.11.0; kani/RESULTS.md): - 89 of 89 harnesses as required: 88 ok, h_canary FAILED on its own assertion only. - 164 of 164 covers SATISFIED, each in some harness of its family (run.sh's per-family rule rechecked over the 89 standing logs). - Plain mode 27 of 27 (incl. h_ref_traces: REF-1..3 on all 212 conformance traces, 8,804 calls). - Mutants: 30 of 30 must-kill killed by plain mode and by their named Kani harness; equivalent mutant 20 survives both. - No property failed; F-1..F-6 witnessed by covers, each in the sense RESULTS.md's Findings table states. Main bounds: step shape 1 metric, 1 term, 2 recipes; exactly 2-record INV pre-states for the _tx, _post and h_ref_* harnesses; INV preserved from 0, 1, 2 and 3 records (induction: reachable states with at most 3 records); values anchored at -1e6/0/1e6 +-4, deltas -3..3, accounts o_, a1, x1, z_; 2-operation traces from Pool::new; 255/256 Cancelled records for the limit. CBMC peaks up to 39 GB. run.sh all was not run end to end in one invocation (its Kani part is about 7 h): every result is the harness's last run (runs A to N) on the final sources. Integration changed comments only (PROP tags for NUM-2 and ROB-1, the v1.0.0 label); plain mode rerun after them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Verified: shared-pool-controls v1.0.0 (contract code byte-identical to the pin a4bb5c3). status.toml: the 31 Kani-primary rows move from unverified to in-progress, with their Kani harnesses first in `harness` and the bounds in a new `kani_bound` key; their other layers' evidence stays. The invariant rows and LIVE-1 gain the Kani induction and h_live1. LIVE-2 is unchanged, and nothing claims for Kani the reachability of F-2, F-2b, F-3 or F-5 from Pool::new. ASM-LEAN-TLA is now also checked by REF-1..3 (mirrored in threat_model.pl); ASM-MODEL and ASM-TOOLS record Kani's bounds and controls. Nothing goes past in-progress: spec_reviewer is empty, and Kani's ceiling is verified-with-assumptions. strategy.md: section 6 and 17.2 now give the Kani results (89 of 89 harnesses as required, 164 of 164 covers, 30 of 30 must-kill mutants, REF-1..3 within the step bounds, and what is not shown). Section 5's Evidence and Status cells name the Kani harnesses; IDs and Layer(s) cells are unchanged. Section 13 records the pin decision: the pin stays at a4bb5c3, whose crates/core/src/lib.rs, crates/contract and crates/executor are byte-identical to v1.0.0 (6f61616), and a CI check for that is next. Upstream PR #4 (v1.1) is not verified here. Sections 1, 4, 10, 12, 14, 15, 16 and 18 follow. Checks: check-status.sh shared-pool 83 properties, 0 problems; check-pin.sh shared-pool ok; prolog/run.sh exit 0 (C-6: 97 properties, 97 section 5 rows, 97 equal layer lists). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
status.toml [project] gains verified_release = "v1.0.0", verified_release_commit = 6f61616 (upstream "Mark the contract as v1.0.0") and identical_paths = crates/core/src/lib.rs, crates/contract, crates/executor. check-pin.sh fetches that commit by SHA when the mirror lacks it (a CI submodule checkout has depth 1) and fails unless each path is the same git tree or blob, mode included, at the pin a4bb5c3 and at 6f61616. Projects without verified_release_commit are unaffected. Checked locally: pass at 6f61616; with 6fcbd56 (PR #4) all three paths differ and the check fails; a bad SHA and a missing path fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…overs) Workflow jobs from kani-jobs.draft.yml with its TODOs resolved: - plain (15 min) and mutants (plain mode, 30 min) on the CI runner. - kani: 29 groups of the 89 harnesses sized by the measured peak memory and time (kani.json), each with its own KANI_TIMEOUT (3x the slowest harness, at least 1800 s) and KANI_MAX_GB (1.5x the peak). runs-on is near-approval's KANI_RUNNER expression byte for byte: without KANI_RUNNER it falls back to the CI runner (ubuntu-latest), where the 8 groups up to 13 GB fit in memory and the 21 above it run on swap (unmeasured; may time out and then fail, nothing is skipped). Runs when the change reaches the Kani layer (pin job gate) or on a manual run with input kani. - covers: every harness ran in exactly one group, then check-covers.sh over every group's covers.tsv (family rule across groups). - kani-mutants: 31 mutants under Kani, manual runs with input mutants. - No loop-bounds job: shared-pool claims no unrolling cutoff and run.sh keeps unwinding assertions on. run.sh: KANI_DEFER_COVERS=1 writes covers.tsv and leaves the family check to the covers job; `run.sh list` prints the harnesses. strategy.md: section 14 rows for the new jobs and the v1.0.0 identity check, status/Next/OQ-11 updated (Kani jobs added, not yet run in CI). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ocs) README: the shared-pool row and section say "verified: shared-pool-controls v1.0.0 (contract code byte-identical to the pin a4bb5c3)", PR #1 merged and the pin kept, the v1.0.0 identity checked by the pin job, the Kani results with their bounds, the Kani CI jobs and their runner needs, and that upstream PR #4 (v1.1) proposes fixes this project has not verified. The label moves from In-Progress to Development Ready: every layer passes on the pin, Kani included, and the spec is unsigned, as for near-approval. docs/architecture.md: Kani in shared-pool's layer list, diagram and CI paragraph; the missing piece is now a cutoff (REF-1..3 exist within the step bounds); no verified* until a spec reviewer signs. Per-layer RESULTS.md pin lines and the strategy.md Target line name v1.0.0; prolog/RESULTS.md no longer calls the read proofs pending Kani. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e on swap CI run 43469880167 (the first with the Kani jobs) verified 85 of the 89 harnesses on GitHub's 16 GB runner. Four did not finish: h_energy_max, h_validate and h_bmc_from_init_s_submit ran out of time on swap, and h_bmc_from_init_po's runner shut down with memory plus swap at 1.25 times its macOS peak. The swap step now brings memory plus swap to twice each group's peak; on swap each harness may use its share of 330 of the job's 360 minutes (kani-mutants: 150 minutes each), and the job prints memory and swap in use every 5 minutes. Records the run in strategy.md section 14, kani/RESULTS.md and the README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ni-record.py) The 36 harnesses and 16 mutants whose measured peak is above 13 GB fail or crawl on swap on GitHub's 16 GB runner (CI runs 43469880167 and 43488691444). They run on a local machine instead, and this records the run so CI can check it rather than run them again. kani/local/run-local.py runs the kani-large groups' harnesses and the kani-mutants-large mutants (read from the workflow) with kani/run.sh unchanged: a git-archive copy of the commit's inputs per lane, each job's matrix timeout as KANI_TIMEOUT, KANI_DEFER_COVERS=1, two jobs at a time within a 50 GB budget of measured peaks, memory sampled every 3 s. It is the repository's copy of the scheduler of the run in progress (same 52 jobs, arguments and timeouts). --record records a run that passed. kani/local/record.py RUN_DIR refuses an incomplete run, a non-zero exit, a harness not ok, a mutant not as its patch expects, a run whose commit, Kani tree, core pin or Kani/CBMC versions do not match, or other Kani inputs than HEAD's. Otherwise it writes provenance.txt (commit, the fingerprint and its input lines, a digest of the data, tool versions, host, start and end), jobs.tsv (result, time, CBMC peak, limit per job) and covers.tsv (the harnesses' covers), and rewrites RESULTS.md's local-record block if it has one. `record.py table` prints that block. tools/scripts/check-kani-record.py recomputes the fingerprint from git object ids (kani/src, Cargo.toml, Cargo.lock, mutants, run.sh, .gitignore, the source-mirror gitlink, conformance/traces/core.txt) and versions.env's KANI and CBMC. This works in a shallow checkout without the submodule. The check fails with "re-run the local Kani record: <command>" when the fingerprint is not HEAD's. It also fails on edited data, a bad recorded verdict, kani groups plus record not covering `run.sh list` exactly once, kani-mutants plus record not covering mutants/*.patch exactly once, a hosted entry above 13 GB, or a stale RESULTS.md block. test-check-kani-record.sh exercises both scripts on a synthetic complete run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ups on swap The kani matrix keeps the 8 groups (53 harnesses) that peaked at 13 GB or less, which fit ubuntu-latest in memory. kani-mutants keeps the 15 mutants whose harness peaked at 13 GB or less. The 21 large groups (36 harnesses) move to kani-large, and the other 16 mutants to kani-mutants-large. Those run only when the KANI_RUNNER variable names a runner and the run is not routed to ubuntu-latest (the pin job's new `large` output). They keep the runner-size check and have no swap step. Otherwise the new kani-record job (every run, about a minute, no submodule) runs test-check-kani-record.sh and check-kani-record.py against the committed record in kani/local. With KANI_RUNNER a stale record is only a warning. The covers job merges the record's harnesses and covers with the groups' when the large groups did not run. The swap step of kani and kani-mutants is narrowed to a margin (KANI_SWAP_GB, default 16, bounded by disk), and the twice-the-peak sizing is gone. Path filters and the pin job's Kani regex add check-kani-record.py. The pin job ignores the local runner and recorder (kani/local/*.py) but not the record's data. ci-areas.sh routes the record check and its test to no near-approval layer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cal record) The docs said CI runs all 89 harnesses in 29 groups, with the large ones on swap or on KANI_RUNNER. Now they describe the split: CI runs the 53 harnesses (8 groups) that fit the hosted runner and 15 mutants under Kani, and checks the local record of the other 36 harnesses and 16 mutants, run at 89f99d6 on a 64 GB Apple M1 Max. KANI_RUNNER still runs the large part in CI. - kani/RESULTS.md: the CI paragraph becomes "CI and the local record", with runs 43469880167 and 43488691444 (27 of 29 groups, 87 harnesses; two never finished on swap). A new "Local record" section covers what was run and how, what kani-record checks, and what it cannot check (that the run took place). It holds the record.py block markers with a marked placeholder, which record.py replaces. The measurement table is kept as the reference that sizes the groups. Also the Layout row for local/ and a note in Mutants. - strategy.md: status, tiers, section 6, layout, the section 12 Kani-row convention (kani_run), the milestones and next steps, a rewrite of section 14 (split table, record, kani-record, KANI_RUNNER, run history, job table with kani-large, kani-record and kani-mutants-large), a risk row for trusting the record, and OQ-11 closed. - status.toml: kani_run on all 38 rows with a Kani result, naming which harnesses the CI kani job runs and which are in the local record (generated from the workflow matrices). Header comments and ASM-TOOLS observed updated. - README.md, docs/architecture.md, kani/local/README.md and the workflow's runner-label comment: same split. check-status.sh, test-check-status.sh, Prolog C-1..C-6 (test_requirements.pl), actionlint, test-check-kani-record.sh and test-ci-areas.sh pass. A synthetic record rewrites the RESULTS.md block and passes check-kani-record.py. No Kani input changed since 89f99d6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Fingerprint: add a default-include line, the sha256 of `git ls-tree -r` of projects/shared-pool/kani less local/ and *.md, so a new file there (kani/.cargo/config.toml, rust-toolchain.toml, build.rs) makes the record stale. The per-path lines stay and name what changed; `check-kani-record.py pathspecs` gives the same inputs for git diff (run-local's work-tree check uses it). The value at 89f99d6 is unchanged in the new algorithm's terms, so the running record stays valid. - Stale record: --stale-ok-harnesses and --stale-ok-mutants excuse each half only when kani-large / kani-mutants-large run (--stale-ok sets both); the workflow passes them from the jobs' own `if:` conditions (kani && large, mutants && large). - check: cross-check provenance.commit by recomputing its fingerprint when the clone has it; require a full commit id; list the changed files when stale; a missing RESULTS.md or local-record block is an error. - record.py: a mutant needs a log of its Kani leg (no header fallback); refuse before writing when RESULTS.md has no block; record kani_env and cargo_config in provenance. - run-local.py: refuse verdict-affecting env (KANI, KANI_FLAGS, KANI_MOD, RUSTFLAGS, CARGO_ENCODED_RUSTFLAGS, RUSTUP_TOOLCHAIN, RUSTC*, CARGO_BUILD_*, CARGO_PROFILE_*, CARGO_TARGET_*_RUSTFLAGS) and cargo config files outside the Kani tree that set rustflags, rustc, a wrapper or a profile; require rustc RUST_TOOLCHAIN and give the mutant jobs RUSTUP_TOOLCHAIN=<RUST_TOOLCHAIN>, as CI does; record the other KANI_* variables in env.txt. - Workflow: the pin job's Kani regex includes conformance/traces/core.txt; `large` needs KANI_RUNNER set, not ubuntu-latest, and matching the job runner; the large jobs' runner-size steps fail on a github-hosted runner with too little memory. - Self-test: scratch-object-store commits (nothing written to the repo) for an added kani/.cargo/config.toml, a run.sh change and a doc-only change; per-half stale flags; commit cross-check; mutant without its Kani log; RESULTS.md without a block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
README (kani/local), RESULTS.md and strategy.md: the default-include fingerprint and `pathspecs`, core.txt among the Kani paths, the refused environment and cargo configuration, RUSTUP_TOOLCHAIN for the mutant jobs, the commit cross-check, the required RESULTS.md block, the per-half stale semantics under KANI_RUNNER (not ubuntu-latest; hosted memory check), and that the record is attested, not proved. Notes that the prototype run's plain mode used rustc 1.95.0 and that the record does not cover the plain half (CI's mutants job re-checks it). Reflows RESULTS.md near line 119 and strategy.md's status and run-43488691444 paragraphs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fixes)
Cargo reads .cargo/config[.toml] in every directory above the crate, so
such a file at the repository root, in projects/ or in
projects/shared-pool/ could change the Kani groups' builds without
changing the local record's fingerprint.
- check-kani-record.py: one more fingerprint line for those files
("none" when the commit has none, as 89f99d6 and HEAD do), the paths
in `pathspecs`, and a `cargo-configs [REV]` subcommand. A stale-record
error on KANI_RUNNER (kani-large ran, kani-mutants-large did not) now
says that only a manual run with `kani` and `mutants` passes without
a new record.
- run-local.py: copies the commit's cargo configuration above kani/ into
each lane, so a run sees it as CI does. A work-tree config above the
run directory that sets build keys is still refused (cargo would read
it on top of the lane's copy), now with a message that says to pass
--out outside the repository.
- shared-pool.yml: the root and projects/ .cargo/config[.toml] in the
path filters and in the pin job's Kani-layer regex. The kani-record
comment notes that a Kani-input change fails it on every pull request
and push until the record is re-made, KANI_RUNNER or not.
- test-check-kani-record.sh: a root .cargo/config.toml makes the record
stale and names the file; the fingerprint repository gains a
projects/shared-pool/.cargo/config commit (one line changes);
cargo-configs; the KANI_RUNNER hint.
- Docs (kani/local/README.md, RESULTS.md, strategy.md section 14,
README.md): the new input, and that a Kani-input change needs a new
record whatever KANI_RUNNER is.
No verdict-affecting Kani input changed; the fingerprint at 89f99d6 and
HEAD is 3ea19cce (the record is not written yet).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 36 harnesses and 16 mutants whose measured peak is above 13 GB, run on a 64 GB Apple M1 Max (Kani 0.68.0, CBMC 6.11.0) from an exact copy of 89f99d6's Kani inputs, two at a time, 2026-11-13T22:44:37Z to 2026-11-14T02:59:36Z: every harness ok, every mutant killed in plain mode and under Kani. h_wedge peaked at 35.4 GB. Fingerprint 3ea19cce127f; check-kani-record.py: with the hosted kani groups, each of the 89 harnesses once; with kani-mutants, each of the 31 mutants once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary of ChangesHello @gabehamilton, I'm the pr-review agent. I've reviewed this pull request — here's a summary to help you and other reviewers get up to speed, with the full code review to follow. This PR adds a multi-layer formal-verification project for the pinned shared-pool-controls implementation, including executable Kani, TLA+, Lean, Prolog, conformance, NEAR, and sandbox artifacts. The most recent change shifts high-memory Kani work to a checked-in local record and adds CI validation of that record and its coverage. Highlights
Changelog
Automated review by the pr-review agent (Codex CLI + GPT-5.6 Terra). Reply on any review thread to discuss a finding. Note: GitHub cannot render this PR's diff (over 20,000 lines), so the review was run against a locally generated merge-base diff, with extra focus on commits 81fb569..a072a2d. |
gabehamilton
left a comment
There was a problem hiding this comment.
Code Review
This PR builds an extensive shared-pool verification suite and, in its newest revision, replaces infeasible hosted high-memory Kani runs with a checked local record. The checker has useful structural and coverage validation, but the record is not bound to the workflow matrix that defines the recorded jobs and the newly added large job can dispatch ordinary fork PR code to KANI_RUNNER. Those correctness and runner-isolation issues should be fixed before relying on the record or enabling the workflow for public PRs. The PR aims to retain meaningful Kani coverage when the largest proofs cannot fit on hosted runners. Its ledger and fingerprint design catch many ordinary stale-record and coverage-split mistakes, but the local execution guard can be bypassed by valid TOML syntax in an external Cargo configuration, and the checker validates matrix declarations rather than that the workflow jobs remain executable. Address these before treating the committed local record as a reliable replacement for CI execution.
| SP + "/source-mirror", | ||
| SP + "/conformance/traces/core.txt", |
There was a problem hiding this comment.
run-local.py obtains the large-job selection and each KANI_TIMEOUT from .github/workflows/shared-pool.yml, but that file is absent from INPUT_PATHS and the checker never compares a recorded limit_s with the current matrix. Consequently, a PR can change a large harness or mutant timeout (or its scheduling/limit metadata) without changing the input fingerprint; the existing record remains accepted even though it was not produced under the verification configuration now claimed by CI. Include the workflow (or a canonical digest of the four relevant matrices) in the fingerprint, then regenerate the record whenever it changes.
| SP + "/source-mirror", | |
| SP + "/conformance/traces/core.txt", | |
| SP + "/source-mirror", | |
| SP + "/conformance/traces/core.txt", | |
| ".github/workflows/shared-pool.yml", | |
There was a problem hiding this comment.
Partly agreed; fixed in 22df7b6. The real gap was that nothing compared a recorded limit_s with the current kani-large / kani-mutants-large matrix timeouts, so a later PR could lower a large timeout and the record would still be accepted. check-kani-record.py now fails when a large matrix timeout is below the limit the recorded run used (a warning only when the large jobs re-verify live on KANI_RUNNER), with self-test cases. All 52 recorded rows match the current matrix, so no re-run was needed. I did not put shared-pool.yml (or a digest of its matrices) into the fingerprint: the file is mostly runner expressions, comments and unrelated TLA+/Lean/Prolog jobs, so every edit would invalidate a 4-hour record, and raising a timeout cannot invalidate a passing run. A direct comparison is exact where a hash would be blunt.
| # KANI_RUNNER must hold them in memory (the runner-size step). | ||
| needs: pin | ||
| if: needs.pin.outputs.kani == 'true' && needs.pin.outputs.large == 'true' | ||
| runs-on: ${{ (startsWith(github.head_ref || github.ref_name, 'dependabot/') || github.actor == 'dependabot[bot]' || github.triggering_actor == 'dependabot[bot]' || startsWith(github.head_ref || github.ref_name, 'claude/') || contains(github.event.pull_request.body, 'claude.ai/code/session_') || github.event.head_commit.committer.email == 'noreply@anthropic.com') && 'ubuntu-latest' || vars.KANI_RUNNER || vars.CI_RUNNER || 'ubuntu-latest' }} |
There was a problem hiding this comment.
The exclusion only recognizes a few bot/agent naming conventions. A normal external contributor can open a fork PR whose ref, actor, body, and committer email do not match any predicate; with KANI_RUNNER configured, this new job then checks out and executes the contributor-controlled Kani crate and build scripts on the persistent self-hosted runner. That exposes its checkout, caches, and any host-accessible credentials to untrusted code. Gate KANI_RUNNER/the large output on an explicit non-fork condition (and route fork PRs to ubuntu-latest or use the local record); apply the same predicate consistently to all Kani jobs.
There was a problem hiding this comment.
Real in principle, but not introduced here, and a fix scoped to the new jobs would not close it. kani and kani-mutants already chose vars.KANI_RUNNER || vars.CI_RUNNER behind the same bot-only clause before this change, near-approval.yml's kani job does the same, and every other job (pin included) runs the PR's scripts on vars.CI_RUNNER. So fork code reaches a self-hosted runner whether or not kani-large is gated. The repo also keeps the runs-on clause byte-identical across about 20 jobs in two workflows, so gating only the new jobs would break that convention and leave the older ones open. Neither variable is set today, so every job runs on ubuntu-latest. The right fix is one repo-wide change adding a fork predicate (e.g. github.event.pull_request.head.repo.full_name != github.repository routes to ubuntu-latest) to the shared clause, paired with the "require approval for all outside collaborators" Actions setting before any self-hosted runner is attached. I've recommended that to the maintainer as a follow-up rather than changing it in this PR.
| # Set per job by this script. | ||
| OWN_ENV = {"KANI_LOG_DIR", "KANI_DEFER_COVERS", "KANI_TIMEOUT", "KANI_CBMC", "KEEP_LOGS"} | ||
| # A cargo configuration key or table that changes how cargo builds. | ||
| CARGO_BUILD_KEYS = re.compile(r"^\s*(rustflags|rustc|rustc-wrapper|rustc-workspace-wrapper)\s*=|^\s*\[profile[.\]]", |
There was a problem hiding this comment.
CARGO_BUILD_KEYS is a text regex, but Cargo parses TOML. For example, a persistent CARGO_HOME/config.toml can legally contain [build] followed by "rustflags" = ["-C", "overflow-checks=off"]. Cargo treats that as the same build.rustflags setting, while this regex does not match the quoted key, so run-local.py accepts an un-fingerprinted configuration that changes the compiler invocation used to produce the supposedly attested proof results. Parse each discovered config with tomllib and reject the relevant keys structurally (including quoted TOML keys), or conservatively reject every external Cargo config rather than attempting lexical filtering.
There was a problem hiding this comment.
Fixed in 651852b. The gap was wider than quoted keys: a top-level build.rustflags = [...] and an inline table build = { rustflags = [...] } also slipped past the line regex. run-local.py now parses each discovered cargo config with tomllib and walks the tree. It refuses rustflags, rustc, rustc-wrapper and rustc-workspace-wrapper at any depth, plus a top-level profile or include, and names the offending key. A file that does not parse, or a Python without tomllib, refuses the run rather than passing it. I did not adopt "reject every external config": a ~/.cargo/config.toml holding only [net] or [registries] does not affect the proof builds. run-local.py is outside the fingerprint, so the 89f99d6 record stays valid (fingerprint 3ea19cce127f unchanged).
| ENTRY = re.compile(r'^\s*- \{ (group|mutant): "([^"]+)", gb: (\d+), timeout: (\d+) \}\s*$') | ||
|
|
||
|
|
||
| def matrices(path=None): |
There was a problem hiding this comment.
matrices() extracts only include rows. It does not validate a job's if: condition, its steps, or the command that consumes matrix.group/matrix.mutant. Thus a workflow edit can retain all four matrices exactly as recorded but add if: false to kani (or replace its Kani step with a no-op). The record checker still reports a complete split, while the 53 harnesses assigned to kani are neither recorded locally nor run; the covers job is also explicitly skipped when needs.kani.result == 'skipped'. Make the required verification workflow immutable from PR branches (for example, a protected/reusable workflow pinned outside the PR ref), and have the self-test/checker reject changes to the required job conditions and Kani invocation rather than treating matrix membership as proof of execution.
There was a problem hiding this comment.
Declining this one. A PR author can edit the workflow and the checker in the same commit, so an if: or step check inside check-kani-record.py cannot stop someone who can edit the workflow; the same edit (if: false, a no-op step, or dropping the job) would equally switch off pin, plain, tla, lean or kani-record itself. Enforcing it needs the workflow protected outside the PR ref (required status checks and branch protection, or a reusable workflow pinned to a SHA), which is repository configuration rather than code in this PR. The split check is meant to catch accidental drift, such as a harness added to run.sh list but left out of every group, or listed twice, and it does that. Parsing if: and step commands would be brittle: kani legitimately has if: needs.pin.outputs.kani == 'true', and covers legitimately skips when kani does. strategy.md section 14 already states the record "cannot show that the run took place as recorded". Recommended to the maintainer as a follow-up: required checks on the PR branch protection.
…ts recorded limit The workflow is outside the local record's fingerprint, so a pull request could lower a kani-large or kani-mutants-large timeout and the record, made under the higher limit, would still be accepted. check-kani-record.py now compares each large entry's timeout with the limit_s its recorded jobs ran under: below it is an error (the record shows a pass within that limit, not within less), equal or above is fine, and under the matching --stale-ok flag (the job runs on KANI_RUNNER under the new timeout) it is a warning. A limit_s that is not whole seconds is an error. The workflow stays out of the fingerprint, so the record at 89f99d6 (fingerprint 3ea19cce127f) is unchanged. Self-test cases: a harness and a two-harness group below the limit, a mutant below it (also with only --stale-ok-harnesses), warnings under --stale-ok-harnesses and --stale-ok-mutants, raised timeouts passing, and a non-numeric limit_s. kani/local/README.md, strategy.md section 14 and the workflow's comments describe the check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sal check
run-local.py refused a cargo configuration file outside its lanes that set
rustflags, rustc, a wrapper or a profile, but it matched the text with a
regex, so cargo's other spellings of the same keys got through: [build]
then "rustflags" = [...], build.rustflags = [...], build = { rustflags =
[...] }, profile.dev.opt-level = 0. It now parses each file with tomllib
and walks the keys: rustflags, rustc, rustc-wrapper and
rustc-workspace-wrapper at any depth (target.<triple>.rustflags too), and
a top-level profile or include (another file the check would not read).
A file that does not parse is refused, and so is a missing tomllib
(Python < 3.11) when there is a file to check: the guard fails closed. The
errors name the keys found, such as "config.toml (build.rustflags)".
--dry-run now makes the environment and cargo configuration checks before
it prints the jobs, as a run does, so the self-test can exercise them
without Kani: test-check-kani-record.sh covers each spelling, a target's
rustflags, rustc and a wrapper, a profile, an include, an unparsable file,
CARGO_HOME/config, a .cargo/ above the run directory, harmless settings,
and RUSTFLAGS in the environment. The kani-record job gets the
Python >= 3.11 step the other macOS-capable jobs have. kani/local/ is
outside the fingerprint, so the record at 89f99d6 (fingerprint
3ea19cce127f) is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, Kani pending) README: the shared-pool row and section give the v1.1.0 numbers of conformance, TLA+, Lean, Prolog, near-tests and the sandbox from their RESULTS.md, the findings closed in v1.1.0 with their closing properties and FR mutants, the documented limits, and the commands (coverage.py, tla executor). The Kani bullet, the Kani split in the CI paragraph and the Kani commands are marked v1.0.0's until the v1.1.0 record. v1.0.0's results are cited on PR #31's branch (a072a2d): the tag does not exist yet. Workflow: header (pin 57b3f02, identity 6fcbd56, every layer but Kani re-done, v1.0.0 on PR #31's branch); tla, lean, prolog, near-unit and sandbox comments with v1.1.0 counts and measured times. Timeouts are unchanged: each is at least 4 times the measured local time. Kani jobs, matrices, inputs and their comments are untouched (W13 part 2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ording, status-lint self-test) - strategy.md and status.toml: hunk anchors at the pin are lib.rs:287 (the Full check, was :284) and :526 (set_paused's bump_new, was :524); FR-8's H13 is :467-469, as in section 4.3 and status.toml. - strategy.md: the v1.1.0 Kani claims in sections 4.5 (FR-2, FR-6b), 5.14 (ASM-MODEL), 10.2, 10.3, 15, 17, 17.5 and 18 now say "pending at v1.1.0" with the v1.0.0 result; OQ-1 says every layer but Kani was re-run and v1.0.0's results stay recorded, not verified. - strategy.md: v1.0.0's results commit is a072a2d; the tag goes on PR #31's head (651852b now; 22df7b6 and 651852b change no layer's results). Q3 and R1 were formalver's plan labels, not upstream's: dropped (D-1 is upstream's; the doc cites stay). - README: the Kani status sentence gives status.toml's counts (68 in-progress; 34 Kani-primary rows keep 31 stale and 3 unverified). - shared-pool.yml: status-lint runs test-check-status.sh first (its path is in both filters) and its comment names the 14 findings; the tla comment records the hosted 5g run (run 43600054037, 22 min). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Formal verification of shared-pool-controls v1.0.0 (
pool-coreand its NEAR contract), following the near-approval pattern. Verified: shared-pool-controls v1.0.0 (contract code byte-identical to the pina4bb5c3). Label: Development Ready: every layer passes on the pin, Kani included; every property staysin-progressbecause the spec is unsigned (no[review] spec_reviewer).Pin and version. The submodule
projects/shared-pool/source-mirrorstays ata4bb5c3, a head of upstream PR #1. PR #1 has merged and the pin is on upstreammain. v1.0.0 is6f61616("Mark the contract as v1.0.0").crates/core/src/lib.rs,crates/contractandcrates/executorare byte-identical between the pin and v1.0.0 (also at80fb89eand today'smain,58e925a); the version number is only in the rootCargo.toml.check-pin.shnow fetches6f61616by SHA and fails unless those three paths are the same git trees and blobs as at the pin (status.toml:verified_release_commit,identical_paths); thepinjob runs it. The pin is kept because re-pinning would renumber the conformance traces (v1.0.0'sfixtures.rsaddsstationfirst) and change the wasm hashes, with no change in the verified code.Upstream v1.1. difflabai/shared-pool-controls#4 (v1.1, open) proposes fixes for the findings below. This PR does not verify v1.1.
Shared link between layers.
conformance/runs the pinnedpool-coreand emits 212 traces (8,804 calls): the F-1 wedge, the five upstream fixtures, 200 random configs, and traces forArithmetic/expiry edges,Full, and findings F-2, F-2b, F-4, F-6. TLA+ (TraceCheck), Lean (REF-5L), Prolog (MC-2), the NEAR shell (host + two wasm builds) and Kani's plain mode (REF-1..3 throughtla.rs) replay every trace with equal results and post-states.pool-core: 89/89 harnesses as required (h_canaryfails on its own assertion, by design), 164/164 covers satisfied, plain mode 27/27, 30/30 must-kill mutants killed by plain mode and by Kani (mutant 20 is equivalent and survives). REF-1..3: the core refines the TLA+ model per step (7/7h_ref_*)status.tomlagainst strategy.md §5), MC-1, MC-2, COV-2 (the core'spreviewandbest_quantityequal the model's on 36,797 requests); 33/33 mutants killedKani on the real core
projects/shared-pool/kani/depends only on the pinnedpool-core(default-features = false);src/spec.rsis an executable spec written from the brief,src/tla.rsa transcription oftla/SharedPool.tla. Kani 0.68.0, CBMC 6.11.0, runs A to N on a 64 GB arm64 Mac, one harness at a time (sum 26,921 s, about 7.5 h; peaks up to 39.0 GB). Details:kani/RESULTS.md, strategy.md §6.Bounds. Steps, REF-1..3,
h_previewandh_version_max_*: 1 metric, 1 term, 2 recipes, an INV pre-state with exactly 2 records in any statuses; values anchored at −10^6, 0 and 10^6, each ±4; deltas −3..3;max_units1..3; weights 1, 2 or 1,000; four accounts in every role and as every caller; times, versions, expiries andpausedfree. INV is preserved from 0, 1, 2 and 3 records, so INV-WF..INV-DEP hold in every reachable state with at most 3 records; INV-VER only along 2-operation traces fromPool::new.h_energycovers the whole value range (2 metrics, 2 terms);h_energy_max64 terms;h_full_*255 and 256 Cancelled records.Shown within those bounds. Every call's exact result in guard order and exact post-state equal the spec's (TX-*, NUM-2, ROB-1, the §5.3 step properties); the reads (RD-PREVIEW; RD-BEST and CFG-1 as compositions); LIVE-1 with 3 records; REF-1 (same error,
Okexactly when the TLA+ action is enabled or a model no-op), REF-2 (same effect) and REF-3 (rejected calls stutter). Each core finding has a cover that must be satisfied: F-1 fromPool::new, F-4 as a configuration, F-2, F-2b and F-5 from constructed states, F-3's cycle and the exact 256-record limit, F-6's mechanism. No property failed and Kani found no new defect. Two Kani 0.68.0 soundness hazards were found and worked around (a written static sharing storage with an equal constant; references into a local array of structs at an unfolded index), recorded under ASM-TOOLS.Not shown. Anything outside the bounds: steps over more metrics, terms or recipes, or from 4 or more records (other than a submit at 255 or 256 Cancelled records); values strictly between the anchors and the extremes outside energy; the reachability of F-2, F-2b, F-3 and F-5 from
Pool::new(plain mode, TLA+ and the sandbox show it, not Kani); LIVE-2 (TLA+'s); REF-1..3 outside the step bounds, and the agreement oftla.rswith the.tlaother than on the traces; memory safety of std; the shell, the executor and NEAR.run.sh allwas not run end to end in one invocation; each result is that harness's last run on the final sources.status.toml. The 31 Kani-primary rows are
in-progresswithbounded-proofevidence, the harnesses first inharnessand the bounds in a newkani_boundkey; ASM-LEAN-TLA is now checked by REF-1..3.Findings (details and reproducers in
projects/shared-pool/strategy.md§4):observedisturbs the pool, a dispatched hedge can neither settle (Boundsboth ways) nor be cancelled (Pending); every laterobservefailsPending.riskfixture, healthy start, the executor's honestsettle(false)failsBoundsandcancel/observefailPending(contradictsdocs/spec.md); variant F-2b failsArithmetic.status.toml: 83 properties, 14 assumptions, nothing past in-progress; status-lint clean.CI
.github/workflows/shared-pool.ymlrunspin(gitlink, source hashes, the v1.0.0 identity),status-lint,conformance,tla,lean,prolog,near-unitand, for Kani,plain,mutants(plain mode) andkani-recordon every run. Kani is split by measured peak:kani, when a change reaches the Kani layer;kani-mutants, manual)kani/local/(orkani-large/kani-mutants-largeon a runner named byKANI_RUNNER, at least 49 GB)h_wedge35-39 GB)On the 16 GB hosted runner the large groups ran on swap and some never finished (runs 43469880167 and 43488691444: timeouts and runners that lost contact), so they were run locally and recorded instead. Local record (
a072a2d): the 36 harnesses and 16 mutants at89f99d6on a 64 GB Apple M1 Max, Kani 0.68.0 / CBMC 6.11.0, 2026-11-13T22:44Z to 2026-11-14T02:59Z, two at a time: every harness ok, every mutant killed in plain mode and under Kani.kani-record(tools/scripts/check-kani-record.py) recomputes the fingerprint of the Kani inputs from git object ids (kani/but its Markdown andlocal/, the core gitlink,conformance/traces/core.txt, cargo config abovekani/, the Kani and CBMC pins) and fails if it is not HEAD's, so any change to a Kani input needs a new record (kani/local/run-local.py --record, about 4 h) or aKANI_RUNNER.coverschecks every harness ran exactly once across the hosted groups and the record, and every family's covers together.sandboxand the Kani mutants run only on manual dispatch. Details:kani/local/README.md,kani/RESULTS.md(local record block), strategy.md §14.Test plan
tools/scripts/check-pin.sh shared-pool(incl. the v1.0.0 identity; negative check against PR ci: run on the self-hosted macOS runner via vars.CI_RUNNER #4's head fails),tools/scripts/check-status.sh shared-poolconformance:cargo run --release --locked -- --check traces/core.txt --reads-check traces/reads.txttla/run.sh(safety liveness trace) andrun.sh mutantslean/run.sh,prolog/run.sh(full),near-tests/run.sh all,sandbox/run.sh(locally)kani/run.sh plain,kani/run.sh kani(all 89, runs A to N),kani/run.sh ref,kani/run.sh mutants --kani(locally).github/workflows/shared-pool.ymlon hosted runners for every layer but Kani (run 43194245726)kani/local/run-local.pyrun of the 36 large harnesses and 16 large mutants at89f99d6,tools/scripts/check-kani-record.pyand its self-test passplain,mutants,kaniwith the 8 in-memory groups,kani-record,covers): run 43549338411 ona072a2d, 19 jobs passed, 4 skipped by design (kani-large,kani-mutants-large,kani-mutants,sandbox)651852b(review fixes: record limits vs matrix timeouts, TOML parse of cargo config): run 43552514654 green🤖 Generated with Claude Code