From f9e2bbe19358726802564943e8da71a8e23fe2ad Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 12:39:18 +0100 Subject: [PATCH] mesh-delivery-builder: a superseded end names the superseding entry's revision (H-A-561) A build step ended superseded names the module graph revision of the entry that superseded it: the revision the picture heard that entry at, or the ask's own revision where the catalog's kept revision names the newer fingerprint. The runner then judges the end by that revision, not by the order the entries were heard in. Builds: design 47 H2 H-A-561 --- .../internal/build/step.go | 23 +++++++++++++++++++ .../internal/build/step_test.go | 15 +++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-builder/internal/build/step.go b/modules/mesh-delivery-builder/internal/build/step.go index 25e57df5f..ad2bf357b 100644 --- a/modules/mesh-delivery-builder/internal/build/step.go +++ b/modules/mesh-delivery-builder/internal/build/step.go @@ -34,6 +34,9 @@ func (b *Builder) BuildStep(ctx context.Context, ask string, run meshbuilds.Step } at := b.now() end.Ended, end.Outcome, end.Said = &at, outcome, said + if outcome != meshbuilds.StepEndedOutcomeSuperseded { + end.Revision = 0 + } movers := make([]string, 0, len(run.Entries)) for _, e := range run.Entries { movers = append(movers, e.Module) @@ -56,6 +59,8 @@ func (b *Builder) BuildStep(ctx context.Context, ask string, run meshbuilds.Step } // The version is reserved before the build (H-A-155): the ask waits for the builder's picture to hold its revision. if outcome, said := b.awaitRevision(ctx, run); outcome != "" { + // Superseded here, the catalog's revision the ask named names the superseding fingerprint (H-A-561). + end.Revision = run.Revision return finish(outcome, said) } b.askedRevision(run) @@ -80,6 +85,8 @@ func (b *Builder) BuildStep(ctx context.Context, ask string, run meshbuilds.Step failed = append(failed, said) case meshbuilds.StepEndedOutcomeSuperseded: superseded = append(superseded, said) + // The end names the module graph revision of the entry that superseded it, the newest of its entries' (H-A-561). + end.Revision = max(end.Revision, b.supersedingRevision(e.Module, e.Fingerprint)) } } if len(failed) > 0 { @@ -91,6 +98,22 @@ func (b *Builder) BuildStep(ctx context.Context, ask string, run meshbuilds.Step return finish(meshbuilds.StepEndedOutcomePassed, "") } +// supersedingRevision is the module graph revision of the entry heard newest on the branch of module's fingerprint fp, the +// one that supersedes it (H-A-561); 0 when the picture names none. +func (b *Builder) supersedingRevision(module, fp string) int64 { + key, err := builds.BuilderBuildKey(module, fp) + if err != nil { + return 0 + } + b.mu.Lock() + defer b.mu.Unlock() + o, ok := b.origin[key] + if !ok { + o = Origin{First: true} + } + return b.heardAt[o.Branch+"\x00"+module].Revision +} + // askedRevision records on the origin of each entry of run the catalog revision the ask names (design 47 H H-A-218), where // the origin is of the ask's branch and source revision: the version reserved for its build names it, and so does its // package-published, so the runner finds the publishing pipeline by branch and revision. diff --git a/modules/mesh-delivery-builder/internal/build/step_test.go b/modules/mesh-delivery-builder/internal/build/step_test.go index 1c9728a9d..9a62217c5 100644 --- a/modules/mesh-delivery-builder/internal/build/step_test.go +++ b/modules/mesh-delivery-builder/internal/build/step_test.go @@ -528,7 +528,8 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) { } // H-A-508 second addendum: below the picture, a kept revision naming another fingerprint of the module superseded the // ask's: the step ends superseded naming it, never failed with the "below" words. - if end := r2.b.BuildStep(t.Context(), "a1", run); end.Outcome != meshbuilds.StepEndedOutcomeSuperseded || end.Said != stepSuperseded("m", fp1, "src2:other") { + // H-A-561: the end names the catalog's revision that names the superseding fingerprint, the ask's own. + if end := r2.b.BuildStep(t.Context(), "a1", run); end.Outcome != meshbuilds.StepEndedOutcomeSuperseded || end.Said != stepSuperseded("m", fp1, "src2:other") || end.Revision != 47 { t.Errorf("end = %+v; want superseded naming the fingerprint the kept revision names", end) } // H-A-222: an ask of the very source the picture holds, whose entries the picture no longer names (a re-pin kept revision 48 @@ -643,6 +644,18 @@ func anOlderHeardEntryWithdrawsNoNewerBuild(t *testing.T) { if len(withdrawn) != 1 || !strings.Contains(withdrawn[0].Error(), newer.Fp) { t.Errorf("after revision 454's entry: withdrawn %v; want fp1's build withdrawn once, naming %s", withdrawn, newer.Fp) } + // H-A-561: a step of fp1 at revision 453 now ends superseded, naming revision 454, the superseding entry's. + r.b.mu.Lock() + delete(r.b.builds, r.key) + r.b.mu.Unlock() + r.b.KeptRevision = func(context.Context, string, int64) (int64, map[string]string, error) { return 141, map[string]string{"m": fp1}, nil } + held.Store(142) + end := r.b.BuildStep(t.Context(), "a1", meshbuilds.StepRun{Pipeline: "main.453.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Revision: 453, Source: 141, + Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}}) + r.b.Wait() + if end.Outcome != meshbuilds.StepEndedOutcomeSuperseded || end.Revision != 454 || !strings.Contains(end.Said, newer.Fp) { + t.Errorf("fp1's step after revision 454's entry: end = %+v; want superseded by %s, naming revision 454", end, newer.Fp) + } } func aStepAskPastItsRevisionBoundFails(t *testing.T) {