Skip to main content

simraft-kv

Sans-I/O Raft consensus engine, deterministic chaos simulator, and linearizable key-value store in Rust.

simraft-kv separates consensus logic from all network, disk, and clock I/O. One pure state machine (Node::step) and one checksummed wire codec ("SRKV") power both a single-seed deterministic chaos simulator and a multi-process TCP and file-backed key-value server.

Docs · Architecture · Invariants · Security · Releases

CI on main crates.io version PyPI version docs.rs MSRV 1.88 MIT or Apache-2.0 license

A two-part view with live five-node cluster topology and safety oracle status above and real simraft-sim and simraft-node terminal runs below, sweeping 25 chaos seeds, replaying seed 912 deterministically, running the sans-I/O embed example, and executing linearizable TCP writes and reads

Every terminal line above comes from real runs of simraft-sim, the embed example, and simraft-node.

Why simraft-kv

Distributed consensus bugs hide in rare interleavings of asymmetric partitions, crash recoveries with unpersisted tails, stale durability acknowledgments after log truncation, and corrupted wire frames. Testing Raft only over live sockets makes those interleavings slow to trigger and nearly impossible to replay. simraft-kv makes every transition a pure function of explicit events so thousands of hostile cluster histories can be explored and replayed byte for byte from a single 64-bit integer.

  • Pure sans-I/O consensus core. simraft-core has zero external dependencies, reads no ambient clock or randomness, and emits explicit Action values (Send, PersistHardState, PersistEntries, Apply, ReadReady, ClientResponse, PersistSnapshot, LoadSnapshot) in deterministic order.
  • Complete operational Raft protocol. Implements Pre-Vote elections with leader recency denial (T-03..T-05), Figure 8 commitment (S-06), term-boundary conflict fast backup (S-08), clock-free ReadIndex quorum reads (R-01..R-04), chunked InstallSnapshot transfer (N-01..N-08), and single-server voter and learner membership changes (M-01..M-05).
  • Durability-gated transitions. Votes, append acknowledgments, snapshot responses, single-voter commits, and ReadIndex releases wait until required HardState and log watermarks reach durable storage, clamping watermarks and fencing stale acks across log truncations (T-02, R-06).
  • Per-event safety oracles and Wing and Gong linearizability. simraft-sim checks Election Safety, Leader Append-Only, Log Matching, Leader Completeness, and State Machine Safety after every simulator event, verifies completed client histories with a per-key Wing and Gong linearizability checker, and enforces post-heal leader and state digest convergence (H-02).
  • Shared wire codec across simulator and TCP. simraft-wire frames every peer and client message with "SRKV" magic, 16 MiB defensive bounds, trailing-byte rejection, and IEEE CRC-32 checksums, exercised identically under simulated bit-flips and live sockets.

Four measured and verified simraft-kv metrics showing 1.50 microsecond three-node commit rounds, 0 Tick and 4 single-entry AppendEntries allocations, 100,000 weekly chaos seeds, and S-01 through S-05 safety plus Wing and Gong linearizability checks

How it works

Tick, SRKV peer frames, persist watermarks, and client requests enter the pure sans-I/O simraft-core and simraft-kv state machines over the shared simraft-wire codec, driving both the deterministic simraft-sim chaos harness and the durable TCP simraft-node server

Crate Kind External runtime deps Role
simraft-core library none (std only) Pure sans-I/O Raft state machine (Node::step), Pre-Vote elections, fast log backup, Figure 8 commitment, ReadIndex, chunked snapshots, and single-server membership changes.
simraft-wire library crc32fast Canonical "SRKV" message frame, log entry, and cluster config codec with 16 MiB frame bounds and IEEE CRC-32 checksums.
simraft-kv library none (std only) Deterministic BTreeMap key-value state machine, bounded client session deduplication, and SHA-256 verified snapshot payloads.
simraft-node library and binary clap, crc32fast File-backed durable store, TCP peer transport, serve daemon, and linearizable client CLI (put, get, delete).
simraft-sim library and binary clap, crc32fast, sha2 Single-threaded deterministic simulator, seeded --chaos fault injector, per-event safety oracles, and Wing and Gong linearizability checker.

Quickstart

Install the server and simulator binaries from crates.io, via cargo-binstall and GitHub Releases, or install the simulator CLI, linearizable TCP client, and typed Python SDK from PyPI.

