sdk-holder-callers-gone: the gate knows a first-view tool by its name; ViewCallersPrefix and views.CallersEnv go

Builds: design 47 H §752, H-A-66, H-A-69
This commit is contained in:
2026-11-20 02:37:45 +01:00
parent b54a05a687
commit c74f332eba
4 changed files with 14 additions and 21 deletions
+1 -2
View File
@@ -30,8 +30,7 @@ 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 is the environment the bundle is composed with, as the runner reads the fingerprint from it.
Env map[string]string
}
+5 -4
View File
@@ -133,8 +133,9 @@ func TestAnUnreadCatalogHalfLetsItsOwnReadsThrough(t *testing.T) {
{"unheld", "list", false, nil, "", false}, // a seat the runner holds no definition of
{"mesh-broker", "events", false, nil, "", false},
// 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"}, "", false},
{"", "first-things", true, map[string]string{"MESH_VIEW_CALLERS_FIRST_THINGS": "grants"}, "", false},
{"", "mesh-delivery-indexer_first_views", true, nil, "", false},
{"", "mesh-delivery-indexer_first_view_again", true, nil, "", false},
{"", "first_views", false, nil, "", false},
{"", "read_modules", false, map[string]string{"MESH_VIEW_CALLERS_MODULES": "grants"}, "", false},
{"mesh-catalog", "register", false, nil, "", false},
{"mesh-delivery", "registrations", false, nil, "", false},
@@ -172,8 +173,8 @@ func TestAnUnreadCatalogHalfLetsItsOwnReadsThrough(t *testing.T) {
t.Errorf("%s: refused with %v, want the marks not read yet", address, err)
}
}
if waited != 19 {
t.Errorf("the other calls waited for the catalog half %d times, want 19 (the start reads wait for nothing)", waited)
if waited != 20 {
t.Errorf("the other calls waited for the catalog half %d times, want 20 (the start reads wait for nothing)", waited)
}
want := []string{
"[approval] mesh-delivery-indexer.bridge_merged_message called by n2.mesh-delivery-forge-bridge: run unmarked before the catalog half is read",
+8 -8
View File
@@ -71,18 +71,18 @@ func (g *Gate) Run(c Call, run func() (any, error)) (any, error) {
// Binding is a Store that says whether the runner's membership binds the state now (§13).
type Binding interface{ Bound() bool }
// 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 runs while the catalog half is unread (design 47 G lead answers A-387, A-388): a seat verb the
// seat definition the runner holds classes `read` explicitly and does not mark needs-approval, so the runner that serves
// them answers the reads its own catalog half and the first take-in wait on; and 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.
// them answers the reads its own catalog half and the first take-in wait on; and a module's own first-view tools (A-377),
// known by their names `<module>_first_views` and `<module>_first_view_again` (design 47 H H-A-69).
func (g *Gate) startRead(c Call) bool {
if c.Seat == "" {
_, first := c.Env[ViewCallersPrefix+strings.ToUpper(strings.ReplaceAll(c.Name, "-", "_"))]
return first
for _, form := range []string{"_first_views", "_first_view_again"} {
if m, ok := strings.CutSuffix(c.Name, form); ok && m != "" {
return true
}
}
return false
}
def, ok := g.d.Catalog.Definitions()[c.Seat]
if !ok {
-7
View File
@@ -8,7 +8,6 @@ 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.
@@ -53,12 +52,6 @@ func (k KeptSource) History(key string) ([]Revision, error) {
return out, nil
}
// 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 approval.ViewCallersPrefix + strings.ToUpper(strings.ReplaceAll(tool, "-", "_"))
}
// FirstViewTool is an owner's first-view tool of one of its states (ADR 0621 §1): each call answers one page of what the
// state holds now, at the revision its mark says, to every caller (design 47 H §752, H-A-66). It reads only the
// owner's own state, so it answers as soon as the runtime is connected, before the owner has asked anyone anything