From 501ff49abe2b03fcd420792de368dac115cb9cc2 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 24 Nov 2026 21:24:42 +0100 Subject: [PATCH 1/3] 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 -- 2.54.0 From ef8dd1207a22132b292b95e795ff6e64bd9a5adf Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 24 Nov 2026 21:53:35 +0100 Subject: [PATCH 2/3] mesh-grants: list the held seat's own-node machine event in the carried module's membership too Code review round 1, C-1: granting the subject in the tool runner's NATS account (the previous commit) is not enough, because the runtime's own mayPublish (node-tools/internal/bus/seat.go) checks a module's membership (SeatTraffic.Publish), never the account permissions. SeatTrafficOf leaves a held seat's machine event out of that list and defers to the held-seats' account grant, which the membership check never reads. MembershipFor now lists it too, on the carried module's own node alone. Golden file testdata/user-lists.json updated: the existing "pause" fixture (node-power's machine event "paused") now also appears in its seat-traffic publish list. Builds: design 08 sign-in-page C-1 --- .../internal/buscompose/buscompose_test.go | 22 ++++++------------- .../internal/buscompose/membership.go | 15 +++++++++++++ .../buscompose/testdata/user-lists.json | 3 ++- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/modules/mesh-grants/internal/buscompose/buscompose_test.go b/modules/mesh-grants/internal/buscompose/buscompose_test.go index 37f0cc05e..db68f1fd9 100644 --- a/modules/mesh-grants/internal/buscompose/buscompose_test.go +++ b/modules/mesh-grants/internal/buscompose/buscompose_test.go @@ -895,8 +895,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 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). + // node seat (granted per machine, to the holder's own account only; the holder's own machine's, design 08 + // sign-in-page C-1, is the node-uplink row below: both the membership the runtime's own mayPublish reads + // and the account's grant must list it). selfCheck := Declared{Module: "mesh-self-check", Holds: []Seat{{Name: "mesh-self-check", Scope: "mesh", Emits: []string{"checked"}}}} for _, c := range []struct { name string @@ -914,6 +915,10 @@ func healthChecks(t *testing.T) { Scope: "node", Emits: []string{"paused.*"}}}}, "mesh.seat.node-power.event.paused.b", false}, {"a flat event of a node seat held by a module is said flat", Declared{Module: "pause", Holds: []Seat{{Name: "node-power", Scope: "node", Emits: []string{"slept"}}}}, "mesh.seat.node-power.event.slept", true}, + {"a carried module's own seat's machine event is composed for the tool runner's own node (design 08 sign-in-page C-1)", + Declared{Module: "networkmanager", Holds: []Seat{{Name: "node-uplink", Scope: "node", Emits: []string{"sign-in-asked"}, + EventSubjects: map[string]string{"sign-in-asked": "sign-in-asked."}}}}, + "mesh.seat.node-uplink.event.sign-in-asked.a", true}, } { m := MembershipFor("a", c.d, Assignments{}) listed := m.SeatTraffic != nil && slices.ContainsFunc(m.SeatTraffic.Publish, func(p string) bool { return p == c.subject }) @@ -926,19 +931,6 @@ 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/membership.go b/modules/mesh-grants/internal/buscompose/membership.go index 4d4ec27c4..4f15dada1 100644 --- a/modules/mesh-grants/internal/buscompose/membership.go +++ b/modules/mesh-grants/internal/buscompose/membership.go @@ -67,6 +67,21 @@ func MembershipFor(node string, d Declared, where Assignments) Membership { m.Streams = append(streamsIssuedFor(d), findingEventsIssued(d, node)...) m.Hears = HeardIssuedFor(node, d) t := SeatTrafficOf(d.Module, d.Holds, d.Uses, d.Watches) + // A held seat's own-node machine event (novox/hq design 08 sign-in-page C-1): SeatTrafficOf leaves it out of + // t.Publish (seattraffic.go, "A holder says its own seat's events") and defers to the held-seats' grant a + // module's own account has, which the runtime's mayPublish never consults — only the membership's own + // SeatTraffic.Publish does (mesh-tools node-tools/internal/bus/seat.go). Listed here, on this node alone, so a + // module the tool runner carries may say it too. + for _, s := range d.Holds { + if s.isNewTraffic() { + continue + } + for _, e := range s.Emits { + if pattern, ok := machineEvent(s, e); ok && node != "" { + t.Publish = append(t.Publish, seatSubject(s, "event", onMachine(pattern, node))) + } + } + } for _, s := range append(append([]Seat{}, d.Uses...), d.Watches...) { if !s.Kinded { continue diff --git a/modules/mesh-grants/internal/buscompose/testdata/user-lists.json b/modules/mesh-grants/internal/buscompose/testdata/user-lists.json index 8bd9faf22..8cdd1f26e 100644 --- a/modules/mesh-grants/internal/buscompose/testdata/user-lists.json +++ b/modules/mesh-grants/internal/buscompose/testdata/user-lists.json @@ -344,7 +344,8 @@ "tools": "mesh.mod.pause.tool.tools", "seat-traffic": { "publish": [ - "mesh.seat.node-power.event.slept" + "mesh.seat.node-power.event.slept", + "mesh.seat.node-power.event.paused.ace" ] } }, -- 2.54.0 From 0509270388412bdb23a282f0f679c726ece96b9c Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 01:13:51 +0100 Subject: [PATCH 3/3] mesh-grants: test that node-uplink's machine event reaches no other node's membership or grant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code review round 2: §4a says the grant and the membership cover the holder's own node's subjects only. Add the negative row beside C-1's: a tool runner on node a, carrying networkmanager, is neither listed for nor granted sign-in-asked.b. Passes already (onMachine substitutes the tool runner's own node and nothing else), proving the fix does not overreach. Builds: design 08 sign-in-page §4a --- modules/mesh-grants/internal/buscompose/buscompose_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/mesh-grants/internal/buscompose/buscompose_test.go b/modules/mesh-grants/internal/buscompose/buscompose_test.go index db68f1fd9..c78a43f1a 100644 --- a/modules/mesh-grants/internal/buscompose/buscompose_test.go +++ b/modules/mesh-grants/internal/buscompose/buscompose_test.go @@ -919,6 +919,10 @@ func healthChecks(t *testing.T) { Declared{Module: "networkmanager", Holds: []Seat{{Name: "node-uplink", Scope: "node", Emits: []string{"sign-in-asked"}, EventSubjects: map[string]string{"sign-in-asked": "sign-in-asked."}}}}, "mesh.seat.node-uplink.event.sign-in-asked.a", true}, + {"a carried module's own seat's machine event is composed for no other node (design 08 sign-in-page §4a)", + Declared{Module: "networkmanager", Holds: []Seat{{Name: "node-uplink", Scope: "node", Emits: []string{"sign-in-asked"}, + EventSubjects: map[string]string{"sign-in-asked": "sign-in-asked."}}}}, + "mesh.seat.node-uplink.event.sign-in-asked.b", false}, } { m := MembershipFor("a", c.d, Assignments{}) listed := m.SeatTraffic != nil && slices.ContainsFunc(m.SeatTraffic.Publish, func(p string) bool { return p == c.subject }) -- 2.54.0