From b53a3fd57566c42653a16b714ceb21082b04c3a3 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 00:08:07 +0100 Subject: [PATCH 1/6] mesh-builds: a build step ends superseded, never failed, for a superseded fingerprint The seat mesh-builds' step-ended gains the outcome superseded, its why naming the superseding fingerprint, so a stale build is not said as a failure of the change; the seat's form is raised to 2. Builds: design 47 H2 H-A-508 (and its addendum) --- .../go/seats/meshbuilds/contract.go | 11 +++++----- .../go/seats/meshbuilds/contract_test.go | 2 ++ .../seats/mesh-builds/fixtures/events.json | 21 +++++++++++++++++++ .../seats/mesh-builds/seat.json | 10 +++++---- .../ts/seats/meshbuilds/index.d.ts | 6 +++--- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go b/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go index 7d0a0c843..e6e00d787 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go @@ -13,13 +13,13 @@ const Seat = "mesh-builds" // Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): // a reader of a value of another form says "form N, this reader knows M". -const Form = 1 +const Form = 2 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "1" - generatedFieldsDigest = "AskTakenEvent=6d5d3da7ac39 BuildEntry=3c829a0a3d58 Dependency=90a32b07c563 DropAnswer=7538f2f5e68e PackagePublished=34dd069a6aab PackagePublishedEvent=8e12888c1559 PublishQueueAnswer=0f1326e35e17 PublishQueueAnswerCountsItem=b770db2f0920 PublishQueueAnswerQueueItem=b1eebc09f41e PublishedAnswer=69a801982819 ReservedAnswer=2272a4d6f0f4 ReservedAnswerArtifactsItem=d74eb6e00abb StepAccept=18efeefb6c34 StepEnded=09a07bfbcb15 StepEndedEvent=207787118dac StepRun=dc5893aef7e5 ToolchainAgreed=f3d9ce993734 ToolchainAgreedDigestsItem=1d42893a96b9 ToolchainAgreedEvent=e3502d6f194d VersionReservedEvent=984547d6ad07" + generatedForms = "2" + generatedFieldsDigest = "AskTakenEvent=6d5d3da7ac39 BuildEntry=3c829a0a3d58 Dependency=90a32b07c563 DropAnswer=7538f2f5e68e PackagePublished=34dd069a6aab PackagePublishedEvent=8e12888c1559 PublishQueueAnswer=0f1326e35e17 PublishQueueAnswerCountsItem=b770db2f0920 PublishQueueAnswerQueueItem=b1eebc09f41e PublishedAnswer=69a801982819 ReservedAnswer=2272a4d6f0f4 ReservedAnswerArtifactsItem=d74eb6e00abb StepAccept=18efeefb6c34 StepEnded=40a0090f7cb5 StepEndedEvent=207787118dac StepRun=dc5893aef7e5 ToolchainAgreed=f3d9ce993734 ToolchainAgreedDigestsItem=1d42893a96b9 ToolchainAgreedEvent=e3502d6f194d VersionReservedEvent=984547d6ad07" ) const ( @@ -163,13 +163,13 @@ type StepEnded struct { ID string `json:"id"` // the node the builder ran it on, as in the subject Node string `json:"node"` - // never passed for a build that built nothing + // never passed for a build that built nothing; superseded for an entry whose fingerprint a newer entry of its branch superseded, built or not (design 47 H2 H-A-508): the mover moved to the newer revision's pipeline, never a failure Outcome string `json:"outcome"` // the pins the step's entries were built with, each mesh package's version by its module path, the ones the builder took from the registry for a package the entry named with none included; the runner asks the entry's held test steps with them (H-A-207) Packages map[string]string `json:"packages,omitempty"` Pipeline string `json:"pipeline"` Rerun bool `json:"rerun,omitempty"` - // why it failed or could not run: the entry not built, the part not heard + // why it failed, could not run or was superseded: the entry not built, the part not heard, the superseding fingerprint Said string `json:"said,omitempty"` Started *time.Time `json:"started,omitempty"` Step string `json:"step"` @@ -183,6 +183,7 @@ const ( StepEndedOutcomeFailed = "failed" StepEndedOutcomeNothingToRun = "nothing to run" StepEndedOutcomeCouldNotRun = "could not run" + StepEndedOutcomeSuperseded = "superseded" ) // The values of StepEnded's step. diff --git a/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract_test.go index 8f92cb7f8..251eaabbf 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract_test.go @@ -25,6 +25,8 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.step-ended\\.[^.*> ]+$")}, {name: "the build step failed on its entry", subject: "mesh.seat.mesh-builds.event.step-ended.laptop", given: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"id\":\"m2kx9a1b3c4d6b\",\"node\":\"laptop\",\"outcome\":\"failed\",\"pipeline\":\"main.12.nats\",\"said\":\"nats:program did not build\",\"step\":\"build\",\"v\":1}", wire: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"id\":\"m2kx9a1b3c4d6b\",\"node\":\"laptop\",\"outcome\":\"failed\",\"pipeline\":\"main.12.nats\",\"said\":\"nats:program did not build\",\"step\":\"build\",\"v\":1}", decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.step-ended\\.[^.*> ]+$")}, + {name: "the build step ended superseded: a newer entry of its branch superseded its fingerprint (H-A-508)", subject: "mesh.seat.mesh-builds.event.step-ended.laptop", given: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"form\":2,\"id\":\"m2kx9a1b3c4d6c\",\"node\":\"laptop\",\"outcome\":\"superseded\",\"pipeline\":\"main.12.nats\",\"said\":\"nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch\",\"step\":\"build\",\"v\":1}", wire: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"form\":2,\"id\":\"m2kx9a1b3c4d6c\",\"node\":\"laptop\",\"outcome\":\"superseded\",\"pipeline\":\"main.12.nats\",\"said\":\"nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch\",\"step\":\"build\",\"v\":1}", + decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.step-ended\\.[^.*> ]+$")}, {name: "an ask taken at the pull", subject: "mesh.seat.mesh-builds.event.ask-taken.main-3589-mesh-sdk-unit", given: "{\"ask\":\"main-3589-mesh-sdk-unit\",\"at\":\"2026-11-21T22:00:00Z\",\"node\":\"anchor\"}", wire: "{\"ask\":\"main-3589-mesh-sdk-unit\",\"at\":\"2026-11-21T22:00:00Z\",\"node\":\"anchor\"}", decode: func(b []byte) (any, error) { var v AskTakenEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.ask-taken\\.[^.*> ]+$")}, {name: "a version reserved at a fingerprint", subject: "mesh.seat.mesh-builds.event.version-reserved", given: "{\"artifact\":\"mesh-sdk:go\",\"fingerprint\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"form\":1,\"module\":\"mesh-sdk\",\"path\":\"git.novox.be/novox/mesh-sdk/go\",\"revision\":\"412\",\"version\":\"0.1.21\"}", wire: "{\"artifact\":\"mesh-sdk:go\",\"fingerprint\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"form\":1,\"module\":\"mesh-sdk\",\"path\":\"git.novox.be/novox/mesh-sdk/go\",\"revision\":\"412\",\"version\":\"0.1.21\"}", diff --git a/modules/mesh-delivery-contracts/seats/mesh-builds/fixtures/events.json b/modules/mesh-delivery-contracts/seats/mesh-builds/fixtures/events.json index 174a449b9..f146c1626 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-builds/fixtures/events.json +++ b/modules/mesh-delivery-contracts/seats/mesh-builds/fixtures/events.json @@ -96,6 +96,27 @@ "said": "nats:program did not build" } }, + { + "name": "the build step ended superseded: a newer entry of its branch superseded its fingerprint (H-A-508)", + "of": "event:step-ended", + "subject": "mesh.seat.mesh-builds.event.step-ended.laptop", + "given": { + "v": 1, + "form": 2, + "id": "m2kx9a1b3c4d6c", + "pipeline": "main.12.nats", + "step": "build", + "node": "laptop", + "outcome": "superseded", + "entries": [ + { + "module": "nats", + "fingerprint": "fp-0123" + } + ], + "said": "nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch" + } + }, { "name": "an ask taken at the pull", "of": "event:ask-taken", diff --git a/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json b/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json index d077cd8c2..0d7612129 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json @@ -636,13 +636,14 @@ "passed", "failed", "nothing to run", - "could not run" + "could not run", + "superseded" ], - "description": "never passed for a build that built nothing" + "description": "never passed for a build that built nothing; superseded for an entry whose fingerprint a newer entry of its branch superseded, built or not (design 47 H2 H-A-508): the mover moved to the newer revision's pipeline, never a failure" }, "said": { "type": "string", - "description": "why it failed or could not run: the entry not built, the part not heard" + "description": "why it failed, could not run or was superseded: the entry not built, the part not heard, the superseding fingerprint" }, "rerun": { "type": "boolean" @@ -703,5 +704,6 @@ "fingerprint" ] } - } + }, + "form": 2 } diff --git a/modules/mesh-delivery-contracts/ts/seats/meshbuilds/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshbuilds/index.d.ts index 5e2903e05..2e6574bba 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshbuilds/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshbuilds/index.d.ts @@ -104,13 +104,13 @@ export interface StepEnded { "id": string; /** the node the builder ran it on, as in the subject */ "node": string; - /** never passed for a build that built nothing */ - "outcome": "passed" | "failed" | "nothing to run" | "could not run"; + /** never passed for a build that built nothing; superseded for an entry whose fingerprint a newer entry of its branch superseded, built or not (design 47 H2 H-A-508): the mover moved to the newer revision's pipeline, never a failure */ + "outcome": "passed" | "failed" | "nothing to run" | "could not run" | "superseded"; /** the pins the step's entries were built with, each mesh package's version by its module path, the ones the builder took from the registry for a package the entry named with none included; the runner asks the entry's held test steps with them (H-A-207) */ "packages"?: Record; "pipeline": string; "rerun"?: boolean; - /** why it failed or could not run: the entry not built, the part not heard */ + /** why it failed, could not run or was superseded: the entry not built, the part not heard, the superseding fingerprint */ "said"?: string; "started"?: string; "step": "build"; -- 2.54.0 From a1379ef084b1e2edbdc44bb572f1e788fe9cafc1 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 00:11:47 +0100 Subject: [PATCH 2/6] builder: a build step of a superseded fingerprint ends superseded, never failed The builder judged an existing done build only by its reservation, release or takeover; once the release of the taking-over version deleted the series key, a stale build of main.327 fell through to "no version is reserved for it". It now judges the step's fingerprint against the branch's newest entry first, for a done build as for one not built, and ends the step superseded naming the superseding fingerprint; those words stay for a current fingerprint, and the release record keeps the fingerprints it withdrew, so TakenOver answers after the release. Builds: design 47 H2 H-A-508 (and its addendum) --- .../internal/build/step.go | 39 +++++++++++++++---- .../internal/build/step_test.go | 36 +++++++++++------ .../internal/versions/reserve.go | 36 +++++++++++++++-- .../internal/versions/reserve_test.go | 16 +++++++- 4 files changed, 103 insertions(+), 24 deletions(-) diff --git a/modules/mesh-delivery-builder/internal/build/step.go b/modules/mesh-delivery-builder/internal/build/step.go index 5be6332f0..55c99d80b 100644 --- a/modules/mesh-delivery-builder/internal/build/step.go +++ b/modules/mesh-delivery-builder/internal/build/step.go @@ -18,12 +18,13 @@ import ( // number is needed, and the builder follows no candidate. // BuildStep builds the entries of the step ask ask and answers its end: passed when every entry's build is done, failed when -// one failed (said), could not run when an entry could not be read, nothing to run for an ask naming none. The node is the +// one failed (said), superseded when none failed and a newer entry of its branch superseded one (H-A-508), could not run when +// an entry could not be read, nothing to run for an ask naming none. The node is the // caller's to set. func (b *Builder) BuildStep(ctx context.Context, ask string, run meshbuilds.StepRun) meshbuilds.StepEnded { b.init() started := b.now() - end := meshbuilds.StepEnded{V: 1, ID: ask, Pipeline: run.Pipeline, Step: meshbuilds.StepEndedStepBuild, Rerun: run.Rerun, By: run.By, Entries: run.Entries, Node: b.Node, Started: &started} + end := meshbuilds.StepEnded{V: 1, Form: meshbuilds.Form, ID: ask, Pipeline: run.Pipeline, Step: meshbuilds.StepEndedStepBuild, Rerun: run.Rerun, By: run.By, Entries: run.Entries, Node: b.Node, Started: &started} // finish is the one place the ask is answered: one journal line, "answered " // (design 47 H2 §792; H-A-320 (1), H-A-333). finish := func(outcome, said string) meshbuilds.StepEnded { @@ -58,7 +59,7 @@ func (b *Builder) BuildStep(ctx context.Context, ask string, run meshbuilds.Step return finish(outcome, said) } b.askedRevision(run) - var failed []string + var failed, superseded []string for _, e := range run.Entries { var pins map[string]string outcome, said := b.buildEntry(ctx, run.Pipeline, e, &pins) @@ -77,11 +78,16 @@ func (b *Builder) BuildStep(ctx context.Context, ask string, run meshbuilds.Step return finish(outcome, said) case meshbuilds.StepEndedOutcomeFailed: failed = append(failed, said) + case meshbuilds.StepEndedOutcomeSuperseded: + superseded = append(superseded, said) } } if len(failed) > 0 { return finish(meshbuilds.StepEndedOutcomeFailed, strings.Join(failed, "; ")) } + if len(superseded) > 0 { + return finish(meshbuilds.StepEndedOutcomeSuperseded, strings.Join(superseded, "; ")) + } return finish(meshbuilds.StepEndedOutcomePassed, "") } @@ -133,7 +139,19 @@ func (b *Builder) buildEntry(ctx context.Context, pipeline string, e meshbuilds. b.logf("%s@%s build step answered %s for %s (%s)", entry.Module, entry.Fp, outcome, pipeline, how) return outcome, said } - if done, failedWords, found := b.keyEnd(ctx, key); found { + done, failedWords, found := b.keyEnd(ctx, key) + // The fingerprint is judged against its branch's newest entry first, for a done build as for one not built (H-A-508): a + // superseded one ends the step superseded, naming the superseding fingerprint, never failed. One not built is refused, not + // waited on (H-A-489): no look builds a superseded fingerprint, so its end would never come. + if newer := b.supersededBy(entry.Module, key, entry.Fp); newer != "" { + how := "existing build" + if !found { + how = "refused" + b.saySuperseded(entry.Module, key, entry.Fp, newer) + } + return answered(meshbuilds.StepEndedOutcomeSuperseded, stepSuperseded(entry.Module, entry.Fp, newer), how) + } + if found { if done { // A key done before reports the pins it was built with, kept with it, never the ones a publish gives now. *pins = b.keptPins(ctx, key) @@ -142,10 +160,6 @@ func (b *Builder) buildEntry(ctx context.Context, pipeline string, e meshbuilds. } return answered(meshbuilds.StepEndedOutcomeFailed, failedWords, "existing build") } - if newer := b.supersededBy(entry.Module, key, entry.Fp); newer != "" { - // Refused, not waited on (H-A-489): no look builds a superseded fingerprint, so its end would never come. - return answered(meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s at %s %s", entry.Module, entry.Fp, b.saySuperseded(entry.Module, key, entry.Fp, newer)), "refused") - } m := meshcatalog.ModulesByModuleValue{Repository: entry.Repository, Commit: entry.Commit, Fp2: entry.Fp, Manifest: meshcatalogclient.BareManifestDigest(entry.ManifestDigest), Path: entry.Path, Toolchains: CatalogToolchains(b.agreedFor(ctx, meshcatalogclient.BareManifestDigest(entry.ManifestDigest))), Packages: entry.Packages} b.consider(ctx, entry.Module, m) @@ -204,11 +218,20 @@ func (b *Builder) passedWithItsVersion(ctx context.Context, entry meshcatalog.Ca // H-A-244 (2): the series was taken over by a newer fingerprint, whose number it carries now: the build is stale. return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s: built at %s but its series moved to %s %s: stale", entry.Module, entry.Fp, by.Fingerprint, by.Version) } + if newer := b.supersededBy(entry.Module, key, entry.Fp); newer != "" { + // Superseded while it built: those words are said only for a current fingerprint (H-A-508). + return meshbuilds.StepEndedOutcomeSuperseded, stepSuperseded(entry.Module, entry.Fp, newer) + } return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s: built at %s, but no version is reserved for it; builder_reserve_done reserves one for the done build", entry.Module, entry.Fp) } return meshbuilds.StepEndedOutcomePassed, "" } +// stepSuperseded is the why of a build step ended superseded (H-A-508): the fingerprint and the newer entry that superseded it. +func stepSuperseded(module, fp, newer string) string { + return fmt.Sprintf("%s at %s is superseded by %s, the newest entry heard on its first branch", module, fp, newer) +} + // keptPins are the pins a done key keeps it was built with (H-A-207); none when it keeps none or cannot be read, so the // runner ends the steps that waited for them could not run, loud. func (b *Builder) keptPins(ctx context.Context, key string) map[string]string { diff --git a/modules/mesh-delivery-builder/internal/build/step_test.go b/modules/mesh-delivery-builder/internal/build/step_test.go index 69abfe82d..fcea5e219 100644 --- a/modules/mesh-delivery-builder/internal/build/step_test.go +++ b/modules/mesh-delivery-builder/internal/build/step_test.go @@ -13,6 +13,7 @@ import ( "time" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" @@ -124,15 +125,19 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T) for _, c := range []struct { name, version string reserve, released, unreadable bool - takenOver bool + takenOver, superseded bool want, said string }{ - {"no version reserved", "0.1", false, false, false, false, meshbuilds.StepEndedOutcomeFailed, "built at " + fp1 + ", but no version is reserved for it"}, - {"H-A-244: its series was taken over by a newer fingerprint", "0.1", false, false, false, true, meshbuilds.StepEndedOutcomeFailed, "m: built at " + fp1 + " but its series moved to " + fp2 + " 0.1.7: stale"}, - {"a version reserved", "0.1", true, false, false, false, meshbuilds.StepEndedOutcomePassed, ""}, - {"a released build whose reservation is gone", "0.1", false, true, false, false, meshbuilds.StepEndedOutcomePassed, ""}, - {"the plan cannot be read", "0.1", false, false, true, false, meshbuilds.StepEndedOutcomeCouldNotRun, "plan cannot be read"}, - {"a series of before G", "1", false, false, false, false, meshbuilds.StepEndedOutcomePassed, ""}, + {"no version reserved", "0.1", false, false, false, false, false, meshbuilds.StepEndedOutcomeFailed, "built at " + fp1 + ", but no version is reserved for it"}, + {"H-A-244: its series was taken over by a newer fingerprint", "0.1", false, false, false, true, false, meshbuilds.StepEndedOutcomeFailed, "m: built at " + fp1 + " but its series moved to " + fp2 + " 0.1.7: stale"}, + // H-A-508: a done build a newer entry of its branch superseded is judged against that entry first, its takeover lost + // with the release that deleted it: superseded, naming the newer fingerprint, never "no version is reserved". + {"H-A-508: a done build a newer entry superseded", "0.1", false, false, false, false, true, meshbuilds.StepEndedOutcomeSuperseded, "m at " + fp1 + " is superseded by " + fp2}, + {"H-A-508: a done build a newer entry superseded, though a version is reserved", "0.1", true, false, false, false, true, meshbuilds.StepEndedOutcomeSuperseded, "m at " + fp1 + " is superseded by " + fp2}, + {"a version reserved", "0.1", true, false, false, false, false, meshbuilds.StepEndedOutcomePassed, ""}, + {"a released build whose reservation is gone", "0.1", false, true, false, false, false, meshbuilds.StepEndedOutcomePassed, ""}, + {"the plan cannot be read", "0.1", false, false, true, false, false, meshbuilds.StepEndedOutcomeCouldNotRun, "plan cannot be read"}, + {"a series of before G", "1", false, false, false, false, false, meshbuilds.StepEndedOutcomePassed, ""}, } { t.Run(c.name, func(t *testing.T) { r := newRig(t, goBundle) @@ -144,6 +149,15 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T) if v := r.consider(t, "modules/m"); v.State != builds.BuildDone { // built while the builder reserved nothing, as the live key was t.Fatalf("build = %+v, want done", v) } + if c.superseded { // a newer entry of the branch heard after the build + 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) + r.b.Wait() + } r.b.Reserved = res if c.reserve { res.sources = append(res.sources, versions.Source{Fingerprint: fp1}) @@ -476,8 +490,8 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) { if len(res.sources) != 1 || res.sources[0].Revision != 45 || res.sources[0].CatalogRevision != 47 { t.Errorf("reserved from %+v; want one version reserved from source revision 45 at catalog revision 47 (H-A-218)", res.sources) } - // H-A-489: once the picture heard the newer entry of m on the first branch, the older ask is refused superseded and - // nothing is built or reserved for it; the newer entry's build keeps the series. + // H-A-489, H-A-508: once the picture heard the newer entry of m on the first branch, the older ask ends superseded (never + // failed) and nothing is built or reserved for it; the newer entry's build keeps the series. rn, resn, entryn := revisionRig(t, &held, make(chan struct{}, 1)) rn.b.RevisionWait = time.Nanosecond rn.b.FirstBranch = r.b.FirstBranch @@ -487,8 +501,8 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) { entryn.Fp = fp2 rn.b.Entry(context.Background(), Origin{Branch: "main", Source: 46, First: true}, entryn) rn.b.Wait() - if endn := rn.b.BuildStep(t.Context(), "a1", run); endn.Outcome != meshbuilds.StepEndedOutcomeFailed || !strings.Contains(endn.Said, "superseded by "+fp2) { - t.Errorf("the older ask after the newer entry: end = %+v; want failed, superseded by %s", endn, fp2) + 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) } rn.b.Wait() if _, built := rn.st.vals[rn.key]; built || len(resn.sources) != 1 || resn.sources[0].Fingerprint != fp2 { diff --git a/modules/mesh-delivery-builder/internal/versions/reserve.go b/modules/mesh-delivery-builder/internal/versions/reserve.go index c80cbbe21..3af61c2dc 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve.go @@ -424,6 +424,9 @@ type ReleasedBuild struct { Version string `json:"version"` // Digests are the published digest of each artifact, by reference (H-A-331); absent for a release kept before. Digests map[string]string `json:"digests,omitempty"` + // Withdrawn are the fingerprints whose numbers the released version took over, by the number withdrawn (H-A-226), so a + // takeover still answers once the release deleted the series key (H-A-508); absent for a release that took none over. + Withdrawn map[string]string `json:"withdrawn,omitempty"` } // ReleasedFor says whether the builder saw a version released for the build of fingerprint among the module's last releases. @@ -494,7 +497,7 @@ func (r *Reserver) PublishedOf(ctx context.Context, module, artifact, fingerprin } // keepRelease adds a release to the module's record, dropping the oldest past ReleasedKept. -func (r *Reserver) keepRelease(ctx context.Context, module, fingerprint, version string, digests map[string]string) error { +func (r *Reserver) keepRelease(ctx context.Context, module, fingerprint, version string, digests, withdrawn map[string]string) error { n := r.ReleasedKept if n < 1 { n = DefaultReleasedKept @@ -514,7 +517,7 @@ func (r *Reserver) keepRelease(ctx context.Context, module, fingerprint, version kept = append(kept, k) } } - kept = append(kept, ReleasedBuild{Fingerprint: fingerprint, Version: version, Digests: digests}) + kept = append(kept, ReleasedBuild{Fingerprint: fingerprint, Version: version, Digests: digests, Withdrawn: maps.Clone(withdrawn)}) if len(kept) > n { kept = kept[len(kept)-n:] } @@ -553,7 +556,7 @@ func (r *Reserver) Released(ctx context.Context, module, version string) ([]stri continue } if cur.Version == version && cur.Fingerprint != "" && r.Releases != nil { - if err := r.keepRelease(ctx, module, cur.Fingerprint, version, cur.Artifacts); err != nil { + if err := r.keepRelease(ctx, module, cur.Fingerprint, version, cur.Artifacts, cur.Withdrawn); err != nil { return gone, fmt.Errorf("the release of %s %s cannot be recorded: %w", module, version, err) } } @@ -625,7 +628,9 @@ func (r *Reserver) All(ctx context.Context) ([]ReservedVersion, error) { } // TakenOver is the reservation of module's series whose withdrawn numbers hold one of the build of fingerprint (design 47 H -// H-A-226), and whether there is one: the series moved to that reservation's fingerprint and version (H-A-244). +// H-A-226), and whether there is one: the series moved to that reservation's fingerprint and version (H-A-244). Once that +// version is released and its series key deleted, the release record answers it, naming the fingerprints it withdrew +// (H-A-508): the newest such release, as a reservation of its fingerprint and version. func (r *Reserver) TakenOver(ctx context.Context, module, fingerprint string) (ReservedVersion, bool, error) { all, err := r.All(ctx) if err != nil { @@ -641,6 +646,29 @@ func (r *Reserver) TakenOver(ctx context.Context, module, fingerprint string) (R } } } + if r.Releases == nil { + return ReservedVersion{}, false, nil + } + raw, _, found, err := r.Releases.Get(ctx, ReleasedKey(module)) + if err != nil || !found { + return ReservedVersion{}, false, err + } + var rec ReleasedRecord + if json.Unmarshal(raw, &rec) != nil { + return ReservedVersion{}, false, nil + } + for i := len(rec.Kept) - 1; i >= 0; i-- { + k := rec.Kept[i] + if k.Fingerprint == fingerprint { + continue + } + for _, fp := range k.Withdrawn { + if fp == fingerprint { + series, _, _ := SplitVersion(k.Version) + return ReservedVersion{V: 1, Module: module, Series: series, Version: k.Version, Fingerprint: k.Fingerprint}, true, nil + } + } + } return ReservedVersion{}, false, nil } diff --git a/modules/mesh-delivery-builder/internal/versions/reserve_test.go b/modules/mesh-delivery-builder/internal/versions/reserve_test.go index e19e53251..e8908d254 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve_test.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve_test.go @@ -326,7 +326,7 @@ func TestTheWithdrawnVersionsAreDroppedOnceReleasedPast(t *testing.T) { ctx := context.Background() store := &reserveMem{mem: newMem()} highest := "0.1.3" - r := &Reserver{Store: store, Filled: func() bool { return true }, + r := &Reserver{Store: store, Releases: &reserveMem{mem: newMem()}, Filled: func() bool { return true }, ReleasedOf: func(context.Context, string) ([]string, error) { return []string{highest}, nil }} for _, fp := range []string{"src2:a", "src2:b", "src2:c"} { if _, err := r.Reserve(ctx, "m", "0.1", []string{"m:a"}, Source{Fingerprint: fp}); err != nil { @@ -349,6 +349,20 @@ func TestTheWithdrawnVersionsAreDroppedOnceReleasedPast(t *testing.T) { if err != nil || got.Version != "0.1.7" || len(got.Withdrawn) != 1 || got.Withdrawn["0.1.6"] != "src2:c" { t.Errorf("reserved %+v (%v); want 0.1.7 keeping only 0.1.6 withdrawn", got, err) } + // H-A-508: the release of the version that took over deletes the series key; the release record still names the + // fingerprint it withdrew, so the stale build finds the series moved, never "no version is reserved". + if _, err := r.Released(ctx, "m", "0.1.7"); err != nil { + t.Fatal(err) + } + if _, _, found, _ := r.get(ctx, ReservedKey("m", "0.1")); found { + t.Fatal("the released series key stands") + } + if by, took, err := r.TakenOver(ctx, "m", "src2:c"); err != nil || !took || by.Fingerprint != "src2:d" || by.Version != "0.1.7" { + t.Errorf("after the release taken over from src2:c by %+v (%v, %v); want src2:d 0.1.7", by, took, err) + } + if _, took, err := r.TakenOver(ctx, "m", "src2:d"); err != nil || took { + t.Errorf("the released build src2:d is said taken over (%v, %v)", took, err) + } } // TestARebuildReservesAboveTheCatalogsHighestWhateverItsStandingNumberWas: design 47 G A-490b as H-A-225 amends it — a build again -- 2.54.0 From 367df6caddbf5fa11ee25082d5823fce7a4f50e5 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 00:14:36 +0100 Subject: [PATCH 3/6] runner: a build ended superseded moves its mover out, never a failure A build step the builder ends superseded is taken as the mover moved to the newer revision's pipeline, by the path a newer pipeline taking a mover already has: its other open steps end superseded, the mover is kept in the pipeline's superseded, and the pipeline is judged by its other movers. Any other seat's end naming superseded stays refused as an outcome the runner does not know. Builds: design 47 H2 H-A-508 (and its addendum) --- .../internal/pipeline/endopen_test.go | 19 ++++++ .../internal/pipeline/steps.go | 60 ++++++++++++++++++- 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go index bc55b7643..4806bceb8 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go @@ -53,6 +53,25 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { h.SupersedeRunning(seat.Pipeline{Pipeline: "main.120", Branch: "main", Revision: 120, Movers: []seat.Mover{ {Module: "a", Commit: "c2", Fingerprint: "src2:a2"}, {Module: "b", Commit: "c2", Fingerprint: "src2:b2"}, {Module: "c", Commit: "c2", Fingerprint: "src2:c2"}}}) }, seat.PipelineOutcomeSuperseded}, + // H-A-508: a build the builder ended superseded moves its mover out as a newer pipeline taking it does: its other open + // steps end superseded, it is kept in superseded, and the pipeline passes by its other movers, never failed. + {"its last open step, a build, ends superseded (H-A-508)", + []seat.StepResult{step("a", seat.StepResultOutcomeRunning, "x1"), {Module: "a", Artifact: "program", Step: seat.StepResultStepUnit, + Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomeWaiting, Seat: "node-build-go"}, + step("b", seat.StepResultOutcomePassed, "x2"), step("c", seat.StepResultOutcomePassed, "x3")}, + func(t *testing.T, h *Hearer) { + 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"} + if _, err := h.OnStepEnded(bs, bs.Prefix+"n1", end); err != nil { + t.Fatal(err) + } + p, _, _ := h.Store.Get("main.117") + if !slices.Equal(p.Superseded, []string{"a"}) || p.Steps[0].Outcome != seat.StepResultOutcomeSuperseded || !strings.Contains(p.Steps[0].Why, "src2:a2") || + p.Steps[1].Outcome != seat.StepResultOutcomeSuperseded { + t.Errorf("after a's build ended superseded: superseded %v, steps %+v; want a left, its build and unit superseded naming src2:a2", p.Superseded, p.Steps[:2]) + } + }, seat.PipelineOutcomePassed}, {"its last open step ends could not run on the silent bound (H-A-243)", []seat.StepResult{step("a", seat.StepResultOutcomeRunning, "mwql5pio3390aa"), step("b", seat.StepResultOutcomePassed, "x2"), step("c", seat.StepResultOutcomePassed, "x3")}, func(t *testing.T, h *Hearer) { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go index 0c26785f7..b0cba09ac 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go @@ -298,7 +298,7 @@ func (h *Hearer) OnStepEndedPinned(bs StepSeat, subject string, ev StepEnded, sh h.logf("the step-ended of ask %s is ignored: its test run %s ended before it (%s)", ev.ID, run, p.Steps[i].Why) } return p, nil - case !endOutcome(ev.Outcome): + case !endOutcome(ev.Outcome) && !supersededBuild(p.Steps[i], ev.Outcome): return p, fmt.Errorf("%w: ask %s ended %q, not an outcome of step-ended", ErrRefused, ev.ID, ev.Outcome) } now := h.now() @@ -344,6 +344,26 @@ func (h *Hearer) OnStepEndedPinned(bs StepSeat, subject string, ev StepEnded, sh readers = append(readers, endPinHeld(&p, *s, pins, now)...) askHeld = stepPassed(*s) && heldOn(p, s.Module) } + // A build ended superseded moves its mover to the newer revision's pipeline, as a newer pipeline taking it does + // (H-A-508, H-A-223): its other open steps end superseded, it is kept in the pipeline's superseded, and the pipeline + // is judged by its other movers alone; never a failure. + var leave, drop []seat.StepResult + left := s.Step == seat.StepResultStepBuild && s.Outcome == seat.StepResultOutcomeSuperseded + if left { + why := "superseded: its build was superseded and its mover left for the newer revision's pipeline (H-A-508): " + s.Why + for j := range p.Steps { + st := &p.Steps[j] + if j == i || st.Module != s.Module || (!open(*st) && st.Outcome != seat.StepResultOutcomeWaiting) { + continue + } + l, d := supersedeStep(&p, st, why, now) + leave, drop = append(leave, l...), append(drop, d...) + readers = append(readers, j) + } + if !slices.Contains(p.Superseded, s.Module) { + p.Superseded = append(p.Superseded, s.Module) + } + } if s.Step == seat.StepResultStepValidate { readers = append(readers, sameValidate(&p, i, now)...) var notAsked []int @@ -364,9 +384,14 @@ func (h *Hearer) OnStepEndedPinned(bs StepSeat, subject string, ev StepEnded, sh // A build that passes, a rerun's among them, places again the steps that ended not asked on it (H-A-406): its // dependents need no hand rerun. var again []string - if s.Step == seat.StepResultStepBuild && stepPassed(*s) { + if s.Step == seat.StepResultStepBuild && (stepPassed(*s) || left) { + // A mover that left is no dependency of the movers that stay (H-A-361): theirs ended not asked on it are placed again. + named := readerNames(p, readers) if again = takeOutNotAsked(&p, s.Module); len(again) > 0 { release = true + // The steps taken out shift the indexes: the step and its readers are found again by their names. + i = stepOfAsk(p, ev.ID) + s, readers = &p.Steps[i], readerIndexes(p, named) } } ended := h.endPipeline(&p, now, wr) @@ -393,6 +418,11 @@ func (h *Hearer) OnStepEndedPinned(bs StepSeat, subject string, ev StepEnded, sh } } h.Failures.StepEnded(h.Store, p, *s) + if left { + h.logf("%s: %s's build ended superseded, so it leaves for the newer revision's pipeline, %d of its other steps ended superseded (H-A-508): %s", + ev.Pipeline, s.Module, len(readers), s.Why) + h.leaveSteps(ev.Pipeline, leave, drop, "the mover %s left "+ev.Pipeline+" for the newer revision's pipeline", "superseded: its build was superseded (H-A-508)") + } if err := h.say(seat.EventStepEnded, p, s); err != nil { return p, fmt.Errorf("pipeline %s's %s is written but not said: %w", ev.Pipeline, seat.EventStepEnded, err) } @@ -767,6 +797,32 @@ func phasesOf(p seat.Pipeline) *seat.PipelineEndedPhases { return ph } +// 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 { + return o == builds.StepEndedOutcomeSuperseded && st.Seat == builds.Seat && st.Step == seat.StepResultStepBuild +} + +// readerNames are the steps of p at the indexes readers, by module, artifact and step. +func readerNames(p seat.Pipeline, readers []int) []string { + out := make([]string, 0, len(readers)) + for _, j := range readers { + out = append(out, p.Steps[j].Module+"\x00"+p.Steps[j].Artifact+"\x00"+p.Steps[j].Step) + } + return out +} + +// readerIndexes are the indexes in p of the steps named, as readerNames names them. +func readerIndexes(p seat.Pipeline, names []string) []int { + var out []int + for j, st := range p.Steps { + if slices.Contains(names, st.Module+"\x00"+st.Artifact+"\x00"+st.Step) { + out = append(out, j) + } + } + return out +} + func endOutcome(o string) bool { switch o { case nodebuildgo.StepEndedOutcomePassed, nodebuildgo.StepEndedOutcomeFailed, nodebuildgo.StepEndedOutcomeNothingToRun, -- 2.54.0 From 1a19c5c4c1b783088fe249df1d04e4abffb62a27 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 00:25:04 +0100 Subject: [PATCH 4/6] builder: judge the newest entry first for a build ended now too Review round 1: a build a newer entry withdrew while it ran still ended the step failed, and passedWithItsVersion judged supersession only after the takeover and only when no version was held. Both now judge the branch's newest entry first and end the step superseded; a release record that cannot be read answers its error, never "not taken over". Builds: design 47 H2 H-A-508 (and its addendum) --- .../internal/build/step.go | 20 +++++--- .../internal/build/step_test.go | 47 +++++++++++++++++++ .../internal/versions/reserve.go | 5 +- .../internal/versions/reserve_test.go | 7 +++ 4 files changed, 70 insertions(+), 9 deletions(-) diff --git a/modules/mesh-delivery-builder/internal/build/step.go b/modules/mesh-delivery-builder/internal/build/step.go index 55c99d80b..25e57df5f 100644 --- a/modules/mesh-delivery-builder/internal/build/step.go +++ b/modules/mesh-delivery-builder/internal/build/step.go @@ -165,6 +165,11 @@ func (b *Builder) buildEntry(ctx context.Context, pipeline string, e meshbuilds. b.consider(ctx, entry.Module, m) select { case log := <-ended: + // A fingerprint a newer entry superseded while it built (its build withdrawn, or done) ends superseded, judged before + // the log's outcome (H-A-508). + if newer := b.supersededBy(entry.Module, key, entry.Fp); newer != "" { + return answered(meshbuilds.StepEndedOutcomeSuperseded, stepSuperseded(entry.Module, entry.Fp, newer), "built now") + } if log.Outcome == builds.BuildDone { *pins = b.keptPins(ctx, key) outcome, said := b.passedWithItsVersion(ctx, entry) @@ -182,13 +187,18 @@ func (b *Builder) buildEntry(ctx context.Context, pipeline string, e meshbuilds. // that can never be released, and one whose series another fingerprint took over fails saying it is stale, naming that // fingerprint and its version (design 47 H H-A-244). A build that reserves none (a candidate's, a series of before G) passes as it did. func (b *Builder) passedWithItsVersion(ctx context.Context, entry meshcatalog.CatalogEntry) (outcome, said string) { - if b.Reserved == nil { - return meshbuilds.StepEndedOutcomePassed, "" - } key, err := builds.BuilderBuildKey(entry.Module, entry.Fp) if err != nil { return meshbuilds.StepEndedOutcomeCouldNotRun, err.Error() } + // The fingerprint is judged against its branch's newest entry first (H-A-508): a superseded one ends superseded, whatever + // its reservation, release or takeover says. + if newer := b.supersededBy(entry.Module, key, entry.Fp); newer != "" { + return meshbuilds.StepEndedOutcomeSuperseded, stepSuperseded(entry.Module, entry.Fp, newer) + } + if b.Reserved == nil { + return meshbuilds.StepEndedOutcomePassed, "" + } b.mu.Lock() reserving := b.trunkFP[key] && b.origin[key].First b.mu.Unlock() @@ -218,10 +228,6 @@ func (b *Builder) passedWithItsVersion(ctx context.Context, entry meshcatalog.Ca // H-A-244 (2): the series was taken over by a newer fingerprint, whose number it carries now: the build is stale. return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s: built at %s but its series moved to %s %s: stale", entry.Module, entry.Fp, by.Fingerprint, by.Version) } - if newer := b.supersededBy(entry.Module, key, entry.Fp); newer != "" { - // Superseded while it built: those words are said only for a current fingerprint (H-A-508). - return meshbuilds.StepEndedOutcomeSuperseded, stepSuperseded(entry.Module, entry.Fp, newer) - } return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s: built at %s, but no version is reserved for it; builder_reserve_done reserves one for the done build", entry.Module, entry.Fp) } return meshbuilds.StepEndedOutcomePassed, "" diff --git a/modules/mesh-delivery-builder/internal/build/step_test.go b/modules/mesh-delivery-builder/internal/build/step_test.go index fcea5e219..543186bbb 100644 --- a/modules/mesh-delivery-builder/internal/build/step_test.go +++ b/modules/mesh-delivery-builder/internal/build/step_test.go @@ -134,6 +134,7 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T) // with the release that deleted it: superseded, naming the newer fingerprint, never "no version is reserved". {"H-A-508: a done build a newer entry superseded", "0.1", false, false, false, false, true, meshbuilds.StepEndedOutcomeSuperseded, "m at " + fp1 + " is superseded by " + fp2}, {"H-A-508: a done build a newer entry superseded, though a version is reserved", "0.1", true, false, false, false, true, meshbuilds.StepEndedOutcomeSuperseded, "m at " + fp1 + " is superseded by " + fp2}, + {"H-A-508: a done build a newer entry superseded, its series taken over", "0.1", false, false, false, true, true, meshbuilds.StepEndedOutcomeSuperseded, "m at " + fp1 + " is superseded by " + fp2}, {"a version reserved", "0.1", true, false, false, false, false, meshbuilds.StepEndedOutcomePassed, ""}, {"a released build whose reservation is gone", "0.1", false, true, false, false, false, meshbuilds.StepEndedOutcomePassed, ""}, {"the plan cannot be read", "0.1", false, false, true, false, false, meshbuilds.StepEndedOutcomeCouldNotRun, "plan cannot be read"}, @@ -169,8 +170,16 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T) if end.Outcome != c.want || !strings.Contains(end.Said, c.said) || (c.want == meshbuilds.StepEndedOutcomeFailed && strings.Contains(end.Said, "builder_reserve_done") == c.takenOver) { t.Errorf("end = %+v, want %s saying %q", end, c.want, c.said) } + // The verdict of a build that ended done, as a build ended now is judged, says the same (H-A-508: the newest entry first). + if c.superseded { + entry, _ := r.b.StepEntry(t.Context(), fp1) + if outcome, said := r.b.passedWithItsVersion(t.Context(), entry); outcome != c.want || !strings.Contains(said, c.said) { + t.Errorf("built now: %s %q, want %s saying %q", outcome, said, c.want, c.said) + } + } }) } + 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-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) @@ -582,3 +591,41 @@ func digestOf(unreadable bool) string { } return mdigest('a') } + +// H-A-508 (review round 1): a newer entry of the branch heard while the step's build runs ends the step superseded, naming the +// newer fingerprint, whatever the build's end (done, or withdrawn as superseded), never failed nor passed. +func aNewerEntryWhileTheBuildRunsSupersedesTheStep(t *testing.T) { + r := newRig(t, goBundle) + r.b.StepEntry = func(context.Context, string) (meshcatalog.CatalogEntry, error) { + return meshcatalog.CatalogEntry{Module: "m", Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20", Fp: fp1, ManifestDigest: mdigest('a'), Path: "modules/m"}, nil + } + r.bm.hold, r.bm.entered = make(chan struct{}), make(chan struct{}, 8) + ended := make(chan meshbuilds.StepEnded, 1) + go func() { + ended <- r.b.BuildStep(t.Context(), "a1", meshbuilds.StepRun{Pipeline: "main.1.m", Step: meshbuilds.StepRunStepBuild, Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}}) + }() + select { + case <-r.bm.entered: // fp1's build is under way + case end := <-ended: + t.Fatalf("the step ended before its build ran: %+v", end) + case <-time.After(5 * time.Second): + t.Fatal("the step's build never started") + } + 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) + close(r.bm.hold) + var end meshbuilds.StepEnded + select { + case end = <-ended: + case <-time.After(5 * time.Second): + t.Fatal("the step never ended") + } + r.b.Wait() + if end.Outcome != meshbuilds.StepEndedOutcomeSuperseded || !strings.Contains(end.Said, "m at "+fp1+" is superseded by "+fp2) { + t.Errorf("end = %+v, want superseded by %s", end, fp2) + } +} diff --git a/modules/mesh-delivery-builder/internal/versions/reserve.go b/modules/mesh-delivery-builder/internal/versions/reserve.go index 3af61c2dc..66386dfa6 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve.go @@ -654,8 +654,9 @@ func (r *Reserver) TakenOver(ctx context.Context, module, fingerprint string) (R return ReservedVersion{}, false, err } var rec ReleasedRecord - if json.Unmarshal(raw, &rec) != nil { - return ReservedVersion{}, false, nil + if err := json.Unmarshal(raw, &rec); err != nil { + // A record that cannot be read answers no "not taken over": the caller says it cannot judge (H-A-508). + return ReservedVersion{}, false, fmt.Errorf("the release record of %s cannot be read: %w", module, err) } for i := len(rec.Kept) - 1; i >= 0; i-- { k := rec.Kept[i] diff --git a/modules/mesh-delivery-builder/internal/versions/reserve_test.go b/modules/mesh-delivery-builder/internal/versions/reserve_test.go index e8908d254..51a093ee0 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve_test.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve_test.go @@ -363,6 +363,13 @@ func TestTheWithdrawnVersionsAreDroppedOnceReleasedPast(t *testing.T) { if _, took, err := r.TakenOver(ctx, "m", "src2:d"); err != nil || took { t.Errorf("the released build src2:d is said taken over (%v, %v)", took, err) } + // A release record that cannot be read answers its error, never "not taken over". + if _, err := r.Releases.Create(ctx, ReleasedKey("n"), []byte("{not json")); err != nil { + t.Fatal(err) + } + if _, took, err := r.TakenOver(ctx, "n", "src2:x"); err == nil || took { + t.Errorf("an unreadable release record answered taken over %v, %v; want its error", took, err) + } } // TestARebuildReservesAboveTheCatalogsHighestWhateverItsStandingNumberWas: design 47 G A-490b as H-A-225 amends it — a build again -- 2.54.0 From a2b916a896848d4710d771fd07a8ef68851bc49d Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 00:25:53 +0100 Subject: [PATCH 5/6] runner: test the refusal of superseded from another seat and a dependent that stays Review round 1: a node-build-go end naming superseded is refused as an outcome the runner does not know, moving nothing; a dependent whose steps ended not asked on a mover whose build ended superseded is taken out and placed again. Builds: design 47 H2 H-A-508 (and its addendum) --- .../internal/pipeline/endopen_test.go | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go index 4806bceb8..3694f842c 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go @@ -1,6 +1,7 @@ package pipeline import ( + "errors" "fmt" "slices" "strings" @@ -58,8 +59,20 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { {"its last open step, a build, ends superseded (H-A-508)", []seat.StepResult{step("a", seat.StepResultOutcomeRunning, "x1"), {Module: "a", Artifact: "program", Step: seat.StepResultStepUnit, Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomeWaiting, Seat: "node-build-go"}, + {Module: "a", Artifact: "program", Step: seat.StepResultStepLint, Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomeRunning, + Ask: "l1", Seat: "node-build-go"}, step("b", seat.StepResultOutcomePassed, "x2"), step("c", seat.StepResultOutcomePassed, "x3")}, func(t *testing.T, h *Hearer) { + // Another seat's end naming superseded is an outcome the runner does not know: refused, loud, nothing taken. + gs := stepSeatOf(t, "node-build-go") + lint := StepEnded{ID: "l1", Node: "n1", Pipeline: "main.117", Module: "a", Commit: "c1", Fingerprint: "src2:a1", Step: "lint", + Outcome: builds.StepEndedOutcomeSuperseded} + if _, err := h.OnStepEnded(gs, gs.Prefix+"n1", lint); !errors.Is(err, ErrRefused) || !strings.Contains(err.Error(), "not an outcome of step-ended") { + t.Errorf("a node-build-go end naming superseded: %v, want refused as no outcome of step-ended", err) + } + 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]) + } 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"} @@ -68,8 +81,8 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { } p, _, _ := h.Store.Get("main.117") if !slices.Equal(p.Superseded, []string{"a"}) || p.Steps[0].Outcome != seat.StepResultOutcomeSuperseded || !strings.Contains(p.Steps[0].Why, "src2:a2") || - p.Steps[1].Outcome != seat.StepResultOutcomeSuperseded { - t.Errorf("after a's build ended superseded: superseded %v, steps %+v; want a left, its build and unit superseded naming src2:a2", p.Superseded, p.Steps[:2]) + p.Steps[1].Outcome != seat.StepResultOutcomeSuperseded || p.Steps[2].Outcome != seat.StepResultOutcomeSuperseded { + t.Errorf("after a's build ended superseded: superseded %v, steps %+v; want a left, its build and unit superseded naming src2:a2", p.Superseded, p.Steps[:3]) } }, seat.PipelineOutcomePassed}, {"its last open step ends could not run on the silent bound (H-A-243)", @@ -145,4 +158,25 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { } }) } + // H-A-508, H-A-361: a dependent that stays, whose steps ended not asked on the mover whose build ended superseded, is + // taken out and placed again; the pipeline does not end on it, and the superseded build's end is said as its own step's. + t.Run("a dependent that stays is placed again when its dependency's build ends superseded", 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("b", seat.StepResultOutcomeNotAsked, ""), step("a", seat.StepResultOutcomeRunning, "x1")}}, rev: 1}} + e := store["main.117"] + 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) }} + 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"}) + if err != nil { + t.Fatal(err) + } + if got.Outcome != seat.PipelineOutcomeRunning || !slices.Equal(got.Superseded, []string{"a"}) || len(got.Steps) != 1 || got.Steps[0].Module != "a" || + got.Steps[0].Outcome != seat.StepResultOutcomeSuperseded || !slices.Equal(released, []string{"main.117"}) { + 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) + } + }) } -- 2.54.0 From a5a7afdfa430cbff945ee539ef418708bdb8fce9 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 00:33:45 +0100 Subject: [PATCH 6/6] builder: hold the after-the-wait superseded judgement with a withdrawn build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review round 2: the subtest's build ended done, so the check after the wait was not held. The build in flight is now withdrawn by the newer entry (the key ends "withdrawn: … superseded by …", main.327's gate build), and the step still ends superseded; without the check it ends failed. Builds: design 47 H2 H-A-508 (and its addendum) --- .../internal/build/step_test.go | 48 ++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/modules/mesh-delivery-builder/internal/build/step_test.go b/modules/mesh-delivery-builder/internal/build/step_test.go index 543186bbb..81d9b5edb 100644 --- a/modules/mesh-delivery-builder/internal/build/step_test.go +++ b/modules/mesh-delivery-builder/internal/build/step_test.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "reflect" + "runtime" "slices" "strings" "sync" @@ -12,6 +13,7 @@ import ( "testing" "time" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" @@ -592,32 +594,53 @@ func digestOf(unreadable bool) string { return mdigest('a') } -// H-A-508 (review round 1): a newer entry of the branch heard while the step's build runs ends the step superseded, naming the -// newer fingerprint, whatever the build's end (done, or withdrawn as superseded), never failed nor passed. +// H-A-508 (review rounds 1, 2): a newer entry of the branch heard while the step's build runs withdraws that build (the key +// ends "withdrawn: … superseded by …", as main.327's mesh-delivery-gate build did); the step waiting on it ends superseded, +// naming the newer fingerprint, judged before the build's failed end, never failed. func aNewerEntryWhileTheBuildRunsSupersedesTheStep(t *testing.T) { r := newRig(t, goBundle) + var asked int32 + running := make(chan struct{}) + r.asks.Answer = func(a buildstep.StepAsk) buildstep.Step { + if atomic.AddInt32(&asked, 1) == 1 { // fp1's ask runs until it is withdrawn + defer close(running) + return buildstep.Step{ID: a.ID, Node: "ace", State: buildstep.StepRunning, Started: time.Now()} + } + return r.answer(a) + } + r.b.Asks = buildrun.Asker{Seats: testSeats(), Publisher: r.asks, Waiter: r.asks, Bound: 2 * time.Second, Dropper: &seatDrops{}} r.b.StepEntry = func(context.Context, string) (meshcatalog.CatalogEntry, error) { return meshcatalog.CatalogEntry{Module: "m", Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20", Fp: fp1, ManifestDigest: mdigest('a'), Path: "modules/m"}, nil } - r.bm.hold, r.bm.entered = make(chan struct{}), make(chan struct{}, 8) + r.b.Module(t.Context(), "m", moduleValue(t, "modules/m")) // fp1, the newest entry heard, is built + <-running ended := make(chan meshbuilds.StepEnded, 1) go func() { ended <- r.b.BuildStep(t.Context(), "a1", meshbuilds.StepRun{Pipeline: "main.1.m", Step: meshbuilds.StepRunStepBuild, Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}}) }() - select { - case <-r.bm.entered: // fp1's build is under way - case end := <-ended: - t.Fatalf("the step ended before its build ran: %+v", end) - case <-time.After(5 * time.Second): - t.Fatal("the step's build never started") + // The step waits on the end of fp1's build in flight before the newer entry is heard. + for deadline := time.Now().Add(5 * time.Second); ; runtime.Gosched() { + r.b.mu.Lock() + n := len(r.b.stepWaits[r.key]) + r.b.mu.Unlock() + if n > 0 { + break + } + select { + case end := <-ended: + t.Fatalf("the step ended before it waited on the build in flight: %+v", end) + default: + } + if time.Now().After(deadline) { + t.Fatal("the step never waited on the build in flight") + } } newer, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20", - Fp2: fp2, Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(agreedToolchains)}) + Fp: "src1:" + hex64('f'), Fp2: fp2, Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(agreedToolchains)}) if err != nil { t.Fatal(err) } r.b.Module(t.Context(), "m", newer) - close(r.bm.hold) var end meshbuilds.StepEnded select { case end = <-ended: @@ -625,6 +648,9 @@ func aNewerEntryWhileTheBuildRunsSupersedesTheStep(t *testing.T) { t.Fatal("the step never ended") } r.b.Wait() + if v := valueOf(t, r.st, r.key); v.State != builds.BuildFailed || !strings.HasPrefix(v.Error, withdrawnPrefix) || !strings.Contains(v.Error, "superseded by the fingerprint "+fp2) { + t.Fatalf("fp1's key = %+v, want its build withdrawn, superseded by %s", v, fp2) + } if end.Outcome != meshbuilds.StepEndedOutcomeSuperseded || !strings.Contains(end.Said, "m at "+fp1+" is superseded by "+fp2) { t.Errorf("end = %+v, want superseded by %s", end, fp2) } -- 2.54.0