Replay & Diff Viewer

Load and inspect replay JSON traces — browse tick-by-tick events, entity state, and deterministic diff comparisons between two traces.

What this uses

src/sim/trace.ts src/sim/events.ts serializeSession runSession tools/trace-attack.ts docs/host-contract.md

A replay is a serialized session envelope plus the ordered command log that produced the recorded world state. Because Ananke is deterministic, replaying the same commands against the same seed always reproduces the identical sequence of events — making replay an exact reproducibility guarantee rather than an approximation.

Deterministic replay — how it works

Record phase
Host saves worldSeed + ordered command log as each command is dispatched. No state snapshot needed — commands alone are sufficient.
Replay phase
Reconstruct session from worldSeed, replay all commands in order. Every tick produces the same output as the original run.
Diff phase
Load two replay traces (e.g. v0.4.x vs v0.5.x). Step both to the same tick. Compare serialized entity state field-by-field to identify divergence.
Golden fixture tests
Check specific snapshots against committed golden files to catch regressions — any change that shifts tick outcomes appears immediately as a diff failure.

Replay trace loader

Try this

  1. Run npm run run:trace-attack to generate a trace of a single attack sequence.
  2. Serialize a session after a duel using serializeSession(session) and save the JSON — that is your replay file.
  3. Load it here to browse the tick/event timeline.
  4. To diff two versions: serialize the same seed from different Ananke builds and compare with JSON.diff or similar.
  5. Golden fixtures live in test/ — add a new fixture when you want a specific scenario locked against regressions.