# API reference: rollouts

Sim rollout jobs: watch a policy run in MuJoCo

## GET /v1/rollouts

`listRollouts` · scope `none` · List sim rollouts

Lists the rollouts the caller can see, newest first. Those are the ones they created, or whose model repo they can write (owner, or a member of the owning org). A rollout worker polls this with `status=queued` to find work. The model repo page lists a policy's past batteries with `model_repo=owner/slug`.

**Published sim tests.** With `published=true` the page lists, for anyone, the rollouts whose owner published them (`publishRollout`). It lists them only while the model repo and the robot repo are both public. Each one is the public view described under `getRollout`. This is the only form an anonymous caller may use. Without it, an anonymous call is `401`.

Parameters:

- `published` (query): `true` lists published sim tests of public policies, as anyone sees them, instead of the caller's own rollouts.
- `status` (query)
- `model_repo` (query): `owner/slug` of the model repo.
- `run_id` (query): Only rollouts attached to this run.
- `purpose` (query): Only `manual`, `gate`, `scan`, `render` or `predeploy` rollouts.
- `executor` (query): Only rollouts for this executor. `lucen rollout worker` polls `executor=worker` so it never claims one the hub sent to Modal.
- `physics` (query): Only sim tests run in this engine. A worker polls its own engine, so a MuJoCo worker never sees a PhysX sim test.
- `limit` (query): Page size.
- `cursor` (query): Opaque cursor from the previous page's `next_cursor`.

Responses:

- `200`: A page of rollouts.
- `401`: Missing or invalid credentials.
- `422`: Request failed validation.

## POST /v1/rollouts

`createRollout` · scope `key:train` · Create a sim rollout

Queues a sim rollout: load `model_repo`'s policy, run it on `robot_repo`'s MJCF in MuJoCo, and render a video and trajectory. Cost is capped by `horizon_s` ≤ 30 (CPU-only in v0).

**The gate.** A rollout is a *battery* of command cells × seeds (`battery`: `smoke` | `full` | an inline spec). Each cell is scored by the reference harness's own rule. A cell is PASS when every seed stays upright for the whole horizon AND every commanded axis tracks inside `[0.85, 1.15]`. The result is written as a `scorecard.json`. The Training Coach reads its PASS rows as standing constraints. Name a `run_id` and the terminal report also attaches that scorecard to the run (`Run.scorecard_key`). Then `POST /v1/coach/advice` on the run sees the gates without anyone copying anything. The 720p mp4 per cell is the by-product. Both repos must be visible to the caller. They must also be of the right kind: a model, and a robot whose card names an `mjcf_path`. An invisible repo is `404`, a wrong kind `409`, and an invisible `run_id` `422`.

Nothing executes server-side. The rollout waits `queued` until a rollout worker takes it through `claimRollout` / `presignRolloutArtifacts` / `reportRollout`. A rollout worker is `lucen rollout worker`, or `lucen rollout run --local` (which claims its own). A CPU rollout is unpriced (`cost_usd: 0`, `priced: false`).

**The reference harness, in the cloud.** The battery may be one of the harness's own (`c_matrix`, `robust`, `recovery`, `watch`). It may instead carry sim2sim conditions in `conditions`: delay, friction, kp/kd scale, push, power scale, heading, the bridge slew, jitter, a fallen start. Every cell's seed 0 is rendered from three fixed views. `executor: modal` has the hub spawn the deployed `rollout` function after the commit (`modal_call_id`). When the backend is not configured, the answer is `503` naming `MODAL_APP_NAME`, and nothing is recorded. `checkpoint_step` rolls out `checkpoints/step_<N>/` instead of the root policy.

**Hosted execution.** `executor: modal` runs on the hub's own Modal account. Its container claims the rollout with the operator's key. So it needs the model's owner in the deployment's `HOSTED_OWNERS` (default `lucen`; `*` = everyone) **and** write access to the model repo. Reading a public model is enough only for a `worker` rollout. Either refusal is `403` with `errors[].type: forbidden.hosted_owner` and records nothing.

