ebe79ebed0
Run detail gains a Findings tab (open-count badge) listing the server's findings ledger with status and minimum-severity filters and expandable event history; visit grants show as an Extra visits summary fact. The resume retry prompt can grant 1-5 extra visits to the exhausted stage or a chosen graph stage (never sent on restart), suggested when the run failed on a visit limit. A loop-exhaustion decision waiting on a model stage is now decidable from its recorded options, with readable labels, targets and the visit count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.4 KiB
Dart
40 lines
1.4 KiB
Dart
import '../../../core/api_gateway.dart';
|
|
|
|
/// The most extra visits one retry may grant (the server accepts 1-5).
|
|
const maxRetryExtraVisits = 5;
|
|
|
|
/// The diagnostic phrases with which the server reports an exhausted loop.
|
|
const _exhaustedPhrases = [
|
|
'visit limit reached',
|
|
'visit budget exceeded',
|
|
'total stage budget exceeded',
|
|
];
|
|
|
|
/// Whether [run] failed because a loop exhausted its visits: its diagnostic
|
|
/// names a visit limit or budget, or a recorded step's control says the limit
|
|
/// was reached. Retrying it with extra visits is then worth suggesting.
|
|
bool runExhaustedVisits(JsonMap run) {
|
|
final diagnostic = '${run['diagnostic'] ?? ''}'.toLowerCase();
|
|
if (_exhaustedPhrases.any(diagnostic.contains)) return true;
|
|
final steps = run['steps'];
|
|
if (steps is! List) return false;
|
|
return steps.whereType<Map>().any(
|
|
(step) =>
|
|
step['control'] is Map && step['control']['limit_reached'] == true,
|
|
);
|
|
}
|
|
|
|
/// The stage keys of the run's graph, in declared order, for the extra
|
|
/// visits stage picker.
|
|
List<String> retryStageKeys(JsonMap run) {
|
|
final graph = run['graph'];
|
|
final stages = graph is Map ? graph['stages'] : null;
|
|
if (stages is! List) return const [];
|
|
final keys = <String>[];
|
|
for (final stage in stages.whereType<Map>()) {
|
|
final key = '${stage['key'] ?? ''}'.trim();
|
|
if (key.isNotEmpty && !keys.contains(key)) keys.add(key);
|
|
}
|
|
return keys;
|
|
}
|