T2 no-callers-hook: the runner admits every caller by serving, with no hook that judges who may call

The `admitted` hook, its parameter of serveSeats and its comments go; the test rows that built definitions with Callers and Class
go with the field mesh-sdk removes. A seat's verb is answered for every caller.

Builds: design 47 H §752, §764 (Every seat contract), H-A-41

Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
2026-11-20 02:38:21 +01:00
parent 5d88eecea9
commit f2a05fb440
4 changed files with 12 additions and 41 deletions
+4 -20
View File
@@ -68,15 +68,14 @@ func TestACallOnTheCallerNamedSubjectReachesTheModuleWithItsCaller(t *testing.T)
} }
} }
// deskDefined is the seat list's definition of the fixture seat node-desk, its verb who taking its class's default. // deskDefined is the seat list's definition of the fixture seat node-desk, its verb who.
var deskDefined = WithSeatDefinitions(func() map[string]seatdef.Definition { var deskDefined = WithSeatDefinitions(func() map[string]seatdef.Definition {
return map[string]seatdef.Definition{"node-desk": {Seat: "node-desk", Verbs: []seatdef.Verb{{Name: "who"}}}} return map[string]seatdef.Definition{"node-desk": {Seat: "node-desk", Verbs: []seatdef.Verb{{Name: "who"}}}}
}) })
// The subject that names no caller is still served for a module's tool, for one release (retired by hq issue 464), and says // The subject that names no caller is still served for a module's tool, for one release (retired by hq issue 464), and says
// so: the module is named no caller, whatever the body claims. A seat's verb refuses it before the bundle runs (design 47 G // so: the module is named no caller, whatever the body claims. A seat's verb answers every caller, an unproven one too (design 47
// §610; lead answers A-165, A-179), and refuses every caller while the seat's definition is unread, names no such verb or // H §752).
// opens it to none.
func TestTheSubjectThatNamesNoCallerStillWorksAndNamesNone(t *testing.T) { func TestTheSubjectThatNamesNoCallerStillWorksAndNamesNone(t *testing.T) {
mesh := mt.New(t) mesh := mt.New(t)
mesh.Issue(t, mt.MembershipOf("ledger", "anchor", true, map[string][]string{"node-desk": {"who"}})) mesh.Issue(t, mt.MembershipOf("ledger", "anchor", true, map[string][]string{"node-desk": {"who"}}))
@@ -104,7 +103,7 @@ func TestTheSubjectThatNamesNoCallerStillWorksAndNamesNone(t *testing.T) {
} }
return err return err
}) })
// Every caller is admitted, an unproven one too (the operator, 2026-11-15 23:25 CET). // Every caller is answered, an unproven one too (design 47 H §752).
if strings.HasPrefix(subject, "mesh.seat.") { if strings.HasPrefix(subject, "mesh.seat.") {
if reply.Error != "" { if reply.Error != "" {
t.Errorf("%s: an unproven caller of a seat's verb was refused: %q, want answered", subject, reply.Error) t.Errorf("%s: an unproven caller of a seat's verb was refused: %q, want answered", subject, reply.Error)
@@ -115,21 +114,6 @@ func TestTheSubjectThatNamesNoCallerStillWorksAndNamesNone(t *testing.T) {
t.Errorf("%s: the module was named caller %q (error %q), want none", subject, reply.Result.Caller, reply.Error) t.Errorf("%s: the module was named caller %q (error %q), want none", subject, reply.Result.Caller, reply.Error)
} }
} }
for _, c := range []struct {
defs map[string]seatdef.Definition
says string
}{
{nil, ""},
{map[string]seatdef.Definition{"node-desk": {Seat: "node-desk"}}, ""},
{map[string]seatdef.Definition{"node-desk": {Seat: "node-desk", Verbs: []seatdef.Verb{{Name: "who", Callers: &seatdef.Callers{List: []string{}}}}}}, ""},
{map[string]seatdef.Definition{"node-desk": {Seat: "node-desk", Verbs: []seatdef.Verb{{Name: "who", Class: seatdef.ClassAct}}}}, ""},
} {
defs := c.defs
err := (&consumers{definitions: func() map[string]seatdef.Definition { return defs }}).admitted("node-desk", "who", "workstation.node-tools")
if c.says == "" && err != nil || c.says != "" && (err == nil || !strings.Contains(err.Error(), c.says)) {
t.Errorf("a proven caller with the definitions %v: %v, want %q", c.defs, err, c.says)
}
}
// Design 47 G A-249: a bundle's seat call is received by the runner in chunks only for a verb whose definition says `chunks`, // Design 47 G A-249: a bundle's seat call is received by the runner in chunks only for a verb whose definition says `chunks`,
// of any machine: a verb a node holds is asked of the node that ran the ask (A-254). // of any machine: a verb a node holds is asked of the node that ran the ask (A-254).
t.Run("OnlyAChunkedSeatVerbIsAskedInChunks", func(t *testing.T) { t.Run("OnlyAChunkedSeatVerbIsAskedInChunks", func(t *testing.T) {
+2 -8
View File
@@ -49,18 +49,12 @@ func WithGate(g Gate) Option { return func(c *consumers) { c.gate = g } }
var _ Gate = (*approval.Gate)(nil) var _ Gate = (*approval.Gate)(nil)
// WithSeatDefinitions refuses, where a seat's verb is answered, a caller outside the verb's effective callers, before the // WithSeatDefinitions gives the runner the seat definitions its seat list holds: a verb's `chunks` and `timeout` are read from them
// bundle runs (design 47 G §610; lead answers A-165, A-179): defs are the seat definitions the runner's seat list holds. // (design 47 H §760). No definition names who may call: every caller is answered (design 47 H §752).
// Without it a verb is answered for every caller, as before.
func WithSeatDefinitions(defs func() map[string]seatdef.Definition) Option { func WithSeatDefinitions(defs func() map[string]seatdef.Definition) Option {
return func(c *consumers) { c.definitions = defs } return func(c *consumers) { c.definitions = defs }
} }
// admitted says why a seat's verb is refused to a caller: never. Every caller is admitted, whether or not the seat's definition
// is read and whatever callers it names (the operator, 2026-11-15 23:25 CET: every module, agent and operator may call anything;
// approval stays as the mark on a verb, held by the gate).
func (c *consumers) admitted(seat, verb, caller string) error { return nil }
// unservedMarks is, of the module's marked tools, those its bundle's registrations under its own name do not register. // unservedMarks is, of the module's marked tools, those its bundle's registrations under its own name do not register.
func (r *runner) unservedMarks(module string, regs []launch.Registration) []string { func (r *runner) unservedMarks(module string, regs []launch.Registration) []string {
if r.events.gate == nil { if r.events.gate == nil {
+5 -11
View File
@@ -314,7 +314,7 @@ func Run(conn *bus.Conn, served []Served, envs map[string]map[string]string, log
} }
logf("%s", line) logf("%s", line)
conn.OnMembership(func(bus.Membership) { go func() { r.refreshRepairs(); conn.Flush() }() }) conn.OnMembership(func(bus.Membership) { go func() { r.refreshRepairs(); conn.Flush() }() })
stopSeats, again := serveSeats(conn, r.modules, r.registrations, r.events.gated, r.events.admitted, r.events.chunked, r.events.withinOf, r.approvalsOf(), stopSeats, again := serveSeats(conn, r.modules, r.registrations, r.events.gated, r.events.chunked, r.events.withinOf, r.approvalsOf(),
r.fingerprintOf, logf) r.fingerprintOf, logf)
r.seatsAgain = again r.seatsAgain = again
r.stops = append(r.stops, stopSeats) r.stops = append(r.stops, stopSeats)
@@ -733,7 +733,7 @@ func subjectsOf(conn *bus.Conn, module, tool string) []string {
// whenever a membership changes, and when again is called because a bundle was loaded again. Whether // whenever a membership changes, and when again is called because a bundle was loaded again. Whether
// this machine holds the seat is the bus's to decide. It answers its stop and again. // this machine holds the seat is the bus's to decide. It answers its stop and again.
func serveSeats(conn *bus.Conn, modules []string, current func() []registration, gated gatedRun, func serveSeats(conn *bus.Conn, modules []string, current func() []registration, gated gatedRun,
admitted func(seat, verb, caller string) error, chunked func(key string) bool, within func(key string) time.Duration, approvals func(caller string) (any, error), chunked func(key string) bool, within func(key string) time.Duration, approvals func(caller string) (any, error),
fingerprintOf func(string) string, logf func(string, ...any)) (func(), func()) { fingerprintOf func(string) string, logf func(string, ...any)) (func(), func()) {
var mu sync.Mutex var mu sync.Mutex
var stops []func() var stops []func()
@@ -773,9 +773,6 @@ func serveSeats(conn *bus.Conn, modules []string, current func() []registration,
if v.Verb == seatdef.ApprovalsVerb && approvals != nil { if v.Verb == seatdef.ApprovalsVerb && approvals != nil {
seat := v.Seat seat := v.Seat
stop, err := conn.HandleSubjectCalled(v.Subject, func(caller string, _ json.RawMessage) (any, error) { stop, err := conn.HandleSubjectCalled(v.Subject, func(caller string, _ json.RawMessage) (any, error) {
if err := admitted(seat, seatdef.ApprovalsVerb, caller); err != nil {
return nil, err
}
return approvals(caller) return approvals(caller)
}) })
if err != nil { if err != nil {
@@ -791,13 +788,10 @@ func serveSeats(conn *bus.Conn, modules []string, current func() []registration,
logf("[mesh-tools] %s claims %s and implements no %s, which that seat promises; not served", module, v.Seat, v.Verb) logf("[mesh-tools] %s claims %s and implements no %s, which that seat promises; not served", module, v.Seat, v.Verb)
continue continue
} }
// Its callers checked, then through the approval gate, before the bundle (design 47 G §610, A-179; design 46 // Through the approval gate, for any caller, before the bundle (design 47 H §752; design 46
// 7-approval-mark §20). // 7-approval-mark §20).
module, v := module, v module, v := module, v
handle := func(caller string, body json.RawMessage) (any, error) { handle := func(caller string, body json.RawMessage) (any, error) {
if err := admitted(v.Seat, v.Verb, caller); err != nil {
return nil, err
}
answer, err := gated(approval.Call{Address: v.Seat + "." + v.Verb, Module: module, Seat: v.Seat, Name: v.Verb, answer, err := gated(approval.Call{Address: v.Seat + "." + v.Verb, Module: module, Seat: v.Seat, Name: v.Verb,
Fingerprint: fingerprintOf(module), Caller: caller, Args: argsOf(body), Description: t.Description}, t.Within(within("seat:"+v.Seat+"."+v.Verb)), caller) Fingerprint: fingerprintOf(module), Caller: caller, Args: argsOf(body), Description: t.Description}, t.Within(within("seat:"+v.Seat+"."+v.Verb)), caller)
if err != nil || !chunked("seat:"+v.Seat+"."+v.Verb) { if err != nil || !chunked("seat:"+v.Seat+"."+v.Verb) {
@@ -812,7 +806,7 @@ func serveSeats(conn *bus.Conn, modules []string, current func() []registration,
continue continue
} }
stops = append(stops, stop) stops = append(stops, stop)
logf("[mesh-tools] serving %s's %s on %s, admitted where %s holds the seat", v.Seat, v.Verb, v.Subject, module) logf("[mesh-tools] serving %s's %s on %s, where %s holds the seat", v.Seat, v.Verb, v.Subject, module)
// A verb of a node-scoped seat is also answered on the subject that names no machine, by any one holder, in // A verb of a node-scoped seat is also answered on the subject that names no machine, by any one holder, in
// one queue group per seat and verb (lead answer A-393). // one queue group per seat and verb (lead answer A-393).
if open, ok := anyHolderSubject(v, m.Node); ok && !have[open] { if open, ok := anyHolderSubject(v, m.Node); ok && !have[open] {
@@ -869,7 +863,7 @@ type consumers struct {
sessions sessionTable sessions sessionTable
// gate is the approval gate every call is served through (gate.go); nil serves every call as before. // gate is the approval gate every call is served through (gate.go); nil serves every call as before.
gate Gate gate Gate
// definitions are the seat definitions a seat verb's callers are read from (gate.go); nil admits every caller. // definitions are the seat definitions a seat verb's `chunks` and `timeout` are read from (gate.go); nil reads none.
definitions func() map[string]seatdef.Definition definitions func() map[string]seatdef.Definition
// reread reads the seat list again (gate.go, chunkedAsked); nil reads nothing. // reread reads the seat list again (gate.go, chunkedAsked); nil reads nothing.
reread func() error reread func() error
+1 -2
View File
@@ -328,8 +328,7 @@ func TestANodeScopedSeatVerbIsAlsoAnsweredWithNoMachine(t *testing.T) {
return tool.Run(caller, nil) return tool.Run(caller, nil)
} }
nodeTools.Follow("theta") nodeTools.Follow("theta")
stop, _ := serveSeats(nodeTools, []string{"theta"}, regs, gated, func(_, _, _ string) error { return nil }, stop, _ := serveSeats(nodeTools, []string{"theta"}, regs, gated, func(string) bool { return false }, func(string) time.Duration { return 0 }, nil, func(string) string { return "" }, (&mt.Logs{}).Logf)
func(string) bool { return false }, func(string) time.Duration { return 0 }, nil, func(string) string { return "" }, (&mt.Logs{}).Logf)
defer stop() defer stop()
for _, key := range []string{"seat:node-shelf.list@anchor", "seat:node-shelf.list"} { for _, key := range []string{"seat:node-shelf.list@anchor", "seat:node-shelf.list"} {
t.Run(key, func(t *testing.T) { t.Run(key, func(t *testing.T) {