Skip to Content
ConceptsScenarios and seeding

Concepts

Scenarios and seeding

A simulator boots empty unless you give it a starting state: a named scenario built into the binary, a seed of your own, or both. The examples use the Lob simulator; every simulator takes the same calls.

Named scenarios

rystic pull lob-twin
PORT=$(rystic run lob-twin -d --name scenarios --port 0 --scenario design_studio --json | jq -r .data.port)
curl -s localhost:$PORT/_rystic/scenarios | jq -c '.scenarios[] | {name, frames, loop}'
# -> {"name":"design_studio","frames":0,"loop":null}
  1. Without a boot input, GET /_rystic/inspect returns {}, or only the records the service always has, such as Okta’s Everyone group.
  2. POST /_rystic/scenario resets, then loads a scenario, with no restart. A scenario loaded this way holds exactly the state the same scenario booted with --scenario holds.
curl -s -X POST localhost:$PORT/_rystic/scenario -d '{"name":"design_studio"}'
# returns 204

An unknown name returns 404, naming the scenarios the build has:

{"message":"unknown scenario \"design-studio\" (have: design_studio)"}

List the scenarios

Discover what a simulator can do lists each way to ask for a simulator’s scenarios and what each holds. rystic describe lob-twin lists them beside the registers and operations, with no simulator running (below).

The shared studio

design_studio is one company across several simulators: One company across simulators names them and runs them together.

A scenario’s timeline

A scenario can carry events that fire as its clock passes them, as Lob’s design_studio does; each simulator’s page says which of its scenarios do. The clock stays put until you move it with /_rystic/clock (Pacing):

curl -s -X POST localhost:$PORT/_rystic/clock -d '{"advance_seconds":3600}'
curl -s localhost:$PORT/_rystic/inject | jq -c '.events[0] | {id, fired_at, status}'
# -> {"id":"harborview-second-office","fired_at":"2026-03-01T01:00:00Z","status":200}

Timelines has the event format.

Seeding

POST /_rystic/seed writes records directly, without calling the API, and returns 204.

curl -s -X POST localhost:$PORT/_rystic/seed -d '{"state_address": {"adr_home": {"id": "adr_home", "object": "address", "name": "HOME", "address_line1": "185 BERRY ST", "address_city": "SAN FRANCISCO", "address_state": "CA", "address_zip": "94107"}}}'
curl -s -u test_x: localhost:$PORT/addresses/adr_home | jq -c '{id, name}'
# -> {"id":"adr_home","name":"HOME"}

Two shapes

  1. Register map: {"<register>": {"<key>": {<record>}}}, as above.
  2. Scenario file: the register map under seed, beside the optional keys below. Other keys are ignored, so expected outcomes can live in the same file. POST /_rystic/seed refuses tape and loop (below), which a boot file ignores. Boot inputs describes how a boot file loads the file.
printf '%s\n' '{' \
  '  "seed": {"state_address": {"adr_home": {"id": "adr_home", "object": "address", "name": "HOME",' \
  '    "address_line1": "185 BERRY ST", "address_city": "SAN FRANCISCO", "address_state": "CA", "address_zip": "94107"}}},' \
  '  "clock": "2026-07-23T00:00:00Z",' \
  '  "expect": {"postcards": 1}' \
  '}' > scenario.json
curl -s -X POST localhost:$PORT/_rystic/reset
curl -s -X POST localhost:$PORT/_rystic/seed --data-binary @scenario.json
# returns 204; the clock now reads 2026-07-23

Either shape also boots: rystic run lob-twin --seed scenario.json, or RYSTIC_SEED for a container. A boot seed file can take a value from the simulator’s environment with {"$env": "NAME"}, such as the webhook secret your app holds (The boot seed file). rystic compose boots each simulator from rystic/seed/<service>.json.

Scenario file keys

A scenario file is checked whole before any of it is applied, so a refusal leaves the simulator as it was.

KeyWhat it sets
seedRequired. The register map, merged as below
clockThe clock’s RFC3339 instant (The clock)
rng_seedThe random stream, as POST /_rystic/seed-rng pins it
sequences{"<scope>": N}, each id counter’s last value, so the next id continues after it. A value only raises a counter, never lowers it. GET /_rystic/inspect?view=sequences reads the counters
networkThe POST /_rystic/network body, {"enabled", "profile", "rate_limits"}, not a bare network profile; needs the faults feature. "rate_limits": "real" enforces the real service’s rate limits, for as long as a profile set the same way lasts
credentials{"<credential>": "<actor>"}, or {"<credential>": {"actor", "grants"}}, as credential bindings take them
eventsA timeline of events that fire as the clock passes them
repliesThe scripted replies of a simulator whose operations return generated replies (Anthropic)
actors{"<actor label>": "<identity value>"}: the seeded user record each label acts as, found by its key or its identity field

