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:
2026-12-03 12:52:16 +00:00
parent c4de1de27b
commit 87016ef5dc
47 changed files with 2674 additions and 129 deletions
@@ -0,0 +1,80 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/graph/domain/check_stage.dart';
import 'package:pipelines_app/features/graph/domain/graph_definition.dart';
import 'package:pipelines_app/features/graph/domain/stage_definition.dart';
Map<String, dynamic> _verify({Map<String, dynamic>? configs}) => {
'key': 'verify',
'type': 'check',
'configs':
configs ??
{
'command_timeout': '15m',
'timeout': '1h',
'keep_going': 'true',
'delivery': 'true',
},
'edges': {'pass': 'review', 'fail': 'implement', 'error': '#failure'},
'blocks': {'commands': 'go vet ./...\n\ngo test ./...\n'},
'prompt': '',
'output': '',
};
void main() {
test('a check stage reads its commands, one per non-blank line', () {
expect(isCheckStage(_verify()), isTrue);
expect(checkCommands(_verify()), ['go vet ./...', 'go test ./...']);
expect(isCheckStage({'type': 'model'}), isFalse);
expect(isCheckStage({'key': 'x'}), isFalse);
});
test('the delivery config marks the gate, and only on a check stage', () {
expect(isDeliveryGate(_verify()), isTrue);
expect(isDeliveryGate(_verify(configs: {'delivery': 'false'})), isFalse);
expect(isDeliveryGate(_verify(configs: {})), isFalse);
expect(
isDeliveryGate({
'type': 'model',
'configs': {'delivery': 'true'},
}),
isFalse,
);
});
test('graph nodes carry the stage type and the gate caption', () {
final nodes = graphNodes({
'stages': [
_verify(),
{
..._verify(configs: {}),
'key': 'lint',
},
{
'key': 'review',
'edges': {'success': '#'},
},
],
});
final byKey = {for (final node in nodes) node.key: node};
expect(byKey['verify']!.kindCaption, 'Delivery gate');
expect(byKey['lint']!.kindCaption, 'Check');
expect(byKey['review']!.kindCaption, isNull);
expect(byKey['#success']!.kindCaption, isNull);
});
test('a check definition lists its commands in place of a prompt', () {
final fields = stageDefinitionFields(_verify());
final byLabel = {for (final field in fields) field.label: field};
expect(byLabel['Type']!.value, 'check (delivery gate)');
final commands = byLabel['Commands']!;
expect(commands.value, 'go vet ./...\ngo test ./...');
expect(commands.monospace, isTrue);
expect(byLabel.containsKey('Prompt'), isFalse);
expect(byLabel['Command timeout']!.value, '15m');
expect(byLabel['Keep going']!.value, 'true');
expect(byLabel['Delivery gate']!.value, 'true');
expect(byLabel['Outcomes']!.value, contains('pass → review'));
expect(byLabel['Outcomes']!.value, contains('fail → implement'));
});
}