Engine: check stages, harness-agnostic delivery, read-only enforcement, complete captures
- New `type=check` stage: the server runs a `commands` block (sh -c, per command_timeout, workspace env) and routes on pass/fail; per-command status, exit code, duration and bounded output are recorded and the failing output is the handoff. With delivery=true it is the landing gate (commit leftovers, merge moved main, checks in a fresh candidate worktree, fast-forward main). Parser/registry, lint (silent guards), format docs, CLI inspect, app graph and run detail rendering. - delivery=true is accepted on every harness (and on check stages). - permissions.shell on claude stages maps to Bash(cmd) / Bash(prefix:*) rules instead of a bare Bash allow; stages without edit that change the workspace fail the visit with the changed files listed (allow_workspace_changes=true opts out; artifacts, public and harness state dirs are ignored). - File-change capture: symlinks compared by target, untouched protected files no longer make captures partial, untracked caches/dependency/build output left out, lockfiles listed without patch, huge files compared by metadata, raised patch/line limits. Outcome repair follow-ups are logged and counted on the step (control.outcome_repairs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// The `check` stage type: a model-free stage that runs shell commands and
|
||||
// routes `pass`/`fail` (plus `error`). Its `delivery` config marks the landing
|
||||
// gate, which runs the commands in a fresh worktree and fast-forwards main on
|
||||
// pass. Pure data only; an older graph simply has no check stages.
|
||||
|
||||
/// The stage type word the server uses for a check stage.
|
||||
const String checkStageType = 'check';
|
||||
|
||||
/// Whether [stage] (a graph stage declaration) is a check stage.
|
||||
bool isCheckStage(dynamic stage) =>
|
||||
stage is Map && '${stage['type'] ?? ''}'.trim() == checkStageType;
|
||||
|
||||
/// Whether a check [stage] is the delivery (landing) gate.
|
||||
///
|
||||
/// Configs are strings on the wire (`"true"`); a JSON boolean is accepted too.
|
||||
bool isDeliveryGate(dynamic stage) {
|
||||
if (!isCheckStage(stage)) return false;
|
||||
final configs = (stage as Map)['configs'];
|
||||
if (configs is! Map) return false;
|
||||
final value = configs['delivery'];
|
||||
return value == true || '${value ?? ''}'.trim().toLowerCase() == 'true';
|
||||
}
|
||||
|
||||
/// The check stage's commands, one per non-blank line of `blocks.commands`
|
||||
/// (a list of strings is read item by item), in declared order.
|
||||
List<String> checkCommands(dynamic stage) {
|
||||
if (stage is! Map) return const <String>[];
|
||||
final blocks = stage['blocks'];
|
||||
if (blocks is! Map) return const <String>[];
|
||||
final raw = blocks['commands'];
|
||||
final lines = raw is List
|
||||
? [for (final item in raw) '${item ?? ''}']
|
||||
: '${raw ?? ''}'.split('\n');
|
||||
return [
|
||||
for (final line in lines)
|
||||
if (line.trim().isNotEmpty) line.trimRight(),
|
||||
];
|
||||
}
|
||||
|
||||
/// The short kind a graph node shows under its name: `Check` or
|
||||
/// `Delivery gate`, or null for every other stage type.
|
||||
String? checkStageCaption({required String type, required bool delivery}) {
|
||||
if (type.trim() != checkStageType) return null;
|
||||
return delivery ? 'Delivery gate' : 'Check';
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'check_stage.dart';
|
||||
import 'graph_protocol.dart';
|
||||
|
||||
/// The graph definition: nodes and edges declared by a pipeline, never the
|
||||
@@ -70,11 +71,27 @@ class GraphEdge {
|
||||
/// One graph definition node: a declared stage, or a terminal the definition
|
||||
/// routes to.
|
||||
class GraphNode {
|
||||
const GraphNode({required this.key, required this.terminal, this.stageIndex});
|
||||
const GraphNode({
|
||||
required this.key,
|
||||
required this.terminal,
|
||||
this.stageIndex,
|
||||
this.type = '',
|
||||
this.delivery = false,
|
||||
});
|
||||
|
||||
final String key;
|
||||
final bool terminal;
|
||||
|
||||
/// The stage's declared `type` exactly as recorded (blank reads `model`);
|
||||
/// empty for a terminal.
|
||||
final String type;
|
||||
|
||||
/// Whether this is a check stage marked as the delivery gate.
|
||||
final bool delivery;
|
||||
|
||||
/// `Check` or `Delivery gate` for a check stage, otherwise null.
|
||||
String? get kindCaption => checkStageCaption(type: type, delivery: delivery);
|
||||
|
||||
/// The node's stage declaration index, or null for a terminal.
|
||||
final int? stageIndex;
|
||||
|
||||
@@ -142,7 +159,15 @@ List<GraphNode> graphNodes(dynamic graph) {
|
||||
for (var index = 0; index < stages.length; index += 1) {
|
||||
final key = _stageKey(stages[index]);
|
||||
if (key.isEmpty || !seen.add(key)) continue;
|
||||
nodes.add(GraphNode(key: key, terminal: false, stageIndex: index));
|
||||
nodes.add(
|
||||
GraphNode(
|
||||
key: key,
|
||||
terminal: false,
|
||||
stageIndex: index,
|
||||
type: '${stages[index]['type'] ?? ''}',
|
||||
delivery: isDeliveryGate(stages[index]),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (graphEdges(graph).any((edge) => edge.isTerminal)) {
|
||||
nodes.add(const GraphNode(key: failureEnd, terminal: true));
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'check_stage.dart';
|
||||
import 'graph_definition.dart';
|
||||
import 'graph_protocol.dart';
|
||||
|
||||
@@ -9,13 +10,22 @@ import 'graph_protocol.dart';
|
||||
/// reads run visits, so a definition can be inspected without claiming that a
|
||||
/// stage executed.
|
||||
class StageDefinitionField {
|
||||
const StageDefinitionField(this.label, this.value, {this.block = false});
|
||||
const StageDefinitionField(
|
||||
this.label,
|
||||
this.value, {
|
||||
this.block = false,
|
||||
this.monospace = false,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final String value;
|
||||
|
||||
/// Multi-line content (prompt, output, outcomes, tools, memory, routes).
|
||||
final bool block;
|
||||
|
||||
/// Literal code (a check stage's commands): always shown verbatim in a
|
||||
/// monospace block, never rendered as markdown.
|
||||
final bool monospace;
|
||||
}
|
||||
|
||||
/// The one stage declaration [key] names, or null when this version does not
|
||||
@@ -58,6 +68,12 @@ String stageConfigLabel(String key) {
|
||||
return 'Budget (tokens)';
|
||||
case 'harness':
|
||||
return 'Harness';
|
||||
case 'command_timeout':
|
||||
return 'Command timeout';
|
||||
case 'keep_going':
|
||||
return 'Keep going';
|
||||
case 'delivery':
|
||||
return 'Delivery gate';
|
||||
default:
|
||||
return key;
|
||||
}
|
||||
@@ -69,10 +85,27 @@ String stageConfigLabel(String key) {
|
||||
/// interpreted here; the pane keeps the stage's raw JSON so they stay visible.
|
||||
List<StageDefinitionField> stageDefinitionFields(dynamic stage) {
|
||||
if (stage is! Map) return const <StageDefinitionField>[];
|
||||
final type = effectiveStageType(stage['type']);
|
||||
final fields = <StageDefinitionField>[
|
||||
StageDefinitionField('Type', effectiveStageType(stage['type'])),
|
||||
StageDefinitionField(
|
||||
'Type',
|
||||
isDeliveryGate(stage) ? '$type (delivery gate)' : type,
|
||||
),
|
||||
];
|
||||
|
||||
// A check stage runs commands where a model stage has its prompt.
|
||||
final commands = checkCommands(stage);
|
||||
if (isCheckStage(stage) && commands.isNotEmpty) {
|
||||
fields.add(
|
||||
StageDefinitionField(
|
||||
'Commands',
|
||||
commands.join('\n'),
|
||||
block: true,
|
||||
monospace: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final prompt = _text(stage['prompt']);
|
||||
if (prompt.trim().isNotEmpty) {
|
||||
fields.add(StageDefinitionField('Prompt', prompt, block: true));
|
||||
|
||||
@@ -45,10 +45,7 @@ class GraphStageNode extends StatelessWidget {
|
||||
return status != null && status.trim().isNotEmpty ? status : null;
|
||||
}
|
||||
|
||||
String get _label {
|
||||
final status = _status;
|
||||
return status == null ? node.label : '${node.label}\n$status';
|
||||
}
|
||||
String get _label => graphNodeSemanticsLabel(node, _status);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -112,11 +109,13 @@ class GraphStageNode extends StatelessWidget {
|
||||
graphStatusState(status),
|
||||
Theme.of(context).colorScheme,
|
||||
);
|
||||
final caption = node.kindCaption;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(_breakable(node.label), softWrap: true),
|
||||
if (caption != null) _kind(context, caption),
|
||||
if (status != null)
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -144,6 +143,29 @@ class GraphStageNode extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// A check stage's kind under its name: the check icon (a gate icon for the
|
||||
/// delivery gate) and `Check`/`Delivery gate` in the muted label role.
|
||||
Widget _kind(BuildContext context, String caption) {
|
||||
final theme = Theme.of(context);
|
||||
final color = theme.colorScheme.onSurfaceVariant;
|
||||
final style = (theme.textTheme.labelSmall ?? const TextStyle()).copyWith(
|
||||
color: color,
|
||||
);
|
||||
return Row(
|
||||
key: ValueKey('graph-node-kind-${node.key}'),
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
checkStageIcon(delivery: node.delivery),
|
||||
size: (style.fontSize ?? 11) * 1.4,
|
||||
color: color,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Flexible(child: Text(caption, style: style, softWrap: true)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// The web node uses `overflow-wrap: anywhere`; Flutter text does not break a
|
||||
/// long unbroken key, so the same invisible break opportunities are added.
|
||||
/// The visible text and the semantics label stay unchanged.
|
||||
@@ -265,6 +287,18 @@ class StageActivityHaloPainter extends CustomPainter {
|
||||
oldDelegate.color != color || oldDelegate.progress != progress;
|
||||
}
|
||||
|
||||
/// The icon for a check stage; the delivery gate gets the landing icon.
|
||||
IconData checkStageIcon({required bool delivery}) =>
|
||||
delivery ? Icons.verified_outlined : Icons.fact_check_outlined;
|
||||
|
||||
/// A node's accessible name: its label, a check stage's kind, then the run's
|
||||
/// recorded status when there is one.
|
||||
String graphNodeSemanticsLabel(GraphNode node, String? status) => [
|
||||
node.label,
|
||||
?node.kindCaption,
|
||||
if (status != null && status.trim().isNotEmpty) status,
|
||||
].join('\n');
|
||||
|
||||
/// The run state a recorded step status colours as: done is green, an error or
|
||||
/// a block is red, running is blue, waiting teal, anything else grey.
|
||||
String graphStatusState(String status) {
|
||||
|
||||
@@ -341,7 +341,7 @@ class RunGraphNode extends StatelessWidget {
|
||||
}
|
||||
return Semantics(
|
||||
container: true,
|
||||
label: status == null ? node.label : '${node.label}\n$status',
|
||||
label: graphNodeSemanticsLabel(node, status),
|
||||
child: ExcludeSemantics(
|
||||
child: IgnorePointer(
|
||||
child: GraphStageNode(
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/text/markdown_source_view.dart';
|
||||
import '../../../ui/text/monospace.dart';
|
||||
import '../../chat/ui/transcript/chat_markdown_view.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
@@ -190,8 +191,15 @@ class _StageDefinitionFieldView extends StatelessWidget {
|
||||
children: [
|
||||
Text(field.label, style: style.label),
|
||||
const SizedBox(height: 4),
|
||||
// Commands are literal code: verbatim and monospace in either mode.
|
||||
if (field.monospace)
|
||||
_SelectableDefinitionText(
|
||||
key: ValueKey('stage-definition-${field.label}'),
|
||||
value: field.value,
|
||||
style: style.value.copyWith(fontFamily: appMonospaceFamily),
|
||||
)
|
||||
// An authored text block (a prompt) is markdown: rendered or raw.
|
||||
if (field.block && raw)
|
||||
else if (field.block && raw)
|
||||
_SelectableDefinitionText(value: field.value, style: style.value)
|
||||
else if (field.block)
|
||||
ChatMarkdownView(text: field.value)
|
||||
@@ -215,7 +223,11 @@ class _StageDefinitionFieldView extends StatelessWidget {
|
||||
/// fallback font with taller metrics and double-space only that block. It is
|
||||
/// the host's own line metrics, not a font override or a fixed height.
|
||||
class _SelectableDefinitionText extends StatelessWidget {
|
||||
const _SelectableDefinitionText({required this.value, required this.style});
|
||||
const _SelectableDefinitionText({
|
||||
super.key,
|
||||
required this.value,
|
||||
required this.style,
|
||||
});
|
||||
|
||||
final String value;
|
||||
final TextStyle style;
|
||||
|
||||
Reference in New Issue
Block a user