From 7f892a757c69e653edd85b003c6ec0a9ace22ee7 Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 16 Nov 2026 00:50:33 +0100 Subject: [PATCH] =?UTF-8?q?node-engine:=20a=20held=20tool=20runner's=20kep?= =?UTF-8?q?t=20program=20is=20not=20replaced=20by=20the=20tools=20bundles?= =?UTF-8?q?=20it=20serves,=20so=20novox's=20new=20indexer=20is=20run=20by?= =?UTF-8?q?=20it=20(ADR=200259=20=C2=A78)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/compose/composed.go | 9 +++++- internal/compose/composed_test.go | 51 +++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/internal/compose/composed.go b/internal/compose/composed.go index 7ae3253b..eff389e5 100644 --- a/internal/compose/composed.go +++ b/internal/compose/composed.go @@ -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 diff --git a/internal/compose/composed_test.go b/internal/compose/composed_test.go index 17fc78a7..71590192 100644 --- a/internal/compose/composed_test.go +++ b/internal/compose/composed_test.go @@ -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) + } +}