Almost two years ago, which in the age of AI is a long time, we set out to achieve what back then seemed to be an unachievable goal: to write our own deterministic hypervisor. Why? Well, maybe because that would make you a cool systems engineer. No, it was because, after working on designing memory chip testing solutions in the semiconductor industry and then on testing real-time operating systems, we knew that anything software can do still has its limits, but this was a clear path to get closer to hardware again. Nonetheless, the challenge was interesting, and the need for an affordable solution was clear.

That’s when TestFlows Machine was born, and now it runs real software, while we keep ironing it out to take on the industry-leading solutions head-on. But once you have a deterministic hypervisor in your hands, what do you do with it? This article is about what you do once a run can be recorded and replayed, and we’ll start with the spoiler: it enables deterministic simulation testing for applications running on x86_64 Linux, in an environment where you and your AI coding agent can go after both the bugs you can name and the ones you can’t.

And yes, it is a real machine. Ask its processor for its name with the CPUID instruction, and this is what it answers:

Processor brand string. Five constants spell TestFlows Machine v1, four characters at a time: Test, Flow, s Ma, chin, e v1.
The processor name a program in the machine reads. Each constant is four characters of TestFlows Machine v1.

Deterministic simulation testing

Machine runs a program, a Docker image, or a Docker Compose project unchanged. It records the run, and a replay then repeats that run exactly. A fork at any point of the run starts a new branch from there, while the run it was forked from stays as it was. Record, replay and branch are the three main operations Machine gives you. Note that we said record, not just run: recording a run again and getting the same run (repeatability) is a different property from replaying a recorded run, and we covered the difference in Is Execution Really Deterministic?. But putting this nuance aside, these three operations lay the foundation of deterministic simulation testing.

So what does that look like in practice? It depends, so let’s digress for a moment to see the big picture.

Every test is a walk through a state space

We can usually divide bugs into two broad categories: the known types of bugs we can think of, and the unknown unknowns. Of the two, the unknown unknowns are the hardest to find, and the classic technique to find them is fuzzing. But fuzzing is not magic.

If you think in basic formal terms, no matter what you do, you are taking a walk through a state space. A known type of bug just means there are some error states you suspect are there, and you try to see if they can be reached. The unknown unknowns are states in your state space that you had no idea were there, or where and how your software could reach them. And because real systems have enormous state spaces, it means that, for our systems, every state is just another potentially reachable state, and all of them are always there, even the bug states, whether we like it or not.

One analogy that we like to use: any picture that you take right now with your phone is not created at that moment. The sequence of bits that defines that image always existed, even before our time.

What makes any good fuzzing a challenging problem is that we can’t explore the state space exhaustively, so the best we can do is play tricks, where some work better than others for specific cases, but no general optimal solution exists. At least not yet. An exhaustive walk would be the simplest form of such exploration. A random walk would be another one, guided fuzzing a third, and so on.

But we will not go deep into fuzzing techniques here. The point is that no matter what testing you do, you are walking a path through a state space. That concept is universal. So if you start by applying a deterministic hypervisor to the known types of bugs, you are already halfway to developing your own fuzzing techniques and spending your time optimizing them to your liking.

Here is what it can look like, abstractly, with both kinds of walks in one state space:

Walking the state space A mesh of the states a program can reach, from a single start on the left. First, a path is forced straight to a bug named by reading the code. Then three other walks wander through the states. Two pass, and the third reaches a bug nobody named, an unknown unknown. Every path is recorded. start bug named in the code unknown unknown other walks
One path is forced to the bug named in the code. Other walks explore the rest, and one reaches a bug nobody named. Every path is a recorded run.

And what about the deterministic and the simulation parts? They become intuitive and obvious once the state space model above sinks in. Why? Because deterministic means that the same inputs always lead to the same outputs. In a state space, that means the next state depends only on the current state, and for that to be true of a real program, every input has to become part of the state: time, interrupts, random numbers, input from devices. And once the inputs are part of the state, you control them. Simulation means you can actuate those inputs to drive different conditions. So simulation is a natural ability that comes from controlling the inputs, and controlling the inputs comes from achieving determinism. All this just means that in your deterministic system, you can precisely define the state and explore it to your liking.

Of course, there are limits. A deterministic system is still just an approximation of the real-world non-deterministic systems where programs run, but using a deterministic hypervisor is as close as we know how to get to that approximation.

AI is the new kid on the block

AI coding agents now write production code, and they write and execute the tests for it too. In effect, that is another testing and fuzzing technique.

But we don’t see the modern approach as being just another powerful fuzzer that runs as a black box for hours and hands you a crash at the end. An agent can read the code, suspect a bug, and reason about which state it needs to reach, which is exactly the known type of bug from above. What it needs first and most importantly is an environment where it has precise control over execution. For example, hold a thread at the exact line, inject a fault at the exact moment, fork from any point, and replay any run as many times as it needs. With that, the same agent can test, verify a bug and its fix, and, once the bugs it can name are fixed, go looking for the unknown unknowns by guiding the walk itself, because fuzzing is just another way to walk the state space. And because every step is recorded, you can see what your agent did, replay it, and take over at any point.

