Add a human decision stage that pauses a run for an operator's choice

A new registered stage type `human` (internal/stage/human.go) has no model,
agent, tools or configs: its required `prompt` block carries the operator
instructions and its non-error edges are the selectable options. It parses,
validates, renders, exports and imports like every other type (no parser
special-case, no config keys).

At runtime the runner parks the run instead of executing: the step and the run
persist `waiting` with self-contained {prompt, options} evidence, and the run
returns without starting later stages, capturing file diffs, scanning artifacts,
holding a goroutine/timer or applying a stage timeout. The wait is durable: a
restart leaves the waiting rows untouched (RecoverRuns excludes them) and a
rebuilt runtime over the same database still accepts the decision.

`pipelines decide <run-id> [stage] --option KEY [--feedback TEXT] [--json]` and
the TUI `c` picker resolve the decision from the pinned graph in one store
transaction, record the choice and feedback as the step's evidence and resume
along edges[KEY]. An unknown option is refused with the valid list, a stage that
is not waiting is refused, and a repeated decision for an already-decided visit
does not double-apply. Cancel and retry keep working while waiting and after a
decision; a human stage is never killed by a stage timeout or max_visits, and a
`notify` policy can fire an `on=waiting` event.

Docs: the authoring skill references (format.md, operations.md), docs/cli.md and
README describe the stage, the command and the TUI picker. Tests cover stage
validation, the parsing round-trip, the store transitions, a websocket wait/decide
integration, cancel/retry, waiting notifications and a persistence-layer rebuild
(second Open + newRunner over one database, no process restart).
This commit is contained in:
2026-10-16 16:47:28 +01:00
parent 1b4674d22c
commit a6aff47117
32 changed files with 1782 additions and 87 deletions
+5 -3
View File
@@ -15,12 +15,14 @@ import (
"unicode/utf8"
)
func (r *runner) notifyStep(id int64, d *protocol.PipelineDetail, workspace string, policy *protocol.NotificationPolicy, step protocol.RunStep) {
func (r *runner) notifyStep(id int64, name, workspace string, policy *protocol.NotificationPolicy, step protocol.RunStep) {
if policy == nil {
return
}
event := "success"
if step.Status != "completed" || step.Outcome == "error" || step.Target == protocol.FailureEnd {
if step.Status == protocol.StepStatusWaiting || step.Outcome == protocol.StepStatusWaiting {
event = protocol.NotifyWaiting
} else if step.Status != "completed" || step.Outcome == "error" || step.Target == protocol.FailureEnd {
event = "failure"
}
enabled := false
@@ -34,7 +36,7 @@ func (r *runner) notifyStep(id int64, d *protocol.PipelineDetail, workspace stri
}
ctx, cancel := context.WithTimeout(r.ctx, 30*time.Second)
defer cancel()
summary := fmt.Sprintf("%s · run #%d · stage %s · %s (%s)", d.Name, id, step.Stage, event, step.Outcome)
summary := fmt.Sprintf("%s · run #%d · stage %s · %s (%s)", name, id, step.Stage, event, step.Outcome)
if len(summary) > 1800 {
summary = summary[:1800]
for !utf8.ValidString(summary) {