grants: a module's own account sends the chunks of a verb of a seat it holds (A-115)

The validation of mesh-delivery #219 failed twice: the indexer answered seat:mesh-catalog.input, and the bus refused
its chunks, since only an account whose process repeats the verb in serves was granted to send them. The indexer's
and the assigner's programs answer their seat's input verb on the module's own account; their claims say they serve it.
This commit is contained in:
2026-11-15 22:40:36 +01:00
parent 2682a623de
commit 7c33a2cf4c
2 changed files with 14 additions and 1 deletions
@@ -1428,6 +1428,7 @@ func chunkSubjectsFollowTheAnswerer(t *testing.T) {
{Module: "recovery", Invokes: []string{"seat:mesh-broker.snapshot-get"}, Processes: []ProcessPrincipal{{Process: "recover", Invokes: []string{"seat:mesh-broker.snapshot-get"}}}},
{Module: "admin-ish", Invokes: []string{"*"}},
{Module: "plain-serve", ServesOwn: []string{"seat:mesh-broker.snapshot-get"}},
{Module: "claim-only", Holds: []Seat{{Name: meshbroker.Seat, Serves: []string{"snapshot-get"}}}},
{Module: "mod-x", Streams: []ModuleStream{{Module: "mod-x", Name: "SECRETS", Events: []string{"sealed"}, Restricted: true},
{Module: "mod-x", Name: "PLAIN", Events: []string{"plain"}}}},
}}}
@@ -1456,6 +1457,10 @@ func chunkSubjectsFollowTheAnswerer(t *testing.T) {
!has(m.Publish, chunks) || !has(m.Subscribe, servedAcks) {
t.Errorf("the module account of a bus-less serving process may not answer the verb and send chunks: %v / %v", m.Publish, m.Subscribe)
}
// A module holding the seat sends the chunks of its verb on its own account, though no process repeats it in `serves`.
if m := perms["a.claim-only"]; !has(m.Publish, chunks) || !has(m.Subscribe, servedAcks) {
t.Errorf("the module account holding the seat may not send its verb's chunks: %v / %v", m.Publish, m.Subscribe)
}
if rec := perms["a.recovery"]; !has(rec.Subscribe, chunks) || !has(rec.Publish, acks) || has(rec.Publish, chunks) {
t.Errorf("the account naming the verb may not hear chunks and send acks, or may send chunks: %v / %v", rec.Publish, rec.Subscribe)
}
@@ -50,7 +50,10 @@ func chunkGrants(p Principal) (pub, sub []string) {
return nil, nil
}
for _, c := range p.Chunked {
if (p.Kind == KindProcess || p.Kind == KindModule) && slices.Contains(p.AnswersSeat, "seat:"+c.Seat+"."+c.Verb) {
// The module's own account sends the chunks of a verb of a seat it holds too: its claim says it serves the verb, and a
// process with no bus of its own answers it on that account, whether or not its resource repeats it in `serves` (A-115;
// the indexer's input and the assigner's wants input were refused their chunks for that line alone).
if (p.Kind == KindProcess || p.Kind == KindModule) && slices.Contains(p.AnswersSeat, "seat:"+c.Seat+"."+c.Verb) || p.Kind == KindModule && holdsVerb(p.Holds, c) {
pub, sub = append(pub, chunkSubject(c)), append(sub, ackServed(c))
}
// Any account of a module, its processes, its node or the tool runner may receive a verb's chunks, invoked or not
@@ -63,6 +66,11 @@ func chunkGrants(p Principal) (pub, sub []string) {
return pub, sub
}
// holdsVerb says one of the seats held serves the chunked verb.
func holdsVerb(holds []Seat, c ChunkVerb) bool {
return slices.ContainsFunc(holds, func(s Seat) bool { return s.Name == c.Seat && slices.Contains(s.Serves, c.Verb) })
}
// restoreGrants are the keeper's standing grant of the bus's stream restore subjects and their chunk subjects, for the bus names
// of the streams ADR 0436 §3 restricts and only those (design 47 G §681, A-60): the restore request of each and the chunks the
// snapshot is sent to.