BM4b (sdk): an end over the steps state's value is read through the verb answer

A step's end is an event, not a verb's answer, so an end over what the steps
state's value or step-ended carries has a reader of its own: keepOver keeps it
in the steps objects as answer.<ask>, the step key and step-ended carry
answer-object in place of output-object, and the build seats gain the read
verb answer (ask and call, marked chunks); output stays the run text's reader.
Step.Whole and StepEnded.ReadOutput read through answer.

Builds: design 47 H2 §791; H-A-412 (2) and its addendum
This commit is contained in:
2026-11-22 01:08:58 +01:00
parent 8617b521a6
commit fad9f059ee
40 changed files with 442 additions and 171 deletions
+12 -12
View File
@@ -83,10 +83,10 @@ type Puller struct {
// every ProgressEvery while it runs, step-ended when an ask outside a pipeline ends (design 47 G §496, §602). Nil says
// none, a test's. ProgressEvery defaults to DefaultProgressEvery.
Say func(event string, body any, id string) error
// KeepOutput keeps a step's answer over what its key holds in the steps state (a check's or a run's, design 47 G A-290)
// as the object named object, which the key and a run's step-ended name and the seat's verb `output` answers (A-254); a
// holder keeps it in the object store its manifest requires. Nil keeps none: such an answer ends the ask failed, saying so.
KeepOutput func(object string, body []byte) error
// KeepAnswer keeps a step's answer over what its key holds in the steps state (a check's or a run's, design 47 G A-290)
// as the object named object, which the key and a run's step-ended name and the seat's verb `answer` answers (A-254); a
// holder keeps it in its steps objects (AnswersStore, H-A-412). Nil keeps none: such an answer ends the ask failed, saying so.
KeepAnswer func(object string, body []byte) error
// Prior says how many runs of the ask under a step key started before (the Run of the step the key holds, PriorRuns; 0 for
// none), so the poison rule and the transport fault's run count only runs that started, never an ask given back before it
// ran. Nil counts the bus's deliveries (a test's).
@@ -713,7 +713,7 @@ func (p *Puller) endUnrun(msg *Pulled, ask sdkstep.StepAsk, key string, step sdk
why = fmt.Errorf("the ask is on its last delivery (%d) and no run of it started: it is out of its deliveries and run no more", msg.Delivered)
}
p.logf("the ask %s is ended on %s: %v", ask.ID, p.Node, why)
if _, ferr := finish(p.Put, p.KeepOutput, key, step, nil, why, p.Logf); ferr != nil {
if _, ferr := finish(p.Put, p.KeepAnswer, key, step, nil, why, p.Logf); ferr != nil {
p.logf("the end of the ask %s could not be written on %s, so it is given back: %v", ask.ID, p.Node, ferr)
_ = msg.Nak()
return
@@ -879,7 +879,7 @@ func (p *Puller) run(ctx context.Context, msg *Pulled, ask sdkstep.StepAsk, key
p.logf("the ask %s ended on a transport fault and its step could not be written again (%v): it ends failed", ask.ID, aerr)
}
}
written, ferr := finish(p.Put, p.KeepOutput, key, step, result, err, p.Logf)
written, ferr := finish(p.Put, p.KeepAnswer, key, step, result, err, p.Logf)
if ferr != nil {
// No end was written: the ask is not acknowledged as done, so the stream gives it again and a run that can
// write its end (or the poison rule, issue 1907) ends it where its asker sees it (issue 1930).
@@ -889,7 +889,7 @@ func (p *Puller) run(ctx context.Context, msg *Pulled, ask sdkstep.StepAsk, key
}
// step-ended says the end the key holds (design 47 G A-290): its outcome, and the answer only when the key kept it, so no
// step reads passed in one place and failed in another.
if len(written.Result) == 0 && written.OutputObject == "" {
if len(written.Result) == 0 && written.AnswerObject == "" {
result = nil
}
outcome := "passed"
@@ -898,9 +898,9 @@ func (p *Puller) run(ctx context.Context, msg *Pulled, ask sdkstep.StepAsk, key
if len(outcome) > 300 {
outcome = outcome[:300] + "..."
}
p.sayEnded(msg, ask, sdkstep.OutcomeFailed, written.Reason, result, written.OutputObject)
p.sayEnded(msg, ask, sdkstep.OutcomeFailed, written.Reason, result, written.AnswerObject)
} else {
p.sayEnded(msg, ask, sdkstep.OutcomePassed, "", result, written.OutputObject)
p.sayEnded(msg, ask, sdkstep.OutcomePassed, "", result, written.AnswerObject)
}
p.logf("the %s ask %s ended on %s after %s, in its phase %q; %s%s", ask.Kind, ask.ID, p.Node,
now().Sub(step.Started).Round(time.Second), step.Phase, outcome, stepOutcomeWords(result))
@@ -1099,8 +1099,8 @@ func (p *Puller) say(event string, body any, id string) {
// sayEnded says step-ended for an ask outside a pipeline, whatever its asker (design 47 G §602): a pipeline step's end is
// its run's own (AskSteps.SayStep). The end of a run carries the run's answer (A-254): the last line of its program's
// standard output, inline as `output` up to sdkstep.StepEndedInlineMost, else as `output-object`, the object kept, the step's
// key naming it (design 47 G A-290: finish kept it with KeepOutput, so it is not put twice); a program that exits other than 0
// standard output, inline as `output` up to sdkstep.StepEndedInlineMost, else as `answer-object`, the object kept, the step's
// key naming it (design 47 G A-290: finish kept it with KeepAnswer, so it is not put twice); a program that exits other than 0
// ends failed with its answer carried.
func (p *Puller) sayEnded(msg *Pulled, ask sdkstep.StepAsk, outcome, said string, result any, kept string) {
if p.Say == nil || ask.Step != nil || ask.Install != nil {
@@ -1114,7 +1114,7 @@ func (p *Puller) sayEnded(msg *Pulled, ask sdkstep.StepAsk, outcome, said string
if len(ans.Output) <= sdkstep.StepEndedInlineMost {
end.Output = string(ans.Output)
} else if kept != "" {
end.OutputObject = kept
end.AnswerObject = kept
} else {
outcome, said = sdkstep.OutcomeFailed, fmt.Sprintf("the run's answer is %d bytes, over what the end carries, and no object of it was kept", len(ans.Output))
}