From 517a4b3cf1b21444f81ba4ca7c86d2ef9c34ce97 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 20:05:52 +0100 Subject: [PATCH 1/3] mesh-delivery-indexer: a pin is the version the registry published for the package's path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At main.39 every importer of a nested package was pinned to the release number of the module holding it (v0.1.97 of the builder for its package builds), and the Go seat found no tag /v0.1.97. A Go package's version is its tag: the pin is now the newest version the registry published for that package path (the seats' published, kept in the package's series), never a module's release; a package the registry never published stays unpinned. Builds: design 47 H H-A-183, H-A-167, G §370 --- .../internal/index/imports_test.go | 36 ++++++++++----- .../internal/index/toolchains.go | 8 ++-- .../internal/index/toolchains_test.go | 12 +++-- .../internal/index/versions.go | 45 +++++++++---------- 4 files changed, 60 insertions(+), 41 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/imports_test.go b/modules/mesh-delivery-indexer/internal/index/imports_test.go index 0bcf5888..9752b6f0 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports_test.go +++ b/modules/mesh-delivery-indexer/internal/index/imports_test.go @@ -123,9 +123,21 @@ func TestImportsReportedMoveTheFingerprintOnlyWithAnImportedPackage(t *testing.T moved.Fp2, before.Fp2, moved.Inputs2.ImportForm, moved.Packages) } - // mesh-sdk releases 0.1.20: the import form's fingerprint takes the pin too and moves, once (H-A-172). + // mesh-sdk's module releases 0.1.97 while the registry has published nothing of its Go package: the module's release + // number is never the package's pin (H-A-183), so avahi stays unpinned and where it was. ix.Versions = newMem() - ix.Versions.(*memStore).put(meshcatalog.VersionsByModuleVersionKey("mesh-sdk", "0.1.20"), []byte(`{}`)) + ix.Versions.(*memStore).put(meshcatalog.VersionsByModuleVersionKey("mesh-sdk", "0.1.97"), []byte(`{}`)) + if err := ix.Recompute(ctx); err != nil { + t.Fatal(err) + } + if m, _ := moduleOf(t, mods, "avahi"); m.Fp2 != moved.Fp2 || m.Packages[meshSDK] != "" { + t.Fatalf("after mesh-sdk's module release alone: fp2 %q (was %q), versions %v; want it unpinned where it was", m.Fp2, moved.Fp2, m.Packages) + } + // The registry publishes its Go package at 0.1.20, another version than the module's release: the import form's + // fingerprint takes that pin and moves, once (H-A-172, H-A-183). + if _, err := ix.HearVersion(ctx, HeardVersion{Package: "mesh-sdk/go", Seat: "go-package-registry", Version: "0.1.20", Commit: c3, GoModule: meshSDK, Published: true}); err != nil { + t.Fatal(err) + } for range 2 { if err := ix.Recompute(ctx); err != nil { t.Fatal(err) @@ -283,17 +295,21 @@ 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) } - 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) + // 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) } - 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) + 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) } - // mesh-sdk releases 0.1.20: an accepted series' older version never stands over a newer release (H-A-167). + // 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.1.20"), []byte(`{}`)) - if m := step("0.1.20 released", func() error { return nil }); m.Packages[meshSDK] != "v0.1.20" { - t.Errorf("a newer release left avahi on its series' older version: %v", m.Packages) + 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" { + t.Errorf("a module's release pinned its package: %v", m.Packages) } } diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index f3b72e2f..ca7cf416 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -218,8 +218,8 @@ 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 := ix.releasedOf(ctx) // each module's newest released version, what a package is pinned to (H-A-161) + 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) type result struct { fp, none string tcs map[string]meshcatalog.ToolchainUsed // by language, when there is a fingerprint @@ -299,7 +299,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, held, released) + r.fp, r.pkgs = pinnedOf(f, released) r.tcs = toolchainsUsed(toolchains) } } @@ -518,7 +518,7 @@ func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2, if f.none != "" || f.fp == "" { return "", nil, false } - fp, pkgs := pinnedOf(f, held, released) + fp, pkgs := pinnedOf(f, released) 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 281540a7..6beb739a 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go @@ -805,17 +805,23 @@ 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). + 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) + } if err := ix.HearPackagePublished(context.Background(), release); err != nil { t.Fatal(err) } 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.20"}) { - t.Fatalf("after mesh-sdk's release: fp2 %q (was %q) packages %v, want a new fingerprint pinned to v0.1.20", a.Fp2, first.Fp2, a.Packages) + 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) } 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) } - second := sdkMerge(strings.Repeat("2", 40), "tree-sdk-2", "v0.1.20") + second := sdkMerge(strings.Repeat("2", 40), "tree-sdk-2", "v0.1.18") if second.Fp2 == first.Fp2 { t.Errorf("a mesh-sdk trunk merge kept avahi's fingerprint %q", first.Fp2) } diff --git a/modules/mesh-delivery-indexer/internal/index/versions.go b/modules/mesh-delivery-indexer/internal/index/versions.go index 1fcae613..2bba22d2 100644 --- a/modules/mesh-delivery-indexer/internal/index/versions.go +++ b/modules/mesh-delivery-indexer/internal/index/versions.go @@ -366,42 +366,39 @@ func isFloor(raw []byte) bool { return json.Unmarshal(raw, &v) == nil && len(v.Artifacts) == 0 } -// releasedOf is the newest released version of each module the state versions keeps (§349; design 47 H-A-161), by module; -// nil when the indexer keeps no such state or it cannot be listed, said. -func (ix *Indexer) releasedOf(ctx context.Context) map[string]string { - if ix.Versions == nil { - return nil - } - all, err := ix.Versions.Keys(ctx) - if err != nil { - ix.logf("versions: the state cannot be listed, so no package is pinned by this pass: %v", err) - return nil - } +// 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 _, k := range all { - m, v, ok := meshcatalog.ParseVersionsByModuleVersionKey(k) - if _, parts := versionParts(v); !ok || !parts { + for _, s := range series { + if s.GoModule == "" || s.Newest == nil { continue } - if cur, has := out[m]; !has || compareVersions(v, cur) > 0 { - out[m] = v + 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, G §370): a package the held module holding it has released is pinned -// to that module's newest released version, as Go names it (v); a version already in that form (an accepted -// series' newest, DLV-I6) stands; any other, a commit, is no pin: its package is kept with no version, so its kind-1 edge -// stands (H §746) and no build is made against a commit. nil for none. -func releasedPins(versions sdkstep.PackageVersions, held map[string]meshcatalog.ModulesByModuleValue, released map[string]string) sdkstep.PackageVersions { +// 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. +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 := released[moduleOfKey(fingerprint.HolderOf(p, held))] + rel := published[p] series := sdkstep.PackageSemver.MatchString(v) _, plain := versionParts(strings.TrimPrefix(v, "v")) switch { @@ -420,8 +417,8 @@ func releasedPins(versions sdkstep.PackageVersions, held map[string]meshcatalog. // 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, held map[string]meshcatalog.ModulesByModuleValue, released map[string]string) (string, sdkstep.PackageVersions) { - pins := releasedPins(f.versions, held, released) +func pinnedOf(f form, published map[string]string) (string, sdkstep.PackageVersions) { + pins := releasedPins(f.versions, published) if f.stands { if maps.Equal(f.built, map[string]string(pins)) { return f.fp, pins -- 2.54.0 From 859f88b2f05bd196f6fbd440833b51634a01ba56 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 20:07:46 +0100 Subject: [PATCH 2/3] 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] = "" } -- 2.54.0 From e93575ffe73702431f06a3bc21186f45e6959573 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 20:13:15 +0100 Subject: [PATCH 3/3] 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 -- 2.54.0