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>
131 lines
3.9 KiB
Dart
131 lines
3.9 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/pipelines/pipeline_format.dart'
|
|
show runStateLabel;
|
|
import 'package:pipelines_app/features/runs/domain/run_failure_class.dart';
|
|
import 'package:pipelines_app/features/runs/domain/run_models.dart';
|
|
import 'package:pipelines_app/features/runs/domain/run_outcome_line.dart';
|
|
import 'package:pipelines_app/features/runs/domain/run_quota.dart';
|
|
|
|
String _local(int hour, int minute) =>
|
|
DateTime(2026, 12, 3, hour, minute).toUtc().toIso8601String();
|
|
|
|
void main() {
|
|
final now = DateTime(2026, 12, 3, 8);
|
|
final parked = {
|
|
'id': 4,
|
|
'status': 'waiting_quota',
|
|
'quota_wait': {
|
|
'resets_at': _local(9, 0),
|
|
'resume_at': _local(9, 1),
|
|
'sequence': 3,
|
|
'stage': 'implement',
|
|
'account': 'work',
|
|
},
|
|
};
|
|
|
|
test('quota_wait parses and reads in local time', () {
|
|
final wait = runQuotaWait(parked)!;
|
|
expect(wait.sequence, 3);
|
|
expect(wait.stage, 'implement');
|
|
expect(wait.account, 'work');
|
|
expect(quotaResumeText(wait, now: now), 'resumes 09:01');
|
|
expect(
|
|
quotaWaitMeta(wait, now: now),
|
|
'Limit resets 09:00 · run resumes 09:01 · account work · at implement',
|
|
);
|
|
expect(runQuotaWait({'status': 'waiting_quota'}), isNull);
|
|
});
|
|
|
|
test('a resume on another day carries its date', () {
|
|
final later = DateTime(2026, 12, 4, 9, 1);
|
|
expect(quotaClockText(later, now: now), '4 Dec 09:01');
|
|
});
|
|
|
|
test('waiting_quota is its own state with its own words', () {
|
|
expect(runStateOf('waiting_quota'), 'waiting_quota');
|
|
expect(runStates, contains('waiting_quota'));
|
|
expect(runStateLabel('waiting_quota'), 'Waiting for usage limit');
|
|
expect(
|
|
runStatusLabel(parked, now: now),
|
|
'Waiting for usage limit · resumes 09:01',
|
|
);
|
|
expect(
|
|
runStatusLabel({'status': 'waiting_quota'}),
|
|
'Waiting for usage limit',
|
|
);
|
|
final filtered = filterRuns(
|
|
[
|
|
parked,
|
|
{'id': 5, 'status': 'waiting'},
|
|
],
|
|
statuses: {'waiting_quota'},
|
|
);
|
|
expect(filtered.map((run) => run['id']), [4]);
|
|
});
|
|
|
|
test('failure classes use the server wording', () {
|
|
expect(runFailureClassLabel({'failure_class': 'quota'}), 'usage limit');
|
|
expect(
|
|
runFailureClassLabel({'failure_class': 'loop_exhausted'}),
|
|
'loop limit reached',
|
|
);
|
|
expect(
|
|
runFailureClassLabel({'failure_class': 'budget'}),
|
|
'budget exhausted',
|
|
);
|
|
expect(runFailureClassLabel({'failure_class': 'new_kind'}), 'new kind');
|
|
expect(runFailureClassLabel({}), isNull);
|
|
expect(runFailureClassLabels.length, 12);
|
|
});
|
|
|
|
test('the outcome line leads with the failure class', () {
|
|
final line = runOutcomeLine({
|
|
'status': 'failed',
|
|
'failure_class': 'quota',
|
|
'failure_reason': 'Claude usage limit\nreset at 9',
|
|
})!;
|
|
expect(line.line, 'Failed · usage limit: Claude usage limit');
|
|
expect(line.full, 'Failed · usage limit: Claude usage limit\nreset at 9');
|
|
expect(line.failed, isTrue);
|
|
expect(
|
|
runOutcomeLine({'status': 'failed', 'failure_class': 'timeout'})?.line,
|
|
'Failed · timed out',
|
|
);
|
|
// The catch-all class adds nothing to the reason.
|
|
expect(
|
|
runOutcomeLine({
|
|
'status': 'failed',
|
|
'failure_class': 'other',
|
|
'failure_reason': 'exit 2',
|
|
})?.line,
|
|
'exit 2',
|
|
);
|
|
expect(
|
|
runOutcomeLine({'status': 'failed', 'failure_class': 'other'}),
|
|
isNull,
|
|
);
|
|
});
|
|
|
|
test('a capped run shows its budget', () {
|
|
expect(
|
|
runBudgetText({
|
|
'budget': {'limit_usd': 5, 'spent_usd': 1.25, 'source': 'run'},
|
|
}),
|
|
r'$1.25 of $5.00 budget',
|
|
);
|
|
expect(
|
|
runBudgetText({
|
|
'budget': {'limit_usd': 2, 'spent_usd': 0, 'source': 'server'},
|
|
}),
|
|
r'$0.00 of $2.00 budget (server default)',
|
|
);
|
|
expect(
|
|
runBudgetText({
|
|
'budget': {'limit_usd': 0},
|
|
}),
|
|
isNull,
|
|
);
|
|
expect(runBudgetText({}), isNull);
|
|
});
|
|
}
|