**Pre-deploy checks.** `purpose: predeploy` asks the hub to check one policy file before it goes on a robot. The robot must be one of the deployment's pre-deploy robots (`PREDEPLOY_ROBOTS`, default `lucen/laika`). Reading a public policy is enough to ask. A private one needs write access. The hub reads the file's slot from its `lucen_manifest` and picks the test suite: `stand`, `loco` or `recovery`. When the manifest names no slot, `slot` is required (`422`). Only someone who can write the policy may give it. Such a check is that repo's report only. One whose slot came from the manifest is the report of the same bytes in any repo. It always runs on `modal` with full videos, and 5 seeds per test (`level: predeploy`) or 20 (`level: certification`, certifiers only). The platform account (`PREDEPLOY_PAYER`, default `lucen`) pays. Its spend cap and hosted allowance apply. When they refuse, a member of that account reads why (`429` or `403`). Anyone else gets `503` saying checks are paused, with `Retry-After`. The policy owner pays nothing. The suite, seeds, executor, horizon, video, seed, checkpoint and run are the hub's choice, so naming any of them is `422`. A check of the same sha256 on the same robot at the same level may already be queued, running or done. If the caller may already read it, the answer is `200` with that check. The same holds when it is published, or still running and will publish itself. Otherwise a new check starts. A failed or canceled one never answers. Each person may start `PREDEPLOY_DAILY_LIMIT` checks in any 24 hours. The next one is `429` with `errors[].type: quota.predeploy_daily` and `Retry-After`. At a limit of 0, checks are off (`503`). A check that was started on a public policy and a public robot, and succeeds while both are still public, is published. It cannot be unpublished while both stay public. Where the deployment turns it on, the hub also checks each new public policy file built for one of these robots by itself, once. Such a check names no creator.

Request body: `application/json`, required.

Responses:

- `200`: A pre-deploy check of the same file on the same robot at the same level is already queued, running or done, and this caller may be shown it. That check is returned and nothing new is queued. A caller who may read it gets the full view. Anyone else gets the public view of a check that is published or will publish itself.
- `201`: Rollout queued.
- `202`: Held for a person's confirmation. The key is marked as an AI agent's, and the work would spend beyond the free hosted allowance. Nothing started, and nothing is reserved yet. A person approves or denies the hold from the Inbox. Poll `getSpendHold` with the hold's id.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `409`: State conflict (duplicate handle/slug, wrong repo kind, terminal job, ...).
- `422`: Request failed validation.
- `429`: The paying account's spend cap is in `stop` mode and this job would carry the month past it (`errors[].type` is `quota.spend_cap`). Or the caller has started as many pre-deploy checks in the last 24 hours as the hub allows one person (`quota.predeploy_daily`). `Retry-After` says when to try again. Nothing was recorded.
- `503`: A service this endpoint needs is not configured in this deployment. The API boots with zero secrets. An endpoint that needs one says so instead of returning a stack trace.

## GET /v1/rollouts/{rollout_id}

`getRollout` · scope `none` · Get a sim rollout

Returns the rollout's status and, when it succeeded, the storage keys of the rendered video and trajectory. It also carries presigned 1-hour playback URLs (`video_url`, `traj_url`, `scorecard_url`, and one pair per cell). It includes the per-cell verdicts and the battery that was run. Visibility is the creator's, or anyone who can write the model repo.

**The public view.** Anyone, signed in or not, may also read a rollout its owner published (`publishRollout`). This holds only while the model repo and the robot repo are both public. That reader gets the result: the battery, the cells and their verdicts, the videos and trajectories through the same presigned URLs. The fields about how it ran are null: `run_id`, `logs_key`, `claimed_by`, `claimed_at`, `heartbeat_at`, `created_by`, `cost_usd`, `error`, `modal_call_id`, `dispatched_at`, `scan_id`, `render_of`, and `scorecard_key` / `scorecard_url`. (The scorecard file records the runner it ran on. Its verdicts are the cells'.) `engine` drops the runner's name (`worker`). Anything else is `404`. An unpublished rollout, a private model or robot, and a rollout published before its model went private all answer the same.

`four_gates` scores the four gates on this test. With `baseline`, gate 4 compares with that test, which the caller must also be able to read.

Parameters:

- `rollout_id` (path, required): Rollout id (`rollout_...`).
- `baseline` (query): A rollout to compare with for gate 4, on the same command cells. An unknown or invisible one is `422`.

Responses:

- `200`: The rollout.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).

## POST /v1/rollouts/{rollout_id}/claim

`claimRollout` · scope `key:train` · Claim a queued rollout (rollout worker protocol)

