From 1df7a964fc343c662f64a5d474ed115a9d152f43 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 12:30:19 +0100 Subject: [PATCH] mesh-delivery-pipeline: a mover leaves only for a newer revision's entry (H-A-555, H-A-557) main.453 ended every build step superseded and moved its movers out for the newer revision's pipeline, though the superseding entry was of source 140, older than its own: no pipeline delivered them. The runner now reads its own view of the branch's catalog half when a build ends superseded: the mover leaves only when that revision is newer than the pipeline's and names another fingerprint of it. Otherwise the end is passed over, said in the journal, and the build is asked again at once under a new ask, as a declined step is; the builder's revision wait holds it. Builds: design 47 H2 H-A-555, H-A-557 --- .../cmd/mesh-delivery-pipeline/main.go | 1 + .../internal/pipeline/endopen_test.go | 57 ++++++++++++++- .../internal/pipeline/steps.go | 72 +++++++++++++++++++ 3 files changed, 129 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go index 33105faee..9aa39e923 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go @@ -365,6 +365,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro verbs.Runs = pipeline.RunsRead{Runs: runsKept{ctx: ctx, kv: runsKV}, Object: runObjs.Get, Fill: starter.TestRunsFill} // A declined step is put again on a node that has its need (design 47 H2 H-A-375, H-A-445). hearer.NeedNodes, hearer.AskDeclined, hearer.PutAgain = rv.Holders.Nodes, verbs.DeclinedAsk, starter.PutAgain + hearer.View = rv.Catalog.View // a build ended superseded moves its mover out only for a newer revision (H-A-555) dropExpired := boundExpired(dropUnanswered(ctx, rv.Findings, cred.Module, time.Now), logger.Printf) askExpired := askBoundExpired(verbs.AskUnanswered, logger.Printf) expired := func(key string) { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go index 3694f842c..69c9f2839 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go @@ -10,6 +10,7 @@ import ( "git.novox.be/novox/mesh-contracts/identity-and-access/go/seats/meshgrants" builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" + catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" ) @@ -73,6 +74,7 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { if p, _, _ := h.Store.Get("main.117"); p.Steps[2].Outcome != seat.StepResultOutcomeRunning { t.Errorf("the refused end moved the lint step: %+v", p.Steps[2]) } + h.View = newerView // the runner's view holds revision 120, naming a at src2:a2 (H-A-555) 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"} @@ -167,7 +169,8 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { e.p.Steps[0].Why = notBuiltWhy("a") store["main.117"] = e var released []string - 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) }} + 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"}) @@ -179,4 +182,56 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { t.Errorf("pipeline %s superseded %v steps %+v released %v; want running, a left, b taken out to be placed again", got.Outcome, got.Superseded, got.Steps, released) } }) + // H-A-555, H-A-557 (main.453): a build ended superseded moves its mover out only when the runner's view holds a revision + // newer than the pipeline's own naming another fingerprint of it; an entry of an older or the same revision (the builder's + // picture lagging), or a newer one naming the mover's own fingerprint, is passed over and said, and the build is asked + // again at once under a new ask; nothing leaves and the pipeline runs on. + for _, r := range []struct { + name string + view Half + left bool + }{ + {"an older revision's entry", Half{Revision: 116, Source: 116, Entries: map[string]catalog.CatalogEntry{"a": {Module: "a", Fp: "src2:a2"}}}, false}, + {"the same revision", Half{Revision: 117, Source: 117, Entries: map[string]catalog.CatalogEntry{"a": {Module: "a", Fp: "src2:a2"}}}, false}, + {"a newer revision naming the mover's own fingerprint", Half{Revision: 120, Source: 120, Entries: map[string]catalog.CatalogEntry{"a": {Module: "a", Fp: "src2:a1"}}}, false}, + {"a newer revision naming another fingerprint", Half{Revision: 120, Source: 120, Entries: map[string]catalog.CatalogEntry{"a": {Module: "a", Fp: "src2:a2"}}}, true}, + } { + t.Run("H-A-555: a build superseded by "+r.name, func(t *testing.T) { + store := memStore{"main.117": {p: seat.Pipeline{V: 1, Pipeline: "main.117", Branch: "main", Source: 117, Revision: 117, Outcome: seat.PipelineOutcomeRunning, + Movers: slices.Clone(movers[:2]), Steps: []seat.StepResult{step("a", seat.StepResultOutcomeRunning, "x1"), step("b", seat.StepResultOutcomeRunning, "x2")}}, rev: 1}} + var put []Asked + var journal []string + h := &Hearer{Store: store, Say: func(string, any) error { return nil }, Now: func() time.Time { return t0 }, + View: func(string) (Half, bool) { return r.view, true }, + AskDeclined: func(_ seat.Pipeline, s seat.StepResult, _ time.Time) (*Asked, error) { + return &Asked{Seat: s.Seat, ID: s.Ask + "again"}, nil + }, + PutAgain: func(_ string, a Asked) error { put = append(put, a); return nil }, + Logf: func(f string, a ...any) { journal = append(journal, fmt.Sprintf(f, a...)) }} + bs := stepSeatOf(t, builds.Seat) + if _, 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, the newest entry heard on its first branch"}); err != nil { + t.Fatal(err) + } + p, _, _ := store.Get("main.117") + if r.left { + if !slices.Equal(p.Superseded, []string{"a"}) || p.Steps[0].Outcome != seat.StepResultOutcomeSuperseded || len(put) != 0 { + 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) + } + return + } + if len(p.Superseded) != 0 || p.Steps[0].Outcome != seat.StepResultOutcomeRunning || p.Steps[0].Ask != "x1again" || p.Steps[0].Ended != nil || + 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, the pipeline running", p.Superseded, p.Steps[0], put, p.Outcome) + } + 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) + } + }) + } +} + +// newerView is the runner's view of main at revision 120, naming a at src2:a2: newer than main.117 (H-A-555). +func newerView(string) (Half, bool) { + return Half{Revision: 120, Source: 120, Entries: map[string]catalog.CatalogEntry{"a": {Module: "a", Fp: "src2:a2"}}}, true } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go index b0cba09ac..2438c7f72 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go @@ -194,6 +194,10 @@ type Hearer struct { // queue (Starter.PutAgain); with either nil a declined step ends could not run. AskDeclined func(p seat.Pipeline, s seat.StepResult, now time.Time) (*Asked, error) PutAgain func(key string, a Asked) error + // View is the runner's view of a branch's catalog half (its newest module graph revision and entries), and whether it is + // read: a build ended superseded moves its mover out only when that revision is newer than the pipeline's own and names + // another fingerprint of it (H-A-555); otherwise the build is asked again (H-A-557). Nil reads none, so none moves out. + View func(branch string) (Half, bool) // Aside runs do beside the caller's path: the drops of an ended pipeline's open asks, each asked side by side, so an end is // never held by a seat that answers a kept call only at its bound (H-A-506); nil runs it in place. @@ -321,6 +325,30 @@ func (h *Hearer) OnStepEndedPinned(bs StepSeat, subject string, ev StepEnded, sh } ev.Outcome, ev.Said = nodebuildgo.StepEndedOutcomeCouldNotRun, why } + if supersededBuild(*s, ev.Outcome) { + // A build superseded only by an entry of a revision no newer than the pipeline's own is passed over and asked + // again at once (H-A-555, H-A-557): the builder's picture lagged, its revision wait holds the new ask. + if passed := h.notNewer(p, s.Module); passed != "" { + old := s.Ask + a, why := h.supersededAgain(&p, i, ev, passed, now) + if a != nil { + if _, err := h.Store.Update(ev.Pipeline, p, rev); errors.Is(err, ErrChanged) { + continue + } else if err != nil { + return p, fmt.Errorf("pipeline %s cannot be written: %w", ev.Pipeline, err) + } + unmarkAsk(h.Clock, old, h.logf) + h.logf("%s: %s's build ended superseded (%s), passed over: %s; asked again as %s (H-A-555, H-A-557)", ev.Pipeline, + s.Module, ev.Said, passed, a.ID) + 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) + } + return p, nil + } + h.logf("%s: %s's build ended superseded (%s), passed over: %s; %s (H-A-555, H-A-557)", ev.Pipeline, s.Module, ev.Said, passed, why) + ev.Outcome, ev.Said = nodebuildgo.StepEndedOutcomeCouldNotRun, why + } + } 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 { s.Shared = shared @@ -797,6 +825,50 @@ func phasesOf(p seat.Pipeline) *seat.PipelineEndedPhases { return ph } +// notNewer is why a build of module in p ended superseded is passed over (H-A-555): "" when the runner's view of p's branch +// holds a module graph revision newer than p's own (by its source where p names no revision) whose entry names another +// fingerprint of module than p moves; else the words of what the view holds. +func (h *Hearer) notNewer(p seat.Pipeline, module string) string { + m, _ := MoverOf(p, module) + if h.View == nil { + return "the runner reads no view of " + p.Branch + "'s catalog half" + } + half, ok := h.View(p.Branch) + if !ok { + return "the runner's view of " + p.Branch + "'s catalog half is not read yet" + } + newer := half.Revision > p.Revision + if p.Revision <= 0 { + newer = half.Source > p.Source + } + e, named := half.Entries[module] + switch { + case !newer: + return fmt.Sprintf("the newest revision of %s is %d (source %d), not newer than the pipeline's %d (source %d)", p.Branch, + half.Revision, half.Source, p.Revision, p.Source) + case !named || e.Fp == "" || e.Fp == m.Fingerprint: + return fmt.Sprintf("the newer revision %d of %s names %s at %q, the pipeline's own fingerprint %s or none", half.Revision, p.Branch, + module, e.Fp, m.Fingerprint) + } + return "" +} + +// supersededAgain is the ask that puts the build step i of p, ended superseded by an entry no newer than p's (passed), +// again under a new id, written into the step (its ask, asked-at; taken-at and node cleared) (H-A-557); nil and the why of +// its could-not-run end when it cannot be asked. +func (h *Hearer) supersededAgain(p *seat.Pipeline, i int, ev StepEnded, passed string, now time.Time) (*Asked, string) { + s := &p.Steps[i] + if h.AskDeclined == nil || h.PutAgain == nil { + return nil, fmt.Sprintf("its build ended superseded (%s), though %s, and the runner cannot ask it again", ev.Said, passed) + } + a, err := h.AskDeclined(*p, *s, now) + if err != nil { + 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, "" + return a, "" +} + // supersededBuild says whether o is the outcome superseded of a build step of the seat mesh-builds, the one seat whose end // names it (H-A-508): another seat's end naming it is refused as any outcome the runner does not know. func supersededBuild(st seat.StepResult, o string) bool {