The node-engine follows the module-assignment seat: assignments, not placement; the seat's packages move to mesh-contracts and mesh-delivery (issue 1966)

The state, events and types of the seat mesh-module-assigner say assignments; the legacy node key form is gone from the
reads; the dead seat-verb list of the retired name is deleted. The placement guard and the placed-file sense stay.

Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
2026-11-05 22:08:40 +01:00
parent e1b9f3e095
commit 8717ec76d4
58 changed files with 581 additions and 616 deletions
+39 -39
View File
@@ -2,7 +2,7 @@
// modules and its own composition with mesh-sdk's composer, from what is on the bus, and hands the compositions to the
// agent as the agent once read them from the controller's bucket `composed-<node>`.
//
// **It watches, it never polls** (ADR 0547 §2): its inputs are watches of the node's wants, the indexer's placement and
// **It watches, it never polls** (ADR 0547 §2): its inputs are watches of the node's wants, the indexer's assignment and
// modules, every node's own have key (where a node's record rides, ADR 0555 §3) and mesh-config's resolved values of this
// node. A change of any of them marks the node to compose again; one loop drains the mark, so a burst of changes composes
// the node once (composing one node takes 0.8 to 4.4 s, measured 2026-10-26). It hands the agent only the compositions that
@@ -19,14 +19,14 @@ import (
"encoding/json"
"errors"
"fmt"
"git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient"
"git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient"
"git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
"git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
"git.novox.be/novox/mesh-contracts/identity-and-access/go/clients/meshvaultclient"
"git.novox.be/novox/mesh-contracts/placement/go/clients/meshmoduleassignerclient"
"git.novox.be/novox/mesh-contracts/placement/go/seats/meshmoduleassigner"
"git.novox.be/novox/mesh-contracts/placement/go/seats/meshwants"
"git.novox.be/novox/mesh-delivery/contracts/go/clients/meshcatalogclient"
"git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
"git.novox.be/novox/mesh-delivery/contracts/go/seats/meshwants"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
"git.novox.be/novox/mesh-sdk/go/declaration"
"github.com/novox/mesh-host/internal/buckets"
@@ -135,13 +135,13 @@ const VaultSecretChanged = "mesh.mod.mesh-vault.event.secret-changed"
type Composer struct {
env Env
mu sync.Mutex
wants map[string]meshwants.WantsByWantNodeModuleValue // by module, the node's own under agent.NodeModule
placements map[string]meshmoduleassigner.Placement
// placementKeys is the seat's state placement key by key in either form, each node's placement assembled from it
mu sync.Mutex
wants map[string]meshwants.WantsByWantNodeModuleValue // by module, the node's own under agent.NodeModule
assignments map[string]meshmoduleassigner.Assignments
// assignmentKeys is the seat's state assignment key by key in either form, each node's assignment assembled from it
// (meshmoduleassignerclient.Keys; research 072 row 37): a write of the holder's under way is never composed half.
placementKeys *meshmoduleassignerclient.Keys
records map[string]nodeengine.NodeRecord
assignmentKeys *meshmoduleassignerclient.Keys
records map[string]nodeengine.NodeRecord
// inOwn is, by module, whether this node's have of it names no fingerprint of the new form (mesh-wireguard, a module
// at a build of the old form): the node runs it inside its own composition, and composes it there again (issue 1126).
inOwn map[string]bool
@@ -307,7 +307,7 @@ func New(env Env) *Composer {
if env.Say == nil {
env.Say = func(string) {}
}
return &Composer{env: env, wants: map[string]meshwants.WantsByWantNodeModuleValue{}, placements: map[string]meshmoduleassigner.Placement{}, placementKeys: meshmoduleassignerclient.NewKeys(),
return &Composer{env: env, wants: map[string]meshwants.WantsByWantNodeModuleValue{}, assignments: map[string]meshmoduleassigner.Assignments{}, assignmentKeys: meshmoduleassignerclient.NewKeys(),
records: map[string]nodeengine.NodeRecord{}, inOwn: map[string]bool{}, modules: map[string]meshcatalog.ModulesByModuleValue{}, values: map[string]map[string]any{},
manifests: map[string][]byte{}, archives: map[string][]byte{}, builds: map[string]builds.BuilderBuild{}, handed: map[string]string{}, sealedOwn: map[string]ownSealed{},
pkgs: map[string]compositions.Composed{}, asked: make(chan chan Pass, 8)}
@@ -363,7 +363,7 @@ func (c *Composer) inputs() []input {
node := c.env.Node
return []input{
{buckets.Wants, "want." + node + ".>", (*Composer).takeWant, nil},
{buckets.Placement, ">", (*Composer).takePlacement, nil},
{buckets.Assignments, ">", (*Composer).takeAssignments, nil},
// Every node's record, and this node's own haves (what it runs inside its own composition): two watches, each
// within the node's grant (buscompose: readGrants of the have bucket at `*.node`, NodeKeysGrants at `<node>.>`).
// A watch of every key is refused by the bus (issue 1126, 2026-10-27 09:21: the fold's `>` stopped every agent).
@@ -396,7 +396,7 @@ func (c *Composer) takeBuildDone(u agent.Update) bool {
w, wanted := c.wants[module]
m := c.modules[module]
placedHere := false
for _, pm := range c.placements[c.env.Node].Modules {
for _, pm := range c.assignments[c.env.Node].Modules {
placedHere = placedHere || pm.Module == module
}
c.mu.Unlock()
@@ -593,7 +593,7 @@ func (c *Composer) caughtSent() bool {
return sent
}
// takeChanged takes u through in.take and says whether the entry it names changed: a want, a placement, a module or a
// takeChanged takes u through in.take and says whether the entry it names changed: a want, a assignment, a module or a
// config value written again with the value it held changes nothing composed, so it makes no pass (issue 774,
// 2026-10-31: every put under want.<node>.> made a pass, and each pass asked the vault for the node's own secrets).
func (c *Composer) takeChanged(in input, u agent.Update) bool {
@@ -623,14 +623,14 @@ func (c *Composer) entry(bucket, key string) (v any, has, known bool) {
}
w, ok := c.wants[module]
return w.Fp, ok, true
case buckets.Placement:
// Any key of a node, its node key, a module key or its legacy key, stands for the node's whole placement: a
case buckets.Assignments:
// Any key of a node, its node key, a module key or its legacy key, stands for the node's whole assignment: a
// module key written before its node key names it changes nothing composed.
node, _, _, err := meshmoduleassignerclient.ParseKey(key)
if err != nil {
return nil, false, true
}
p, ok := c.placements[node]
p, ok := c.assignments[node]
return p, ok, true
case buckets.Modules:
name, err := meshcatalogclient.ParseModulesKey(key)
@@ -677,25 +677,25 @@ func (c *Composer) takeWant(u agent.Update) {
c.wants[module] = w
}
func (c *Composer) takePlacement(u agent.Update) {
func (c *Composer) takeAssignments(u agent.Update) {
if u.Caught {
return
}
c.mu.Lock()
if c.placementKeys == nil {
c.placementKeys = meshmoduleassignerclient.NewKeys()
if c.assignmentKeys == nil {
c.assignmentKeys = meshmoduleassignerclient.NewKeys()
}
node, err := c.placementKeys.Put(u.Key, u.Value, u.Revision, u.Deleted || len(u.Value) == 0)
node, err := c.assignmentKeys.Put(u.Key, u.Value, u.Revision, u.Deleted || len(u.Value) == 0)
if node != "" {
if p, _, ok := c.placementKeys.Of(node); ok {
c.placements[node] = p
if p, _, ok := c.assignmentKeys.Of(node); ok {
c.assignments[node] = p
} else {
delete(c.placements, node)
delete(c.assignments, node)
}
}
c.mu.Unlock()
if node != "" && err != nil && c.env.Say != nil {
c.env.Say("the seat's placement of " + node + ": " + err.Error())
c.env.Say("the seat's assignment of " + node + ": " + err.Error())
}
}
@@ -758,14 +758,14 @@ func (c *Composer) takeModuleHave(u agent.Update) bool {
}
// inOwnOf is, of the modules p places, those the node runs inside its own composition (c.inOwn), sorted; c.mu held.
// Machines is, from the placements this composer holds, each node by its address on the private network, and the hub's
// Machines is, from the assignments this composer holds, each node by its address on the private network, and the hub's
// node: what names the machine a failing network part points at (nodeengine.NetworkPart.Targets, issue 774). Empty
// before any placement is read.
// before any assignment is read.
func (c *Composer) Machines() (byAddress map[string]string, hub string) {
c.mu.Lock()
defer c.mu.Unlock()
byAddress = map[string]string{}
for node, p := range c.placements {
for node, p := range c.assignments {
if a, _, _ := strings.Cut(p.Decided.Address, "/"); a != "" {
byAddress[a] = node
}
@@ -776,7 +776,7 @@ func (c *Composer) Machines() (byAddress map[string]string, hub string) {
return byAddress, hub
}
func (c *Composer) inOwnOf(p meshmoduleassigner.Placement) []string {
func (c *Composer) inOwnOf(p meshmoduleassigner.Assignments) []string {
var out []string
for _, m := range p.Modules {
if c.inOwn[m.Module] {
@@ -874,14 +874,14 @@ func (c *Composer) compose(ctx context.Context) []agent.Update {
_, nodeWanted := c.wants[agent.NodeModule]
// What it runs inside its own composition and no want names at a build of the new form stays there, as the
// controller's composed writer folds it (issue 1126); compose folds none a want names.
own, placed := c.placements[c.env.Node]
own, placed := c.assignments[c.env.Node]
inOwn := c.inOwnOf(own)
r := reader{c: c}
c.mu.Unlock()
if !placed {
// The catalogue does not place it: it composes nothing, applies no composition made elsewhere, and this is no
// refusal of what it runs (issue 1126).
c.sayOnce("this node's key in the seat's placement state is gone: it composes nothing of its own, and keeps running what it runs")
c.sayOnce("this node's key in the seat's assignment state is gone: it composes nothing of its own, and keeps running what it runs")
c.paid() // nothing of its own to compose, so no pass is owed and no timer armed again
return nil
}
@@ -1317,10 +1317,10 @@ func (r reader) VaultAuthority(context.Context) string {
var _ frombus.SignersReader = reader{}
// certificateWanted says whether a module the placement p puts on this node asks for a certificate for the machine's
// certificateWanted says whether a module the assignment p puts on this node asks for a certificate for the machine's
// internal name (its manifest's `certificate`), read from the indexer's manifests; a manifest that cannot be read is
// taken as asking none, and the composition says what it misses.
func (c *Composer) certificateWanted(ctx context.Context, r reader, p meshmoduleassigner.Placement) bool {
func (c *Composer) certificateWanted(ctx context.Context, r reader, p meshmoduleassigner.Assignments) bool {
for _, m := range p.Modules {
c.mu.Lock()
digest := c.modules[m.Module].Manifest
@@ -1348,7 +1348,7 @@ func (c *Composer) certificateWanted(ctx context.Context, r reader, p meshmodule
// certifyIfWanted asks Certify once per serving key when a module placed here asks for a certificate and this node's
// record holds none for its internal name and serving key from an authority it trusts (the one it holds, or the vault's).
func (c *Composer) certifyIfWanted(ctx context.Context, r reader, p meshmoduleassigner.Placement) {
func (c *Composer) certifyIfWanted(ctx context.Context, r reader, p meshmoduleassigner.Assignments) {
if c.env.Certify == nil || !c.certificateWanted(ctx, r, p) {
return
}
@@ -1377,11 +1377,11 @@ func (c *Composer) certifyIfWanted(ctx context.Context, r reader, p meshmoduleas
c.mu.Unlock()
}
func (r reader) Placements(context.Context) (map[string]meshmoduleassigner.Placement, error) {
func (r reader) Assignments(context.Context) (map[string]meshmoduleassigner.Assignments, error) {
r.c.mu.Lock()
defer r.c.mu.Unlock()
out := make(map[string]meshmoduleassigner.Placement, len(r.c.placements))
for k, v := range r.c.placements {
out := make(map[string]meshmoduleassigner.Assignments, len(r.c.assignments))
for k, v := range r.c.assignments {
out[k] = v
}
return out, nil
@@ -1721,7 +1721,7 @@ func Transient(err error) bool {
// ComposedToday is the digest of module composed at the build fp with today's settings and secrets, as this node would
// compose it now beside its other modules at their wanted builds, the boxes it runs kept as compose keeps them, and whether
// it composed (novox/hq ADR 0601 §1): the node agent compares it with what runs, to say whether a move to another build
// changes the build alone. A module held, a node refused, or no placement: false, and the move is asked of a person.
// changes the build alone. A module held, a node refused, or no assignment: false, and the move is asked of a person.
func (c *Composer) ComposedToday(ctx context.Context, module, fp string) (string, bool) {
c.mu.Lock()
fps, kept := map[string]string{}, map[string]string{}
@@ -1739,7 +1739,7 @@ func (c *Composer) ComposedToday(ctx context.Context, module, fp string) (string
if mm, ok := c.modules[module]; !ok || mm.Fp2 != fp {
kept[module] = fp
}
own, placed := c.placements[c.env.Node]
own, placed := c.assignments[c.env.Node]
inOwn := c.inOwnOf(own)
c.mu.Unlock()
if !placed {