feat(raft-library): task 3.3 — raft_on_vote_request 6-step decision; 10 tests

This commit is contained in:
Rongsong Shen 2026-05-31 05:44:34 +00:00
parent 4955fa3805
commit e0bcb35554
3 changed files with 497 additions and 15 deletions

View file

@ -40,7 +40,7 @@
- Fires `on_trace` events: `election_start`, `self_vote`, `term_update` if NULL-safe checks pass
- _Requirements: 2.1, 2.2, 2.3, 6.1_
- [ ] 3.3 Implement raft_on_vote_request (incoming RequestVote processing)
- [x] 3.3 Implement raft_on_vote_request (incoming RequestVote processing)
- Stale term: `term < current_term` → set `*reply_term`, fire `on_trace(vote_denied_stale_term)`, return `RAFT_DENY`
- Term upgrade: `term > current_term` → update `current_term=term`, clear `voted_for=-1`, set `role=RAFT_FOLLOWER`, fire `on_trace(term_update)`
- Role gate: if `role == RAFT_LEADER` → return `RAFT_DENY` (fire `on_trace(vote_denied_role)`); note: COMMITTING state is delegated to `on_vote_eligible` in the adapter