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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1047,11 +1047,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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"},
|
||||
|
||||
Reference in New Issue
Block a user