selfcompose: a module built by hand, with no running event, is held as running; its trunk build is asked (A-480a)

Builds: design 47 G A-480a (G-22-lead-answers-2.md)
This commit is contained in:
2026-11-17 23:16:33 +01:00
parent 7bfeb466bf
commit 179a4a6402
2 changed files with 27 additions and 18 deletions
+5 -4
View File
@@ -549,12 +549,13 @@ func (c *Composer) needsAddressOf(node, module string) bool {
return false return false
} }
// runsWithoutEntry says this node runs module (heard, not stopped) and holds no entry of its wanted build nor of its running build // 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): the case where its provisions are read from its trunk build (A-480a). // (c.mu held): 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 is held as running unless it was heard stopped.
func (c *Composer) runsWithoutEntry(module string) bool { func (c *Composer) runsWithoutEntry(module string) bool {
run, ok := c.heard[c.env.Node][module] run := c.heard[c.env.Node][module]
w, wanted := c.wants[module] w, wanted := c.wants[module]
if !ok || run.stopped || !wanted || w.Fp == "" { if run.stopped || !wanted || w.Fp == "" {
return false return false
} }
for _, fp := range []string{w.Fp, run.fingerprint} { for _, fp := range []string{w.Fp, run.fingerprint} {
+22 -14
View File
@@ -44,7 +44,10 @@ func composeFromEntries(t *testing.T) {
var mu sync.Mutex var mu sync.Mutex
var asked []string var asked []string
ask := func(_ context.Context, seat, verb string, args any) (json.RawMessage, error) { ask := func(_ context.Context, seat, verb string, args any) (json.RawMessage, error) {
in := args.(meshcatalog.EntryInput) in, isEntry := args.(meshcatalog.EntryInput)
if !isEntry {
return nil, errors.New("the catalog half holds no trunk build here") // A-480a: the module verb, asked of a ghost
}
mu.Lock() mu.Lock()
asked = append(asked, in.Fingerprint) asked = append(asked, in.Fingerprint)
mu.Unlock() mu.Unlock()
@@ -268,20 +271,22 @@ func runningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) {
newest := meshcatalogclient.SourcePrefix2 + strings.Repeat("2", 64) newest := meshcatalogclient.SourcePrefix2 + strings.Repeat("2", 64)
body := `{"module":"postgres","version":"2"}` body := `{"module":"postgres","version":"2"}`
for _, tc := range []struct { for _, tc := range []struct {
name string name string
runs bool runs bool
newest string newest string
holds bool holds bool
laid bool laid bool
wantFp string wantFp string
trunk bool // A-480a: the catalog half's trunk build of the module has an entry (the newest build has none) 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)
}{ }{
{"runs, newest entry held", true, newest, true, true, old, false}, {"runs, newest entry held", true, newest, true, true, old, false, false},
{"not running here", false, newest, true, false, old, false}, {"not running here", false, newest, true, false, old, false, false},
{"names no newer build", true, "", false, false, old, false}, {"names no newer build", true, "", false, false, old, false, false},
{"newest entry not held", true, newest, false, false, old, 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, true}, {"runs, no newest build, trunk entry held (A-480a)", true, "", false, true, old, false, true},
{"not running here, trunk entry held (A-480a)", false, "", false, false, old, true}, {"heard no running event (built by hand), trunk entry held (A-480a)", false, "", false, true, old, false, true},
{"heard stopped, trunk entry held (A-480a)", false, "", false, false, old, true, true},
} { } {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
env := newFakeBus().env() env := newFakeBus().env()
@@ -300,6 +305,9 @@ func runningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) {
if tc.runs { if tc.runs {
c.heard = map[string]map[string]heardRun{"n1": {"postgres": {fingerprint: old}}} c.heard = map[string]map[string]heardRun{"n1": {"postgres": {fingerprint: old}}}
} }
if tc.stopped {
c.heard = map[string]map[string]heardRun{"n1": {"postgres": {fingerprint: old, stopped: true}}}
}
c.mu.Unlock() c.mu.Unlock()
if tc.holds { if tc.holds {
c.holdEntry(t, "postgres", newest, body) c.holdEntry(t, "postgres", newest, body)