Recorder/Comparator Pipeline

Active campaign context: Operation Crystal Replay is the current parity strategy for replay/session evidence hardening.

This project now treats session parity as a two-phase pipeline:

  1. Recorder phase: run JS from captured C inputs and record raw JS outputs.
  2. Comparator phase: compare the raw JS recording to the C session with policy-controlled rules.

This separation keeps replay/runtime execution free of comparison heuristics.

Why This Split Exists

replay_core should only execute game logic and capture what happened. It should not decide whether sparse boundary shifts are acceptable.

Sparse/special boundary tolerance belongs in comparator policy code, where matching rules can evolve without changing runtime behavior.

Modules

Recorder

Recorder output is a raw replay trace (startup + steps with RNG/screen data).

Comparator

This orchestrates result metrics (rng/screen/color/event) from recorded trace vs C session data.

Comparator Policy

Policy owns comparison behavior for:

If sparse-boundary allowances are needed, implement them in policy methods.

Tooling Entry Points

Main parity gate

Session runner

By default, session runs now also emit merged .comparison.json artifacts under:

Each artifact contains:

This makes repeated divergence inspection cheap without regenerating traces.

Single-session debug replay

Replay dump CLI

npm run replay:dump -- test/comparison/sessions/seed208_ranger_wizard_gameplay.session.json --out /tmp/seed208.js-replay.json

Session compare CLI

# Compare against generated replay
npm run session:compare -- test/comparison/sessions/seed208_ranger_wizard_gameplay.session.json

# Compare against previously dumped replay
npm run session:compare -- test/comparison/sessions/seed208_ranger_wizard_gameplay.session.json --js /tmp/seed208.js-replay.json --json

Comparison window CLI

# list latest run artifacts
node scripts/comparison-window.mjs --list

# show default (first-divergence) RNG window for a specific session
node scripts/comparison-window.mjs seed208_ranger_wizard_gameplay.session.json --channel rng --window 6

# inspect event channel at explicit normalized index
node scripts/comparison-window.mjs seed208_ranger_wizard_gameplay.session.json --channel event --index 623 --window 4

Implementation Rule

When parity disagreements involve step-boundary interpretation, do not patch runtime execution to force a match. Add or adjust comparator policy instead.