Refuse an apply that would remove a resource of a module a want still places here, so a composition that lost what runs can never remove the bus server or a held module again (issue 774)

This commit is contained in:
2026-10-29 21:04:17 +01:00
parent d2645a27e9
commit a7acee3eed
4 changed files with 129 additions and 31 deletions
+14
View File
@@ -1042,6 +1042,20 @@ func (a *Agent) Everything() []delivery.Composed {
return a.others("\x00")
}
// Placed is the modules a want still places on the node (present and not removed), held ones included, but except:
// what no apply but the module's own may remove (apply.Scope.Placed, issue 774). Called without a.mu held.
func (a *Agent) Placed(except string) map[string]bool {
a.mu.Lock()
defer a.mu.Unlock()
out := map[string]bool{}
for m, w := range a.wants {
if m != NodeModule && m != except && w.Present && !w.Want.Removed {
out[m] = true
}
}
return out
}
// HoldsNode says whether the agent runs the node's own composition, so the node's parts are its and not the kept
// declaration's.
func (a *Agent) HoldsNode() bool {