And we believe this capability must be accessible to every developer and to every coding agent. That is why we provide Machine as a self-service product, with a free plan, and you can have your first run in about five minutes. The free plan gives a session up to 2 vCPUs and 4G of memory. When you want to run the bigger examples, such as Jepsen, just ping us at contact@testflows.com. To get running, you install the Machine skill for Claude Code, Codex or Cursor, and your agent drives the very same machine CLI that you can use, so there is no separate tool for the agent and no black box between you. And while smarter ways to guide the state space walk are what we keep working on, you can give the deterministic execution environment to your agent today.

However, there are limits to know about. A machine runs x86_64 Linux programs, Docker images and Docker Compose projects, in cloud sessions, and sessions run in our Europe region today. A recording replays on a CPU compatible with the one it was recorded on, as we explain in Is Execution Really Deterministic? And because a machine runs its vCPUs one at a time, the more vCPUs it has, the longer a run takes in real time, as we measured in How Many vCPUs Can You Run?

So when we say “you” in the examples below, we mean you and your agent. None of this has to be manual work: the agent can type every command, and you can read and repeat each one of them.

Now let’s quickly review what you can do today.

A bug you can see in the code

If the bug can be seen in the source, an agent is very good at seeing it. A good toy example is missed-wakeup.c, where the waiter unlocks a mutex, and the signaler can deliver its signal before the waiter starts waiting. On ordinary hardware, that window rarely lines up with the moment you are looking, so the failure shows up only once in a while, and almost never when you need it. Instead, the agent reads the code and quickly names that window as the suspect race. Then it confirms it: in a machine, it holds the waiter in the window, lets the signaler run through the signal, and the waiter times out on the very first try. Then it applies its fix, builds the fixed program into a new run, forces the same interleaving again, and it passes. Identify, confirm, verify, all with the same machine CLI. In Introducing TestFlows Machine, we walk through these steps command by command, the way an agent runs them.

A bug a test found

If, while running inside the machine, a test finds a bug, you keep the run that found it. For example, we ran an unmodified Jepsen test of etcd in a machine, with one option added to its command to turn on serializable reads, and Jepsen reported a stale read: a write of 0 completed, and the very next read, invoked 10 ms later, came back with 1. Serializable reads are allowed to return stale values, so this is a failure we asked for, not a defect in etcd, but it is a real failure that Jepsen caught. We forked that run at checkpoint 1 and replayed it, and all 460,379 entries converged. The output of the replay matched the original line for line, timestamps included. You can read the whole story in Running Jepsen in a Deterministic Hypervisor. For an agent, that kept run is something to investigate rather than a line in a CI log: it can replay the failing history as many times as it needs, stop at the moment the stale read is served, or fork just before the partition and try something else by running custom commands inside the machine, including using the machine’s own debugger from the outside or GDB on the inside.

A bug you haven’t found yet

And if you don’t know yet which path fails, you are looking for the unknown unknowns, and this is where fuzzing starts. A program with threads can behave differently depending on how its threads interleave, and we call one such interleaving a schedule. A machine already has support to draw the schedules for you. For example, you can give a range for how long each stretch of execution lasts, and each draw picks a length from it, so every draw results in a different interleaving. Each draw takes a seed, and the same seed always draws the same values. Note that the same values do not mean the same run: drawing a seed again records a new run, which repeats the old one only when the run is repeatable. What reproduces a run is replaying its recording.

The explore_seeds.py example shows how: for each seed, it forks a branch from the booted checkpoint and runs it with a schedule drawn from that seed. A branch whose program is killed by a signal is kept and marked %bug-N, since its recording is the finding, and the branches where nothing was killed are deleted, since there is nothing in them worth keeping. Replaying a kept branch fails the same way.

This is also where the agent guiding the walk can come in. The agent can decide where to start the walk, how many seeds to draw, and what each draw varies. A schedule varies only the length of each stretch, and a plan can go further. It can define rules that say, for each state of the program, what to draw, such as whether a thread is held, preempted or moved to another vCPU, how fast the machine’s clock runs, or how long an interrupt waits. Again, every branch that fails can be kept for investigation the same way as we did in the Jepsen run.

But there is more: when the agent needs a technique of its own, we provide the Python SDK, which gives it the same operations to write its own fuzzers with. A random walk, a guided one, or a walk the agent designs after reading the code are all the same thing to the machine. All these are paths through the state space, each one recorded, replayed and branched off.

Conclusion

Writing the deterministic hypervisor was just the first step. Deterministic simulation testing is what the hypervisor now enables as part of the overall deterministic execution environment. Every run there is nothing but a path through the state space of your software, and now you just get to keep it. Combining this with an AI coding agent gives the agent what it needs to find and fix bugs, the known ones and the unknown unknowns alike.

If you are new, create a free account and start with the examples. We’d love to hear what you find, so come and share it with us in the repository’s Discussions. As always, happy testing.