From dc507ec9ff27e1ce4e8bba38960c44a65a3d2fd4 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 22:13:20 +0100 Subject: [PATCH 1/3] H-A-186, H-A-188: declare diskreadings as a package artifact; the gate accepts asks at 0.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit disk-load's Go package diskreadings is imported by mesh-grants, whose build waits for a publish no release made: an imported mesh package is a declared artifact of its module, so every release publishes it. The gate imports the assigner's asks, published in the assigner's series 0.3, so it names that series in its packages. Builds: design 47 H H-A-186, H-A-188, H-A-198, G §370 --- modules/disk-load/module.json | 9 +++++++++ modules/mesh-delivery-gate/module.json | 1 + 2 files changed, 10 insertions(+) diff --git a/modules/disk-load/module.json b/modules/disk-load/module.json index 3d33aecb9..a2798476a 100644 --- a/modules/disk-load/module.json +++ b/modules/disk-load/module.json @@ -24,6 +24,15 @@ "loads": [ "disk-load" ] + }, + { + "name": "diskreadings", + "kind": "package", + "language": "go", + "paths": [ + "diskreadings" + ], + "series": "0.1" } ] }, diff --git a/modules/mesh-delivery-gate/module.json b/modules/mesh-delivery-gate/module.json index e01d2a89a..94b485b45 100644 --- a/modules/mesh-delivery-gate/module.json +++ b/modules/mesh-delivery-gate/module.json @@ -291,6 +291,7 @@ } ], "packages": { + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-assigner/asks": "0.3", "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-forge-bridge/forgemsg": "0.1" }, "invokes": [ -- 2.54.0 From 3fd2e58072446fd65cbaccb4b51d79874dc0c559 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 22:20:12 +0100 Subject: [PATCH 2/3] H-A-192: the Go build module refuses a requirement with no pin of its own MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Given no pin, the module took the version of another package of the same repository, or the latest, and built against versions never published. A requirement of another repository is now taken at the pin the ask names for its own path, else the build fails naming the path; a same-repository requirement is still built from the fetched tree. Builds: design 47 H H-A-192, H-A-198, G §370 --- .../mesh-build-go/cmd/mesh-build-go/pins.go | 30 +++++------------ .../cmd/mesh-build-go/pins_test.go | 32 +++++++++++-------- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/modules/mesh-build-go/cmd/mesh-build-go/pins.go b/modules/mesh-build-go/cmd/mesh-build-go/pins.go index 00c5e900c..6ae7c685d 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/pins.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/pins.go @@ -365,9 +365,9 @@ func (m *Module) takeReplacedZeroPins(ctx context.Context, root, repository, dir } // takeZeroRequirements takes, for each requirement at the zero version, the version it is built against (ADR 0573 §2, -// §4: whatever go.mod names): the commit the ask names for the package; else the head of the package's repository among -// the asked versions (the check's or try's members: another package of the same repository names it); else the latest -// published version, the trunk's head. It never looks for the commit 000000000000 among the pull request heads. One +// §4: whatever go.mod names): a module of the checked repository from the fetched tree (H-A-198); any other at the pin +// the ask names for that package path, and with no pin it refuses the build, never taking another path's version or +// the latest (design 47 H, H-A-192). It never looks for the commit 000000000000 among the pull request heads. One // taken before (dir's modfile requires or replaces it) is left as it is. func (m *Module) takeZeroRequirements(ctx context.Context, root, repository, dir, d string, reqs []zeroRequirement, asked sdkstep.PackageVersions, pins *sync.Mutex) ([]TakenVersion, error) { resolved := map[string]string{} @@ -409,13 +409,13 @@ func (m *Module) takeZeroRequirements(ctx context.Context, root, repository, dir taken = append(taken, tv) continue } - tv := TakenVersion{Dir: d, Package: p.module, Asked: askedFor(asked, p), Named: named} - why := "the ask names it" + // The ask's pin for this path alone: a build module given no pin refuses the build, loud, and never takes another + // path's version nor the latest (design 47 H, H-A-192). + tv := TakenVersion{Dir: d, Package: p.module, Asked: asked[p.module], Named: named} if tv.Asked == "" { - tv.Asked, why = "latest", "the ask names no commit of its repository, so its latest published version" - } else if _, ok := asked[p.module]; !ok { - why = "the head of its repository among the asked versions" + return taken, fmt.Errorf("no pin for %s: the builder pins or waits (H-A-192)", p.module) } + why := "the ask names it" if err := m.takeVersion(ctx, root, dir, &tv, pins); err != nil { return taken, fmt.Errorf("the requirement of %s at the zero version: %w", p.module, err) } @@ -431,20 +431,6 @@ func (m *Module) takeZeroRequirements(ctx context.Context, root, repository, dir // namedBySaid says that a module dir replaces by the directory by names a package, and dir's go.mod does not. func namedBySaid(by string) string { return "named by " + by + ", not by this go.mod" } -// askedFor is the commit the ask names for the package p: its own, else that of the first package of the same repository -// in order (the members' heads are by repository), else none. -func askedFor(asked sdkstep.PackageVersions, p pin) string { - if c := asked[p.module]; c != "" { - return c - } - for _, pkg := range slices.Sorted(maps.Keys(asked)) { - if pkg == forgePrefix+p.repo || strings.HasPrefix(pkg, forgePrefix+p.repo+"/") { - return asked[pkg] - } - } - return "" -} - // useOwnModules replaces, in dir's temporary modfile, every module of the fetched tree whose path lies in the repository // repo by its directory in the tree (once), and answers the paths of those modules. A replace of a module dir does not // require is harmless to Go; one module of a repository requires another of it at the zero version. diff --git a/modules/mesh-build-go/cmd/mesh-build-go/pins_test.go b/modules/mesh-build-go/cmd/mesh-build-go/pins_test.go index 920da2bc4..a55468fc6 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/pins_test.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/pins_test.go @@ -301,10 +301,10 @@ func TestARelativeReplaceStillResolvesInTheTemporaryModfile(t *testing.T) { } // A go.mod requirement at the zero version v0.0.0-00010101000000-000000000000 names no commit (ADR 0573 §2, §4: whatever -// go.mod names): it is taken from the commit the ask names for the package, else from the head of its repository among -// the asked versions, else from the trunk's latest published version, and never looked for as the commit 000000000000 -// among the pull request heads. -func TestARequirementAtTheZeroVersionIsTakenFromTheAskOrTheTrunk(t *testing.T) { +// go.mod names): it is taken from the pin the ask names for that package path alone, and never looked for as the commit +// 000000000000 among the pull request heads. With no pin of its own the build is refused, loud, naming the path: never +// built at another package's pin of the same repository nor at the latest (design 47 H, H-A-192). +func TestARequirementAtTheZeroVersionIsTakenFromItsPinOrRefused(t *testing.T) { t.Parallel() const sdk = "git.novox.be/novox/mesh-sdk/go" zeroMod := "module fixture/member\n\ngo 1.26\n\nrequire (\n\t" + sdk + " v0.0.0-00010101000000-" + zeroShort + "\n)\n" @@ -314,6 +314,7 @@ func TestARequirementAtTheZeroVersionIsTakenFromTheAskOrTheTrunk(t *testing.T) { packages map[string]any download string // what go mod download -json answers want string // the version asked of go + refused bool // the step fails, naming the path: the ask carries no pin for it (H-A-192) head bool // the asked commit is on no trunk: only a pull request head carries it // replaced: the directory's go.mod names no mesh package; a module it replaces by a directory of the tree requires // it at the zero version, so go mod download passes and only a shut-off package load would look it up (1966/AC178-1) @@ -321,18 +322,14 @@ func TestARequirementAtTheZeroVersionIsTakenFromTheAskOrTheTrunk(t *testing.T) { }{ {name: "the ask names the package", packages: map[string]any{sdk: trunk}, want: sdk + "@" + trunk, download: `{"Version":"v0.1.15-0.20261101000000-aaaaaaaaaaaa","Sum":"h1:zip="}`}, - {name: "the ask names another package of its repository", packages: map[string]any{"git.novox.be/novox/mesh-sdk/other": trunk}, want: sdk + "@" + trunk, - download: `{"Version":"v0.1.15-0.20261101000000-aaaaaaaaaaaa","Sum":"h1:zip="}`}, - {name: "the ask names the root of its repository, which no package of is published", packages: map[string]any{"git.novox.be/novox/mesh-sdk": trunk}, want: sdk + "@" + trunk, - download: `{"Version":"v0.1.15-0.20261101000000-aaaaaaaaaaaa","Sum":"h1:zip="}`}, + {name: "the ask pins only another package of its repository", packages: map[string]any{"git.novox.be/novox/mesh-sdk/other": trunk}, refused: true}, + {name: "the ask pins only the root of its repository", packages: map[string]any{"git.novox.be/novox/mesh-sdk": trunk}, refused: true}, {name: "the ask names the head of a pull request", packages: map[string]any{sdk: commitSHA}, want: sdk + "@" + commitSHA, head: true}, - {name: "the ask names nothing of its repository", packages: map[string]any{"git.novox.be/novox/mesh-tools/go": trunk}, want: sdk + "@latest", - download: `{"Version":"v0.1.20-0.20261104000000-bbbbbbbbbbbb","Sum":"h1:zip="}`}, - {name: "no ask", want: sdk + "@latest", download: `{"Version":"v0.1.20-0.20261104000000-bbbbbbbbbbbb","Sum":"h1:zip="}`}, + {name: "the ask names nothing of its repository", packages: map[string]any{"git.novox.be/novox/mesh-tools/go": trunk}, refused: true}, + {name: "no ask", refused: true}, {name: "named only by a module the directory replaces, the ask names it", packages: map[string]any{sdk: trunk}, want: sdk + "@" + trunk, replaced: true, download: `{"Version":"v0.1.15-0.20261101000000-aaaaaaaaaaaa","Sum":"h1:zip="}`}, - {name: "named only by a module the directory replaces, no ask", want: sdk + "@latest", replaced: true, - download: `{"Version":"v0.1.20-0.20261104000000-bbbbbbbbbbbb","Sum":"h1:zip="}`}, + {name: "named only by a module the directory replaces, no ask", replaced: true, refused: true}, } { t.Run(c.name, func(t *testing.T) { gomod := zeroMod @@ -375,6 +372,15 @@ func TestARequirementAtTheZeroVersionIsTakenFromTheAskOrTheTrunk(t *testing.T) { t.Fatal(err) } st := states.waitEnd(t) + if c.refused { + if st.State == sdkstep.StepPassed || !strings.Contains(st.Reason, "no pin for "+sdk) { + t.Fatalf("the step ended %s (%s), want it failed naming no pin for %s", st.State, st.Reason, sdk) + } + if h.ran(" mod download -json " + sdk + "@") { + t.Errorf("go was asked for a version of %s with no pin:\n%s", sdk, strings.Join(h.f.lines(), "\n")) + } + return + } if st.State != sdkstep.StepPassed { t.Fatalf("the step ended %s: %s", st.State, st.Reason) } -- 2.54.0 From b889075e21bdb979eaf32d10886cc559dfc40373 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 22:28:28 +0100 Subject: [PATCH 3/3] H-A-202: the narrowed tree keeps the repository's packages a required package requires, transitively A package artifact's go.mod may require a package of its repository that requires another of it at the zero version; the narrowing kept only the first level, so the build of the second found no module of that path. The entry's paths keep the manifest's form; the Go build module reads each kept package's go.mod in turn, each directory once, and keeps what it requires. Builds: design 47 H H-A-202, H-A-198 --- .../mesh-build-go/cmd/mesh-build-go/narrow.go | 51 ++++++++++++++----- .../cmd/mesh-build-go/narrow_test.go | 38 +++++++++++++- 2 files changed, 74 insertions(+), 15 deletions(-) diff --git a/modules/mesh-build-go/cmd/mesh-build-go/narrow.go b/modules/mesh-build-go/cmd/mesh-build-go/narrow.go index 06060903a..ba27c3e1f 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/narrow.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/narrow.go @@ -2,6 +2,7 @@ package main import ( "io/fs" + "maps" "os" "path" "path/filepath" @@ -127,11 +128,20 @@ func generatedFromDirs(tree, dir string) []string { } // ownZeroPackageDirs are the directories (from the tree's root) of the packages of the checked repository that a go.mod -// under the artifact's named paths requires at the zero version (H-A-136; ADR 0573 §2). Each is found by the manifests -// of the repository's modules: a module's directory or the directory of one of its artifacts' paths whose go.mod declares -// the required module path. One no manifest leads to is left to the fetch's resolution, which fails naming it. +// under the artifact's named paths requires at the zero version (H-A-136; ADR 0573 §2), transitively: the go.mod of each +// such directory is read in turn for the packages of the repository it requires at the zero version, each directory +// once (design 47 H, H-A-202, H-A-198). Each is found by the manifests of the repository's modules: a module's directory +// or the directory of one of its artifacts' paths whose go.mod declares the required module path. One no manifest leads +// to is left to the fetch's resolution, which fails naming it. func ownZeroPackageDirs(tree, repository, dir string, paths []string) []string { want := map[string]bool{} + addReqs := func(raw []byte) { + for _, pn := range forgePins(string(raw)) { + if pn.short == zeroShort && "novox/"+pn.repo == repository { + want[pn.module] = true + } + } + } for _, p := range paths { root := filepath.Join(tree, filepath.FromSlash(path.Join(dir, p))) filepath.WalkDir(root, func(file string, e fs.DirEntry, err error) error { @@ -147,14 +157,8 @@ func ownZeroPackageDirs(tree, repository, dir string, paths []string) []string { if e.Name() != "go.mod" { return nil } - raw, err := os.ReadFile(file) - if err != nil { - return nil - } - for _, pn := range forgePins(string(raw)) { - if pn.short == zeroShort && "novox/"+pn.repo == repository { - want[pn.module] = true - } + if raw, err := os.ReadFile(file); err == nil { + addReqs(raw) } return nil }) @@ -162,10 +166,29 @@ func ownZeroPackageDirs(tree, repository, dir string, paths []string) []string { if len(want) == 0 { return nil } - var out []string + byModule := map[string][]string{} // a module path and the manifest-named directories whose go.mod declares it for _, cand := range manifestDirs(tree) { - if mod := goModulePath(filepath.Join(tree, filepath.FromSlash(cand), "go.mod")); want[mod] && !slices.Contains(out, cand) { - out = append(out, cand) + if mod := goModulePath(filepath.Join(tree, filepath.FromSlash(cand), "go.mod")); mod != "" && !slices.Contains(byModule[mod], cand) { + byModule[mod] = append(byModule[mod], cand) + } + } + var out []string + done := map[string]bool{} + for len(want) > len(done) { + for _, mod := range slices.Sorted(maps.Keys(want)) { + if done[mod] { + continue + } + done[mod] = true + for _, cand := range byModule[mod] { + if slices.Contains(out, cand) { + continue + } + out = append(out, cand) + if raw, err := os.ReadFile(filepath.Join(tree, filepath.FromSlash(cand), "go.mod")); err == nil { + addReqs(raw) // what this package requires of the repository comes along (H-A-202) + } + } } } slices.Sort(out) diff --git a/modules/mesh-build-go/cmd/mesh-build-go/narrow_test.go b/modules/mesh-build-go/cmd/mesh-build-go/narrow_test.go index b451fccd4..30332dd21 100644 --- a/modules/mesh-build-go/cmd/mesh-build-go/narrow_test.go +++ b/modules/mesh-build-go/cmd/mesh-build-go/narrow_test.go @@ -29,6 +29,7 @@ func writeFile(t *testing.T, file, body string) { // modules stay the artifact's own (A-447a): neither the generated-from directory's nor the sibling package's. func TestANarrowedWorkspaceHoldsTheGeneratedFromDirectoriesAndItsRepositorysZeroVersionPackages(t *testing.T) { const sdk = "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk" + const repo = "git.novox.be/novox/mesh-delivery" zero := " v0.0.0-00010101000000-" + zeroShort for _, tc := range []struct { name, dir string @@ -37,6 +38,7 @@ func TestANarrowedWorkspaceHoldsTheGeneratedFromDirectoriesAndItsRepositorysZero kept, gone []string modules []string seats []string // generated into the tree by the seat generator, its out-of-step check then finding nothing + refused string // the narrowing fails naming this }{ {name: "a generated-from directory", dir: "modules/c", paths: []string{"go/seats/a"}, files: map[string]string{ @@ -92,6 +94,33 @@ func TestANarrowedWorkspaceHoldsTheGeneratedFromDirectoriesAndItsRepositorysZero "modules/mesh-delivery-sdk/go.mod", "modules/mesh-delivery-sdk/steprun/s.go"}, gone: []string{"module.json", "go.sum", "modules/mesh-delivery-view", "modules/mesh-delivery-contracts/go/clients/other"}, modules: []string{"modules/mesh-delivery-contracts/go/clients/meshcatalogclient"}}, + // H-A-202, H-A-198: the packages of the repository a required one requires at the zero version come along too, + // transitively (state -> builds -> client), each found by its manifest. + {name: "the repository's packages a required package requires, transitively", dir: "modules/a", paths: []string{"state"}, + files: map[string]string{ + "modules/a/module.json": `{"module":"a","build":{"artifacts":[{"name":"state","kind":"package","language":"go","paths":["state"]}]}}`, + "modules/a/state/go.mod": "module " + repo + "/modules/a/state\n\ngo 1.26\n\nrequire " + repo + "/modules/b/builds" + zero + "\n", + "modules/a/state/s.go": "package state\n", + "modules/b/module.json": `{"module":"b","build":{"artifacts":[{"name":"builds","kind":"package","language":"go","paths":["builds"]}]}}`, + "modules/b/builds/go.mod": "module " + repo + "/modules/b/builds\n\ngo 1.26\n\nrequire (\n\t" + repo + "/modules/c/client" + zero + "\n\tgit.novox.be/novox/mesh-sdk/go" + zero + "\n)\n", + "modules/b/builds/b.go": "package builds\n", + "modules/b/other/o.go": "package other\n", + "modules/c/module.json": `{"module":"c","build":{"artifacts":[{"name":"client","kind":"package","language":"go","paths":["client"]}]}}`, + "modules/c/client/go.mod": "module " + repo + "/modules/c/client\n\ngo 1.26\n\nrequire " + repo + "/modules/b/builds" + zero + "\n", + "modules/c/client/c.go": "package client\n", + "modules/c/other/o.go": "package other\n", + "modules/d/module.json": `{"module":"d"}`, + }, + kept: []string{"modules/a/state/s.go", "modules/b/builds/b.go", "modules/c/client/c.go"}, + gone: []string{"modules/b/other", "modules/c/other", "modules/d"}, + modules: []string{"modules/a/state"}}, + // A named path that leaves the repository is refused. + {name: "a named path that leaves the repository", dir: "mesh-grants", paths: []string{".", "../../outside"}, + files: map[string]string{"mesh-grants/module.json": `{"module":"mesh-grants"}`, "mesh-grants/go.mod": "module mesh-grants\n\ngo 1.26\n"}, + refused: `"../../outside" leaves`}, + {name: "a named path that leaves the repository from a nested module", dir: "modules/mesh-grants", paths: []string{"../../../outside"}, + files: map[string]string{"modules/mesh-grants/module.json": `{"module":"mesh-grants"}`, "modules/mesh-grants/go.mod": "module mesh-grants\n\ngo 1.26\n"}, + refused: `"../../../outside" leaves`}, } { t.Run(tc.name, func(t *testing.T) { tree := t.TempDir() @@ -125,7 +154,14 @@ func TestANarrowedWorkspaceHoldsTheGeneratedFromDirectoriesAndItsRepositorysZero } } req := sdkstep.FetchRequest{Repository: "novox/mesh-delivery", Commit: commitSHA, Dir: tc.dir, Paths: tc.paths} - if err := narrowTree(tree, req.Repository, req); err != nil { + err := narrowTree(tree, req.Repository, req) + if tc.refused != "" { + if err == nil || !strings.Contains(err.Error(), tc.refused) { + t.Fatalf("the narrowing answered %v, want it refused naming %s", err, tc.refused) + } + return + } + if err != nil { t.Fatal(err) } for _, k := range tc.kept { -- 2.54.0