Guides
Running a shared simulator
For one simulator that many clients or agents call: a shared dev box, a CI service or a simulator behind your own proxy. The clients get the vendor API. You keep the control plane (reset, seed, clock, inspect) and a log of every change.
Set it up
export RYSTIC_ADMIN_TOKEN=$(openssl rand -hex 16) # keep this; clients never need it
export RYSTIC_ACTION_LOG=$PWD/actions.jsonl
PORT=$(rystic run stripe-twin -d --name shared --port 0 --bind 0.0.0.0 --scenario design_studio --json | jq -r .data.port)
--port 0 picks a free port and PORT keeps it. --bind 0.0.0.0 listens on every interface, so other machines reach it; without it, only this machine does. Clients get http://<this host>:$PORT and a key of their own. For a port your clients know in advance, pass that port to --port. The native runner, rystic run’s default, hands RYSTIC_ADMIN_TOKEN and RYSTIC_ACTION_LOG to the simulator.
The admin token
With RYSTIC_ADMIN_TOKEN set, every control route but /_rystic/version and signed file and upload URLs needs it in an X-Rystic-Admin-Token header, or, on the evaluator’s three routes, the worker token below. The vendor API does not.
curl -s -o /dev/null -w '%{http_code}\n' -X POST localhost:$PORT/_rystic/reset
# -> 401
curl -s -o /dev/null -w '%{http_code}\n' -X POST localhost:$PORT/_rystic/reset -H 'X-Rystic-Admin-Token: wrong'
# -> 403
curl -s -o /dev/null -w '%{http_code}\n' -X POST localhost:$PORT/_rystic/reset -H "X-Rystic-Admin-Token: $RYSTIC_ADMIN_TOKEN"
# -> 204
curl -s localhost:$PORT/v1/customers -u sk_test_agent: | jq .object
# -> "list"
| Route | With the token set |
|---|---|
/_rystic/*: every route in the control plane reference, the state UI included | needs the token |
a simulator’s own control routes: Kalshi’s /_replay/*, /_settle and /_account/snapshot, Stripe’s /_dispute, Resend’s /_bounce, Lob’s /_tracking_event | needs the token |
/_rystic/eval/claim, eval/complete, eval/snapshot | the token, or X-Rystic-Worker-Token carrying the simulator’s RYSTIC_EVAL_WORKER_TOKEN, which reaches nothing else; rystic evaluator sends its own RYSTIC_EVAL_WORKER_TOKEN |
GET /_rystic/version | open: the readiness check |
/_rystic/files/… | open: the signature is the credential (File URLs) |
/_rystic/staged-uploads/… | open: the signed upload target is the credential |
GET /_feed | open: a UI reads a timeline’s messages there |
| the vendor API | open |
- No token returns
401with the bodyUnauthorized; a wrong one returns403. - A browser sends the token as a
rystic_admin_tokencookie, for the state UI at/_rystic/ui/. - With the token unset, every control route is open.
From the CLI
rystic reads RYSTIC_ADMIN_TOKEN from its own environment:
rystic runhands it to the simulator it starts.- The CLI adds the header to its own calls to the simulator, such as
rystic tailandrun --seed-rng, onlocalhostand loopback addresses. - For a simulator on another host, list that host in
RYSTIC_ADMIN_TOKEN_HOSTS, comma-separatedhostorhost:port. The CLI sends the token to no other host.
export RYSTIC_ADMIN_TOKEN=… RYSTIC_ADMIN_TOKEN_HOSTS=sims.internal:8080
rystic tail --addr http://sims.internal:8080
# -> 00:00:00.000 CTL reset
Without the host in the list, or without the token:
rystic: cannot reach twin at http://sims.internal:8080: 401 Unauthorized from http://sims.internal:8080/_rystic/events
Export the token. rystic run --env RYSTIC_ADMIN_TOKEN=… hands it to the simulator only, so the CLI’s own calls, such as --seed-rng, are refused.
The action log
RYSTIC_ACTION_LOG=<path> appends one JSON line per state change to that file. After the setup, the three resets above and one write:
curl -s localhost:$PORT/v1/customers -u sk_test_agent: -d email=ada@example.com > /dev/null
jq -c '{seq, kind, op: .data.op, path: .data.path, status: .data.status}' actions.jsonl
# -> {"seq":1,"kind":"control","op":"reset","path":null,"status":null}
# -> {"seq":2,"kind":"control","op":"scenario","path":null,"status":null}
# -> {"seq":3,"kind":"request","op":null,"path":"/_rystic/reset","status":401}
# -> {"seq":4,"kind":"request","op":null,"path":"/_rystic/reset","status":403}
# -> {"seq":5,"kind":"control","op":"reset","path":null,"status":null}
# -> {"seq":6,"kind":"request","op":null,"path":"/_rystic/reset","status":204}
# -> {"seq":7,"kind":"request","op":null,"path":"/v1/customers","status":200}
What it logs:
- Every request but
GET,HEADandOPTIONS, on the vendor API and the control plane, refused ones included. - Every control operation, the boot’s
resetandscenarioincluded, as acontrolline. On Kalshi, a playing tape adds acontrolline withopreplayper step. - Every webhook delivery attempt, as a
deliveryline naming the receiver’s origin (never its path or query) and the address dialed or refused: Which receivers a simulator may reach shows one. - No reads.
A request line:
{"seq":7,"kind":"request","wall":"2026-10-13T16:29:49.720243Z","received":"2026-10-13T16:29:49.719984Z","sim_clock":"2026-01-01T00:00:00Z",
"data":{"method":"POST","path":"/v1/customers","template":"/v1/customers","actor":"member","status":200,
"request":{"email":["ada@example.com"]},"response":{"id":"cus_…","object":"customer",…}}}
| Field | What it is |
|---|---|
seq | 1, 2, 3… for this process |
kind | request, control or delivery; on Kalshi, also fill, one per fill of an order a caller placed |
wall | wall time the line was written, UTC |
received | request lines: wall time the request arrived |
sim_clock | the simulator’s clock |
data.method, data.path, data.query, data.status | the request and the status it got |
data.template, data.actor | vendor routes: the route it matched and the actor that sent it |
data.request, data.response | the bodies: a form as its fields, JSON as JSON, anything else as text; past 64 KiB, cut and marked …[truncated] |
data.op, data.detail | control lines: the operation and its arguments |
data.destination, data.address, data.refused | delivery lines: the receiver’s origin and the address dialed or refused; data.refused is true for a refusal. An event’s delivery adds data.seq, data.attempt, data.endpoint, data.http_status and data.reason, as on the egress log |
- Headers are never copied, so neither the admin token nor
Authorizationreaches the file. - The caller’s API key is replaced by
[redacted]wherever it appears in a body or query. On Stripe, that is a key sent asAuthorization: Bearer; a key sent withcurl -uis not redacted. - A
/_rystic/*request body (a seed, a schedule, credential bindings) is logged as{"omitted_bytes":N,"sha256":"…"}, not copied. - The file is created readable by you only. A restart appends to it, with
seqstarting again at1. - A path the simulator can’t open stops it at boot with
panic: rystic: RYSTIC_ACTION_LOG: open …: no such file or directory;rystic run -dexits 7.
Read it over HTTP
GET /_rystic/actions serves this process’s lines as application/x-ndjson, a page at a time. It needs the admin token when one is set.
curl -s -D headers.txt "localhost:$PORT/_rystic/actions?since=1&limit=1" -H "X-Rystic-Admin-Token: $RYSTIC_ADMIN_TOKEN" | jq -c '{seq, kind, op: .data.op, detail: .data.detail}'
# -> {"seq":2,"kind":"control","op":"scenario","detail":{"frames":0,"name":"design_studio"}}
grep -i '^x-rystic' headers.txt
# -> X-Rystic-More: true
# -> X-Rystic-Next-Since: 2
Pass X-Rystic-Next-Since as the next since while X-Rystic-More is true. The route’s entry has its parameters and responses, including the 404 it returns when the action log is off.
Behind your own proxy
RYSTIC_GATEWAY_TOKEN makes every request carry X-Rystic-Gateway-Token; Boot configuration has what it does to rystic run and the image’s health check. With both tokens set, the proxy adds the gateway header to everything, and you add the admin header on top:
| Request carries | /_rystic/version | vendor API | control routes |
|---|---|---|---|
| nothing | 403 | 403 | 403 |
| the gateway token | 200 | served | 401 |
| the admin token only | 403 | 403 | 403 |
| both | 200 | served | served |
RYSTIC_GATEWAY_TOKEN=… RYSTIC_ADMIN_TOKEN=… \
~/.rystic/twins/stripe-twin/0.0.36/stripe-twin --addr 127.0.0.1:8080
The binary needs its API key (RYSTIC_TOKEN) or license (RYSTIC_LICENSE): Environment variables.
The URLs a simulator returns that lead back to it, such as links on the vendor’s hosts and file URLs, name the host the client sent in Host, and https when the request carries X-Forwarded-Proto: https. A proxy in front must pass the original Host through. RYSTIC_PRESERVE_SERVICE_URLS=1 keeps the vendor’s own hosts, for a simulator behind a transparent proxy; --intercept sets it. With it set, a request that arrives on a vendor host gets file URLs on the host the vendor serves files from, where that differs from its API host, as the vendor does: GitHub’s release-assets.githubusercontent.com.
Listen address
| Started with | Listens on |
|---|---|
rystic run --port 8080 | 127.0.0.1:8080, this machine only |
rystic run --port 8080 --bind 0.0.0.0, or RYSTIC_BIND=0.0.0.0 | every interface, *:8080 |
rystic run in the Rystic image | every interface in the container; the ports it publishes decide who reaches it |
the binary, with no --addr or RYSTIC_ADDR | 127.0.0.1:8080, this machine only |
the binary, --addr 0.0.0.0:8080 | every interface |
the binary, RYSTIC_ADDR=<host:port> | that address; --addr wins over it |
-
rystic runsets the address from--bindand--port, even with--env RYSTIC_ADDR=….--bindtakes an IP address:127.0.0.1(the default),0.0.0.0or one interface’s address.RYSTIC_BINDsets the bind when--bindis absent:RYSTIC_BIND=0.0.0.0 rystic run stripe-twin -d --name reach --port 0 2>&1 >/dev/null | grep '^rystic: listen:' # -> rystic: listen: 0.0.0.0:..., every interface rystic stop reach >/dev/null RYSTIC_BIND=0.0.0.0 rystic run stripe-twin -d --name reach --port 0 --bind 127.0.0.1 2>&1 >/dev/null | grep '^rystic: listen:' # -> rystic: listen: 127.0.0.1:..., this machine only (--bind 0.0.0.0 listens on every interface) rystic stop reach >/dev/null -
Anyone who can reach the port reaches the control plane unless the admin token is set. Set it before you widen the address (Who can reach it).
-
The log names the address and whether the control plane is locked, and
rystic run -dsays the same on stderr. The binary given no address listens on127.0.0.1:8080, locked here by the token Set it up exported:RYSTIC_TOKEN=rys_… ~/.rystic/twins/stripe-twin/0.0.36/stripe-twin 2> twin.log & TWIN=$! until grep -q 'control plane' twin.log; do sleep 1; done grep -oE 'rystic: .*(listening on|control plane).*' twin.log # -> rystic: stripe-twin 0.0.36 listening on 127.0.0.1:8080 (model …) # -> rystic: control plane locked: its routes need RYSTIC_ADMIN_TOKEN kill $TWIN
Many clients, one simulator
Every caller acts as member until you say otherwise. Two ways to give each client its own actor:
X-Rystic-Actor: <label>on the request. It wins over everything else.- A credential binding: the client changes nothing but its key.
curl -s -o /dev/null -w '%{http_code}\n' -X POST localhost:$PORT/_rystic/credentials \
-H "X-Rystic-Admin-Token: $RYSTIC_ADMIN_TOKEN" -H 'Content-Type: application/json' \
-d '{"bindings":{"sk_test_agent_a":"agent_a","sk_test_agent_b":"agent_b"}}'
# -> 204
curl -s localhost:$PORT/v1/customers -H 'Authorization: Bearer sk_test_agent_a' > /dev/null
curl -s localhost:$PORT/v1/customers -H 'Authorization: Bearer sk_test_agent_b' > /dev/null
curl -s localhost:$PORT/_rystic/calls -H "X-Rystic-Admin-Token: $RYSTIC_ADMIN_TOKEN" \
| jq -c '.calls[-2:][] | {actor, method, path, status}'
# -> {"actor":"agent_a","method":"GET","path":"/v1/customers","status":200}
# -> {"actor":"agent_b","method":"GET","path":"/v1/customers","status":200}
- A posted set of bindings replaces the last one. With
"keep": trueit adds only the credentials no binding holds yet, and a bound credential keeps its actor and grants. A key with no binding acts asmember, and a reset clears every binding. - A binding may be
{"actor": "<label>", "grants": [...]}: the access the credential holds, from the grants the simulator declares. A simulator that declares none refuses any grant with400. - On Stripe, a binding matches a key sent as
Authorization: Bearer, the way Stripe’s libraries send it.curl -u sk_test_agent_a:acts asmember. GET /_rystic/callslists every request since the last reset, reads included, with itsactorandprincipal: the scenario user the actor maps to in the loaded scenario, or empty when there is none. The action log’sdata.actornames the same actor.- What an actor sees is each simulator’s own rule: Slack identities, Kalshi’s multiple bots, which also reads
KALSHI-ACCESS-KEY.
A client that joins later can add its own key with "keep": true, and the bindings already made stay as they were:
curl -s -o /dev/null -w '%{http_code}\n' -X POST localhost:$PORT/_rystic/credentials \
-H "X-Rystic-Admin-Token: $RYSTIC_ADMIN_TOKEN" -H 'Content-Type: application/json' \
-d '{"keep":true,"bindings":{"sk_test_agent_a":"intruder","sk_test_agent_c":"agent_c"}}'
# -> 204
curl -s localhost:$PORT/v1/customers -H 'Authorization: Bearer sk_test_agent_a' > /dev/null
curl -s localhost:$PORT/v1/customers -H 'Authorization: Bearer sk_test_agent_c' > /dev/null
curl -s localhost:$PORT/_rystic/calls -H "X-Rystic-Admin-Token: $RYSTIC_ADMIN_TOKEN" \
| jq -c '.calls[-2:][] | {actor, path}'
# -> {"actor":"agent_a","path":"/v1/customers"}
# -> {"actor":"agent_c","path":"/v1/customers"}
rystic stop shared
One simulator per client
Simulators share nothing, so a client or agent that must not see another’s writes gets a simulator of its own. Start one per client, each with its own --name and port:
A=$(rystic run stripe-twin -d --name agent-a --project agent-a --port 0 --json | jq -r .data.port)
B=$(rystic run stripe-twin -d --name agent-b --project agent-b --port 0 --json | jq -r .data.port)
curl -s localhost:$A/v1/customers -u sk_test_x: -d name=Ada | jq -r .object
# -> customer
curl -s localhost:$B/v1/customers -u sk_test_x: | jq '.data | length'
# -> 0
rystic down --project agent-a
# -> stopped agent-a
rystic stop agent-b
--projectlabels a client’s simulators, sorystic ps --project,rystic clock --projectandrystic down --projectact on them together. It defaults todefault.- With
--intercept, each project gets its own gateway, so two clients can each callapi.stripe.comand reach their own simulator: Intercept vendor calls. rystic grid <product> -worlds <scenarios> -- <command>runs your command once per scenario, each against a fresh simulator, and reads its address fromRYSTIC_ADDR. Grade agent runs runs an agent once per eval the same way, and grades each run.
rystic grid stripe-twin -worlds design_studio -out cells -- sh -c 'curl -s -o /dev/null "$RYSTIC_ADDR/v1/customers" -u sk_test_x:'
# -> grid: 1 bots × 1 ... through stripe-twin ...
# -> ...GRID GREEN — 1 cells, every bot held in every ...
File URLs
A simulator that stores files, such as Notion’s uploads and Jira’s attachments, serves them from itself under a signed /_rystic/files/ URL:
{"type":"file","file":{"url":"http://localhost:8080/_rystic/files/notes.txt?expires=1769907600003&key=…&resource=state_file_upload&signature=…","expiry_time":"2026-02-01T01:00:00.003Z"}}
- It expires after a lifetime the simulator sets, measured on the simulator’s clock. Every read returns a fresh one; on Notion,
expiry_timesays when it expires. - It needs no admin token. Anyone holding the URL can fetch the file until it expires.
- Moving the clock past its expiry with
POST /_rystic/clockexpires it at once.
On a GitHub simulator booted with --intercept, a release asset download redirects to GitHub’s storage host instead of the host the client sent. Boot one in a project of its own, downloads, seed a release asset in tb-owner/tb-repo, and download it from api.github.com:
URL=$(rystic run github-pulls-twin -d --port 0 --intercept --name downloads --project downloads --scenario github-pulls_open_queue --json | jq -r .data.url)
curl -s -X POST "$URL/_rystic/seed" -H "X-Rystic-Admin-Token: $RYSTIC_ADMIN_TOKEN" -d '{"state_release_asset":{"tb-owner/tb-repo#7001":{"id":7001,"release_id":1,"repository":"tb-owner/tb-repo","name":"notes.txt","body_b64":"aGVsbG8K"}}}' -o /dev/null -w '%{http_code}\n'
# -> 204
rystic exec --project downloads -- curl -s -o /dev/null -w '%{redirect_url}\n' -H 'Accept: application/octet-stream' -H 'Authorization: Bearer ghp_anything' https://api.github.com/repos/tb-owner/tb-repo/releases/assets/7001
# -> https://release-assets.githubusercontent.com/...
rystic stop downloads >/dev/null
rystic gateway --stop --project downloads >/dev/null
/_rystic/files/{path} lists the URL’s methods, parameters and responses, including the 403 for an expired or edited URL. Notion → file uploads and Jira → attachments have the calls that store a file.