Merge pull request 'The build verb takes on and behind, the command's other two shapes' (#130) from feat/the-build-verb-takes-on-and-behind into main

This commit was merged in pull request #130.
This commit is contained in:
2026-10-08 00:37:14 +00:00
5 changed files with 119 additions and 10 deletions
+15 -6
View File
@@ -407,13 +407,22 @@ var ControllerVerbs = []Verb{
"machine": "one machine (optional)",
"retired": "\"true\": only what is retired",
}, nil, "retired")},
{Name: "build", Description: "Have the build machine build a repository. Answers at once with the build's id: " +
"`builds` with that id follows it line by line, and the module is registered when the outcome comes.",
// Three shapes, as the command has them: one repository, every module standing on a base (on), or
// every module behind its source (behind). One per call; a second is refused as passed over.
{Name: "build", Description: "Have the build machine build a repository — or, instead, every module that " +
"stands on a base (on), or every module behind its source (behind). Answers at once with each build's id: " +
"`builds` with an id follows it line by line, and a module is registered when its outcome comes.",
Input: schema(map[string]string{
"repository": "the repository's URL, or its path on the forge holding the git seat (owner/name)",
"path": "the module's directory inside it (optional)",
"ref": "the branch, tag or commit to build (optional)",
}, []string{"repository"})},
"repository": "the repository's URL, or its path on the forge holding the git seat (owner/name); " +
"needed unless on or behind is given",
"path": "with repository: the module's directory inside it (optional)",
"ref": "with repository: the branch, tag or commit to build (optional)",
"on": "instead of a repository: a module's name. Every module the mesh holds that was built against " +
"its artifacts is built again from its own source, bases among them asked first — the rebuild a " +
"changed base needs, which behind does not see because their sources did not move",
"behind": "\"true\", instead of a repository: build every module the mesh holds whose source has moved " +
"past the commit it was built from, bases asked first",
}, nil, "behind")},
}
// schema is a JSON schema for an object of string properties, which is every argument the verbs
+45
View File
@@ -227,3 +227,48 @@ func TestASeatsVerbGainsTheArgumentsTheBinaryNames(t *testing.T) {
}
}
}
// **A stored row's build verb takes on and behind** (novox/hq ADR 0246: arguments added to a verb are
// additive): a row seeded before them described build with a repository it required, so the console
// would refuse both and a call naming neither would be refused for want of a repository. Re-seeding
// gives the row this binary's build.
func TestAStoredRowsBuildVerbTakesOnAndBehind(t *testing.T) {
inv := ForTest(t)
ctx := t.Context()
if _, err := inv.SeedSeats(ctx, catalogue.DefaultSeats()); err != nil {
t.Fatal(err)
}
old := `[{"name":"build","description":"Have the build machine build a repository.","input":{"type":"object",
"properties":{"repository":{"type":"string"},"path":{"type":"string"},"ref":{"type":"string"}},
"required":["repository"]}}]`
if _, err := inv.store.Pool().Exec(ctx, `update seat set serves = $1 where name = $2`,
[]byte(old), catalogue.ControllerSeatName); err != nil {
t.Fatal(err)
}
if _, err := inv.SeedSeats(ctx, catalogue.DefaultSeats()); err != nil {
t.Fatal(err)
}
seats, err := inv.Seats(ctx)
if err != nil {
t.Fatal(err)
}
var build catalogue.Verb
for _, s := range seats {
if s.Name == catalogue.ControllerSeatName {
for _, v := range s.Serves {
if v.Name == "build" {
build = v
}
}
}
}
props, _ := build.Input["properties"].(map[string]any)
for _, arg := range []string{"repository", "path", "ref", "on", "behind"} {
if _, has := props[arg]; !has {
t.Errorf("build in the row does not take %s: %v", arg, props)
}
}
if req, _ := build.Input["required"].([]any); len(req) != 0 {
t.Errorf("build in the row still requires %v, so on and behind alone are refused", req)
}
}