approval: before the catalog half is read, a module account's call runs unmarked, seat verb or tool, and a module's own call in its runtime of its own (design 47 G A-433)

This commit is contained in:
2026-11-16 02:34:22 +01:00
parent 45ee5a2a88
commit 1182cadc9d
2 changed files with 25 additions and 11 deletions
+16 -4
View File
@@ -149,9 +149,10 @@ func TestAnUnreadCatalogHalfLetsItsOwnReadsThrough(t *testing.T) {
{"", "bridge_merged_message", false, nil, "person.operator", false}, // a person {"", "bridge_merged_message", false, nil, "person.operator", false}, // a person
{"", "bridge_merged_message", false, nil, "controller", false}, {"", "bridge_merged_message", false, nil, "controller", false},
{"", "bridge_merged_message", false, nil, "unproven", false}, {"", "bridge_merged_message", false, nil, "unproven", false},
{"", "bridge_merged_message", false, nil, "n1.mesh-delivery-indexer", false}, // the tool's own module {"", "bridge_merged_message", true, nil, "n1.mesh-delivery-indexer", false}, // the tool's own module's account (A-433)
{"", "ledger_repair", false, nil, "n1.mesh-delivery-runner", true}, // the runner's own tool {"", "ledger_repair", false, nil, "n1.mesh-delivery-runner", true}, // the runner's own tool
{"git", "merge-pull", false, nil, "n1.mesh-delivery-runner", false}, // a seat verb's act is no module tool {"git", "merge-pull", true, nil, "n1.mesh-delivery-runner", false}, // a module's account, a seat verb too (A-433)
{"git", "merge-pull", false, nil, "n1.node-tools", false}, // the console's account stays held
} { } {
ran := false ran := false
address := tc.seat + "." + tc.name address := tc.seat + "." + tc.name
@@ -171,14 +172,25 @@ func TestAnUnreadCatalogHalfLetsItsOwnReadsThrough(t *testing.T) {
t.Errorf("%s: refused with %v, want the marks not read yet", address, err) t.Errorf("%s: refused with %v, want the marks not read yet", address, err)
} }
} }
if waited != 20 { if waited != 19 {
t.Errorf("the other calls waited for the catalog half %d times, want 20 (the start reads wait for nothing)", waited) t.Errorf("the other calls waited for the catalog half %d times, want 19 (the start reads wait for nothing)", waited)
} }
want := []string{ want := []string{
"[approval] mesh-delivery-indexer.bridge_merged_message called by n2.mesh-delivery-forge-bridge: run unmarked before the catalog half is read", "[approval] mesh-delivery-indexer.bridge_merged_message called by n2.mesh-delivery-forge-bridge: run unmarked before the catalog half is read",
"[approval] mesh-delivery-indexer.read_modules called by n1.mesh-delivery-runner: run unmarked before the catalog half is read", "[approval] mesh-delivery-indexer.read_modules called by n1.mesh-delivery-runner: run unmarked before the catalog half is read",
"[approval] git.merge-pull called by n1.mesh-delivery-runner: run unmarked before the catalog half is read",
} }
if strings.Join(logged, "\n") != strings.Join(want, "\n") { if strings.Join(logged, "\n") != strings.Join(want, "\n") {
t.Errorf("logged %q, want each module tool run unmarked once with its caller %q", logged, want) t.Errorf("logged %q, want each module tool run unmarked once with its caller %q", logged, want)
} }
// A-433: a module's runtime of its own (its runner the module itself) runs its own account's seat call while unread, as the
// indexer's runtime asks its own mesh-catalog.revision for the first view it waits on; a seat the definition does not class
// read, so no start read.
own := New(Deps{Node: "n1", Runner: "mesh-delivery-indexer", Catalog: unread{defs: map[string]seatdef.Definition{}},
Wait: func(time.Duration) error { return errors.New("still unread") }, Logf: func(string, ...any) {}})
ran := false
if _, err := own.Run(Call{Address: "mesh-catalog.revision", Module: "mesh-delivery-indexer", Seat: "mesh-catalog", Name: "revision",
Fingerprint: "fp1", Caller: "n1.mesh-delivery-indexer"}, func() (any, error) { ran = true; return "ok", nil }); err != nil || !ran {
t.Errorf("the module's own seat call in its own runtime: ran %v (%v), want it run", ran, err)
}
} }
+9 -7
View File
@@ -90,17 +90,19 @@ func (g *Gate) startRead(c Call) bool {
return i >= 0 && def.Verbs[i].Class == seatdef.ClassRead && !def.Verbs[i].NeedsApproval return i >= 0 && def.Verbs[i].Class == seatdef.ClassRead && !def.Verbs[i].NeedsApproval
} }
// calledByModule says a module tool runs unmarked while the catalog half is unread (design 47 G lead answers A-389): one // calledByModule says a call runs unmarked while the catalog half is unread (design 47 G lead answers A-389, A-433): one
// whose proven caller is another module's account, `<node>.<module>` naming neither the tool's module nor the runner's // whose proven caller is a module's account, `<node>.<module>`, a seat verb or a module tool alike, and the module itself
// own, which is the account the console and the sessions through it call as; a person's, the controller's or an unproven // in a runtime of its own; never the runner's own account where the runner serves other modules (the console's, which the
// caller is none. The runner's own tools served under a module's name are no module tool. Each such tool is logged once, // sessions and agents call as), a person's, the controller's or an unproven caller. Approval marks are for agent calls; a
// with its caller. // module's account may do everything (principle 6), and a runtime of its own asks its own seat for the very first view it
// waits on (novox 2026-11-16: the indexer's runtime refused its own mesh-catalog.revision for ever). The runner's own tools
// are none. Each such call is logged once, with its caller.
func (g *Gate) calledByModule(c Call) bool { func (g *Gate) calledByModule(c Call) bool {
if c.Seat != "" || c.Own || strings.HasPrefix(c.Caller, "person.") { if c.Own || strings.HasPrefix(c.Caller, "person.") {
return false return false
} }
node, module, ok := strings.Cut(c.Caller, ".") node, module, ok := strings.Cut(c.Caller, ".")
if !ok || node == "" || module == "" || strings.Contains(module, ".") || module == c.Module || module == g.d.Runner { if !ok || node == "" || module == "" || strings.Contains(module, ".") || (module == g.d.Runner && g.d.Runner != c.Module) {
return false return false
} }
g.mu.Lock() g.mu.Lock()