A-C5: mesh-build-node builds against the latest published SDK, the toolchain pins none

Recovered from cfee5f2d (feat/47-G-buildmods).
Builds: design 47 G §571 (the build writes a mesh package's lock entry from the latest published version), A-56

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-11 23:23:44 +01:00
parent ff07c3a668
commit c41a84ee95
10 changed files with 158 additions and 69 deletions
@@ -91,29 +91,42 @@ func placedVersion(dir string) string {
return p.Version
}
// The lead's decision L10 (ADR 0500 §6): a member is built against the SDK version its own lock names, downloaded from
// the registry and checked against the lock's integrity; a version the registry does not hold is a wait, `waits for:`.
func TestAMemberGetsTheSDKVersionItsLockNamesOrWaitsForIt(t *testing.T) {
// ADR 0573 §2 (unpinned, the lead's decision L10's lock version gone): a member is built against the latest release the
// registry holds, whatever its lock names or when it names none, checked against the lock's integrity only when the lock
// names that version; a pre-release is never the latest; a registry holding no release is a wait, `waits for:`.
func TestAMemberGetsTheLatestPublishedSDKWhateverItsLockNames(t *testing.T) {
m, _, _ := newMachine(t)
held := tgzOf(t, sdkPackage, "0.1.15")
held, older, pre := tgzOf(t, sdkPackage, "0.1.15"), tgzOf(t, sdkPackage, "0.1.9"), tgzOf(t, sdkPackage, "0.1.16-feat-x.1")
fakeRegistry(t, m, map[string][]byte{"0.1.15": held, "0.1.9": older, "0.1.16-feat-x.1": pre})
for _, c := range []struct {
name, locks, integrity, fails string
}{
{name: "a lock naming the latest", locks: "0.1.15", integrity: integrityOf(held)},
{name: "a lock naming an older version (the pin)", locks: "0.1.9", integrity: integrityOf(older)},
{name: "a lock naming a version the registry lacks", locks: "0.1.16", integrity: "sha512-x"},
{name: "a lock naming none", locks: ""},
{name: "a lock naming the latest with another integrity", locks: "0.1.15", integrity: "sha512-another", fails: "sha512-another"},
} {
dir := memberLocking(t, c.locks, c.integrity)
err := m.placeSDK(context.Background(), dir, "modules/m", nil, nil)
switch {
case c.fails == "" && (err != nil || placedVersion(dir) != "0.1.15"):
t.Errorf("%s: %v, placed %q, want the latest release 0.1.15", c.name, err, placedVersion(dir))
case c.fails != "" && (err == nil || !strings.Contains(err.Error(), c.fails)):
t.Errorf("%s: %v, want it to fail naming %s", c.name, err, c.fails)
}
}
fakeRegistry(t, m, map[string][]byte{"0.1.16-feat-x.1": pre})
if err := m.placeSDK(context.Background(), memberLocking(t, "0.1.15", ""), "modules/m", nil, nil); err == nil || err.Error() != builds.WaitsFor+"@novox/mesh-sdk" {
t.Errorf("a registry with no release answered %v, want %s@novox/mesh-sdk", err, builds.WaitsFor)
}
held = tgzOf(t, sdkPackage, "0.1.15")
fakeRegistry(t, m, map[string][]byte{"0.1.15": held})
dir := memberLocking(t, "0.1.15", integrityOf(held))
if err := m.placeSDK(context.Background(), dir, "modules/m", nil, nil); err != nil || placedVersion(dir) != "0.1.15" {
t.Errorf("the registry's 0.1.15: %v, placed %q", err, placedVersion(dir))
}
dir = memberLocking(t, "0.1.16", "sha512-x")
err := m.placeSDK(context.Background(), dir, "modules/m", nil, nil)
if err == nil || err.Error() != builds.WaitsFor+"@novox/mesh-sdk@0.1.16" {
t.Errorf("a version the registry lacks answered %v, want %s@novox/mesh-sdk@0.1.16", err, builds.WaitsFor)
}
dir = memberLocking(t, "0.1.15", "sha512-another")
if err := m.placeSDK(context.Background(), dir, "modules/m", nil, nil); err == nil || !strings.Contains(err.Error(), "sha512-another") {
t.Errorf("a registry file of another integrity than the lock's answered %v", err)
}
var dir string
// ADR 0607 §3, §5 (design 51 *Tagged versions*): given the group's tagged version, the fetch places it from the
// registry whatever the lock names, against the lock's integrity when the lock names it, else the registry's; one the
// registry lacks fails naming it, no wait (the check waited for its published).
tagged := tgzOf(t, sdkPackage, "0.1.16-feat-x.1")
tagged := pre
fakeRegistry(t, m, map[string][]byte{"0.1.15": held, "0.1.16-feat-x.1": tagged})
group := &groupPackage{Name: sdkPackage, Version: "0.1.16-feat-x.1"}
for _, c := range []struct {
@@ -140,8 +153,8 @@ func TestAMemberGetsTheSDKVersionItsLockNamesOrWaitsForIt(t *testing.T) {
}
// ADR 0500 §5 (S3, S4): the group's packed package is served in place of the registry's when the member's lock names its
// version with its integrity; another integrity, or a version neither the group nor the registry holds, fails naming both.
// A member whose lock names no SDK keeps the toolchain's and asks the registry nothing.
// version with its integrity; another integrity fails naming both. A member locking another version, or none, gets the
// registry's latest release (ADR 0573 §2); with no release in the registry it fails naming the group's, no wait.
func TestTheGroupsPackageIsServedToAMemberLockingItsVersion(t *testing.T) {
m, _, _ := newMachine(t)
asked := fakeRegistry(t, m, map[string][]byte{"0.1.14": tgzOf(t, sdkPackage, "0.1.14")})
@@ -159,14 +172,15 @@ func TestTheGroupsPackageIsServedToAMemberLockingItsVersion(t *testing.T) {
if err := m.placeSDK(context.Background(), dir, "modules/m", group, nil); err != nil || placedVersion(dir) != "0.1.14" {
t.Errorf("a member locking the registry's 0.1.14 in a group: %v, placed %q", err, placedVersion(dir))
}
dir = memberLocking(t, "0.1.13", "sha512-x")
if err := m.placeSDK(context.Background(), dir, "modules/m", group, nil); err == nil || !strings.Contains(err.Error(), "0.1.13") || !strings.Contains(err.Error(), "0.1.15") || strings.HasPrefix(err.Error(), builds.WaitsFor) {
t.Errorf("a version neither holds answered %v, want both named and no wait", err)
for _, locks := range []string{"0.1.13", ""} {
dir = memberLocking(t, locks, "sha512-x")
if err := m.placeSDK(context.Background(), dir, "modules/m", group, nil); err != nil || placedVersion(dir) != "0.1.14" {
t.Errorf("a member in a group locking %q: %v, placed %q, want the registry's latest 0.1.14", locks, err, placedVersion(dir))
}
}
before := asked.Load()
dir = memberLocking(t, "", "")
if err := m.placeSDK(context.Background(), dir, "modules/m", group, nil); err != nil || placedVersion(dir) != "" || asked.Load() != before {
t.Errorf("a lock naming no SDK: %v, placed %q, the registry asked", err, placedVersion(dir))
fakeRegistry(t, m, nil)
if err := m.placeSDK(context.Background(), memberLocking(t, "0.1.13", "sha512-x"), "modules/m", group, nil); err == nil || !strings.Contains(err.Error(), "0.1.15") || strings.HasPrefix(err.Error(), builds.WaitsFor) {
t.Errorf("no release and a group answered %v, want the group's named and no wait", err)
}
}