From 501ff49abe2b03fcd420792de368dac115cb9cc2 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 24 Nov 2026 21:24:42 +0100 Subject: [PATCH] mesh-grants: the tool runner publishes its own node's machine event of a seat a carried module holds The grants part granted a held seat's events to the holder's own account only (nats.go "Seats it holds"), so a module the tool runner carries (networkmanager's node-uplink, nftables' node-packet-filter) had no way to say the machine's half of its own seat's events: SeatTrafficOf explicitly leaves a machine event out of the tool runner's membership and defers to that rule, which never runs for KindNodeTools. Grant it the same machineEvent-derived subject, for its own node's machine only, mirroring step 3 of PermissionsFor's KindModule case. Builds: design 08 sign-in-page DMC-1, Where --- .../internal/buscompose/buscompose_test.go | 18 ++++++++++++++++-- .../mesh-grants/internal/buscompose/nats.go | 11 +++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/modules/mesh-grants/internal/buscompose/buscompose_test.go b/modules/mesh-grants/internal/buscompose/buscompose_test.go index 723119064..37f0cc05e 100644 --- a/modules/mesh-grants/internal/buscompose/buscompose_test.go +++ b/modules/mesh-grants/internal/buscompose/buscompose_test.go @@ -894,8 +894,9 @@ func healthChecks(t *testing.T) { } // Issue 1952: a module that holds a seat says its own seat's events, also when the tool runner carries it, so the // self-check's `checked`, the keeper's condition events and the healers' `healer-acted` reach their hearers. Its - // membership lists them, the runtime is granted them; a user of the seat is not, nor a machine's event on a node seat - // (granted per machine, to the holder's own account only). + // membership lists them, the runtime is granted them; a user of the seat is not, nor another machine's event on a + // node seat (granted per machine, to the holder's own account only; the holder's own machine's is design 08 + // sign-in-page DMC-1, tested below). selfCheck := Declared{Module: "mesh-self-check", Holds: []Seat{{Name: "mesh-self-check", Scope: "mesh", Emits: []string{"checked"}}}} for _, c := range []struct { name string @@ -925,6 +926,19 @@ func healthChecks(t *testing.T) { MayPublish(perms, c.subject), c.may) } } + // Design 08 sign-in-page DMC-1: the grants part grants the tool runner the publish of its own node's machine + // event of a seat a module it carries holds (networkmanager's node-uplink, nftables' node-packet-filter would both + // be such a seat once their manifests declare the event), never another node's — the tool runner has no other way + // to say it, unlike the holder's own account (step 3 of PermissionsFor's KindModule case, the same machineEvent + // rule used there). + carryingPower := Declared{Module: "pause", Holds: []Seat{{Name: "node-power", Scope: "node", Emits: []string{"paused.*"}}}} + if perms, err := PermissionsFor(Principal{Kind: KindNodeTools, Node: "a", Carries: []Declared{carryingPower}}); err != nil { + t.Fatal(err) + } else if !MayPublish(perms, "mesh.seat.node-power.event.paused.a") { + t.Errorf("the tool runner on a carrying pause may not say node-power's paused for its own node") + } else if MayPublish(perms, "mesh.seat.node-power.event.paused.b") { + t.Errorf("the tool runner on a carrying pause may say node-power's paused for another node") + } // Lead answer A-280 (A-274, §529): the enrolment's membership lists its finding-events stream under its binding's subject // with the machine last, and the finding events, so the tool runner carrying it says them there and is granted them. enrolment := Declared{Module: "mesh-enrolment", FindingEvents: []string{"finding-written.*", "finding-cleared.*", "findings-stated.*"}, diff --git a/modules/mesh-grants/internal/buscompose/nats.go b/modules/mesh-grants/internal/buscompose/nats.go index f794266e5..05b244be4 100644 --- a/modules/mesh-grants/internal/buscompose/nats.go +++ b/modules/mesh-grants/internal/buscompose/nats.go @@ -1287,6 +1287,17 @@ func permissionsFor(p Principal) (Permissions, error) { for _, t := range s.Serves { sub = append(sub, seatToolSubjects(s, t, p.Node)...) } + // A carried module's held seat's own machine's event (design 08 sign-in-page DMC-1): step 3 above + // grants a module's own account its seat's machine event (ADR 0219), but a module the tool runner + // carries publishes only through the runtime, which SeatTrafficOf leaves to this rule (seattraffic.go + // "A holder says its own seat's events"). Granted for this node alone, never another's. + if !s.isNewTraffic() { + for _, e := range s.Emits { + if pattern, ok := machineEvent(s, e); ok && p.Node != "" { + pub = append(pub, seatSubject(s, "event", onMachine(pattern, p.Node))) + } + } + } } } // Every assigned module's membership on this node (ADR 0160): one per module, read and watched from the