From 859f88b2f05bd196f6fbd440833b51634a01ba56 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 20:07:46 +0100 Subject: [PATCH] mesh-delivery-indexer: a pin stays within the series the module accepts A pin by the package path across every series moved a module to a series it does not accept while its contents came from the accepted one. The pin is the accepted series' newest published version where that series gives the contents; only where none does yet is it the newest published of the path. A publish in another series pins nothing and moves nothing. Builds: design 47 H H-A-184, H-A-183 --- .../internal/index/imports_test.go | 15 ++++++-------- .../internal/index/toolchains_test.go | 5 +++-- .../internal/index/versions.go | 20 +++++++++---------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/imports_test.go b/modules/mesh-delivery-indexer/internal/index/imports_test.go index 9752b6f0..7bca9361 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports_test.go +++ b/modules/mesh-delivery-indexer/internal/index/imports_test.go @@ -295,20 +295,17 @@ func anAcceptedSeriesPinsItsNewest(t *testing.T) { if pinned.Fp2 == before.Fp2 || pinned.Packages[meshSDK] != "v0.1.15" { t.Fatalf("after 0.1.15: fp2 %q (was %q), versions %v; want moved by c3's announce, pinned to v0.1.15", pinned.Fp2, before.Fp2, pinned.Packages) } - // 0.2.0 published, of a series avahi does not accept: the pin is the newest version the registry published for the - // package's path, an accepted series' older version never standing over it (H-A-167, H-A-183), and the pin moves the - // fingerprint (H-A-172). - newest := step("0.2.0 published from c1", hear("0.2.0", c1)) - if newest.Fp2 == pinned.Fp2 || newest.Packages[meshSDK] != "v0.2.0" { - t.Errorf("a newer publish of another series left avahi on its accepted series' older version: %q %v", newest.Fp2, newest.Packages) + // A publish in a series avahi does not accept pins nothing and moves nothing (H-A-184). + if m := step("0.2.0 published from c1", hear("0.2.0", c1)); m.Fp2 != pinned.Fp2 || m.Packages[meshSDK] != "v0.1.15" { + t.Errorf("a publish of a series avahi does not accept moved it: %q %v", m.Fp2, m.Packages) } - if m := step("trunk at c2", trunk(c2)); m.Fp2 != newest.Fp2 || m.Packages[meshSDK] != "v0.2.0" { - t.Errorf("a trunk merge moved avahi off the newest published version: %q %v", m.Fp2, m.Packages) + if m := step("trunk at c2", trunk(c2)); m.Fp2 != pinned.Fp2 || m.Packages[meshSDK] != "v0.1.15" { + t.Errorf("a trunk merge moved avahi off its accepted series' newest: %q %v", m.Fp2, m.Packages) } // mesh-sdk's module releases 0.3.0: a module's release number is never a package's pin (H-A-183). ix.Versions = newMem() ix.Versions.(*memStore).put(meshcatalog.VersionsByModuleVersionKey("mesh-sdk", "0.3.0"), []byte(`{}`)) - if m := step("0.3.0 released", func() error { return nil }); m.Packages[meshSDK] != "v0.2.0" { + if m := step("0.3.0 released", func() error { return nil }); m.Packages[meshSDK] != "v0.1.15" { t.Errorf("a module's release pinned its package: %v", m.Packages) } } diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go index 6beb739a..cc312061 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go @@ -805,8 +805,9 @@ 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: the pin is the - // version the registry published for the package's path (H-A-183). + // 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). 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) diff --git a/modules/mesh-delivery-indexer/internal/index/versions.go b/modules/mesh-delivery-indexer/internal/index/versions.go index 2bba22d2..e1d20b36 100644 --- a/modules/mesh-delivery-indexer/internal/index/versions.go +++ b/modules/mesh-delivery-indexer/internal/index/versions.go @@ -387,25 +387,23 @@ func publishedOf(series map[string]SeriesPackage) map[string]string { } // 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, G §370): a package the registry published is pinned to the -// newest version it published for that package's path (published, publishedOf), as Go names it (v); an accepted -// series' version (DLV-I6) stands only while no newer one is published (H-A-167); 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. +// 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 { if len(versions) == 0 { return nil } out := sdkstep.PackageVersions{} for p, v := range versions { - rel := published[p] - series := sdkstep.PackageSemver.MatchString(v) - _, plain := versionParts(strings.TrimPrefix(v, "v")) switch { - case rel != "" && (!series || !plain || compareVersions(rel, strings.TrimPrefix(v, "v")) > 0): - out[p] = "v" + rel // never an older series' version over a newer release (H-A-167) - case series: + case sdkstep.PackageSemver.MatchString(v): out[p] = v + case published[p] != "": + out[p] = "v" + published[p] default: out[p] = "" }