From d69ee473218f996a4df75c90f4bad670c4c729ed Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 16 Nov 2026 14:13:31 +0100 Subject: [PATCH] indexer: a node-engine's call of the verb revision is proved as node. and stands for the module holding the seat node-engine (A-450) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds: design 47 G (G-22 lead answers 2) A-450; ADR 0621 §2, ADR 0663 §2 --- .../internal/index/catalog_branches_test.go | 34 +++++++++++++++++++ .../internal/index/revision_verb.go | 23 +++++++++++++ 2 files changed, 57 insertions(+) diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_branches_test.go b/modules/mesh-delivery-indexer/internal/index/catalog_branches_test.go index d6d653a7..e5f21613 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_branches_test.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_branches_test.go @@ -96,3 +96,37 @@ func TestACatalogRevisionIsKeptPerWatchedBranch(t *testing.T) { t.Error("a candidate never kept was answered") } } + +// A-450: a node-engine's call is proved as node.; it is answered as the module whose entry serves the seat node-engine +// (a part of the revision, so on the list as its own call would be), and refused when the revision holds no such module or the +// account is no node's. +func TestTheNodeEngineReadsTheRevisionAsTheModuleHoldingItsSeat(t *testing.T) { + ctx := context.Background() + for _, c := range []struct { + name string + invokes []string + caller string + want bool + }{ + {"the engine's module declares the verb", []string{RevisionInvoke}, "node.novox", true}, + {"no module of the revision serves the seat node-engine", nil, "node.novox", false}, + {"a caller with a dot after the machine is no engine's account", []string{RevisionInvoke}, "node.novox.extra", false}, + {"a module that serves no engine seat is no engine", []string{RevisionInvoke}, "node.", false}, + } { + t.Run(c.name, func(t *testing.T) { + ix := &Indexer{Module: testSelf, Revisions: newMemObjects(1 << 20)} + engine := meshcatalog.CatalogEntry{Module: "mesh-host", Repository: "novox/h", Commit: "c1", Manifest: map[string]any{}, + Serves: []string{"seat:node-engine.compose", "seat:node-engine.compose-candidate"}, Invokes: c.invokes} + if c.name == "no module of the revision serves the seat node-engine" { + engine.Serves = nil + } + if err := ix.KeepBranchEntries(ctx, "main", 5, map[string]meshcatalog.CatalogEntry{"mesh-host": engine}); err != nil { + t.Fatal(err) + } + _, err := Revision(ctx, ix.Revisions, "indexer", c.caller, meshcatalog.RevisionInput{Branch: "main"}) + if (err == nil) != c.want { + t.Errorf("caller %q: err %v, want answered %v", c.caller, err, c.want) + } + }) + } +} diff --git a/modules/mesh-delivery-indexer/internal/index/revision_verb.go b/modules/mesh-delivery-indexer/internal/index/revision_verb.go index fa5cec93..13da59fd 100644 --- a/modules/mesh-delivery-indexer/internal/index/revision_verb.go +++ b/modules/mesh-delivery-indexer/internal/index/revision_verb.go @@ -34,6 +34,28 @@ func RevisionCallers(entries []meshcatalog.CatalogEntry, holder string) stdio.Ca return out } +// nodeEngineSeat is the seat whose holder's calls come as the account of a node, not of a module process. +const nodeEngineSeat = "node-engine" + +// CallerModule is the caller a callers list is checked against (design 47 G A-450; ADR 0621 §2, ADR 0663 §2): the proof of a +// node-engine's call is the account `node.` (one dot), which no list entry names, so it stands for the module whose +// entry of the revision serves the seat node-engine, the part that declares the verb. Any other caller is its own. Every verb +// of the seat mesh-catalog the indexer holds that checks its caller reads it through this one function. +func CallerModule(entries []meshcatalog.CatalogEntry, caller string) string { + machine, ok := strings.CutPrefix(caller, "node.") + if !ok || machine == "" || strings.Contains(machine, ".") { + return caller + } + for _, e := range entries { + for _, word := range e.Serves { + if strings.HasPrefix(word, "seat:"+nodeEngineSeat+".") { + return e.Module + } + } + } + return caller +} + // ToolRunner is the module of every node's tool runner, the runtime every module's tools run in (A-395). const ToolRunner = "node-tools" @@ -57,6 +79,7 @@ func Revision(ctx context.Context, o Objects, holder, caller string, in meshcata if err != nil { return out, err } + caller = CallerModule(trunkEntries, caller) if err := views.Refusal(meshcatalog.Seat+"."+meshcatalog.VerbRevision, RevisionCallers(trunkEntries, holder), caller); err != nil { return out, fmt.Errorf("%w (novox/hq ADR 0663 §2: a part reads it by declaring %s in invokes)", err, RevisionInvoke) }