From c74f332eba54a90265f15057d8418823bb73d34d Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 02:37:45 +0100 Subject: [PATCH] sdk-holder-callers-gone: the gate knows a first-view tool by its name; ViewCallersPrefix and views.CallersEnv go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds: design 47 H §752, H-A-66, H-A-69 --- go/approval/act.go | 3 +-- go/approval/approval_test.go | 9 +++++---- go/approval/run.go | 16 ++++++++-------- go/views/tools.go | 7 ------- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/go/approval/act.go b/go/approval/act.go index 2219c975..535e66c0 100644 --- a/go/approval/act.go +++ b/go/approval/act.go @@ -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 } diff --git a/go/approval/approval_test.go b/go/approval/approval_test.go index 2adb54c7..c3920334 100644 --- a/go/approval/approval_test.go +++ b/go/approval/approval_test.go @@ -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", diff --git a/go/approval/run.go b/go/approval/run.go index f3dde11e..2ad008b3 100644 --- a/go/approval/run.go +++ b/go/approval/run.go @@ -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 `_first_views` and `_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 { diff --git a/go/views/tools.go b/go/views/tools.go index bc43f890..8ab9061a 100644 --- a/go/views/tools.go +++ b/go/views/tools.go @@ -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_, -// 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