handlePublishResponse commits only on a publish quorum of both configurations
ProvedOpenSearchCoordination.handlePublishResponse_specFor every coordination state cs, node src, publish response r, state cs' and optional commit o: if cs.handlePublishResponse src r = .ok (cs', o) then
cs.electionWon = true,r.term = cs.currentTermandr.version = cs.lastPublishedVersion;cs'iscswith publish votes(cs.publishVotes.addVote src).1;- if
o = some c, thencis the commit⟨cs.localNode, cs.currentTerm, cs.lastPublishedVersion⟩(sent by this node, for its current term and the version being published), and the new publish votes are a quorum ofcs.lastCommittedConfigurationand ofcs.lastPublishedConfiguration, the configuration being published.
The statement says when a commit can be emitted; it is one-directional: it does not say that a commit is emitted whenever the new votes are a publish quorum, and it says nothing when o = none.
import Definitions.Def_OpenSearchCoordination
theorem OpenSearchCoordination.handlePublishResponse_spec {V : Type} (cs : CoordinationState V) (src : DiscoveryNode) (r : PublishResponse)
(cs' : CoordinationState V) (o : Option ApplyCommitRequest) (h : cs.handlePublishResponse src r = .ok (cs', o)) :
cs.electionWon = true ∧ r.term = cs.currentTerm ∧ r.version = cs.lastPublishedVersion ∧
cs' = { cs with publishVotes := (cs.publishVotes.addVote src).1 } ∧
(∀ c, o = some c →
c = ⟨cs.localNode, cs.currentTerm, cs.lastPublishedVersion⟩ ∧
cs'.publishVotes.isQuorum cs.lastCommittedConfiguration = true ∧
cs'.publishVotes.isQuorum cs.lastPublishedConfiguration = true) := 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.handlePublishResponse_spec
Notions used
Coordination states. A coordination state has nine fields:
- , a node with an id and an eligibility flag;
- ;
- ;
- and , vote collections (lists of ids);
- and , Booleans;
- ;
- .
is the last committed configuration of .
Votes and quorums.
- holds iff strictly more than half of the ids of configuration occur in .
- returns if is eligible and , and otherwise.
- .
Messages.
- A publish response has and .
- A commit request is a triple .
The handler tests three guards in order. The first one that holds yields :
- ;
- ;
- .
Otherwise, let and with . The result is:
- if ;
- otherwise.
1. Declaration
Binders.
- (implicit);
- : a coordination state;
- (
src): a node; - : a publish response;
- : a coordination state;
- : an optional commit request.
Hypothesis. : .
Conclusion. The conjunction of:
- ;
- ;
- ;
- with ;
- the following three facts hold:
- ;
- ;
- .
Conjuncts 1–3 are the negations of the guards. Conjunct 4 determines completely. Conjunct 5 constrains the returned commit request, if there is one: its term and version equal the node's current term and last published version, and the updated publish votes form a quorum of both the committed and the last published configuration (not the accepted one).
2. What is not constrained
- When , nothing is claimed. The theorem does not say that "none" means the votes fail to be a publish quorum. Equally, it does not say that a commit request is returned whenever a quorum is reached, although by definition the handler is deterministic and does return one.
- is arbitrary. If is ineligible or already counted, the votes are unchanged. If a quorum already holds, a commit request is returned again; the statement permits this.
- The commit's source node is the local node. The responding node does not appear in the returned request.
- No assumption on beyond success, and no invariant.
- Not vacuous. The success hypothesis is satisfiable, for example by a node that has won the election and receives a response matching its current term and published version.
3. Plain-language summary
A node processes a publish response only if:
- it has won the election;
- the response's term equals its current term;
- the response's version equals its last published version.
The only state change is adding the responder (if eligible) to the publish votes. If a commit request is returned, it comes from the local node for the current term and the last published version, and the updated publish votes form a quorum of both the last committed and the last published configurations.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.