A node answers a pre-vote request exactly when it is healthy and follows no other leader
ProvedOpenSearchPreVote.handlePreVoteRequest_specFor every health status healthy, collector state st, request req and response resp: handlePreVoteRequest healthy st req = .ok resp iff healthy = true, the node knows no leader or knows the requester as its leader (st.leader = none ∨ st.leader = some req.sourceNode), and resp = st.response, the node's own current response. Unhealthy nodes and nodes that follow a leader other than the requester refuse.
import Definitions.Def_OpenSearchPreVote open OpenSearchCoordination OpenSearchPreVote
theorem OpenSearchPreVote.handlePreVoteRequest_spec (healthy : Bool) (st : CollectorState) (req : PreVoteRequest)
(resp : PreVoteResponse) :
handlePreVoteRequest healthy st req = .ok resp ↔
healthy = true ∧ (st.leader = none ∨ st.leader = some req.sourceNode) ∧ resp = st.response := 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: OpenSearchPreVote.handlePreVoteRequest_spec
Notions used
Discovery nodes. A discovery node is a pair (node id , Boolean "cluster-manager-eligible" flag). Two discovery nodes are equal iff both components are equal.
Messages and collector state.
- A pre-vote request has a source node and a term .
- A pre-vote response is a triple .
- A collector state has a known leader ("none", or "some " for a discovery node ) and a stored response .
The handler. returns either an error string or a response:
- If is false: the error "rejecting on unhealthy node".
- Otherwise, if : success with .
- Otherwise, if with : success with .
- Otherwise: the error "rejecting as there is already a leader".
1. Declaration
Binders. There are no hypotheses.
- : a Boolean;
- : a collector state;
- : a pre-vote request;
- : a pre-vote response.
Conclusion.
In words, the handler returns success with exactly when three things hold:
- the node is healthy;
- the node knows no leader, or the leader it knows is exactly the requesting node (same id and same flag);
- is the node's stored response.
2. What is not constrained
- The request's term. does not occur on the right-hand side. The handler never reads it.
- Leader equality. It is structural on (id, flag). A known leader with the requester's id but the opposite flag counts as "another leader", and the request is refused.
- Errors. The theorem says nothing about the error messages and does not separate the two refusal reasons. The handler always returns either success or an error. So for given , the theorem also implies: the handler is an error iff the first two conjuncts fail. When it succeeds, the value is exactly .
- Side effects. The Java handler's side effect (raising
maxTermSeento the request's term) is not modelled by the function, so the theorem does not mention it. - Vacuity. There are no hypotheses, so nothing can be vacuous. Both sides are satisfiable; for example, take , and .
3. Plain-language summary
A node grants a pre-vote request if and only if it is healthy and either knows no leader or its known leader is the requester itself. When it grants, it returns its stored response unchanged. The term carried by the request plays no role in the decision.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.