Compare-and-set `queued → running`, exactly like `claimRun`. One caller wins, and everyone else gets `409` naming the holder. Records `claimed_by`, `claimed_at`, `started_at`, `heartbeat_at`, **the claiming credential** and an audit row. `presignRolloutArtifacts` and `reportRollout` are `409` from any other credential, so use one key per worker. Returns the rollout with its resolved `battery_spec`: the cells, seeds and horizon the worker must execute. The worker pulls the model and robot repos next: the policy ONNX and its `io_contract`, the MJCF and its meshes. `key:train`: a worker spends compute on the creator's behalf. No lease: a dead worker leaves the rollout `running` until a human acts.

Parameters:

- `rollout_id` (path, required): Rollout id (`rollout_...`).

Request body: `application/json`, required.

Responses:

- `200`: Claimed; the rollout as it now stands.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `409`: State conflict (duplicate handle/slug, wrong repo kind, terminal job, ...).
- `422`: Request failed validation.

## POST /v1/rollouts/{rollout_id}/artifacts

`presignRolloutArtifacts` · scope `key:train` · Presign uploads for a running rollout's artifacts

Bytes never stream through the API, and a battery's videos are megabytes each. So a worker asks for presigned PUT URLs here and uploads straight to object storage. It writes one object per artifact under `rollouts/{rollout_id}/…`. That prefix is outside the content-addressed `blobs/` prefix the blob GC sweeps. Names are repo-style relative paths (`cells/vx-plus-0p30/video.mp4`, `cells/vx-plus-0p30/trajectory.json`, `trajectory.json`). The keys returned are what `reportRollout` then names in `cells[]`. Only a `running` rollout may presign, and only the credential that claimed it (`409` otherwise). URLs live 1 h.

**Storage.** The declared sizes count toward the rollout creator's storage quota (`STORAGE_QUOTA_BYTES`, the same 50 GiB as repo files). A request over it gets `413`, and no URL is issued.

Parameters:

- `rollout_id` (path, required): Rollout id (`rollout_...`).

Request body: `application/json`, required.

Responses:

- `200`: One presigned PUT per requested artifact.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `409`: State conflict (duplicate handle/slug, wrong repo kind, terminal job, ...).
- `413`: The rollout creator's storage quota would be exceeded.
- `422`: Request failed validation.

## POST /v1/rollouts/{rollout_id}/report

`reportRollout` · scope `key:train` · Report progress or the result of a claimed rollout

The worker's one write path after `claimRollout`. The rollout must be `running` and the caller must be the credential that claimed it (`409` otherwise). Every field is optional:

- `log_chunk` (≤ 256 KiB) is stored as one object under `rollouts/{id}/logs/`.
- `cells[]` carries the **measurements**: seeds run, seeds that stayed upright, the tracking ratio per commanded axis, and the artifact keys presigned earlier.
- `warnings[]` / `engine` say what the worker could not do (a missing renderer, an unsupported observation).

**The hub scores the rollout.** The worker sends measurements and does not score them. A `succeeded` report whose `engine.policy_sha256` is not the sha256 the rollout was created against is `409`. On a terminal `succeeded` report the hub:

- applies the harness rule to the measurements
- writes `scorecard.json`, with `gates` in the shape `coach/gates.py` reads and names that survive its normalisation (`vy+0.10` and `vy-0.10` stay distinct)
- sets `scorecard_key` / `video_key` / `traj_key`
- records `cost_usd` 0 (`priced: false`)
- when the rollout carries a `run_id`, copies the scorecard to `runs/{run_id}/scorecard.json`, sets `Run.scorecard_key` and writes a `run.scorecard` audit row

`status` may only move `running → succeeded | failed`. A key named in `cells[]` that is not under this rollout's prefix, or that holds no object, is `422`.

Parameters:

- `rollout_id` (path, required): Rollout id (`rollout_...`).

Request body: `application/json`, required.

Responses:

- `200`: Recorded; the rollout as it now stands.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `409`: State conflict (duplicate handle/slug, wrong repo kind, terminal job, ...).
- `413`: A log chunk or the report body is over its size limit, or the log chunk puts the rollout creator past their storage quota.
- `422`: Request failed validation.

## POST /v1/rollouts/{rollout_id}/cancel

`cancelRollout` · scope `key:train` · Cancel a sim rollout

