T2 amendment: a call after the stop began is answered nothing, never refused

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
This commit is contained in:
2026-11-21 23:57:07 +01:00
parent 07ebeae74d
commit 858beb2b63
3 changed files with 24 additions and 12 deletions
+12 -4
View File
@@ -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{})}
+6 -4
View File
@@ -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 {