From 48038105fc9ff0f36a68d0fb60eb95df866c1c29 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 18:05:52 +0100 Subject: [PATCH] P6 widens-at-the-base: a pipeline's widens is its revision against the revision's own base, and a carried mover says its first pipeline's Builds: design 47 H2 H-A-582, H-A-595 --- .../cmd/mesh-delivery-pipeline/views.go | 2 +- .../cmd/mesh-delivery-pipeline/widens.go | 2 +- .../internal/pipeline/endopen_test.go | 2 +- .../internal/pipeline/registrations.go | 4 +++- .../internal/pipeline/steps.go | 5 ++++- .../internal/pipeline/widens.go | 10 +++++++--- .../internal/pipeline/widens_test.go | 17 +++++++++++++---- 7 files changed, 30 insertions(+), 12 deletions(-) diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/views.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/views.go index d508b2dd5..9b5b34320 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/views.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/views.go @@ -192,5 +192,5 @@ func (v catalogView) View() (pipeline.Half, bool) { if !ok { return pipeline.Half{}, false } - return pipeline.Half{Revision: h.Revision.Revision, Source: h.Revision.Source, Entries: h.Entries}, true + return pipeline.Half{Revision: h.Revision.Revision, Source: h.Revision.Source, Base: h.Revision.Base, Entries: h.Entries}, true } diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/widens.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/widens.go index eb509c08f..8447568cd 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/widens.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/widens.go @@ -175,7 +175,7 @@ func catalogRevision(call func(string, any) (json.RawMessage, error), kept *revi if h, ok := kept.get(branch, a.Revision.Revision); ok { return h, nil } - half = pipeline.Half{Revision: a.Revision.Revision, Source: a.Revision.Source, Entries: map[string]catalog.CatalogEntry{}, + half = pipeline.Half{Revision: a.Revision.Revision, Source: a.Revision.Source, Base: a.Revision.Base, Entries: map[string]catalog.CatalogEntry{}, Call: a.Revision.Call, Movers: a.Revision.Movers} in.Revision = a.Revision.Revision // the pages of one revision, though a newer one is said between them } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go index 49ec419e3..891236465 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go @@ -123,7 +123,7 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { store.refused["main.118"], store.refused["main.119"] = true, true grants, revisions := 0, 0 w := &Widener{ - Revision: func(string, int64) (Half, error) { revisions++; return Half{}, nil }, + Revision: func(string, int64) (Half, error) { revisions++; return Half{Base: 4}, nil }, Holder: func(s string) (string, error) { return s, nil }, GrantsFor: func(string, int64) (meshgrants.GrantsFor, error) { grants++ diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/registrations.go b/modules/mesh-delivery-pipeline/internal/pipeline/registrations.go index 1f0cc57ab..b2233cc37 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/registrations.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/registrations.go @@ -98,7 +98,9 @@ type readyView interface{ Ready() <-chan struct{} } type Half struct { Revision int64 Source int64 - Entries map[string]catalog.CatalogEntry + // Base is the revision's base, the newest kept revision of its branch below it (H-A-151); 0 on the branch's first take-in. + Base int64 + Entries map[string]catalog.CatalogEntry // Call and Movers are the revision's own, as the revision verb answers them (H-A-213): what made it and its movers; // a view's half names none. Call string diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go index 1f78a2d91..97ab0410e 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go @@ -1085,7 +1085,10 @@ func (h *Hearer) endPipeline(p *seat.Pipeline, now time.Time, wr func(seat.Pipel } if wr != nil { for i := range p.Movers { - p.Movers[i].Widens = wr(*p, p.Movers[i].Module) + // A carried or reopened mover says the widens its first pipeline computed and never computes it again (H-A-595). + if len(p.Movers[i].Widens) == 0 { + p.Movers[i].Widens = wr(*p, p.Movers[i].Module) + } } } return true diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/widens.go b/modules/mesh-delivery-pipeline/internal/pipeline/widens.go index 4f73cb0ae..7bf7a4725 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/widens.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/widens.go @@ -105,9 +105,13 @@ func (r *endReads) widens(p seat.Pipeline, module string) []seat.Widening { if err != nil { return could("mesh-catalog", fmt.Sprintf("the candidate's revision %d is not read: %v", p.Revision, err)) } - newest, err := r.revision(p.Branch, 0) - if err != nil { - return could("mesh-catalog", fmt.Sprintf("the branch's newest revision is not read: %v", err)) + // A change is what its movers alter against the revision's own base, never against a branch's newest (design 47 H2 H-A-582); + // the branch's first take-in has no base and alters nothing against it. + newest := cand + if cand.Base > 0 { + if newest, err = r.revision(p.Branch, cand.Base); err != nil { + return could("mesh-catalog", fmt.Sprintf("the base revision %d of revision %d is not read: %v", cand.Base, p.Revision, err)) + } } var out []seat.Widening for _, s := range servingSeats(p) { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/widens_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/widens_test.go index b146b7aac..b04caf628 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/widens_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/widens_test.go @@ -27,7 +27,7 @@ func halfOf(rev int64, es ...catalog.CatalogEntry) Half { // (the runner, the catalog, each step's seat, the node-engine) by fingerprint, an acting rule gained or matching more, a // credential named that was not, and the grants the grants part adds; each is said by name, a grants part that does not answer says // `could not run` and nothing is refused (design 47 G §71, §275, §441, A-207, A-215, A-220). -func TestWidensIsTheCandidateAgainstTheNewest(t *testing.T) { +func TestWidensIsTheCandidateAgainstItsBase(t *testing.T) { p := seat.Pipeline{Pipeline: "main.8.app", Branch: "main", Source: 31, Revision: 8, Steps: []seat.StepResult{{Module: "app", Step: "unit", Seat: "node-build-go"}, {Module: "app", Step: "lint", Seat: "node-build-go"}, {Module: "app", Step: "approval"}}, Movers: []seat.Mover{{Module: "app"}}} holders := map[string]string{seat.Seat: "runner", catalog.Seat: "indexer", "node-build-go": "build-go", "node-engine": "host"} @@ -65,13 +65,16 @@ func TestWidensIsTheCandidateAgainstTheNewest(t *testing.T) { for _, c := range cases { w := &Widener{ Revision: func(_ string, rev int64) (Half, error) { - if rev == 0 { + // The base of revision 8 is revision 9 here (design 47 H2 H-A-582): never the branch's newest, revision 0. + if rev == 9 { return newest, nil } if rev != 8 { - t.Errorf("%s: the candidate asked as revision %d", c.name, rev) + t.Errorf("%s: revision %d asked, want the candidate 8 or its base 9", c.name, rev) } - return c.cand, nil + cand := c.cand + cand.Base = 9 + return cand, nil }, Holder: func(s string) (string, error) { return holders[s], nil }, GrantsFor: func(string, int64) (meshgrants.GrantsFor, error) { return c.grants, c.grantsErr }, @@ -98,6 +101,12 @@ func TestAnEndKeepsEachMoversWidens(t *testing.T) { if !h.endPipeline(&p, time.Unix(1, 0), h.widensReads()) || len(p.Movers[0].Widens) != 1 || p.Movers[0].Widens[0].Name != "app s v" || p.Movers[1].Widens[0].Name != "lib s v" { t.Errorf("the ended movers = %+v", p.Movers) } + // design 47 H2 H-A-595 (AC-P6b): a carried mover says its first pipeline's widens, never computed again. + c := seat.Pipeline{Outcome: seat.PipelineOutcomeRunning, Movers: []seat.Mover{{Module: "app", Widens: []seat.Widening{{What: seat.WideningWhatGrant, Name: "first"}}}}, + Steps: []seat.StepResult{{Module: "app", Step: "build", Outcome: "passed"}}} + if !h.endPipeline(&c, time.Unix(1, 0), h.widensReads()) || len(c.Movers[0].Widens) != 1 || c.Movers[0].Widens[0].Name != "first" { + t.Errorf("a carried mover's widens = %+v, want its first pipeline's", c.Movers[0].Widens) + } h.Widens = nil q := seat.Pipeline{Outcome: seat.PipelineOutcomeRunning, Movers: []seat.Mover{{Module: "app"}}, Steps: []seat.StepResult{{Module: "app", Step: "build", Outcome: "passed"}}} if !h.endPipeline(&q, time.Unix(1, 0), h.widensReads()) || len(q.Movers[0].Widens) != 0 {