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
+77 -3
View File
@@ -194,8 +194,11 @@ Every submission, including agent-issued `submit`/`rpc`, still uses server valid
## Drafts in the TUI
The server runs one active run per resolved workspace, including overlapping
parent/descendant directories (and symlink aliases). Separate sibling worktrees
remain independent. A new request key in a
parent/descendant directories of one repository (and symlink aliases). Separate
sibling worktrees, and separate repositories nested in one another, remain
independent. Two folders outside any repository overlap only when they are the
same folder or one lies within the other run's declared write paths. A new
request key in a
different workspace is admitted immediately and executes concurrently; a second
run in a workspace an active run is already changing is refused, naming the
conflicting run and advising you to wait or use a different workspace (for
@@ -328,6 +331,8 @@ Submitting activates included schedules, so review them before publishing.
| Rename a run | `title ID "TITLE" --json` |
| Decide a waiting human stage | `decide ID [STAGE] --option KEY [--feedback TEXT] --json` |
| Cancel | `cancel ID --json` |
| Resume a run parked for a usage limit | `resume ID --yes --json` |
| Default whole-run budget | `run-budget [USD\|off] --json` |
| Connection and phone settings | `connection --json`, `ping --json` |
| Server/ntfy status popup | `status --json` |
| Usage statistics/charts | `stats --json` |
@@ -347,7 +352,7 @@ printf '%s' '{"type":"get_pipeline","pipeline_id":1,"version":1}' | pipelines rp
Existing protocol commands: `ping`, `list_pipelines` (optional `include_archived`),
`get_pipeline`, `archive_pipeline`, `unarchive_pipeline`,
`list_templates`, `validate`, `submit`, `run_pipeline`, `list_runs`, `get_run`,
`cancel_run`, `retry_run`, `decide_run`, `set_run_title`, `get_run_evidence`,
`cancel_run`, `retry_run`, `decide_run`, `resume_run`, `set_run_title`, `get_run_evidence`, `get_run_settings`, `set_run_settings`,
`get_status`, `search`. `search` takes a `search` request object (`query`, with an
optional `kind` and `limit`) and returns a `search_results` response whose ranked
`results` each carry a stable `target` the client can open plus the typed payload
@@ -1163,6 +1168,75 @@ bound is stored as a valid, credential-redacted preview envelope that preserves
available stage limits and failure/format diagnostics and names the retained
session instead of slicing to malformed JSON.
### Whole-run budgets
A run can also carry a whole-run USD cap: `pipelines run ... --budget 5` (and
`retry ... --budget 5`; a retry otherwise keeps its source run's own budget), else
the server default set with `pipelines run-budget 5` (`run-budget off` removes it;
`run-budget` alone shows it). Every model stage's reported cost counts towards it.
At 80% the operator gets one `budget_warning` notification; at 100% the running
visit stops, the error edge is not followed and the run fails with failure class
`budget`. The run records `budget: {limit_usd, source: run|server, spent_usd,
warned}`; `inspect` prints it. Stage `budget_usd`/`budget_tokens` still cap each
stage on their own. Protocol: `run_pipeline`/`retry_run` take `budget_usd`;
`get_run_settings` and `set_run_settings` (`run_settings: {default_budget_usd}`)
reply `run_settings`.
### Usage limits: `waiting_quota`
A Claude stage refused for a subscription usage limit (the 5-hour or weekly
window) does not fail its run:
1. The server records the account's limit and tries the same Claude account
auto-switch chats use (only when the stage's Claude home sets its own
`CLAUDE_CONFIG_DIR` and its auto-switch setting is on, see Claude account
switching). On a switch the same stage visit runs again at once on the new
account.
2. Otherwise the run is parked with status `waiting_quota`. The run (and its
`run_event` frames) carry `quota_wait: {resets_at, resume_at, sequence, stage,
account}`; the server resumes the interrupted visit at `resume_at` (the reset
plus one minute), also after a server restart. A parked run holds no executor
and no workspace reservation; if another run holds its workspace at resume
time it tries again a minute later.
3. The visit that runs again does not count against the stage's `max_visits` and
its `input.md` carries a `# Previous attempt` note saying it was interrupted by
the limit and that partial edits may be in the worktree.
`pipelines resume <run-id>` (protocol `resume_run`) resumes a parked run now;
`pipelines cancel <run-id>` cancels it (failure class `canceled`). `pipelines wait`
keeps waiting through `waiting_quota`; `run --wait`/`retry --wait` return with the
parked run and a line saying when it resumes. An exhausted paid balance (an API
key's credit, OpenCode's quota error) has no reset of its own and still fails the
run with failure class `quota`; only that case says to top up the account.
While an account is known to be limited, a new `run` or `retry` whose pipeline has
Claude stages is not launched into it. The request's `quota_policy` decides:
`defer` (the default, and the CLI's choice at an interactive prompt) creates the run
parked in `waiting_quota` with `sequence: 0`, starting at the reset; `refuse` (the
CLI's choice under `--json`/`--yes`) rejects it naming the reset time; `now`
starts it anyway. The CLI flags are `--defer` and `--now`.
### Failure classes and error loops
A run that did not succeed carries `failure_class`, written by the runner and
shown by `inspect`, `runs`, `wait`, `run --wait`, the app's failure line and
`stats` (`failure_classes` counts): `quota`, `loop_exhausted`, `timeout`,
`permission_denied`, `harness_error`, `blocked` (a stage routed to `#failure` on
its own outcome), `environment`, `canceled`, `interrupted`, `budget`,
`check_failed` (verification target or delivery gate) and `other`. Runs recorded
before the class existed read as `blocked`, `other`, `canceled` or `interrupted`
from their status.
A Claude stage that answers `blocked` (or `error`) after the permission rules
refused one of its tool uses (`permission_denials` in Claude Code's result, or a
refused `tool_result`) fails with `permission_denied` naming the tool and path or
command, instead of being reported as the model's own block. Harness failures are
classified before an `error -> <same stage>` loop is followed: deterministic ones
(authentication, invalid arguments or model, a configuration the harness refuses,
a permission denial, the same empty readback twice) go to `#failure`; transient
ones (network, 5xx, overloaded, timeouts) wait 15 s, 1 min, then 4 min before the
next visit.
### Result-first views
Home shows retained result previews and completed visits alongside each run and