A-471: a toolchain is agreed, reported and named by its language version alone

A build node whose installed patch differs from the ask's takes the ask: one shared
comparison in mesh-delivery-sdk buildstep (LanguageVersion, SameToolchainVersion),
used by the agreement (indexer, builder, checker), a build node's step guard and ask
check, and the builder's digest list. A fingerprint names the language version, so
every module's fingerprint changes once.

Builds: design 47 G A-471 (G-22-lead-answers-2.md)
This commit is contained in:
2026-11-17 15:53:05 +01:00
parent 80a7061efa
commit a66583236a
15 changed files with 144 additions and 67 deletions
@@ -69,7 +69,7 @@ type AgreedDigest struct {
func Digests(entries []buildstep.NodeToolchain, agreed buildstep.Toolchain) []AgreedDigest {
by := map[string][]string{}
for _, e := range entries {
if e.Version == agreed.Version && e.Recipe == agreed.Recipe && e.Digest != "" {
if buildstep.LanguageVersion(e.Version) == agreed.Version && e.Recipe == agreed.Recipe && e.Digest != "" {
by[e.Digest] = append(by[e.Digest], e.Node)
}
}
@@ -369,7 +369,7 @@ func (b *bed) module(t *testing.T, name, fixture, path string) string {
}
// bothToolchains are the toolchains the bed's nodes report, as a module's fingerprint names them.
var bothToolchains = map[string]builds.ToolchainUsed{"go": {Version: "go1.27.1", Recipe: "1"}, "typescript": {Version: "tsc5", Recipe: "1"}}
var bothToolchains = map[string]builds.ToolchainUsed{"go": {Version: "go1.27", Recipe: "1"}, "typescript": {Version: "tsc5", Recipe: "1"}}
// moduleWith is module with the toolchains its fingerprint was computed with.
func (b *bed) moduleWith(t *testing.T, name, fixture, path string, toolchains map[string]builds.ToolchainUsed) string {
@@ -546,7 +546,7 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
t.Errorf("artifact = %+v, want the digest every node built and the reference its push answered (ADR 0498 clause 1)", a)
}
}
if v.Toolchains["go"].Version != "go1.27.1" || v.Toolchains["typescript"].Version != "tsc5" {
if v.Toolchains["go"].Version != "go1.27" || v.Toolchains["typescript"].Version != "tsc5" {
t.Errorf("toolchains = %+v", v.Toolchains)
}
// A-115: the builder's process answers the seat mesh-builds' verb reserved over the bus; the reservation of a module it never
@@ -750,7 +750,7 @@ func TestAFailedKeyIsBuiltAgainAsANewRevisionFromANewModulesValueWithTheSameFing
}
}
// TestAToolchainChangeDoesNotBuildTheOldFingerprint: the fingerprint names go1.27.1, the nodes then agree on go1.27.2 (a
// TestAToolchainChangeDoesNotBuildTheOldFingerprint: the fingerprint names go1.27.1, the nodes then agree on go1.28.0 (a
// report of both nodes), and the builder writes no key for the old fingerprint although it was woken by the report; a
// module value naming go1.27.2 (the new fingerprint, computed by the indexer) is built.
func TestAToolchainChangeDoesNotBuildTheOldFingerprint(t *testing.T) { // 1615/AC4
@@ -765,15 +765,15 @@ func TestAToolchainChangeDoesNotBuildTheOldFingerprint(t *testing.T) { // 1615/A
if err := st.Purge(b.ctx, jetstream.WithPurgeSubject("mesh.seat.node-build-go.event.toolchain-reported.>")); err != nil {
t.Fatal(err)
}
b.report(t, "mesh-build-go", "n1", "go", "go1.27.2", "1")
b.report(t, "mesh-build-go", "n2", "go", "go1.27.2", "1")
b.module(t, "netcheck", "catalogue-a67f0196-netcheck.module.json", "modules/netcheck") // names go1.27.1
b.report(t, "mesh-build-go", "n1", "go", "go1.28.0", "1")
b.report(t, "mesh-build-go", "n2", "go", "go1.28.0", "1")
b.module(t, "netcheck", "catalogue-a67f0196-netcheck.module.json", "modules/netcheck") // names go1.27
b.start(t, "n1", nil)
// Another module, whose fingerprint names the new toolchain, is built; by then the old one has been looked at.
b.moduleCommit(t, "netcheck2", "catalogue-a67f0196-netcheck.module.json", "modules/netcheck",
map[string]builds.ToolchainUsed{"go": {Version: "go1.27.2", Recipe: "1"}, "typescript": {Version: "tsc5", Recipe: "1"}}, commit)
map[string]builds.ToolchainUsed{"go": {Version: "go1.28", Recipe: "1"}, "typescript": {Version: "tsc5", Recipe: "1"}}, commit)
b.await(t, "netcheck2", isState(builds.BuildDone))
// The builder never agreed on go1.27.1, not for a moment: that is what would build the old fingerprint.
// The builder never agreed on go1.27, not for a moment: that is what would build the old fingerprint.
info, err := st.Info(b.ctx)
if err != nil {
t.Fatal(err)
@@ -786,12 +786,12 @@ func TestAToolchainChangeDoesNotBuildTheOldFingerprint(t *testing.T) { // 1615/A
if err != nil {
t.Fatal(err)
}
if strings.HasSuffix(m.Subject, ".toolchain-agreed") && strings.Contains(string(m.Data), `"version":"go1.27.1"`) {
t.Errorf("the builder said the nodes agree on go1.27.1: %s", m.Data)
if strings.HasSuffix(m.Subject, ".toolchain-agreed") && strings.Contains(string(m.Data), `"version":"go1.27"`) {
t.Errorf("the builder said the nodes agree on go1.27: %s", m.Data)
}
}
if _, err := b.builds.Get(b.ctx, mustKey(t, "netcheck")); err == nil {
t.Error("the old fingerprint, naming go1.27.1, was built with go1.27.2; the log: " + b.out.String())
t.Error("the old fingerprint, naming go1.27, was built with go1.28.0; the log: " + b.out.String())
}
if n := b.fake.count("mesh-build-go.build_go_build"); n != 1 {
t.Errorf("build_go_build was called %d times, want 1 (the new fingerprint on one node only)", n)
@@ -111,7 +111,7 @@ func TestTheBuilderKeepsTheToolchainsItHeardAndForgetsThemOnStopped(t *testing.T
if len(keys) != 3 || keys[0] != "ace.go" {
t.Fatalf("the state holds %v, want the three nodes' keys <node>.go", keys)
}
if len(r.said) != 1 || r.said[0].Version != "1.26.0" || r.said[0].Language != "go" {
if len(r.said) != 1 || r.said[0].Version != "1.26" || r.said[0].Language != "go" {
t.Fatalf("toolchain-agreed said %+v, want one for go 1.26.0 (said only when the version changes)", r.said)
}
// The first report agreed it with one digest; a later digest of the same version is not said again.
@@ -120,13 +120,13 @@ func TestTheBuilderKeepsTheToolchainsItHeardAndForgetsThemOnStopped(t *testing.T
}
// A restarted builder reads the keys back and agrees the same version with no new report; the digests it says are all three nodes'.
again := newHeardRig(t, state)
if len(again.said) != 1 || again.said[0].Version != "1.26.0" || len(again.said[0].Digests) != 2 || again.said[0].Digests[0].Nodes[1] != "g14" {
if len(again.said) != 1 || again.said[0].Version != "1.26" || len(again.said[0].Digests) != 2 || again.said[0].Digests[0].Nodes[1] != "g14" {
t.Fatalf("a restarted builder said %+v, want go 1.26.0 with the digests of its three nodes", again.said)
}
// A version change is said; the stopped build module of ace takes ace's key out, a placement taking nothing.
again.report(t, "node-build-go", "ace", "go", "1.27.0", da)
again.report(t, "node-build-go", "g14", "go", "1.27.0", da)
if len(again.said) != 2 || again.said[1].Version != "1.27.0" {
if len(again.said) != 2 || again.said[1].Version != "1.27" {
t.Fatalf("a changed agreed version was not said: %+v", again.said)
}
at := time.Now()
@@ -197,7 +197,7 @@ func newRig(t *testing.T, artifacts ...catalogue.Artifact) *rig {
}
// agreedToolchains are what the rig's nodes report, and so what a fingerprint computed now names.
var agreedToolchains = map[string]builds.ToolchainUsed{"go": {Version: "go1.27.1", Recipe: "1"}, "typescript": {Version: "tsc5", Recipe: "1"}}
var agreedToolchains = map[string]builds.ToolchainUsed{"go": {Version: "go1.27", Recipe: "1"}, "typescript": {Version: "tsc5", Recipe: "1"}}
func moduleValue(t *testing.T, path string) []byte { return moduleValueWith(t, path, agreedToolchains) }
@@ -301,7 +301,7 @@ func TestABundleAndAnArchiveAreBuiltOnOneNodeAndDone(t *testing.T) { // 1607/AC7
if !slices.Equal(v.Needs, []string{"form:artifact-store"}) || v.Artifacts[0].References != nil {
t.Errorf("needs = %v, references = %v", v.Needs, v.Artifacts[0].References)
}
if got := v.Toolchains["go"]; got.Version != "go1.27.1" || got.Recipe != "1" {
if got := v.Toolchains["go"]; got.Version != "go1.27" || got.Recipe != "1" {
t.Errorf("toolchains = %+v, want go and typescript named", v.Toolchains)
}
if got := v.Toolchains["typescript"]; got.Version != "tsc5" {
@@ -684,32 +684,32 @@ func (d *seatDrops) get() []string {
func TestAKeyIsBuiltOnlyWithTheToolchainItsFingerprintNamesAndNothingIsWrittenOtherwise(t *testing.T) { // 1615/AC4
r := newRig(t, goBundle)
old := map[string]builds.ToolchainUsed{"go": {Version: "go1.26.0", Recipe: "1"}}
old := map[string]builds.ToolchainUsed{"go": {Version: "go1.26", Recipe: "1"}}
r.b.Module(context.Background(), "m", moduleValueWith(t, "modules/m", old))
r.b.Wait()
if len(r.st.vals) != 0 || len(r.bm.calls) != 0 {
t.Run("a recipe that moves builds the module again under its new fingerprint", aRecipeThatMovesBuildsTheModuleAgainUnderItsNewFingerprint)
t.Errorf("keys %v and %d calls for a fingerprint of go1.26.0 while the nodes agree on go1.27.1, want neither", r.st.vals, len(r.bm.calls))
t.Errorf("keys %v and %d calls for a fingerprint of go1.26 while the nodes agree on go1.27, want neither", r.st.vals, len(r.bm.calls))
}
// A recipe that differs is a different toolchain too, and a value that names none (written before) is not built.
r.b.Module(context.Background(), "m", moduleValueWith(t, "modules/m", map[string]builds.ToolchainUsed{"go": {Version: "go1.27.1", Recipe: "0"}}))
r.b.Module(context.Background(), "m", moduleValueWith(t, "modules/m", map[string]builds.ToolchainUsed{"go": {Version: "go1.27", Recipe: "0"}}))
r.b.Module(context.Background(), "m", moduleValueWith(t, "modules/m", nil))
r.b.Wait()
if len(r.st.vals) != 0 || len(r.bm.calls) != 0 {
t.Errorf("keys %v and %d calls for a recipe that differs or a value that names no toolchain", r.st.vals, len(r.bm.calls))
}
// The toolchain moves under a key that is not built yet: the old fingerprint stays unbuilt, the new one builds.
r.tools.Set("ace", tcOf("go", "go1.27.2"))
r.tools.Set("novox", tcOf("go", "go1.27.2"))
r.tools.Set("ace", tcOf("go", "go1.28.0"))
r.tools.Set("novox", tcOf("go", "go1.28.0"))
r.b.Reconsider(context.Background())
r.b.Wait()
if len(r.st.vals) != 0 {
t.Errorf("keys %v: the old fingerprint was built with the new toolchain", r.st.vals)
}
r.b.Module(context.Background(), "m", moduleValueWith(t, "modules/m", map[string]builds.ToolchainUsed{"go": {Version: "go1.27.2", Recipe: "1"}}))
r.b.Module(context.Background(), "m", moduleValueWith(t, "modules/m", map[string]builds.ToolchainUsed{"go": {Version: "go1.28", Recipe: "1"}}))
r.b.Wait()
if v := valueOf(t, r.st, r.key); v.State != builds.BuildDone || v.Toolchains["go"].Version != "go1.27.2" {
t.Errorf("build = %+v, want done with go1.27.2", v)
if v := valueOf(t, r.st, r.key); v.State != builds.BuildDone || v.Toolchains["go"].Version != "go1.28" {
t.Errorf("build = %+v, want done with go1.28", v)
}
}
@@ -730,7 +730,7 @@ func aRecipeThatMovesBuildsTheModuleAgainUnderItsNewFingerprint(t *testing.T) {
t.Errorf("%d calls, was %d: the first fingerprint was built again for the new recipe", len(r.bm.calls), calls)
}
data, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20", Fp: "src1:" + hex64('f'), Fp2: fp2,
Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(map[string]builds.ToolchainUsed{"go": {Version: "go1.27.1", Recipe: "2"}})})
Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(map[string]builds.ToolchainUsed{"go": {Version: "go1.27", Recipe: "2"}})})
if err != nil {
t.Fatal(err)
}
@@ -41,7 +41,7 @@ func (w *memWaits) End(_ context.Context, module, fp, how string) bool {
// built and ended `ran` when the agreed toolchain moves to that version; and one held is built with the running build
// module by Release and ended `released`.
func TestAnEntryWhoseFingerprintNamesAnotherToolchainWaitsAndIsBuiltWhenItIsAgreedOrReleased(t *testing.T) {
old := map[string]builds.ToolchainUsed{"go": {Version: "go1.26.0", Recipe: "1"}}
old := map[string]builds.ToolchainUsed{"go": {Version: "go1.26", Recipe: "1"}}
t.Run("ran", func(t *testing.T) {
r := newRig(t, goBundle)
w := &memWaits{}
@@ -52,7 +52,7 @@ func TestAnEntryWhoseFingerprintNamesAnotherToolchainWaitsAndIsBuiltWhenItIsAgre
t.Fatalf("held %v, keys %v: want one wait and nothing written", w.held, r.st.vals)
}
for _, h := range w.held {
if h.On() != "toolchain:go@go1.26.0" {
if h.On() != "toolchain:go@go1.26" {
t.Errorf("the wait is on %s", h.On())
}
}
@@ -75,7 +75,7 @@ func TestAnEntryWhoseFingerprintNamesAnotherToolchainWaitsAndIsBuiltWhenItIsAgre
t.Fatalf("release refused: %s", why)
}
r.b.Wait()
if got := valueOf(t, r.st, r.key); got.State != builds.BuildDone || got.Toolchains["go"].Version != "go1.27.1" || len(w.ended) != 1 || w.ended[0] != WaitReleased {
if got := valueOf(t, r.st, r.key); got.State != builds.BuildDone || got.Toolchains["go"].Version != "go1.27" || len(w.ended) != 1 || w.ended[0] != WaitReleased {
t.Errorf("build %+v, ended %v: want done with the running toolchain and a wait ended released", got, w.ended)
}
if why := r.b.Release(context.Background(), "m", fp1, "again", "operator"); why == "" {
@@ -555,8 +555,8 @@ func TestOnlyThePackageWithoutAKeptVerdictRuns(t *testing.T) { // 1288/AC1
t.Fatalf("verdict %+v, asks %+v: want a pass of three asks, the first naming no need", out.Verdict, asks)
}
for _, a := range asks { // ADR 0584: every check ask names the agreed toolchain, so a node off it declines
if a.Check.Toolchain == nil || a.Check.Toolchain.Version != "go1.27.1" || a.Check.Toolchain.Recipe != "7" {
t.Errorf("a check ask names toolchain %+v, want go1.27.1 recipe 7", a.Check.Toolchain)
if a.Check.Toolchain == nil || a.Check.Toolchain.Version != "go1.27" || a.Check.Toolchain.Recipe != "7" {
t.Errorf("a check ask names toolchain %+v, want go1.27 recipe 7", a.Check.Toolchain)
}
}
for _, a := range asks[1:] {
@@ -1191,7 +1191,7 @@ func TestACheckIsOneAskAndAReJudgeGoesOnTheRecheckStream(t *testing.T) {
t.Fatalf("the job = %+v", asks[0].Check)
}
// B2g: the job carries the toolchain the checker agreed (ADR 0584), with its language, so a node on another declines it.
if tc := asks[0].Check.Toolchain; tc == nil || *tc != (buildstep.ToolchainUsed{Language: "go", Version: "go1.27.1", Recipe: "7"}) {
if tc := asks[0].Check.Toolchain; tc == nil || *tc != (buildstep.ToolchainUsed{Language: "go", Version: "go1.27", Recipe: "7"}) {
t.Errorf("the job's toolchain = %+v, want the agreed go toolchain", tc)
}
cs := caseOf(t, pullOf(repoA, 7, head1))
@@ -941,7 +941,7 @@ func TestTakeIn(t *testing.T) { // 1585/T3-T13 (ADR 0633)
x := b.ix.dry().ix
for _, node := range []string{"novox", "ace"} {
key, _ := ToolchainKey(node, "go")
x.PutToolchain("mesh-build-go", key, toolchainValue(t, "go", "go1.27.2", "1"), false)
x.PutToolchain("mesh-build-go", key, toolchainValue(t, "go", "go1.28.0", "1"), false)
}
ready, _, _, _ := b.ix.loadNewest(ctx, WaitsOf(entries).Ready)
next, _, err := x.computeOver(ctx, ready)
@@ -951,11 +951,11 @@ func TestTakeIn(t *testing.T) { // 1585/T3-T13 (ADR 0633)
b.ix.ownMu.Lock()
b.ix.ownFP = next
b.ix.ownMu.Unlock()
reportToolchain(t, b.ix, "mesh-build-go", "novox", "go", "go1.27.2")
reportToolchain(t, b.ix, "mesh-build-go", "novox", "go", "go1.28.0")
if len(b.keys()) != 1 {
t.Fatalf("one node's report: pending %v, want the revision still held (the nodes disagree)", b.keys())
}
reportToolchain(t, b.ix, "mesh-build-go", "ace", "go", "go1.27.2")
reportToolchain(t, b.ix, "mesh-build-go", "ace", "go", "go1.28.0")
if len(b.keys()) != 0 || b.commit(t, "avahi") != sha('c') {
t.Errorf("after the toolchain report: pending %v, avahi at %s: want the revision taken in", b.keys(), b.commit(t, "avahi"))
}
@@ -7,14 +7,14 @@
},
"candidate": {
"base": 5,
"fpset": "01c840ec276b",
"fpset": "6ed3e0bd2a45",
"group": "feat/x",
"heads": "dfe9fb8f79e8",
"pulls": [
{
"fps": {
"avahi": {
"fp2": "src2:e8d595aea1b13f1f5578ef1f245dab0d28a351c28079ecdcd2276c63a932d7be",
"fp2": "src2:fc14d6ab7e13fd81e12df0ca9fcdcc536691cb4ea31d7efc24a25b5401efaf67",
"manifest": "8a3856b6c0566d76f2556fc4f46c5251dc7935517bb6bd15809ded7e5546a0d8"
}
},
@@ -170,13 +170,13 @@ func TestAgreedToolchainChangesAGoModulesReasonWithNoMerge(t *testing.T) { // 14
reportToolchain(t, ix, "mesh-build-go", "ace", "go", "go1.27.1")
m, _ := moduleOf(t, mods, "avahi")
// L3 (ADR 0603 §2, §3): the agreement moving rewrites the module's toolchain edge, and again when it moves on.
if g := graphOf(t, ix, "avahi"); g.FP != m.Fp2 || g.Toolchains["go"].Version != "go1.27.1" || g.Toolchains["go"].Module != "mesh-build-go" {
t.Errorf("after: graph.avahi = %+v, want the toolchain edge of go1.27.1", g)
if g := graphOf(t, ix, "avahi"); g.FP != m.Fp2 || g.Toolchains["go"].Version != "go1.27" || g.Toolchains["go"].Module != "mesh-build-go" {
t.Errorf("after: graph.avahi = %+v, want the toolchain edge of go1.27", g)
}
reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.28.0")
reportToolchain(t, ix, "mesh-build-go", "ace", "go", "go1.28.0")
if g := graphOf(t, ix, "avahi"); g.Toolchains["go"].Version != "go1.28.0" {
t.Errorf("moved on: graph.avahi = %+v, want the toolchain edge of go1.28.0", g)
if g := graphOf(t, ix, "avahi"); g.Toolchains["go"].Version != "go1.28" {
t.Errorf("moved on: graph.avahi = %+v, want the toolchain edge of go1.28", g)
}
reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1")
reportToolchain(t, ix, "mesh-build-go", "ace", "go", "go1.27.1")
@@ -283,7 +283,7 @@ func TestNodesReportingDifferentVersionsLeaveTheReasonNamingBoth(t *testing.T) {
t.Fatal(err)
}
m, _ := moduleOf(t, mods, "avahi")
if !strings.Contains(m.None2, "builders disagree") || !strings.Contains(m.None2, "go1.27.1") || !strings.Contains(m.None2, "go1.26.0") {
if !strings.Contains(m.None2, "builders disagree") || !strings.Contains(m.None2, "go1.27") || !strings.Contains(m.None2, "go1.26") {
t.Errorf("none2 = %q, want 'builders disagree' naming both versions", m.None2)
}
}
@@ -304,7 +304,7 @@ func goInputs(t *testing.T, ix *Indexer, mods *memStore, module, builder string,
t.Helper()
return fingerprint.Inputs{Module: module, Tree: "tree-" + module, Builder: builder, Bases: bases,
Locks: map[string]string{"tools": avahiGoSum},
Toolchains: map[string]meshcatalogclient.Toolchain2{"tools": {Language: "go", Version: "go1.27.1", Recipe: "1"}}}
Toolchains: map[string]meshcatalogclient.Toolchain2{"tools": {Language: "go", Version: "go1.27", Recipe: "1"}}}
}
func fp2(t *testing.T, in fingerprint.Inputs) string {
@@ -333,7 +333,7 @@ func TestBasesAreComputedFirstAndNoFingerprintTakesTheBuilder(t *testing.T) { //
t.Errorf("other: fp2 = %q none2 = %q, want none2 naming the base ts-base", m.Fp2, m.None2)
}
// L3 (ADR 0603 §2): the module graph holds each module's edges as this recompute computed them.
goTool := map[string]graph.Toolchain{"go": {Module: "mesh-build-go", Version: "go1.27.1", Recipe: "1"}}
goTool := map[string]graph.Toolchain{"go": {Module: "mesh-build-go", Version: "go1.27", Recipe: "1"}}
if g := graphOf(t, ix, "avahi"); g.FP != want["avahi"] || !reflect.DeepEqual(g.Bases, []string{"mesh-tools"}) ||
!reflect.DeepEqual(g.Toolchains, goTool) || g.Repository != catalogueRepo || g.Path != "modules/avahi" {
t.Errorf("graph.avahi = %+v", g)
@@ -359,7 +359,7 @@ func TestBasesAreComputedFirstAndNoFingerprintTakesTheBuilder(t *testing.T) { //
t.Errorf("the indexer's main = %q (%v), want cmd/mesh-delivery-indexer", MainOf(m), err)
}
if e := entries["avahi"]; e.Fp != want["avahi"] || e.Commit == "" || e.ManifestDigest == "" || !reflect.DeepEqual(e.Bases, []string{"mesh-tools"}) ||
e.Toolchains["go"] != (meshcatalog.BuildEdge{Module: "mesh-build-go", Version: "go1.27.1", Recipe: "1"}) {
e.Toolchains["go"] != (meshcatalog.BuildEdge{Module: "mesh-build-go", Version: "go1.27", Recipe: "1"}) {
t.Errorf("the catalog entry of avahi = %+v", e)
}
// W3.1's inputs (the lead's ruling on finding 1): an entry carries what the next revision is computed from (the
@@ -372,7 +372,7 @@ func TestBasesAreComputedFirstAndNoFingerprintTakesTheBuilder(t *testing.T) { //
t.Errorf("%s read back from its entry = %+v, want %+v", name, back, m)
}
}
if e := entries["avahi"]; e.Inputs == nil || e.Inputs.From == nil || e.Inputs.Toolchains["go"].Version != "go1.27.1" {
if e := entries["avahi"]; e.Inputs == nil || e.Inputs.From == nil || e.Inputs.Toolchains["go"].Version != "go1.27" {
t.Errorf("the catalog entry of avahi carries inputs %+v, want what its fingerprint is computed from", e.Inputs)
}
rev, objects, err := CatalogRevisionOf(meshcatalog.CatalogRevision{Revision: 1, Kind: "trunk", Source: 7}, entries)
@@ -799,7 +799,7 @@ func TestAModuleKeepsTheToolchainsItsFingerprintWasComputedWith(t *testing.T) {
}
reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1")
m, _ := moduleOf(t, mods, "avahi")
want := map[string]meshcatalog.ToolchainUsed{"go": {Version: "go1.27.1", Recipe: "1"}}
want := map[string]meshcatalog.ToolchainUsed{"go": {Version: "go1.27", Recipe: "1"}}
if m.Fp2 == "" || !reflect.DeepEqual(m.Toolchains, want) {
t.Fatalf("avahi: fp2 %q toolchains %+v, want %+v", m.Fp2, m.Toolchains, want)
}
@@ -807,9 +807,9 @@ func TestAModuleKeepsTheToolchainsItsFingerprintWasComputedWith(t *testing.T) {
t.Errorf("a module with no fingerprint carries toolchains %+v", o.Toolchains)
}
// An upgrade moves the fingerprint and the toolchains together, with no merge.
reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.2")
reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.28.0")
n, _ := moduleOf(t, mods, "avahi")
if n.Fp2 == m.Fp2 || n.Toolchains["go"].Version != "go1.27.2" {
if n.Fp2 == m.Fp2 || n.Toolchains["go"].Version != "go1.28" {
t.Errorf("after the upgrade: fp2 %q (was %q) toolchains %+v, want the new version with the new fingerprint", n.Fp2, m.Fp2, n.Toolchains)
}
// Issue 1585 (ADR 0573 §2): a module whose go.sum names mesh-sdk takes mesh-sdk's latest published version into its
@@ -863,7 +863,7 @@ func TestAModuleKeepsTheToolchainsItsFingerprintWasComputedWith(t *testing.T) {
t.Errorf("a new tree while nodes disagree: fp2 %q toolchains %+v none2 %q, want no fingerprint and the disagreement", d.Fp2, d.Toolchains, d.None2)
}
// They agree again: the new tree gets its fingerprint.
reportToolchain(t, ix, "mesh-build-go", "ace", "go", "go1.27.2")
reportToolchain(t, ix, "mesh-build-go", "ace", "go", "go1.28.0")
if a, _ := moduleOf(t, mods, "avahi"); a.Fp2 == "" || a.Fp2 == n.Fp2 {
t.Errorf("agreed again: fp2 %q (was %q), want a new fingerprint", a.Fp2, n.Fp2)
}
@@ -13,6 +13,35 @@ import (
// ToolchainNoReport is the reason AgreedToolchain gives when no node has reported a language's toolchain.
const ToolchainNoReport = "toolchain not yet reported"
// LanguageVersion is the version of a language a toolchain is agreed, reported and named by (design 47 G, A-471): its
// major.minor, so "go1.27.4-X:nodwarf5" and "go1.27.3" are "go1.27" and "v26.13.1" is "v26.13". A text before the first
// digit (go, v) is kept. A version with no major.minor is returned as it is.
func LanguageVersion(version string) string {
start := strings.IndexAny(version, "0123456789")
if start < 0 {
return version
}
end, dots := start, 0
for end < len(version) {
c := version[end]
if c >= '0' && c <= '9' {
end++
} else if c == '.' && dots == 0 && end+1 < len(version) && version[end+1] >= '0' && version[end+1] <= '9' {
dots++
end++
} else {
break
}
}
if dots == 0 {
return version
}
return version[:end]
}
// SameToolchainVersion is whether two installed versions are one language version (LanguageVersion).
func SameToolchainVersion(a, b string) bool { return LanguageVersion(a) == LanguageVersion(b) }
// NodeToolchain is one node's entry of a language, as read from a build seat's state toolchains (the entry is Toolchain).
type NodeToolchain struct {
Node string
@@ -38,7 +67,7 @@ type Agreement struct {
Wait string
}
// ToolchainAgreement is the agreed toolchain of a language: the version and recipe a strict majority of the reporting
// ToolchainAgreement is the agreed toolchain of a language: the language version (LanguageVersion: the patch is not counted, A-471) and recipe a strict majority of the reporting
// nodes report (novox/hq ADR 0584 clause 1). With no strict majority (two against two) or no entry it gives no toolchain
// and says why in Wait. The answer does not depend on the entries' order. The entries must all be of one language.
func ToolchainAgreement(entries []NodeToolchain) Agreement {
@@ -48,15 +77,15 @@ func ToolchainAgreement(entries []NodeToolchain) Agreement {
type identity struct{ Language, Version, Recipe string }
groups := map[identity][]string{}
for _, e := range entries {
k := identity{e.Language, e.Version, e.Recipe}
k := identity{e.Language, LanguageVersion(e.Version), e.Recipe}
groups[k] = append(groups[k], e.Node)
}
for k, nodes := range groups {
if 2*len(nodes) > len(entries) {
a := Agreement{Toolchain: Toolchain{Language: k.Language, Version: k.Version, Recipe: k.Recipe}}
for _, e := range entries {
if e.Version != k.Version || e.Recipe != k.Recipe {
a.SittingOut = append(a.SittingOut, SittingOut{Node: e.Node, Version: e.Version, Recipe: e.Recipe})
if LanguageVersion(e.Version) != k.Version || e.Recipe != k.Recipe {
a.SittingOut = append(a.SittingOut, SittingOut{Node: e.Node, Version: LanguageVersion(e.Version), Recipe: e.Recipe})
}
}
sort.Slice(a.SittingOut, func(i, j int) bool { return a.SittingOut[i].Node < a.SittingOut[j].Node })
@@ -19,12 +19,14 @@ func TestToolchainAgreement(t *testing.T) {
out []SittingOut
wait []string // "" wait means agreed
}{
{"all agree", []NodeToolchain{e("ace", "go", "1.26.1", "3"), e("novox", "go", "1.26.1", "3")}, "1.26.1", nil, nil},
{"all agree", []NodeToolchain{e("ace", "go", "1.26.1", "3"), e("novox", "go", "1.26.1", "3")}, "1.26", nil, nil},
{"patches differ", []NodeToolchain{e("g14", "go", "go1.27.4-X:nodwarf5", "3"), e("ace", "go", "go1.27.3", "3"), e("novox", "go", "go1.27.3", "3")}, "go1.27", nil, nil},
{"recipes differ", []NodeToolchain{e("shanks", "typescript", "v26.13.0", "f2"), e("ace", "typescript", "v26.13.0", "f5"), e("novox", "typescript", "v26.13.0", "f5"), e("g14", "typescript", "v26.13.1", "f5")}, "v26.13", []SittingOut{{"shanks", "v26.13", "f2"}}, nil},
{"three against one", []NodeToolchain{e("ace", "typescript", "26.12.1", "3"), e("g14", "typescript", "26.13.0", "3"), e("novox", "typescript", "26.13.0", "3"), e("shanks", "typescript", "26.13.0", "3")},
"26.13.0", []SittingOut{{"ace", "26.12.1", "3"}}, nil},
{"two against two", []NodeToolchain{e("ace", "go", "1.26.1", "3"), e("novox", "go", "1.26.2", "3"), e("g14", "go", "1.26.1", "3"), e("shanks", "go", "1.26.2", "3")},
"", nil, []string{"builders disagree", "1.26.1 recipe 3 on ace, g14", "1.26.2 recipe 3 on novox, shanks"}},
{"one node alone", []NodeToolchain{e("ace", "go", "1.26.1", "3")}, "1.26.1", nil, nil},
"26.13", []SittingOut{{"ace", "26.12", "3"}}, nil},
{"two against two", []NodeToolchain{e("ace", "go", "1.26.1", "3"), e("novox", "go", "1.27.2", "3"), e("g14", "go", "1.26.1", "3"), e("shanks", "go", "1.27.2", "3")},
"", nil, []string{"builders disagree", "1.26 recipe 3 on ace, g14", "1.27 recipe 3 on novox, shanks"}},
{"one node alone", []NodeToolchain{e("ace", "go", "1.26.1", "3")}, "1.26", nil, nil},
{"no report", nil, "", nil, []string{ToolchainNoReport}},
} {
a := ToolchainAgreement(c.in)
@@ -71,3 +73,18 @@ func TestToolchainKeyParsesBack(t *testing.T) {
}
}
}
// A-471: a toolchain is named by its language version, Go's and Node's major.minor, the patch and the build's suffix not counted.
func TestLanguageVersion(t *testing.T) {
for in, want := range map[string]string{
"go1.27.4-X:nodwarf5": "go1.27", "go1.27.3": "go1.27", "go1.27": "go1.27", "1.26.1": "1.26",
"v26.13.0": "v26.13", "v26.13.1": "v26.13", "v26": "v26", "go": "go", "": "",
} {
if got := LanguageVersion(in); got != want {
t.Errorf("LanguageVersion(%q) = %q, want %q", in, got, want)
}
}
if !SameToolchainVersion("go1.27.3", "go1.27.4-X:nodwarf5") || SameToolchainVersion("go1.27.3", "go1.28.0") {
t.Error("SameToolchainVersion does not compare the language version")
}
}
+2 -1
View File
@@ -159,11 +159,12 @@ func (s AskSteps) onToolchain(ctx context.Context, want *sdkstep.ToolchainUsed)
if err != nil {
return nil, err
}
if tc.Version != want.Version || tc.Recipe != want.Recipe {
if !sdkstep.SameToolchainVersion(tc.Version, want.Version) || tc.Recipe != want.Recipe {
return nil, &Declining{Lacks: []string{fmt.Sprintf("the agreed toolchain %s (recipe %s)", want.Version, want.Recipe)},
Text: fmt.Sprintf("the ask is for %s (recipe %s) and this node builds with %s (recipe %s): it sits out, and the ask is left to a node on the agreed toolchain",
want.Version, want.Recipe, tc.Version, tc.Recipe)}
}
tc.Version = sdkstep.LanguageVersion(tc.Version) // named by its language version, the patch not counted (A-471)
return &tc, nil
}
@@ -141,6 +141,24 @@ func TestRunAskRefusesAnotherToolchain(t *testing.T) {
}
}
// A-471: a node whose installed patch differs from the ask's takes it: the ask names go1.27, the node builds with
// go1.27.4-X:nodwarf5, and its answer names the language version.
func TestRunAskTakesAnotherPatchOfTheLanguageVersion(t *testing.T) {
r := &recorder{fetch: map[string]any{"workspace": "/w"}}
s := r.steps()
s.Toolchain = func(context.Context) (sdkstep.ToolchainUsed, error) {
return sdkstep.ToolchainUsed{Version: "go1.27.4-X:nodwarf5", Recipe: "3"}, nil
}
out, err := RunAsk(context.Background(), s, ask(sdkstep.BuildJob{Module: "m", Path: ".", Fetch: &sdkstep.Fetch{Repository: "novox/x", Commit: runCommit},
Artifacts: []sdkstep.AskArtifact{{Artifact: "bundle"}}, Toolchain: &sdkstep.ToolchainUsed{Version: "go1.27", Recipe: "3"}}))
if err != nil {
t.Fatalf("err %v", err)
}
if tc := out.(sdkstep.BuildAnswer).Toolchain; tc == nil || tc.Version != "go1.27" {
t.Errorf("the answer names %+v, want go1.27", tc)
}
}
// 1887/A3, A5a: a check ask runs the levels of one check after one fetch: it digests the unit level, takes the kept
// verdicts, tests the packages whose tests changed first and then the others, also after one of them failed, and runs
// every level, also after one that did not pass, so one check names every failure (the operator, 2026-11-02).
+2 -2
View File
@@ -37,14 +37,14 @@ func (g Guard) Check(ctx context.Context) error {
if err != nil {
return err
}
raw, err := sdkstep.EncodeToolchain(sdkstep.Toolchain{Language: g.Language, Version: installed, Recipe: g.Recipe, At: now().UTC()})
raw, err := sdkstep.EncodeToolchain(sdkstep.Toolchain{Language: g.Language, Version: sdkstep.LanguageVersion(installed), Recipe: g.Recipe, At: now().UTC()})
if err != nil {
return err
}
if _, err := g.Put(key, json.RawMessage(raw)); err != nil {
return fmt.Errorf("steprun: writing the toolchain %s: %w", key, err)
}
if installed != g.Want {
if !sdkstep.SameToolchainVersion(installed, g.Want) {
return &Refusal{Text: fmt.Sprintf("%s %s installed, the recipe builds with %s %s", g.Language, installed, g.Language, g.Want),
Want: g.Want, Have: installed}
}
@@ -33,24 +33,36 @@ func TestCheckPassesAndWritesTheToolchain(t *testing.T) {
t.Fatal(err)
}
tc, ok := k["ace.go"]
if !ok || tc.Version != "1.27.0" || tc.Recipe != "r7" || tc.Language != "go" || tc.At.IsZero() {
if !ok || tc.Version != "1.27" || tc.Recipe != "r7" || tc.Language != "go" || tc.At.IsZero() {
t.Errorf("keys = %+v", k)
}
}
// A-471: the patch is not counted: a node on another patch of the recipe's language version passes, and its key holds the
// language version alone.
func TestCheckPassesAnotherPatchAndWritesTheLanguageVersion(t *testing.T) {
k := toolchainKeys{}
if err := guardFor(k, "1.27.4-X:nodwarf5", nil).Check(context.Background()); err != nil {
t.Fatal(err)
}
if v := k["ace.go"].Version; v != "1.27" {
t.Errorf("the key holds %q, want 1.27", v)
}
}
// 1473/AC2: another version: a Refusal naming both, and the key holds the installed version.
func TestCheckRefusesAnotherVersionAndWritesTheInstalledOne(t *testing.T) {
k := toolchainKeys{}
err := guardFor(k, "1.27.1", nil).Check(context.Background())
err := guardFor(k, "1.28.1", nil).Check(context.Background())
var ref *Refusal
if !errors.As(err, &ref) {
t.Fatalf("Check = %v, want a Refusal", err)
}
if ref.Text != "go 1.27.1 installed, the recipe builds with go 1.27.0" || ref.Want != "1.27.0" || ref.Have != "1.27.1" {
if ref.Text != "go 1.28.1 installed, the recipe builds with go 1.27.0" || ref.Want != "1.27.0" || ref.Have != "1.28.1" {
t.Errorf("refusal = %+v", ref)
}
if k["ace.go"].Version != "1.27.1" {
t.Errorf("the key holds %q, want the installed 1.27.1", k["ace.go"].Version)
if k["ace.go"].Version != "1.28" {
t.Errorf("the key holds %q, want the installed 1.28", k["ace.go"].Version)
}
}