H1 integration bound: a reload's stand-in serves no repairs; stop waits its Say

Review round 1. A ledger binding heard while a module was loaded again
made refreshRepairs serve the repairs on the reload's stand-in, whose
subscriptions nobody stopped: the repairs were served twice, and still
answered after the runtime stopped. The stand-in is now marked as
reloading and the refresh leaves it alone; the reload serves the module's
repairs as its binding is when the load ends. The reload test holds a
bundle's start, issues the binding inside the reload, and asks a repair
after the runtime stopped: without the change it still answered (6 of 6
runs, GOMAXPROCS=1 and 24).

No test failed without keep's stop waiting for the heartbeat's goroutine.
The heartbeat test now holds one Say and stops meanwhile: stop must not
return before that Say has; without the wait it failed 50 of 50 runs at
GOMAXPROCS=1 and at 24.

Builds: design 47 H §774, H-A-160; principle 11
This commit is contained in:
2026-11-20 17:45:50 +01:00
parent 05deea5952
commit 8ee4fdfb8e
3 changed files with 100 additions and 5 deletions
+13 -1
View File
@@ -177,6 +177,11 @@ func (r *runner) refreshRepairs() {
changed := false
for _, m := range r.modules {
l := r.of[m]
// A module being loaded again is left to its reload, which serves its repairs as its binding is then: served
// here on the stand-in, they would be served twice and never stopped (design 47 H, H-A-160).
if l.reloading {
continue
}
served := false
for _, reg := range l.own {
served = served || reg.repairs
@@ -205,6 +210,8 @@ type loadedModule struct {
failed string
names []string // the tools it serves, as module.tool
serving map[string]func() // its tools' subscriptions, by module.tool; serve alone changes it
// reloading marks the stand-in a reload puts in place while it loads the module again: it serves nothing.
reloading bool
}
// unload stops serving the module's tools and stops its bundles.
@@ -631,7 +638,7 @@ func (r *runner) reconcile() {
func (r *runner) reload(module, what string) {
r.mu.Lock()
old := r.of[module]
r.of[module] = &loadedModule{served: old.served, seen: old.seen}
r.of[module] = &loadedModule{served: old.served, seen: old.seen, reloading: true}
r.mu.Unlock()
// Its events are refused first, so one heard while the old bundle stops is refused at once.
r.events.dropModule(module)
@@ -646,6 +653,11 @@ func (r *runner) reload(module, what string) {
r.logf("[mesh-tools] %s's bundle is refused: %v; its tools are not served here", module, err)
}
r.mu.Lock()
// Its repairs as its binding is now, not as it was when the load began: the refresh left the stand-in alone.
if fresh.failed == "" {
repairs := r.repairsOf(module)
fresh.own, fresh.regs = withRepairs(fresh.own, repairs), withRepairs(fresh.regs, repairs)
}
r.of[module] = fresh
r.serve(fresh)
r.bindVerbs()