Skip to Content
ConceptsReset and determinism

Concepts

Reset and determinism

The same starting state and the same requests give byte-identical ids, timestamps and events, run after run. The examples use the Lob simulator; every simulator takes the same calls.

The loop

curl -s -X POST localhost:$PORT/_rystic/reset                 # empty; ids and clock rewound
curl -s -X POST localhost:$PORT/_rystic/seed -d @scenario.json   # or POST /_rystic/scenario
# ... run your code ...
curl -s localhost:$PORT/_rystic/inspect                       # assert exact records
curl -s localhost:$PORT/_rystic/egress                        # assert exact events

Scenarios and seeding covers scenario.json; Observing a simulator covers what to assert on.

Every boot starts the same

  1. The same command line boots the same state on every plan: --scenario, --seed, both or neither. With no boot input, the simulator boots empty.
  2. State lives in memory. A restart discards everything since boot and boots that state again.
  3. Requests run one at a time, so each one sees the state the one before it left.

What reset does

POST /_rystic/reset returns 204. It does not load the boot --scenario again; POST /_rystic/scenario resets and loads a scenario in one call, and {"to": "boot"} on the reset restores the boot state again (Control plane).

StateAfter a reset
RegistersCleared, then the simulator’s built-in records are seeded again
Id sequencesRestarted, so the first record gets the same id every time
ClockBack at initial_clock, not the scenario’s instant: load the scenario again for that (The clock)
The wall offset (wall_offset_seconds, below)Back at 0
RNGRestarted from the last pinned seed
Egress log and call logEmptied; seq restarts at 1
Live feedEmptied; its seq keeps counting
Action log fileKept; the reset adds a control line
Credential bindingsCleared, whether POST /_rystic/credentials, a boot file, a named scenario or a posted scenario file made them
Stored idempotency keysForgotten, so a repeated key runs again
Webhook deliveries waiting or retryingCanceled
Open upload sessionsClosed
Rate-limit windows and query-cost budgetsRestarted
The rate_limits setting (Turn on the real service’s rate limits)Kept, unless a scenario set it: that one lasts for the scenario only
A scenario’s own timeline eventsDropped
A schedule loaded on its own (POST /_rystic/inject, --inject, RYSTIC_INJECT)Kept; it replays from its first event
A network profile a scenario installedDropped, and the one from before it returns, unless a post to /_rystic/network or a posted scenario file with a network came since
A network profile you posted, or loaded from RYSTIC_NETWORK or a boot seed fileKept
Egress retentionKept
Revoked credentials, duplicate deliveries, page capsDisarmed
A webhook URL set with POST /_rystic/webhooksKept
A scenario’s tape, on a simulator that has oneStopped: Kalshi → Determinism and reset
rystic pull lob-twin
PORT=$(rystic run lob-twin -d --name loop --port 0 --scenario design_studio --json | jq -r .data.port)
add() { curl -s -u test_x: localhost:$PORT/addresses -d name=Ada -d address_line1='185 BERRY ST' \
  -d address_city='SAN FRANCISCO' -d address_state=CA -d address_zip=94107 | jq -c '{id, date_created}'; }
add
# -> {"id":"adr_0000000000000001","date_created":"2026-03-01T00:00:00.001Z"}
curl -s -X POST localhost:$PORT/_rystic/reset
curl -s localhost:$PORT/_rystic/inspect
# -> {}
add
# -> {"id":"adr_0000000000000001","date_created":"2026-01-01T00:00:00.001Z"}
curl -s -X POST localhost:$PORT/_rystic/scenario -d '{"name":"design_studio"}'
add
# -> {"id":"adr_0000000000000001","date_created":"2026-03-01T00:00:00.001Z"}

The clock

Every simulator keeps its own clock, and timestamps come from it.

  1. Where it starts. A scenario sets its own instant, given in the Clock column of its simulator’s Scenarios table: Lob’s design_studio starts at 2026-03-01T00:00:00Z. An empty boot starts at 2026-01-01T00:00:00Z, unless the simulator’s Determinism and reset section names another start, such as the wall time the process started. GET /_rystic/version shows the empty-boot instant as initial_clock.
  2. How it moves. Each request that stamps a time moves it one millisecond. It never follows wall time unless you pace it (below): two writes seconds apart still read .001Z and .002Z.
  3. Set it. POST /_rystic/clock with {"time":"<RFC3339>"} sets it; {"advance_seconds":N} moves it by N seconds; a negative N moves it back. A scenario file’s clock sets it too. Moving it past a loaded scenario’s events fires every one it skips, in order.
  4. Shift the wall time. {"wall_offset_seconds":N} on the same route shifts the wall time the simulator signs most deliveries with and checks incoming signatures against, and 0 puts it back. The clock does not move. Webhooks → Test a stale signature says what it reaches.
  5. Pin the start. rystic run --clock <RFC3339> (RYSTIC_CLOCK) sets initial_clock, so an empty boot and every reset start there. Use it to make two processes agree.
  6. Read it. GET /_rystic/version returns clock, the instant now. Reading it does not move it.
