From 014f7b7c2f39ee72d639f3a9e8f766685f626ae1 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 23:03:45 +0100 Subject: [PATCH] Reserve the version of an ask admitted by its kept revision (H-A-205) An ask of an older kept revision was admitted, but after a builder restart its fingerprint had never been heard on the branch, so its build neither reserved a version nor was checked against one and passed silently. Each asked fingerprint is now recorded as the branch's (its source revision, and first as the module's registration says), without moving what the picture heard, so the newer fingerprint's build is not superseded. Builds: design 47 H H-A-205, H-A-155 --- .../cmd/mesh-delivery-builder/main.go | 1 + .../internal/build/revisionwait.go | 13 +++++++++++++ .../mesh-delivery-builder/internal/build/run.go | 4 ++++ .../internal/build/step_test.go | 15 +++++++++++---- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index 0faf4eaf..60097089 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -471,6 +471,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro b.Picture = half.picture // An ask of a revision below the newest the picture holds is read by number from the catalog seat (H-A-205). b.KeptRevision = keptRevisionVia(calls.Call) + b.FirstBranch = half.first branches.Held = func(string, meshcatalog.CatalogRevision) { b.PictureHeld() } // a revision held wakes a step ask's wait (H-A-162) half.ready = func() { if err := b.Sweep(ctx, half.pictured()...); err != nil { diff --git a/modules/mesh-delivery-builder/internal/build/revisionwait.go b/modules/mesh-delivery-builder/internal/build/revisionwait.go index 2ae3c745..274ec20c 100644 --- a/modules/mesh-delivery-builder/internal/build/revisionwait.go +++ b/modules/mesh-delivery-builder/internal/build/revisionwait.go @@ -93,6 +93,19 @@ func (b *Builder) keptRevisionHolds(ctx context.Context, run meshbuilds.StepRun, return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s, and the catalog's revision %d names %s at %q, not %s", below, run.Revision, e.Module, fps[e.Module], e.Fingerprint) } } + // Each asked fingerprint is recorded as the branch's, so its build reserves its version (H-A-155) as one the picture + // took in does; what the picture heard stays as it is, so the newer fingerprint's build is not superseded. + b.mu.Lock() + for _, e := range run.Entries { + key, err := builds.BuilderBuildKey(e.Module, e.Fingerprint) + if err != nil || b.origin[key].Branch != "" { + continue + } + first := b.FirstBranch == nil || b.FirstBranch(run.Branch, e.Module) + b.trunkFP[key] = true + b.origin[key] = Origin{Branch: run.Branch, Source: run.Source, First: first} + } + b.mu.Unlock() b.logf("%s: %s; the catalog keeps revision %d with its entries: the build goes on", run.Pipeline, below, run.Revision) return "", "" } diff --git a/modules/mesh-delivery-builder/internal/build/run.go b/modules/mesh-delivery-builder/internal/build/run.go index 4bfb6df4..b87cfd1a 100644 --- a/modules/mesh-delivery-builder/internal/build/run.go +++ b/modules/mesh-delivery-builder/internal/build/run.go @@ -114,6 +114,10 @@ type Builder struct { // H-A-205, H-A-147): the source revision it was taken in from and the fingerprint of each module it names. A step ask of // a source revision below the newest the picture holds is built when that kept revision names its entries. Nil reads none. KeptRevision func(ctx context.Context, branch string, revision int64) (source int64, fingerprints map[string]string, err error) + // FirstBranch says whether branch is the first watched branch of the module's registration, the one whose builds reserve + // a version (design 47 G ยง371): an ask admitted by its kept revision is recorded as that branch's (H-A-205, H-A-155). Nil + // takes every branch as the first, as an origin never heard is. + FirstBranch func(branch, module string) bool // RevisionWait bounds a step ask's wait for its revision, its setting revision-wait-minutes (H-A-156); DefaultRevisionWait // when 0. RevisionWait time.Duration diff --git a/modules/mesh-delivery-builder/internal/build/step_test.go b/modules/mesh-delivery-builder/internal/build/step_test.go index 2bf0847a..2a0e23dd 100644 --- a/modules/mesh-delivery-builder/internal/build/step_test.go +++ b/modules/mesh-delivery-builder/internal/build/step_test.go @@ -370,8 +370,9 @@ func aStepAskWaitsForItsRevision(t *testing.T) { func anOlderKeptRevisionIsReadByNumber(t *testing.T) { var held atomic.Int64 held.Store(46) - r, _, _ := revisionRig(t, &held, make(chan struct{}, 1)) - r.b.RevisionWait = time.Nanosecond // a wait would fail at once: the older revision is never waited for + r, res, _ := revisionRig(t, &held, make(chan struct{}, 1)) // a picture at 46 that never heard 45 (a restart) + r.b.RevisionWait = time.Nanosecond // a wait would fail at once: the older revision is never waited for + r.b.FirstBranch = func(branch, module string) bool { return branch == "main" && module == "m" } var read []string r.b.KeptRevision = func(_ context.Context, branch string, revision int64) (int64, map[string]string, error) { read = append(read, fmt.Sprintf("%s %d", branch, revision)) @@ -384,10 +385,16 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) { if end.Outcome != meshbuilds.StepEndedOutcomePassed || !slices.Equal(read, []string{"main 45"}) { t.Errorf("end = %+v, kept revisions read %v; want passed, revision 45 of main read once", end, read) } - r.b.KeptRevision = func(context.Context, string, int64) (int64, map[string]string, error) { + // Its fingerprint is recorded as the branch's: its build reserves its version from source revision 45 (H-A-155). + if len(res.sources) != 1 || res.sources[0].Revision != 45 { + t.Errorf("reserved from %+v; want one version reserved from revision 45", res.sources) + } + r2, _, _ := revisionRig(t, &held, make(chan struct{}, 1)) + r2.b.RevisionWait = time.Nanosecond + r2.b.KeptRevision = func(context.Context, string, int64) (int64, map[string]string, error) { return 45, map[string]string{"m": "src2:other"}, nil } - if end := r.b.BuildStep(t.Context(), run); end.Outcome != meshbuilds.StepEndedOutcomeFailed || !strings.Contains(end.Said, "names m at \"src2:other\"") { + if end := r2.b.BuildStep(t.Context(), run); end.Outcome != meshbuilds.StepEndedOutcomeFailed || !strings.Contains(end.Said, "names m at \"src2:other\"") { t.Errorf("end = %+v; want failed naming the fingerprint the kept revision names", end) } }