From b79b3a63007aa4b6e6908ba6c0020231c48a5ead Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:16:49 +0100 Subject: [PATCH] B15 superseded-names-its-revision: a superseded end with no revision heard is could-not-run, never superseded with a zero Builds: design 47 H2 H-A-650, H-A-561 --- .../internal/build/step.go | 5 +++ .../internal/build/step_test.go | 43 +++++++++++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/modules/mesh-delivery-builder/internal/build/step.go b/modules/mesh-delivery-builder/internal/build/step.go index 6b2031979..d8240a309 100644 --- a/modules/mesh-delivery-builder/internal/build/step.go +++ b/modules/mesh-delivery-builder/internal/build/step.go @@ -32,6 +32,11 @@ func (b *Builder) BuildStep(ctx context.Context, ask string, run meshbuilds.Step if d := DroppedOf(ctx); d != nil { outcome, said = meshbuilds.StepEndedOutcomeCouldNotRun, d.Error() } + // A superseded end names the revision of the entry that supersedes it (H-A-561); where the builder heard none, it ends the + // step could-not-run itself, naming that, never superseded with a zero revision (design 47 H2 H-A-650). + if outcome == meshbuilds.StepEndedOutcomeSuperseded && end.Revision <= 0 { + outcome, said = meshbuilds.StepEndedOutcomeCouldNotRun, "superseded by a newer entry, but the builder heard no superseding revision for it to name: "+said + } at := b.now() end.Ended, end.Outcome, end.Said = &at, outcome, said if outcome != meshbuilds.StepEndedOutcomeSuperseded { diff --git a/modules/mesh-delivery-builder/internal/build/step_test.go b/modules/mesh-delivery-builder/internal/build/step_test.go index 6081f7558..3ffced765 100644 --- a/modules/mesh-delivery-builder/internal/build/step_test.go +++ b/modules/mesh-delivery-builder/internal/build/step_test.go @@ -158,7 +158,7 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T) if err != nil { t.Fatal(err) } - r.b.Module(t.Context(), "m", newer) + hearAtRevision(t, r.b, "m", newer, 9) r.b.Wait() } r.b.Reserved = res @@ -182,6 +182,7 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T) }) } t.Run("H-A-508: built now, superseded: a newer entry heard while the build runs ends the step superseded", aNewerEntryWhileTheBuildRunsSupersedesTheStep) + t.Run("H-A-650: a superseded end the builder knows no revision for is could-not-run, never superseded with a zero", aSupersededEndWithNoRevisionIsCouldNotRun) t.Run("H-A-155: an ask waits for the picture to take its revision in, then builds with its version reserved", aStepAskWaitsForItsRevision) t.Run("H-A-155: past the bound the ask fails naming its revision, and nothing is built", aStepAskPastItsRevisionBoundFails) t.Run("H-A-205: an ask of a revision below the picture's newest is read by number and built", anOlderKeptRevisionIsReadByNumber) @@ -495,7 +496,7 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) { return 45, map[string]string{"m": fp1}, nil } entryn.Fp = fp2 - rn.b.Entry(context.Background(), Origin{Branch: "main", Source: 46, First: true}, entryn) + rn.b.Entry(context.Background(), Origin{Branch: "main", Source: 46, Revision: 48, First: true}, entryn) rn.b.Wait() if endn := rn.b.BuildStep(t.Context(), "a1", run); endn.Outcome != meshbuilds.StepEndedOutcomeSuperseded || !strings.Contains(endn.Said, "superseded by "+fp2) { t.Errorf("the older ask after the newer entry: end = %+v; want superseded by %s", endn, fp2) @@ -724,7 +725,7 @@ func aNewerEntryWhileTheBuildRunsSupersedesTheStep(t *testing.T) { if err != nil { t.Fatal(err) } - r.b.Module(t.Context(), "m", newer) + hearAtRevision(t, r.b, "m", newer, 9) var end meshbuilds.StepEnded select { case end = <-ended: @@ -739,3 +740,39 @@ func aNewerEntryWhileTheBuildRunsSupersedesTheStep(t *testing.T) { t.Errorf("end = %+v, want superseded by %s", end, fp2) } } + +// hearAtRevision takes a module's value in as the picture hears an entry of catalog revision rev on the first branch, so a step it +// supersedes names that revision (design 47 H H-A-561; H2 H-A-650: none heard is no superseded end). +func hearAtRevision(t *testing.T, b *Builder, module string, value []byte, rev int64) { + t.Helper() + m, err := meshcatalogclient.DecodeModule(value) + if err != nil { + t.Fatal(err) + } + b.init() + b.take(t.Context(), Origin{First: true, Revision: rev}, module, m, nil) + b.Wait() +} + +func aSupersededEndWithNoRevisionIsCouldNotRun(t *testing.T) { + r := newRig(t, goBundle) + r.mf.byDigest[mdigest('a')] = catalogue.Manifest{Module: "m", Version: "0.1", Build: &catalogue.Build{Artifacts: []catalogue.Artifact{goBundle}}} + if v := r.consider(t, "modules/m"); v.State != builds.BuildDone { + t.Fatalf("build = %+v, want done", v) + } + newer, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20", + Fp2: fp2, Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(agreedToolchains)}) + if err != nil { + t.Fatal(err) + } + r.b.Module(t.Context(), "m", newer) // heard with no catalog revision + r.b.Wait() + r.b.Reserved = &fakeReservations{} + r.b.StepEntry = func(context.Context, string) (meshcatalog.CatalogEntry, error) { + return meshcatalog.CatalogEntry{Module: "m", Repository: "novox/m", Commit: "c1", Fp: fp1, ManifestDigest: digestOf(false), Path: "modules/m"}, nil + } + end := r.b.BuildStep(t.Context(), "a1", meshbuilds.StepRun{Pipeline: "main.1.m", Step: meshbuilds.StepRunStepBuild, Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}}) + if end.Outcome != meshbuilds.StepEndedOutcomeCouldNotRun || end.Revision != 0 || !strings.Contains(end.Said, "no superseding revision") { + t.Errorf("end = %+v, want could not run naming that no superseding revision was heard", end) + } +}