grants: every module account may put an ask on any seat (principle 6)
The bus refused the indexer's validation ask and the pipeline runner's step asks: a named ask was granted only from the seat definition's callers and a composed manifest, and both accounts were kept from the list in force without them. The operator, 2026-11-15 about 18:10 CET: no fine-grained permissions inside the mesh; every account of a module, its processes, its node and the tool runner is granted mesh.seat.*.accept.>, composed or kept. A seat's events and verbs keep their own rules until the research after G decides the whole shape.
This commit is contained in:
@@ -203,7 +203,7 @@ func TestTheCopiedComposerComposesAsTheControllers(t *testing.T) {
|
||||
for subject, want := range map[string]bool{
|
||||
"mesh.seat.operator-channel.accept.ask.node-engine-one": true,
|
||||
"mesh.seat.operator-channel.accept.cancel.node-engine-one": true,
|
||||
"mesh.seat.operator-channel.accept.ask.node-engine-two": false,
|
||||
"mesh.seat.operator-channel.accept.ask.node-engine-two": true, // any ask (principle 6)
|
||||
"$JS.API.DIRECT.GET.KV_messenger_asks.$KV.messenger_asks.node-engine-one.hand-over-1": true,
|
||||
"$JS.API.DIRECT.GET.KV_messenger_asks.$KV.messenger_asks.node-engine-two.hand-over-1": false,
|
||||
"mesh.seat." + EngineSeat + ".event.done.one": true,
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Design 47 G §543, §544, §600: a build seat's ask names its asker, each queue has a named worker beside main's, an asker
|
||||
// is granted the queues of its kinds under its own seat's name alone, and main's subject is the checker's and the builder's.
|
||||
// Design 47 G §543, §544, §600: a build seat's ask names its asker and each queue has a named worker beside main's; any module may
|
||||
// put any ask (principle 6, the operator 2026-11-15).
|
||||
func TestNamedAsks(t *testing.T) {
|
||||
build := Seat{Name: "node-build-go", Scope: "node", Accepts: []string{"delivery", "check", "recheck"}, PulledByKind: true,
|
||||
AcceptCallers: map[string][]string{
|
||||
@@ -22,29 +22,18 @@ func TestNamedAsks(t *testing.T) {
|
||||
return p
|
||||
}
|
||||
const base = "mesh.seat.node-build-go.accept."
|
||||
for _, c := range []struct {
|
||||
who Principal
|
||||
want map[string]bool
|
||||
}{
|
||||
{asker("runner-module", "mesh-pipeline-runner"), map[string]bool{
|
||||
base + "check.mesh-pipeline-runner": true, base + "delivery.mesh-pipeline-runner": false,
|
||||
base + "check.mesh-catalog": false, base + "check": false, base + "delivery": false}},
|
||||
{asker("an-indexer", "mesh-catalog"), map[string]bool{
|
||||
base + "check.mesh-catalog": true, base + "check.mesh-pipeline-runner": false, base + "recheck.mesh-catalog": false}},
|
||||
{asker("the-builder", "mesh-builds"), map[string]bool{
|
||||
base + "delivery.mesh-builds": true, base + "delivery": true, base + "check": true, base + "check.mesh-builds": false}},
|
||||
{asker("the-checker", "mesh-delivery-checker"), map[string]bool{
|
||||
base + "check.mesh-delivery-checker": true, base + "recheck.mesh-delivery-checker": true, base + "recheck": true,
|
||||
base + "delivery.mesh-delivery-checker": false}},
|
||||
{asker("a-stranger"), map[string]bool{base + "check": false, base + "delivery": false, base + "check.a-stranger": false}},
|
||||
} {
|
||||
perms, err := PermissionsFor(c.who)
|
||||
// Principle 6 (the operator, 2026-11-15): every module's account may put an ask on any queue of any seat, under any asker's
|
||||
// name or none (AnySeatSubject); the callers lists withhold nothing.
|
||||
for _, who := range []Principal{asker("runner-module", "mesh-pipeline-runner"), asker("an-indexer", "mesh-catalog"),
|
||||
asker("the-builder", "mesh-builds"), asker("the-checker", "mesh-delivery-checker"), asker("a-stranger")} {
|
||||
perms, err := PermissionsFor(who)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for subject, want := range c.want {
|
||||
if got := MayPublish(perms, subject); got != want {
|
||||
t.Errorf("%s may publish %s: %v, want %v", c.who.Module, subject, got, want)
|
||||
for _, subject := range []string{base + "check", base + "delivery", base + "check.mesh-catalog", base + "recheck.mesh-delivery-checker",
|
||||
base + "check." + who.Module} {
|
||||
if !MayPublish(perms, subject) {
|
||||
t.Errorf("%s may not publish %s", who.Module, subject)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -735,6 +735,11 @@ func PermissionsFor(p Principal) (Permissions, error) {
|
||||
if slices.Contains([]Kind{KindModule, KindNodeTools, KindNode, KindProcess}, p.Kind) && !slices.Contains(perms.Publish, StreamNamesSubject) {
|
||||
perms.Publish = append(perms.Publish, StreamNamesSubject)
|
||||
}
|
||||
// The same accounts may put an ask on any seat (AnySeatSubject, principle 6), in the list's order.
|
||||
if slices.Contains([]Kind{KindModule, KindNodeTools, KindNode, KindProcess}, p.Kind) && !slices.Contains(perms.Publish, AnySeatSubject) {
|
||||
perms.Publish = append(perms.Publish, AnySeatSubject)
|
||||
sort.Strings(perms.Publish)
|
||||
}
|
||||
return perms, nil
|
||||
}
|
||||
|
||||
@@ -773,6 +778,12 @@ func RunnerNewEventGrants(r Records) map[string][]string {
|
||||
// StreamNamesSubject is the request for the names of the bus's streams, granted to every account.
|
||||
const StreamNamesSubject = "$JS.API.STREAM.NAMES"
|
||||
|
||||
// AnySeatSubject is every seat's asks: each queue of each seat, named by any asker or none. Inside the mesh every module is trusted
|
||||
// (principle 6), so every account of a module, its processes, its node and the tool runner may put an ask on any seat, and no seat
|
||||
// definition's callers list or manifest's invokes withholds one (the operator, 2026-11-15 about 18:10 CET, until the research after
|
||||
// G on dropping fine-grained permissions decides the whole shape). A seat's events and its verbs keep their own rules.
|
||||
const AnySeatSubject = "mesh.seat.*.accept.>"
|
||||
|
||||
func permissionsFor(p Principal) (Permissions, error) {
|
||||
for _, part := range []struct{ what, value string }{
|
||||
{"node", p.Node}, {"module", p.Module}, {"process", p.Process},
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -8,11 +8,14 @@ import (
|
||||
)
|
||||
|
||||
// Design 47 G A-383, A-384: a runner's account kept from the list in force gains the rights of hearing new events and the streams'
|
||||
// names, and loses nothing; a ledger's account gains neither.
|
||||
// names, and loses nothing; every account may ask any seat (principle 6); a ledger's account gains none of them.
|
||||
func TestAKeptRunnerGainsWhatEveryRunnerCarries(t *testing.T) {
|
||||
own := map[string][]string{"novox.node-tools": buscompose.NewEventGrants([]string{"EVENTS"})}
|
||||
kept := map[string]User{"novox.node-tools": {User: "novox.node-tools", Publish: []string{"a"}}, "ledger.novox.m": {User: "ledger.novox.m", Publish: []string{"b"}}}
|
||||
users, kept := withEveryAccountsRights([]User{{User: "novox.node-tools", Publish: []string{"a"}}}, kept, own)
|
||||
if !slices.Contains(kept["novox.node-tools"].Publish, buscompose.AnySeatSubject) {
|
||||
t.Errorf("the kept runner may not ask a seat: %v", kept["novox.node-tools"].Publish)
|
||||
}
|
||||
for _, u := range []User{users[0], kept["novox.node-tools"]} {
|
||||
for _, want := range []string{"a", buscompose.StreamNamesSubject, "$JS.API.CONSUMER.CREATE.EVENTS.*", "$JS.FC.EVENTS.>"} {
|
||||
if !slices.Contains(u.Publish, want) {
|
||||
@@ -24,3 +27,17 @@ func TestAKeptRunnerGainsWhatEveryRunnerCarries(t *testing.T) {
|
||||
t.Errorf("a ledger's account = %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
// Principle 6 (the operator, 2026-11-15): a module's account kept from the list in force may put an ask on any seat, named by any
|
||||
// asker (a composed one has it from buscompose.PermissionsFor); an enrolling node's account gains none.
|
||||
func TestAKeptModuleAccountMayAskAnySeat(t *testing.T) {
|
||||
kept := map[string]User{"novox.mesh-delivery-pipeline": {User: "novox.mesh-delivery-pipeline", Publish: []string{"x"}},
|
||||
"enrol.ace": {User: "enrol.ace", Publish: []string{"y"}}}
|
||||
_, kept = withEveryAccountsRights(nil, kept, nil)
|
||||
if !slices.Contains(kept["novox.mesh-delivery-pipeline"].Publish, buscompose.AnySeatSubject) {
|
||||
t.Errorf("a kept module account may not ask a seat: %v", kept["novox.mesh-delivery-pipeline"].Publish)
|
||||
}
|
||||
if got := kept["enrol.ace"].Publish; !slices.Equal(got, []string{"y"}) {
|
||||
t.Errorf("an enrolling node's account = %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,30 +139,32 @@ func (p *Part) sayPrincipalsRefused(refused map[string]string, kept map[string]U
|
||||
}
|
||||
|
||||
// withEveryAccountsRights gives each account a right every account of its kind carries (buscompose.StreamNamesSubject, design 47 G
|
||||
// A-382) that it lacks, in users and in kept: a user kept from the list in force or held is copied whole, so it would never gain it. An
|
||||
// A-382; buscompose.AnySeatSubject, principle 6, to a kept one) that it lacks, in users and in kept: a user kept from the list in force or held is copied whole, so it would never gain it. An
|
||||
// account of a ledger, an enrolling node, a person or a provisioner publishes on a few subjects alone and gets none. It only adds.
|
||||
func withEveryAccountsRights(users []User, kept map[string]User, own map[string][]string) ([]User, map[string]User) {
|
||||
add := func(u User) User {
|
||||
add := func(u User, isKept bool) User {
|
||||
u.Publish = withMissing(u.Publish, own[u.User])
|
||||
for _, alone := range []string{"ledger.", "enrol.", "person.", "provisioner."} {
|
||||
if strings.HasPrefix(u.User, alone) {
|
||||
return u
|
||||
}
|
||||
}
|
||||
if !slices.Contains(u.Publish, buscompose.StreamNamesSubject) {
|
||||
u.Publish = append(slices.Clone(u.Publish), buscompose.StreamNamesSubject)
|
||||
u.Publish = withMissing(u.Publish, []string{buscompose.StreamNamesSubject})
|
||||
if isKept {
|
||||
// A composed account has it from buscompose.PermissionsFor where its kind asks; a kept one is copied whole.
|
||||
u.Publish = withMissing(u.Publish, []string{buscompose.AnySeatSubject})
|
||||
}
|
||||
return u
|
||||
}
|
||||
out := make([]User, len(users))
|
||||
for i, u := range users {
|
||||
out[i] = add(u)
|
||||
out[i] = add(u, false)
|
||||
}
|
||||
var withKept map[string]User
|
||||
if kept != nil {
|
||||
withKept = make(map[string]User, len(kept))
|
||||
for k, u := range kept {
|
||||
withKept[k] = add(u)
|
||||
withKept[k] = add(u, true)
|
||||
}
|
||||
}
|
||||
return out, withKept
|
||||
|
||||
Reference in New Issue
Block a user