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 fieldEffect
diffs: trueAfter 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.
checkEach 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: trueThe 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

StateMeaning
generatingSpotlight has the diff and generates the stack.
readyEvery hunk of the diff is assigned to exactly one layer.
failedGeneration did not finish. The stack carries the reason.
MessageCause
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.

PartContains
CohortA kind, a title and an intent.
LayerA 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 kindContains
changeThe hunks a reviewer reads, in layers that build on one another.
incidentalLockfiles, 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.

LanguageFiles
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 is all, any, route, handle, handlefunc or match, 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, and Map calls such as MapGet in C#;
  • in Go, also from a pattern that starts with its method, as in "GET /tasks/{id}", given to Handle, HandleFunc, route, match, any or all, 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.

StepChecked tree
The whole changeThe run's diff applied in full. Always first.
Each change layer, in orderThe 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 setup runs 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-timeout while no runner has a lease on it.
Check statusMeaning
waitingWaiting for a runner to claim and run it.
checkedEvery step ran. Each step passed or failed.
skippedThe check did not run. It carries a skip code.
CodeCause
no-baseSpotlight doesn't know the commit where the run began. The layers can't be checked without it.
no-checkoutSpotlight does not know which checkout the changes are from.
checkout-failedSpotlight could not lay out a copy of the checkout to check.
setup-failedThe setup of the checkout failed before the check ran.
working-copy-failedThe runner could not open a working copy to check the layers.
out-of-timeThere was no time left to check the layers.
no-imageThe host couldn't pull the runner image that the line names.
queue-timeoutNo runner checked the layers in time. The check had waited more than 60 minutes, and no runner had a lease on it.
provision-failedSpotlight 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

KindLabel in the pull request comment
trade-offTrade-off
assumptionAssumption
limitationLimitation
rejected-approachRejected approach
deviationDeviation

Fields

FieldTypeDescription
kindstringOne of the kinds above.
titlestringAt most 120 characters.
whystringThe reasons, at most 2,000 characters.
alternativesarray of stringsWhat was weighed and set aside. At most 5, each at most 300 characters.
pathsarray of stringsThe files the decision covers. 1 to 20.
journalStepsarray of integersThe 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.
disputesarray of objectsEach 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 with spotlight 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

StatusMeaning
proposedRecorded, and open to disputes.
mergedA 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 with decisions: true is also briefed under ## Record what you decide. See Briefing.

On this page