node-tools: a stopping tool runner takes its subscriptions down, so callers meet no responders (issue 721)

The runner answered each call it did not take once its stop began with the typed fault
stopping (#90). Callers built before mesh-sdk read it as the callee's refusal and ended their
kept call, and no edge delivered the new answer after its readers. Now, once told to stop,
the runner first drains every subscription it answers calls on (a tool's, a seat verb's and
a seat proof's) and subscribes none again, then finishes the calls in flight within
drain-bound. A call made after the stop meets no responders at once, a transport fault every
caller of every mesh-sdk already waits out, until the new runner subscribes. A call that
still reached it is answered nothing, as H-A-369 has it. The typed answer goes whole: the
reply's error-kind, KindedError, ErrorKindStopping and the bundle's error data.

Tests: 721/AC4 in the bus (a call and a proof after the stop meet no responders within a
second, the call in flight is answered, a subject served after the stop is refused) and in
launch (a call that still reaches the runner gets no answer and no typed fault); the whole
test meets no responders while a call is still in flight, before the drain bound.

Builds: design 47 H2 H-A-570 (1), (3) (mesh-tools' part), amending §813 (12) as H-A-369 has it
This commit is contained in:
2026-11-23 16:35:15 +01:00
parent e8f58540ee
commit 662b05ca5a
9 changed files with 162 additions and 123 deletions
+10 -12
View File
@@ -33,21 +33,18 @@ var asks = struct {
ended chan struct{}
}{of: map[uint64]*inFlight{}}
// ErrorKindStopping is the typed fault a stopping tool runner answers each call it does not take with (design 47 H2 H-A-542,
// amending H-A-369): the answer's `error-kind`, so its caller asks again and meets the new runner; never silence.
const ErrorKindStopping = "stopping"
// afterStop is an ask made after the stop began: it is not taken, and its caller is answered the typed fault stopping
// (ErrorKind), never silence, so the caller asks again after a pause and meets the new runner (design 47 H2 §813 (12) as
// H-A-369 and H-A-542 amend it).
// afterStop is an ask made after the stop began that still reached the runner: a call the bus handed it before its
// subscriptions were down, or a message a consumer hands on. It is not taken and its caller is answered nothing, never
// refused, so the caller's kept call paces and meets the new runner (design 47 H2 §813 (12) as H-A-369 has it); a call made
// once the subscriptions are down meets no responders instead (H-A-570 (1)).
type afterStop struct{ module, verb string }
func (e *afterStop) Error() string {
return fmt.Sprintf("%s's %s was not taken: the tool runner is stopping; ask again, the new runner answers it", e.module, e.verb)
return fmt.Sprintf("%s's %s was not taken: the tool runner is stopping, and a call after its stop is answered nothing", e.module, e.verb)
}
// ErrorKind is the typed fault the call is answered with: stopping.
func (e *afterStop) ErrorKind() string { return ErrorKindStopping }
// Unanswered says the call is left without an answer, so its kept call asks again and meets the new runner.
func (e *afterStop) Unanswered() bool { return true }
// cutCall is a call the drain cut at its bound. Its caller is answered nothing, so it sees a transport fault (§813 (12)): the
// bus reads Unanswered and sends no reply.
@@ -60,7 +57,7 @@ func (e *cutCall) Error() string {
// Unanswered says the call is left without an answer, so its caller sees a transport fault.
func (e *cutCall) Unanswered() bool { return true }
// begin records an ask about to be made; once the runner drains it takes none, and its caller is answered stopping.
// begin records an ask about to be made; once the runner drains it takes none, and its caller is answered nothing.
func begin(module, verb string) (uint64, *inFlight, error) {
asks.mu.Lock()
defer asks.mu.Unlock()
@@ -86,7 +83,8 @@ func end(id uint64) {
}
}
// Drain is the runner's stop (design 47 H2 §813 (12), H-A-342 (2), H-A-353): from now on no new ask is made of any bundle, the
// Drain is the runner's stop (design 47 H2 §813 (12), H-A-342 (2), H-A-353), once it took down every subscription it answers
// calls on (the bus's StopAnswering, H-A-570 (1)): from now on no new ask is made of any bundle, the
// asks in flight are waited for within bound, and each still in flight at the bound is cut, with a journal line naming the
// bundle, the verb and the call's age; its caller is answered nothing. It returns once no ask is in flight or the bound
// passed; the runner then stops its bundles itself.