handleClientValue publishes only as an elected node, in its term, above the last version, reconfiguring only safely
ProvedOpenSearchCoordination.handleClientValue_specFor every coordination state cs, cluster state s, state cs' and publish request p: if cs.handleClientValue s = .ok (cs', p) then
cs.electionWon = true;cs.lastPublishedVersion = cs.lastAcceptedVersion: the node has accepted its own last publication;s.term = cs.currentTermandcs.lastAcceptedVersion < s.version(so the new version is above the last published one);skeeps the node's last accepted configuration (s.lastAcceptedConfiguration = cs.lastAcceptedConfiguration), or no reconfiguration is pending (cs.lastCommittedConfiguration = cs.lastAcceptedConfiguration);- the node's join votes are a quorum of the new accepted configuration:
cs.joinVotes.isQuorum s.lastAcceptedConfiguration = true; pis the publish request ofs, andcs'iscswithlastPublishedVersion := s.version,lastPublishedConfiguration := s.lastAcceptedConfigurationand empty publish votes.
The asserted precondition that s keeps the node's last committed configuration (clientValueContract, CoordinationState.java:397-398) is a caller contract and is not part of the statement.
import Definitions.Def_OpenSearchCoordination
theorem OpenSearchCoordination.handleClientValue_spec {V : Type} (cs : CoordinationState V) (s : ClusterState V) (cs' : CoordinationState V)
(p : PublishRequest V) (h : cs.handleClientValue s = .ok (cs', p)) :
cs.electionWon = true ∧ cs.lastPublishedVersion = cs.lastAcceptedVersion ∧ s.term = cs.currentTerm ∧
cs.lastAcceptedVersion < s.version ∧
(s.lastAcceptedConfiguration = cs.lastAcceptedConfiguration ∨
cs.lastCommittedConfiguration = cs.lastAcceptedConfiguration) ∧
cs.joinVotes.isQuorum s.lastAcceptedConfiguration = true ∧
p = ⟨s⟩ ∧ cs' = { cs with lastPublishedVersion := s.version,
lastPublishedConfiguration := s.lastAcceptedConfiguration,
publishVotes := VoteCollection.empty } := 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.handleClientValue_spec
Notions used
Coordination states and cluster states. For a payload type , a coordination state has nine fields:
- ;
- ;
- , a cluster state;
- and , vote collections (lists of ids);
- and , Booleans;
- ;
- .
A cluster state has nine independent fields:
- ;
- ;
- two voting configurations, and ;
- an optional cluster-manager id;
- two Booleans about the cluster UUID;
- a payload.
Abbreviations, all read from the accepted state:
- ;
- is the last committed configuration;
- is the last accepted configuration.
Configurations and votes.
- Voting configurations are strictly increasing lists of ids. Two configurations are equal iff they denote the same set.
- holds iff .
- is the empty list.
A publish request is a wrapper around one cluster state.
The handler tests six guards in order. The first one that holds yields :
- ;
- ;
- ;
- ;
- ;
- .
If no guard holds, the result is
1. Declaration
Binders.
- (implicit);
- : a coordination state;
- (
s): a cluster state; - : a coordination state;
- : a publish request.
Hypothesis. : .
Conclusion. The conjunction of:
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- with , and .
Conjuncts 1–6 are the negations of the six guards. Conjunct 4 is stated against rather than ; given conjunct 2 the two are equivalent. Conjunct 5 means: either the value keeps the accepted configuration, or no reconfiguration is pending. Conjuncts 7 and 8 determine the output completely.
2. What is not constrained
- The committed configuration of is free. appears in neither the hypotheses nor the conclusion. The handler does not check it. Java's assertion that it equals is the separate predicate
clientValueContract, which is not used here. So the statement allows publishing a value whose committed configuration differs from the node's. - Other fields of are free: , the cluster-manager id, the UUID flags and the payload.
- The configuration test is set equality. "Equal" in conjunct 5 compares sets, because configurations are stored sorted.
- No hypothesis on beyond success, and no invariant.
- Only one direction. The statement goes from success to the conjuncts. It does not claim that a value meeting 1–6 is accepted, although by definition it is.
- Not vacuous. For example, a winner with matching versions, given a value of the current term with a higher version and the same accepted configuration, satisfies the hypothesis whenever its join votes are a quorum of that configuration.
3. Plain-language summary
A node accepts a new cluster state for publication only if all of the following hold:
- it has won the election;
- its previous publication has been accepted locally (published version equals accepted version);
- the new state is in the current term with a strictly higher version;
- it does not start a reconfiguration while one is pending;
- its join votes form a quorum of the new state's accepted configuration.
The result is a publish request carrying the state unchanged. The node records the new published version and configuration and clears its publish votes.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.