From 14df4c69068473b157269b8d6f2dcd6312be0a9b Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 22:56:44 +0100 Subject: [PATCH] mesh-delivery-pipeline: an ended pipeline's mover is placed from the head's entry; a rerun at a fingerprint the head no longer holds is refused Builds: design 47 H2 H-A-764 (1), (2); H-A-763 (3), H-A-761, H-A-286 --- .../internal/pipeline/place_test.go | 2 +- .../internal/pipeline/repin_test.go | 26 +++++++++++++++++++ .../internal/pipeline/start.go | 6 +++-- .../internal/pipeline/testruns_test.go | 8 +++--- .../internal/pipeline/verbs.go | 7 ++++- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go index 57f62eb88..4e49421e7 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/place_test.go @@ -48,7 +48,7 @@ func placeFixture() (catalog.Registration, map[string]catalog.CatalogEntry) { Artifacts: map[string]catalog.StepStatuses{"tools": {Lint: "bypass"}}, }} return reg, map[string]catalog.CatalogEntry{ - "app": {Module: "app", Path: "modules/app", Packages: map[string]string{"git.novox.be/novox/mesh-sdk/go": "v0.1.25"}, Artifacts: []catalog.Artifact{{Ref: "app:program", Language: "go"}, {Ref: "app:tools", Language: "go"}, + "app": {Module: "app", Fp: "src2:aa", Path: "modules/app", Packages: map[string]string{"git.novox.be/novox/mesh-sdk/go": "v0.1.25"}, Artifacts: []catalog.Artifact{{Ref: "app:program", Language: "go"}, {Ref: "app:tools", Language: "go"}, {Ref: "app:web", Language: "rust"}}, Inputs: &catalog.EntryInputs{Paths: map[string][]string{"app:program": {"cmd/app"}}}}, "mesh-build-go": {Module: "mesh-build-go", Acts: []catalog.ActingRule{{Seat: "node-build-go", Step: "build", On: "go"}}}, } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go index a461728b2..3c35851fb 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go @@ -171,6 +171,32 @@ func TestASameSourceRepinKeepsTheMoverInItsPipeline(t *testing.T) { if b, ok := a.Ask.(nodebuildgo.StepAsk); !ok || b.Step.Fetch.Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.27" { t.Errorf("the rerun with the head holding app at its fingerprint asked %+v, want mesh-sdk pinned to the head's v0.1.27", a.Ask) } + // H-A-764 (1): a pipeline that ended and goes on again places its never-asked kept mover from the head's entry too, its ids still + // mixing in the kept revision; a running pipeline's kept mover is placed at its kept revision (H-A-286). + for ends, want := range map[int64]string{1: "v0.1.27", 0: "v0.1.26"} { + again := cur + again.EndCount, again.Steps = ends, nil + again.Movers = slices.Clone(cur.Movers) + asked, _, _, _ := s.placeMovers(&again, func(string) (catalog.Registration, bool) { return reg, true }, headEntries, time.Unix(100, 0)) + var got string + for _, a := range asked { + if b, ok := a.Ask.(nodebuildgo.StepAsk); ok && b.Step != nil && b.Step.Step == "unit" { + got = b.Step.Fetch.Packages["git.novox.be/novox/mesh-sdk/go"] + } + } + if ends == 0 { + want = "" // revision 11 leaves a package unpinned: a running pipeline's unit step waits on the publish + } + if got != want { + t.Errorf("placing with %d ends asked the unit step with mesh-sdk %q, want %q", ends, got, want) + } + } + // H-A-764 (2): a rerun of a mover the head holds at another fingerprint is refused naming both fingerprints, and asks nothing. + headEntries["app"] = func() catalog.CatalogEntry { e := headApp; e.Fp = "src2:zz"; return e }() + if _, err := rv.askOf(cur, unit, "op@shanks", time.Unix(101, 0)); err == nil || !strings.Contains(err.Error(), "src2:ab") || !strings.Contains(err.Error(), "src2:zz") { + t.Errorf("the rerun with the head at another fingerprint = %v, want it refused naming src2:ab and src2:zz", err) + } + headEntries["app"] = headApp // A revision of a new source starts its own pipeline and moves the mover out (H-A-223). if n, err := s.Revised(ev(12), read); n != 1 || err != nil { t.Fatalf("a new source's revision started %d (%v)", n, err) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/start.go b/modules/mesh-delivery-pipeline/internal/pipeline/start.go index ba2795075..f3644fb75 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/start.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/start.go @@ -511,7 +511,9 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog } // A mover a same-source re-pin kept is placed from the revision it is kept at, its ids its own (H-A-286). entries := all - if rev := kept[m.Module]; rev > 0 { + // A mover of a pipeline that ended and goes on again reads the head's entry when it holds the mover at its fingerprint + // (design 47 H2 H-A-764 (1), H-A-763 (3)); its ids still mix in the kept revision. + if rev := kept[m.Module]; rev > 0 && !(p.EndCount > 0 && all[m.Module].Fp == m.Fingerprint) { var err error if entries, err = s.keptEntries(p.Branch, rev); errors.Is(err, ErrRevisionGone) { // A kept revision the catalog no longer holds is never read: the pipeline ends failed (H-A-496). @@ -830,7 +832,7 @@ func (s *Starter) Resume(store Updater, branch string, half Half) (int, error) { } // A kept mover's steps are found by the ids its kept revision gives, from that revision's entries (H-A-286). entries, rev := half.Entries, kept[m.Module] - if rev > 0 { + if rev > 0 && !(p.EndCount > 0 && half.Entries[m.Module].Fp == m.Fingerprint) { // H-A-764 (1) var err error if entries, err = s.keptEntries(p.Branch, rev); err != nil { s.logf("%s: revision %d of %s, which %s is kept at, is not read (%v): its steps are asked again once it is", key, rev, p.Branch, m.Module, err) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go index c35cc487d..d7554587e 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/testruns_test.go @@ -157,7 +157,7 @@ func newRunFixture() *runFixture { func (f *runFixture) start(t *testing.T, source, revision int64) seat.Pipeline { t.Helper() entries := map[string]catalog.CatalogEntry{ - "app": {Module: "app", Path: "modules/app", Artifacts: []catalog.Artifact{{Ref: "app:program", Language: "go"}, {Ref: "app:tools", Language: "go"}}}, + "app": {Module: "app", Fp: "src2:aa", Path: "modules/app", Artifacts: []catalog.Artifact{{Ref: "app:program", Language: "go"}, {Ref: "app:tools", Language: "go"}}}, "mesh-build-go": {Module: "mesh-build-go", Acts: []catalog.ActingRule{{Seat: "node-build-go", Step: "build", On: "go"}}}, } if ok, err := f.s.Start(Begin{Branch: "main", Source: source, Revision: revision, Key: Key("main", source), Entries: entries, Movers: []seat.Mover{{Module: "app", Commit: "c1", Fingerprint: "src2:aa"}}}); !ok || err != nil { @@ -547,7 +547,7 @@ func TestARerunOfATestRunMovesEveryReaderThatDidNotPass(t *testing.T) { } v := Verbs{Hearer: f.h, Starter: f.s, View: func(string) (Half, bool) { return Half{Entries: map[string]catalog.CatalogEntry{ - "app": {Module: "app", Path: "modules/app", Artifacts: []catalog.Artifact{{Ref: "app:program", Language: "go"}, {Ref: "app:tools", Language: "go"}}}, + "app": {Module: "app", Fp: "src2:aa", Path: "modules/app", Artifacts: []catalog.Artifact{{Ref: "app:program", Language: "go"}, {Ref: "app:tools", Language: "go"}}}, "mesh-build-go": {Module: "mesh-build-go", Acts: []catalog.ActingRule{{Seat: "node-build-go", Step: "build", On: "go"}}}}}, true }, Acts: &actLog{}} a, err := v.Rerun("op@shanks", seat.RerunInput{Pipeline: p.Pipeline, Step: "unit", Artifact: "app:tools", Why: "flaky"}) @@ -874,7 +874,7 @@ func TestNoWriteOfATestRunActsOnAReadBeforeItsLatestChange(t *testing.T) { } v := Verbs{Hearer: f.h, Starter: f.s, View: func(string) (Half, bool) { return Half{Entries: map[string]catalog.CatalogEntry{ - "app": {Module: "app", Path: "modules/app", Artifacts: []catalog.Artifact{{Ref: "app:program", Language: "go"}, {Ref: "app:tools", Language: "go"}}}, + "app": {Module: "app", Fp: "src2:aa", Path: "modules/app", Artifacts: []catalog.Artifact{{Ref: "app:program", Language: "go"}, {Ref: "app:tools", Language: "go"}}}, "mesh-build-go": {Module: "mesh-build-go", Acts: []catalog.ActingRule{{Seat: "node-build-go", Step: "build", On: "go"}}}}}, true }, Acts: &actLog{}, RevisionHeld: func(string, int64) error { return nil }} a, err := v.Rerun("op@shanks", seat.RerunInput{Pipeline: p.Pipeline, Step: "unit", Artifact: "app:program", Why: "fixed"}) @@ -907,7 +907,7 @@ func TestNoWriteOfATestRunActsOnAReadBeforeItsLatestChange(t *testing.T) { }} v := Verbs{Hearer: f.h, Starter: f.s, View: func(string) (Half, bool) { return Half{Entries: map[string]catalog.CatalogEntry{ - "app": {Module: "app", Path: "modules/app", Artifacts: []catalog.Artifact{{Ref: "app:program", Language: "go"}, {Ref: "app:tools", Language: "go"}}}, + "app": {Module: "app", Fp: "src2:aa", Path: "modules/app", Artifacts: []catalog.Artifact{{Ref: "app:program", Language: "go"}, {Ref: "app:tools", Language: "go"}}}, "mesh-build-go": {Module: "mesh-build-go", Acts: []catalog.ActingRule{{Seat: "node-build-go", Step: "build", On: "go"}}}}}, true }, Acts: &actLog{}} a, err := v.Rerun("op@shanks", seat.RerunInput{Pipeline: p.Pipeline, Step: "unit", Artifact: "app:program", Why: "fixed"}) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go b/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go index 010ff2145..f9261a7e2 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/verbs.go @@ -711,7 +711,12 @@ func (v Verbs) placedAsk(p seat.Pipeline, s seat.StepResult, id string, now time // A kept mover's step is placed under its kept ids (H-A-286), from the head's entry when that holds the mover at its // fingerprint, so its build is asked with the newest pins (design 47 H2 H-A-763 (3)); else from the revision it is kept at. entries, rev := half.Entries, v.keptOf(p.Pipeline)[m.Module] - if rev > 0 && (p.Run != "" || half.Entries[m.Module].Fp != m.Fingerprint) { + if p.Run == "" && half.Entries[m.Module].Fp != m.Fingerprint { + // An older fingerprint is never built again after a newer one (design 47 H2 H-A-764 (2), as H-A-761). + return nil, fmt.Errorf("%s of %s is asked again at fingerprint %s, which the head's revision %d of %s no longer holds (it holds %q); its pipeline's revision is %d and its kept revision %d: nothing was asked", + s.Step, m.Module, m.Fingerprint, half.Revision, p.Branch, half.Entries[m.Module].Fp, p.Revision, rev) + } + if rev > 0 && p.Run != "" { var err error if entries, err = v.Starter.keptEntries(p.Branch, rev); err != nil { return nil, fmt.Errorf("revision %d of %s, which %s is kept at, is not read (%v): the step is asked when it is", rev, p.Branch, m.Module, err)