Carry a process's drain bound in the declaration

A process that stays up may name drain-bound (seconds): the node-engine
writes its unit's stop from it, so the tool runner finishes its calls in
flight before it exits. Absent is none; a step or a scheduled run is
refused one.

Builds: design 47 H2 §813 (12); H-A-358, H-A-353
This commit is contained in:
2026-11-21 23:08:38 +01:00
parent f5dc3b6bd1
commit d40fa0b3a0
2 changed files with 28 additions and 0 deletions
+16
View File
@@ -1,6 +1,7 @@
package declaration
import (
"encoding/json"
"strings"
"testing"
)
@@ -99,6 +100,9 @@ func testTheModesAreExclusive(t *testing.T) {
"an unknown priority": func(p *Process) { p.Yields = &Yields{Priority: "low"} },
"a share over the whole": func(p *Process) { p.Yields = &Yields{CPUShare: 150} },
"a yield saying nothing": func(p *Process) { p.Yields = &Yields{} },
// Design 47 H2 §813 (12), H-A-358: a drain bound is seconds, for a process that stays up.
"a step with a drain bound": func(p *Process) { p.RunOnce = true; p.DrainBound = 30 },
"a negative drain bound": func(p *Process) { p.DrainBound = -1 },
} {
p := aProcess()
bad(p)
@@ -106,6 +110,18 @@ func testTheModesAreExclusive(t *testing.T) {
t.Errorf("%s was accepted", name)
}
}
// It travels in the declaration under drain-bound, and so in its digest; absent says none.
up := aProcess()
up.DrainBound = 30
if problems := up.validate("a process", false); len(problems) != 0 {
t.Errorf("a process that stays up with a drain bound was refused: %v", problems)
}
if b, _ := json.Marshal(up); !strings.Contains(string(b), `"drain-bound":30`) {
t.Errorf("the drain bound is not in the declaration: %s", b)
}
if b, _ := json.Marshal(aProcess()); strings.Contains(string(b), "drain-bound") {
t.Errorf("a process with no drain bound says one: %s", b)
}
}
// A cadence that is not a cadence is refused near its author, rather than by a machine at the far