handleStartJoin succeeds exactly when the term increases; it moves to that term and votes for the requester
ProvedOpenSearchCoordination.handleStartJoin_specFor every coordination state cs, start-join request req, state cs' and join j: cs.handleStartJoin req = .ok (cs', j) holds iff all of the following hold:
cs.currentTerm < req.term, andcs'.currentTerm = req.term;cs'has the last accepted state and the local node ofcs;cs'.startedJoinSinceLastReboot = trueandcs'.electionWon = false;- the join votes and the publish votes of
cs'areVoteCollection.empty; cs'.lastPublishedVersion = 0andcs'.lastPublishedConfiguration = cs.lastAcceptedConfiguration;jis the join fromcs.localNodetoreq.sourceNodein termreq.term, carryingcs.lastAcceptedTermandcs.lastAcceptedVersionOrMetadataVersion(the last accepted state's version, or its metadata version if its term is 0).
The conditions on cs' fix all nine of its fields, so the result of a successful call is determined; a request whose term is not above the current term is rejected.
import Definitions.Def_OpenSearchCoordination
theorem OpenSearchCoordination.handleStartJoin_spec {V : Type} (cs : CoordinationState V) (req : StartJoinRequest) (cs' : CoordinationState V)
(j : Join) :
cs.handleStartJoin req = .ok (cs', j) ↔
cs.currentTerm < req.term ∧ cs'.currentTerm = req.term ∧ cs'.lastAcceptedState = cs.lastAcceptedState ∧
cs'.localNode = cs.localNode ∧ cs'.startedJoinSinceLastReboot = true ∧ cs'.electionWon = false ∧
cs'.joinVotes = VoteCollection.empty ∧ cs'.publishVotes = VoteCollection.empty ∧
cs'.lastPublishedVersion = 0 ∧ cs'.lastPublishedConfiguration = cs.lastAcceptedConfiguration ∧
j = ⟨cs.localNode, req.sourceNode, req.term, cs.lastAcceptedTerm, cs.lastAcceptedVersionOrMetadataVersion⟩ := 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.handleStartJoin_spec
Notions used
Coordination states and cluster states. For a payload type , a coordination state has nine fields:
- : a node, made of an id in and a Boolean "eligible" flag
isClusterManagerNode; - ;
- : a cluster state;
- and : vote collections, which are lists of ids;
- and : Booleans;
- ;
- : a voting configuration.
A cluster state has:
- ;
- ;
- two voting configurations, and ;
- an optional natural ;
- two Booleans about the cluster UUID;
- a payload .
The file's accessors give these abbreviations:
- ;
- ;
- is the accepted state's if its term is , and its otherwise (
lastAcceptedVersionOrMetadataVersion).
is the empty list.
Messages. A start-join request has a node and a term . A join is a 5-tuple of two nodes, two naturals and an integer.
The handler :
- If , it returns .
- Otherwise it returns , where:
- is with , , , , , and ;
- .
1. Declaration
Binders.
- : a type (implicit);
- : a coordination state over ;
- (
req): a start-join request; - : a coordination state over ;
- : a join.
Hypotheses. None.
Conclusion. The statement is a biconditional:
where:
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- .
Conjuncts 2–10 fix all nine fields of , and conjunct 11 fixes . So the right-hand side says exactly that the guard holds and that is the handler's output.
The biconditional therefore characterizes the handler completely:
- It succeeds iff , and its output is then the one listed.
- When the result is not of anything, so it is an .
2. What is not constrained
- is arbitrary. No invariant is assumed. In particular, is not required.
- is arbitrary. It may be the local node itself, and it may be ineligible. It appears only as the target of the returned join.
- The old , , and are discarded whatever their values.
- The join's version field is : the metadata version when the accepted state's term is , otherwise the cluster-state version.
- There are no hypotheses, so nothing can make the statement vacuous. Both sides of the biconditional are satisfiable.
3. Plain-language summary
A start-join request succeeds exactly when its term is larger than the node's current term. The node then:
- adopts that term;
- keeps its accepted state and identity;
- resets its election and publication bookkeeping: votes emptied, election not won, published version , published configuration set to the accepted configuration;
- records that it has started a join since restart.
It returns a join vote from itself to the requester, carrying the new term and its last accepted term and version (the metadata version for term-0 states).
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.