fix(workflow): reject execution plans with unreachable stages

Live repro: the architect wired all three stages straight to 'done'
instead of chaining them, so phase 2 legitimately completed after
stage 1 of 3 — a silently truncated plan reported as success. The
compiler now walks the edge graph from start and fails compilation
when any declared stage is unreachable, surfacing the broken topology
as ExecutionPlanRejected at lock time instead. Architect prompt edge
rules rewritten to demand explicit chaining (the old wording was
garbled).
This commit is contained in:
2026-06-12 12:55:17 +04:00
parent c25ba27e57
commit a4f0c6d0a2
3 changed files with 69 additions and 2 deletions
@@ -67,14 +67,17 @@ Emit a JSON object that validates against the `execution_plan` schema:
- `from` and `to` must each be a declared stage `id` or the literal string `"done"`.
- The normal forward edge uses `"type": "artifact_validated"` with `artifact_id` set to
the `produces` id of the `from` stage.
- Chain sequential stages: stage N's edge goes `to` stage N+1, not to `"done"`. Only the
final stage's edge points to `"done"`. A plan where an intermediate stage jumps to
`"done"` ends the whole workflow there and never runs the remaining stages.
- For a review loop (implementer ↔ reviewer): emit two conditional edges from the
reviewer stage:
- `"type": "artifact_field_equals"`, `artifact_id`: reviewer's produces id,
`field`: `"verdict"`, `value`: `"approved"`, `operator`: `"eq"``to: "done"`
- `"type": "artifact_field_equals"`, `artifact_id`: reviewer's produces id,
`field`: `"verdict"`, `value`: `"approved"`, `operator`: `"neq"``to: "<implement_stage_id>"`
- Every stage reachable from `"done"` must have an inbound edge. Every non-terminal stage
must have an outbound edge.
- Every stage except the first must have an inbound edge from an earlier stage; every
stage must have an outbound edge. Unreachable stages fail to compile.
## Constraints