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));
|
||||
|
||||
Reference in New Issue
Block a user