diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go index f17529c6c..590ea849d 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go @@ -308,6 +308,62 @@ func TestAMoversBuildWaitsForItsDependenciesInThePipeline(t *testing.T) { } check("after a later placing and the end judgement") }) + + // H-A-406 (main.158 of 2026-11-22): builder's build fails, so tool and ext end not asked on it; its rerun then passes. The + // same take-out places them again at that build's end: tool is asked, ext waits for tool's build, with no hand rerun. + t.Run("a rerun build that passes places again the movers not asked on it", 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) }} + end := func(ask, outcome string) { + t.Helper() + e, err := bs.Decode([]byte(`{"id":"` + ask + `","pipeline":"main.7","step":"build","node":"n1","outcome":"` + outcome + `","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) + } + } + p, _, _ := mem.Get("main.7") + end(stepsOf(p, "builder")[0].Ask, "failed") + if _, err := s.Release(mem, "main.7", view); err != nil { + t.Fatal(err) + } + // The rerun asks builder's build again under a new ask. + p, rev, _ := mem.Get("main.7") + for i := range p.Steps { + if p.Steps[i].Module == "builder" && p.Steps[i].Step == seat.StepResultStepBuild { + p.Steps[i].Outcome, p.Steps[i].Ask, p.Steps[i].Rerun, p.Steps[i].Ended = seat.StepResultOutcomeRunning, "rerun-1", true, nil + } + } + if _, err := mem.Update("main.7", p, rev); err != nil { + t.Fatal(err) + } + end("rerun-1", "passed") + p, _, _ = mem.Get("main.7") + if st := stepsOf(p, "tool"); len(st) == 0 || st[0].Outcome != seat.StepResultOutcomeRunning || st[0].Ask == "" { + t.Errorf("after builder's rerun passed, tool's steps = %+v, want its build placed again and asked", st) + } + if placed(p, "ext") || p.Outcome != seat.PipelineOutcomeRunning { + t.Errorf("after builder's rerun passed, main.7 %s, ext %+v; want running, ext waiting for tool's build", p.Outcome, stepsOf(p, "ext")) + } + if !slices.ContainsFunc(journal, func(l string) bool { return strings.Contains(l, "main.7: tool, ext, not asked on builder, which built now, placed again") }) { + t.Errorf("the journal %q does not say tool and ext are placed again", journal) + } + }) } // 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/steps.go b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go index dfd0fae94..a4d3fea30 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go @@ -330,6 +330,14 @@ func (h *Hearer) OnStepEndedPinned(bs StepSeat, subject string, ev StepEnded, sh // A mover's build passed is what a kind-3 edge waits for (§746, H-A-83 (2)); one that did not pass ends its // dependents' steps not asked. release := s.Step == seat.StepResultStepBuild && (!stepPassed(*s) || built(&p, s.Module)) + // A build that passes, a rerun's among them, places again the steps that ended not asked on it (H-A-406): its + // dependents need no hand rerun. + var again []string + if s.Step == seat.StepResultStepBuild && stepPassed(*s) { + if again = takeOutNotAsked(&p, s.Module); len(again) > 0 { + release = true + } + } ended := h.endPipeline(&p, now, wr) if _, err := h.Store.Update(ev.Pipeline, p, rev); errors.Is(err, ErrChanged) { continue @@ -362,6 +370,9 @@ func (h *Hearer) OnStepEndedPinned(bs StepSeat, subject string, ev StepEnded, sh return p, fmt.Errorf("pipeline %s's %s is written but not said: %w", ev.Pipeline, seat.EventStepEnded, err) } } + if len(again) > 0 { + h.logf("%s: %s, not asked on %s, which built now, placed again (H-A-406)", ev.Pipeline, strings.Join(again, ", "), s.Module) + } if release && h.Release != nil { h.Release(ev.Pipeline) } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go b/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go index bbb3ccc0c..420ce2ec9 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go @@ -175,10 +175,10 @@ 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 { +// build, that dependency a mover that left p, one built names (its build passed since, H-A-406), 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, built ...string) []string { var out []string for changed := true; changed; { changed = false @@ -193,7 +193,7 @@ func takeOutNotAsked(p *seat.Pipeline) []string { break } } - if dep == "" || (!slices.Contains(p.Superseded, dep) && !slices.Contains(out, dep)) { + if dep == "" || (!slices.Contains(p.Superseded, dep) && !slices.Contains(out, dep) && !slices.Contains(built, dep)) { continue } p.Steps = slices.DeleteFunc(p.Steps, func(st seat.StepResult) bool { return st.Module == m.Module })