H-A-333: the ended line at every said end, the answered line at every answer

The runner's ended line was written only for a heard step-ended and its run's
readers; the unanswered-bound end, the end at placing, a supersede, a re-pin,
the approval's end, the start pass and the verbs said their ends silently. It
is now written in Hearer.say, the one place that says step-ended, and at the
starter's two sayers that call stepEvent directly (repin, sayNotAsked). The
builder's answered line sat on four of buildEntry's returns; the ask's answer
is now one line in BuildStep's finish, naming the pipeline, the movers, the
step and the outcome, the per-entry existing/built-now line kept beside it.

Builds: design 47 H H-A-320 (1), H-A-333
This commit is contained in:
2026-11-21 21:58:36 +01:00
parent dc83ef3e27
commit 6a847a8d9c
7 changed files with 47 additions and 12 deletions
@@ -24,9 +24,24 @@ func (b *Builder) BuildStep(ctx context.Context, run meshbuilds.StepRun) meshbui
b.init()
started := b.now()
end := meshbuilds.StepEnded{V: 1, Pipeline: run.Pipeline, Step: meshbuilds.StepEndedStepBuild, Rerun: run.Rerun, By: run.By, Entries: run.Entries, Node: b.Node, Started: &started}
// finish is the one place the ask is answered: its line names the pipeline, the movers, the step and the outcome, with
// the words of an end that did not pass (H-A-320 (1), H-A-333).
finish := func(outcome, said string) meshbuilds.StepEnded {
at := b.now()
end.Ended, end.Outcome, end.Said = &at, outcome, said
movers := make([]string, 0, len(run.Entries))
for _, e := range run.Entries {
movers = append(movers, e.Module)
}
mv := strings.Join(movers, ",")
if mv == "" {
mv = "-"
}
if said != "" {
b.logf("%s %s %s step answered %s: %s", run.Pipeline, mv, end.Step, outcome, said)
} else {
b.logf("%s %s %s step answered %s", run.Pipeline, mv, end.Step, outcome)
}
return end
}
if len(run.Entries) == 0 {
@@ -37,12 +37,23 @@ func TestABuildStepAnswersItsEnd(t *testing.T) {
ask := func(entries ...meshbuilds.BuildEntry) meshbuilds.StepEnded {
return r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "main.1.m", Step: meshbuilds.StepRunStepBuild, Entries: entries})
}
// Every answer is one journal line naming the pipeline, the movers, the step and the outcome (H-A-320 (1), H-A-333).
var answers []string
r.b.Logf = func(f string, a ...any) {
if l := fmt.Sprintf(f, a...); strings.Contains(l, " step answered ") {
answers = append(answers, l)
}
}
if end := ask(); end.Outcome != meshbuilds.StepEndedOutcomeNothingToRun {
t.Errorf("an ask naming no entry: %+v", end)
}
if end := ask(meshbuilds.BuildEntry{Module: "m", Fingerprint: "src2:" + strings.Repeat("2", 64)}); end.Outcome != meshbuilds.StepEndedOutcomeCouldNotRun || !strings.Contains(end.Said, "cannot be read") {
t.Errorf("an entry the seat does not hold: %+v", end)
}
if len(answers) != 2 || answers[0] != "main.1.m - build step answered nothing to run: the ask names no entry" ||
!strings.HasPrefix(answers[1], "main.1.m m build step answered could not run: the entry m at ") {
t.Errorf("the answers journaled %q, want one line per answer", answers)
}
if end := ask(meshbuilds.BuildEntry{Module: "m", Fingerprint: fp1, Commit: "other"}); end.Outcome != meshbuilds.StepEndedOutcomeCouldNotRun {
t.Errorf("an entry at another commit: %+v", end)
}
@@ -172,13 +183,13 @@ func awaitWaiting[T any](t *testing.T, waiting <-chan struct{}, ended <-chan T)
// another series and the module's release number pin nothing.
func aPackageWithNoPinWaitsForItsRelease(t *testing.T) {
r, _, waiting := unpinnedRig(t)
// Each answer from a build is one journal line, built now or existing (H-A-320 (1)).
// Each entry's answer from a build is one journal line, built now or existing, beside the ask's answer (H-A-320 (1), H-A-333).
var mu sync.Mutex
var answers []string
logf := r.b.Logf
r.b.Logf = func(format string, args ...any) {
logf(format, args...)
if l := fmt.Sprintf(format, args...); strings.Contains(l, "build step answered") {
if l := fmt.Sprintf(format, args...); strings.HasPrefix(l, "m@") && strings.Contains(l, "build step answered") {
mu.Lock()
answers = append(answers, l)
mu.Unlock()
@@ -1,6 +1,7 @@
package pipeline
import (
"fmt"
"slices"
"strings"
"testing"
@@ -20,7 +21,7 @@ func TestAnAskNobodyAnswersIsAskedOnceMoreThenEndsItsStep(t *testing.T) {
v, store, said, asks, _, _ := verbsFixture()
var armed, unbound, raised, cleared []string
logs := []string{}
v.Hearer.Logf = func(f string, a ...any) { logs = append(logs, f) }
v.Hearer.Logf = func(f string, a ...any) { logs = append(logs, fmt.Sprintf(f, a...)) }
c := &AskClock{Bound: 10 * time.Minute,
Arm: func(key string, ttl time.Duration) error { armed = append(armed, key+" "+ttl.String()); return nil },
Unbound: func(key string) error { unbound = append(unbound, key); return nil },
@@ -83,6 +84,10 @@ func TestAnAskNobodyAnswersIsAskedOnceMoreThenEndsItsStep(t *testing.T) {
if s.Outcome != seat.StepResultOutcomeCouldNotRun || s.Why != "its ask "+ask+" was not answered" || s.Ended == nil {
t.Errorf("the step = %+v", s)
}
// The unanswered-bound end is one journal line, as every said end (H-A-320 (1), H-A-333).
if n := countLines(logs, pkey+" app lint ended could not run (no node, "); n != 1 {
t.Errorf("the unanswered end journaled %d times in %q, want once", n, logs)
}
if got.Outcome != seat.PipelineOutcomeFailed || len(asks.ids) != 2 {
t.Errorf("the pipeline is %s (%s), asked %d, want failed and nothing more asked", got.Outcome, got.Why, len(asks.ids))
}
@@ -137,6 +137,7 @@ func (s *Starter) keepIn(key string, half Half, movers []seat.Mover) []seat.Move
}
was := p
was.Movers = olds
logEnded(s.logf, key, st)
if err := s.Say(stepEvent(seat.EventStepEnded, was, st, now)); err != nil {
s.logf("step-ended of %s's %s %s, superseded, is not said: %v", key, st.Module, st.Step, err)
}
@@ -372,7 +372,6 @@ func (h *Hearer) endReader(reader RunReader, run string, r Run) error {
} else if err != nil {
return fmt.Errorf("pipeline %s cannot be written: %w", reader.Pipeline, err)
}
h.logEnded(reader.Pipeline, *s)
h.Failures.StepEnded(h.Store, p, *s)
if err := h.say(seat.EventStepEnded, p, s); err != nil {
return fmt.Errorf("pipeline %s's %s is written but not said: %w", reader.Pipeline, seat.EventStepEnded, err)
@@ -495,6 +495,7 @@ func (s *Starter) sayNotAsked(p seat.Pipeline, steps []int) {
}
at := s.now()
for _, i := range steps {
logEnded(s.logf, p.Pipeline, p.Steps[i])
subject, ev := stepEvent(seat.EventStepEnded, p, p.Steps[i], at)
if err := s.Say(subject, ev); err != nil {
s.logf("step-ended of %s's %s %s, not asked, is not said: %v", p.Pipeline, p.Steps[i].Module, p.Steps[i].Step, err)
@@ -345,10 +345,6 @@ func (h *Hearer) OnStepEndedPinned(bs StepSeat, subject string, ev StepEnded, sh
} else if err != nil {
return p, fmt.Errorf("pipeline %s cannot be written: %w", ev.Pipeline, err)
}
h.logEnded(ev.Pipeline, *s)
for _, j := range readers {
h.logEnded(ev.Pipeline, p.Steps[j])
}
// The run's end is written as its step-ended is heard, before any finding the step says, so no wait elsewhere (a
// finding's event the bus is slow to take) delays it past its bound (A-470o).
runErr := h.endRunOf(p, *s, ev)
@@ -556,9 +552,13 @@ func endEntry(key string, s seat.StepResult, at time.Time, kept ...string) seat.
Output: s.Output, Kept: kept, At: at}
}
// logEnded writes the journal line of a step's end written (H-A-320 (1)): the pipeline, the mover, the step, its outcome, the
// node that ended it and how long it ran from its start.
func (h *Hearer) logEnded(key string, s seat.StepResult) {
// logEnded writes the journal line of a step's end said (H-A-320 (1), H-A-333): the pipeline, the mover, the step, its
// outcome, the node that ended it and how long it ran from its start. It is written where step-ended is said, Hearer.say and
// the starter's two sayers, so every said end has its one line.
func logEnded(logf func(string, ...any), key string, s seat.StepResult) {
if logf == nil {
return
}
mover, node, took := s.Module, s.Node, "no start"
if mover == "" {
mover = "-"
@@ -569,7 +569,7 @@ func (h *Hearer) logEnded(key string, s seat.StepResult) {
if s.Started != nil && s.Ended != nil {
took = s.Ended.Sub(*s.Started).Round(time.Millisecond).String()
}
h.logf("%s %s %s ended %s (%s, %s)", key, mover, s.Step, s.Outcome, node, took)
logf("%s %s %s ended %s (%s, %s)", key, mover, s.Step, s.Outcome, node, took)
}
func (h *Hearer) logf(format string, args ...any) {
@@ -585,6 +585,9 @@ func (h *Hearer) say(event string, p seat.Pipeline, step *seat.StepResult) error
at := h.now()
switch event {
case seat.EventStepEnded, seat.EventStepStarted:
if event == seat.EventStepEnded {
logEnded(h.logf, p.Pipeline, *step)
}
subject, ev := stepEvent(event, p, *step, at)
return h.Say(subject, ev)
case seat.EventPipelineEnded: