Design 47 H1: an entry's packages never leave out a requirement

Build asks were refused for a requirement with no pin: the import form's
versions name only what the last build imported, and the version line
leaves out a package none publishes, so the pins kept only those. The pins
now name every other-repository package of the module's go.mod graph (its
kept packages), at the newest published version of its accepted series, or
with no version while none is published, so the builder waits for it.

Builds: design 47 H H-A-204, H-A-201, H-A-165, H-A-167
This commit is contained in:
2026-11-20 22:57:26 +01:00
parent b9cc97470b
commit 0418a2b94b
4 changed files with 48 additions and 8 deletions
@@ -137,7 +137,7 @@ func TestTheEntryPinsEveryRequirementOfTheModuleGraph(t *testing.T) {
t.Errorf("packages = %+v, want the client's requirement and state's mesh-sdk, and no module of the repository", m.Inputs2)
}
builds := "git.novox.be/novox/mesh-delivery/modules/b/builds"
pins := releasedPins(sdkstep.PackageVersions{builds: "v0.1.106", conditions: "v0.1.4"}, nil, catalogue.Manifest{}, "novox/mesh-delivery")
pins := releasedPins(sdkstep.PackageVersions{builds: "v0.1.106", conditions: "v0.1.4"}, nil, catalogue.Manifest{}, "novox/mesh-delivery", nil)
if _, pinned := pins[builds]; pinned || len(pins) != 1 {
t.Errorf("pins = %v, want %s only, never a module of the repository", pins, conditions)
}
@@ -0,0 +1,32 @@
package index
import (
"testing"
"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"
"git.novox.be/novox/mesh-sdk/go/catalogue"
)
// Design 47 H-A-204, H-A-201, H-A-165: an entry's packages name every requirement of its module graph of another
// repository: one the form's versions leave out (an import form naming only what the build imported) is pinned by its
// series' newest published version, and one none publishes yet is kept with no version, never left out.
func TestAnEntryNamesEveryRequirementPinnedOrWaiting(t *testing.T) {
const (
wireguard = "git.novox.be/novox/mesh-networking/modules/mesh-wireguard/go"
busgrants = "git.novox.be/novox/mesh-delivery/modules/mesh-grants/busgrants"
sdk = "git.novox.be/novox/mesh-sdk/go"
)
series := map[string]SeriesPackage{"wg": {Name: "mesh-wireguard/go", GoModule: wireguard, Series: catalogue.DefaultSeries,
Newest: &meshcatalog.PackagesByPackageSeriesValueNewest{Version: "0.1.47"}}}
pins := releasedPins(sdkstep.PackageVersions{sdk: "c0ffee"}, series, catalogue.Manifest{}, "novox/mesh-catalog", []string{busgrants, sdk, wireguard})
want := sdkstep.PackageVersions{sdk: "", wireguard: "v0.1.47", busgrants: ""}
if len(pins) != len(want) {
t.Fatalf("pins = %v, want %v", pins, want)
}
for p, v := range want {
if got, named := pins[p]; !named || got != v {
t.Errorf("the pin of %s is %q (named %v), want %q", p, got, named, v)
}
}
}
@@ -298,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, series, k.manifest, k.cur.Repository)
r.fp, r.pkgs = pinnedOf(f, series, k.manifest, k.cur.Repository, kept.Packages)
r.tcs = toolchainsUsed(toolchains)
}
}
@@ -517,7 +517,7 @@ func stillComputed(module string, kept meshcatalog.ModulesByModuleValueInputs2,
if f.none != "" || f.fp == "" {
return "", nil, false
}
fp, pkgs := pinnedOf(f, series, k.manifest, k.held.Repository)
fp, pkgs := pinnedOf(f, series, k.manifest, k.held.Repository, kept.Packages)
return fp, pkgs, fp == k.held.Fp2
}
@@ -376,12 +376,20 @@ func isFloor(raw []byte) bool {
// 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). A module of the module's own repository is never
// pinned, whatever a build reported: it is built from the tree (design 47 H-A-198, H-A-201, H-A-202). nil for none.
func releasedPins(versions sdkstep.PackageVersions, series map[string]SeriesPackage, m catalogue.Manifest, repository string) sdkstep.PackageVersions {
if len(versions) == 0 {
//
// required are the mesh packages the module's go.mod graph requires (its kept packages, H-A-201): each of another
// repository is named whether or not the form's versions name it, with no version while none is published, never left
// out, so the builder waits for its publish instead of the build module refusing (design 47 H-A-204, H-A-165).
func releasedPins(versions sdkstep.PackageVersions, series map[string]SeriesPackage, m catalogue.Manifest, repository string, required []string) sdkstep.PackageVersions {
names := slices.Collect(maps.Keys(versions))
if repository != "" {
names = append(names, fingerprint.OtherPackages(required, repository)...)
}
if len(names) == 0 {
return nil
}
out := sdkstep.PackageVersions{}
for p := range versions {
for _, p := range names {
if repo, _, ok := trunk.PackageRepository(p); ok && repository != "" && trunk.SameRepository(repo, repository) {
continue
}
@@ -403,8 +411,8 @@ func releasedPins(versions sdkstep.PackageVersions, series map[string]SeriesPack
// 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, series map[string]SeriesPackage, m catalogue.Manifest, repository string) (string, sdkstep.PackageVersions) {
pins := releasedPins(f.versions, series, m, repository)
func pinnedOf(f form, series map[string]SeriesPackage, m catalogue.Manifest, repository string, required []string) (string, sdkstep.PackageVersions) {
pins := releasedPins(f.versions, series, m, repository, required)
if f.stands {
if maps.Equal(f.built, map[string]string(pins)) {
return f.fp, pins