Issue #1580: Decision: a record-and-replay mode that records every outside input of a run and replays it deterministically

Open and answer this issue on GitHub.

decision · opened 2026-11-12 · updated 2026-11-12 · 0 comments

Where this comes from

An outside consultancy made suggestions to the owner on 2026-11-12. This is one of them: a replay mode that records all effects of a run (file reads, network answers, clock, random numbers, AI calls) so that any run, including a failure in production, can be replayed exactly, for debugging and for audit. No ADR and no issue covers it.

The question, from zero

A program run is reproducible when the same code given the same inputs does the same thing. Most runs are not reproducible, because they read things from outside: the clock, random numbers, files, the network, environment variables, standard input, and the order in which tasks are scheduled. A bug that shows up once in production may never show up again on the developer’s machine.

Record and replay fixes this. In record mode the runtime writes every value that comes in from outside to a log. In replay mode it reads them back from the log instead of from the world, so the run repeats exactly, step for step. This makes a production failure reproducible, a test of the failure a matter of keeping its log, and an audit able to show exactly what a program saw.

The question: should Nikaia offer a record-and-replay mode? If so, at which boundary are inputs recorded, how is concurrency made replayable, and what is promised: an exact replay, or a best effort?

What exists that it builds on

How others do it

These facts are from memory, not checked.

System How
rr (Mozilla) records a Linux process at the system-call level and replays it under a debugger, with reverse execution. It works for any language, but runs on one core and needs hardware counters
Boruna records effects in an audit log as part of its capability model (as far as I know)
Temporal, Azure Durable Functions workflow code must be deterministic. Every side effect is an “activity” whose result is recorded and replayed when the workflow resumes
Elm the time-travelling debugger replays the messages of a pure program
Haskell, Koka, Unison effect handlers make swapping the real world for a recorded one a library matter
AILANG describes deterministic replay of effects as a goal (not verified)
Vera, Dafny, Mojo none that I know of

Options

  1. Do nothing. Reproduce bugs with logs and tests, or use rr outside the language.
    • For: no work, and rr already exists on Linux.
    • Against: rr is Linux-only and debugger-oriented, with no audit log and no test from a recording. It does not use the permission boundary Nikaia already has.
  2. Record and replay in std, at the permission boundary. nikaia run --record LOG makes every std call that reads outside data (by the #1433 kinds) append its result to the log. nikaia run --replay LOG returns the values from the log instead. With tasks, the scheduler records its order, or runs single-threaded and deterministic under replay. A program using native cannot be replayed exactly, and the tool says so.
    • For: it uses the boundary #1432/#1433 already prove complete. It works on every platform. A log can become a regression test (nikaia test from a recording). An AI call is net, so it is recorded like any other answer.
    • Against: runtime work in every input path of std, and the log may hold secrets (environment variables, network answers), so it needs a redaction story. The scheduler’s order has to be pinned.
  3. Replay for tests only. A recorded run turns into a fixture, and nikaia test replays it. There is no production record mode.
    • For: smaller, and still makes failures reproducible once caught.
    • Against: does not catch the production failure that started the wish.
  4. Leave it to effect handlers. If Nikaia ever has user-definable effect handlers, replay becomes a library.
    • For: general.
    • Against: Nikaia has permissions, not effect handlers, and this would be a far larger decision.

Recommendation

Option 2, scoped after #1433 is built, because it needs the vocabulary to name what to record. Promise an exact replay only for programs without native, and with the scheduler pinned. Treat the log as sensitive by default: no environment variables recorded unless asked, and a redaction hook. Ship option 3 (a recording as a test fixture) as its first user.

What it touches

Back to Open Issues