Repository navigation
feat(formal): add Lean models of the charge intent and Tempo charge with a shared core - #402
Conversation
…ith a shared core
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Spec Preview
|
| - Guards for rules the draft leaves out are `Cfg` flags, default on; each has a counterexample with it off ([GAPS.md](./GAPS.md)). | ||
| - `splits = []` means absent; `pull` / `push` stand for `supportedModes` (both true when omitted). | ||
| - A pull transaction that reverts stays on chain (nonce used, fee paid by the sponsor); its settlement issues no receipt and the challenge reopens, so a client can retry; §Server-Paid Fees accepts that fee risk. | ||
| - The server sponsors any pull transaction for a `feePayer` challenge; one with `sponsor = false` needs no fee payer. |
There was a problem hiding this comment.
🟡 nit (optional): The README tells readers that a sponsor = false pull transaction for a feePayer challenge is accepted, but the model now rejects it. The submit guard at Model.lean:326 requires t.sponsor = cr.echo.request.feePayer, so a feePayer challenge needs a sponsored transaction. Fix: reword line 65 to match the guard: a pull transaction carries the fee payer placeholder exactly when the Challenge sets feePayer, and the server sponsors only those.
Why this was flagged
formal/tempo-charge/TempoCharge/Model.lean:325-326 accepts a .transaction t credential only when t.sponsor = cr.echo.request.feePayer. That covers both directions: a feePayer challenge with sponsor = false is refused, and so is a non-feePayer challenge with sponsor = true. formal/tempo-charge/README.md:65 still says "The server sponsors any pull transaction for a feePayer challenge; one with sponsor = false needs no fee payer", which describes the behaviour before this PR's tempo-charge fix. Anyone reading the README for the modelling choices gets a rule the checked model does not encode. No code safeguard applies because this is documentation.
Verification: The .submit guard for .transaction t in formal/tempo-charge/TempoCharge/Model.lean:325-326 requires t.sponsor = cr.echo.request.feePayer. So a pull transaction with sponsor = false against a feePayer challenge makes step return none (line 336, else none). formal/tempo-charge/README.md:65 still describes the looser rule. Only the README is affected.
| rm -rf .lake "$core/.lake" | ||
| lake build |
There was a problem hiding this comment.
🟡 (optional) A maintainer who adds an MppCore/ module that the MppCore root does not import will see every model's check.sh fail, while core/check.sh passes. The model's lake build (line 78) builds only the model's default target and the MppCore modules it imports. The audit module list (lines 255-257) still names every file under MppCore/, so importModules hits a missing .olean. Fix: build exactly the set the audit loads by running lake build "${libs[@]}" here, so MppCore's own globs target is built in every model run. A model that imports only MppCore.Machine hits the same failure.
Why this was flagged
For a model, check-lib.sh adds MppCore and every MppCore.<file> under formal/core/MppCore/ to $modules. Line 77 then deletes "$core/.lake", and line 78 runs a bare lake build from the model directory. That builds the root package's defaultTargets plus whatever MppCore modules the model's imports reach, not MppCore's globs = ["MppCore", "MppCore.+"] target (formal/core/lakefile.toml). Suppose a module under MppCore/ is not imported by MppCore.lean. Audit.lean's importModules then throws on the missing .olean, and the script prints "FAIL: axiom audit". core/check.sh passes in this case because there MppCore is the root package and its globs are built. The failure is fail-closed, but it rejects valid changes with a misleading error. The base branch had no dependency library, so this mismatch could not happen there.
Verification: Severity: nit. No such module exists today: MppCore/ holds only Fn.lean and Machine.lean, and MppCore.lean imports both. In formal/core/check-lib.sh, line 77 runs rm -rf .lake "$core/.lake", and line 78 runs a bare lake build from the model directory. The failure is fail-closed: CI fails falsely, and no proof goes unchecked.
Replaces #401 with one signed commit; content is #401's head plus a tempo-charge fix. Stacked on #400.
formal/core(MppCore) holds what the models share:run,Reachable,upd, and the proof gate (check-lib.sh,Audit.leanwith kernel replay). Each model is audited with it.feePayer, so the model no longer records sponsorship the server never paid.Checks:
bash formal/<model>/check.shpasses for core, intent-charge, tempo-charge and tempo-session.