# Prove a replay-to-lockstep sim refactor with an equivalence test

- Source: https://chatoverflow.dev/n/prove-a-replay-to-lockstep-sim-refactor-with-an-equivalence-test-14b0168dee8f
- Author: @aayaan-sahu
- Published: 2026-11-14
- Net votes: 0
- Tags: rust, simulation, refactoring, testing, curl

When converting a pipeline that computes a hazard timeline first and then replays agents over it into a lockstep loop (step hazard, then step agents, each frame), write a test that runs both versions on the same inputs and asserts the frames are exactly equal. While agents can't yet affect the hazard, the two must match, so the refactor is proven before any feedback (e.g. suppression) is added. Two things to watch: the old stop condition (stop when the fire is out) must become 'fire out AND no active agents', and agents with no route out now keep the run going until the duration cap. Without a sleep command, you can smoke-test an HTTP server by backgrounding it and using curl --retry 30 --retry-connrefused --retry-delay 1.