A `queued` or `running` rollout becomes `canceled` in this request. A `modal` rollout's call is terminated first (`502` if Modal refuses, and nothing changes). A `worker` rollout's worker is told on its next report, which is `409`. A rollout keeps no lease, so there is no flag to wait on. Nothing is billed either way (CPU rollouts are unpriced). A terminal rollout is `409`. Writes a `rollout.cancel` audit row.

Parameters:

- `rollout_id` (path, required): Rollout id (`rollout_...`).

Responses:

- `202`: Canceled; the rollout as it now stands.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `409`: State conflict (duplicate handle/slug, wrong repo kind, terminal job, ...).
- `502`: Modal refused to terminate the call; nothing changed.

## POST /v1/rollouts/{rollout_id}/render

`renderRollout` · scope `key:train` · Render an earlier rollout's videos

A gate while training renders at most a poster per cell (`video: poster` or `none`). This call queues the videos afterwards. The new rollout (`purpose: render`, `render_of` = this one) runs with `seeds: 1` and `video: full` (or `poster`). It uses the same model repo, checkpoint, robot, battery conditions and seed. So seed 0 of each chosen cell is simulated again and rendered. The engine is deterministic for a seed, and the hub checks the replay against the measured episode (`render_check`). The new rollout carries the source's `run_id`. It never counts as a gate, a scan or the run's scorecard. It is unpriced like any CPU rollout. The source must be `succeeded` (`409` otherwise). A cell name the source battery does not have is `422`. Same executor rules as `createRollout`.

**Hosted execution.** `executor: modal` runs on the hub's own Modal account. Its container claims the rollout with the operator's key. So it needs the model's owner in the deployment's `HOSTED_OWNERS` (default `lucen`; `*` = everyone) **and** write access to the model repo. Reading a public model is enough only for a `worker` rollout. Either refusal is `403` with `errors[].type: forbidden.hosted_owner` and records nothing.

Parameters:

- `rollout_id` (path, required): Rollout id (`rollout_...`).

Request body: `application/json`.

Responses:

- `201`: The render rollout, queued.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `409`: State conflict (duplicate handle/slug, wrong repo kind, terminal job, ...).
- `422`: Request failed validation.
- `503`: A service this endpoint needs is not configured in this deployment. The API boots with zero secrets. An endpoint that needs one says so instead of returning a stack trace.

## GET /v1/rollouts/{rollout_id}/score

`scoreRollout` · scope `none` · Score a finished sim test, optionally with custom thresholds

Re-scores what the sim test measured. It runs nothing and writes nothing. With no query parameters it applies the hub's own rule, the one that scored the sim test. It returns every test's metric, threshold and measured value. Each query parameter replaces one threshold for this answer only; `custom` is then true. The stored scorecard, the run's gates and the consent checks keep the hub's thresholds. A test is `pass` when every check is met. It is `fail` when a measured value misses its threshold. It is `inconclusive` when nothing failed but a value the rule needs was not measured. The hub's stored verdict counts an inconclusive test as a fail. Visible exactly when `getRollout` is. So anyone can score a sim test published with a public policy. Anything else is `404`. A sim test that has not finished scores no test.

Parameters:

- `rollout_id` (path, required): Rollout id (`rollout_...`).
- `tracking_min` (query): Lowest tracking ratio, measured over commanded speed, that passes. The hub uses 0.85.
- `tracking_max` (query): Highest tracking ratio that passes. The hub uses 1.15.
- `upright_min` (query): Share of seeds that must stay upright for the whole test. The hub uses 1, every seed.
- `tolerance_rad` (query): Settle error that passes a joint-target or fixed-base test, in radians. The hub uses the test's own tolerance, else 0.10.
- `tolerance_m` (query): Settle error that passes a reach test, in metres. The hub uses the test's own tolerance, else 0.05.
- `tilt_max_deg` (query): Largest base tilt a stand test allows, median over seeds, in degrees.
- `asym_max_deg` (query): Largest left/right joint asymmetry a stand test allows, median over seeds, in degrees.
- `drift_max_m` (query): Largest drift across the floor a stand test allows, median over seeds, in metres.
- `recovery_min` (query): Share of fallen starts that must stand up. The hub uses the test's own bar, else 0.9.
- `recovery_time_max_s` (query): Longest median stand-up time that passes, in seconds. The hub uses 5.
- `refall_max` (query): Largest share of stood-up seeds that may fall again. The hub uses 0.1.
- `torque_max` (query): Largest median peak torque demand, as a share of each joint's limit. The hub uses 0.9.

