Change stacks and decisions
A change stack is a run's diff arranged for review. A decision is a choice an agent made during a run, which the agent records itself. A station turns each on in its station fields:
| Station field | Effect |
|---|---|
diffs: true | After each run, a change stack is generated for each checkout that changed. After a person pushes to the task's pull request, a new stack is generated for that repository. |
check | Each change stack generated at the station is checked with this command, so it has effect only with diffs: true. With both set, every repository of the line must have setup. |
decisions: true | The briefing asks the agent to record each decision that shaped the change with spotlight decide. |
Spotlight, not the agent, generates a change stack, in a session in the team's harness. The agent records its decisions itself. Reviewing an agent's changes gives the reasons.
Change stacks
States
| State | Meaning |
|---|---|
generating | Spotlight has the diff and generates the stack. |
ready | Every hunk of the diff is assigned to exactly one layer. |
failed | Generation did not finish. The stack carries the reason. |
| Message | Cause |
|---|---|
Spotlight couldn't generate the change stack. | Every generation attempt failed. |
Generation was interrupted before it finished. | Generation stopped without a reason. |
Generation is attempted at most 4 times. Each attempt may take 30 minutes, and the wait before the next starts at 30 seconds and doubles. A diff is at most 6 MiB and 2,000 hunks.
Structure
A stack is an ordered list of cohorts. A cohort is an ordered list of layers.
| Part | Contains |
|---|---|
| Cohort | A kind, a title and an intent. |
| Layer | A title, a summary, the hunks assigned to it, a note on each file it changes, and the earlier layers it depends on with the reason for each. |
| Cohort kind | Contains |
|---|---|
change | The hunks a reviewer reads, in layers that build on one another. |
incidental | Lockfiles, generated files, test snapshots, pure renames and formatting-only changes. Spotlight assigns these itself. |
A diff whose hunks are all incidental gives a ready stack at once.
Languages read across files
Before generating, Spotlight reads the changed files in these languages, before and after the change. It reads only the lines the diff shows, the changed lines and their context, and leaves the other lines blank. Binary files are not read. Each side of a file is read only when that text is at most 524,288 characters.
Spotlight links each hunk of the diff to the hunks that define a name it uses or imports, or a route it names. The hunks may be in the same file. A hunk is not linked to itself. Route links come only from the after side.
| Language | Files |
|---|---|
| TypeScript | .ts, .mts, .cts, .tsx |
| JavaScript | .js, .mjs, .cjs, .jsx |
| Vue | .vue: the script blocks, and the component tags of the template |
| Svelte | .svelte: the script blocks, and the component tags of the markup |
| Python | .py |
| Go | .go |
| Java | .java |
| Ruby | .rb, .rake |
| Rust | .rs |
| PHP | .php |
| C# | .cs |
| Terraform | .tf |
Routes are read in every language above but Terraform:
- from a call whose first argument starts with
/, where the call is named for an HTTP method (get,post,put,patch,delete,head,options) or isall,any,route,handle,handlefuncormatch, in TypeScript, JavaScript, Vue, Svelte, Python, Ruby, Rust and Go; - from Nest decorators, with the controller's prefix, in TypeScript, JavaScript, Vue and Svelte;
- from route annotations in Java, attributes in PHP and C#,
Route::and other route calls in PHP, andMapcalls such asMapGetin C#; - in Go, also from a pattern that starts with its method, as in
"GET /tasks/{id}", given toHandle,HandleFunc,route,match,anyorall, with or without a host before the path.
A route links only when its path has at least 2 segments that are not wildcards.
Checks
A station's check command is run against the stack in a sandbox of its own,
from the line's runner image, on a runner that meets the run's placement.
| Step | Checked tree |
|---|---|
| The whole change | The run's diff applied in full. Always first. |
Each change layer, in order | The incidental hunks and every layer up to and including this one. |
- Each checked tree borrows git objects from the host's mirror of the repository, when the host has one.
- Each repository's
setupruns before the first step, and again before any step whose lockfile changes differ from the step before. - When the whole change fails, the layers are not checked.
- When the whole change passes and a layer fails, the stack is redrafted once and checked again.
- A step may take 5 minutes, and a check 60 minutes in all. The last 16,000 characters of each step's output are kept.
- A runner has a 10-minute lease on a check, which it renews while the
check runs, with
POST /api/runs/{runId}/change-stack-checks/{stackId}/lease. A renewal fails 65 minutes after the claim. The lease ends when it expires, or 65 minutes after the claim. - A check is claimed at most 3 times.
- A check that has waited more than 60 minutes is skipped with
queue-timeoutwhile no runner has a lease on it.
| Check status | Meaning |
|---|---|
waiting | Waiting for a runner to claim and run it. |
checked | Every step ran. Each step passed or failed. |
skipped | The check did not run. It carries a skip code. |
| Code | Cause |
|---|---|
no-base | Spotlight doesn't know the commit where the run began. The layers can't be checked without it. |
no-checkout | Spotlight does not know which checkout the changes are from. |
checkout-failed | Spotlight could not lay out a copy of the checkout to check. |
setup-failed | The setup of the checkout failed before the check ran. |
working-copy-failed | The runner could not open a working copy to check the layers. |
out-of-time | There was no time left to check the layers. |
no-image | The host couldn't pull the runner image that the line names. |
queue-timeout | No runner checked the layers in time. The check had waited more than 60 minutes, and no runner had a lease on it. |
provision-failed | Spotlight couldn't provision a runner to check the layers. |
A push pool receives a check, and the diff of a person's push, as provision
work of kind check. See Provision call.
Where a change stack is shown
- The task's change stack page in the web app, reached from the task's
"Changes" property, with the newest stack of each repository. A run's own
stacks are on its page at
/changes. See Web app. - A comment on each pull request of the task, kept up to date with the latest ready stack of that pull request's repository, when the workspace is connected to GitHub.
Decisions
Kinds
| Kind | Label in the pull request comment |
|---|---|
trade-off | Trade-off |
assumption | Assumption |
limitation | Limitation |
rejected-approach | Rejected approach |
deviation | Deviation |
Fields
| Field | Type | Description |
|---|---|---|
kind | string | One of the kinds above. |
title | string | At most 120 characters. |
why | string | The reasons, at most 2,000 characters. |
alternatives | array of strings | What was weighed and set aside. At most 5, each at most 300 characters. |
paths | array of strings | The files the decision covers. 1 to 20. |
journalSteps | array of integers | The journal steps of the run that reason the decision. Empty for a decision the agent recorded with spotlight decide. A step's number is (attempt − 1) × 1,000,000 + its position in that attempt's journal, so a run that waited for a person and resumed keeps the numbers of its earlier attempts. |
disputes | array of objects | Each has the file, the person and the reason. |
spotlight decide refuses a decision that breaks these limits.
Recording
- The agent of a run of a task, at a station with
decisions: true, records each decision withspotlight decide. A task that reviews a pull request keeps no decisions. - A task has one set of decisions. Each run adds its decisions to the set, and a decision the task holds already is kept once.
- A task keeps at most 50 decisions.
Status
| Status | Meaning |
|---|---|
proposed | Recorded, and open to disputes. |
merged | A pull request of the task merged. The task takes no more decisions. |
A merge is recorded for each repository. A decision counts as merged in a repository once the task's pull request there merged and the decision covers files in it.
When the task's first pull request is closed without merging, the decisions
are discarded. A later pull request of the task, in another repository, that
closes without merging keeps them.
Merged decisions are listed by
GET /api/workspaces/{slug}/decisions, filtered by repository, path,
since and until (merge times).
Disputes
A member of the task's team disputes a decision by replying to it on one of its files in the change stack page. A reason is 1 to 1,000 characters.
Where decisions are shown
- The change stack page, beside the files each decision covers.
- A comment on each pull request of the task, with the decisions whose files are in that pull request's repository, when the workspace is connected to GitHub. Decisions on files in no such repository go on the first pull request. Spotlight deletes the comment from a pull request with no decisions.
- The briefing of each later run on the task, under
## Decisions on record, with each dispute. A run at a station withdecisions: trueis also briefed under## Record what you decide. See Briefing.