handleCommit only marks the last accepted state committed
ProvedOpenSearchCoordination.handleCommit_specFor every coordination state cs, commit request c and state cs': if cs.handleCommit c = .ok cs' then
- the commit is for the last accepted state in the current term:
c.term = cs.currentTerm,c.term = cs.lastAcceptedTermandc.version = cs.lastAcceptedVersion; cs'iscswith its last accepted state replaced bycs.lastAcceptedState.markCommitted(the committed configuration becomes the accepted one, and a known cluster UUID is marked committed);- in
cs'the last committed configuration equals the last accepted configuration (the assertion atCoordinationState.java:572); - the last accepted configuration, term, version and payload of
cs'are those ofcs.
import Definitions.Def_OpenSearchCoordination
theorem OpenSearchCoordination.handleCommit_spec {V : Type} (cs : CoordinationState V) (c : ApplyCommitRequest) (cs' : CoordinationState V)
(h : cs.handleCommit c = .ok cs') :
c.term = cs.currentTerm ∧ c.term = cs.lastAcceptedTerm ∧ c.version = cs.lastAcceptedVersion ∧
cs' = { cs with lastAcceptedState := cs.lastAcceptedState.markCommitted } ∧
cs'.lastCommittedConfiguration = cs'.lastAcceptedConfiguration ∧
cs'.lastAcceptedConfiguration = cs.lastAcceptedConfiguration ∧
cs'.lastAcceptedTerm = cs.lastAcceptedTerm ∧ cs'.lastAcceptedVersion = cs.lastAcceptedVersion ∧
cs'.lastAcceptedState.value = cs.lastAcceptedState.value := by sorryRead-back
What the Lean code literally says, in plain math · claude-opus-5-5 (independent sub-agent, blind: Lean code + auditor instructions only)
Read-back: OpenSearchCoordination.handleCommit_spec
Notions used
Coordination states and cluster states. A coordination state has nine fields: localNode, currentTerm , lastAcceptedState, joinVotes, startedJoinSinceLastReboot, electionWon, lastPublishedVersion , lastPublishedConfiguration and publishVotes.
A cluster state has nine independent fields:
- ;
- and ;
- two voting configurations, and ;
- , an optional natural;
- two Booleans, and ;
- a payload .
Abbreviations, read from :
- = its term;
- = its version;
- = its last committed configuration;
- = its last accepted configuration.
Marking committed. works in two steps:
- If the two configurations differ, set the committed configuration to the accepted one.
- If and , set .
The net effect: the committed configuration becomes the accepted configuration, and becomes . The other seven fields are unchanged.
Messages. A commit request has a node , a term and a version .
The handler checks three guards in order:
- If , it returns .
- If , it returns .
- If , it returns .
Otherwise it returns .
1. Declaration
Binders. (implicit), , (a commit request), .
Hypothesis. : .
Conclusion. The conjunction of:
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- .
Conjunct 4 determines completely. Conjuncts 5–9 spell out consequences of it. Conjuncts 1 and 2 together give : a commit is applied only when the node's last-accepted term equals its current term.
2. What is not constrained
- is never mentioned. The handler does not read it.
- Some effects of are implied only through conjunct 4 and are not stated separately:
- the update of ;
- the preservation of , and .
- The statement goes in one direction only: from success to the listed facts.
- No hypothesis beyond success is assumed. No invariant on is needed or used.
- The statement is not vacuous: any with and succeeds.
3. Plain-language summary
A commit is applied only when its term equals both the node's current term and its last-accepted term, and its version equals the last-accepted version. Applying it only marks the last-accepted state as committed:
- the committed configuration becomes the accepted configuration;
- a known cluster UUID is flagged committed;
- the term, version, accepted configuration and payload are unchanged.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.