Declare the runner's drain bound and kept-call pace settings, read at its start

node-tools declares drain-bound (30s), kept-call-pace-first (1s) and kept-call-pace-max (30s) as
duration settings; the runner reads the pace through the SDK at its start, as it reads its drain
bound, and stops before it serves on a value that is no duration.

Builds: design 47 H2 §775, §813 (12), §781, H-A-370, H-A-377
This commit is contained in:
2026-11-22 00:01:45 +01:00
parent 5cca1fceba
commit 0c7000fa93
3 changed files with 46 additions and 21 deletions
+5
View File
@@ -31,6 +31,7 @@ import (
"git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/approval"
"git.novox.be/novox/mesh-sdk/go/busretry"
"github.com/novox/mesh-tools/node-tools/internal/alive"
runnerapproval "github.com/novox/mesh-tools/node-tools/internal/approval"
@@ -71,6 +72,10 @@ func serve(ctx context.Context) error {
if err != nil {
return err
}
// And the pace of its kept calls, its settings kept-call-pace-first and kept-call-pace-max (design 47 H2 §775).
if err := busretry.ReadPace(stdio.SettingDuration); err != nil {
return err
}
until := time.Now().Add(startWait)
cred := credential(until)
conn := connectPatiently(cred, until)
+21 -21
View File
@@ -131,33 +131,33 @@ func connectsWithin(t *testing.T) {
}
}
// **The drain bound is the setting drain-bound** (design 47 H2 §813 (12), H-A-369, H-A-370, H-A-377): a duration text the
// node-engine composes as MESH_CONFIG_DRAIN_BOUND, 30 s when none is composed; a value that is no duration stops the runner
// before it serves, naming the setting.
func TestTheRunnersDrainBoundIsItsSettingDrainBound(t *testing.T) {
// **The runner's settings are read through the one settings reader** (design 47 H2 §813 (12), §775, H-A-369, H-A-370,
// H-A-377): drain-bound, a duration text the node-engine composes as MESH_CONFIG_DRAIN_BOUND, 30 s when none is composed; a
// value that is no duration, of it or of the kept call's pace, stops the runner before it serves, naming the setting.
func TestTheRunnersSettingsAreReadThroughTheOneReader(t *testing.T) {
for _, row := range []struct {
composed string
want time.Duration
refused bool
word, composed, refused string
want time.Duration
}{
{"", 30 * time.Second, false},
{"5s", 5 * time.Second, false},
{"30", 0, true},
{"MESH_CONFIG_DRAIN_BOUND", "", "", 30 * time.Second},
{"MESH_CONFIG_DRAIN_BOUND", "5s", "", 5 * time.Second},
{"MESH_CONFIG_DRAIN_BOUND", "30", "drain-bound", 0},
{"MESH_CONFIG_KEPT_CALL_PACE_FIRST", "1", "kept-call-pace-first", 30 * time.Second},
{"MESH_CONFIG_KEPT_CALL_PACE_MAX", "100ms", "kept-call-pace-max", 30 * time.Second},
} {
t.Run(row.composed, func(t *testing.T) {
t.Setenv("MESH_CONFIG_DRAIN_BOUND", row.composed)
got, err := drainBoundSetting()
if row.refused {
if err == nil || !strings.Contains(err.Error(), "drain-bound") {
t.Errorf("drain-bound %q read %s, %v; want it refused by name", row.composed, got, err)
t.Run(row.word+"="+row.composed, func(t *testing.T) {
t.Setenv(row.word, row.composed)
if row.refused != "" {
if err := serve(t.Context()); err == nil || !strings.Contains(err.Error(), row.refused) {
t.Errorf("the runner with %s=%q served (%v); want it stopped before it serves, naming %s", row.word,
row.composed, err, row.refused)
}
if err := serve(t.Context()); err == nil || !strings.Contains(err.Error(), "drain-bound") {
t.Errorf("the runner with drain-bound %q served (%v); want it stopped before it serves", row.composed, err)
if row.want == 0 {
return
}
return
}
if err != nil || got != row.want {
t.Errorf("drain-bound %q read %s, %v; want %s", row.composed, got, err, row.want)
if got, err := drainBoundSetting(); err != nil || got != row.want {
t.Errorf("drain-bound read %s, %v; want %s", got, err, row.want)
}
})
}
+20
View File
@@ -37,6 +37,26 @@
"why": "the mesh's tools for whoever is on this machine, over MCP on loopback; the machine's login is the authority (novox/hq ADR 0152, 0175)"
}
],
"config": {
"drain-bound": {
"type": "string",
"description": "how long the tool runner, once told to stop, finishes the calls in flight before it cuts them and stops its bundles, a Go duration such as 30s (design 47 H2 §813 (12), H-A-377).",
"trusted": false,
"default": "30s"
},
"kept-call-pace-first": {
"type": "string",
"description": "how long the tool runner's kept call waits after its first transport fault before it calls again, doubling to kept-call-pace-max, a Go duration such as 1s (design 47 H2 §775).",
"trusted": false,
"default": "1s"
},
"kept-call-pace-max": {
"type": "string",
"description": "the longest wait of the tool runner's kept call between two calls, a Go duration such as 30s (design 47 H2 §775).",
"trusted": false,
"default": "30s"
}
},
"resources": [
{
"id": "mesh-state",