cargo install simraft-node simraft-sim
# or install simraft-sim and the Python SDK from PyPI
pip install simraft-kv
import simraft_kv

sweep = simraft_kv.simulate(seed=912, seeds=5, chaos=True)
assert sweep.all_passed

# Connect directly to a live simraft-node TCP cluster (follows leader redirects
# and preserves (client_id, seq) session deduplication across retries)
client = simraft_kv.SimRaftClient(
    ["127.0.0.1:7001", "127.0.0.1:7002", "127.0.0.1:7003"]
)
client.put("greeting", "hello")
assert client.get_text("greeting") == "hello"
client.delete("greeting")

Run a deterministic chaos sweep and replay a single seed

Sweep 25 seeds across asymmetric partitions, crashes, clock jumps, and wire bit-flip corruption, then replay seed 912 deterministically.

simraft-sim --seed 0 --seeds 25 --chaos
simraft-sim --seed 912 --seeds 1 --chaos --json
{"seed":912,"completed":true,"converged":true,"leader_converged":true,"ticks":9292,"verdict":"linearizable","digest":"c8a282578b8f0c97569595cff000063cfa6dfd8f23fc41c6be10f4994bde7095","passed":true}

Run a three-node localhost TCP cluster

Start three simraft-node servers in separate terminals.

simraft-node serve --id 1 --data-dir /tmp/srkv-1 \
  --member 1@127.0.0.1:7001 --member 2@127.0.0.1:7002 --member 3@127.0.0.1:7003

simraft-node serve --id 2 --data-dir /tmp/srkv-2 \
  --member 1@127.0.0.1:7001 --member 2@127.0.0.1:7002 --member 3@127.0.0.1:7003

simraft-node serve --id 3 --data-dir /tmp/srkv-3 \
  --member 1@127.0.0.1:7001 --member 2@127.0.0.1:7002 --member 3@127.0.0.1:7003

Write, read, and delete keys against any member. The client follows leader hints automatically and reads linearizably through ReadIndex.

simraft-node client --server 127.0.0.1:7001 put greeting hello
simraft-node client --server 127.0.0.1:7002 get greeting
simraft-node client --server 127.0.0.1:7003 delete greeting

put and delete print ok and exit 0. get writes raw value bytes to standard output and exits 0 when present, exits 1 with simraft-node: key not found on standard error when absent, and exits 2 on transport, timeout, or cluster errors.

Embed the sans-I/O core in Rust

Callers embedding simraft-core own sockets, storage, and timers while Node::step computes every state transition.

let actions = node.step(event);
for action in actions {
    // Send messages, persist durable state, apply committed entries,
    // or complete client proposals and reads in action order.
}

Run the self-contained single-file three-node embedding example.

cargo run -p simraft-core --example embed --locked

Benchmarks and verification

Measured with the Criterion benchmarks in this repository on hosted runners (2026-11-19 baseline plus v0.2.0 allocation gate).

Benchmark / Gate Workload Median / Bound Throughput / Budget
propose_commit_single Full propose and commit round on a 3-node cluster (32-byte entry) 1.50 us ~668,000 rounds/s
propose_commit_batch_32 Coalesced batch of 32 proposals released on one persist ack (B-02) 85.5 us ~374,000 entries/s
follower_append_entries Follower stepping one AppendEntries RPC 76 ns ~13.1M steps/s
follower_catchup_10k Empty follower catching up to a 10,000-entry leader log 4.06 ms ~2.46M entries/s
step_allocations (L-03) Thread-local heap allocations inside Node::step 0 (Tick), 2 (RequestVote), 4 (AppendEntries) Budgets 4, 4, 7
checker_scale (L-04) Wing and Gong per-key linearizability decision over 100,000 ops across 64 keys 100,000 states Memoized exact verdict

Run the full verification suite locally on Rust 1.88 or newer (CI pins 1.100.0 and checks MSRV 1.88.0 across Linux, macOS, and Windows, plus 1,000 chaos seeds on PRs, 10,000 on main, and 100,000 weekly).

cargo fmt --all -- --check
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
PROPTEST_CASES=500 cargo test --workspace --all-features --locked
RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --locked
cargo bench --workspace --locked -- --test

Documentation

