Files
mesh-delivery/modules/mesh-delivery-pipeline/internal/pipeline/stepoutput.go
T
jschoubben 38ad9ed84d R10: a step's output is read where its build seat's holder keeps it
runner_step_output (pipeline, mover, step) reads the step from the state
pipelines and asks the verb output of the build seat's holder on the node
its step key names, by the step's ask, once per artifact the step ran for;
a step that reads a shared run is answered by that run's ask. The runner
keeps no output of its own: the objects step-outputs go, with the step's
and the log entry's output and show's outputs; the runner seat's form
rises to 4. The manifest invokes the three build seats' output.

Builds: design 47 H2 §791; H-A-412 (1)
2026-11-22 01:34:54 +01:00

75 lines
2.4 KiB
Go

package pipeline
import (
"fmt"
"strings"
)
// OutputAt is where one step's output is kept (design 47 H2 §791): by the holder of the build seat the step was asked of,
// on the node the step key `<node>.<ask id>` names, read through that seat's verb `output` with the ask.
type OutputAt struct {
Artifact string `json:"artifact,omitempty"`
Seat string `json:"seat"`
Node string `json:"node"`
Ask string `json:"ask"`
}
// StepOutputs names where the output of a mover's step of a pipeline is kept, one per artifact the step ran for: the runner
// keeps no output of its own (§791), so runner_step_output asks each holder. A step that reads a shared run is answered by
// that run's ask and the seat its asking step was asked of. A step no build seat ran on a node is refused, naming why.
func (r Reads) StepOutputs(pipeline, mover, step string) ([]OutputAt, error) {
mover, step = strings.TrimSpace(mover), strings.TrimSpace(step)
if mover == "" || step == "" {
return nil, fmt.Errorf("name the pipeline, the mover and the step")
}
p, ok, err := r.pipeline(pipeline)
if err != nil {
return nil, err
}
if !ok {
return nil, fmt.Errorf("no pipeline %q in pipelines", pipeline)
}
seatOf := map[string]string{}
for _, s := range p.Steps {
if s.Ask != "" && s.Seat != "" {
seatOf[s.Ask] = s.Seat
}
}
var out []OutputAt
var why []string
for _, s := range p.Steps {
if s.Module != mover || s.Step != step {
continue
}
at := OutputAt{Artifact: s.Artifact, Seat: s.Seat, Node: s.Node, Ask: s.Ask}
if at.Ask == "" && len(s.Shared) > 0 {
at.Ask = s.Shared[0].Ask
}
if at.Seat == "" {
at.Seat = seatOf[at.Ask]
}
switch {
case at.Ask == "" || at.Node == "":
why = append(why, fmt.Sprintf("%s %s ran on no node (%s)", step, nameOf(s.Artifact, mover), s.Outcome))
case !BoundSeat(at.Seat):
why = append(why, fmt.Sprintf("%s %s was asked of %s, which keeps no output", step, nameOf(s.Artifact, mover), at.Seat))
default:
out = append(out, at)
}
}
if len(out) == 0 {
if len(why) == 0 {
return nil, fmt.Errorf("the pipeline %s holds no step %s of %s", p.Pipeline, step, mover)
}
return nil, fmt.Errorf("no output of the pipeline %s's step %s of %s is kept: %s", p.Pipeline, step, mover, strings.Join(why, "; "))
}
return out, nil
}
func nameOf(artifact, mover string) string {
if artifact != "" {
return artifact
}
return mover
}