From 017451762d446b684cefdaea03dee83d93214855 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 16 Nov 2026 11:09:26 +0100 Subject: [PATCH 1/3] Builder names the module's directory on every fetch; the fetch request accepts dir with no paths (A-447) Builds: design 47 G (G-22 lead answers 2) A-447 --- .../mesh-delivery-builder/internal/build/r4e_test.go | 4 ++-- modules/mesh-delivery-builder/internal/build/run.go | 5 +++-- modules/mesh-delivery-sdk/buildstep/request.go | 11 +++++------ modules/mesh-delivery-sdk/buildstep/request_test.go | 5 ++++- sdk/buildstep/request.go | 11 +++++------ sdk/buildstep/request_test.go | 5 ++++- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/modules/mesh-delivery-builder/internal/build/r4e_test.go b/modules/mesh-delivery-builder/internal/build/r4e_test.go index a79c0ed0..f48baf7b 100644 --- a/modules/mesh-delivery-builder/internal/build/r4e_test.go +++ b/modules/mesh-delivery-builder/internal/build/r4e_test.go @@ -253,8 +253,8 @@ func TestTheFetchOfAModuleNamingItsPathsCarriesItsDirectoryAndThosePaths(t *test } r2 := newRig(t, goBundle) r2.consider(t, "modules/m") - if a := r2.bm.callsOf("build_go_fetch")[0].body.(map[string]any); a["dir"] != nil || a["paths"] != nil { - t.Errorf("fetch args = %+v, want no dir or paths for a module naming none", a) + if a := r2.bm.callsOf("build_go_fetch")[0].body.(map[string]any); a["dir"] != "modules/m" || a["paths"] != nil { + t.Errorf("fetch args = %+v, want the module's directory and no paths for a module naming none (A-447)", a) } } diff --git a/modules/mesh-delivery-builder/internal/build/run.go b/modules/mesh-delivery-builder/internal/build/run.go index 5e0b5bea..d03b0f52 100644 --- a/modules/mesh-delivery-builder/internal/build/run.go +++ b/modules/mesh-delivery-builder/internal/build/run.go @@ -1038,11 +1038,12 @@ func (n *askNotes) note(ctx context.Context, language, id, step string) error { // is copied by its pinned reference with no fetch (ADR 0498 clause 4); a lane of copies alone fetches nothing. A lane of a // key taken over at start waits for the ask the key names and puts none. func (b *Builder) runLane(ctx context.Context, l *lane, repository string, m meshcatalog.ModulesByModuleValue, module string, asked *askNotes) { - req := sdkstep.Fetch{Repository: repository, Commit: m.Commit} + // The module's directory goes with every fetch, so a Go build downloads and judges that module and what its go.mod + // replaces alone, never another Go module of the tree (design 47 G, A-447). + req := sdkstep.Fetch{Repository: repository, Commit: m.Commit, Dir: m.Path} if m.Inputs2 != nil && len(m.Inputs2.Paths) > 0 { // A module whose every artifact names its paths is built from those alone (ADR 0499 clause 4): the paths come from // the indexer's kept inputs, never from a manifest (the lead's decision L8 of R4e). - req.Dir = m.Path for p := range m.Inputs2.Paths { req.Paths = append(req.Paths, p) } diff --git a/modules/mesh-delivery-sdk/buildstep/request.go b/modules/mesh-delivery-sdk/buildstep/request.go index 9cc961ff..5ea272b0 100644 --- a/modules/mesh-delivery-sdk/buildstep/request.go +++ b/modules/mesh-delivery-sdk/buildstep/request.go @@ -19,8 +19,9 @@ var ( // // **The paths come from the builder, not from a manifest** (ADR 0495 clause 1; the lead's decision L8 of R4e): the // builder fills Dir and Paths from the indexer's Module value (Path, and KeptInputs2.Paths' keys), and the build module -// gives the build and test steps a workspace holding those paths, the manifest and its lock files. A request without -// them builds from the module's directory, as before. +// gives the build and test steps a workspace holding those paths, the manifest and its lock files. A request with a directory and no +// paths builds from the module's directory, which a Go build resolves with the Go modules it replaces alone (A-447); +// one without either builds the whole tree. type FetchRequest struct { Repository string `json:"repository"` Commit string `json:"commit"` @@ -138,11 +139,9 @@ func (r FetchRequest) Check() error { if r.Base != "" && !requestCommitOK.MatchString(r.Base) { return fmt.Errorf("%q is not a trunk commit (40 hex digits)", r.Base) } - switch { - case len(r.Paths) > 0 && r.Dir == "": + // A module directory alone is a request for that module's Go modules alone (design 47 G, A-447); paths need it. + if len(r.Paths) > 0 && r.Dir == "" { return fmt.Errorf("the request names paths and names no module directory (dir) they are relative to") - case len(r.Paths) == 0 && r.Dir != "": - return fmt.Errorf("the request names a module directory and no path") } if r.Dir != "" && (outside(r.Dir) || strings.HasPrefix(r.Dir, "/")) { return fmt.Errorf("the module directory %q leaves the repository", r.Dir) diff --git a/modules/mesh-delivery-sdk/buildstep/request_test.go b/modules/mesh-delivery-sdk/buildstep/request_test.go index 7732329f..fbd79d55 100644 --- a/modules/mesh-delivery-sdk/buildstep/request_test.go +++ b/modules/mesh-delivery-sdk/buildstep/request_test.go @@ -33,6 +33,10 @@ func TestAFetchRequestCarriesTheNamedPathsThroughTheToolCall(t *testing.T) { } ok := map[string]any{"repository": "novox/x", "commit": strings.Repeat("b", 40)} + // A module directory with no paths is a request (design 47 G, A-447). + if dirOnly, err := ParseFetchRequest(map[string]any{"repository": "novox/x", "commit": strings.Repeat("b", 40), "dir": "modules/a"}); err != nil || dirOnly.Dir != "modules/a" || dirOnly.Paths != nil { + t.Fatalf("a directory with no paths: %+v, %v", dirOnly, err) + } for _, c := range []struct { set map[string]any says string @@ -45,7 +49,6 @@ func TestAFetchRequestCarriesTheNamedPathsThroughTheToolCall(t *testing.T) { {map[string]any{"dir": "modules/a", "paths": []any{"../b"}}, "leaves the module's directory"}, {map[string]any{"dir": "../a", "paths": []any{"src"}}, "leaves the repository"}, {map[string]any{"dir": "modules/a", "paths": []any{3}}, "paths is a list of strings"}, - {map[string]any{"dir": "modules/a"}, "names a module directory and no path"}, {map[string]any{"packages": map[string]any{"git.novox.be/novox/mesh-sdk/go": "main"}}, "neither a full commit nor a Go semantic version"}, {map[string]any{"packages": map[string]any{"a b": strings.Repeat("d", 40)}}, "no module path"}, {map[string]any{"packages": []any{"x"}}, "packages is an object"}, diff --git a/sdk/buildstep/request.go b/sdk/buildstep/request.go index 9cc961ff..5ea272b0 100644 --- a/sdk/buildstep/request.go +++ b/sdk/buildstep/request.go @@ -19,8 +19,9 @@ var ( // // **The paths come from the builder, not from a manifest** (ADR 0495 clause 1; the lead's decision L8 of R4e): the // builder fills Dir and Paths from the indexer's Module value (Path, and KeptInputs2.Paths' keys), and the build module -// gives the build and test steps a workspace holding those paths, the manifest and its lock files. A request without -// them builds from the module's directory, as before. +// gives the build and test steps a workspace holding those paths, the manifest and its lock files. A request with a directory and no +// paths builds from the module's directory, which a Go build resolves with the Go modules it replaces alone (A-447); +// one without either builds the whole tree. type FetchRequest struct { Repository string `json:"repository"` Commit string `json:"commit"` @@ -138,11 +139,9 @@ func (r FetchRequest) Check() error { if r.Base != "" && !requestCommitOK.MatchString(r.Base) { return fmt.Errorf("%q is not a trunk commit (40 hex digits)", r.Base) } - switch { - case len(r.Paths) > 0 && r.Dir == "": + // A module directory alone is a request for that module's Go modules alone (design 47 G, A-447); paths need it. + if len(r.Paths) > 0 && r.Dir == "" { return fmt.Errorf("the request names paths and names no module directory (dir) they are relative to") - case len(r.Paths) == 0 && r.Dir != "": - return fmt.Errorf("the request names a module directory and no path") } if r.Dir != "" && (outside(r.Dir) || strings.HasPrefix(r.Dir, "/")) { return fmt.Errorf("the module directory %q leaves the repository", r.Dir) diff --git a/sdk/buildstep/request_test.go b/sdk/buildstep/request_test.go index 7732329f..fbd79d55 100644 --- a/sdk/buildstep/request_test.go +++ b/sdk/buildstep/request_test.go @@ -33,6 +33,10 @@ func TestAFetchRequestCarriesTheNamedPathsThroughTheToolCall(t *testing.T) { } ok := map[string]any{"repository": "novox/x", "commit": strings.Repeat("b", 40)} + // A module directory with no paths is a request (design 47 G, A-447). + if dirOnly, err := ParseFetchRequest(map[string]any{"repository": "novox/x", "commit": strings.Repeat("b", 40), "dir": "modules/a"}); err != nil || dirOnly.Dir != "modules/a" || dirOnly.Paths != nil { + t.Fatalf("a directory with no paths: %+v, %v", dirOnly, err) + } for _, c := range []struct { set map[string]any says string @@ -45,7 +49,6 @@ func TestAFetchRequestCarriesTheNamedPathsThroughTheToolCall(t *testing.T) { {map[string]any{"dir": "modules/a", "paths": []any{"../b"}}, "leaves the module's directory"}, {map[string]any{"dir": "../a", "paths": []any{"src"}}, "leaves the repository"}, {map[string]any{"dir": "modules/a", "paths": []any{3}}, "paths is a list of strings"}, - {map[string]any{"dir": "modules/a"}, "names a module directory and no path"}, {map[string]any{"packages": map[string]any{"git.novox.be/novox/mesh-sdk/go": "main"}}, "neither a full commit nor a Go semantic version"}, {map[string]any{"packages": map[string]any{"a b": strings.Repeat("d", 40)}}, "no module path"}, {map[string]any{"packages": []any{"x"}}, "packages is an object"}, From 41821c841ace0d64854f24e9ee439c8166a5c97d Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 16 Nov 2026 11:34:43 +0100 Subject: [PATCH 2/3] Compose jobs of the checker name their module's directory in the fetch (A-447b) Builds: design 47 G (G-22 lead answers 2) A-447b --- modules/mesh-delivery-checker/internal/check/engines.go | 2 +- modules/mesh-delivery-checker/internal/check/engines_test.go | 3 +++ .../mesh-delivery-checker/internal/check/manifests_judge.go | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/mesh-delivery-checker/internal/check/engines.go b/modules/mesh-delivery-checker/internal/check/engines.go index 02110b28..bf2fc352 100644 --- a/modules/mesh-delivery-checker/internal/check/engines.go +++ b/modules/mesh-delivery-checker/internal/check/engines.go @@ -227,7 +227,7 @@ func (e EngineCompositions) inSandbox(ctx context.Context, c *Case, head, node s return a, err } } - job := buildstep.ComposeJob{Fetch: buildstep.Fetch{Repository: nodeEngineRepo, Commit: head, Packages: packagesFor(e.Published, c, nodeEngineRepo)}, Dir: meshcatalogclient.RootPath, + job := buildstep.ComposeJob{Fetch: buildstep.Fetch{Repository: nodeEngineRepo, Commit: head, Dir: meshcatalogclient.RootPath, Packages: packagesFor(e.Published, c, nodeEngineRepo)}, Dir: meshcatalogclient.RootPath, Package: composer.Package, Request: raw, Reader: "the node-engine head of " + c.Group} // The ask travels on the bus, whose message limit a whole request passes (1.2 MB for a large node): it goes packed. if err := job.PackRequest(raw); err != nil { diff --git a/modules/mesh-delivery-checker/internal/check/engines_test.go b/modules/mesh-delivery-checker/internal/check/engines_test.go index 499d3ce5..66483abb 100644 --- a/modules/mesh-delivery-checker/internal/check/engines_test.go +++ b/modules/mesh-delivery-checker/internal/check/engines_test.go @@ -219,6 +219,9 @@ func TestTheCompositionIsMadeFromTheEnginesAnswers(t *testing.T) { t.Fatalf("asked %+v, jobs %+v: want the input asked and one job", e.asked, sb.jobs) } job := sb.jobs[0] + if job.Fetch.Dir == "" || job.Fetch.Dir != job.Dir { // a build is for one module: its fetch names the directory (A-447b) + t.Errorf("the compose job's fetch names the directory %q, want its module's %q", job.Fetch.Dir, job.Dir) + } var req composer.Request if len(job.Request) == 0 || job.Request[0] != '"' { t.Errorf("the request went whole, not packed (issue 1966): %.60s", job.Request) diff --git a/modules/mesh-delivery-checker/internal/check/manifests_judge.go b/modules/mesh-delivery-checker/internal/check/manifests_judge.go index e137cfbc..f665de95 100644 --- a/modules/mesh-delivery-checker/internal/check/manifests_judge.go +++ b/modules/mesh-delivery-checker/internal/check/manifests_judge.go @@ -160,7 +160,7 @@ func (st *state) runJudge(ctx context.Context, req composer.Request, touched []s st.fail(st.goModule(), err.Error()) return change, trunk, false } - job := buildstep.ComposeJob{Fetch: buildstep.Fetch{Repository: DeliveryRepository, Commit: commit, Packages: versions}, Dir: JudgeDir, + job := buildstep.ComposeJob{Fetch: buildstep.Fetch{Repository: DeliveryRepository, Commit: commit, Dir: JudgeDir, Packages: versions}, Dir: JudgeDir, Package: JudgePackage, Request: raw, Reader: "the indexer's judge at " + at} a := buildstep.StepAsk{ID: buildstep.NewID(), Kind: buildstep.AskCheck, Language: buildstep.AskGo, Asker: st.j.Module, At: st.j.now().UTC(), Compose: &job} From a5a5d9a16f55e08561f954b823d1b53fff048f96 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 16 Nov 2026 11:37:54 +0100 Subject: [PATCH 3/3] A check for a module tests that module directory's modules alone (A-447c) Builds: design 47 G (G-22 lead answers 2) A-447c --- modules/mesh-delivery-sdk/steprun/askrun.go | 19 ++++++++++++++++++- .../mesh-delivery-sdk/steprun/askrun_test.go | 10 ++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-sdk/steprun/askrun.go b/modules/mesh-delivery-sdk/steprun/askrun.go index a0b95356..17693494 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun.go +++ b/modules/mesh-delivery-sdk/steprun/askrun.go @@ -374,7 +374,7 @@ func (s AskSteps) level(ctx context.Context, job sdkstep.CheckJob, level string, if s.Digest == nil { // A module with no digest (Node) tests each module directory of the tree, those whose tests changed first. for _, priority := range []bool{true, false} { - for _, dir := range f.Modules { + for _, dir := range modulesOf(f.Modules, job.Fetch.Dir) { if changesTestIn(f.Changed, dir) != priority { continue } @@ -424,6 +424,23 @@ func (s AskSteps) level(ctx context.Context, job sdkstep.CheckJob, level string, return all, nil } +// modulesOf are the module directories a fetch answered that a step for the module in dir tests: that directory's and +// those under it, never another module's of the repository (design 47 G, A-447c); all of them when the ask names no +// directory, or the root. +func modulesOf(modules []string, dir string) []string { + dir = strings.Trim(path.Clean(dir), "/") + if dir == "" || dir == "." { + return modules + } + var out []string + for _, m := range modules { + if m == dir || strings.HasPrefix(m, dir+"/") { + out = append(out, m) + } + } + return out +} + // release removes an ask's workspace, saying a failure: the module's sweep removes it later. func (s AskSteps) release(workspace string) { if workspace == "" || s.Release == nil { diff --git a/modules/mesh-delivery-sdk/steprun/askrun_test.go b/modules/mesh-delivery-sdk/steprun/askrun_test.go index 3662862d..c2c89ee1 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun_test.go +++ b/modules/mesh-delivery-sdk/steprun/askrun_test.go @@ -296,6 +296,16 @@ func TestRunAskChecksNodeModulesAndConflicts(t *testing.T) { if fmt.Sprint(r.calls[1:]) != `[test {"level":"unit","module":"b","workspace":"/w"} test {"level":"unit","module":"a","workspace":"/w"}]` { t.Fatalf("calls %v", r.calls) } + // A check asked for the module in a directory tests that directory's modules alone (A-447c). + r = &recorder{fetch: map[string]any{"workspace": "/w", "modules": []string{"a", "b", "b/c"}}, tests: map[string]bool{"b": true, "b/c": true}} + s = r.steps() + s.Digest = nil + if _, err := RunAsk(context.Background(), s, ask(sdkstep.CheckJob{Levels: []string{sdkstep.LevelUnit}, Fetch: sdkstep.Fetch{Repository: "novox/x", Commit: runCommit, Dir: "b"}})); err != nil { + t.Fatal(err) + } + if fmt.Sprint(r.calls[1:]) != `[test {"level":"unit","module":"b","workspace":"/w"} test {"level":"unit","module":"b/c","workspace":"/w"}]` { + t.Fatalf("a check for the module b: calls %v", r.calls) + } r = &recorder{fetch: map[string]any{"workspace": "/w", "conflicts": []string{"go.mod"}}} out, err := RunAsk(context.Background(), r.steps(), ask(sdkstep.CheckJob{Levels: []string{sdkstep.LevelUnit}, Fetch: sdkstep.Fetch{Repository: "novox/x", Commit: runCommit}})) if err != nil || len(r.calls) != 1 || len(out.(sdkstep.CheckAnswer).Levels) != 0 {