From e93575ffe73702431f06a3bc21186f45e6959573 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 20:13:15 +0100 Subject: [PATCH] mesh-delivery-indexer: the accepted series is the manifest's, contents or none The pin fell back to the path's newest publish while no series value held contents, which live none does, so a publish in a series a module does not accept pinned it. The series a module accepts is the one its manifest names, or the default; the pin is the newest version published for the package path within it. Builds: design 47 H H-A-185, H-A-184 --- .../internal/index/toolchains.go | 11 ++-- .../internal/index/toolchains_test.go | 16 +++++- .../internal/index/versions.go | 57 +++++++------------ 3 files changed, 38 insertions(+), 46 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index ca7cf416..c6a4a53a 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -218,8 +218,7 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc ix.logf("no fingerprint is written by this pass: %v", err) return fmt.Errorf("no fingerprint is written: %w", err) } - series := ix.SeriesAll(ctx) // each package's series, the newest a user accepting it takes (DLV-I6) - released := publishedOf(series) // each Go package's newest published version by its path, what it is pinned to (H-A-183) + series := ix.SeriesAll(ctx) // each package's series, the newest a user accepting it takes (DLV-I6) type result struct { fp, none string tcs map[string]meshcatalog.ToolchainUsed // by language, when there is a fingerprint @@ -291,7 +290,7 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc r.none = strings.Join(missing, "; ") case noToolchain != "": r.none = noToolchain - if fp, pkgs, ok := stillComputed(module, kept, k, toolchains, held, pub, pins, ix.sourceHeads(), released); ok { + if fp, pkgs, ok := stillComputed(module, kept, k, toolchains, held, pub, pins, ix.sourceHeads(), series); ok { r = result{fp: fp, tcs: k.held.Toolchains, pkgs: pkgs} } default: @@ -299,7 +298,7 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc r.fp, r.none = f.fp, f.none if r.fp != "" { // a pin is a released version, never a commit (H-A-161), and the version line's fingerprint takes it (H-A-167) - r.fp, r.pkgs = pinnedOf(f, released) + r.fp, r.pkgs = pinnedOf(f, series, k.manifest) r.tcs = toolchainsUsed(toolchains) } } @@ -498,7 +497,7 @@ func hasContext(m catalogue.Manifest) bool { // with the toolchains it was computed with in place of the languages agreed on none, give it again, in its form. Any // other input that moved (a merge, a base, an agreed toolchain, an imported package) gives another fingerprint, and the // module has none until they agree. -func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, k *known, agreed map[string]meshcatalogclient.Toolchain2, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string, released map[string]string) (string, sdkstep.PackageVersions, bool) { +func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, k *known, agreed map[string]meshcatalogclient.Toolchain2, held map[string]meshcatalog.ModulesByModuleValue, published map[string]meshcatalog.PackagesByModuleValue, pins sdkstep.PackageVersions, heads map[string]string, series map[string]SeriesPackage) (string, sdkstep.PackageVersions, bool) { if k.held.Fp2 == "" { return "", nil, false } @@ -518,7 +517,7 @@ func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, if f.none != "" || f.fp == "" { return "", nil, false } - fp, pkgs := pinnedOf(f, released) + fp, pkgs := pinnedOf(f, series, k.manifest) return fp, pkgs, fp == k.held.Fp2 } diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go index cc312061..561b544a 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go @@ -805,9 +805,8 @@ func TestAModuleKeepsTheToolchainsItsFingerprintWasComputedWith(t *testing.T) { t.Fatal("a release whose re-pin failed was acknowledged") } mods.keysErr = nil - // The registry published mesh-sdk's Go package at 0.1.18, not at the module's release number 0.1.20, and no series - // avahi accepts gives its contents yet (none read): the pin is the newest version published for the package's path - // (H-A-183, H-A-184). + // The registry published mesh-sdk's Go package at 0.1.18, not at the module's release number 0.1.20, in the series + // avahi accepts (the default 0.1), with no contents read: the pin is that version (H-A-183, H-A-185). ix.Packages = newMem() if _, err := ix.HearVersion(context.Background(), HeardVersion{Package: "mesh-sdk/go", Seat: "go-package-registry", Version: "0.1.18", Commit: strings.Repeat("1", 40), GoModule: sdk, Published: true}); err != nil { t.Fatal(err) @@ -818,6 +817,17 @@ func TestAModuleKeepsTheToolchainsItsFingerprintWasComputedWith(t *testing.T) { ix.Revisions = revisions if a, _ := moduleOf(t, mods, "avahi"); a.Fp2 == first.Fp2 || a.Fp2 == "" || !reflect.DeepEqual(a.Packages, map[string]string{sdk: "v0.1.18"}) { t.Fatalf("after mesh-sdk's release: fp2 %q (was %q) packages %v, want a new fingerprint pinned to v0.1.18", a.Fp2, first.Fp2, a.Packages) + } else { + // A 0.2.0 publish, of a series avahi does not accept, leaves it alone, contents or none (H-A-184, H-A-185). + if _, err := ix.HearVersion(context.Background(), HeardVersion{Package: "mesh-sdk/go", Seat: "go-package-registry", Version: "0.2.0", Commit: strings.Repeat("1", 40), GoModule: sdk, Published: true}); err != nil { + t.Fatal(err) + } + if _, err := ix.Repin(context.Background(), "mesh-sdk"); err != nil { // the pass for avahi alone: mesh-tools is held stale here + t.Fatal(err) + } + if b, _ := moduleOf(t, mods, "avahi"); b.Fp2 != a.Fp2 || b.Packages[sdk] != "v0.1.18" { + t.Fatalf("a publish of another series moved avahi: fp2 %q (was %q) packages %v", b.Fp2, a.Fp2, b.Packages) + } } if o, _ := moduleOf(t, mods, "mesh-tools"); o.Fp2 != tools.Fp2 { t.Errorf("a re-pin moved mesh-tools, which holds no package of mesh-sdk: %q (was %q)", o.Fp2, tools.Fp2) diff --git a/modules/mesh-delivery-indexer/internal/index/versions.go b/modules/mesh-delivery-indexer/internal/index/versions.go index e1d20b36..f199ff14 100644 --- a/modules/mesh-delivery-indexer/internal/index/versions.go +++ b/modules/mesh-delivery-indexer/internal/index/versions.go @@ -16,6 +16,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" stdio "git.novox.be/novox/mesh-sdk/go" + "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/keys" "mesh-delivery-indexer/internal/fingerprint" @@ -366,46 +367,28 @@ func isFloor(raw []byte) bool { return json.Unmarshal(raw, &v) == nil && len(v.Artifacts) == 0 } -// publishedOf is the newest version the registry published of each Go package, by its path (design 47 H-A-183, G §370): -// what the seats' published said, kept in the package's series (HearVersion), across every series; none for a package -// the registry never published. A Go package's version is its tag, so a module's release number is never one. -func publishedOf(series map[string]SeriesPackage) map[string]string { - out := map[string]string{} - for _, s := range series { - if s.GoModule == "" || s.Newest == nil { - continue - } - v := strings.TrimPrefix(s.Newest.Version, "v") - if _, ok := versionParts(v); !ok { - continue - } - if cur, has := out[s.GoModule]; !has || compareVersions(v, cur) > 0 { - out[s.GoModule] = v - } - } - return out -} - // releasedPins are a module's pins (its catalog entry's packages, which the builder builds it against) from the versions its -// fingerprint was computed with (design 47 H-A-161, H-A-183, H-A-184, G §370). A package of a series the module accepts -// that gives the fingerprint's contents (acceptedSeries, DLV-I6) is pinned to that series' newest published version, which -// versions already names (v): a publish in another series pins nothing and moves nothing. Where no series the module -// accepts gives it one yet, a package the registry published is pinned to the newest version published for its path -// (published, publishedOf). Any other, a commit, is no pin: its package is kept with no version, so its kind-1 edge stands -// (H §746) and its build waits for the publish (H-A-165). nil for none. -func releasedPins(versions sdkstep.PackageVersions, published map[string]string) sdkstep.PackageVersions { +// fingerprint was computed with (design 47 H-A-161, H-A-183, H-A-184, H-A-185, G §370): each package is pinned to the +// newest version the registry published for its path (the seats' published, kept in the package's series by HearVersion) +// within the series the module accepts, the one its manifest m names or the default (Manifest.AcceptedSeries), whether +// or not that series holds contents yet; a publish in another series pins nothing and moves nothing, and a module's +// release number is never a pin. A package with none published in that series is kept with no version, so its kind-1 +// edge stands (H §746) and its build waits for the publish (H-A-165). nil for none. +func releasedPins(versions sdkstep.PackageVersions, series map[string]SeriesPackage, m catalogue.Manifest) sdkstep.PackageVersions { if len(versions) == 0 { return nil } out := sdkstep.PackageVersions{} - for p, v := range versions { - switch { - case sdkstep.PackageSemver.MatchString(v): - out[p] = v - case published[p] != "": - out[p] = "v" + published[p] - default: - out[p] = "" + for p := range versions { + out[p] = "" + for _, s := range series { + if s.GoModule != p || s.Newest == nil || s.Series != m.AcceptedSeries(s.Name) { + continue + } + v := strings.TrimPrefix(s.Newest.Version, "v") + if _, ok := versionParts(v); ok && (out[p] == "" || compareVersions(v, strings.TrimPrefix(out[p], "v")) > 0) { + out[p] = "v" + v + } } } return out @@ -415,8 +398,8 @@ func releasedPins(versions sdkstep.PackageVersions, published map[string]string) // form's fingerprint takes them (design 47 H-A-167, H-A-172; ADR 0573 §4) and a re-pin moves it, the module a mover // built again against the release; a fingerprint with no pin is the form's as it is. The held fingerprint of a build that // stands is kept while its pins are the ones it was built with, else its import form takes the new pins. -func pinnedOf(f form, published map[string]string) (string, sdkstep.PackageVersions) { - pins := releasedPins(f.versions, published) +func pinnedOf(f form, series map[string]SeriesPackage, m catalogue.Manifest) (string, sdkstep.PackageVersions) { + pins := releasedPins(f.versions, series, m) if f.stands { if maps.Equal(f.built, map[string]string(pins)) { return f.fp, pins