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:
@@ -0,0 +1,96 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/attention/domain/attention_models.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/cancel_eligibility.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/cancel_wording.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/resume_quota_action.dart';
|
||||
import 'package:pipelines_app/features/runs/domain/run_decisions.dart';
|
||||
import 'package:pipelines_app/features/runs/domain/run_models.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_actions.dart';
|
||||
|
||||
import 'cancel_test_support.dart';
|
||||
|
||||
JsonMap _parked({bool cancelRequested = false}) => {
|
||||
'id': 7,
|
||||
'title': 'Nightly build',
|
||||
'status': 'waiting_quota',
|
||||
'executing': false,
|
||||
'cancel_requested': cancelRequested,
|
||||
'quota_wait': {
|
||||
'resets_at': DateTime(2026, 12, 3, 9).toUtc().toIso8601String(),
|
||||
'resume_at': DateTime(2026, 12, 3, 9, 1).toUtc().toIso8601String(),
|
||||
'sequence': 2,
|
||||
'stage': 'implement',
|
||||
'account': 'work',
|
||||
},
|
||||
};
|
||||
|
||||
Future<List<JsonMap>> _pump(
|
||||
WidgetTester tester,
|
||||
FakeCancelGateway gateway,
|
||||
) async {
|
||||
final changed = <JsonMap>[];
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: RunDetailActions(
|
||||
run: _parked(),
|
||||
gateway: gateway,
|
||||
onRunChanged: changed.add,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
return changed;
|
||||
}
|
||||
|
||||
void main() {
|
||||
test('a parked run is cancellable and resumable, never a decision', () {
|
||||
final run = _parked();
|
||||
expect(canCancelRun(run), isTrue);
|
||||
expect(canResumeQuotaRun(run), isTrue);
|
||||
expect(canResumeQuotaRun(_parked(cancelRequested: true)), isFalse);
|
||||
expect(canCancelRun(_parked(cancelRequested: true)), isFalse);
|
||||
expect(canResumeQuotaRun({'id': 7, 'status': 'waiting'}), isFalse);
|
||||
expect(attentionKindForRun(run), isNull);
|
||||
expect(orderAttention([run]), isEmpty);
|
||||
expect(pendingDecision(run), isNull);
|
||||
});
|
||||
|
||||
testWidgets('Resume now sends resume_run and applies the reply', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = FakeCancelGateway(
|
||||
(type, fields) async => {
|
||||
'type': 'run',
|
||||
'run_detail': {'id': 7, 'status': 'running', 'executing': true},
|
||||
},
|
||||
);
|
||||
final changed = await _pump(tester, gateway);
|
||||
expect(find.text('Waiting for usage limit'), findsOneWidget);
|
||||
expect(find.textContaining('account work'), findsOneWidget);
|
||||
expect(find.byKey(cancelActionKey), findsOneWidget);
|
||||
await tester.tap(find.byKey(resumeQuotaActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.calls.single.type, 'resume_run');
|
||||
expect(gateway.calls.single.fields, {'run_id': 7});
|
||||
expect(changed.single['status'], 'running');
|
||||
});
|
||||
|
||||
testWidgets('a refused resume shows the server message', (tester) async {
|
||||
final gateway = FakeCancelGateway(
|
||||
(type, fields) async =>
|
||||
throw Exception('run 7 is not waiting for a usage limit'),
|
||||
);
|
||||
final changed = await _pump(tester, gateway);
|
||||
await tester.tap(find.byKey(resumeQuotaActionKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(resumeQuotaErrorKey), findsOneWidget);
|
||||
expect(
|
||||
find.textContaining('not waiting for a usage limit'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(changed, isEmpty);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user