Let the approval gate's start path through a module's own first-view tools (A-377)

The tool is told by the callers list its bundle's environment carries (views.CallersEnv); the list still limits who.

Builds: design 47 G A-377 (widens A-359 toward A-353)

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-13 23:14:06 +01:00
parent 6903ed97cd
commit c01a3de0b2
4 changed files with 34 additions and 16 deletions
+3
View File
@@ -30,6 +30,9 @@ type Call struct {
Description string
// Own says it is one of the runner's own tools served under the module's name (its ledger repairs), not its bundle's.
Own bool
// Env is the environment the bundle is composed with, as the runner reads the fingerprint from it: a tool is a first-view
// tool when it holds views.CallersEnv(Name), the tool's callers list (design 47 G lead answers A-377).
Env map[string]string
}
// MostArguments is the most a marked call's arguments may hold: more is refused, asking nothing (§9).
+19 -14
View File
@@ -92,7 +92,7 @@ func (unread) Newest(string) (Entry, bool) { return Entry{}, fals
func (unread) Definitions() map[string]seatdef.Definition { return nil }
func (unread) Entries() []Entry { return nil }
// Design 47 G lead answers A-353, A-359: while its catalog half is unread, the gate lets through the five seat verbs that
// Design 47 G lead answers A-353, A-359: while its catalog half is unread, the gate lets through the seat verbs and first-view tools that
// half is read by, told from the call's seat and verb, and holds every other call as before.
func TestAnUnreadCatalogHalfLetsItsOwnReadsThrough(t *testing.T) {
waited := 0
@@ -103,17 +103,22 @@ func TestAnUnreadCatalogHalfLetsItsOwnReadsThrough(t *testing.T) {
for _, tc := range []struct {
seat, name string
runs bool
env map[string]string
}{
{"mesh-catalog", "registrations", true},
{"mesh-catalog", "revision", true},
{"mesh-catalog", "entry", true},
{"mesh-delivery", "source", true},
{"mesh-broker", "list", true},
{"mesh-broker", "events", false},
{"mesh-catalog", "register", false},
{"mesh-delivery", "registrations", false},
{"", "registrations", false}, // a module's tool of that name is no seat verb
{"", "revision", false},
{"mesh-catalog", "registrations", true, nil},
{"mesh-catalog", "revision", true, nil},
{"mesh-catalog", "entry", true, nil},
{"mesh-delivery", "source", true, nil},
{"mesh-broker", "list", true, nil},
{"mesh-broker", "events", false, nil},
// A-377: a module's own first-view tool runs unread, an ordinary tool of the same module stays held.
{"", "modules", true, map[string]string{"MESH_VIEW_CALLERS_MODULES": "grants"}},
{"", "first-things", true, map[string]string{"MESH_VIEW_CALLERS_FIRST_THINGS": "grants"}},
{"", "read_modules", false, map[string]string{"MESH_VIEW_CALLERS_MODULES": "grants"}},
{"mesh-catalog", "register", false, nil},
{"mesh-delivery", "registrations", false, nil},
{"", "registrations", false, nil}, // a module's tool of that name is no seat verb
{"", "revision", false, nil},
} {
ran := false
address := tc.seat + "." + tc.name
@@ -121,7 +126,7 @@ func TestAnUnreadCatalogHalfLetsItsOwnReadsThrough(t *testing.T) {
address = "mesh-delivery-indexer." + tc.name
}
_, err := g.Run(Call{Address: address, Module: "mesh-delivery-indexer", Seat: tc.seat, Name: tc.name, Fingerprint: "fp1",
Caller: "node-tools"}, func() (any, error) { ran = true; return "ok", nil })
Caller: "node-tools", Env: tc.env}, func() (any, error) { ran = true; return "ok", nil })
if ran != tc.runs || (err == nil) != tc.runs {
t.Errorf("%s: ran %v (%v), want ran %v", address, ran, err, tc.runs)
}
@@ -129,7 +134,7 @@ func TestAnUnreadCatalogHalfLetsItsOwnReadsThrough(t *testing.T) {
t.Errorf("%s: refused with %v, want the marks not read yet", address, err)
}
}
if waited != 5 {
t.Errorf("the other calls waited for the catalog half %d times, want 5 (the five start reads wait for nothing)", waited)
if waited != 6 {
t.Errorf("the other calls waited for the catalog half %d times, want 6 (the start reads wait for nothing)", waited)
}
}
+10 -1
View File
@@ -70,11 +70,20 @@ type Binding interface{ Bound() bool }
// startReads are the seat verbs the catalog half is read by, as `<seat>.<verb>`: while it is unread the gate lets them
// through, so the runner that serves them answers the reads its own catalog half waits on (design 47 G lead answers
// A-353, A-359, A-375).
// A-353, A-359, A-375), and so is a module's own first-view tool (A-377): the tool whose callers list its
// bundle's environment carries, a list that still limits who may call it.
var startReads = []string{"mesh-catalog.registrations", "mesh-catalog.revision", "mesh-catalog.entry", "mesh-delivery.source", "mesh-broker.list"}
// ViewCallersPrefix starts the name of the env value that holds a first-view tool's callers list in its owner's bundle
// (views.CallersEnv adds the tool's name), by which the gate tells a first-view tool.
const ViewCallersPrefix = "MESH_VIEW_CALLERS_"
// startRead says the call is one of startReads, told from its seat and verb.
func startRead(c Call) bool {
if c.Seat == "" {
_, first := c.Env[ViewCallersPrefix+strings.ToUpper(strings.ReplaceAll(c.Name, "-", "_"))]
return first
}
return c.Seat != "" && slices.Contains(startReads, c.Seat+"."+c.Name)
}
+2 -1
View File
@@ -8,6 +8,7 @@ import (
"time"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/approval"
)
// KeptSource is a state as a tools bundle reads it through its runtime (stdio.KeptState), as a Source.
@@ -67,7 +68,7 @@ func ParseCallers(list string) stdio.Callers {
// CallersEnv is the env value of a first-view tool's callers list, in the owner's tools bundle: MESH_VIEW_CALLERS_<TOOL>,
// the tool's name in capitals, a hyphen an underscore.
func CallersEnv(tool string) string {
return "MESH_VIEW_CALLERS_" + strings.ToUpper(strings.ReplaceAll(tool, "-", "_"))
return approval.ViewCallersPrefix + strings.ToUpper(strings.ReplaceAll(tool, "-", "_"))
}
// Refusal is why caller may not ask tool, or nil: the caller's proof, never an argument, against the tool's callers