diff --git a/modules/mesh-grants/internal/grants/records.go b/modules/mesh-grants/internal/grants/records.go index 78b49ba1..20b00004 100644 --- a/modules/mesh-grants/internal/grants/records.go +++ b/modules/mesh-grants/internal/grants/records.go @@ -171,7 +171,7 @@ func declaredFor(m catalogue.Manifest, seats map[string]catalogue.SeatDeclaratio fromModules, watches := consumedOf(m, seats, declarers) d := buscompose.Declared{ Module: m.Module, ToolRunner: catalogue.IsToolRunner(m), Emits: m.EmitsAll(), Consumes: fromModules, Watches: watches, Serves: m.Tools, - Invokes: m.Invokes, State: bucketsOf(m), Reads: m.Reads, Logs: logsOf(m), + Invokes: withRunnerReads(m.Invokes), State: bucketsOf(m), Reads: m.Reads, Logs: logsOf(m), Streams: streamsOf(m), Queues: queueOwnersOf(m), Processes: processesOf(m), ServesOwn: ownServesOf(m), Checks: catalogue.HealthChecks(m), RunsAs: m.RunsAs, Issued: issuedTools(m), // The keys its served values fill, which every node may read where it runs (issue 1126). @@ -807,3 +807,18 @@ func findingEventsOf(m catalogue.Manifest) []string { } return nil } + +// RunnerReads are the seat verbs the tool runner itself asks for every module it serves, on that module's account: its seat +// list and the catalog half's first views. Every module is composed as invoking them (lead answer A-396, beside A-395). +var RunnerReads = []string{"seat:mesh-catalog.seat-definitions", "seat:mesh-catalog.revision", "seat:mesh-catalog.registrations", "seat:mesh-delivery.source"} + +// withRunnerReads is invokes with each of RunnerReads it lacks. +func withRunnerReads(invokes []string) []string { + out := slices.Clone(invokes) + for _, r := range RunnerReads { + if !slices.Contains(out, r) && !slices.Contains(out, "*") { + out = append(out, r) + } + } + return out +} diff --git a/modules/mesh-grants/internal/grants/runner_reads_test.go b/modules/mesh-grants/internal/grants/runner_reads_test.go new file mode 100644 index 00000000..cf3ff005 --- /dev/null +++ b/modules/mesh-grants/internal/grants/runner_reads_test.go @@ -0,0 +1,25 @@ +package grants + +import ( + "slices" + "testing" + + "git.novox.be/novox/mesh-sdk/go/catalogue" +) + +// A-396: every module is composed as invoking the runner's own reads, so its account may ask them. +func TestEveryModuleInvokesTheRunnersReads(t *testing.T) { + for _, c := range []struct { + name string + invokes []string + want int + }{{"none declared", nil, len(RunnerReads)}, {"one declared", []string{"seat:mesh-catalog.revision"}, len(RunnerReads)}, {"every verb", []string{"*"}, 1}} { + d := declaredFor(catalogue.Manifest{Module: "mesh-build-go", Invokes: c.invokes}, nil, nil) + if len(d.Invokes) != c.want { + t.Errorf("%s: invokes %v, want %d", c.name, d.Invokes, c.want) + } + if c.want > 1 && !slices.Contains(d.Invokes, "seat:mesh-catalog.seat-definitions") { + t.Errorf("%s: invokes %v lack the seat list's verb", c.name, d.Invokes) + } + } +}