curl -s -X POST localhost:$PORT/_rystic/reset
curl -s localhost:$PORT/_rystic/version | jq .initial_clock
# -> "2026-01-01T00:00:00Z"
curl -s -X POST localhost:$PORT/_rystic/clock -d '{"time":"2026-06-01T09:00:00Z"}'
add
# -> {"id":"adr_0000000000000001","date_created":"2026-06-01T09:00:00.001Z"}
curl -s localhost:$PORT/_rystic/version | jq .clock
# -> "2026-06-01T09:00:00.001Z"

The RNG

  1. Every boot seeds the random stream with 1.
  2. POST /_rystic/seed-rng with {"seed":N} pins another; so do rystic run --seed-rng N and a scenario file’s rng_seed.
  3. Ids are sequences, not random draws: the seed does not change them. Their shapes are the simulator’s, so treat them as opaque.
  4. Network profiles draw from it: the same seed and profile refuse the same requests in the same order.

Pacing

The clock is manual by default: while your code is idle, nothing moves and no timeline event fires.

  1. RYSTIC_PACE=<speed> moves the clock speed simulated seconds per wall second, firing events as they come due. rystic run --speed <speed> sets it.
  2. rystic run and rystic up pace at 1 on their own for an --inject schedule or a --seed scenario with events. A built-in --scenario stays manual. --speed 0, or speed: 0 in a stack file, keeps the clock manual.
  3. A paced clock follows wall time, so timestamps depend on when requests arrive.
  4. It moves in steps: once per wall second it jumps speed seconds. Each simulator steps on its own phase, so two paced simulators can read up to a step apart: up to a second at speed 1.
  5. A /_replay tape or live feed drives the clock, and pacing waits for it. Kalshi’s btc15m_tape does not wait, so set --speed 0 beside it: Kalshi → Scripted events.
rystic run lob-twin -d --name paced --port 0 --scenario design_studio --speed 3600
# one simulated hour per second: the scenario's hourly events fire as they come due

An --inject file paces at 1 with no --speed, and the clock holds between steps:

echo '{"events":[{"id":"later","at":"+1h","message":{"channel":"ops","body":"an hour on"}}]}' > later.json
PORT=$(rystic run stripe-twin -d --name stepped --port 0 --inject later.json --json | jq -r .data.port)
for i in 1 2 3 4; do curl -s localhost:$PORT/_rystic/version | jq -r .clock; sleep 0.3; done
# 2026-01-01T00:00:01.001755459Z
# 2026-01-01T00:00:01.001755459Z
# 2026-01-01T00:00:01.001755459Z
# 2026-01-01T00:00:02.002358209Z

The same run with --speed 0 reads 2026-01-01T00:00:00Z every time.

Timelines covers scheduling events.

What is and isn’t deterministic

From the same boot or reset, with the same requests in the same order, these repeat byte for byte:

  1. Ids, numbers and sequences.
  2. Timestamps, on a manual clock.
  3. The egress log: its events, their order and their seq.
  4. Network-profile rejections, for the same seed and profile.

These do not:

  1. Concurrent requests. They run one at a time in the order they arrive, so which one gets which id changes run to run. Send them in a fixed order.
  2. A paced clock. It follows wall time.
  3. An empty boot that starts at wall time (The clock). Within one process every reset returns to that instant; across processes, pass --clock.
  4. Kalshi’s recorded tape. btc15m_tape plays on the wall clock, so what your code meets depends on when it acts (Kalshi → Determinism & reset).
  5. Restarts. They discard everything since boot.
  6. Rate limits, once you turn them on. By default no simulator enforces a rate limit, so how fast you send never changes a result. Turning on the real service’s limits brings back refusals on the wall clock. Resend allows 10 requests a second, Linear 2,500 requests and 3,000,000 complexity points an hour and Shopify’s query-cost bucket restores by the wall second. The same requests sent back to back can then be refused where spaced out they pass, so a test that turns the limits on should expect a 429. A reset refills the allowance.

Done with the example: rystic stop loop, rystic stop paced and rystic stop stepped.

Last updated on