actors works on a simulator whose callers are records of its own, such as Linear’s users. Here member, the label every caller acts as by default, becomes a seeded user:

rystic pull linear-twin
LINEAR=$(rystic run linear-twin -d --name actors --port 0 --json | jq -r .data.port)
curl -s -X POST localhost:$LINEAR/_rystic/seed -d '{"seed": {"state_user": {"usr_ada": {"id": "usr_ada", "name": "Ada Lovelace", "email": "ada@example.com", "active": true}}}, "actors": {"member": "usr_ada"}}'
curl -s localhost:$LINEAR/graphql -H 'Authorization: lin_api_x' -H 'Content-Type: application/json' -d '{"query": "{ viewer { id name } }"}'
# -> {"data":{"viewer":{"id":"usr_ada","name":"Ada Lovelace"}}}
rystic stop actors

A label that names no record of the file’s own seed is refused with 400, naming the label and the value. A simulator without such records refuses actors whole.

How a seed lands

  1. A seed merges into what the simulator holds; it does not reset first. A new key adds a record.
  2. An existing key merges field by field: {"adr_home": {"name": "HOME 2"}} changes the name and keeps the address. A nested object, such as metadata, replaces the old one whole.
  3. GET /_rystic/inspect returns the state as a register map, so a dump posted back after a reset restores it.
  4. The dump leaves out the id counters: read them with GET /_rystic/inspect?view=sequences and post them back under sequences, so the next ids continue the old counts.
  5. A counter can jump past seeded ids even when the seed declares no sequences:
    • A counter named for a record type and field passes the largest integer the seed holds in that field, as a number or a string of digits. It also passes the largest number after a prefix in a key such as adr_12.
    • A uuid the simulator minted, as in an inspect dump, raises its counter.
    • A seed the simulator doesn’t ship also raises the counter of each field whose register names a mint (GET /_rystic/registers), to the largest id of that form the field holds at the top level.
    • Any other counter starts over, and an id in another form, such as a gid:// URI, moves nothing, so a new record can take a seeded id. Carry the counters under sequences whenever ids must not repeat.
    • A seed raises a counter and never lowers one.
  6. A seed may be partial: under RYSTIC_SEED_GATE=partial, a record lists the fields it leaves unknown and the ids the simulator should mint (The seed gate).

What a seed refuses

A refusal returns 400 with {"message", "errors"}, and nothing is written. Only these are refused:

  1. An unknown register. The error names every register the simulator has:

    {"errors":[{"register":"state_adress","error":"unknown register \"state_adress\"; this twin has: state_address, state_idempotency_key, state_postcard"}],"message":"seed rejected: 1 invalid entries"}
    
  2. A register whose value is not a map of key to record: <register> value must be an object of key -> record.

  3. A record that is not a JSON object: record "<key>" must be a JSON object.

  4. A scenario file carrying a tape or loop. Those play only from a built-in scenario.

  5. An incomplete record, under RYSTIC_SEED_GATE=reject (below).

Seed only what you inspected

GET /_rystic/inspect?etag=1 adds an ETag header for the state it returns. Send it back as If-Match on POST /_rystic/seed, and the seed is applied only if no record has changed and no reset has run since. Otherwise it returns 412 and writes nothing:

curl -s -X POST localhost:$PORT/_rystic/reset
TAG=$(curl -s -D - -o /dev/null "localhost:$PORT/_rystic/inspect?etag=1" | tr -d '\r' | awk -F': ' 'tolower($1) == "etag" {print $2}')
curl -s -o /dev/null -w '%{http_code}\n' -X POST localhost:$PORT/_rystic/seed -H "If-Match: $TAG" -d '{"state_address": {"adr_one": {"id": "adr_one", "object": "address", "name": "ONE"}}}'
# -> 204
curl -s -w '%{http_code}\n' -X POST localhost:$PORT/_rystic/seed -H "If-Match: $TAG" -d '{"state_address": {"adr_two": {"id": "adr_two", "object": "address", "name": "TWO"}}}'
# -> {"message":"state changed; inspect again before seeding"}
# -> 412

