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
This commit is contained in:
2026-11-16 12:22:37 +01:00
parent e7c05c5370
commit d0e7dee951
6 changed files with 23 additions and 18 deletions
+5 -6
View File
@@ -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)
+4 -1
View File
@@ -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"},