The problem
A bug can need two rare things, one after the other. Each new seed starts from zero, so it must find the first rare thing again before it can try for the second. The chance is the product of the two, and most seeds never get near.
The technique
A run is a stream of random numbers. A recipe is a list of (draw count, seed) pairs: replay the stream up to that draw, then go on with a new seed. When a run makes a discovery that no run made before (a coverage assertion fires for the first time, a bucket fills, a watermark rises), the explorer forks it there: the children replay the run up to the discovery, then each takes another future. A productive child forks again; a child with nothing new ends its branch. A failing child is a bug, with the recipe that replays it.
moonpool-explorer forks processes and shares memory between them, so it does not run in a browser. A Rust test ran this exploration and recorded its tree.
The live run
Seed 7 of the register with the planted bug. Its root timeline passes. The explorer ran 48 timelines: each column is one, in the order it ran, and each row is a depth. Step through them, or select one. Timeline 5 forks from timeline 0 at draw 10 and breaks the invariant. The engine replays it from its recipe in your browser.
The code
The settings of this exploration. workers: 0 runs each timeline in the process, one after the other, so the tree is the same each time:
fn exploration() -> ExplorationConfig {
ExplorationConfig {
workers: 0,
max_runs_per_seed: 48,
branching_factor: 3,
max_frontier: 64,
max_recipe_len: 6,
}
}The test turns it on, and keeps the tree in the report:
fn explore(seed: u64) -> SimulationReport {
simulation(&RunConfig { seed, ..config() })
.set_iterations(1)
.set_debug_seeds(vec![seed])
.enable_exploration(exploration())
.record_exploration_tree()
.run()
.expect("the site's config is valid")
}The report gives each bug as a BugRecipe. replay_timeline(seed, recipe) runs that one timeline again.