Grants: the holder of a seat pulled by kind says the seat's own events, on its machine where the subject names <node> (A-399): a build seat's step-ended and toolchain-reported were granted to nobody
This commit is contained in:
@@ -500,7 +500,9 @@ func machineEvent(s Seat, e string) (string, bool) {
|
||||
return "", false
|
||||
case perMachineEvents[e]:
|
||||
return strings.TrimSuffix(e, "*") + nodeToken, true
|
||||
case s.HeldByTheEngine:
|
||||
case s.HeldByTheEngine || strings.Contains(s.EventSubjects[e], nodeToken):
|
||||
// The node-engine's seats, and any node seat whose definition names `<node>` in an event's subject (a build seat's
|
||||
// `step-ended.<node>`, `toolchain-reported.<node>`; lead answer A-399).
|
||||
if subject, ok := s.EventSubjects[e]; ok {
|
||||
toks := strings.Split(subject, ".")
|
||||
found := false
|
||||
@@ -522,6 +524,30 @@ func machineEvent(s Seat, e string) (string, bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
// pulledSeatEvents are the events a holder of a seat pulled by kind (and not kinded) says: each the seat emits and no caller
|
||||
// names, on its own machine where the event names one (machineEvent), node "" giving any machine's (the membership's form).
|
||||
func pulledSeatEvents(s Seat, node string) []string {
|
||||
if !s.PulledByKind || s.Kinded {
|
||||
return nil
|
||||
}
|
||||
var out []string
|
||||
for _, e := range s.Emits {
|
||||
if namesVerb(s.ByCaller, e) {
|
||||
continue
|
||||
}
|
||||
if pattern, ok := machineEvent(s, e); ok {
|
||||
if node == "" {
|
||||
out = append(out, seatSubject(s, "event", anyMachine(pattern)))
|
||||
} else {
|
||||
out = append(out, seatSubject(s, "event", onMachine(pattern, node)))
|
||||
}
|
||||
continue
|
||||
}
|
||||
out = append(out, seatSubject(s, "event", e))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// anyMachine is a machineEvent pattern a watcher hears: every machine's.
|
||||
func anyMachine(pattern string) string { return strings.ReplaceAll(pattern, nodeToken, "*") }
|
||||
|
||||
@@ -1114,6 +1140,9 @@ func permissionsFor(p Principal) (Permissions, error) {
|
||||
for _, t := range s.Serves {
|
||||
sub = append(sub, seatToolSubjects(s, t, p.Node)...)
|
||||
}
|
||||
// And a seat pulled by kind says its own events, as any held seat does, its machine's alone (lead answer A-399:
|
||||
// a build seat's step-ended and toolchain-reported were granted to nobody).
|
||||
pub = append(pub, pulledSeatEvents(s, p.Node)...)
|
||||
continue
|
||||
}
|
||||
// Taking work from the role's queue: the worker consumer every holder shares (asked
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package buscompose
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// A-399: the holder of a seat pulled by kind says the seat's own events on its machine (a build seat's step-ended and
|
||||
// toolchain-reported, `<event>.<node>`); on 2026-11-14 they were granted to nobody, so the builder never heard a toolchain.
|
||||
func TestAPulledSeatsHolderSaysItsEvents(t *testing.T) {
|
||||
held := Seat{Name: "node-build-go", Scope: "node", Accepts: []string{"delivery"}, PulledByKind: true,
|
||||
Emits: []string{"step-ended", "toolchain-reported"},
|
||||
EventSubjects: map[string]string{"step-ended": "step-ended.<node>", "toolchain-reported": "toolchain-reported.<node>"}}
|
||||
perms, err := PermissionsFor(Principal{Kind: KindModule, Node: "shanks", Module: "mesh-build-go", Holds: []Seat{held}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, want := range []string{"mesh.seat.node-build-go.event.step-ended.shanks", "mesh.seat.node-build-go.event.toolchain-reported.shanks"} {
|
||||
if !slices.Contains(perms.Publish, want) {
|
||||
t.Errorf("the holder's account is not granted %s", want)
|
||||
}
|
||||
}
|
||||
tr := SeatTrafficOf("mesh-build-go", []Seat{held}, nil, nil)
|
||||
if !slices.Contains(tr.Publish, "mesh.seat.node-build-go.event.toolchain-reported.*") {
|
||||
t.Errorf("the membership does not list toolchain-reported: %v", tr.Publish)
|
||||
}
|
||||
}
|
||||
@@ -184,6 +184,8 @@ func SeatTrafficOf(module string, holds, uses, watches []Seat) SeatTraffic {
|
||||
t.Publish = append(t.Publish, seatSubject(s, "event", e+".*"))
|
||||
}
|
||||
}
|
||||
// A seat pulled by kind: its own events, so the runtime carrying the holder may say them (A-399).
|
||||
t.Publish = append(t.Publish, pulledSeatEvents(s, "")...)
|
||||
if kind != "" {
|
||||
for _, v := range s.Proofs {
|
||||
t.Publish = append(t.Publish, seatSubject(s, "proof", v+"."+kind))
|
||||
|
||||
Reference in New Issue
Block a user