Files
mesh-delivery/sdk/grouppackages/grouppackages.go
T
jschoubben 6bd77f3d31 Merge the release fix/1921-zero-version-builds into the registry group: every producer of a build at a group's heads takes its versions from sdk/grouppackages (issue 1921, issue 1966)
grouppackages is the Delivery SDK's (ADR 0634) and imports sdk/buildstep and sdk/trunk, not the deleted mesh-sdk/go/delivery.
The checker's packagesFor lays the group's tagged versions (design 51) over grouppackages.Heads, so a heard tag still stands
before a member's head; the composer and the trunk's manifest validator are built with no tags. Fetches carry the versions
in buildstep.Fetch.Packages, so withPackages is gone; the group's fetch names no beside ref, so the test of the node-engine
member beside reads its commit alone.

Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
2026-11-06 02:32:02 +01:00

66 lines
2.6 KiB
Go

// Package grouppackages is the one place that names the versions a build at a delivery group's heads uses (novox/hq
// ADR 0573 §2, §4; issue 1921). A build writes into its workspace the version of every mesh package it is asked, whatever
// its go.mod names; a requirement at the zero version that no ask names a commit for cannot be fetched. So every part
// that asks a build for a check, a try or a candidate (the checker's check, judge and compose asks, the indexer's
// candidate modules) takes the versions from Heads, and a member of the group that publishes no package yet is named too.
package grouppackages
import (
"strings"
"git.novox.be/novox/mesh-sdk/go/sdkversion"
"git.novox.be/novox/mesh-delivery/sdk/buildstep"
"git.novox.be/novox/mesh-delivery/sdk/trunk"
)
// rootOf is the module a member of repo stands for when no package of it is known: its root module path, or for the
// repository of mesh-sdk its Go module (sdkversion.Module, which is not at the root).
func rootOf(repo string) (string, bool) {
if sdkRepo, _, ok := trunk.PackageRepository(sdkversion.Module); ok && trunk.SameRepository(repo, sdkRepo) {
return sdkversion.Module, true
}
name, found := strings.CutPrefix(repo, "novox/")
if !found || name == "" {
return "", false
}
return trunk.ForgeModulePrefix + name, true
}
// Heads is the version of each mesh package a build of own builds against: latest (the latest published version of each
// package the mesh's modules use, nil for none) with every package of a group member at that member's head (heads, by
// repository <owner>/<name>, a full commit each), and for a member of which latest holds no package, the member's root
// module path (mesh-sdk's Go module for mesh-sdk) at its head: the build module takes the head of a
// repository from any package of it. A package of own comes with the tree the build fetched, and is left out, as is a
// package no version is known of. Nil for none. latest is not changed.
func Heads(latest buildstep.PackageVersions, heads map[string]string, own string) buildstep.PackageVersions {
versions := buildstep.PackageVersions{}
held := map[string]bool{}
for pkg, version := range latest {
repo, _, ok := trunk.PackageRepository(pkg)
if !ok || trunk.SameRepository(repo, own) {
continue
}
if head := heads[repo]; len(head) == 40 {
version = head
}
if version == "" {
continue
}
versions[pkg] = version
held[repo] = true
}
for repo, head := range heads {
if trunk.SameRepository(repo, own) || len(head) != 40 || held[repo] {
continue
}
if root, ok := rootOf(repo); ok {
versions[root] = head
}
}
if len(versions) == 0 {
return nil
}
return versions
}