Search for a better station config
Use this when you want Spotlight to look for a better config for a work station, instead of writing each change yourself. A search is a series of rounds. In each round an agent studies how the station's past runs went and proposes a few changed configs, called candidates, and Spotlight replays each one on most of a replay set's tasks. Nothing is applied: when you pick a candidate, Spotlight opens a pull request in the repository that holds the line's Terraform. You need:
- To be on the team, or an owner or admin of the workspace.
- A replay set at the station with runs of at least 5 different tasks. See Pick the tasks to replay. Replay it once first, so its first baseline checks it, and read the set's health to know whether its results can be trusted.
- A host serving the workspace with the station's harness, and the harness you want the search's agent to run on. See Install a host.
- To open pull requests from it: the line's Terraform in a GitHub repository
that Spotlight's GitHub App is installed on, and a
sourceblock on the line that names the file. See Name the file that holds the line.
Name the file that holds the line
Do this once per line, before you pick a candidate.
Add a source block to the line's spotlight_line resource, naming the
repository and the .tf file, from the repository's root, that holds the
resource:
resource "spotlight_line" "core_delivery" {
# ...
source {
repository = "acme/platform"
path = "teams/core/delivery.tf"
}
}Run terraform apply.
If the station's prompt, or another attribute a search may change, is read
from a file, write it as file("${path.module}/<path>"), so Spotlight can
follow it.
See source for the rules.
Start a search
On the line's board, select the station's name. On the Station page, open the Improve tab. On the Searches card, select Start a search.
If the station has no replay set and no searches yet, the card reads No searches yet and shows no Start a search: create a replay set first. If the button is greyed out, hover over it to see why, such as No replay set covers 5 different tasks yet. Add runs of more tasks to a set, or wait for the station's search under way to end.
Under Search on, choose the replay set. A set with runs of fewer than 5 different tasks can't be chosen: a search keeps about 30% of the tasks back to check its results on, and needs some left to search on. See Why a search holds tasks back.
Set the budget:
- Iterations: how many rounds, so how many times the agent runs, from 1 to 10.
- Candidates per iteration: how many candidates each round may propose, from 1 to 5.
- At once: how many of the search's replay runs run together, from 1 to 10. They run beside the team's other replays, below every task run.
- Repeats: how many times each of its replays replays each run, from 1 to 5. The live config's replay, every candidate's and the held-out replays all take this many copies. More copies narrow the range around each score, and the runs and spend grow with them.
- Ceiling: the most the whole search may spend, its replays and its
agent's runs, and its currency, as in
20.00andUSD.
Under Aim for, choose what counts as better:
- More success: candidates that succeed more often.
- The same success for less: candidates that succeed as often as the live config, within noise, and cost less a run.
If the live config already succeeds on more than 95% of the set, The same success for less is chosen for you, with a note saying so. You can change it.
Under Its agent, choose the harness, and the model and effort if you want other than the harness's own defaults. This is the agent that proposes candidates, not the station's own.
Read the estimate under the fields. It gives how many tasks are searched and held out, how many copies of each run, the most runs the search may start, what each replay may spend, and roughly how long it takes, from how long the set's runs took. If Ceiling says the ceiling must allow at least 0.01 for each replay run, raise the ceiling or lower the iterations, candidates or repeats.
Read any warning under the estimate:
- If nobody has measured how much the set's success moves by chance, start a replay of the set first, so its first baseline checks it, or set Repeats above 1.
- If the set's success moves more than the line counts as real, select the
button under the warning, as in Replay each run 3 times, to set
Repeats to what it suggests, and raise the ceiling if the estimate asks.
If the warning says even 5 copies won't bring it under, read small gains
with care, or raise the line's
min_gain. - If the live config already succeeds on almost all of the set, aim for the same success for less, or add runs of tasks the live config fails.
- If the judge gave the same verdict too rarely when it judged the same change twice, make its rubric more specific before you search.
- If the check flipped on changes it ran twice, fix the flaky tests, or take those tasks' runs out of the set. The set's page lists them.
- If the live config, handed each run's answer, gained little on the set, a better config has little room to show there. Add runs of tasks the live config fails. See Read the room to improve.
The search starts with a warning all the same, but a gain it finds may be chance.
Select Start search. The search's page opens.
While the search runs, its replay set can't change: runs can't be added or taken out, and the set can't be deleted. A station has one search at a time.
Follow the search
On the station's Searches card, State shows where the search is: Replaying the live config, Searching, Checking on held-out tasks, then Finished or Stopped. Hover over the state to see why it ended, such as Ran every iteration it was given. See Search states for what each state means.
Select the search to open its page. See Search page for its tiles and pills. Under Candidates, select a candidate's name to see the agent's hypothesis, what the candidate changes from the live config, and how it scored. Select Agent run on an iteration's row to see what the agent read and did.
To stop a search, select Stop, then Stop search. The agent's run stops and nothing more is replayed. Candidates whose replays finished keep their scores and can still be picked.
If the search stalls
A search stalls when two iterations in a row propose nothing better than the best config before them. If it has at least 2 iterations and enough of its ceiling left, the next iteration proposes nothing: its agent looks into each searched task the best config so far still fails, and records what caused the failure. When a change to the config could fix some of them, the search goes on and its next agent is told what was found. Otherwise the search ends. See Stalls.
If you started the search, you get an inbox notice when it ends this way, and when it goes on but found something to fix outside the config.
Open Inbox. A notice about the search reads, for example, The search for a better Build config ended with nothing the config can fix. Open it, and it moves under Resolved. Under Details, it says what happened, then names each task with what to fix. Select Open the search.
On the search's page, under Why it stalled (iteration <n>), the tasks
are grouped by cause. Each shows what in the runs showed
the cause and what the agent suggests. Select Open the failed replay run
to check it yourself.
Fix what each group asks:
- The task itself: take the task's run out of the replay set, or reword the task. See Pick the tasks to replay.
- The judge: fix the judge's rubric. See Set a station's judge and alerts.
- The check: fix the broken or flaky test the station's check runs.
- Around the work: replay the task again. If it keeps failing, fix what the run needs, such as a tool or a service.
- The station's config: nothing. The search keeps trying configs for these.
- No cause recorded: open the failed replay run and decide for yourself.
If the search ended, start a new one once the fixes are in.
If the notice reads ended with no budget left to reflect, the search had fewer than 2 iterations or too little of its ceiling left. Start a new search with more iterations or a higher ceiling.
Read the results
To read a score's range, hover over the score in the Candidates table,
or read it in brackets in a candidate's details or in the Success against
cost card's Table, as in 72% (50–89%). Act on a gain that reads
Better or Worse, not within noise. See
Gains for when each verdict shows. The
smallest gain that counts is in the note of the Live config tile.
Success against cost plots each candidate's success on the searched tasks against what it spent a run, with the frontier joined by a line. In the Success against cost card's header, select Table to read the same as a table. See Frontier.
The Best tile shows the best candidate, or Live config when nothing beat the station as it is. If the search aims for the same success for less, the tile reads Cheapest in place of Best. See Best candidate.
If the station has a judge, each gain is followed by the candidate's wins,
losses and ties against the live config, once its replay has finished, as in
Side by side with the search's starting config: 4 wins, 1 loss, 2 ties.
See Side by side for how the judge
compares the changes.
Give the held-out score the most weight. Before you pick a candidate marked Only on seen tasks, or one that reads Too few held-out tasks to tell, hover over the reading for its note. See Only on seen tasks, and Frontier for which candidates are held out. To see a candidate's result task by task, select Replay or Held-out replay in its details. See Replays.
To set the search's candidates beside the station's other replayed candidates and the live config, open the team's Insights page at Stations, under Candidates. See Compare the station's candidates. There, Changes on a searched candidate's row opens this page at it, or its pull request once picking it opened one.
Pick a candidate
Select the candidate's name. In its details, select Pick. You can pick any candidate whose replay on the searched tasks has finished, while the search runs or after, and more than one. If Pick is greyed out, the text beside it says why.
If the candidate is marked Only on seen tasks, a warning above Pick says its gain may not carry over to new work. You can still pick it.
The candidate's details read Opening a pull request…, then Pull request opened. Select it to open the pull request on GitHub. Its row under Pull request reads Opened, linked to it too.
Review the pull request. Its description has the agent's hypothesis, the candidate's scores beside the live config's with their ranges, whether each gain is more than noise, and its side-by-side wins, losses and ties when it has any. For a candidate marked Only on seen tasks, a paragraph under the opening one warns that its gain showed only on the searched tasks and gives both gains. It says instead when too few held-out tasks were scored to tell, or when the held-out replays had not finished as the pull request opened. The plan of the change runs in your Terraform workflow as for any other pull request; if the line checks pull requests, that check runs too.
Merge it and apply it as you would any change to the line.
Once a candidate has a pull request, its details show it in place of Pick, so it opens no second one.
If no pull request opens
The candidate's row reads Not opened under Pull request; hover over the warning icon beside it for the reason. Its details read No pull request opened, the reason, and what Spotlight found. Fix the cause, then select Retry.
| Reason | What to do |
|---|---|
| Line names no repository for its Terraform | Give the line a source block. See Name the file that holds the line. |
| Spotlight's GitHub App can't reach the line's repository | Install the GitHub App on that repository, or correct source.repository. |
| Line's Terraform file isn't in its repository | Correct source.path. Spotlight reads the file on the repository's default branch. |
| Station's block isn't in the file, or Station's block appears more than once | Spotlight looks for exactly one spotlight_line resource whose key is the line's, and in it exactly one station block whose key is the station's, both written as plain text. Write them that way, or make the change by hand. |
| Attribute is computed in Terraform. Please set it by hand. | The attribute is built from a variable, a local or another expression. The reason names the attribute, the expression and the value to set: make the change by hand. |
| File changed since the search began | The station's block in the repository no longer matches the config the search started from, such as after another change was applied. Make the change by hand, or start a new search. |
| Pull request branch already exists | The branch spotlight/search-<id>-<name> holds commits Spotlight did not write. Delete the branch, then retry. |
Config pull request reasons lists every reason.