From a8adda1a8c172ae78aed4f2e3acbc44777174505 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 18:09:07 +0100 Subject: [PATCH] mesh-delivery-pipeline: a build module's own inputs await not its toolchain edge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A pipeline moving the Go build module with a package it imports (mesh-sdk, mesh-delivery-contracts) placed nothing: the package's build awaited the new build module's files, the build module awaited the package. What a build module's new version is built from is built by its running version. Builds: design 47 G §270, G-22 A-326, H §746, H-A-83 (2) --- .../internal/pipeline/order.go | 27 ++++++++++- .../internal/pipeline/order_test.go | 47 +++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/order.go b/modules/mesh-delivery-pipeline/internal/pipeline/order.go index cf0000b6..59838981 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/order.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/order.go @@ -137,7 +137,9 @@ func components(movers []seat.Mover, after map[string][]string) map[string]int { var buildKinds = []int64{3, 1} // awaited are the artifact references mover m's steps wait for in p (§746, H-A-51): the From of each edge of a build kind -// into m from another mover of p, toolchain edges first, each once. +// into m from another mover of p, toolchain edges first, each once. A toolchain edge (kind 3) from a build module whose +// own new version is built from m is not awaited: what a build module's new version is built from is built by its +// running version, never waited for (G §270, A-326), so the running build module builds m and the new one the rest. func awaited(p seat.Pipeline, m string, entries map[string]catalog.CatalogEntry) []catalog.Edge { var out []catalog.Edge for _, kind := range buildKinds { @@ -146,12 +148,35 @@ func awaited(p seat.Pipeline, m string, entries map[string]catalog.CatalogEntry) if x.Kind != kind || from == m || !Moves(p, from) || slices.ContainsFunc(out, func(e catalog.Edge) bool { return e.From == x.From }) { continue } + if kind == 3 && builtFrom(p, from, entries)[m] { + continue + } out = append(out, x) } } return out } +// builtFrom are the movers of p that module's new version is built from (G §270): the From mover of each edge of a build +// kind into it, and what those are built from in turn. +func builtFrom(p seat.Pipeline, module string, entries map[string]catalog.CatalogEntry) map[string]bool { + seen := map[string]bool{} + next := []string{module} + for len(next) > 0 { + cur := next[0] + next = next[1:] + for _, x := range entries[cur].Edges { + from := moduleOf(x.From) + if !slices.Contains(buildKinds, x.Kind) || from == cur || seen[from] || !Moves(p, from) { + continue + } + seen[from] = true + next = append(next, from) + } + } + return seen +} + // ready says whether mover m of p may be placed (§746, H-A-84): every artifact it awaits is in its From mover's published. // It answers the references still awaited, and the first From mover whose build ended without passing, so m never builds. func ready(p seat.Pipeline, m string, entries map[string]catalog.CatalogEntry) (bool, []string, string) { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go index a5dff3bb..d5cc86e0 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/order_test.go @@ -124,3 +124,50 @@ func TestAMoversBuildWaitsForItsDependenciesInThePipeline(t *testing.T) { } } } + +// Design 47 G §270, A-326 (H §746, H-A-83 (2)): what a build module's new version is built from is built by its running +// version, never waited for: a mover the moving build module imports, directly or through another mover, does not await +// that build module's toolchain edge, so a pipeline moving mesh-sdk or the contracts with the Go build module places them +// at once (main.28, main.30 of 2026-11-20 waited on each other forever); every other mover still awaits the new one. +func TestAToolchainEdgeIsNotAwaitedByTheBuildModulesOwnInputs(t *testing.T) { + e := func(from, to string, kind int64) catalog.Edge { return catalog.Edge{From: from, To: to, Kind: kind} } + entries := map[string]catalog.CatalogEntry{ + "mesh-sdk": {Edges: []catalog.Edge{e("mesh-build-go:files", "mesh-sdk:go", 3)}}, + "contracts": {Edges: []catalog.Edge{e("mesh-build-go:files", "contracts:go-a", 3), e("mesh-build-go:files", "contracts:go-b", 3)}}, + "delivery-sdk": {Edges: []catalog.Edge{e("mesh-build-go:files", "delivery-sdk:go", 3), e("mesh-sdk:go", "delivery-sdk:go", 1)}}, + "mesh-build-go": {Edges: []catalog.Edge{e("contracts:go-a", "mesh-build-go:tools", 1), e("delivery-sdk:go", "mesh-build-go:tools", 1), e("nats:tools", "mesh-build-go:files", 4)}}, + "zfs": {Edges: []catalog.Edge{e("mesh-build-go:files", "zfs:tools", 3), e("contracts:go-a", "zfs:tools", 1)}}, + "tool": {Edges: []catalog.Edge{e("builder:program", "tool:program", 3)}}, + "builder": {}, + } + pipe := func(modules ...string) seat.Pipeline { + var p seat.Pipeline + for _, m := range modules { + p.Movers = append(p.Movers, seat.Mover{Module: m}) + } + return p + } + all := pipe("mesh-sdk", "contracts", "delivery-sdk", "mesh-build-go", "zfs") + for _, c := range []struct { + name string + p seat.Pipeline + mover string + want []string + }{ + {"the build module's own package input awaits no toolchain edge", all, "contracts", nil}, + {"an input through another mover awaits no toolchain edge", all, "mesh-sdk", nil}, + {"an input that imports another input awaits only that package", all, "delivery-sdk", []string{"mesh-sdk:go"}}, + {"the build module awaits its inputs' packages", all, "mesh-build-go", []string{"contracts:go-a", "delivery-sdk:go"}}, + {"any other mover awaits the new build module first", all, "zfs", []string{"mesh-build-go:files", "contracts:go-a"}}, + {"a build module that is not built from the mover is awaited", pipe("tool", "builder"), "tool", []string{"builder:program"}}, + {"a build module that does not move is not awaited", pipe("tool"), "tool", nil}, + } { + var got []string + for _, x := range awaited(c.p, c.mover, entries) { + got = append(got, x.From) + } + if !slices.Equal(got, c.want) { + t.Errorf("%s: %s awaits %v, want %v", c.name, c.mover, got, c.want) + } + } +}