indexer: a node-engine's call of the verb revision is proved as node.<machine> and stands for the module holding the seat node-engine (A-450)

Builds: design 47 G (G-22 lead answers 2) A-450; ADR 0621 §2, ADR 0663 §2
This commit is contained in:
2026-11-16 14:13:31 +01:00
parent 05c765e36d
commit d69ee47321
2 changed files with 57 additions and 0 deletions
@@ -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.<machine>; 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)
}
})
}
}
@@ -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.<machine>` (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)
}