Files
mesh-delivery/modules/mesh-grants/internal/grants/sentobjects_test.go
T
jschoubben 6b43adafca G1 (in progress): the grants part reads no callers and no verdicts
Every account may call every verb: the grants part reads no definition's
callers (callerOf, the verb and accept callers, admits) and grants every
module's account every verb of every seat (mesh.seat.*.tool.> and its
caller-named form), a sent store to every module invoking a verb of its
claimant's seat, and every queue's named ask to every asker. grants_callers
goes; grants_why_refused answers the bus's own verdict. The indexer keeps
no verdicts: their first view, events, invoke and the engine's read go, and
a want names its build alone (no newest). internal/... and cmd/... tests are
green; the root package's grants_test.go still reads the verdicts (rows at
grants_test.go:303-307, 741, 1184, 3700-3870, 4560-4615) and does not compile.

Builds: design 47 H §745, §750, §752, §764 (every seat contract: the callers lists); lead answers H-A-37, H-A-66, H-A-79, H-A-113 (hq f599b761)

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
2026-11-20 04:28:04 +01:00

62 lines
3.6 KiB
Go

package grants
import (
"slices"
"testing"
"git.novox.be/novox/mesh-sdk/go/catalogue"
"mesh-grants/internal/buscompose"
)
// The sent stores a module reads follow the catalog graph (design 47 G §59, §124): the consumers of a module's events and the
// callers a seat's verb admits, and no other module.
func TestSentStoresRead(t *testing.T) {
// The store beside each state of the field state is the module's own object bucket (design 47 G §58, A-237); a state only
// read has none, a state's size is its store's.
objs := objectsOf(catalogue.Manifest{Module: "mesh-delivery-indexer", State: []catalogue.StateDeclaration{{Name: "inputs", History: 1},
{Name: "versions", MaxMiB: 64}, {Name: "seen", ReadOnly: true}}})
if len(objs) != 2 || objs[0].Bucket() != "mesh-delivery-indexer_inputs-objects" || objs[0].MaxMiB != StateObjectsMiB ||
objs[1].Bucket() != "mesh-delivery-indexer_versions-objects" || objs[1].MaxMiB != 64 {
t.Errorf("the state's object stores = %+v", objs)
}
holder := catalogue.Manifest{Module: "shop", Claims: []catalogue.Claim{{Name: "orders-seat"}}}
all := map[string]catalogue.Manifest{"shop": holder, "bank": {Module: "bank"}, "plain": {Module: "plain"}}
for _, c := range []struct {
name string
m catalogue.Manifest
want []string
}{
{"consumes a module's event", catalogue.Manifest{Module: "bank", Consumes: []string{"shop.sold"}}, []string{"shop_sent-objects"}},
{"consumes a seat's event", catalogue.Manifest{Module: "bank", Consumes: []string{"orders-seat.sold"}}, []string{"shop_sent-objects"}},
{"invokes a verb that names its seat", catalogue.Manifest{Module: "bank", Claims: []catalogue.Claim{{Name: "billing"}},
Invokes: []string{"seat:orders-seat.place"}}, []string{"shop_sent-objects"}},
{"invokes a verb that names it", catalogue.Manifest{Module: "plain", Invokes: []string{"seat:orders-seat.place"}}, []string{"shop_sent-objects"}},
{"invokes a read", catalogue.Manifest{Module: "bank", Invokes: []string{"seat:orders-seat.list"}}, []string{"shop_sent-objects"}},
{"invokes an act", catalogue.Manifest{Module: "bank", Invokes: []string{"seat:orders-seat.wipe"}}, []string{"shop_sent-objects"}},
{"invokes a verb no callers list names: every account may call every verb (design 47 H §752)", catalogue.Manifest{Module: "bank", Invokes: []string{"seat:orders-seat.place"}}, []string{"shop_sent-objects"}},
{"declares neither", catalogue.Manifest{Module: "bank"}, nil},
{"its own store is its binding's", holder, nil},
} {
if got := sentStoresRead(c.m, all); !slices.Equal(got, c.want) {
t.Errorf("%s: %v, want %v", c.name, got, c.want)
}
}
}
// The marked verbs a declaration names (design 47 G §677): a definition-marked verb its module invokes or a process answers,
// and no unmarked verb.
func TestTheMarkedVerbsADeclarationNames(t *testing.T) {
seats := map[string]catalogue.SeatDeclaration{"node-login-shell": {Name: "node-login-shell",
Serves: []catalogue.Verb{{Name: "execute", NeedsApproval: true}, {Name: "list"}}}}
d := buscompose.Declared{Invokes: []string{"seat:node-login-shell.execute", "seat:node-login-shell.list", "shop.tool"},
Processes: []buscompose.ProcessPrincipal{{Serves: []string{"seat:node-login-shell.execute"}}}}
if got := markedNamed(d, seats); !slices.Equal(got, []string{"seat:node-login-shell.execute"}) {
t.Errorf("marked = %v", got)
}
m := catalogue.Manifest{Module: "shop", Invokes: []string{"seat:node-login-shell.execute"}}
if got := declaredFor(m, seats, nil, nil).MarkedVerbs; !slices.Equal(got, []string{"seat:node-login-shell.execute"}) {
t.Errorf("the declaration carries %v, want the marked verb it invokes", got)
}
}