spotlight replay
spotlight replay check checks the station changes in a Terraform plan
against the replay set
Spotlight keeps for each station, through the
Replay checks API. It is part of the
spotlight binary; see
The spotlight command.
Synopsis
spotlight replay check [--json] [--timeout 60m] [--every 15s] [--commit <sha>] [--pull-request <n>] [--repeats 1] <plan.json | ->Flags may come before or after the argument. spotlight replay alone prints
its help, as spotlight help replay does.
Install
spotlight replay check needs only the spotlight binary, not a host. The
install script without arguments
installs only the binary:
curl -fsSL https://app.usespotlight.ai/api/install.sh | shIn CI, or to check the file yourself, download the binary from the release:
<os> | <arch> |
|---|---|
linux or darwin | amd64 or arm64 |
curl -fsSL -o spotlight https://github.com/usespotlightai/spotlight/releases/latest/download/spotlight-<os>-<arch>
curl -fsSL -o spotlight.sha256 https://github.com/usespotlightai/spotlight/releases/latest/download/spotlight-<os>-<arch>.sha256Compare the file's SHA-256 with spotlight.sha256, then make it executable
with chmod +x spotlight. For a given release, replace latest/download with
download/<version>.
spotlight replay check
Checks each work station a saved Terraform plan changes against the replay set
Spotlight keeps for the station, under the live line's
replay_check, and waits
for the results. Give it the output of terraform show -json <planfile>, or
- to read it from standard input. Spotlight never runs Terraform. See
Check Terraform pull requests for station regressions.
| Flag | Default | Description |
|---|---|---|
--json | Prints the report as JSON in place of the text. | |
--timeout | 60m | How long to wait for the checks, as a Go duration, above 0. A check still running then keeps running in Spotlight. |
--every | 15s | How often to read the checks, as a Go duration, at least 1s. |
--commit | none | The commit that plans the change, recorded on each check. |
--pull-request | none | The pull request that plans the change, recorded on each check and used to name its candidate. |
--repeats | 1 | How many times each check replays each run of the set, 1 to 5. The line's ceiling covers every repeat. |
Environment
| Variable | Description |
|---|---|
SPOTLIGHT_URL | The Spotlight address. Without it, the address of your one login, else https://app.usespotlight.ai. Required with SPOTLIGHT_API_TOKEN or SPOTLIGHT_OIDC_TRUST. |
SPOTLIGHT_API_TOKEN | A workspace token with plan. Used in place of a trust when both are set. |
SPOTLIGHT_OIDC_TRUST | The id of an OIDC trust that grants plan. The command exchanges the job's OIDC token through it for a short-lived workspace token, exchanges again before that token expires, and once more on a 401. |
SPOTLIGHT_OIDC_TOKEN | The OIDC token to exchange. Without it, the command requests one from GitHub Actions, through ACTIONS_ID_TOKEN_REQUEST_URL and ACTIONS_ID_TOKEN_REQUEST_TOKEN, which need permissions: id-token: write. |
SPOTLIGHT_OIDC_AUDIENCE | The audience to request the OIDC token for. Default spotlight. Must equal the trust's audience. |
GITHUB_STEP_SUMMARY | When set, a Markdown summary is appended to the file it names. |
Without SPOTLIGHT_API_TOKEN and SPOTLIGHT_OIDC_TRUST, the command uses the
login that spotlight login
keeps for SPOTLIGHT_URL. Credentials are read only when the plan has a station
to check.
What it checks
The command reads every managed spotlight_line of the provider
usespotlightai/spotlight that the plan updates, and compares each station's
block before and after. A work station whose block changes, or whose line's
repositories change, is checked: its planned block, and the planned
repositories with their image and setup, are sent to Spotlight. Each is
named by the line's address and the station's key, as in
core/delivery/build.
Some changes are not checked, and are printed as notes:
| Note | Cause |
|---|---|
<resource> is a new line, with no live stations to check a change against | The plan creates the line. |
<resource> is replaced, so its stations start anew, with no live config to check a change against | The plan replaces the line. Each of its work stations is also reported UNDECIDED. |
<resource> is removed, so there is nothing of it to check | The plan deletes the line. |
<resource> has stations known only after apply, so none is checked | The line's stations are unknown until apply. |
<resource> removes station <key>, which leaves nothing to replay | A station is removed. |
<resource> adds station <key>, with no live config to check it against | A station is added. If the plan also removes a work station of the line, an added work station is also reported UNDECIDED. |
<resource> has a station whose key is known only after apply, so it is not checked | A station's key is unknown until apply. |
<resource> changes station <key>, where nothing runs, so there is nothing to replay | A backlog or completed station changes. |
A station is reported UNDECIDED without being checked when:
| Message | Cause |
|---|---|
not checked, since the plan replaces its line, so it starts with no live config to check it against | The plan replaces its line. |
not checked, since the plan removes <keys> and adds this station, which may be a station renamed; a renamed station starts with no live config to check it against | The plan removes a work station of the line and adds this one. A changed station key is planned this way. |
not checked, since Terraform knows its <attributes> only after apply | Part of the station, or the line's repositories, is known only after apply. |
not checked, since the plan also changes the <resources>, which Terraform names only after apply, so Spotlight cannot tell whether its runs depend on it | The plan changes a spotlight_skill, spotlight_harness_profile, spotlight_integration or spotlight_hook of the station's team, or a spotlight_secret, whose key, name or team, a hook's match or an integration's definition, Terraform knows only after apply. |
not checked, since the plan also changes the <integration>, which the CLI does not send to Spotlight since its planned definition holds sensitive values, so Spotlight cannot tell whether its runs depend on it | The plan changes a spotlight_integration of the station's team whose planned definition holds sensitive values. The message says is larger than 16 KiB instead when the definition is larger than 16 KiB as JSON. |
not checked, since the plan also changes the <hook>, which the CLI does not send to Spotlight since its planned definition is known only after apply, so Spotlight cannot tell whether its runs depend on it | The plan changes a spotlight_hook of the station's team, and Terraform knows part of its planned definition only after apply. |
not checked, since the plan also changes the <hook>, which the CLI does not send to Spotlight since its planned definition holds sensitive values, so Spotlight cannot tell whether its runs depend on it | The plan changes a spotlight_hook of the station's team whose planned definition holds sensitive values. |
not checked, since the plan also changes the <hook>, which the CLI does not send to Spotlight since its planned definition is larger than 16 KiB, so Spotlight cannot tell whether its runs depend on it | The plan changes a spotlight_hook of the station's team whose planned definition is larger than 16 KiB as JSON. |
not checked, since the plan also changes the <hook>, which the CLI does not send to Spotlight since its planned definition sets <attributes>, which this CLI does not read; update the CLI, so Spotlight cannot tell whether its runs depend on it | The plan changes a spotlight_hook of the station's team whose planned definition sets attributes that this version of the CLI does not read, such as a new attribute of a step. Update the CLI. |
not checked, since the planned changes are too large to send to Spotlight | Spotlight answered 413 to the check request. |
Each check is started with an Idempotency-Key made from the line, the
station, its planned block, the planned repositories, the other changes it sends, --commit,
--pull-request and --repeats, so running the job again on the same plan answers the same
check. Starting and reading are tried again when Spotlight cannot be reached or
answers with a 5xx status, waiting twice --every after the first failure
and doubling, at most 2 minutes, and given up after 5 failures in a row.
Results
Each station ends with one status:
| Status | Meaning |
|---|---|
PASSED | The change regressed on no more tasks than the line allows, and enough tasks were scored. |
FAILED | It regressed on more tasks than the line allows. |
UNDECIDED | The check could not decide, or the station was not checked. When the plan also changes a skill, harness profile, integration, hook or secret that the station depends on, Spotlight starts no replay and the message says which. A run.starting hook whose steps all call read-only tools is replayed instead; see Errors. The message: Spotlight cannot decide this change. The plan also changes <changes>, which the station depends on, and a replay uses only the live ones. When the station has no runs to replay yet, the message is Station <key> has no replay set yet. Spotlight keeps one after a run of the station ends. or Station <key> has no runs in its replay set yet. See Check Terraform pull requests for station regressions. |
RUNNING | The check was still running at --timeout: still running after <timeout>. The check keeps running in Spotlight. |
UNCHANGED | The plan changes nothing that changes how the station's runs go, so there is nothing to replay. |
ERRORED | The check could not start, or reading it failed. The message says why. See Errors. |
An undecided check prints why:
undecidedBecause | Printed after undecided: |
|---|---|
stopped | the replay was stopped |
over-ceiling | the replay hit its ceiling before every task ran |
baseline-unfinished | the baseline replay of the live config did not finish |
too-few-scored | fewer than half the tasks were scored on both sides |
replay-gone | the replay is gone |
no-baseline | no baseline replay of the live config the check started against is left, and none can come, since the live config or its set moved on |
Output
note: <note>
core/delivery/build: FAILED
1 of 6 tasks regressed (at most 0 may), replaying the station's replay set: 6 tasks, 6 scored on both sides
candidate 4 of 6 succeeded, 67% (33–100%) over 6 tasks, baseline 5 of 6 succeeded, 83% (50–100%) over 6 tasks
Within noise of the baseline: -17 points (-50 to +0) over 6 tasks, not clearly past the 5-point gain that counts as real
spent 3.2 USD of a 10 USD ceiling
mean run of the candidate against the baseline: cost 0.52 USD against 0.8 USD, tool cost 0.02 USD against 0 USD, 41000 harness tokens against 60000, 1m35s against 2m20s
hook ticket did not run in replays: Step open calls linear.create-issue, which is not read-only.
scored with the live check, judge, which the plan also changes
Task Live config Candidate Regressed
Fix queue drain Succeeded: Judge passed it. Failed: Checks failed: npm test. Yes
Add retry flag Succeeded: Judge passed it. Succeeded: Judge passed it. NoAfter the line with the regressions comes a line undecided: <reason> when the
check is undecided.
With --repeats above 1, a line each run replayed <n> times comes before
the candidate line. When the check reuses a search's replays, a line
reuses a search's replays of the same config, against the search's live baseline comes before it too. See
Search replays. The candidate and baseline line counts repeats, then
gives each side's success with its range over the tasks scored, or nothing scored yet. The next line gives the candidate's gain over the baseline, as
Better than the baseline: …, past the <n>-point gain that counts as real,
Worse than the baseline: … or Within noise of the baseline: …, not clearly past the <n>-point gain that counts as real. The gain does not decide the
status.
After the spent line, a line compares the mean run of the candidate with the
baseline's, once both sides have runs that reported their usage: the cost, the
tool cost when either side has one, the harness tokens and the wall time, each part
only when both sides have it. It does not decide the status either. Then a line
hook <key> did not run in replays: <reason> names each run.starting hook
that either side's replay runs skipped. See
Run usage.
The table lists every task of the set, the regressed tasks first. "Task" is the
task's title, or Untitled task. "Live config" and "Candidate" give each
side's result, Succeeded, Succeeded <n>% when its repeats disagree,
Failed, Not scored, Running or Not replayed, then its one-line
reason, cut at 160 characters.
"Regressed" is Yes or No. The output has no link into Spotlight.
A plan that changes no live station prints
The plan changes no live station of a line, so there is nothing to check.
With --json, it prints { "stations", "notes", "exitCode" }, each station as
{ station, resource, status, message, check }, check being the
check as Spotlight read it last.
The step summary is headed Spotlight replay check, with any notes, then a
table with the columns Station, Result, Regressed, Candidate, Baseline, Gain
and Spent. Then, for each station with a message, a gain, a usage line, a skipped
hook or tasks, a heading with the station, the message, Undecided: <reason>
when the check is undecided, the gain line, the usage line, a line for each
hook that replays skipped, and the same task table, with
the columns Task, Live config, Candidate and Regressed. A gain reads as in
-17 points (-50 to +0), within noise, or - without one.
Exit codes
| Code | Meaning |
|---|---|
0 | Every station PASSED or UNCHANGED, or there was nothing to check. |
1 | A usage error, a plan it cannot read, missing credentials, or any station ERRORED. |
2 | No station ERRORED, and at least one FAILED. |
3 | No station ERRORED or FAILED, and at least one UNDECIDED or RUNNING. |
| Message | Cause |
|---|---|
name the plan, the output of `terraform show -json <planfile>`, or - to read it from stdin | No plan, or more than one. The usage follows. |
this is the log `terraform plan -json` streams, which contains no station blocks; save the plan with `terraform plan -out=<planfile>`, then pass this the output of `terraform show -json <planfile>` | The file is the streamed log of terraform plan -json. |
the plan is not JSON; pass this the output of `terraform show -json <planfile>` | The file is not JSON. |
this is not a saved plan shown as JSON; pass this the output of `terraform show -json <planfile>` | The JSON has no format_version. |
set SPOTLIGHT_URL with SPOTLIGHT_API_TOKEN or SPOTLIGHT_OIDC_TRUST, to check a plan | SPOTLIGHT_API_TOKEN or SPOTLIGHT_OIDC_TRUST is set, but SPOTLIGHT_URL is not. The usage follows. |
there are logins for <addresses>. Set SPOTLIGHT_URL to the one to check the plan with | No SPOTLIGHT_URL, and more than one login. |
no credentials for <address>. Set SPOTLIGHT_API_TOKEN, a workspace token that may plan, or SPOTLIGHT_OIDC_TRUST, an OIDC trust to exchange the job's OIDC token through, or run spotlight login | No token, no trust and no login for the address. The usage follows. |
read the login for <address>: <error> | The credentials file cannot be read. |
SPOTLIGHT_OIDC_TRUST needs an OIDC token: set SPOTLIGHT_OIDC_TOKEN, or run in GitHub Actions with permissions: id-token: write | A trust, but no OIDC token to exchange. |
the OIDC trust <trust> did not accept the OIDC token: <problem> | The trust did not accept the exchange. |
--timeout is how long to wait, above 0, not <value> | --timeout is 0 or less. |
--every is at least 1s, not <value> | --every is under 1s. |
--repeats is how many times to replay each run, from 1 to 5, not <n> | --repeats is below 1 or above 5. |
Each is printed after spotlight replay check: on standard error.