A module's directory is never shared code, held or not (hq issue 278)
The merge of mesh-catalog 7f99fb4a rebuilt 103 modules with the build agent in tier 0, and ADR 0236 recorded it as "a change to the build agent rebuilds most of the catalogue". The agent had not changed: modules/showcase/index.ts had. showcase is the catalogue's reference module, held by no machine, and its manifest was not in the merge, so whatTheMergeTouched read the file as shared code and rebuilt everything built from the repository (88 came out byte-identical). The agent stood first only because everything is built by it. Whether a directory is a module is a fact of the repository at the merge commit, so the forge's announcer now says it: module_dirs, the changed files' directories holding a module.json there, with module_dirs_said. A changed file inside one is that module's business; only a file in no such directory is shared. An announcer that does not say keeps the old rule. `plans` what-if takes the same list as module-dirs. And a regression for the open question: nothing depends on the build agent except by being built by it, and built-by never widens a plan, so a change to the agent - manifest or program - rebuilds the agent alone; what moved beside it is ordered after it.
This commit is contained in:
@@ -212,3 +212,45 @@ func TestTheGateJudgesEachMachineFromItsOwnSend(t *testing.T) {
|
||||
t.Fatal("a report from before the machine was sent opened the gate")
|
||||
}
|
||||
}
|
||||
|
||||
// novox/hq issue 278 and ADR 0236's open question: a change to the build agent — its manifest alone, as
|
||||
// the catalogue's data sections were, or its program — rebuilds the build agent and nothing it builds.
|
||||
// What it builds is ordered after it in a plan that holds both, never added to one for its sake. The
|
||||
// merge that rebuilt 103 modules with the agent in tier 0 rebuilt them for a file read as shared code;
|
||||
// the agent stood first only because everything else is built by it.
|
||||
func TestAChangeToTheBuildAgentRebuildsTheBuildAgentAlone(t *testing.T) {
|
||||
const repo = "http://forge.internal:20000/novox/mesh-catalog.git"
|
||||
agent := fromRepo("build-agent", repo, "modules/build-agent")
|
||||
redis := fromRepo("redis", repo, "modules/redis")
|
||||
postgres := fromRepo("postgres", repo, "modules/postgres")
|
||||
entries := []inventory.Entry{agent, redis, postgres}
|
||||
edges := []inventory.Edge{
|
||||
{From: "redis", To: "mesh-tools", Kind: inventory.EdgeStandsOn},
|
||||
{From: "redis", To: "build-agent", Kind: inventory.EdgeBuiltBy},
|
||||
{From: "postgres", To: "build-agent", Kind: inventory.EdgeBuiltBy},
|
||||
{From: "mesh-tools", To: "build-agent", Kind: inventory.EdgeBuiltBy},
|
||||
{From: "mesh-controller", To: "build-agent", Kind: inventory.EdgeBuiltBy},
|
||||
{From: "build-agent", To: "mesh-controller", Kind: inventory.EdgeWorkerOf},
|
||||
}
|
||||
for _, paths := range [][]string{
|
||||
{"modules/build-agent/module.json"}, // its manifest alone
|
||||
{"modules/build-agent/cmd/agent/main.go", "modules/build-agent/module.json"}, // its program too
|
||||
} {
|
||||
m := link.SourceMoved{Owner: "novox", Repo: "mesh-catalog", Base: "main", Commit: "abc", Paths: paths,
|
||||
ModuleDirs: []string{"modules/build-agent"}, ModuleDirsSaid: true}
|
||||
touched := whatTheMergeTouched(entries, entries, m)
|
||||
if len(touched) != 1 || touched[0].Manifest.Module != "build-agent" {
|
||||
t.Fatalf("%v touched %v", paths, touched)
|
||||
}
|
||||
p := planOfMerge(m, []string{"build-agent"}, edges)
|
||||
if len(p.Tiers) != 1 || len(p.Tiers[0]) != 1 || p.Tiers[0][0] != "build-agent" || len(p.Modules) != 1 {
|
||||
t.Fatalf("%v planned %v: the build agent alone", paths, p.Tiers)
|
||||
}
|
||||
}
|
||||
// With what it builds moved beside it, the agent comes first and they follow: an order, not a widening.
|
||||
p := planOfMerge(link.SourceMoved{Owner: "novox", Repo: "mesh-catalog", Commit: "abc"},
|
||||
[]string{"build-agent", "redis"}, edges)
|
||||
if len(p.Tiers) != 2 || p.Tiers[0][0] != "build-agent" || p.Tiers[1][0] != "redis" || len(p.Modules) != 2 {
|
||||
t.Fatalf("the agent, then what moved beside it: %v", p.Tiers)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user