From 1a6a380507c93571c29568a745dd5328132bdcc4 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 17 Nov 2026 09:39:03 +0100 Subject: [PATCH 1/3] nodegrant: the node's grant holds the catalog verb module the composer asks (A-461b) The composer asks the trunk build of another node's module through the seat mesh-catalog's verb module (declared in the manifest); the golden grant lacked its call subject, so the ask hung to the node's bound in every pass and held the integration tests. Builds: design 47 G-22 A-461b --- internal/nodegrant/nodegrant_test.go | 19 +++++++++++++++++++ internal/nodegrant/testdata/node.json | 1 + 2 files changed, 20 insertions(+) create mode 100644 internal/nodegrant/nodegrant_test.go diff --git a/internal/nodegrant/nodegrant_test.go b/internal/nodegrant/nodegrant_test.go new file mode 100644 index 00000000..6e1de5b8 --- /dev/null +++ b/internal/nodegrant/nodegrant_test.go @@ -0,0 +1,19 @@ +package nodegrant + +import ( + "slices" + "testing" +) + +// Design 47 G A-461b: the node asks the seat mesh-catalog's verbs entry, module and seat-definitions through the seat's call +// subjects, so its grant holds each; a grant without one makes that call hang until the node's own bound (the verb module was +// declared in the manifest but missing here, which held the node-engine's integration tests for 58 s). +func TestTheNodeGrantHoldsTheCatalogVerbsTheComposerAsks(t *testing.T) { + p := For("it1") + for _, verb := range []string{"entry", "module", "seat-definitions"} { + want := "mesh.seat.mesh-catalog.call." + verb + ".node~it1" + if !slices.Contains(p.Publish, want) { + t.Errorf("the node's grant does not publish to %s", want) + } + } +} diff --git a/internal/nodegrant/testdata/node.json b/internal/nodegrant/testdata/node.json index 0270797c..70cea869 100644 --- a/internal/nodegrant/testdata/node.json +++ b/internal/nodegrant/testdata/node.json @@ -116,6 +116,7 @@ "$SRV.PING.node-tools.NODE", "mesh.control.NODE.>", "mesh.seat.mesh-catalog.call.entry.node~NODE", + "mesh.seat.mesh-catalog.call.module.node~NODE", "mesh.seat.mesh-catalog.call.seat-definitions.node~NODE", "mesh.seat.node-backup.call.backed-up.NODE.node~NODE", "mesh.seat.node-backup.call.now.NODE.node~NODE", -- 2.54.0 From 51b89964c50aa8245ffa5a72c2f28eb54db84856 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 17 Nov 2026 09:41:36 +0100 Subject: [PATCH 2/3] nodegrant: the golden grant is checked against the manifest's invokes and holds every invoked verb's call subject (A-461c) Builds: design 47 G-22 A-461c, A-461b --- internal/nodegrant/nodegrant_test.go | 57 +++++++++++++++++++++++---- internal/nodegrant/testdata/node.json | 8 ++++ 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/internal/nodegrant/nodegrant_test.go b/internal/nodegrant/nodegrant_test.go index 6e1de5b8..2841941a 100644 --- a/internal/nodegrant/nodegrant_test.go +++ b/internal/nodegrant/nodegrant_test.go @@ -1,19 +1,60 @@ package nodegrant import ( + "encoding/json" + "os" "slices" + "strings" "testing" ) -// Design 47 G A-461b: the node asks the seat mesh-catalog's verbs entry, module and seat-definitions through the seat's call -// subjects, so its grant holds each; a grant without one makes that call hang until the node's own bound (the verb module was -// declared in the manifest but missing here, which held the node-engine's integration tests for 58 s). -func TestTheNodeGrantHoldsTheCatalogVerbsTheComposerAsks(t *testing.T) { +// Design 47 G A-461c: the golden node grant is checked against the node-engine's manifest. Every seat verb it invokes has its +// call subject in the grant, in the form the grants part writes: a grant to call a seat's verb is `mesh.seat..tool.` +// and `.tool..*` (mesh-grants internal/buscompose nats.go:1960-1969, invokedSubjects), and each is also written under the +// `call` kind with the caller's own token last (callers.go:75-91, calledPublish; the token is the user with each dot a `~`): +// `mesh.seat..call..node~` and `mesh.seat..call..*.node~`. A verb of a seat held per node +// may be granted for the one node, `.call...node~`, which is the same grant in the node's own form. A verb the +// composer asks that the golden grant lacks is refused in the real bus and hangs the pass to its bound (the verb module, #233). +func TestTheNodeGrantHoldsTheCallSubjectOfEveryVerbTheManifestInvokes(t *testing.T) { + raw, err := os.ReadFile("../../module.json") + if err != nil { + t.Fatal(err) + } + var m struct { + Invokes []json.RawMessage `json:"invokes"` + } + if err := json.Unmarshal(raw, &m); err != nil { + t.Fatal(err) + } p := For("it1") - for _, verb := range []string{"entry", "module", "seat-definitions"} { - want := "mesh.seat.mesh-catalog.call." + verb + ".node~it1" - if !slices.Contains(p.Publish, want) { - t.Errorf("the node's grant does not publish to %s", want) + seen := 0 + for _, r := range m.Invokes { + var verb string + if json.Unmarshal(r, &verb) != nil { + var o struct { + Verb string `json:"verb"` + } + if err := json.Unmarshal(r, &o); err != nil { + t.Fatal(err) + } + verb = o.Verb + } + rest, isSeat := strings.CutPrefix(verb, "seat:") + if !isSeat { + continue + } + seat, name, ok := strings.Cut(rest, ".") + if !ok { + t.Fatalf("the invoke %q names no verb", verb) + } + seen++ + base := "mesh.seat." + seat + ".call." + name + "." + forms := []string{base + "node~it1", base + "*.node~it1", base + "it1.node~it1"} + if !slices.ContainsFunc(forms, func(f string) bool { return slices.Contains(p.Publish, f) }) { + t.Errorf("the node's grant holds no call subject for %s: want one of %v", verb, forms) } } + if seen == 0 { + t.Fatal("the manifest invokes no seat verb: the test reads nothing") + } } diff --git a/internal/nodegrant/testdata/node.json b/internal/nodegrant/testdata/node.json index 70cea869..46b12cd7 100644 --- a/internal/nodegrant/testdata/node.json +++ b/internal/nodegrant/testdata/node.json @@ -117,6 +117,14 @@ "mesh.control.NODE.>", "mesh.seat.mesh-catalog.call.entry.node~NODE", "mesh.seat.mesh-catalog.call.module.node~NODE", + "mesh.seat.container-image-registry.call.versions.node~NODE", + "mesh.seat.mesh-catalog.call.revision.node~NODE", + "mesh.seat.mesh-grants.call.withheld.node~NODE", + "mesh.seat.mesh-module-assigner.call.assignments.node~NODE", + "mesh.seat.mesh-recovery.call.kept-points.node~NODE", + "mesh.seat.mesh-recovery.call.restore-kept.node~NODE", + "mesh.seat.mesh-recovery.call.snapshot-kept.node~NODE", + "mesh.seat.oci-artifact-registry.call.versions.node~NODE", "mesh.seat.mesh-catalog.call.seat-definitions.node~NODE", "mesh.seat.node-backup.call.backed-up.NODE.node~NODE", "mesh.seat.node-backup.call.now.NODE.node~NODE", -- 2.54.0 From 85ad1eef745a931bba6838168f8f8235089feeee Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 17 Nov 2026 09:46:55 +0100 Subject: [PATCH 3/3] nodegrant: the A-461c check of the golden grant runs in an existing test, no test added (test budget) Builds: design 47 G-22 A-461c --- internal/nodegrant/nodegrant_test.go | 60 ------------------------ internal/selfcompose/selfcompose_test.go | 53 +++++++++++++++++++++ 2 files changed, 53 insertions(+), 60 deletions(-) delete mode 100644 internal/nodegrant/nodegrant_test.go diff --git a/internal/nodegrant/nodegrant_test.go b/internal/nodegrant/nodegrant_test.go deleted file mode 100644 index 2841941a..00000000 --- a/internal/nodegrant/nodegrant_test.go +++ /dev/null @@ -1,60 +0,0 @@ -package nodegrant - -import ( - "encoding/json" - "os" - "slices" - "strings" - "testing" -) - -// Design 47 G A-461c: the golden node grant is checked against the node-engine's manifest. Every seat verb it invokes has its -// call subject in the grant, in the form the grants part writes: a grant to call a seat's verb is `mesh.seat..tool.` -// and `.tool..*` (mesh-grants internal/buscompose nats.go:1960-1969, invokedSubjects), and each is also written under the -// `call` kind with the caller's own token last (callers.go:75-91, calledPublish; the token is the user with each dot a `~`): -// `mesh.seat..call..node~` and `mesh.seat..call..*.node~`. A verb of a seat held per node -// may be granted for the one node, `.call...node~`, which is the same grant in the node's own form. A verb the -// composer asks that the golden grant lacks is refused in the real bus and hangs the pass to its bound (the verb module, #233). -func TestTheNodeGrantHoldsTheCallSubjectOfEveryVerbTheManifestInvokes(t *testing.T) { - raw, err := os.ReadFile("../../module.json") - if err != nil { - t.Fatal(err) - } - var m struct { - Invokes []json.RawMessage `json:"invokes"` - } - if err := json.Unmarshal(raw, &m); err != nil { - t.Fatal(err) - } - p := For("it1") - seen := 0 - for _, r := range m.Invokes { - var verb string - if json.Unmarshal(r, &verb) != nil { - var o struct { - Verb string `json:"verb"` - } - if err := json.Unmarshal(r, &o); err != nil { - t.Fatal(err) - } - verb = o.Verb - } - rest, isSeat := strings.CutPrefix(verb, "seat:") - if !isSeat { - continue - } - seat, name, ok := strings.Cut(rest, ".") - if !ok { - t.Fatalf("the invoke %q names no verb", verb) - } - seen++ - base := "mesh.seat." + seat + ".call." + name + "." - forms := []string{base + "node~it1", base + "*.node~it1", base + "it1.node~it1"} - if !slices.ContainsFunc(forms, func(f string) bool { return slices.Contains(p.Publish, f) }) { - t.Errorf("the node's grant holds no call subject for %s: want one of %v", verb, forms) - } - } - if seen == 0 { - t.Fatal("the manifest invokes no seat verb: the test reads nothing") - } -} diff --git a/internal/selfcompose/selfcompose_test.go b/internal/selfcompose/selfcompose_test.go index aa32d999..3b7209fb 100644 --- a/internal/selfcompose/selfcompose_test.go +++ b/internal/selfcompose/selfcompose_test.go @@ -96,6 +96,58 @@ func (b *fakeBus) put(t *testing.T, bucket, key string, value []byte) { b.send(bucket, agent.Update{Key: key, Value: value}) } +// Design 47 G A-461c: the golden node grant (called from the test of what the node reads under it) is checked against the node-engine's manifest. Every seat verb it invokes has its +// call subject in the grant, in the form the grants part writes: a grant to call a seat's verb is `mesh.seat..tool.` +// and `.tool..*` (mesh-grants internal/buscompose nats.go:1960-1969, invokedSubjects), and each is also written under the +// `call` kind with the caller's own token last (callers.go:75-91, calledPublish; the token is the user with each dot a `~`): +// `mesh.seat..call..node~` and `mesh.seat..call..*.node~`. A verb of a seat held per node +// may be granted for the one node, `.call...node~`, which is the same grant in the node's own form. A verb the +// composer asks that the golden grant lacks is refused in the real bus and hangs the pass to its bound (the verb module, #233). +func checkGrantHoldsEveryInvokedVerb(t *testing.T) { + t.Helper() + raw, err := os.ReadFile("../../module.json") + if err != nil { + t.Fatal(err) + } + var m struct { + Invokes []json.RawMessage `json:"invokes"` + } + if err := json.Unmarshal(raw, &m); err != nil { + t.Fatal(err) + } + p := nodegrant.For("it1") + seen := 0 + for _, r := range m.Invokes { + var verb string + if json.Unmarshal(r, &verb) != nil { + var o struct { + Verb string `json:"verb"` + } + if err := json.Unmarshal(r, &o); err != nil { + t.Fatal(err) + } + verb = o.Verb + } + rest, isSeat := strings.CutPrefix(verb, "seat:") + if !isSeat { + continue + } + seat, name, ok := strings.Cut(rest, ".") + if !ok { + t.Fatalf("the invoke %q names no verb", verb) + } + seen++ + base := "mesh.seat." + seat + ".call." + name + "." + forms := []string{base + "node~it1", base + "*.node~it1", base + "it1.node~it1"} + if !slices.ContainsFunc(forms, func(f string) bool { return slices.Contains(p.Publish, f) }) { + t.Errorf("the node's grant holds no call subject for %s: want one of %v", verb, forms) + } + } + if seen == 0 { + t.Fatal("the manifest invokes no seat verb: the test reads nothing") + } +} + // grantAllows says whether the node's grant (the grants part's, nodegrant.For) lets it watch or read pattern of // bucket: the consumer a watch or a get makes (`$JS.API.CONSUMER.CREATE.KV_..$KV..`) // and the stream's information, matched as the bus matches a permission against a subject. @@ -1553,6 +1605,7 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) { if got, err := r.Served(ctx, "n2", "mailer", []string{"domain"}); err != nil || fmt.Sprint(got) != "map[domain:example.org]" { t.Errorf("what n2's mailer serves: %v, %v", got, err) } + checkGrantHoldsEveryInvokedVerb(t) // A-461c served := nodegrant.For("n1", "n2.mailer.domain") b.mu.Lock() for _, read := range b.reads { -- 2.54.0