node-tools: a stopping tool runner answers the typed fault stopping (H-A-542)

A call the runner does not take once its stop began was answered nothing, so its
caller's wait ended in a bare "timeout" and a build step's publish failed (main.440).
It is now answered with error-kind stopping beside its words, on a tool's reply and
a seat proof's alike; the calling runner keeps that kind and hands it to its bundle
as the JSON-RPC error's data, so mesh-sdk's stdio tells it by its kind. A call cut
at the drain bound stays unanswered (H-A-369).

Builds: design 47 H2 H-A-542 (amends H-A-369)
This commit is contained in:
2026-11-23 11:43:19 +01:00
parent f26ca923c9
commit 089d98b406
8 changed files with 132 additions and 27 deletions
+17 -4
View File
@@ -34,6 +34,16 @@ func TestALostWriteIsAnsweredWithItsOwnCodeAndNothingElseIs(t *testing.T) {
if got := errorCode(errors.New("issues keeps no state numbers")); got == CodeChanged || got != -32000 {
t.Errorf("a plain refusal is answered %d", got)
}
// A typed fault reaches the bundle as its kind in the error's data, wrapped or not (design 47 H2 H-A-542); a plain
// refusal carries none.
for _, err := range []error{&afterStop{module: "registry", verb: "publish"}, fmt.Errorf("asked: %w", &afterStop{module: "registry", verb: "publish"})} {
if data, _ := errorAnswer(err)["data"].(map[string]any); data["error-kind"] != ErrorKindStopping {
t.Errorf("%v is answered %v, want its error-kind stopping", err, errorAnswer(err))
}
}
if _, has := errorAnswer(errors.New("issues keeps no state numbers"))["data"]; has {
t.Error("a plain refusal is answered an error-kind")
}
}
// A bundle that answers the handshake and an empty tool list, and notes each start and its pid in $OUT.
@@ -55,7 +65,7 @@ done
// itself is stopping, none is, by a restart or by a call.
//
// **The tool runner drains at a stop** (design 47 H2 §813 (12), H-A-342 (2), H-A-353, H-A-369): once it drains, no new call is
// taken and its caller is answered nothing (Unanswered), never refused; a call
// taken and its caller is answered the typed fault stopping (H-A-542), never silence; a call
// in flight that ends within the drain bound is answered; one still in flight at the bound is cut, said with its bundle, its verb
// and its age, and left unanswered (Unanswered, so the bus sends its caller nothing: a transport fault).
func TestABundleIsStartedAgainUnlessTheRuntimeIsStopping(t *testing.T) {
@@ -71,7 +81,7 @@ func TestABundleIsStartedAgainUnlessTheRuntimeIsStopping(t *testing.T) {
}{
{"a bundle that dies while the runtime serves", false, 2, 0, false},
{"a bundle signalled with the stopping runtime", true, 1, 0, false},
{"a call that ends within the drain bound is answered, and a call after the stop is answered nothing", false, 0, 10 * time.Second, true},
{"a call that ends within the drain bound is answered, and a call after the stop is answered stopping", false, 0, 10 * time.Second, true},
{"a call that outlives the drain bound is cut and said", false, 0, 50 * time.Millisecond, false},
} {
t.Run(row.name, func(t *testing.T) {
@@ -130,9 +140,12 @@ func TestABundleIsStartedAgainUnlessTheRuntimeIsStopping(t *testing.T) {
}
}
if row.release {
// A call made after the stop is answered the typed fault stopping, never silence (H-A-542).
var kinded interface{ ErrorKind() string }
var unanswered interface{ Unanswered() bool }
if _, err := run("", json.RawMessage(`{}`)); !errors.As(err, &unanswered) || !unanswered.Unanswered() {
t.Errorf("a call made after the stop ended %v, want it answered nothing, never refused", err)
if _, err := run("", json.RawMessage(`{}`)); !errors.As(err, &kinded) || kinded.ErrorKind() != ErrorKindStopping ||
errors.As(err, &unanswered) {
t.Errorf("a call made after the stop ended %v, want it answered stopping, never silence", err)
}
f, err := os.OpenFile(hold, os.O_WRONLY, 0)
if err != nil {