From 858beb2b63b52dcc6126b199d5c4daad23b237d2 Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 21 Nov 2026 23:57:07 +0100 Subject: [PATCH] T2 amendment: a call after the stop began is answered nothing, never refused MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A refusal would end the caller's kept call; left unanswered, the kept call paces and meets the new runner. The ask made once the drain began ends Unanswered, so the bus sends its caller nothing. Builds: design 47 H2 §813 (12), H-A-369 --- .../cmd/node-tools/whole_integration_test.go | 10 ++++++---- node-tools/internal/launch/drain.go | 16 ++++++++++++---- node-tools/internal/launch/drain_test.go | 10 ++++++---- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/node-tools/cmd/node-tools/whole_integration_test.go b/node-tools/cmd/node-tools/whole_integration_test.go index dfeee5a..f020023 100644 --- a/node-tools/cmd/node-tools/whole_integration_test.go +++ b/node-tools/cmd/node-tools/whole_integration_test.go @@ -180,7 +180,7 @@ func TestTheToolRunnerStartedByItsEntryServesABundleOverTheSeatListItReads(t *te mu.Unlock() // at its stop the runner drains (design 47 H2 §813 (12), H-A-353; the bound 2 s here for the setting's 30 s): a call of 1 s in - // flight is answered, one of 6 s is cut at the bound, said, and its caller answered nothing; a call after the stop is refused + // flight is answered, one of 6 s is cut at the bound, said, and its caller answered nothing; a call after the stop is answered nothing type answer struct { got string err error @@ -202,10 +202,12 @@ func TestTheToolRunnerStartedByItsEntryServesABundleOverTheSeatListItReads(t *te return nil }) stop() + // a call after the stop began is answered nothing, never refused, so the caller's kept call paces and meets the new runner + // (H-A-369): until the drain began it is still answered mt.Until(t, func() error { - _, err := ask("ledger.who") - if err == nil || !strings.Contains(err.Error(), "takes no new call") { - return fmt.Errorf("a call after the stop was answered %v, want it refused", err) + answered, err := asker.AskWithin("ledger.who", map[string]any{}, "", 500*time.Millisecond) + if err == nil || err.Error() != "timeout" { + return fmt.Errorf("a call after the stop was answered %s, %v; want no answer", answered.Result, err) } return nil }) diff --git a/node-tools/internal/launch/drain.go b/node-tools/internal/launch/drain.go index 2eb4b8a..abcec58 100644 --- a/node-tools/internal/launch/drain.go +++ b/node-tools/internal/launch/drain.go @@ -30,8 +30,16 @@ var asks = struct { ended chan struct{} }{of: map[uint64]*inFlight{}} -// errStopping is an ask made after the stop: refused, the call made after the stop is not taken (§813 (12)). -var errStopping = &Refused{Method: "", Message: "the tool runner is stopping: it takes no new call (design 47 H2 §813 (12))"} +// afterStop is an ask made after the stop began: 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 amends it). +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, and a call after its stop is answered nothing", e.module, e.verb) +} + +// 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. @@ -44,12 +52,12 @@ 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, or refuses it once the runner drains. +// 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() if asks.draining { - return 0, nil, errStopping + return 0, nil, &afterStop{module: module, verb: verb} } asks.next++ f := &inFlight{module: module, verb: verb, at: time.Now(), cut: make(chan struct{})} diff --git a/node-tools/internal/launch/drain_test.go b/node-tools/internal/launch/drain_test.go index dcee2b2..06e82bb 100644 --- a/node-tools/internal/launch/drain_test.go +++ b/node-tools/internal/launch/drain_test.go @@ -27,7 +27,8 @@ while IFS= read -r line; do done ` -// **The tool runner drains at a stop** (design 47 H2 §813 (12), H-A-342 (2), H-A-353): once it drains, no new call is taken; 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 // 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 TestTheToolRunnerDrainsItsCallsInFlightAtAStop(t *testing.T) { @@ -36,7 +37,7 @@ func TestTheToolRunnerDrainsItsCallsInFlightAtAStop(t *testing.T) { bound time.Duration release bool }{ - {"a call that ends within the bound is answered, and a call after the stop is refused", 10 * time.Second, true}, + {"a call that ends within the bound is answered, and a call after the stop is answered nothing", 10 * time.Second, true}, {"a call that outlives the bound is cut and said", 50 * time.Millisecond, false}, } { t.Run(row.name, func(t *testing.T) { @@ -93,8 +94,9 @@ func TestTheToolRunnerDrainsItsCallsInFlightAtAStop(t *testing.T) { } } if row.release { - if _, err := run("", json.RawMessage(`{}`)); err == nil || !strings.Contains(err.Error(), "takes no new call") { - t.Errorf("a call made after the stop was answered %v, want it refused", err) + 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) } f, err := os.OpenFile(hold, os.O_WRONLY, 0) if err != nil {