b3c9575fde
- 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>
109 lines
3.2 KiB
Dart
109 lines
3.2 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/runs/domain/run_events.dart';
|
|
|
|
void main() {
|
|
const wait = {
|
|
'resets_at': '2026-12-03T09:00:00Z',
|
|
'resume_at': '2026-12-03T09:01:00Z',
|
|
'sequence': 2,
|
|
'stage': 'implement',
|
|
'account': 'work',
|
|
};
|
|
final running = {
|
|
'id': 4,
|
|
'pipeline_id': 1,
|
|
'name': 'build',
|
|
'status': 'running',
|
|
'executing': true,
|
|
};
|
|
|
|
test('a running run parks with its wait and resumes without it', () {
|
|
final parked = foldRunEvent(
|
|
[running],
|
|
{'run_id': 4, 'status': 'waiting_quota', 'quota_wait': wait},
|
|
).runs.single;
|
|
expect(parked['status'], 'waiting_quota');
|
|
expect(parked['executing'], isFalse);
|
|
expect(parked['quota_wait'], wait);
|
|
// A frame without a status keeps the wait.
|
|
final same = foldRunEvent(
|
|
[parked],
|
|
{'run_id': 4, 'current_stage': 'implement'},
|
|
).runs.single;
|
|
expect(same['quota_wait'], wait);
|
|
final resumed = foldRunEvent(
|
|
[parked],
|
|
{'run_id': 4, 'status': 'running'},
|
|
).runs.single;
|
|
expect(resumed['status'], 'running');
|
|
expect(resumed['executing'], isTrue);
|
|
expect(resumed.containsKey('quota_wait'), isFalse);
|
|
});
|
|
|
|
test('a deferred run goes back to queued when resumed', () {
|
|
final deferred = {
|
|
...running,
|
|
'status': 'waiting_quota',
|
|
'executing': false,
|
|
};
|
|
final queued = foldRunEvent(
|
|
[deferred],
|
|
{'run_id': 4, 'status': 'queued'},
|
|
).runs.single;
|
|
expect(queued['status'], 'queued');
|
|
expect(queued['executing'], isTrue);
|
|
final parkedAgain = foldRunEvent(
|
|
[queued],
|
|
{'run_id': 4, 'status': 'waiting_quota', 'quota_wait': wait},
|
|
).runs.single;
|
|
expect(parkedAgain['status'], 'waiting_quota');
|
|
});
|
|
|
|
test('a parked run can be canceled and records the failure class', () {
|
|
final parked = {...running, 'status': 'waiting_quota', 'quota_wait': wait};
|
|
final canceled = foldRunEvent(
|
|
[parked],
|
|
{'run_id': 4, 'status': 'canceled', 'failure_class': 'canceled'},
|
|
).runs.single;
|
|
expect(canceled['status'], 'canceled');
|
|
expect(canceled['failure_class'], 'canceled');
|
|
expect(canceled.containsKey('quota_wait'), isFalse);
|
|
// Terminal stays terminal.
|
|
final stale = foldRunEvent(
|
|
[canceled],
|
|
{'run_id': 4, 'status': 'waiting_quota'},
|
|
).runs.single;
|
|
expect(stale['status'], 'canceled');
|
|
});
|
|
|
|
test('the detail folds the same fields and re-reads on parking', () {
|
|
final detail = foldRunEventDetail(
|
|
{...running, 'steps': []},
|
|
{
|
|
'run_id': 4,
|
|
'status': 'failed',
|
|
'failure_class': 'quota',
|
|
'failure_reason': 'usage limit',
|
|
},
|
|
)!;
|
|
expect(detail['failure_class'], 'quota');
|
|
expect(
|
|
runDetailNeedsFullSync({'run_id': 4, 'status': 'waiting_quota'}),
|
|
isTrue,
|
|
);
|
|
});
|
|
|
|
test('a new row from a parked frame keeps its wait', () {
|
|
final row = newRunSummaryFromFrame({
|
|
'run_id': 9,
|
|
'pipeline_id': 1,
|
|
'name': 'build',
|
|
'status': 'waiting_quota',
|
|
'quota_wait': wait,
|
|
})!;
|
|
expect(row['executing'], isFalse);
|
|
expect(row['quota_wait'], wait);
|
|
expect(row['failure_class'], '');
|
|
});
|
|
}
|