H-A-303: a pass that holds a module for a part withheld composes the tool runner as it runs
The node-engine restarted the tool runner at every self-compose on three machines: a module held for a part that did not answer (the catalog half's entry, the registry seats' versions) had its slice of the runtime process rebuilt from what runs, with its fingerprint set to its want's and its files words dropped, so MESH_TOOL_MODULES and MESH_TOOL_ENV differed pass by pass. A held module's entries and words are now copied verbatim from the running process, after the fingerprints are laid, so a holding pass digests as what runs and writes no new revision; a module whose parts answered and changed is still composed from its build. The composition read's grants ask names the holder it asked and why, and says it once in the journal until the grants part answers again. Builds: design 47 H H-A-303 (1)-(3), H-A-306 (1)-(3); H-A-296
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
engcomp "github.com/novox/mesh-host/internal/compositions"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -133,39 +134,62 @@ func TestCompositionsAreTheDeclarationSplitByModule(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
served := "lamp=" + resolution.BundlePath("lamp", "tools") + "/lamp-tools"
|
||||
runtimeRuns := func(dropped bool) engcomp.Composed {
|
||||
runtimeRuns := func(dropped bool, ran string) engcomp.Composed {
|
||||
env := `"MESH_TOOL_MODULES":"` + served + `","MESH_TOOL_ENV":"{\"lamp\":{\"LAMP_CONF\":\"/var/lib/lamp/conf\"}}"`
|
||||
if dropped {
|
||||
env = `"MESH_TOOL_MODULES":""` // the drop already applied (shanks, 2026-10-29)
|
||||
}
|
||||
if ran != "" {
|
||||
env = ran
|
||||
}
|
||||
return engcomp.Composed{Node: "anchor", Module: "node-tools", Resources: []json.RawMessage{json.RawMessage(
|
||||
`{"id":"node-tools.runtime","module":"node-tools","type":"process","name":"node-tools","env":{` + env + `}}`)}}
|
||||
}
|
||||
lampRuns := `{"id":"lamp.bundle-tools","type":"archive","source":"` + catalogue.ArtifactStoreScheme + `lamp/tools/blobs/` + dg('b') +
|
||||
`","digest":"` + dg('b') + `","path":"` + resolution.BundlePath("lamp", "tools") + `"}`
|
||||
// H-A-303, H-A-306: what runs of lamp in the runtime, its fingerprint and the paths it owns among its words, at a load
|
||||
// its new build no longer names.
|
||||
ranServed := "lamp=" + resolution.BundlePath("lamp", "tools") + "/lamp-tools-old"
|
||||
ranWords := `{"lamp":{"LAMP_CONF":"/var/lib/lamp/conf","MESH_FINGERPRINT":"` + fpFor('0') + `","MESH_OWNED_PATHS":"/var/lib/lamp"}}`
|
||||
ranEnv := `"MESH_TOOL_MODULES":"` + ranServed + `","MESH_TOOL_ENV":` + strconv.Quote(ranWords)
|
||||
held := func(n *Node) engcomp.Composed {
|
||||
n.Held = map[string]bool{"lamp": true}
|
||||
lr := engcomp.Composed{Node: "anchor", Module: "lamp", Resources: []json.RawMessage{json.RawMessage(
|
||||
strings.Replace(lampRuns, `"type"`, `"module":"lamp","type"`, 1))}}
|
||||
n.Kept = map[string]catalogue.Manifest{"lamp": Carried(newLamp, "lamp", &lr)}
|
||||
return lr
|
||||
}
|
||||
for _, row := range []struct {
|
||||
name string
|
||||
set func(n *Node) engcomp.Composed // and what runs of lamp
|
||||
fps map[string]string
|
||||
dropped bool
|
||||
ran string // the runtime's env as it runs, when not served's
|
||||
// What the runtime is composed to serve of lamp, and its words, when not served and its manifest's words.
|
||||
wantServed, wantWords string
|
||||
}{
|
||||
{"folded at a build of the old form", func(n *Node) engcomp.Composed {
|
||||
n.InOwn = map[string]bool{"lamp": true}
|
||||
n.RunsOwn = &engcomp.Composed{Node: "anchor", Resources: []json.RawMessage{json.RawMessage(lampRuns)}}
|
||||
return *n.RunsOwn
|
||||
}, map[string]string{}, false},
|
||||
}, map[string]string{}, false, "", "", ""},
|
||||
{"folded, the runtime already dropped it", func(n *Node) engcomp.Composed {
|
||||
n.InOwn = map[string]bool{"lamp": true}
|
||||
n.RunsOwn = &engcomp.Composed{Node: "anchor", Resources: []json.RawMessage{json.RawMessage(lampRuns)}}
|
||||
return *n.RunsOwn
|
||||
}, map[string]string{}, true},
|
||||
{"held, its new build not delivered", func(n *Node) engcomp.Composed {
|
||||
n.Held = map[string]bool{"lamp": true}
|
||||
lr := engcomp.Composed{Node: "anchor", Module: "lamp", Resources: []json.RawMessage{json.RawMessage(
|
||||
}, map[string]string{}, true, "", "", ""},
|
||||
// H-A-306: a held module's slice is what runs of it, verbatim: no fingerprint of its want where none runs.
|
||||
{"held, its new build not delivered", held, map[string]string{"lamp": fpFor('1')}, false, "",
|
||||
served, `{"lamp":{"LAMP_CONF":"/var/lib/lamp/conf"}}`},
|
||||
// H-A-303, H-A-306: held for a part withheld, its load, its fingerprint and its files words are what runs.
|
||||
{"held for a part withheld, its slice as it runs", held, map[string]string{"lamp": fpFor('1')}, false, ranEnv,
|
||||
ranServed, ranWords},
|
||||
// H-A-306 (3): a module whose parts answered and changed is composed from its build, not from what runs.
|
||||
{"read, its build changed", func(n *Node) engcomp.Composed {
|
||||
n.Kept = map[string]catalogue.Manifest{"lamp": newLamp}
|
||||
return engcomp.Composed{Node: "anchor", Module: "lamp", Resources: []json.RawMessage{json.RawMessage(
|
||||
strings.Replace(lampRuns, `"type"`, `"module":"lamp","type"`, 1))}}
|
||||
n.Kept = map[string]catalogue.Manifest{"lamp": Carried(newLamp, "lamp", &lr)}
|
||||
return lr
|
||||
}, map[string]string{"lamp": fpFor('1')}, false},
|
||||
}, map[string]string{"lamp": fpFor('1')}, false, ranEnv, "", ""},
|
||||
} {
|
||||
tools := aMesh(t)
|
||||
tools.Catalogue["node-tools"], tools.Catalogue["artifacts"], tools.Catalogue["lamp"] = runtime, store, lamp
|
||||
@@ -173,32 +197,47 @@ func TestCompositionsAreTheDeclarationSplitByModule(t *testing.T) {
|
||||
anchor.Assigned = append(anchor.Assigned, "artifacts", "node-tools", "lamp")
|
||||
tools.BusMinted = []string{"anchor." + "node-tools"}
|
||||
anchor.SealingKey = keyOf(t, "anchor")
|
||||
anchor.RunsTools = ToolsRunning([]engcomp.Composed{runtimeRuns(row.dropped), row.set(anchor)})
|
||||
ran := []engcomp.Composed{runtimeRuns(row.dropped, row.ran), row.set(anchor)}
|
||||
anchor.RunsTools, anchor.RunsRuntime = ToolsRunning(ran), RuntimeRunning(ran)
|
||||
row.fps[overlay.Name], row.fps["artifacts"], row.fps["node-tools"] = fpFor('a'), fpFor('5'), fpFor('e')
|
||||
out, _, _, err := CompositionsIn(tools, "anchor", row.fps, Foreseeing)
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v", row.name, err)
|
||||
}
|
||||
var digests []string
|
||||
var env map[string]any
|
||||
for _, c := range out {
|
||||
for _, raw := range c.Resources {
|
||||
var r struct {
|
||||
ID string `json:"id"`
|
||||
Env map[string]any `json:"env"`
|
||||
}
|
||||
if json.Unmarshal(raw, &r) == nil && r.ID == "node-tools.runtime" {
|
||||
env = r.Env
|
||||
for range 2 { // two passes over the same input compose the same runtime (H-A-303)
|
||||
out, _, _, err := CompositionsIn(tools, "anchor", row.fps, Foreseeing)
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v", row.name, err)
|
||||
}
|
||||
for _, c := range out {
|
||||
for _, raw := range c.Resources {
|
||||
var r struct {
|
||||
ID string `json:"id"`
|
||||
Env map[string]any `json:"env"`
|
||||
}
|
||||
if json.Unmarshal(raw, &r) == nil && r.ID == "node-tools.runtime" {
|
||||
env = r.Env
|
||||
dig, err := engcomp.DigestOf(c)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
digests = append(digests, dig)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(digests) != 2 || digests[0] != digests[1] {
|
||||
t.Errorf("%s: two passes composed the runtime at %v", row.name, digests)
|
||||
}
|
||||
// §519: the words each bundle's module is given hold the fingerprint of the want it applies, where there is one.
|
||||
words := `{"lamp":{"LAMP_CONF":"/var/lib/lamp/conf"}}`
|
||||
wantServed, words := served, `{"lamp":{"LAMP_CONF":"/var/lib/lamp/conf"}}`
|
||||
if fp := row.fps["lamp"]; fp != "" {
|
||||
words = `{"lamp":{"LAMP_CONF":"/var/lib/lamp/conf","MESH_FINGERPRINT":"` + fp + `"}}`
|
||||
}
|
||||
if env[catalogue.RuntimeToolModules] != served || env[catalogue.RuntimeToolEnv] != words {
|
||||
t.Errorf("%s: the runtime serves %v with %v, want what runs of lamp, %s", row.name,
|
||||
env[catalogue.RuntimeToolModules], env[catalogue.RuntimeToolEnv], served)
|
||||
if row.wantServed != "" {
|
||||
wantServed, words = row.wantServed, row.wantWords
|
||||
}
|
||||
if env[catalogue.RuntimeToolModules] != wantServed || env[catalogue.RuntimeToolEnv] != words {
|
||||
t.Errorf("%s: the runtime serves %v with %v, want %s with %s", row.name,
|
||||
env[catalogue.RuntimeToolModules], env[catalogue.RuntimeToolEnv], wantServed, words)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user