Inspiration

Distributed-systems bugs hide in rare orderings: a pause here, a lost message there. You see one once in production and never again, and the logs show what went wrong but not the interleaving that caused it. FoundationDB and TigerBeetle showed that deterministic simulation makes those bugs reproducible, but their simulators are built into one database. I wanted a small, general skeleton that anyone can read, run in a browser and learn from.

What it does

Evocation is a lean Rust framework for deterministic simulation testing.

  • Write a node with no I/O. Each server is a plain state machine that reacts to messages, timers and client requests, and acts only through a context: send, set a timer, write to disk. No sockets, no threads, no clock.
  • One process, virtual time, one seed. Evocation runs the whole cluster in one process. The simulated network drops, duplicates, delays and partitions messages; the simulated disk loses unsynced writes or tears them; nodes crash, pause and have skewed clocks. Every one of those choices comes from the seed, so the same seed and build give a byte-identical trace and every failure replays exactly.
  • Check and shrink. Invariants run after every event, and a linearizability checker judges the clients' history. A failing scenario shrinks to the few faults that still break it: seed 453 goes from 12 faults to a single pause.
  • Skeleton Crew: one core, two very different apps.
    • A distributed lock service with fencing tokens. buggy lets a holder paused past its lease write after a newer holder; fenced rejects it.
    • A Raft key-value store (get, put, cas) with the four Raft safety invariants and six broken variants beside the correct one: stale reads, amnesia, lying fsync, rollback, lease reads, and Figure 8 of the Raft paper.
  • Everywhere you look at a bug:
    • a CLI (hunt, shrink, replay, run) and a terminal viewer that steps through any run and jumps to the violation;
    • a WebAssembly playground that needs no server: cluster view and playback, guided tours of each bug story, side by side of two variants with the first difference marked, fault editing, shareable links;
    • a hunt farm on a $4 droplet that hunts around the clock and publishes its finds live to the playground. It found 6 of the 7 bug variants on its own in about 49,000 seeds each;
    • the same node code on a real cluster: one OS process per node, real TCP, real fsync, and real faults (SIGSTOP, SIGKILL, iptables partitions, tc netem). The buggy lock produced a real stale write on the droplet, and Raft stayed linearizable through a full minute of every fault.
  • An MCP server, so an agent can hunt, shrink and explain bugs itself.

How we built it

Evocation was built spec-first with Kiro.

  • Specs: .kiro/specs/evocation/ holds the requirements, the design (28 sections, each with its decisions, limits and measured results) and the tasks. Every milestone was one prompt naming its requirement and design sections, one branch and one pull request, merged only after review and ./check.sh.
  • Steering: determinism.md is always included. It states the core promise (same scenario plus same build gives a byte-identical trace) and the rules that keep it: no wall clock, no ambient randomness, no HashMap, no floats in decisions, and a build for wasm32. Every PR compared up to 3,636 runs with main, byte for byte. workflow.md holds the branch and PR rules and a "Stories" rule: every bug story is checked against the exact trace it describes. That rule was added after a real mistake.
  • Hooks: five in .kiro/hooks/: core tests on save, a determinism guard, a spec consistency check, a story checker for scenario files, and a pre-PR hook that blocks gh pr create when checks fail.
  • Property-based testing (proptest) for the simulator's core guarantees: queue order, crash recovery, same seed same trace, shrinking that never grows.
  • MCP: through Evocation's own MCP server, Kiro hunted, shrank and explained a Raft amnesia bug. The session is written up in KIRO.md.
  • Pushback before code: when a prompt was wrong (a random-stream key already in use, an impossible pass rule, an unreachable target), Kiro said so and asked before writing code.

Honesty note: the first core commits (M0 and M1) and two pieces of spec text were written with Claude Code, which also reviewed each PR and wrote the prompts. Kiro implemented every PR's code. Details are in KIRO.md.

Stack: Rust for the core, the apps, the CLI and the real-cluster driver; WebAssembly and plain HTML, CSS and JavaScript for the playground; GitHub Actions and GitHub Pages; a DigitalOcean droplet with systemd for the farm and the real cluster.

Challenges we ran into

  • Keeping determinism across every PR, including WebAssembly in the browser. Every change was checked against thousands of runs, and the CLI and the browser build must agree on every trace hash.
  • Bugs too rare for random search. Figure 8 and lease reads never fail in 10,000 random seeds. They became hand-built scenarios that fail every time, with stories checked event by event.
  • A real cluster on a 512 MB droplet. The first 60-second Raft run was killed for memory because the driver kept every event. Streaming events to a file took the peak to 21 MB.

Accomplishments that we're proud of

  • A real stale write reproduced on real processes, from the same node code the simulator checks.
  • A live playground that needs no server, fed by a farm that keeps hunting.
  • Every failure replays exactly, from a seed or a small JSON file, in the CLI, the terminal and the browser.

What we learned

How consensus and fencing actually fail, and that determinism is a discipline enforced by tests and steering, not a property you get once.

What's next for Evocation

Evocation as a library (evocation-test), fault points (buggify), more checkers, smarter search, a GitHub Action, nodes in other languages, and real-cluster runs published to the playground.

Built With

Share this project:

Updates

Submission history