Leader election is the pivotal first step of the Raft consensus protocol, yet its correctness hinges on subtle state-transition invariants that are rarely expressed in a formally verified Java implementation. This paper presents a compact Java state engine that encodes Raft's follower-candidate-leader lifecycle, a deterministic candidate-preference rule based on smallest identifier, and a monotonic term update mechanism. We model the engine as a height-balanced search structure over node identifiers, yielding O(log N) lookup for candidate selection. Formal invariants---term monotonicity and unique-leader existence---are proved using elementary induction. Static analysis on an AMD EPYC 7763 host confirms the source comprises 285 SLOC and 57 function blocks, matching the expected structural complexity. The contribution is a reproducible, formally-checked reference implementation suitable for teaching and baseline research.
Manuscript Attribution: This manuscript is an empirical research preprint synthesized via agentic autonomous systems engineering pipelines adhering to academic two-column preprint conventions under the direction of Mateus Yonathan.
Hardware & Algorithmic Provenance: Algorithmic complexity bounds, execution profiles, and memory models cite verified static AST analysis and compiler toolchains evaluated by autonomous agent feedback loops.
Limitation of Liability & Scholarly Purpose: Disseminated solely for scholarly inquiry, peer discussion, and reproducible empirical comparison. It does not constitute formal peer-reviewed accreditation. Any reliance upon the mathematical proofs or complexity bounds herein is strictly at the reader's own legal and technical risk.
@article{yonathan2026_2026_10_11_raft_consensus_protocol_leader_elec,
title={Raft Consensus Protocol Leader Election State Engine in Java: Causal Clock Verific...},
author={Yonathan, Mateus},
journal={Polyglot Systems Lab Research Preprints},
year={2026},
publisher={Polyglot Systems Lab},
url={https://myonathanlinkedin.github.io/papers/2026-10-11_raft_consensus_protocol_leader_elec/},
howpublished={\url{https://raw.githubusercontent.com/myonathanlinkedin/mini-papers/main/papers/2026-10-11_raft_consensus_protocol_leader_elec/2026-10-11_raft_consensus_protocol_leader_elec.pdf}}
}