selfcompose: what is read decides the trunk build's stand: the running event's manifest held, a running composition's build read as ranOf reads it (A-480a, A-482)

Builds: design 47 G A-480a, A-482
This commit is contained in:
2026-11-17 23:58:13 +01:00
parent 121a8090b3
commit cdd8bd3cba
3 changed files with 43 additions and 28 deletions
+7 -8
View File
@@ -550,22 +550,21 @@ func (c *Composer) needsAddressOf(node, module string) bool {
}
// runsWithoutEntry says this node holds module on, as it runs it, and holds no entry of its wanted build nor of its running build
// (c.mu held), and that neither its running event nor a composition it runs names the manifest of that build: the case where its
// (c.mu held), and whose running event's manifest is not held (A-480a): the case where its
// provisions are read from its trunk build (A-480a). A module built by hand before G says no running event (the engine says one only
// of a build whose manifest it knows), so it counts as running when its have names a build in the phase running or held (A-482); one
// wanted here that is heard running nowhere, runs nothing here and has no such have does not count.
func (c *Composer) runsWithoutEntry(module string) bool {
run := c.heard[c.env.Node][module]
w, wanted := c.wants[module]
if run.stopped || !wanted || w.Fp == "" || run.manifest != "" || !(c.runsHere(module) || c.haveRuns[module]) {
if run.stopped || !wanted || w.Fp == "" || !(c.runsHere(module) || c.haveRuns[module]) {
return false
}
if c.env.Running != nil {
for _, r := range c.env.Running() {
if r.Module == module && r.FP != "" {
return false // its running composition says the build it runs: its manifest is read there, or its own words say it is not
}
}
// What is read decides (A-480a: "can be read from neither"): the manifest its running event names, where that digest is held;
// a running composition's build is read as frombus ranOf reads it, only through the entry of the wanted fingerprint (the
// loop below), so a composition at another build reads nothing.
if _, read := c.manifests[run.manifest]; run.manifest != "" && read {
return false
}
for _, fp := range []string{w.Fp, run.fingerprint} {
if k, held := c.keptEnt[fp]; held && k.entry.Module != "" {
+24 -13
View File
@@ -281,18 +281,20 @@ func runningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) {
stopped bool // A-480a: heard stopped
trunk bool // A-480a: the catalog half's trunk build of the module has an entry (the newest build has none)
have string // A-482: the phase its have says, naming the build it runs ("" for none)
named bool // A-480a: its running event names a manifest
named string // A-480a: the manifest its running event names ("held": one this node holds, "unread": one it does not)
}{
{"runs, newest entry held", true, newest, true, true, old, false, false, "", false},
{"not running here", false, newest, true, false, old, false, false, "", false},
{"names no newer build", true, "", false, false, old, false, false, "", false},
{"newest entry not held", true, newest, false, false, old, false, false, "", false},
{"runs, no newest build, trunk entry held (A-480a)", true, "", false, true, old, false, true, "", false},
{"heard no running event, its have says running (A-480a, A-482)", false, "", false, true, old, false, true, "running", false},
{"heard no running event, its have says held (A-482)", false, "", false, true, old, false, true, "held", false},
{"wanted here, heard no running event, no have (A-482)", false, "", false, false, old, false, true, "", false},
{"its running event names a manifest (A-480a)", true, "", false, false, old, false, true, "", true},
{"heard stopped, trunk entry held (A-480a)", false, "", false, false, old, true, true, "running", false},
{"runs, newest entry held", true, newest, true, true, old, false, false, "", ""},
{"not running here", false, newest, true, false, old, false, false, "", ""},
{"names no newer build", true, "", false, false, old, false, false, "", ""},
{"newest entry not held", true, newest, false, false, old, false, false, "", ""},
{"runs, no newest build, trunk entry held (A-480a)", true, "", false, true, old, false, true, "", ""},
{"heard no running event, its have says running (A-480a, A-482)", false, "", false, true, old, false, true, "running", ""},
{"heard no running event, its have says held (A-482)", false, "", false, true, old, false, true, "held", ""},
{"wanted here, heard no running event, no have (A-482)", false, "", false, false, old, false, true, "", ""},
{"its running event names a manifest this node holds (A-480a)", true, "", false, false, old, false, true, "", "held"},
{"its running event names a manifest this node cannot read (A-480a)", true, "", false, true, old, false, true, "", "unread"},
{"runs a composition at another build, no manifest read (A-480a)", true, "", false, true, old, false, true, "other", ""},
{"heard stopped, trunk entry held (A-480a)", false, "", false, false, old, true, true, "running", ""},
} {
t.Run(tc.name, func(t *testing.T) {
env := newFakeBus().env()
@@ -311,12 +313,21 @@ func runningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) {
if tc.runs {
c.heard = map[string]map[string]heardRun{"n1": {"postgres": {fingerprint: old}}}
}
if tc.named {
c.heard = map[string]map[string]heardRun{"n1": {"postgres": {fingerprint: old, manifest: "sha256:" + strings.Repeat("9", 64)}}}
if tc.named != "" {
digest := "sha256:" + strings.Repeat("9", 64)
c.heard = map[string]map[string]heardRun{"n1": {"postgres": {fingerprint: old, manifest: digest}}}
if tc.named == "held" {
c.manifests[digest] = []byte(body)
}
}
if tc.have != "" {
c.haveRuns["postgres"] = true
}
if tc.have == "other" {
c.env.Running = func() []compositions.Composed {
return []compositions.Composed{{Node: "n1", Module: "postgres", FP: meshcatalogclient.SourcePrefix2 + strings.Repeat("5", 64)}}
}
}
if tc.stopped {
c.heard = map[string]map[string]heardRun{"n1": {"postgres": {fingerprint: old, stopped: true}}}
}
+12 -7
View File
@@ -1828,22 +1828,24 @@ func TestAHaveSaysWhetherItsModuleRunsInsideTheNodesOwn(t *testing.T) {
in bool
// heldToday says the shadow counts the module held today (issue 1126: a seed holding it too holds it as today).
heldToday bool
// runs says the have names a build in the phase running or held: it keeps running what it runs (A-482).
runs bool
}{
{"failed, naming nothing it runs", nodeengine.HaveByNodeModuleValue{Phase: nodeengineclient.PhaseFailed, Health: nodeengineclient.HealthFailed,
Detail: "the node cannot compose it, and keeps running what it ran: no build"}, false, true},
Detail: "the node cannot compose it, and keeps running what it ran: no build"}, false, true, false},
{"failed at a build fingerprint", nodeengine.HaveByNodeModuleValue{Fp: "build-0123abcd", Composed: "sha256:" + strings.Repeat("c", 64), Phase: nodeengineclient.PhaseFailed,
Health: nodeengineclient.HealthFailed, Detail: "the node cannot compose it, and keeps running what it ran: no build"}, true, true},
Health: nodeengineclient.HealthFailed, Detail: "the node cannot compose it, and keeps running what it ran: no build"}, true, true, false},
// The live have of novox's de-spiegel (2026-10-28): a build of the old form, named by `build`, and no `fp`.
{"running a build of the old form", nodeengine.HaveByNodeModuleValue{Build: "build-1790368817085312877", Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK}, true, true},
{"running a build of the old form", nodeengine.HaveByNodeModuleValue{Build: "build-1790368817085312877", Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK}, true, true, false},
{"running a build of the new form", nodeengine.HaveByNodeModuleValue{Fp: meshcatalogclient.SourcePrefix2 + strings.Repeat("a", 64), Composed: "sha256:" + strings.Repeat("c", 64),
Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK}, false, false},
{"running with no fingerprint (mesh-wireguard)", nodeengine.HaveByNodeModuleValue{Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK}, true, false},
Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK}, false, false, true},
{"running with no fingerprint (mesh-wireguard)", nodeengine.HaveByNodeModuleValue{Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK}, true, false, false},
{"held today", nodeengine.HaveByNodeModuleValue{Fp: "build-0123abcd", Composed: "sha256:" + strings.Repeat("c", 64), Phase: nodeengineclient.PhaseHeld,
Health: nodeengineclient.HealthWaits, Detail: "held: a required config value is unset"}, true, true},
Health: nodeengineclient.HealthWaits, Detail: "held: a required config value is unset"}, true, true, true},
// novox's postgres (2026-10-31), its have written before mesh-host #189: held by a backup the node agent's stop
// interrupted and naming nothing; counted in, it was composed from its manifest and refused for its secret reader.
{"held by an interrupted backup, naming nothing", nodeengine.HaveByNodeModuleValue{Phase: nodeengineclient.PhaseHeld, Health: nodeengineclient.HealthWaits,
Detail: agent.BackupInterrupted}, false, true},
Detail: agent.BackupInterrupted}, false, true, false},
} {
t.Run(row.name, func(t *testing.T) {
c := New(Env{Node: "n1"})
@@ -1859,6 +1861,9 @@ func TestAHaveSaysWhetherItsModuleRunsInsideTheNodesOwn(t *testing.T) {
if c.inOwn["web"] != row.in {
t.Errorf("web counted inside the node's own composition: %v, want %v", c.inOwn["web"], row.in)
}
if c.haveRuns["web"] != row.runs {
t.Errorf("web counted as running by its have: %v, want %v", c.haveRuns["web"], row.runs)
}
s := &Shadow{c: c, ran: map[string]string{}}
s.takeRan(agent.Update{Key: key, Value: value})
if _, got := s.heldToday(nil)["web"]; got != row.heldToday {