Skip to content
Back to the work
Public repo

quorum

Raft consensus written from scratch, behind a linearizable key-value store.

PythongRPCDockerpytestmypy --strict

Problem

Consensus is the piece most teams import rather than understand, and its failure modes only show up under partition, reorder and crash. Testing it is the harder half: a real cluster is slow, non-deterministic, and rarely reproduces the bug being chased.

Approach

The Raft core is written as a pure function. It never reads a clock, opens a socket or touches disk; it takes a message and the current time and returns new state plus outgoing messages, and a test enforces that purity. Every bit of I/O lives in a separate driver, which is what lets an entire cluster run inside one process under a seeded scheduler that can delay, drop, reorder and partition at will.

Outcome

147 tests run a real cluster in-process in about 25 seconds, asserting all four safety properties continuously. A Jepsen-style linearizability checker replays roughly 22,000 operations across chaos scenarios with zero violations, and all four negative controls are flagged as expected. Re-election settles at p50 235ms and p95 430ms against a 150 to 300ms election timeout.