Skip to content
Like what we’re building? Star on GitHub

ADR-183 — A paused run stays warm for an idle window before it is parked ​

  • Status: Accepted — the operator chose the direction and the default on 2026-12-02 and accepted the record with its implementation, #4068, on 2026-12-03. Where the implementation had to choose is in Implementation notes.
  • Date: 2026-12-02
  • Deciders: jo (the direction and the default), Claude (the design and the measurements)
  • Relates to: ADR-106 (a resume restores the scratch banked at teardown) · ADR-081 (async human interaction) · ADR-176 (a launch past capacity waits as a run) · ADR-184 (a resumed run says why)
  • Serves: #4033 · epic #1403

Context ​

A cloud run that reaches a human node pauses (run_paused), and the runner parks it at once:

  1. it banks the scratch (ADR-106);
  2. it tears the sandbox pod down;
  3. it frees its slot.

The answer resumes the run as a new attempt:

  1. the repository is cloned again;
  2. a new sandbox pod is provisioned;
  3. the scratch is restored.

The cost, measured on a Saboteur run in production (01a237d3-025c-77d3-a3c5-100475967d5a, v7.45.0, 2026-12-02):

UTCCost
run_paused on approval17:37:43scratch banked 5 s later (12 KB)
the human accepts17:40:16
run_resumed → sandbox_started → the next node starts17:40:16 → 17:41:1357 s of cold restart, a second attempt

The human answered in two and a half minutes, and the run paid a minute of restart and a second attempt. Many runs pause on a human gate (approvals, reviews, chats): parking at the first instant of a pause is the most aggressive choice and the slowest for the person who answers quickly.

Parking at once is not free of reasons. A runner serves one run at a time (runner.concurrency: 1 in the chart), each sandbox requests 2 CPU and 4 Gi, and the production fleet is six runners. A pause that holds its runner holds a sixth of the fleet.

Decision ​

A paused run stays warm for an idle window before it is parked.

  1. The window is a setting with an override. A duration for human-gate pauses, carried by the database configuration cascade (platform, org, team, bot). 15 minutes by default. 0 parks at once, as today, so an operator who wants today's behaviour sets it, and nothing else changes for them.
  2. An answer inside the window continues the run in place. The run keeps the same attempt and the same sandbox. Nothing is cloned again, no new pod is started, and the scratch makes no round-trip.
  3. A window that expires parks the run exactly as today. The scratch is banked and the slot released. The answer then resumes the run cold, as a new attempt (ADR-106 unchanged).
  4. Capacity comes first. A launch that waits for capacity (ADR-176) evicts the oldest warm pause, which is parked as in point 3. A warm pause never makes a launch wait.
  5. The answer finds its runner, or falls back cold.
    • The answer can land on any server replica. It wakes the runner that holds the warm run, through a per-run signal.
    • A wake that is lost leaves the run warm until its window expires, then parked; the stored answer then resumes it cold. An answer is never lost and never applied twice.
  6. Drain and death park. A lame-duck runner parks its warm pauses at once. A runner that dies leaves its run to today's recovery path.
  7. The warm wait is not model spend.
    • The pause is accounted as the run's wall time, not as spend.
    • An in-window answer does not open an attempt, so the attempt count says how often the run really restarted.

Options considered ​

  • Park at once (today). Cheapest in capacity. Every answer pays a cold restart and a new attempt, whatever its delay.
  • Never park a human pause. Fastest resume. A forgotten approval holds a runner forever, and six of them stop the fleet. Rejected.
  • A fixed window with no eviction. Simple. Under load, warm pauses make real launches wait, which inverts the priority. Rejected for point 4.
  • Keep only the sandbox warm, release the runner. It frees the runner but leaves a pod that no process owns. Its life, its cost and its cleanup would need a second owner. Rejected: the runner that holds the run stays its owner.

Consequences ​

  • An approval answered within 15 minutes continues within seconds, in the same attempt (#4033).
  • Under load a warm pause gives way: the fleet's capacity for launches is unchanged.
  • The runner gains a third way to end a run's slot (finished, parked, and now warm-then-parked), with its tests:
    • an in-window answer continues in place;
    • idle expiry parks;
    • a queued launch evicts the oldest warm pause;
    • drain parks;
    • a lost wake falls back cold at window end;
    • 0 behaves as today.
  • How the studio shows a cold or a warm resume is ADR-184.

Open questions ​

  • Which store carries the window. The provider and model cascade carries per-bot settings today. Whether it hosts a runtime duration, or the setting needs its own row, is the implementation's first read.
  • Other pauses. The same window may suit other pauses (a recovery pause, an await_answers pause, ADR-081). This record decides human gates only.

Implementation notes (#4033) ​

How the decision landed, where it had to choose:

  • The window lives in its own run policy (pkg/runpolicy, the run_policies collection, one document per level: platform, org:<id>, team:<id>, bot:<team>/<bot>), not in the provider and model cascade, whose bot level is the bot manifest. It is resolved at launch and frozen on the run, like the retry and routing policies. A level that cannot be read stamps the run unavailable, and it parks at once: a latency setting never refuses a launch.
  • The warm continuation is the cold resume without its infrastructure. A sandbox has one owner at a time: the engine that started it, the runner's warm holder between two engines, then the engine that adopts it (runtime.WithAdoptedSandbox). That engine resumes the run through Engine.Resume, so every pause kind a resume knows would continue the same way; one predicate (warmEligible) decides which may stay warm — human gates. It restores no scratch, opens no attempt (run_resumed carries in_place), and is bound to the run revision the answer was read at.
  • A lost wake falls back cold at once, not at the window's end. The answer goes to the run's warm subject (iterion.warm.<run_id>). No holder or a refusal sends it down the cold path, after the holder is asked to let the run go, bound to the pause INSTANCE the answer was read for: the hold names the seq of the run_paused event that opened it, every claim of it emits a run_resumed past that seq, and a review gate waits again on the same interaction — so a run_resumed past it refuses the cold resume. The check is a range read from the pause on (an index range on Mongo). A lost reply is attributed by the answer's receipt on the continuation's run_resumed; without it and with the pause moved, the outcome is reported unknown, never resumed twice.
  • The capacity a warm hold gives way to is the runner queue's. ADR-176's waiting_capacity is not built, and its logical axes (team, org, key, gateway) are not held by a pause. The elected warm evictor parks the oldest hold of a pool whose runner queue has a backlog, one at a time.
  • A continuation re-asserts its delivery's capacity places at its claim. A pause holds none of them. One taken while the run waited refuses the continuation, and the cold resume admits the run again.
  • A rewind parks a warm hold first, and refuses with a 409 when the park does not land in time. The other mutations of a paused run go through the resume or cancel it first.
  • A runner that dies while it holds a run leaves it paused with no bank of that pause: the cold resume refuses the scratch's loss by name, as for a death mid-execution.

Open question 2 (other pauses) stays open. The mechanism serves them already, and widening warmEligible is the change.