P1 superseded-needs-its-revision: a superseded end with no revision ends the step could-not-run; a passed-over end says step-started with rerun by the runner

Builds: design 47 H2 H-A-601, H-A-577 (3), H-A-583 (2), H-A-650
This commit is contained in:
2026-11-25 17:20:00 +01:00
parent b0d915f6d0
commit 8f36311d08
2 changed files with 30 additions and 5 deletions
@@ -78,7 +78,7 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
bs := stepSeatOf(t, builds.Seat)
end := StepEnded{ID: "x1", Node: "n1", Pipeline: "main.117", Module: "a", Commit: "c1", Fingerprint: "src2:a1", Step: "build",
Outcome: builds.StepEndedOutcomeSuperseded, Said: "a at src2:a1 is superseded by src2:a2, the newest entry heard on its first branch"}
if _, err := h.OnStepEnded(bs, bs.Prefix+"n1", end); err != nil {
if _, err := h.OnStepEndedRevised(bs, bs.Prefix+"n1", end, nil, nil, 120); err != nil { // the end names its superseding revision (H-A-601)
t.Fatal(err)
}
p, _, _ := h.Store.Get("main.117")
@@ -172,8 +172,8 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
h := &Hearer{Store: store, Say: func(string, any) error { return nil }, Now: func() time.Time { return t0 }, Release: func(key string) { released = append(released, key) },
View: newerView}
bs := stepSeatOf(t, builds.Seat)
got, err := h.OnStepEnded(bs, bs.Prefix+"n1", StepEnded{ID: "x1", Node: "n1", Pipeline: "main.117", Module: "a", Commit: "c1", Fingerprint: "src2:a1",
Step: "build", Outcome: builds.StepEndedOutcomeSuperseded, Said: "a at src2:a1 is superseded by src2:a2"})
got, err := h.OnStepEndedRevised(bs, bs.Prefix+"n1", StepEnded{ID: "x1", Node: "n1", Pipeline: "main.117", Module: "a", Commit: "c1", Fingerprint: "src2:a1",
Step: "build", Outcome: builds.StepEndedOutcomeSuperseded, Said: "a at src2:a1 is superseded by src2:a2"}, nil, nil, 120)
if err != nil {
t.Fatal(err)
}
@@ -197,7 +197,7 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
view int64
want string // left, again or held
}{
{"an end naming no revision (H-A-508 as before)", 0, 116, "left"},
{"an end naming no revision (H-A-601: could not run)", 0, 116, "could-not-run"},
{"an older revision's entry", 116, 117, "again"},
{"the same revision's entry, the builder's kept revision (H-A-563)", 117, 117, "left"},
{"a newer revision's entry the view does not hold yet", 120, 118, "held"},
@@ -209,8 +209,12 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
var put []Asked
var journal []string
var waits []string // the waits said, by event and what they wait on (H-A-563)
var started []seat.StepEvent
view := r.view
say := func(subject string, body any) error {
if ev, ok := body.(seat.StepEvent); ok && strings.Contains(subject, seat.EventStepStarted) {
started = append(started, ev)
}
if w, ok := body.(seat.Wait); ok {
ev := seat.EventWaitHeld
if strings.Contains(subject, seat.EventWaitEnded) {
@@ -220,7 +224,7 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
}
return nil
}
h := &Hearer{Store: store, Say: say, Now: func() time.Time { return t0 },
h := &Hearer{Store: store, Say: say, Now: func() time.Time { return t0 }, Name: "mesh-delivery-pipeline",
View: func(string) (Half, bool) {
return Half{Revision: view, Source: view, Entries: map[string]catalog.CatalogEntry{"a": {Module: "a", Fp: "src2:a2"}}}, true
},
@@ -239,6 +243,11 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
return slices.Equal(p.Superseded, []string{"a"}) && p.Steps[0].Outcome == seat.StepResultOutcomeSuperseded && len(put) == 0
}
switch r.want {
case "could-not-run":
// H2 H-A-601: no revision, no judging: the step ends could-not-run naming the builder and the words, the mover stays
if s := p.Steps[0]; len(p.Superseded) != 0 || s.Outcome != seat.StepResultOutcomeCouldNotRun || !strings.Contains(s.Why, "a superseded end without its revision") || len(put) != 0 {
t.Errorf("superseded %v, a's build %+v, put %+v; want the step could-not-run with the words, the mover staying", p.Superseded, s, put)
}
case "left":
if !left(p) {
t.Errorf("superseded %v, a's build %+v, put %+v; want a left, its build superseded, nothing asked again", p.Superseded, p.Steps[0], put)
@@ -248,6 +257,10 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
len(put) != 1 || put[0].ID != "x1again" || p.Outcome != seat.PipelineOutcomeRunning {
t.Errorf("superseded %v, a's build %+v, put %+v, pipeline %s; want nothing left, the build asked again as x1again", p.Superseded, p.Steps[0], put, p.Outcome)
}
// H2 H-A-577 (3): the passed-over end is said as a step-started with rerun and the runner as the caller
if len(started) != 1 || !started[0].Result.Rerun || started[0].Result.By != "mesh-delivery-pipeline" || started[0].Result.Ask != "x1again" {
t.Errorf("step-started said %+v, want one rerun by the runner of x1again", started)
}
if !slices.ContainsFunc(journal, func(l string) bool { return strings.Contains(l, "passed over") }) {
t.Errorf("the passed-over end is not said: %q", journal)
}
@@ -379,6 +379,11 @@ func (h *Hearer) OnStepEndedRevised(bs StepSeat, subject string, ev StepEnded, s
if err := h.PutAgain(ev.Pipeline, *a); err != nil {
h.logf("%s: the build of %s asked again as %s is written and not put, put again at the next start: %v", ev.Pipeline, s.Module, a.ID, err)
}
// The passed-over end is said as an event, not only in the journal (design 47 H2 H-A-577 (3)): step-started with rerun
// and the runner as the caller.
if err := h.say(seat.EventStepStarted, p, s); err != nil {
h.logf("%s: the step-started of %s asked again is not said: %v", ev.Pipeline, s.Module, err)
}
return p, nil
}
h.logf("%s: %s's build ended superseded (%s), passed over: %s; %s (H-A-555, H-A-561)", ev.Pipeline, s.Module, ev.Said, passed, why)
@@ -399,6 +404,11 @@ func (h *Hearer) OnStepEndedRevised(bs StepSeat, subject string, ev StepEnded, s
}
return p, nil
}
} else if supersededBuild(*s, ev.Outcome) {
// A superseded end naming no revision is no end the runner can judge (design 47 H2 H-A-601, H-A-650): the step ends could-not-run,
// naming the builder, and a rerun asks it again.
h.logf("%s: %s's build ended superseded (%s) with no revision: the step ends could-not-run (H-A-601)", ev.Pipeline, s.Module, ev.Said)
ev.Outcome, ev.Said = nodebuildgo.StepEndedOutcomeCouldNotRun, fmt.Sprintf("the builder on %s ended it superseded: a superseded end without its revision (%s)", node, ev.Said)
}
s.Outcome, s.Node, s.Why, s.Rerun, s.By, s.Ended = ev.Outcome, node, ev.Said, ev.Rerun, ev.By, &now
if len(shared) > 0 {
@@ -901,6 +911,8 @@ func (h *Hearer) supersededAgain(p *seat.Pipeline, i int, ev StepEnded, passed s
return nil, fmt.Sprintf("its build ended superseded (%s), though %s, and it cannot be asked again: %v", ev.Said, passed, err)
}
s.Ask, s.AskedAt, s.TakenAt, s.Node = a.ID, &now, nil, ""
// The step asked again is a rerun by the runner itself, said as such by its step-started (design 47 H2 H-A-577 (3)).
s.Rerun, s.By = true, h.Name
return a, ""
}