If you want to... Read
Browse every document in the workspace Documentation index
Read the protocol state rules, "SRKV" byte tables, and digest domains Architecture · Decisions
Audit every safety, durability, liveness, and determinism invariant Invariants and traceability matrix
Explore individual workspace crates simraft-core · simraft-wire · simraft-kv · simraft-node · simraft-sim
Check defensive bounds, threat model, and release history Security policy · Roadmap · Changelog

Contributing

CONTRIBUTING.md covers local verification commands, replaying failing chaos seeds, invariant traceability rules, and public copy standards.

License

Licensed under either of MIT or Apache-2.0 at your option.

Metadata

Release files for simraft-kv 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simraft-kv 0.2.1
File Size Uploaded Provenance Actions
simraft_kv-0.2.1.tar.gz 159.5 kB With provenance Details for simraft_kv-0.2.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for simraft-kv 0.2.1
File Actions
simraft_kv-0.2.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for simraft_kv-0.2.1-py3-none-win_amd64.whl
simraft_kv-0.2.1-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for simraft_kv-0.2.1-py3-none-manylinux_2_28_x86_64.whl
simraft_kv-0.2.1-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for simraft_kv-0.2.1-py3-none-manylinux_2_28_aarch64.whl
simraft_kv-0.2.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for simraft_kv-0.2.1-py3-none-macosx_11_0_arm64.whl
simraft_kv-0.2.1-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for simraft_kv-0.2.1-py3-none-macosx_10_12_x86_64.whl

Total release size: 3.4 MB

Release files / simraft_kv-0.2.1.tar.gz

Download URL simraft_kv-0.2.1.tar.gz
Size 159.5 kB
Tags Source
SHA-256 checksum
How to use checksums
02ac9bc95b6433009fd6af08556aeb60b3a8288e5acbf2093feef57d9a9a9ae6
BLAKE2b-256 checksum
How to use checksums
a77e7a7aae9a7d79de469035e17e52ce7de777d3a84556d574778fe75078e94c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / simraft_kv-0.2.1-py3-none-win_amd64.whl

Download URL simraft_kv-0.2.1-py3-none-win_amd64.whl
Size 598.1 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
180666503e149a4bab0c03241be1772f29acd0b83b9859c71c291de352b40b80
BLAKE2b-256 checksum
How to use checksums
f3596584c523b5df163164a29f533a71e1ea7fcdf7794d2efa39abc0416bb6c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / simraft_kv-0.2.1-py3-none-manylinux_2_28_x86_64.whl

Download URL simraft_kv-0.2.1-py3-none-manylinux_2_28_x86_64.whl
Size 687.1 kB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
d978fa3c9c62927d77bb0966130defd9719712b779ee2dbbe47ef0ae178772ba
BLAKE2b-256 checksum
How to use checksums
106d4c259b1e5a3b984dabdc47a5660a0e46524c71f7a3bae2aeae97b1d67079
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / simraft_kv-0.2.1-py3-none-manylinux_2_28_aarch64.whl

Download URL simraft_kv-0.2.1-py3-none-manylinux_2_28_aarch64.whl
Size 640.2 kB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
5434c49156da9297df168074542bcde1af69323f323b6d650b0ac2d1546cf39d
BLAKE2b-256 checksum
How to use checksums
e3c24fb086391f739ad949d81af39bd56e9433192dc3cd2dbe77c00efd07a369
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / simraft_kv-0.2.1-py3-none-macosx_11_0_arm64.whl

Download URL simraft_kv-0.2.1-py3-none-macosx_11_0_arm64.whl
Size 594.8 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2f31e1671f6612ac3da7fbc73a67fa2f43d7bdde1e63b755d89a6ce74cf5798f
BLAKE2b-256 checksum
How to use checksums
1af466dd4e235aed8573bd3bb666ee4370e90ab6e26d058aefc98472d6491cde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / simraft_kv-0.2.1-py3-none-macosx_10_12_x86_64.whl

Download URL simraft_kv-0.2.1-py3-none-macosx_10_12_x86_64.whl
Size 673.9 kB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
563e631db1dfbeee601fc8486d10fd4fdff7a1bd21341668c999f97a0b368ed5
BLAKE2b-256 checksum
How to use checksums
a225c345949fb0c02ff499fe5a339eac85111cfe2c647d0ec73e3b772ddd77c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for simraft-kv 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for simraft_kv-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

6 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page