handlePublishRequest accepts only a strictly newer state of the current term, Zen1 compatibility aside
ProvedOpenSearchCoordination.handlePublishRequest_specLet cs be a coordination state with cs.lastAcceptedTerm ≤ cs.currentTerm, and suppose cs.handlePublishRequest req = .ok (cs', resp). Then:
cs'.lastAcceptedState = req.acceptedStateandreq.acceptedState.term = cs.currentTerm;cs'has the current term and the local node ofcs;respcarries the term and the version ofreq.acceptedState;- the accepted state is strictly newer than the old one in the lexicographic (term, version) order —
cs.lastAcceptedTerm < req.acceptedState.term, or the terms are equal andcs.lastAcceptedVersion < req.acceptedState.version— or its term isZEN1_BWC_TERM(0), about which nothing more is stated: this disjunct holds for every term-0 state (the handler accepts a term-0 state that is not newer only in its Zen1 compatibility branch, when that state names a cluster-manager and the last accepted state names none or a different one; the statement does not record this condition); - the join votes,
electionWon,startedJoinSinceLastReboot,lastPublishedVersion,lastPublishedConfigurationand the publish votes are those ofcs.
The hypothesis on cs is the first assertion of invariant(); without it, a node whose accepted term exceeds its current term would accept a state of a lower term.
import Definitions.Def_OpenSearchCoordination
theorem OpenSearchCoordination.handlePublishRequest_spec {V : Type} (cs : CoordinationState V) (req : PublishRequest V) (cs' : CoordinationState V)
(resp : PublishResponse) (hcs : cs.lastAcceptedTerm ≤ cs.currentTerm)
(h : cs.handlePublishRequest req = .ok (cs', resp)) :
cs'.lastAcceptedState = req.acceptedState ∧ req.acceptedState.term = cs.currentTerm ∧
cs'.currentTerm = cs.currentTerm ∧ cs'.localNode = cs.localNode ∧
resp = ⟨req.acceptedState.term, req.acceptedState.version⟩ ∧
(cs.lastAcceptedTerm < req.acceptedState.term ∨
(cs.lastAcceptedTerm = req.acceptedState.term ∧ cs.lastAcceptedVersion < req.acceptedState.version) ∨
req.acceptedState.term = ZEN1_BWC_TERM) ∧
cs'.joinVotes = cs.joinVotes ∧ cs'.electionWon = cs.electionWon ∧
cs'.startedJoinSinceLastReboot = cs.startedJoinSinceLastReboot ∧
cs'.lastPublishedVersion = cs.lastPublishedVersion ∧
cs'.lastPublishedConfiguration = cs.lastPublishedConfiguration ∧ cs'.publishVotes = cs.publishVotes := 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.handlePublishRequest_spec
Notions used
Coordination states and cluster states. For a payload type , a coordination state has nine fields:
- : a node;
- ;
- : a cluster state;
- and : vote collections;
- and : Booleans;
- ;
- : a voting configuration.
A cluster state has nine independent fields:
- ;
- and ;
- two voting configurations, and ;
- , an optional natural (an ephemeral id);
- two Booleans about the cluster UUID;
- a payload .
Abbreviations:
- (
lastAcceptedTerm); - (
lastAcceptedVersion).
.
Messages. A publish request carries one cluster state . A publish response is a pair .
The handler , with . Let . The handler proceeds as follows:
- If , it returns .
- Else, if and :
- if :
- if , it returns ;
- if , it returns when , and otherwise;
- otherwise, it returns .
- if :
- Else, it returns .
1. Declaration
Binders.
- (implicit);
- : a coordination state;
- (
req): a publish request; - : a coordination state;
- : a publish response.
Write .
Hypotheses, in order.
- : ;
- : .
Conclusion. The conjunction of:
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- ;
- .
Conjuncts 1, 3, 4 and 7–12 fix all nine fields of : the accepted state is replaced by and nothing else changes. Conjunct 5 fixes the response.
2. What is not constrained
- Only one direction. The statement is an implication from success. It does not say that requests satisfying conjuncts 2 and 6 are accepted.
- Conjunct 6 is weaker than the handler's real acceptance condition. Its third alternative, , holds for every term-0 request. So for term-0 requests conjunct 6 constrains nothing.
- It omits the Zen1-branch condition: an incoming cluster manager that differs from the stored one.
- It allows a term-0 state with a version lower than or equal to the current one.
- The role of . is what makes conjunct 6 hold.
- Without it, a state with would accept a request with and . That request satisfies none of the three alternatives.
- Given and conjunct 2, the first alternative is equivalent to .
- is satisfiable, so the statement is not vacuous. For example, any state with accepts any with .
- The rest of is unconstrained. Its configurations (including the committed one), , , UUID flags and payload are free. Accepting a publish may therefore replace the configurations arbitrarily.
- is carried over unchanged (conjunct 8). The election-quorum test depends on the accepted state's configurations, version and term, so the stored flag may stop matching that test. See
javaInvariant_not_local. - 's other fields are unconstrained. Only is assumed.
3. Plain-language summary
Suppose a node whose last-accepted term does not exceed its current term accepts a publish request. Then:
- the published state is in the node's current term and becomes its new last-accepted state;
- nothing else in the node changes;
- the response echoes that state's term and version;
- the accepted state is strictly newer than the old one in (term, version) order, except when its term is (Zen1 compatibility), where nothing is claimed.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.