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
@@ -19,7 +19,7 @@ List<JsonMap> runDetailChangeSteps(JsonMap run) {
return const <JsonMap>[];
}
const _executingStatuses = {'queued', 'running', 'waiting'};
const _executingStatuses = {'queued', 'running', 'waiting', 'waiting_quota'};
/// Whether the run detail offers the action at all. The opened page is a
/// snapshot of the recorded steps, so it is offered only once nothing is
@@ -0,0 +1,136 @@
import 'package:flutter/material.dart';
import '../../../ui/status/run_status_icon.dart';
import '../../../ui/text/monospace.dart';
import '../../chat/ui/transcript/chat_markdown_view.dart';
import '../domain/check_step_output.dart';
/// The note under a command whose recorded output the server cut short.
const String checkOutputTruncated =
'The server truncated this output at its capture limit.';
/// The body of a command that recorded no output.
const String checkOutputEmpty = 'No output recorded.';
/// A check visit's Output: its summary, a delivery-gate marker, one
/// expandable row per command and the handoff document the next stage reads.
class RunCheckOutputView extends StatelessWidget {
const RunCheckOutputView({super.key, required this.output});
final CheckStepOutput output;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final summary = output.summary;
final markdown = output.markdown;
return Column(
key: const Key('run-check-output'),
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (output.delivery)
Align(
alignment: AlignmentDirectional.centerStart,
child: Chip(
key: const Key('run-check-delivery'),
avatar: const Icon(Icons.verified_outlined),
label: const Text('Delivery gate'),
),
),
if (summary != null)
Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: SelectableText(summary, style: theme.textTheme.bodyLarge),
),
if (output.checks.isEmpty)
const Text('No commands were recorded.')
else
for (final (index, check) in output.checks.indexed)
RunCheckCommandRow(
key: ValueKey('run-check-command-$index'),
check: check,
),
if (markdown != null) ...[
const SizedBox(height: 12),
Text('Handoff', style: theme.textTheme.titleSmall),
const SizedBox(height: 4),
ChatMarkdownView(text: markdown),
],
],
);
}
}
/// One command: a status icon, the command, its status, exit code and
/// duration; expanding it shows the recorded output as selectable monospace.
class RunCheckCommandRow extends StatelessWidget {
const RunCheckCommandRow({super.key, required this.check});
final CheckCommandResult check;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final mono = (theme.textTheme.bodyMedium ?? const TextStyle()).copyWith(
fontFamily: appMonospaceFamily,
);
final color = runStatusColor(_state(check.status), theme.colorScheme);
final meta = check.meta;
return ExpansionTile(
tilePadding: EdgeInsets.zero,
childrenPadding: const EdgeInsets.only(bottom: 12),
expandedCrossAxisAlignment: CrossAxisAlignment.stretch,
leading: Icon(
_icon(check.status),
color: color,
semanticLabel: checkStatusLabel(check),
),
title: Text(
check.command.isEmpty ? '(no command)' : check.command,
style: mono,
),
subtitle: Text(
[checkStatusLabel(check), if (meta.isNotEmpty) meta].join(' · '),
),
children: [
if (check.output.isEmpty)
const Text(checkOutputEmpty)
else
DecoratedBox(
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(8),
),
child: Padding(
padding: const EdgeInsets.all(12),
child: SelectableText(check.output, style: mono),
),
),
if (check.truncated)
Padding(
padding: const EdgeInsets.only(top: 4),
child: Text(
checkOutputTruncated,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
),
],
);
}
static String _state(CheckCommandStatus status) => switch (status) {
CheckCommandStatus.passed => 'succeeded',
CheckCommandStatus.failed || CheckCommandStatus.timedOut => 'failed',
CheckCommandStatus.notRun || CheckCommandStatus.unknown => 'unknown',
};
static IconData _icon(CheckCommandStatus status) => switch (status) {
CheckCommandStatus.passed => Icons.check_circle_outline,
CheckCommandStatus.failed => Icons.cancel_outlined,
CheckCommandStatus.timedOut => Icons.timer_off_outlined,
CheckCommandStatus.notRun => Icons.remove_circle_outline,
CheckCommandStatus.unknown => Icons.help_outline,
};
}
@@ -6,6 +6,7 @@ import '../actions/cancel_run_action.dart';
import '../actions/retry_action.dart';
import '../actions/retry_eligibility.dart';
import 'run_decision_notice.dart';
import 'run_quota_notice.dart';
/// Native actions on the loaded run, all using the app's one gateway and
/// applying only accepted server detail through the same controller callback.
@@ -60,6 +61,7 @@ class RunDetailActions extends StatelessWidget {
],
),
RunDecisionNotice(run: run, gateway: gateway, onRunChanged: onRunChanged),
RunQuotaNotice(run: run, gateway: gateway, onRunChanged: onRunChanged),
],
);
}
@@ -1,6 +1,7 @@
import '../../../core/api_gateway.dart';
import '../../pipelines/pipeline_format.dart';
import '../domain/run_deletion.dart' show formatByteSize, runSizeBytes;
import '../domain/run_failure_class.dart' show runBudgetText;
import '../domain/run_tokens.dart';
import 'run_detail_visit_facts.dart';
@@ -68,6 +69,7 @@ List<DetailSummaryRow> detailSummaryRows(JsonMap run, {DateTime? now}) {
add('Tokens', tokenUsageDetail(usage));
add('Cost', tokenUsageCost(usage));
}
add('Budget', runBudgetText(run));
final retryOf = _number(run['retry_of'])?.toInt() ?? 0;
if (retryOf > 0) add('Retry of', 'run $retryOf');
// A diagnostic is a recorded document: its own whitespace is preserved, but a
@@ -133,6 +133,22 @@ String? detailVisitSkills(JsonMap step) {
return (option: option, reason: reason);
}
/// How many times the server sent its one "missing `# outcome`" repair
/// follow-up for this visit (`control.outcome_repairs`); 0 when not recorded,
/// which older servers and unrepaired visits both mean.
int detailVisitOutcomeRepairs(JsonMap step) {
final control = step['control'];
if (control is! Map) return 0;
final value = control['outcome_repairs'];
if (value is num) return value.toInt();
return int.tryParse('${value ?? ''}'.trim()) ?? 0;
}
/// The note a repaired visit shows under its facts.
String outcomeRepairNote(int repairs) => repairs == 1
? 'Outcome repaired by follow-up'
: 'Outcome repaired by follow-up ($repairs times)';
/// The visit's diagnostic exactly as recorded, or null when it is blank.
String? detailVisitDiagnostic(JsonMap step) => _text(step['diagnostic']);
@@ -21,6 +21,7 @@ class RunVisitFactsView extends StatelessWidget {
final facts = detailVisitFacts(step);
final verdict = detailVisitVerdict(step);
final diagnostic = detailVisitDiagnostic(step);
final repairs = detailVisitOutcomeRepairs(step);
return Padding(
key: const Key('run-visit-facts'),
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 12),
@@ -28,6 +29,23 @@ class RunVisitFactsView extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_FactGrid(facts: facts, style: style),
if (repairs > 0) ...[
const SizedBox(height: 8),
Row(
key: const Key('run-visit-outcome-repaired'),
children: [
Icon(
Icons.build_circle_outlined,
size: 16,
color: style.muted.color,
),
const SizedBox(width: 6),
Flexible(
child: Text(outcomeRepairNote(repairs), style: style.muted),
),
],
),
],
if (verdict != null) ...[
const SizedBox(height: 8),
Text('Verdict', style: style.heading),
@@ -57,10 +75,14 @@ class _FactGrid extends StatelessWidget {
static String _stateOf(VisitFact fact) {
final value = fact.value.trim().toLowerCase();
if (fact.label == 'Outcome') {
if (value == 'error' || value == 'failed' || value == 'blocked') {
if (value == 'error' ||
value == 'failed' ||
value == 'fail' ||
value == 'blocked') {
return 'failed';
}
if (value == 'success') return 'succeeded';
// A check stage routes `pass`/`fail`.
if (value == 'success' || value == 'pass') return 'succeeded';
return 'running';
}
return graphStatusState(fact.value);
@@ -4,6 +4,8 @@ import 'package:flutter/services.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/floating_destination_bar.dart';
import '../../changes/changes.dart';
import '../domain/check_step_output.dart';
import 'run_check_output_view.dart';
import 'run_detail_tab_bodies.dart';
import 'run_field_body.dart';
import '../../../ui/layout/sticky_section.dart';
@@ -216,6 +218,9 @@ class _VisitSummaryState extends State<_VisitSummary> {
);
final open = !_closed.contains(name);
const padding = EdgeInsets.fromLTRB(16, 0, 16, 16);
// A check visit's Output is its command results, not a field map.
final check = name == 'Output' ? checkStepOutput(value) : null;
final sliver = lazy && check == null;
return StickySection(
key: ValueKey('run-visit-section-$name'),
title: name,
@@ -224,13 +229,15 @@ class _VisitSummaryState extends State<_VisitSummary> {
if (!_closed.remove(name)) _closed.add(name);
}),
trailing: [copy],
body: lazy
body: sliver
? null
: Padding(
padding: padding,
child: RunFieldBody(value: value, empty: empty),
child: check != null
? RunCheckOutputView(output: check)
: RunFieldBody(value: value, empty: empty),
),
sliverBody: lazy
sliverBody: sliver
? SliverPadding(
padding: padding,
sliver: RunFieldSliver(value: value, empty: empty),
@@ -1,4 +1,5 @@
import '../../../core/api_gateway.dart';
import '../domain/check_step_output.dart';
import 'run_detail_visit_export.dart';
import 'run_detail_visit_recorded.dart';
@@ -18,6 +19,10 @@ const String visitSessionNoIdentity =
'Runtime error: this model stage has no recorded session identity.';
const String visitSessionNone = 'This visit has no harness session.';
/// A check stage runs commands, never a model, so it has no session at all.
const String visitSessionCheck =
'A check stage runs commands without a model; it has no harness session.';
/// An export that exists but cannot be resolved through the configured server.
const String visitSessionEndpointMissing =
'Set the server URL in Settings to open the session.';
@@ -94,6 +99,7 @@ String _noSessionMessage(JsonMap step) {
if (status == 'canceled' || status == 'interrupted') {
return visitSessionStopped;
}
if (checkStepOutput(step['output']) != null) return visitSessionCheck;
final model =
recordedText(step['provider']) != null ||
recordedText(step['model']) != null;
@@ -0,0 +1,68 @@
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../actions/resume_quota_action.dart';
import '../domain/run_quota.dart';
/// A run parked until a usage limit resets: when the limit resets and the run
/// resumes, the account that hit it, and "Resume now". The run's Cancel stays
/// with the other run actions. Nothing for any other run.
class RunQuotaNotice extends StatelessWidget {
const RunQuotaNotice({
super.key,
required this.run,
required this.gateway,
required this.onRunChanged,
this.now,
});
final JsonMap run;
final ApiGateway gateway;
final ValueChanged<JsonMap> onRunChanged;
/// The clock, for tests.
final DateTime? now;
@override
Widget build(BuildContext context) {
if (!isWaitingQuotaStatus(run['status'])) return const SizedBox.shrink();
final wait = runQuotaWait(run);
final meta = wait == null ? '' : quotaWaitMeta(wait, now: now);
final color = Theme.of(context).colorScheme.tertiary;
return Container(
key: const Key('run-quota-banner'),
width: double.infinity,
padding: const EdgeInsets.only(top: 8, bottom: 4),
child: Row(
children: [
Icon(Icons.hourglass_bottom, color: color, size: 18),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Semantics(
header: true,
child: const Text(
runWaitingQuotaLabel,
style: TextStyle(fontWeight: FontWeight.w600),
),
),
if (meta.isNotEmpty) ...[
const SizedBox(height: 2),
Text(meta, style: Theme.of(context).textTheme.bodySmall),
],
],
),
),
const SizedBox(width: 12),
ResumeQuotaRunAction(
run: run,
gateway: gateway,
onRunChanged: onRunChanged,
),
],
),
);
}
}