Replay checks API
A replay check replays a planned change of a work station on the
replay set Spotlight keeps for the
station, compares it with the live config, and
gives a result under the line's replay_check.
spotlight replay check
calls these endpoints from CI. They sit under /api/teams/{teamId}, answer
JSON, and answer errors as application/problem+json, as on the
resource API.
Endpoints
| Method and path | Returns |
|---|---|
POST /replay-checks | 201 and a check, or 200 and the check this change already has. See Start a check. Requires Idempotency-Key. |
GET /replay-checks/{checkId} | A check and its result. |
Start a check
{
"lineId": "<line id>",
"stationKey": "build",
"station": {
"key": "build",
"name": "Build",
"kind": "work",
"harness": "claude-code",
"prompt": "Build it, then drain the queue.",
"passesTo": ["ship"]
},
"line": {
"repositories": [{ "name": "acme/api", "setup": "npm ci" }]
},
"reference": { "commit": "4f7c2a9e1b3d", "pullRequest": 42 },
"repeats": 1
}| Field | Type | Default | Description |
|---|---|---|---|
lineId | string | required | The line the station is on. |
stationKey | string | required | The station the change plans, by its key. |
station | object | required | The station block as the plan would apply it, in the shape of one entry of a line's stations. |
line | object | none | The line's repositories as the plan would apply them, each with its image and setup, as { "repositories": [...] }. At most 64,000 characters. Without it, the live line's. |
changed.secrets | string[] | none | The names of the workspace secrets the plan creates, changes or deletes. |
changed.skills | string[] | none | The keys of the team's skills the plan changes. |
changed.harnessProfiles | string[] | none | The keys of the team's harness profiles the plan changes. |
changed.integrations | object[] | none | The team's integrations the plan changes, each as { "key", "definition" }: its key and its definition as planned, or null when the plan deletes it. |
changed.hooks | object[] | none | The team's hooks the plan changes, each as { "key", "lines", "stations", "definition", "removed" }: its key, the lines and stations it matches as planned (an empty list matches every line or station), its definition as the plan would apply it, in the shape the hook resource stores, and removed: true when the plan deletes it. Leave definition out when the plan removes the hook or Terraform knows it only after apply. A hook may not have both. |
reference.commit | string | none | The commit that plans the change, a hex sha of 7 to 64 characters. |
reference.pullRequest | number | none | The pull request that plans the change. |
repeats | number | 1 | How many times the check replays each run of the set, 1 to 5. The line's ceiling covers every repeat. |
The check:
- Reads
replay_checkfrom the line as it is applied, never from the plan. - Replaces the planned block's
check,judge,diffsandrunnerswith the live station's, and records inscoringPinnedToLiveeach one the plan changed. - Checks the block as the line would be with the station replaced, by every
rule of
spotlight_line, each problem at its path understation. - Reuses a search's replays of the same config, when there are some. See Search replays.
- Replays it, under the planned repositories, images and setup commands, on
every other run of the station's set,
repeatstimes, on the team's runners. When the check reuses no search replays and the set has no baseline of the current live config with at least three repeats, and at least as many asrepeats, it also starts a baseline replay of the live config with that many repeats. See Ceiling.
A change that changes nothing about how the station's runs go fails with
409 and the type urn:spotlight:problem:nothing-to-replay.
When the station depends on something in changed, the check starts no
replay and fails with 409 and the type
urn:spotlight:problem:dependency-changed, since a replay uses only what is
live. A station depends on the harness profile and the skills it names, on an
integration whose tools its runs get (through the station, a skill it names or
a mark), on a hook that may fire at it as live or as planned, on an
integration such a hook calls, on an integration whose planned definition
enables tools on marks or cannot be read, and on a secret that any of these use. Both the
live station and the planned one count.
A changed hook is the one exception when it is on run.starting and its steps
all call read-only tools, both as live and as planned. A hook the plan adds
has no live side, and a hook it removes has no planned side. The check then
replays the change: the candidate's replay runs the hook as planned, and the
baseline runs the live hooks. A planned hook definition that does not compile
fails with 422, each problem at its path under hooks/<key>. A changed hook sent
without its definition and not marked removed cannot be replayed.
A change already checked is answered with that check, 200 and reused: true, while the earlier check is running, passed or failed, and only if it
replayed the same runs of the set against the same live config, the same
threshold, the same scoring and the same repeats. When search replays of the
change are there, the earlier check must also reuse search replays. Otherwise a new check starts, with the next
attempt. A repeated request with the same Idempotency-Key answers 201
with the check it started and the header Idempotent-Replayed: true.
How a config runs includes the live run.starting hooks that reach the
station, and for the planned change, those hooks as the plan changes them. So
when a live run.starting hook at the station changes, an earlier check or an
earlier search replay is not reused.
Search replays
A search replays each candidate on its searched and its held-out tasks, and compares it with its seed. When a check's planned change runs and is scored as a search's candidate, the check takes these replays as its result on their runs. Its baseline is the seed of that search. So the check reads the same task results as the search on these runs, and does not replay them again.
A check reuses a search's replays when all of these are true:
- each replay finished, with the same
repeatsas the check; - the seed finished, replayed the current live config with at least as many repeats as the check, and covers every run of the set;
- the replays are of a config that runs and is scored as the planned change.
When replays compared with more than one seed apply, the check takes the seed
whose replays cover the most runs, the newest seed on a tie, and of its
replays the newest one of each run. It
replays the runs that no reused replay covers, against the same seed. When the
reused replays cover every run, replayId is null and the check starts no
replay.
Ceiling
The line's replay_check.ceiling caps each replay a check starts, each on its
own:
- the replay of the planned change, on the runs that no reused search replay covers;
- the baseline replay of the live config, only when the check reuses no search
replays and the station's set has no baseline for the current live config
with at least three repeats of each run, and at least as many as
repeats. Its ceiling is the line's ceiling scaled fromrepeatsto its own repeats, up to 1,000. A baseline already there costs the check nothing.
Reused search replays cost the check nothing, and the check's spent does not
include them. A run whose cost is not reported, or is in
another currency, counts as the ceiling divided by the number of runs in the
set times repeats: threshold.unpricedRun. When a replay reaches its ceiling, no more of its
runs start, and runs already running finish, so it can end a little over. A
check whose replay reached its ceiling is undecided, over-ceiling, unless
it has already failed.
The check replays a candidate Spotlight names Planned change, PR #<n>, or
after the commit's first 7 characters, or the date.
Check
| Field | Type | Description |
|---|---|---|
id, teamId, lineId, stationId, stationKey | string | |
setId | string | The replay set Spotlight keeps for the station. |
candidateId | string | The planned candidate. |
replayId | string or null | The replay of the planned change on the runs that no reused search replay covers. Null when reused search replays cover every run. |
reusedReplayIds | array | The search replays the check takes as its result on their runs. Empty when it reuses none. See Search replays. |
baselineReplayId | string or null | The replay of the live config it is compared with. Null while it is being started. |
attempt | number | Counts checks of the same change against the same live config, from 1. |
reference | object | { commit, pullRequest }. |
liveFingerprint, candidateFingerprint | string | The config fingerprints of the live and planned station. |
scoringPinnedToLive | array of strings | What the plan changed of check, judge, diffs and runners, which the check pinned to the live station's values. |
threshold | object | { maxRegressions, minGain, ceiling, unpricedRun }, from the live line when the check started. minGain is its replay_check.min_gain; ceiling caps each replay of the check; unpricedRun is what an unpriced run counts against it, or null once the replay is gone. |
repeats | number | How many times the check replays each run of the set. |
gain | object or null | The candidate's gain in success over the baseline, { gain, low, high, significance, minGain, tasks }: the gain and its 95% interval as shares, better, worse or within-noise as in Gains, the line's min_gain, and the tasks scored on both sides. It does not decide result. Null with no baseline or no replay, and while no task was scored on both sides. |
result | string | See Results. |
undecidedBecause | string or null | See Results. |
failedBecause | string or null | too-many-regressions. Null unless result is failed. See Results. |
taskCount | number | How many tasks the set replays. |
compared | number | How many were scored on both sides. |
candidate, baseline | object | Each { state, entries, scored, succeeded, successRate, interval, tasksScored, spent, usage, skippedHooks }. state is the replay's state, queued, running, finished, stopped or ceiling-reached, or null once it is gone. entries, scored and succeeded count repeats; successRate is the share of scored repeats that succeeded, interval its 95% interval { low, high }, and tasksScored counts tasks with a scored repeat. usage and skippedHooks are in Run usage. |
usageChange | object or null | { totalCost, meteredCost, tokens, ms }: the candidate's mean run less the baseline's, negative where the candidate uses less. totalCost and meteredCost are { amount, currency }, each null unless both sides have it in the same currency and every run of each side's usage has a known price, with pricedRuns equal to runs. Otherwise the two means would cover different runs. Null without a baseline. It does not decide result. |
tasks | array | Each task of the set, the regressed tasks first: { taskId, originalRunId, title, regressed, live, candidate }. See Task rows. |
reused | boolean | true when starting a check answered one this change already had. Always false on a read. |
createdAt | string | An RFC 3339 time. |
Run usage
usage is { runs, pricedRuns, totalCost, meteredCost, tokens, ms }, or null
once the replay is gone:
| Field | Type | Description |
|---|---|---|
runs | number | The side's ended runs whose usage is recorded, runs whose usage is unknown included. |
pricedRuns | number | The side's runs priced in that side's replay currency. totalCost and meteredCost are the mean of these runs. |
totalCost | object or null | The mean cost of a priced run, { amount, currency }, in that side's replay currency: what the harness cost plus what metered tool calls cost, when both are known and in one currency. |
meteredCost | object or null | The mean cost of a run's metered tool calls, such as the model calls of a hook. |
tokens | number or null | The mean harness tokens of a run that reported them: input, output and cache tokens. Tool calls' tokens are not counted. |
ms | number or null | The mean wall time of a run that reported it, in milliseconds. |
skippedHooks lists each run.starting hook that the side's replay runs did
not run, as { hook, because }, such as
{ "hook": "ticket", "because": "Step open calls linear.create-issue, which is not read-only." }.
A replay runs only hooks whose steps all call read-only tools that need no
approval and do not act as the person who started a task. It skips a
broken hook, even one whose failure is block, with
The hook is broken. Reason: <reason>. See
Replay runs.
Task rows
Each item of tasks gives the task's title (null once the task is deleted),
regressed, true when the candidate did worse than the live config on the
task as in Regressions, and one side
each for the live config and the candidate:
| Field | Type | Description |
|---|---|---|
result | string | succeeded or failed when every repeat agrees; mixed when the repeats disagree; unscored when nothing scored the run; pending while the replay runs; absent when the side did not replay the task. |
successRate | number or null | The share of the scored repeats that succeeded, from 0 to 1. |
reason | string | Why the side got its result, in one line of at most 200 characters, as in Judge failed it: The tests do not cover the new branch. |
reason is one result reason of a
repeat that shows the side's result: a failed repeat for failed and mixed.
It reads the reason, then a colon and its detail when it has one:
| Code | Reads |
|---|---|
unreplayable | Spotlight could not replay or start the run |
not-run | The run did not start |
run-failed | The run failed |
run-stopped | The replay stopped before the run finished |
asked-a-person | The run asked a person, and a replay cannot answer |
check-failed | Checks failed |
check-skipped | Checks could not run |
change-not-generated | Spotlight could not make the change |
no-change | The run changed no files for the checks |
no-change-stack | The change did not get to Spotlight |
judged | Judge passed it |
judge-failed | Judge failed it |
unjudged | Judge could not judge it |
Without a reason, it reads Checks passed., The run failed., The repeats did not agree., Nothing scored the run., The replay has not finished. or
Not replayed., by result. The same rows make up the task-by-task table of
spotlight replay check and of a
config pull request.
Results
| Result | When |
|---|---|
failed | More tasks regressed than maxRegressions allows. See failedBecause below. |
running | The change's replay or its baseline is queued or running, or the baseline is still being started. |
undecided | See below. |
passed | None of the above. |
undecidedBecause | When |
|---|---|
replay-gone | The change's replay is gone. |
stopped | The change's replay was stopped. |
over-ceiling | The change's replay reached its ceiling. |
no-baseline | There is no replay of the live config to compare with. |
baseline-unfinished | The live config's replay did not finish. |
too-few-scored | Fewer than half the tasks were scored on both sides. |
failedBecause | When |
|---|---|
too-many-regressions | More tasks regressed than maxRegressions allows. Decided as soon as it happens. Spotlight stops the check's replay when the next of its runs ends, and its runs that have not started do not start. A task counts only once each of its repeats, on both sides, has ended. |
Who may read and change
Reading needs a person on the team or an owner or admin of its workspace, or a
workspace token of the team's workspace
with the read scope. Anyone else is answered 404. Starting a check also
needs plan. See
Team outcomes.
Starting a check is recorded as a
configuration change
of the kind replay-check.
Errors
| Status | Cause |
|---|---|
401 | No session or token, or an unknown token. |
403 | A change by a caller who may read the team but not plan. |
404 | The team, line, station or check is not one the caller may see, as in Replay check <checkId> not found. |
409 | A line with no replay_check (Line <lineKey> has no replay_check block. Please add one with max_regressions, ceiling and currency.). A station with no runs to replay, no-runs-to-replay: a station with no replay set yet, or whose set's station has left its line (Station <stationKey> has no replay set yet. Spotlight keeps one after a run of the station ends.), or whose set has no runs (Station <stationKey> has no runs in its replay set yet.). A change with nothing to replay, nothing-to-replay: There is nothing to replay. The plan changes nothing that affects how the station's runs go., or There is nothing to replay. A check pins these changed fields to their live values: <fields>. A change of something the station depends on, dependency-changed: Spotlight cannot decide this change. The plan also changes <changes>, which the station depends on, and a replay uses only the live ones. |
422 | The planned block is not one the line takes, each problem at its path under station. A missing lineId (Line ID must name the line of the station.) or stationKey (Station key must be the key of the planned station.), or a reference, line or changed not in its form (each list under changed: Must be a list of keys.; a hook with no key: Must be the key of the hook.; an integration's definition larger than 16 KiB as JSON: Must be at most 16 KiB as JSON.). repeats not a number (Repeats must be a number.) or out of range (Replay check repeats must be from 1 to 5.). The 409 causes are checked before repeats, so a check of a line with no replay_check, of a station with no set or an empty set, or with nothing to replay answers 409 whatever its repeats. A planned block the line does not take answers this 422 before no-runs-to-replay, as do nothing-to-replay and dependency-changed, so a new station's problems are named even before it has runs. |