Add the C++-aligned Lean disaster recovery model - #8277
Add the C++-aligned Lean disaster recovery model#8277Amaury Chamayou (achamayou) wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Two newly added Lean source files are committed with CRLF line endings, which should be normalized to LF for consistency and to avoid future diff/tooling churn.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR introduces a new, pinned Lean package under lean/disaster-recovery/ containing the canonical (C++-aligned) disaster recovery model plus associated safety/liveness proofs and executable “canonical checks”, and adds a dedicated GitHub Actions workflow to build and validate it on relevant PRs.
Changes:
- Add the Lean disaster recovery model (local + global semantics) and proof modules (invariants, quorum uniqueness, committed-prefix safety, temporal progress).
- Add an executable
canonical-checkstarget and an axiom/sorry gate (AxiomChecks.lean) for the project’sDisasterRecoverydeclarations. - Add a PR-scoped CI workflow to install Lean, restore Mathlib cache, build, and run canonical checks.
Custom instructions used:
.github/copilot-instructions.md
File summaries
| File | Description |
|---|---|
lean/disaster-recovery/README.md |
Package overview, proof scope/limits, and validation commands. |
lean/disaster-recovery/lean-toolchain |
Pins the Lean toolchain version for reproducible builds. |
lean/disaster-recovery/lakefile.toml |
Defines the Lean package, Mathlib dependency pin, and executable target. |
lean/disaster-recovery/lake-manifest.json |
Captures resolved Lake dependencies for reproducibility. |
lean/disaster-recovery/.gitignore |
Ignores Lake build artifacts. |
lean/disaster-recovery/DisasterRecovery.lean |
Top-level library module importing all package components. |
lean/disaster-recovery/DisasterRecovery/Protocol/Model.lean |
C++-aligned local state machine + transition function. |
lean/disaster-recovery/DisasterRecovery/Protocol/Temporal.lean |
Local temporal definitions and progress/safety lemmas. |
lean/disaster-recovery/DisasterRecovery/Protocol/Global.lean |
Global semantics (network/sent history/effects) over local transitions. |
lean/disaster-recovery/DisasterRecovery/Protocol/Invariants.lean |
Reachability and well-formedness invariants for global executions. |
lean/disaster-recovery/DisasterRecovery/Protocol/Quorum.lean |
Quorum invariants and quorum-opener uniqueness theorem. |
lean/disaster-recovery/DisasterRecovery/Protocol/Committed.lean |
TxID prefix order + committed-prefix preservation under explicit premises. |
lean/disaster-recovery/DisasterRecovery/Protocol/GlobalTemporal.lean |
Conditional global liveness/progress results under fairness premises. |
lean/disaster-recovery/CanonicalTests.lean |
Executable canonical behavior checks + small-state exploration. |
lean/disaster-recovery/AxiomChecks.lean |
Rejects sorryAx dependencies in DisasterRecovery.* declarations. |
.github/workflows/README.md |
Documents the new Lean DR workflow purpose and scope. |
.github/workflows/lean-disaster-recovery.yml |
Adds PR workflow to install Lean, build, reject sorryAx, and run canonical checks. |
Review details
- Files reviewed: 16/17 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
6ab6f18 to
6151e0c
Compare
Heidi Howard (heidihoward)
left a comment
There was a problem hiding this comment.
Can we restructure this to clearly separate Lean code that is human reviewed (e.g. a Properties.lean and Model.lean) and code that's not (e.g. Proof.lean)
| run: | | ||
| set -euo pipefail | ||
| lake build | ||
| lake env lean -DwarningAsError=true AxiomChecks.lean |
There was a problem hiding this comment.
Lean provides an gh action for checking Lean files including checking for non-standard axioms etc. I think it would be better to use that instead of rolling our own
The action: https://github.com/leanprover/lean-action
Example use: https://github.com/fpaxos/fpaxos-tlaplus/blob/main/.github/workflows/lean.yml
| @@ -0,0 +1,46 @@ | |||
| name: "Lean Disaster Recovery" | |||
There was a problem hiding this comment.
Can we call this just lean.yml and have it cover any future lean code to instead of just the DR? I'd like the CI to ensure no lean files are checked in to this repo that haven't been checked by Lean
There was a problem hiding this comment.
move file to up a level to lean directory to shared by all lean code
There was a problem hiding this comment.
Personally, I'd prefer a clear separation between checking proofs (the model is correct) and executing test cases (the model is useful). Likewise, this files combines the specific test scenarios with the infra for running said tests, which I feel would be clearer if seperated
Summary
Part 1 of 4 replacing #8241 with a reviewable stack. This bottom layer adds the permanent canonical Lean package under
lean/disaster-recovery/: the C++-aligned transition model, local and global semantics, reachability invariants, quorum uniqueness, committed-prefix safety, and conditional liveness proofs.The package exposes only the permanent library and canonical executable checks. A dedicated pull-request workflow builds the package, rejects project
sorryAxdependencies, and runs the canonical behavior checks. It does not add the temporary legacy-equivalence bridge, Rust changes, implementation tracing, C++ instrumentation, or e2e wiring.Proof limits
DurableCommitandFullGossipSelectionpremises. A quorum opening alone does not establish full-gossip selection.BroadcastBeforeCompletionfor all-node termination. The proofs do not construct a scheduler satisfying those premises.Validation.acceptedandValidation.rejectedmodel the result of implementation validation; they do not prove quote, certificate, or other cryptographic checks.Files
Model and checks
DisasterRecovery/Protocol/Model.leanDisasterRecovery/Protocol/Global.leanCanonicalTests.leanAxiomChecks.leansorryAxrejectionProofs
DisasterRecovery/Protocol/Temporal.leanDisasterRecovery/Protocol/Invariants.leanDisasterRecovery/Protocol/Quorum.leanDisasterRecovery/Protocol/Committed.leanDisasterRecovery/Protocol/GlobalTemporal.leanReplacement stack
Later layers will add the temporary Lean/Stateright equivalence bridge, remove that bridge together with the legacy Rust model after equivalence is established, and finally add permanent implementation trace validation. The canonical model and proofs in this PR are intended to remain unchanged through those layers.
Validation
lake exe cache getlake buildlake env lean -DwarningAsError=true AxiomChecks.leanlake exe canonical-checksscripts/prettier-checks.sh -fscripts/ascii-checks.shscripts/ci-checks.sh