Merge pull request 'mesh-grants: the tool runner may publish its own node's machine event of a held seat (design 08 sign-in-page §4a)' (#364) from feat/sign-in-page into main

This commit was merged in pull request #364.
This commit is contained in:
2026-11-25 00:20:06 +00:00
4 changed files with 40 additions and 3 deletions
@@ -894,8 +894,10 @@ 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, 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
@@ -913,6 +915,14 @@ 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.<node>"}}}},
"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.<node>"}}}},
"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 })
@@ -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
@@ -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
@@ -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"
]
}
},