From e0632b2c0e8785fd62c8791dd0ddacfab10c9815 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 15 Nov 2026 01:03:16 +0100 Subject: [PATCH] mesh-grants: the part makes the build seats' named workers its composed holders name (A-413) Builds: design 47 G A-413, A-414 --- .../internal/buscompose/derived.go | 13 ++++++++++++ .../internal/buscompose/named_asks_test.go | 15 ++++++++++++- .../mesh-grants/internal/grants/consumers.go | 21 +++++++++++++++++++ modules/mesh-grants/internal/grants/part.go | 1 + 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/modules/mesh-grants/internal/buscompose/derived.go b/modules/mesh-grants/internal/buscompose/derived.go index a87385f1..ddc633d8 100644 --- a/modules/mesh-grants/internal/buscompose/derived.go +++ b/modules/mesh-grants/internal/buscompose/derived.go @@ -309,6 +309,19 @@ func AccountConsumers(users []Principal) []ModuleConsumer { out = append(out, mc) } } + // A build seat's named workers (design 47 G §544, A-413): the seat traffic of each composed holder names them, and the part makes + // them, never only names them in a membership. Main's workers are held already; only the named ones are made here. + made := map[string]bool{} + for _, p := range users { + _, cs := SeatTrafficObjects([]Principal{p}) + for _, c := range cs { + if !strings.HasSuffix(c.Name, "_named_worker") || made[c.Stream+"."+c.Name] { + continue + } + made[c.Stream+"."+c.Name] = true + out = append(out, ModuleConsumer{Node: p.Node, Module: p.Module, Consumer: c}) + } + } return out } diff --git a/modules/mesh-grants/internal/buscompose/named_asks_test.go b/modules/mesh-grants/internal/buscompose/named_asks_test.go index 47370ecc..824dfcc8 100644 --- a/modules/mesh-grants/internal/buscompose/named_asks_test.go +++ b/modules/mesh-grants/internal/buscompose/named_asks_test.go @@ -1,6 +1,9 @@ package buscompose -import "testing" +import ( + "strings" + "testing" +) // Design 47 G §543, §544, §600: a build seat's ask names its asker, each queue has a named worker beside main's, an asker // is granted the queues of its kinds under its own seat's name alone, and main's subject is the checker's and the builder's. @@ -66,6 +69,16 @@ func TestNamedAsks(t *testing.T) { if len(consumers) != 4 { t.Errorf("the work queue's consumers: %d, want 4 (a main and a named worker for each of two queues)", len(consumers)) } + // A-413: the part makes the named workers (AccountConsumers), never only names them in a membership. + named := 0 + for _, mc := range AccountConsumers([]Principal{{Kind: KindModule, Node: "one", Module: "go-module", Holds: []Seat{held}}}) { + if strings.HasSuffix(mc.Consumer.Name, "_named_worker") { + named++ + } + } + if named != 2 { + t.Errorf("account consumers hold %d named workers, want 2", named) + } } // Design 47 G §610, A-179 (test 60's case of §271): a user of a seat is granted a verb's call subject only where the verb's diff --git a/modules/mesh-grants/internal/grants/consumers.go b/modules/mesh-grants/internal/grants/consumers.go index 3934107f..dc141292 100644 --- a/modules/mesh-grants/internal/grants/consumers.go +++ b/modules/mesh-grants/internal/grants/consumers.go @@ -136,6 +136,9 @@ func (p *Part) consumers(res *Result, recs buscompose.Records, match string) { for _, c := range byStream[stream] { key := stream + "." + c.Name h, ok := held[c.Name] + if ok && strings.HasSuffix(c.Name, "_named_worker") { + p.sayWorker(key + " is held already") + } if ok { if h.Pending > BehindBound { if p.behindSeen[key] { @@ -190,6 +193,9 @@ func (p *Part) consumers(res *Result, recs buscompose.Records, match string) { switch err := p.Consumers.CreateConsumer(stream, buscompose.ConsumerConfig(c)); { case err == nil: st.Created = append(st.Created, key) + if strings.HasSuffix(c.Name, "_named_worker") { + p.sayWorker(key + " is created") + } if p.Logf != nil { p.Logf("consumer %s created", key) } @@ -340,3 +346,18 @@ func (p *Part) sayBehind(st *ConsumersState) { p.behindSaid, p.behindKnown = why, true } } + +// sayWorker logs one named seat worker's outcome (created, held already) once per change, so the journal names each worker the +// pass considers (A-413). +func (p *Part) sayWorker(line string) { + p.holdMu.Lock() + if p.workersSaid == nil { + p.workersSaid = map[string]bool{} + } + done := p.workersSaid[line] + p.workersSaid[line] = true + p.holdMu.Unlock() + if !done && p.Logf != nil { + p.Logf("seat worker %s", line) + } +} diff --git a/modules/mesh-grants/internal/grants/part.go b/modules/mesh-grants/internal/grants/part.go index e2187481..1c84dc26 100644 --- a/modules/mesh-grants/internal/grants/part.go +++ b/modules/mesh-grants/internal/grants/part.go @@ -212,6 +212,7 @@ type Part struct { // leftOutSaid is the left-out and wanted-manifest lines last logged, so each change is said once (sayLeftOut). leftOutSaid string namedSaid string + workersSaid map[string]bool heldKnown bool // differSaid is the account consumers' differences last said as a condition, once differKnown (consumers.go). differSaid string