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 pathReturns
POST /replay-checks201 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
}
FieldTypeDefaultDescription
lineIdstringrequiredThe line the station is on.
stationKeystringrequiredThe station the change plans, by its key.
stationobjectrequiredThe station block as the plan would apply it, in the shape of one entry of a line's stations.
lineobjectnoneThe 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.secretsstring[]noneThe names of the workspace secrets the plan creates, changes or deletes.
changed.skillsstring[]noneThe keys of the team's skills the plan changes.
changed.harnessProfilesstring[]noneThe keys of the team's harness profiles the plan changes.
changed.integrationsobject[]noneThe 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.hooksobject[]noneThe 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.commitstringnoneThe commit that plans the change, a hex sha of 7 to 64 characters.
reference.pullRequestnumbernoneThe pull request that plans the change.
repeatsnumber1How many times the check replays each run of the set, 1 to 5. The line's ceiling covers every repeat.

The check:

  1. Reads replay_check from the line as it is applied, never from the plan.
  2. Replaces the planned block's check, judge, diffs and runners with the live station's, and records in scoringPinnedToLive each one the plan changed.
  3. Checks the block as the line would be with the station replaced, by every rule of spotlight_line, each problem at its path under station.
  4. Reuses a search's replays of the same config, when there are some. See Search replays.
  5. Replays it, under the planned repositories, images and setup commands, on every other run of the station's set, repeats times, 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 as repeats, 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 repeats as 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 from repeats to 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

FieldTypeDescription
id, teamId, lineId, stationId, stationKeystring
setIdstringThe replay set Spotlight keeps for the station.
candidateIdstringThe planned candidate.
replayIdstring or nullThe replay of the planned change on the runs that no reused search replay covers. Null when reused search replays cover every run.
reusedReplayIdsarrayThe search replays the check takes as its result on their runs. Empty when it reuses none. See Search replays.
baselineReplayIdstring or nullThe replay of the live config it is compared with. Null while it is being started.
attemptnumberCounts checks of the same change against the same live config, from 1.
referenceobject{ commit, pullRequest }.
liveFingerprint, candidateFingerprintstringThe config fingerprints of the live and planned station.
scoringPinnedToLivearray of stringsWhat the plan changed of check, judge, diffs and runners, which the check pinned to the live station's values.
thresholdobject{ 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.
repeatsnumberHow many times the check replays each run of the set.
gainobject or nullThe 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.
resultstringSee Results.
undecidedBecausestring or nullSee Results.
failedBecausestring or nulltoo-many-regressions. Null unless result is failed. See Results.
taskCountnumberHow many tasks the set replays.
comparednumberHow many were scored on both sides.
candidate, baselineobjectEach { 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.
usageChangeobject 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.
tasksarrayEach task of the set, the regressed tasks first: { taskId, originalRunId, title, regressed, live, candidate }. See Task rows.
reusedbooleantrue when starting a check answered one this change already had. Always false on a read.
createdAtstringAn RFC 3339 time.

Run usage

usage is { runs, pricedRuns, totalCost, meteredCost, tokens, ms }, or null once the replay is gone:

FieldTypeDescription
runsnumberThe side's ended runs whose usage is recorded, runs whose usage is unknown included.
pricedRunsnumberThe side's runs priced in that side's replay currency. totalCost and meteredCost are the mean of these runs.
totalCostobject or nullThe 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.
meteredCostobject or nullThe mean cost of a run's metered tool calls, such as the model calls of a hook.
tokensnumber or nullThe mean harness tokens of a run that reported them: input, output and cache tokens. Tool calls' tokens are not counted.
msnumber or nullThe 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:

FieldTypeDescription
resultstringsucceeded 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.
successRatenumber or nullThe share of the scored repeats that succeeded, from 0 to 1.
reasonstringWhy 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:

CodeReads
unreplayableSpotlight could not replay or start the run
not-runThe run did not start
run-failedThe run failed
run-stoppedThe replay stopped before the run finished
asked-a-personThe run asked a person, and a replay cannot answer
check-failedChecks failed
check-skippedChecks could not run
change-not-generatedSpotlight could not make the change
no-changeThe run changed no files for the checks
no-change-stackThe change did not get to Spotlight
judgedJudge passed it
judge-failedJudge failed it
unjudgedJudge 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

ResultWhen
failedMore tasks regressed than maxRegressions allows. See failedBecause below.
runningThe change's replay or its baseline is queued or running, or the baseline is still being started.
undecidedSee below.
passedNone of the above.
undecidedBecauseWhen
replay-goneThe change's replay is gone.
stoppedThe change's replay was stopped.
over-ceilingThe change's replay reached its ceiling.
no-baselineThere is no replay of the live config to compare with.
baseline-unfinishedThe live config's replay did not finish.
too-few-scoredFewer than half the tasks were scored on both sides.
failedBecauseWhen
too-many-regressionsMore 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

StatusCause
401No session or token, or an unknown token.
403A change by a caller who may read the team but not plan.
404The team, line, station or check is not one the caller may see, as in Replay check <checkId> not found.
409A 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.
422The 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.

On this page