The node-engine finds the tool runner by what its manifest says (tool-runner), never by its name, pinned at mesh-sdk a973bfa (issue 774, the operator 2026-11-03)

This commit is contained in:
2026-11-03 13:28:44 +01:00
parent 12c80d7c2e
commit db7cd273f0
13 changed files with 105 additions and 95 deletions
+16 -20
View File
@@ -21,12 +21,8 @@ func BundlePath(module, bundle string) string { return mcat.BundleRoot + "/" + m
// a node is sent exactly what it was sent before, bundles included, because a bundle nothing loads
// is bytes nobody reads.
func resolutionRuntimeHere(r mcat.Resolution) bool {
for _, m := range r.Modules {
if m.Module == mcat.RuntimeModule {
return true
}
}
return false
_, here := mcat.ToolRunnerOf(r.Modules)
return here
}
// bundleArchives is one archive per tools bundle of a module — a bundle the runtime LOADS something
@@ -59,13 +55,13 @@ func RuntimeProcessID() string { return "runtime" }
// interpreterFor is how a bundle in a language is run: the program the host's unit starts, with the
// bundle's entrypoint after it. The one thing the composer takes from a language, and said here
// rather than in a manifest because the runtime's process is the mesh's to compose (to-be 38 WP3).
func interpreterFor(language string) (string, error) {
func interpreterFor(module, language string) (string, error) {
switch language {
case "typescript":
return "node", nil
}
return "", fmt.Errorf(
"%s is written in %q, and the mesh knows no interpreter to run a %q bundle with", mcat.RuntimeModule, language, language)
"%s is written in %q, and the mesh knows no interpreter to run a %q bundle with", module, language, language)
}
// runtimeProcess is the one process a machine runs the node's tool runtime as (novox/hq ADR 0175,
@@ -80,7 +76,7 @@ func interpreterFor(language string) (string, error) {
func resolutionRuntimeProcess(r mcat.Resolution, with mcat.Rendering) (map[string]any, error) {
var runtime *mcat.Manifest
for i := range r.Modules {
if r.Modules[i].Module == mcat.RuntimeModule {
if mcat.IsToolRunner(r.Modules[i]) {
runtime = &r.Modules[i]
}
}
@@ -93,7 +89,7 @@ func resolutionRuntimeProcess(r mcat.Resolution, with mcat.Rendering) (map[strin
if len(runtime.Bundles) != 1 {
return nil, fmt.Errorf(
"%s is assigned to %s and its build produced %d bundle(s); the runtime is one bundle "+
"the mesh runs, so the module declares exactly one (novox/hq to-be 38)", mcat.RuntimeModule, r.Node, len(runtime.Bundles))
"the mesh runs, so the module declares exactly one (novox/hq to-be 38)", runtime.Module, r.Node, len(runtime.Bundles))
}
bundle := runtime.Bundles[0]
// What runs it (novox/hq ADR 0193): a runtime compiled to a binary runs itself, from its own
@@ -105,9 +101,9 @@ func resolutionRuntimeProcess(r mcat.Resolution, with mcat.Rendering) (map[strin
if len(bundle.Entrypoints) != 1 {
return nil, fmt.Errorf(
"%s's bundle %q names %d entrypoint(s); the runtime is run from one, so the module "+
"declares exactly one (novox/hq to-be 38)", mcat.RuntimeModule, bundle.Name, len(bundle.Entrypoints))
"declares exactly one (novox/hq to-be 38)", runtime.Module, bundle.Name, len(bundle.Entrypoints))
}
interpreter, err := interpreterFor(bundle.Language)
interpreter, err := interpreterFor(runtime.Module, bundle.Language)
if err != nil {
return nil, err
}
@@ -117,7 +113,7 @@ func resolutionRuntimeProcess(r mcat.Resolution, with mcat.Rendering) (map[strin
if !declared {
return nil, fmt.Errorf(
"%s declares no own secret named broker, and the node's credential is delivered there: "+
"a module that speaks on the bus declares \"own-secrets\": {\"broker\": <path>}", mcat.RuntimeModule,
"a module that speaks on the bus declares \"own-secrets\": {\"broker\": <path>}", runtime.Module,
)
}
@@ -163,7 +159,7 @@ func resolutionRuntimeProcess(r mcat.Resolution, with mcat.Rendering) (map[strin
}
}
sort.Strings(served)
restartOn = append(restartOn, mcat.RuntimeModule+"."+mcat.NeedID("broker"))
restartOn = append(restartOn, runtime.Module+"."+mcat.NeedID("broker"))
sort.Strings(restartOn)
env := map[string]string{mcat.RuntimeToolModules: strings.Join(served, ","), mcat.RuntimeBrokerFile: credential.Path}
@@ -176,7 +172,7 @@ func resolutionRuntimeProcess(r mcat.Resolution, with mcat.Rendering) (map[strin
env[mcat.RuntimeToolEnv] = string(body)
}
process := map[string]any{
"id": mcat.RuntimeModule + "." + RuntimeProcessID(), "type": "process", "name": mcat.RuntimeModule,
"id": runtime.Module + "." + RuntimeProcessID(), "type": "process", "name": runtime.Module,
"source": bundle.Source, "digest": bundle.Digest,
"run": run,
"env": env,
@@ -193,7 +189,7 @@ func resolutionRuntimeProcess(r mcat.Resolution, with mcat.Rendering) (map[strin
}
// Routed through the artifact store as this network reaches it now, like everything the mesh
// built; refused with the same words when there is no store to route through.
if err := artifactsInto(process, mcat.RuntimeModule, with); err != nil {
if err := artifactsInto(process, runtime.Module, with); err != nil {
return nil, err
}
return process, nil
@@ -229,14 +225,14 @@ func resolutionOwnRuntimes(r mcat.Resolution, with mcat.Rendering) ([]map[string
}
var runtime *mcat.Manifest
for i := range r.Modules {
if r.Modules[i].Module == mcat.RuntimeModule {
if mcat.IsToolRunner(r.Modules[i]) {
runtime = &r.Modules[i]
}
}
if runtime == nil || len(runtime.Bundles) != 1 || runtime.Bundles[0].Binary == "" {
return nil, &NoRuntimeToRunError{Held: runtime != nil && runtime.Stubbed, said: fmt.Sprintf("%s runs as its own "+
"account in a runtime of its own, and %s is not here to run it from: assign %s to %s first (novox/hq ADR 0259)",
own[0].Module, mcat.RuntimeModule, mcat.RuntimeModule, r.Node)}
"account in a runtime of its own, and the tool runner is not here to run it from: assign the tool runner to %s first "+
"(novox/hq ADR 0259)", own[0].Module, r.Node)}
}
program := runtime.Bundles[0]
var out []map[string]any
@@ -314,7 +310,7 @@ func resolutionOwnRuntimes(r mcat.Resolution, with mcat.Rendering) ([]map[string
if yielding != nil {
process["yields"] = yielding
}
if err := artifactsInto(process, mcat.RuntimeModule, with); err != nil {
if err := artifactsInto(process, runtime.Module, with); err != nil {
return nil, err
}
out = append(out, process)