A reset changes the tag too, even when the state reads the same. The clock, credential bindings, network profile and id counters are not in the tag. Without If-Match, a seed is always applied.

Registers

A register holds one kind of record. GET /_rystic/registers lists each one: id, kind, key_fields, seed_via and its fields, each with its type, and required where the model requires it.

curl -s localhost:$PORT/_rystic/registers | jq -c '.registers[] | {id, kind, key_fields}'
# -> {"id":"state_address","kind":"document_collection","key_fields":["id"]}
# -> {"id":"state_idempotency_key","kind":"idempotency_store","key_fields":["idempotency_key"]}
# -> {"id":"state_postcard","kind":"document_collection","key_fields":["id"]}

A register with an owner_field files each record under one caller, as Kalshi’s portfolio registers do (Kalshi → Seeding state).

rystic describe

rystic describe <product> asks the installed binary what it serves, with no simulator running.

rystic describe lob-twin
# -> ...
# -> scenarios (1) — `rystic run lob-twin --scenario <name>`; ...
# ->   design_studio  [start] Website Design Contractors' account: the Portland, ME offi...
# -> registers (3) — seed a keyed one with POST /_rystic/seed {<id>: {<key>: <record>}}:
# ->   state_address          document_collection (key id, 17 fields)
# ->   ...
# -> operations (17): DELETE 4, GET 8, POST 5
# -> ...
  1. -json adds every register’s typed fields and an example record. Post {"<register>": <example>} to /_rystic/seed as it is.
  2. -v lists every operation.
  3. With no product named, it describes every installed simulator. CLI flag reference → describe.
  4. [start] marks the scenario the quickstart offers.

The seed gate

A record missing a field its register marks required is still accepted by default, and served as though whole. The simulator’s log says so. Okta’s password register requires salt and verifier:

rystic pull okta-twin
OKTA=$(rystic run okta-twin -d --name gate --port 0 --json | jq -r .data.port)
curl -s -X POST localhost:$OKTA/_rystic/seed -d '{"state_user_password": {"00u1": {"userId": "00u1"}}}'
# returns 204
rystic logs gate | grep "incomplete seed"
# -> ... rystic: WARNING — incomplete seed: state_user_password record "00u1" is missing 2 required field(s): salt, verifier. ...
rystic stop gate
  1. RYSTIC_SEED_GATE=reject refuses such a seed instead: 400, seed rejected: 1 incomplete record(s), naming each missing field.
  2. RYSTIC_SEED_GATE=off skips the check.
  3. The check runs on the merged record, so a partial update to a complete record passes.
  4. RYSTIC_SEED_GATE=partial refuses an incomplete record as reject does, unless the record lists the missing field under _rystic_partial.unknown, or an id field under _rystic_partial.mint. A field listed as unknown counts as carried. The simulator stores nothing for it and answers what it answers for a missing field, except that a record it already holds keeps its value. A minted id takes the form the register’s mint names, and a later create never repeats it. A _rystic_partial marker at a record’s top level is refused under every other value.
  5. Set it at boot: rystic run okta-twin --env RYSTIC_SEED_GATE=reject, or in the container’s environment. An unrecognized value stops the simulator before it serves, and the error names the valid ones.

What a partial seed left unknown

Under partial, GET /_rystic/gaps counts the reads that met a field the seed left unknown. A read is a request answered 2xx that wrote nothing. Reset clears the counts, and under any other value every count is 0:

{"gate": "partial", "partial_records": 1, "reads": 3, "reads_rendering_unknown": 2,
 "empty_list_reads": 1, "unsearched_reads": 0,
 "unknown_fields": {"state_address": {"address_zip": 2}},
 "empty_lists": {"state_address": 1},
 "records": [{"register": "state_address", "key": "adr_x", "unknown": ["address_zip"], "reads": 2}]}
  1. unknown_fields counts, per register and field path, the reads whose answer showed an unknown field. A field counts until a write changes it.
  2. empty_lists counts, per register, the reads that listed it and answered an empty list, which shows a scenario with too few records.
  3. records names each partial record with its unknown fields, its read count and any ids the simulator minted (minted).
  4. unsearched_reads counts reads whose answer was over 4 MiB, or held too many objects to compare.
  5. The route needs the state_view feature: Control plane reference.

Done with the Lob example: rystic stop scenarios.

Last updated on