By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
Version 2 of the refund graph shipped on Tuesday. By Thursday a support lead has three threads where the customer was refunded $47.00 for a $42.00 order. The new total node counts shipping in the refundable amount; the fix is a one-line change to a calculation node. The engineering question is not "can we fix it" but "how do we know the fix is right for the threads that already ran" — and how do we learn that without replaying production, where every replay is a live refund?
The answer is a controlled experiment. Take the recorded thread — its checkpoint values, the graph version that wrote them and the effects it committed — fork it into a sandbox, pin the bad version to reproduce the failure, then replay the candidate fix against the same fixture and diff the result. That is incident simulation: an incident reproduced deliberately, in a place where the only write is to a scratch store. It is the applied form of the replay and migration skills from earlier modules, used as a release gate rather than as a postmortem step.
Start by replaying the recorded thread through the bad version. If the failure does not reproduce, the incident's cause is not in the graph code — it is in data, timing or an external system — and changing a node will not fix it. Once the bad version reproduces the divergence, the candidate fix is tested the same way: same fixture, same stand-ins, one changed version. The comparison is mechanical, which is the point; nobody has to argue about whether the fix looks right.
The divergence check works on the trace's deltas, not on the final reply. A reply can be wrong for a plausible reason, while a delta is exactly what one node wrote. Find the first span whose update differs between the recorded run and the replay, and you have both the bug's signature and the smallest possible regression fixture: everything before that span was correct.
from typing import Any
# Two recorded runs of the same thread: the deployed graph version and the
# candidate fix. Replaying compares the deltas the checkpoints captured.
BAD_RUN: list[dict[str, Any]] = [
{"node": "lookup_order", "update": {"order_total": 4200}},
{"node": "compute_total", "update": {"total": 4700}},
{"node": "execute_refund", "update": {"refunded_cents": 4700}},
]
FIXED_RUN: list[dict[str, Any]] = [
{"node": "lookup_order", "update": {"order_total": 4200}},
{"node": "compute_total", "update": {"total": 4700}},
{"node": "execute_refund", "update": {"refunded_cents": 4200}},
]
def first_divergence(
recorded: list[dict[str, Any]], replayed: list[dict[str, Any]]
) -> tuple[int, dict[str, Any], dict[str, Any]] | None:
"""The first span whose returned delta differs, or None if identical."""
for index, (left, right) in enumerate(zip(recorded, replayed)):
if left["update"] != right["update"]:
return index, left, right
return None
divergence = first_divergence(BAD_RUN, FIXED_RUN)
print("diverged at:", divergence[0])
print("bad delta:", divergence[1]["update"])
print("fixed delta:", divergence[2]["update"])
print("fixed refund:", FIXED_RUN[-1]["update"]["refunded_cents"])The first two spans agree, so the lookup and the total calculation are exonerated. The third span diverges by exactly the reported amount, which confirms the incident, identifies the node and produces the assertion for the regression test: replay this fixture and require refunded_cents == 4200. The fixture is small enough to commit, and it fails against every future version that reintroduces the shipping bug.
A replay demo is not a release gate. Five properties turn it into evidence that a reviewer can accept, and each one is an artifact rather than a claim.
Key takeaways
Incident simulation is a controlled experiment: freeze the thread snapshot, the graph version and the effect ledger, then replay in a sandbox instead of production.
Reproduce with the bad version first; if the failure does not reproduce on the fixture, the cause is not the code change you suspect.
Diff the trace deltas to find the first divergent node — that span is both the bug's signature and the smallest regression fixture.
Compare effects, not just state: the ledger's count and amount show the incident's real cost, and the replay must commit no new effects.
A passing replay is necessary but not sufficient; commit the fixture and the report as release artifacts, then still ship the fix behind a canary and a kill switch.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.