Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a345706
Commit a signature batched before a configuration adding the first peer
cjen1-msft Nov 16, 2026
541b825
Add trace encoders for Aft vote state
cjen1-msft Nov 16, 2026
ae5646e
Trace Aft protocol variables on the events that use them
cjen1-msft Nov 16, 2026
2357f64
Add observation refinement and lock-hold sections to ccf_common
cjen1-msft Nov 17, 2026
bdd494b
Add the reviewed trace-validation surface for cft.h
cjen1-msft Nov 17, 2026
327c76c
Add M_tv, a model of cft.h with one step per trace point
cjen1-msft Nov 17, 2026
57cf5a6
Replace the consensus replayer with the M_tv validator
cjen1-msft Nov 17, 2026
419a50b
Add the refinement proof framework for trace validation
cjen1-msft Nov 17, 2026
d1f37a0
Prove the lifecycle and drop obligations
cjen1-msft Nov 17, 2026
a0e30ea
Prove the AppendEntries obligation
cjen1-msft Nov 17, 2026
750fe5a
Prove the vote obligations
cjen1-msft Nov 17, 2026
98274d6
Prove the AppendEntriesResponse and nomination obligations
cjen1-msft Nov 17, 2026
d6ee298
Prove the tick obligation
cjen1-msft Nov 17, 2026
20db0b5
Prove the replicate obligation
cjen1-msft Nov 17, 2026
cbe5227
State and prove that accepted traces refine the clean model
cjen1-msft Nov 17, 2026
62722a3
Document trace validation and its known differences from the specific…
cjen1-msft Nov 17, 2026
1b8dcbe
State that the observations are the streams' events, not just their l…
cjen1-msft Nov 17, 2026
5b1c3c7
Require every trace point's declared fields, uniformly
cjen1-msft Nov 17, 2026
a584595
Take a snapshot joiner's view history from the donor
cjen1-msft Nov 17, 2026
fc29fa3
Describe the replicate batch commit fix in the change notes
cjen1-msft Nov 17, 2026
ab894d8
Say what to change when trace validation rejects a cft.h change
cjen1-msft Nov 17, 2026
2841121
Move M_tv and the validator out of the reviewed folder
cjen1-msft Nov 17, 2026
58d7a2f
Make the trusted path from a trace file reviewed, apart from the sche…
cjen1-msft Nov 17, 2026
7c7f1ee
Keep the reviewed trace-validation files independent of their subfolders
cjen1-msft Nov 17, 2026
8cf7b4b
Document the reviewed and unreviewed trace-validation folders
cjen1-msft Nov 17, 2026
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
2 changes: 2 additions & 0 deletions .changes/cft-trace-protocol-variables.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
`ccf.cft` consensus trace events now also carry the protocol variables `voted_for`, `votes_for_me`, `leader_id`, `is_new_follower` and `ticking` as top-level fields, on the events whose code reads or writes them.
See the [consensus trace replay README](lean/consensus/replay/README.md#run-replay) for the encoding.
2 changes: 2 additions & 0 deletions .changes/commit-before-reconfiguration-in-batch.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
A signature replicated in the same batch as a later reconfiguration transaction adding the first other node now commits at once, rather than waiting for that node to acknowledge it.
See [Reconfiguration](doc/architecture/consensus/index.rst#reconfiguration).
2 changes: 1 addition & 1 deletion .github/workflows/lean-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
shopt -s failglob
for trace in lean/consensus/replay/fixtures/valid/*.ndjson; do
echo "::group::Validate $trace"
lean/consensus/.lake/build/bin/consensus-replay "$trace"
lean/consensus/.lake/build/bin/consensus-replay --refine "$trace"
echo "::endgroup::"
done

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ jobs:
shopt -s failglob
for trace in "$RUNNER_TEMP"/cft-scenario-traces/*.ndjson; do
echo "::group::Validate $trace"
lean/consensus/.lake/build/bin/consensus-replay "$trace"
lean/consensus/.lake/build/bin/consensus-replay --refine "$trace"
echo "::endgroup::"
done

Expand Down
2 changes: 1 addition & 1 deletion doc/architecture/verification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Lean packages
- The :doc:`CCF consensus protocol </architecture/consensus/index>`, as implemented in :ccf_repo:`src/consensus/aft/cft.h`.
Proved properties include election safety (no two primaries in the same term), prefix-comparability of committed logs, and that every positive commit index points to a signature entry.
A joining node may initialize from another node's committed ledger prefix, as when installing a snapshot; the join protocol is not modelled.
- :ccf_repo:`consensus-replay <lean/consensus/replay/README.md>` replays traces of the consensus scenarios run by the native ``cft_driver``.
- :ccf_repo:`consensus-replay <lean/consensus/replay/README.md>` validates traces of the consensus scenarios run by the native ``cft_driver``, and of real nodes, against a model of ``cft.h`` with one step per trace point, and relates each accepted trace to the protocol model by a refinement theorem.
* - :ccf_repo:`consistency <lean/consistency/README.md>`
- CCF's externally visible consistency semantics, including :ref:`transaction status <use_apps/verify_tx:Checking for Commit>`, for a simple append-and-read application with forwarded reads, elections and invalidation.
The primary guarantee is that committed writes serialize in transaction ID order, and that this order respects the real-time order of requests and their initial responses.
Expand Down
9 changes: 6 additions & 3 deletions lean/AGENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ Within a model's library directory, use this layout:
| `Properties/` | Definitions needed to state and understand those claims, such as state and trace predicates. |
| `Proofs/` | Supporting derivations, ghost state, strengthening invariants, and correspondence proofs. |
| `Tests/` | Executable model checks and regression cases. |
| `TraceValidation.lean` | Replay recorded implementation traces through the executable model. |
| `TraceValidation/` | Parsing and ordering of those traces, for `TraceValidation.lean`. |
| `TraceValidation.lean` | State that accepted implementation traces refine the model. |
| `TraceValidation/` | Reviewed: declared state, trace events and their decoding, observation and state mapping. |
| `TraceValidation/*/` | Not reviewed: the implementation model, validator and proofs, each in a sensibly named subfolder. |

## Dependency direction

Expand All @@ -32,6 +33,7 @@ Within a model's library directory, use this layout:
- Property helpers in `Properties/` should depend on the model, shared definitions, and other property helpers.
They may not import `Properties.lean` or `Proofs/`.
- Let `Proofs/` depend on model definitions, property helpers, and other supporting proofs, but not `Properties.lean`.
- Files directly in `TraceValidation/` may import only the model, `common/CCF/` definitions (not `CCF.Proofs`), `TraceValidation.lean` and each other, so the reviewed surface reads without its subfolders.
`Properties.lean` publicly imports the types and helpers needed to understand its statements and privately imports proof implementations.

Write the full logical statement in each public safety theorem and existential witness lemma, rather than defining a separate named proposition.
Expand Down Expand Up @@ -78,6 +80,7 @@ Moving ghost definitions into `Properties/` merely to remove an import does not

Review the model, full statements and proof links in `Properties.lean`, and the property helpers used by those statements.
Keep the detailed proof implementations machine-checked and within the axiom allowlist.
For trace validation, review `TraceValidation.lean` and the files directly in `TraceValidation/`; its subfolders are machine-checked like `Proofs/`.

Retain the package-level import root, whole-package import coverage with `lake exe check-imports`, and kernel and axiom-dependency checks with `lake check`.
The proof entrypoint does not replace either check.
Expand All @@ -86,4 +89,4 @@ For disaster recovery, see the [validation commands](disaster-recovery/README.md

The shared `lake exe check-imports` command checks dependency direction for every specification library root discovered from Lake.
Do not add per-model architecture tests; see [the common package](common/README.md#architecture-checks) for the policy.
It keeps common and model modules independent of properties and proofs, property helpers independent of proofs and theorem entrypoints, and proof implementations independent of the final theorem entrypoint.
It keeps common and model modules independent of properties and proofs, property helpers independent of proofs and theorem entrypoints, proof implementations independent of the final theorem entrypoint, and the reviewed trace-validation files independent of their subfolders.
4 changes: 4 additions & 0 deletions lean/common/CCF.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ public import CCF.Execution
public import CCF.Finset
public import CCF.Function
public import CCF.MultiNodeTransitionSystem
public import CCF.Observation
public import CCF.Parsec
public import CCF.Proofs.Execution
public import CCF.Proofs.Finset
public import CCF.Proofs.Function
public import CCF.Proofs.Sections
public import CCF.Proofs.SectionsObservation
public import CCF.Proofs.Seq
public import CCF.Sections
public import CCF.Seq
public import CCF.TransitionSystem
public import CCF.TxID
7 changes: 6 additions & 1 deletion lean/common/CCF/Architecture.lean
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ def allowedImport (root owner dependency : Name) : Bool :=
let model := root ++ `Model
let properties := root ++ `Properties
let proofs := root ++ `Proofs
let traceValidation := root ++ `TraceValidation
-- The reviewed trace-validation surface: the modules directly in `TraceValidation/`.
let reviewed (module : Name) := module.getPrefix == traceValidation
if (`CCF).isPrefixOf owner then
!root.isPrefixOf dependency
else if !root.isPrefixOf dependency then
-- The `CCF` entrypoint reexports `CCF.Proofs`, so models must import definitions directly.
!(model.isPrefixOf owner
!((model.isPrefixOf owner || reviewed owner)
&& ((`CCF.Proofs).isPrefixOf dependency || dependency == `CCF))
else if model.isPrefixOf owner then
model.isPrefixOf dependency && (owner == model || dependency != model)
Expand All @@ -37,6 +40,8 @@ def allowedImport (root owner dependency : Name) : Bool :=
else if properties.isPrefixOf owner then
model.isPrefixOf dependency
|| (dependency != properties && properties.isPrefixOf dependency)
else if reviewed owner then
model.isPrefixOf dependency || dependency == traceValidation || reviewed dependency
else if proofs.isPrefixOf owner then
model.isPrefixOf dependency
|| proofs.isPrefixOf dependency
Expand Down
53 changes: 53 additions & 0 deletions lean/common/CCF/Observation.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module

public import CCF.Execution

@[expose] public section

namespace CCF.ObservationRefinement

/-!
Observation-point refinement: the reviewed statement relating a traced
implementation to a specification.

An implementation is observed through a list of `Observation`s, one per traced event,
each carrying the node's declared state as snapshotted at that event. `Refines` says
that one specification execution, read at nondecreasing positions, explains every
observed point: the observed node's state in the specification at the corresponding
position is related by `rel` to the observed declared state. Only declared states,
`rel`, the event predicate and the specification appear here; how the implementation
model is built, and how it is proved to satisfy this, is not part of the statement.
-/

/-- One traced event: the node, the event, and the node's declared state at the event. -/
structure Observation (Node Event Declared : Type) where
/-- The node that traced the event. -/
node : Node
/-- The traced event, with every label it carries. -/
event : Event
/-- The node's declared state, as snapshotted when the event was traced. -/
declared : Declared

/--
`Refines spec nodeOf rel observed observations`: there is a specification trace and a
nondecreasing map `index` from observation positions to trace positions such that, at
every observation whose event satisfies `observed`, the trace's state at `index`
position has the observed node in a state related by `rel` (for that node) to the
observed declared state.
-/
def Refines {Node Event Declared SpecLocal : Type} (spec : TransitionSystem)
(nodeOf : spec.State -> Node -> Option SpecLocal)
(rel : Node -> SpecLocal -> Declared -> Prop)
(observed : Event -> Bool) (observations : List (Observation Node Event Declared))
: Prop :=
exists (trace : Execution.Trace spec) (index : Nat -> Nat),
(forall i j, i <= j -> index i <= index j)
/\ forall (i : Nat) (observation : Observation Node Event Declared),
observations[i]? = some observation
-> observed observation.event = true
-> exists state local_,
trace.stateAt (index i) = some state
/\ nodeOf state observation.node = some local_
/\ rel observation.node local_ observation.declared

end CCF.ObservationRefinement
Loading