Runs park on usage limits; failure classes, harness error policy, run budgets

- A stage refused for a Claude usage limit no longer fails its run: the
  runner tries the chats' Claude account auto-switch (per-home setting) and
  reruns the visit, else parks the run in the new waiting_quota status
  (persisted, with reset/resume time in run summaries, details and events)
  and resumes the same visit at reset + 1 min, also after a restart.
  resume_run / `pipelines resume` resumes now; cancel works on parked runs.
  The rerun visit gets a "# Previous attempt" interruption note. Subscription
  limits no longer say "top up the provider account".
- run/retry into an account known to be limited are deferred (quota_policy
  defer/refuse/now; CLI refuses under --json/--yes unless --defer or --now).
- failure_class on runs (quota, loop_exhausted, timeout, permission_denied,
  harness_error, blocked, environment, canceled, interrupted, budget,
  check_failed, other) in RunSummary/RunDetail/events, CLI inspect/runs/wait/
  stats and the app failure line.
- Claude permission denials (permission_denials / refused tool results) fail
  a blocked visit with permission_denied naming the tool use.
- Harness failures are classified transient vs deterministic; deterministic
  ones (and a repeated empty readback) skip error self-loops; transient
  self-loops back off 15 s, 1 min, 4 min.
- Whole-run USD budget: run --budget, server default (run-budget /
  get/set_run_settings); 80% warning notification, stop with class budget.
- App: waiting_quota status/filter with resume time, Resume now and Cancel,
  failure class wording. Docs and skill references updated.

Merges main (check stage, delivery gate, Claude stage restart survival,
schedule changes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 14:34:53 +00:00
193 changed files with 11295 additions and 505 deletions
@@ -10,6 +10,37 @@
4. Verify the repair with a focused regression; run broader checks once relevant
inputs settle. Do not raise retry/time budgets to hide a reproducible defect.
Read the run's `failure_class` first (in `inspect`, `runs`, `wait` and the app's
failure line; `stats` counts them):
| class | meaning and next action |
|---|---|
| `quota` | provider usage/balance refused; a Claude window parks instead (below), so this means an exhausted paid balance or a failed park |
| `loop_exhausted` | a stage's visit limit or the 30-step cap; fix the cause the loop kept hitting |
| `timeout` | a stage attempt ran past its `timeout`; check whether work landed before raising it |
| `permission_denied` | the stage's tool use was refused (named in the diagnostic) and it gave up; widen `tools`/write paths or change the task |
| `harness_error` | the harness failed (transport, readback, cleanup); a deterministic one was not looped |
| `blocked` | a stage deliberately routed to `#failure` (its own outcome); read its handoff |
| `environment` | harness missing or signed out, workspace/env/delivery access problems |
| `budget` | the run's `--budget`/default run budget (or a stage budget) was spent |
| `check_failed` | a verification target or delivery gate check failed |
| `canceled`, `interrupted`, `other` | operator cancel, server stop, anything else |
A Claude stage refused for a usage limit is never failed and never retried into
the limit. The server first switches the Claude home to another saved account
with usage left (when that home's auto-switch is on) and runs the visit again;
otherwise the run is parked in `waiting_quota` with `quota_wait.resets_at`/
`resume_at` and resumes the same visit a minute after the reset, also after a
restart. The visit that runs again is told in `# Previous attempt` that it was
interrupted and that partial edits may be in the worktree. Do not retry or cancel a
parked run to "unstick" it: `pipelines wait ID` waits through it,
`pipelines resume ID --yes` resumes it now (only when the limit is known to be
lifted) and `pipelines cancel ID --yes` stops it. While an account is known to be
limited, `run`/`retry` under `--json`/`--yes` are refused with the reset time;
pass `--defer` to queue the run for the reset or `--now` only when you know the
limit is gone. A run's `--budget USD` (or the server's `pipelines run-budget`)
warns at 80% and stops at 100% with class `budget`.
`pipelines retry ID --yes --json` resumes the failed stage; `--stage KEY [--visit N]` picks a
recorded stage, `--input-file FILE|-` merges a bounded JSON correction (shown to
the stage as `# Operator correction`), `--version N` a published version of the