Name build-agent's own as the builder's module, build-agent and mesh-tools (ADR 0520 §1, issue 1851)

ADR 0520 narrowed after its review: mesh-tools-go builds from its own
directory on a pinned base and has its key from mesh-build-image, and
mesh-tools-python is no module, so the set is named, not derived from
the toolchain bases.
This commit is contained in:
2026-10-22 21:08:47 +02:00
parent 61f7e89ad5
commit 61449249a8
3 changed files with 22 additions and 36 deletions
+16 -10
View File
@@ -60,11 +60,12 @@ func TestAWalkAsksBuildAgentForTheBuildersOwnModuleAlone(t *testing.T) {
} }
} }
// ADR 0520 (issue 1851): until R4g build-agent and the toolchain images its builds stand on are build-agent's own, as the // ADR 0520 §1 (issue 1851): until R4g build-agent and mesh-tools, the toolchain image its builds stand on, are build-agent's
// builder's module is: the builder writes no key of them, so a walk asks build-agent for them and reads no key; any other // own, as the builder's module is: the builder writes no key of them, so a walk asks build-agent for them and reads no key;
// module of the same tier is still taken from its key. // mesh-tools-go (its key from mesh-build-image) and any other module of the same tier are still taken from their keys.
func TestAWalkAsksBuildAgentForItselfAndItsToolchainsAndReadsNoKeyOfThem(t *testing.T) { func TestAWalkAsksBuildAgentForItselfAndMeshToolsAndReadsNoKeyOfThem(t *testing.T) {
own := []string{"build-agent", "mesh-tools", "mesh-tools-go", "mesh-tools-python"} own := []string{"build-agent", "mesh-tools"}
keyed := []string{"mesh-tools-go", "sudo"}
wasModule := askedModuleOf wasModule := askedModuleOf
askedModuleOf = func(_ context.Context, _ buildSource, path string) (string, error) { askedModuleOf = func(_ context.Context, _ buildSource, path string) (string, error) {
return strings.TrimPrefix(path, "modules/"), nil return strings.TrimPrefix(path, "modules/"), nil
@@ -75,6 +76,9 @@ func TestAWalkAsksBuildAgentForItselfAndItsToolchainsAndReadsNoKeyOfThem(t *test
t.Fatalf("an ask of %s is refused: %v", m, err) t.Fatalf("an ask of %s is refused: %v", m, err)
} }
} }
if err := onlyTheBuildersOwn(t.Context(), buildSource{Repository: "novox/x", Seat: "git"}, "modules/mesh-tools-go"); !errors.Is(err, errNotTheBuildersOwn) {
t.Fatalf("an ask of mesh-tools-go went on: %v", err)
}
var asked []string var asked []string
was := askABuild was := askABuild
askABuild = func(_ context.Context, _ buildSource, path, _ string) (string, error) { askABuild = func(_ context.Context, _ buildSource, path, _ string) (string, error) {
@@ -83,8 +87,8 @@ func TestAWalkAsksBuildAgentForItselfAndItsToolchainsAndReadsNoKeyOfThem(t *test
} }
t.Cleanup(func() { askABuild = was }) t.Cleanup(func() { askABuild = was })
p, byName := aWalkOfOne("sudo") p, byName := aWalkOfOne("sudo")
p.Tiers = [][]string{append(append([]string{}, own...), "sudo")} p.Tiers = [][]string{append(append([]string{}, own...), keyed...)}
for _, m := range own { for _, m := range append(append([]string{}, own...), keyed...) {
e := byName["sudo"] e := byName["sudo"]
e.Source.Path = "modules/" + m e.Source.Path = "modules/" + m
byName[m] = e byName[m] = e
@@ -92,7 +96,7 @@ func TestAWalkAsksBuildAgentForItselfAndItsToolchainsAndReadsNoKeyOfThem(t *test
for _, m := range p.Tiers[0] { for _, m := range p.Tiers[0] {
askModule(t.Context(), p, m, byName) askModule(t.Context(), p, m, byName)
} }
if strings.Join(asked, " ") != "modules/build-agent modules/mesh-tools modules/mesh-tools-go modules/mesh-tools-python" { if strings.Join(asked, " ") != "modules/build-agent modules/mesh-tools" {
t.Fatalf("build-agent was asked for %v", asked) t.Fatalf("build-agent was asked for %v", asked)
} }
for _, m := range own { for _, m := range own {
@@ -100,7 +104,9 @@ func TestAWalkAsksBuildAgentForItselfAndItsToolchainsAndReadsNoKeyOfThem(t *test
t.Fatalf("%s is not asked of build-agent, or is read from a key: %+v", m, s) t.Fatalf("%s is not asked of build-agent, or is read from a key: %+v", m, s)
} }
} }
if s := p.Modules["sudo"]; !s.Key || s.Build != "" { for _, m := range keyed {
t.Fatalf("the other module is not taken from its key: %+v", s) if s := p.Modules[m]; !s.Key || s.Build != "" {
t.Fatalf("%s is not taken from its key: %+v", m, s)
}
} }
} }
+6 -11
View File
@@ -25,19 +25,14 @@ import (
// **No timer**: the builder's and the indexer's writes wake the look (builderkeys.Watch, watchNewModules). // **No timer**: the builder's and the indexer's writes wake the look (builderkeys.Watch, watchNewModules).
// isBuildersOwn says a module is build-agent's own: asked of build-agent on a merge and taken from its build record, never // isBuildersOwn says a module is build-agent's own: asked of build-agent on a merge and taken from its build record, never
// from the builder's key, until R4g (ADR 0453 §5, ADR 0498 §7, ADR 0520). They are the builder's module, build-agent itself // from the builder's key, until R4g (ADR 0453 §5, ADR 0498 §7, ADR 0520 §1).
// (its image's context is another repository's) and the toolchain images build-agent's builds stand on
// (builder.Bases): the builder writes no key of any of them, and a walk waiting for one would hold its tier for ever.
func isBuildersOwn(module string) bool { return buildersOwn(module) } func isBuildersOwn(module string) bool { return buildersOwn(module) }
// buildAgentsOwn are those modules: the builder's, build-agent's and every toolchain's base, read from the toolchains. // buildAgentsOwn are those modules, named (ADR 0520 §1): the builder's; build-agent itself, whose image's context is another
var buildAgentsOwn = func() map[string]bool { // repository's; and mesh-tools, the toolchain image build-agent's builds stand on. The builder writes no key of any of them,
own := map[string]bool{sdkdelivery.BuilderModule: true, builder.AgentModule: true} // and a walk waiting for one would hold its tier for ever. mesh-tools-go is not among them: it builds from a Dockerfile in
for _, b := range builder.Bases() { // its own directory on a pinned base, and has its key from mesh-build-image.
own[b] = true var buildAgentsOwn = map[string]bool{sdkdelivery.BuilderModule: true, builder.AgentModule: true, "mesh-tools": true}
}
return own
}()
// buildersOwn is isBuildersOwn's rule: a variable only so a test of the asks left (their bus waits, their plan key) may // buildersOwn is isBuildersOwn's rule: a variable only so a test of the asks left (their bus waits, their plan key) may
// name modules of its own as build-agent's. // name modules of its own as build-agent's.
-15
View File
@@ -237,21 +237,6 @@ func spoken() string {
// AgentModule is build-agent's own module: the machine's builder, whose image is built from another repository's context. // AgentModule is build-agent's own module: the machine's builder, whose image is built from another repository's context.
const AgentModule = "build-agent" const AgentModule = "build-agent"
// Bases are the modules whose artifacts provide the toolchains' compilers (Toolchain.Base), each once, sorted: images
// build-agent's builds stand on.
func Bases() []string {
seen := map[string]bool{}
var out []string
for _, t := range toolchains {
if t.Base != "" && !seen[t.Base] {
seen[t.Base] = true
out = append(out, t.Base)
}
}
sort.Strings(out)
return out
}
func Languages() []string { func Languages() []string {
names := make([]string, 0, len(toolchains)) names := make([]string, 0, len(toolchains))
for _, t := range toolchains { for _, t := range toolchains {