Files
pipelines/internal/stage/human.go
T
alan 85a7284fba Stages: optional skills block loading pinned library skills per visit
A model stage may declare a skills block (name or name@N per line).
Drafts and publications are validated against the server skill library;
human/ntfy stages reject the block. Each run resolves unpinned names to the
latest version at admission and records name@N per stage (run
stage_skills, step skills); retry reuses the recorded versions. Every visit
gets a private read-only copy of exactly those bundles under the run's
artifact tree, and the harness loads only them: Claude via a session
plugin (--plugin-dir, Skill tool with per-skill allow rules, bundled skills
off, ambient loads fail the visit), Pi via --skill under --no-skills, and
OpenCode via per-session instruction entries (V2 only). The app shows the
block in the stage definition and the resolved versions on each visit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 19:17:16 +00:00

63 lines
2.0 KiB
Go

package stage
import (
"context"
"fmt"
"sort"
"strings"
)
const HumanType = "human"
// HumanStage pauses its run until a person chooses one of the stage's outgoing
// options. It has no model, agent, tools or configs: its outcomes are exactly
// its non-error edges (the selectable options) and its required prompt block
// carries the operator instructions. It parses, validates, renders, exports and
// imports like every other registered type. The runner owns the wait and the
// decision path; Run is defensive only and never executes synchronously.
type HumanStage struct{}
func (HumanStage) Validate(def Definition) error {
if EffectiveType(def.Type) != HumanType {
return fmt.Errorf("expected human stage")
}
for name := range def.Blocks {
switch name {
case "configs", "edges", "output", "prompt":
case "skills":
return errSkillsModelOnly("human")
default:
return fmt.Errorf("unexpected block %q for human stage", name)
}
}
for key := range def.Configs {
return fmt.Errorf("unknown human config %q", key)
}
if strings.TrimSpace(def.Blocks["prompt"]) == "" {
return fmt.Errorf("human stage requires a nonempty prompt block with the operator instructions")
}
if len(HumanOptions(def.Edges)) == 0 {
return fmt.Errorf("human stage requires at least one non-error option edge")
}
return nil
}
func (HumanStage) Run(context.Context, Definition, Values) (Result, error) {
return Result{}, fmt.Errorf("human stage is resolved by the runner's decision path, not executed")
}
// HumanOptions is the single definition of a human stage's selectable outcomes:
// its non-error edges in a deterministic order. The mandatory error edge is a
// failure route, not an operator choice, so it is never returned. Store, runner
// and TUI all read this one helper, so the option set cannot drift.
func HumanOptions(edges map[string]string) []string {
options := make([]string, 0, len(edges))
for outcome := range edges {
if outcome != "error" {
options = append(options, outcome)
}
}
sort.Strings(options)
return options
}