E3: compose every setting as the word the one settings reader takes

A module's settings reached its own process only as files its manifest
named, and its tools bundles not at all. The node-engine now composes each
setting the module declares as MESH_CONFIG_<KEY>, its value as text, into
each of its processes' environments and its slice of the tool runner's
MESH_TOOL_ENV alike, and the tool runner's own into its process; the
runner's drain-bound is a Go duration like every time setting.

Builds: design 47 H2 §781; H-A-350 DMC-13, H-A-370, H-A-377
This commit is contained in:
2026-11-22 00:09:04 +01:00
parent 84fc34398a
commit b33061088a
5 changed files with 152 additions and 35 deletions
+34 -29
View File
@@ -3,9 +3,10 @@ package resolution
import (
"encoding/json"
"fmt"
"slices"
"sort"
"strconv"
"strings"
"time"
mcat "git.novox.be/novox/mesh-sdk/go/catalogue"
)
@@ -164,6 +165,14 @@ func resolutionRuntimeProcess(r mcat.Resolution, with mcat.Rendering, h Holding)
sort.Strings(restartOn)
env := map[string]string{mcat.RuntimeToolModules: strings.Join(served, ","), mcat.RuntimeBrokerFile: credential.Path}
// The tool runner's own settings, as every module's process is given its own (design 47 H2 §781, H-A-370).
own, err := settingWords(*runtime, with.Settings[runtime.Module])
if err != nil {
return nil, err
}
for word, value := range own {
env[word] = value
}
if len(given) > 0 {
// Marshalled from maps, whose keys encoding/json sorts: the same words, the same unit.
body, err := json.Marshal(given)
@@ -201,42 +210,29 @@ func resolutionRuntimeProcess(r mcat.Resolution, with mcat.Rendering, h Holding)
return process, nil
}
// DrainBoundSetting is the tool runner module's setting of how long, in seconds, it finishes its calls in flight once
// stopped (design 47 H2 §813 (12)); DefaultDrainBound is its default where no layer sets it (H-A-358).
// DrainBoundSetting is the tool runner module's setting of how long it finishes its calls in flight once stopped, a Go
// duration such as "30s" (design 47 H2 §813 (12), H-A-377); DefaultDrainBound is its default where no layer sets it
// (H-A-358).
const (
DrainBoundSetting = "drain-bound"
DefaultDrainBound = 30
DefaultDrainBound = 30 * time.Second
)
// drainBoundOf is the tool runner's drain bound in seconds, from its setting drain-bound, else DefaultDrainBound (design
// 47 H2 §813 (12), H-A-358): the node-engine writes its unit's stop from it. A value that is no whole number of seconds
// above zero is refused by name.
// drainBoundOf is the tool runner's drain bound in whole seconds, the declaration's process field, from its setting
// drain-bound, else DefaultDrainBound (design 47 H2 §813 (12), H-A-358, H-A-377): the node-engine writes its unit's stop
// from it. The setting is a Go duration, as every time setting is (H-A-370); part of a second counts as a whole one, so
// the bound is never shorter than the setting. A value that is no duration above zero is refused by name.
func drainBoundOf(m mcat.Manifest, layers []mcat.Layer) (int, error) {
v, set := settingValue(WithDefaults(m, layers), DrainBoundSetting)
if !set {
return DefaultDrainBound, nil
return int(DefaultDrainBound / time.Second), nil
}
var n float64
switch x := v.(type) {
case float64:
n = x
case int:
n = float64(x)
case int64:
n = float64(x)
case string:
parsed, err := strconv.Atoi(strings.TrimSpace(x))
if err != nil {
return 0, fmt.Errorf("%s's setting %s is %q, and it is a whole number of seconds", m.Module, DrainBoundSetting, x)
}
n = float64(parsed)
default:
return 0, fmt.Errorf("%s's setting %s is %v, and it is a whole number of seconds", m.Module, DrainBoundSetting, v)
text, ok := v.(string)
d, err := time.ParseDuration(strings.TrimSpace(text))
if !ok || err != nil || d <= 0 {
return 0, fmt.Errorf("%s's setting %s is %v, and it is a Go duration above zero, such as \"30s\" (H-A-377)", m.Module, DrainBoundSetting, v)
}
if n < 1 || n != float64(int(n)) {
return 0, fmt.Errorf("%s's setting %s is %v, and it is a whole number of seconds above zero", m.Module, DrainBoundSetting, v)
}
return int(n), nil
return int((d + time.Second - 1) / time.Second), nil
}
// NoRuntimeToRunError is a module of its own account with no runtime program on its node to run it from. Held says the
@@ -400,7 +396,16 @@ func bundleWords(m mcat.Manifest, with mcat.Rendering) (map[string]string, error
out[word] = value
}
}
return out, nil
// And the module's settings, as its processes are given them (design 47 H2 §781, H-A-370), for a module the runtime
// loads a bundle of.
if !slices.ContainsFunc(m.Bundles, func(b mcat.Bundle) bool { return len(b.Loads) > 0 }) {
return out, nil
}
settings, err := settingWords(m, with.Settings[m.Module])
if err != nil {
return nil, err
}
return withSettingWords(out, settings, m.Module, "bundles' words")
}
// givenTo makes what a bundle's words name readable by the account the runtime runs as (novox/hq