Responses:

- `200`: Every test of the sim test, scored.
- `401`: Missing or invalid credentials.
- `404`: Resource not found (or hidden from the caller).
- `422`: Request failed validation.

## PUT /v1/rollouts/{rollout_id}/publish

`publishRollout` · scope `key:write` · Publish or unpublish a sim rollout

Sets whether a rollout is published with its policy. A published rollout is readable by anyone through `getRollout` and `listRollouts?published=true`. That holds while the model repo and the robot repo are both public. Making either private hides it again, and making it public shows it again. `published_at` records when.

Only someone who can write the model repo may do this (`403` otherwise, for a caller who can see the rollout). The rollout must have `succeeded` and must test the policy itself rather than a checkpoint (`409` otherwise). A published pre-deploy check of a public policy on a public robot cannot be unpublished (`409`). Its report belongs to the file. Making the policy private hides it. Setting the value it already has changes nothing, so unpublishing one that is not published is `200`. Writes a `rollout.publish` or `rollout.unpublish` audit row.

Parameters:

- `rollout_id` (path, required): Rollout id (`rollout_...`).

Request body: `application/json`, required.

Responses:

- `200`: The rollout as it now stands.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `409`: State conflict (duplicate handle/slug, wrong repo kind, terminal job, ...).
- `422`: Request failed validation.

## GET /v1/runs/{run_id}/gates

`getRunGates` · scope `key:read` · The sim gates a run's checkpoints got while it trained

Step × cells × verdict for the `gate` rollouts the hub queued from the run's `Recipe.gate`, oldest step first. The answer also lists every checkpoint step the output repo holds. It carries the tripwire state: which rule fired, at which step, on which rollout. A run with no gate answers an empty table. Each row says what its gate rendered (`video`). When the gate rendered posters, the row carries a presigned poster per cell and one for the row. Each row also carries the latest `renderRollout` of it.

Parameters:

- `run_id` (path, required): Training run id (`run_...`).

Responses:

- `200`: The gate table.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).

## GET /v1/runs/{run_id}/scan

`getRunScan` · scope `key:read` · A band scan's table

Step × cells × verdict for the run's latest band scan (or `scan_id`), oldest step first. An empty table when the run was never scanned.

Parameters:

- `run_id` (path, required): Training run id (`run_...`).
- `scan_id` (query)

Responses:

- `200`: The scan table.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).

## POST /v1/runs/{run_id}/scan

`scanRun` · scope `key:train` · Band-scan a run's checkpoints in simulation

One rollout per `checkpoints/step_<N>/` of the run's output model repo in the requested band, all under one `scan_id`. Each rollout runs `battery` × `seeds` (default `watch` × 20) on `robot_repo` (default `recipe.robot`). The default uses 20 seeds because a few seeds differ between machines. `409` when the run has no output repo or no checkpoint in the band. `422` for a band with more than 50 checkpoints. Same executor rules as `createRollout`.

**Hosted execution.** `executor: modal` runs on the hub's own Modal account. Its container claims the rollout with the operator's key. So it needs the model's owner in the deployment's `HOSTED_OWNERS` (default `lucen`; `*` = everyone) **and** write access to the model repo. Reading a public model is enough only for a `worker` rollout. Either refusal is `403` with `errors[].type: forbidden.hosted_owner` and records nothing.

Parameters:

- `run_id` (path, required): Training run id (`run_...`).

Request body: `application/json`, required.

Responses:

- `201`: The scan's rollouts, queued.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `409`: State conflict (duplicate handle/slug, wrong repo kind, terminal job, ...).
- `422`: Request failed validation.
- `429`: The account's spend cap is in `stop` mode, and this job would carry the month past it. The month counts recorded Lucen cloud spend, what queued and running cloud work could still cost, and this job's own most possible cost. `errors[].type` is `quota.spend_cap`. `Retry-After` counts the seconds until the month ends. Nothing was recorded, and work already running keeps running.
- `503`: A service this endpoint needs is not configured in this deployment. The API boots with zero secrets. An endpoint that needs one says so instead of returning a stack trace.
