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:
@@ -105,6 +105,46 @@ Use this block for intentional file/command restrictions; prose is not a runtime
|
||||
permission policy. Keep ordinary workflows language-neutral and unrestricted
|
||||
within their run directory unless the user asks for a narrower scope.
|
||||
|
||||
## Human (decision) stages
|
||||
|
||||
A `type=human` stage pauses its run until a person chooses one of its outgoing
|
||||
options. It has no model, agent, tools or configs: it needs a nonempty `prompt`
|
||||
block (the operator instructions) and at least one non-`error` `edges` outcome.
|
||||
Its outcomes are exactly its non-error edges, so a draft can express choices such
|
||||
as `deploy`, `revise` or `abort`; the mandatory error edge is a failure route,
|
||||
not a choice. It validates, renders, exports and imports like every other type.
|
||||
|
||||
````markdown
|
||||
# stage gate
|
||||
|
||||
```output
|
||||
The operator's decision evidence.
|
||||
```
|
||||
|
||||
```prompt
|
||||
Review the screenshots and artifacts above, then choose where the run goes.
|
||||
```
|
||||
|
||||
```edges
|
||||
deploy -> publish
|
||||
revise -> worker
|
||||
abort -> #failure
|
||||
error -> #failure
|
||||
```
|
||||
````
|
||||
|
||||
When a run reaches a human stage its step becomes `waiting`, the run reports it is
|
||||
waiting on a person, and nothing later runs. Decide from the TUI (open the run,
|
||||
press `c`, pick an option, optionally type feedback, Enter) or the CLI:
|
||||
`pipelines decide <run-id> [stage] --option KEY [--feedback TEXT]`. The decision
|
||||
and feedback are recorded as the step's evidence (the feedback stays in the step
|
||||
output, never an error diagnostic) and the run resumes along that
|
||||
edge. The wait is persisted, so it survives a server restart. An unknown option is
|
||||
refused with the valid list; a decision to a stage that is not waiting is refused;
|
||||
a repeated decision for an already-decided visit does not double-apply. Cancel and
|
||||
retry keep working while waiting and after a decision, and a human stage is never
|
||||
killed by a stage timeout or `max_visits` (the shared run budget still applies).
|
||||
|
||||
Malformed final JSON has bounded recovery even with `retries=0`; it never changes
|
||||
verdict/evidence. Recovery tries a deterministic local pass first (append missing
|
||||
closing delimiters, drop one trailing comma, or insert the single comma/colon the
|
||||
@@ -139,7 +179,8 @@ are not approved. Warn explicitly before adding/changing schedules.
|
||||
## Notifications
|
||||
|
||||
Stage hooks use the global phone connection, never store credentials. Optional
|
||||
fenced `notify` block: `on=success,failure`, `artifacts=markdown`.
|
||||
fenced `notify` block: `on=success,failure` (add `waiting` to fire when a human
|
||||
stage parks the run), `artifacts=markdown`.
|
||||
Read this skill's `references/notifications.md` for the minimal terminal-path
|
||||
recipe and optional native publisher format. Prefer hooks for ordinary success/error
|
||||
alerts; a request to notify is not a request for a new delivery stage. Do not scan
|
||||
|
||||
Reference in New Issue
Block a user