From 99b25a7db42d6a3c43604545dd1bc209e6ab3cb6 Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 21 Nov 2026 23:34:24 +0100 Subject: [PATCH] H-A-361: a hand-off places again the stayers not asked on a mover that left On 21 Nov the order was the reverse of the first commit's: mesh-contracts' old build was withdrawn first (21:50:16), so the stayers that awaited it were placed not asked, and only then did the hand-offs take it away. A mover that left is still a dependency of those stayers: their not-asked steps held the pipeline's end as failures. At the hand-off the steps of each stayer that ended not asked on a dependency that left, directly or through a mover itself taken out, are taken out, so the placing that follows places them again against the newest published package; a dependency that truly did not build is named again at that placing. The journal says which movers are placed again. Builds: design 47 H H-A-361, H-A-53, H-A-223 --- .../internal/pipeline/order_test.go | 70 +++++++++++++++++++ .../internal/pipeline/repin.go | 2 +- .../internal/pipeline/start.go | 18 ++++- .../internal/pipeline/supersede.go | 33 +++++++++ 4 files changed, 121 insertions(+), 2 deletions(-) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go index f4a33bbd8..f17529c6c 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go @@ -238,6 +238,76 @@ func TestAMoversBuildWaitsForItsDependenciesInThePipeline(t *testing.T) { } check("after a later placing and the end judgement") }) + + // H-A-361, the reverse order (21:50:16 of 2026-11-21, mesh-contracts' old build withdrawn): builder's build ends without + // passing first, so tool, awaiting it, and ext, awaiting tool, are placed not asked; only then does a newer pipeline take + // builder away. At the hand-off tool and ext, not asked on a dependency that left (ext through tool), are taken out and + // placed again: tool is asked, building against the newest published package, ext waits for tool's build; the journal + // says it, and a later placing and the end judgement leave the pipeline running. + t.Run("a build that did not pass, then a hand-off, places again the movers not asked on the mover that left", func(t *testing.T) { + ext := entries["app"] + ext.Module, ext.Edges = "ext", []catalog.Edge{{From: "tool:program", To: "ext:program", Kind: 1}} + entries["ext"] = ext + mem := memStore{} + s := &Starter{Pipelines: memCreated{mem}, Store: mem, Say: func(string, any) error { return nil }, Steps: &stepAsks{}, Name: "the-runner", + Registration: func(string) (catalog.Registration, bool) { return reg, true }} + ev := ev + ev.Entries = append(slices.Clone(ev.Entries), catalog.TakeInEntry{Module: "ext", Commit: "c6", Fingerprint: "src2:ee"}) + if n, err := s.TakenIn(ev, view); n != 1 || err != nil { + t.Fatalf("the take-in started %d (%v)", n, err) + } + var journal []string + h := &Hearer{Store: mem, Name: "the-runner", Say: func(string, any) error { return nil }, + Logf: func(f string, a ...any) { journal = append(journal, fmt.Sprintf(f, a...)) }, + Release: func(key string) { _, _ = s.Release(mem, key, view) }} + p, _, _ := mem.Get("main.7") + b := stepsOf(p, "builder")[0] + e, err := bs.Decode([]byte(`{"id":"` + b.Ask + `","pipeline":"main.7","step":"build","node":"n1","outcome":"failed","entries":[{"module":"builder","commit":"c2","fingerprint":"src2:bb"}]}`)) + if err != nil { + t.Fatal(err) + } + if _, err := h.OnStepEnded(bs, bs.Prefix+"n1", e); err != nil { + t.Fatal(err) + } + // A later placing places ext, whose dependency tool was not asked, not asked too. + if _, err := s.Release(mem, "main.7", view); err != nil { + t.Fatal(err) + } + p, _, _ = mem.Get("main.7") + for _, m := range []string{"tool", "ext"} { + if st := stepsOf(p, m); len(st) == 0 || st[0].Outcome != seat.StepResultOutcomeNotAsked { + t.Fatalf("after builder's build failed, %s's steps = %+v, want placed not asked", m, st) + } + } + h.SupersedeRunning(seat.Pipeline{Pipeline: "main.9", Branch: "main", Revision: 9, Movers: []seat.Mover{ + {Module: "builder", Commit: "c5", Fingerprint: "src2:b2"}}}) + check := func(when string) { + p, _, _ := mem.Get("main.7") + if p.Outcome != seat.PipelineOutcomeRunning { + t.Fatalf("%s: main.7 = %s (%s), want running until its kept steps end", when, p.Outcome, p.Why) + } + if st := stepsOf(p, "tool"); len(st) == 0 || st[0].Step != seat.StepResultStepBuild || st[0].Outcome != seat.StepResultOutcomeRunning || st[0].Ask == "" { + t.Errorf("%s: tool's steps = %+v, want its build placed again and asked", when, st) + } + if placed(p, "ext") { + t.Errorf("%s: ext's steps = %+v, want it waiting for tool's build, not placed", when, stepsOf(p, "ext")) + } + } + check("at the hand-off") + if !slices.ContainsFunc(journal, func(l string) bool { + return strings.Contains(l, "main.7: tool, ext, not asked on a dependency that left, placed again") + }) { + t.Errorf("the journal %q does not say tool and ext are placed again", journal) + } + if _, err := s.Release(mem, "main.7", view); err != nil { + t.Fatal(err) + } + p, rev, _ := mem.Get("main.7") + if endPipeline(&p, time.Now(), nil) { + _, _ = mem.Update("main.7", p, rev) + } + check("after a later placing and the end judgement") + }) } // Design 47 G §270, A-326 (H §746, H-A-83 (2)): what a build module's new version is built from is built by its running diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/repin.go b/modules/mesh-delivery-pipeline/internal/pipeline/repin.go index b00481a32..e2423b645 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/repin.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/repin.go @@ -189,7 +189,7 @@ func (s *Starter) placeAgain(p *seat.Pipeline, m seat.Mover, half Half, now time supersededWhy(*p, m.Module, half.Entries, steps) var notAsked []int if failed != "" { - why := "its dependency " + failed + " did not build" + why := notBuiltWhy(failed) for k := range steps { st := &steps[k] if st.Outcome == seat.StepResultOutcomeBypassed { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/start.go b/modules/mesh-delivery-pipeline/internal/pipeline/start.go index 0f2e7c16b..7c0357000 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/start.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/start.go @@ -134,6 +134,22 @@ func placed(p seat.Pipeline, module string) bool { return false } +// notBuiltWhy is the why of a step placed not asked because dependency failed did not build (H-A-101 (2)). +func notBuiltWhy(failed string) string { return "its dependency " + failed + " did not build" } + +// notBuiltDependency answers the dependency a step placed not asked names as not built (notBuiltWhy), if it is one. +func notBuiltDependency(st seat.StepResult) (string, bool) { + if st.Outcome != seat.StepResultOutcomeNotAsked { + return "", false + } + d, ok := strings.CutPrefix(st.Why, "its dependency ") + if !ok { + return "", false + } + d, ok = strings.CutSuffix(d, " did not build") + return d, ok && d != "" +} + // Starter starts pipelines (design 47 G §54, §103): it writes a pipeline's key by compare-and-set on its absence, so one // source revision and module has one pipeline whichever event starts it first, and says pipeline-started for the one it // wrote. @@ -444,7 +460,7 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog } } if failed != "" { - why := "its dependency " + failed + " did not build" + why := notBuiltWhy(failed) for k := range steps { st := &steps[k] if st.Outcome == seat.StepResultOutcomeBypassed { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go b/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go index 7f66ed937..7bb8b8b9c 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go @@ -124,6 +124,7 @@ func (h *Hearer) supersedeRunningOne(key string, newer seat.Pipeline) bool { ended = append(ended, i) } p.Superseded = append(p.Superseded, moved...) + again := takeOutNotAsked(&p) done := h.endPipeline(&p, now, wr) if _, err := h.Store.Update(key, p, rev); errors.Is(err, ErrChanged) { continue @@ -139,6 +140,9 @@ func (h *Hearer) supersedeRunningOne(key string, newer seat.Pipeline) bool { } h.logf("%s: %s moved by the newer %s leave it, %d of its open steps ended superseded (H-A-223); %d stay: %s (H-A-361)", key, strings.Join(moved, ", "), newer.Pipeline, len(ended), len(stay), strings.Join(stay, ", ")) + if len(again) > 0 { + h.logf("%s: %s, not asked on a dependency that left, placed again (H-A-361)", key, strings.Join(again, ", ")) + } for _, i := range ended { if err := h.say(seat.EventStepEnded, p, &p.Steps[i]); err != nil { h.logf("step-ended of %s's %s %s, superseded, is not said: %v", key, p.Steps[i].Module, p.Steps[i].Step, err) @@ -158,6 +162,35 @@ func (h *Hearer) supersedeRunningOne(key string, newer seat.Pipeline) bool { } } +// takeOutNotAsked takes out of p the steps of each mover that stays whose steps ended not asked because a dependency did not +// build, that dependency a mover that left p, or a mover itself taken out here (H-A-361): a left mover is no dependency of +// the movers that stay (H-A-53), so they are placed again, and a dependency that truly did not build is named again at that +// placing. It answers the movers taken out, in p's order. +func takeOutNotAsked(p *seat.Pipeline) []string { + var out []string + for changed := true; changed; { + changed = false + for _, m := range p.Movers { + if slices.Contains(p.Superseded, m.Module) || slices.Contains(out, m.Module) { + continue + } + dep := "" + for _, st := range stepsOf(*p, m.Module) { + if d, ok := notBuiltDependency(st); ok { + dep = d + break + } + } + if dep == "" || (!slices.Contains(p.Superseded, dep) && !slices.Contains(out, dep)) { + continue + } + p.Steps = slices.DeleteFunc(p.Steps, func(st seat.StepResult) bool { return st.Module == m.Module }) + out, changed = append(out, m.Module), true + } + } + return out +} + // supersedeStep ends the open or waiting step st of p superseded, naming why, with its step log entry: a step reading a test // run is answered to leave it, and one with its own ask on a build node to drop it (H-A-223). func supersedeStep(p *seat.Pipeline, st *seat.StepResult, why string, now time.Time) (leave, drop []seat.StepResult) {