Files
aji/docs/spec/11-determinism-and-replay.md
T
dev 17a55a7fef Initial import: Aji 0.1 draft spec and Zig scaffolding
Draft specification, RFCs, reference registries and examples, plus the
reference-implementation skeleton: build.zig, diagnostic envelope with
error-code registry synced to docs, aji CLI, conformance runner with seed
tests, CI and contributor docs.
2026-10-04 11:59:13 +03:00

1.3 KiB

11. Determinism, Trace and Replay

1. Interpreter

The reference AIR interpreter defines executable semantic behavior for the language model.

2. Trace

Trace mode may record each AIR instruction and selected abstract-state changes.

Example:

#120 region.create -> r3
#121 region.alloc r3 4096 -> p8
#122 borrow.mut p8 -> b4
#123 store.u32 b4 10
#124 borrow.end b4

3. Deterministic mode

Deterministic execution controls or records sources of nondeterminism including:

  • task scheduling choices;
  • timer progression;
  • clock reads;
  • random inputs;
  • I/O completion ordering;
  • channel wake selection;
  • selected filesystem/network inputs.

4. Replay

A recorded execution should be replayable when program, runtime and replay-format compatibility requirements are met.

aji run --record failure.ajr app.aji
aji replay failure.ajr

5. Concurrency exploration

Test mode may systematically or pseudo-randomly vary scheduling at synchronization points.

Candidate scheduling points include:

  • atomic operations;
  • lock/unlock;
  • channel send/receive;
  • task yield/wake;
  • I/O completion;
  • cancellation observation.

Example:

aji test --interleavings=10000

6. Deterministic selection

When select has multiple ready branches, deterministic mode must choose according to a stable rule and record the decision.