# Restarted voters: what must survive the reply?

This is a constructed vote-memory example, not an implementation or measurement
of a deployed consensus service. Start with the
[Raft definition](https://hesela.dev/terms/raft/).

## The finite schedule

There are three voters, A, B and C. All logs are empty and equally up to date.
A and C begin candidacy in term 1 and each votes for itself. Deliver A's vote
request to B first; delay C's request. B grants A a vote and replies. Restart B
before delivering C's request. No message is forged and no membership changes.

The counterexample intentionally removes a required persistence action. It is
not an allowed execution of correctly persisted Raft. Raft Figure 2 specifies
persistent term/vote state before RPC replies, and section 5.2 supplies the
one-vote and intersecting-majority argument.
[Ongaro and Ousterhout, 2014](https://raft.github.io/raft.pdf)

| B's write schedule | B grants C after restart | A's voters | C's voters |
| --- | --- | --- | --- |
| No durable vote | Yes | A, B | B, C |
| Persist before replying to A | No | A, B | C |
| Reply, then crash before the planned write | Yes | A, B | B, C |
| Reply, complete the write, then crash | No | A, B | C |

The first and third rows exhibit two distinct majority certificates for one
term. The overlap is the same B identity; forgetting its earlier answer defeats
the protection that intersection was meant to provide. The final row is a
control, not an endorsement of replying before persistence: another crash
position still breaks that schedule.

## Reproduce and inspect

Use Node.js with its built-in test runner; no third-party package is required.

```sh
node model.mjs --check
node --test model.test.mjs
```

[Model](./model.mjs), [tests](./model.test.mjs), [generated traces](./results.json).

The model writes no real disk and starts no real process. A modeled persist
copies the entire term/vote pair atomically to protected state; a crash discards
volatile state and an unsent response. Recovery restores the protected pair.
Receive, persist, reply, crash and recovery are distinct transitions. Tests cover
crash positions around a reply, repeated restarts, lower terms, repeated
requests and input errors.

This isolates election voting, not log replication, commitment, timers, client
deduplication, dynamic membership, torn writes or storage-device guarantees.
Two certificates here do not demonstrate two conflicting committed commands.
The model does not implement the algorithms or prove the lower bounds of
Aguilera, Chen and Toueg.

## Provenance

Hesela's original pedagogical schedule and implementation, generated 2026-11-20.
See results.json for explicit inputs, event traces and outputs. The companion
definition cites the formal failure model separately from the Raft mechanism.
No third-party PDF, figure or dataset is redistributed.
