node-engine: a held tool runner's kept program is not replaced by the tools bundles it serves, so novox's new indexer is run by it (ADR 0259 §8)

This commit is contained in:
2026-11-16 00:50:33 +01:00
parent 40ed0633e0
commit 7f892a757c
2 changed files with 59 additions and 1 deletions
+8 -1
View File
@@ -161,7 +161,7 @@ func compositions(in Input, node string, fps map[string]string, mode Mode, appli
}
kept := make(map[string]catalogue.Manifest, len(n.Kept))
for m, man := range n.Kept {
if man.Stubbed && man.RunsAs == "" {
if man.Stubbed && man.RunsAs == "" && !keepsProgram(man) {
man.Bundles = runningBundles(n.RunsTools[m], reading.Catalogue[m])
}
kept[m] = man
@@ -498,6 +498,13 @@ func Carried(m catalogue.Manifest, module string, runs *engcomp.Composed) catalo
return stub
}
// keepsProgram says a held tool runner carries the program it runs (Carried, runningProgram): its one bundle is that
// program, which the tools bundles it serves never replace, or the modules of their own account it runs are held for
// want of it (lead-47 2026-11-16: 40ed063 kept novox's, and the loop over what the runtime serves dropped it again).
func keepsProgram(m catalogue.Manifest) bool {
return catalogue.IsToolRunner(m) && len(m.Bundles) == 1 && m.Bundles[0].Binary != ""
}
// runningProgram is the program bundle of the tool runner as it runs on the node: its process's source, digest and binary.
// A held tool runner keeps it, so a module of its own account is run by the same program the node runs (novox/hq ADR 0259
// §8) and is not held for want of a runtime that runs (lead-47 2026-11-16: novox's tool runner was held for a build the
+51
View File
@@ -191,3 +191,54 @@ func TestCompositionsAreTheDeclarationSplitByModule(t *testing.T) {
}
}
}
// lead-47 2026-11-16: a held tool runner keeps the program it runs (Carried, runningProgram) after what the runtime serves
// is laid on the stubs (Node.RunsTools), so a module of its own account on its node is run by that program, not held
// "the tool runner is not here to run it from" (novox, the new indexer).
func TestAHeldToolRunnerKeepsItsProgramForTheModulesOfTheirOwnAccount(t *testing.T) {
dg := "sha256:" + strings.Repeat("d", 64)
source := catalogue.ArtifactStoreScheme + "node-tools/runtime/blobs/" + dg
runtime := catalogue.Manifest{Module: "node-tools", Version: "1", ToolRunner: true,
OwnSecrets: catalogue.OwnSecrets{"broker": {Path: "/var/lib/mesh/node-tools/broker"}}}
own := catalogue.Manifest{Module: "mesh-self-check", Version: "1", RunsAs: "mesh-self-check",
OwnSecrets: catalogue.OwnSecrets{"broker": {Path: "/var/lib/mesh/mesh-self-check/broker", Taken: catalogue.TakenAtStart}},
Bundles: []catalogue.Bundle{{Name: "tools", Source: catalogue.ArtifactStoreScheme + "mesh-self-check/tools/blobs/" + dg,
Digest: dg, Language: "go", Loads: []string{"mesh-self-check-tools"}}}}
store := catalogue.Manifest{Module: "artifacts", Version: "1",
Claims: []catalogue.Claim{{Name: "container-image-registry", Scope: catalogue.ScopeMesh}},
Listens: []catalogue.Listening{{Name: "registry", Port: 5100, From: catalogue.FromMesh}}}
runs := engcomp.Composed{Node: "anchor", Module: "node-tools", Resources: []json.RawMessage{json.RawMessage(
`{"id":"node-tools.runtime","module":"node-tools","type":"process","name":"node-tools","source":"` + source +
`","digest":"` + dg + `","run":["./node-tools"],"env":{"MESH_TOOL_MODULES":""}}`)}}
in := aMesh(t)
in.Catalogue["node-tools"], in.Catalogue["artifacts"], in.Catalogue["mesh-self-check"] = runtime, store, own
anchor := nodeOf(t, &in, "anchor")
anchor.Assigned = append(anchor.Assigned, "artifacts", "node-tools", "mesh-self-check")
in.BusMinted = []string{"anchor.node-tools", "anchor.mesh-self-check"}
anchor.SealingKey = keyOf(t, "anchor")
anchor.Held = map[string]bool{"node-tools": true}
anchor.Kept = map[string]catalogue.Manifest{"node-tools": Carried(runtime, "node-tools", &runs)}
anchor.RunsTools = ToolsRunning([]engcomp.Composed{runs})
fps := map[string]string{overlay.Name: fpFor('a'), "artifacts": fpFor('5'), "node-tools": fpFor('e'), "mesh-self-check": fpFor('6')}
out, _, _, err := CompositionsIn(in, "anchor", fps, Foreseeing)
if err != nil {
t.Fatalf("a module of its own account beside a held tool runner: %v", err)
}
ran := false
for _, c := range out {
for _, raw := range c.Resources {
var r struct {
Type string `json:"type"`
Digest string `json:"digest"`
Run []string `json:"run"`
User string `json:"user"`
}
if json.Unmarshal(raw, &r) == nil && r.Type == "process" && r.User == "mesh-self-check" {
ran = r.Digest == dg && len(r.Run) == 1 && r.Run[0] == "./node-tools"
}
}
}
if !ran {
t.Errorf("mesh-self-check is not run by the program node-tools runs: %v", out)
}
}