T2 drain at stop: finish the calls in flight within the drain bound, cut and say past it

Once told to stop, the tool runner makes no new ask of a bundle (a call after the stop is refused),
waits for the asks in flight within the drain bound (30 s by default), cuts each still in flight at
the bound with a journal line naming the bundle, the verb and the call's age, leaves its caller
unanswered (a transport fault), and only then stops its bundles itself.

Builds: design 47 H2 §813 (12), H-A-342 (2), H-A-353
This commit is contained in:
2026-11-21 23:11:38 +01:00
parent 02675a43ea
commit f7269d9812
7 changed files with 374 additions and 13 deletions
+17
View File
@@ -890,6 +890,18 @@ func Start(module, entry string, env []string, mesh Bus, logf func(string, ...an
}
func (c *child) ask(module, method string, params any, timeout time.Duration) (json.RawMessage, error) {
// Counted for the drain at a stop, and refused once it began (design 47 H2 §813 (12)).
verb := method
if p, ok := params.(map[string]any); ok && method == "tools/call" {
if name, ok := p["name"].(string); ok {
verb = name
}
}
asked, flight, err := begin(module, verb)
if err != nil {
return nil, err
}
defer end(asked)
c.mu.Lock()
if c.why != nil {
c.mu.Unlock()
@@ -925,6 +937,11 @@ func (c *child) ask(module, method string, params any, timeout time.Duration) (j
return m.Result, nil
case <-c.dead:
return nil, c.deathReason()
case <-flight.cut:
c.mu.Lock()
delete(c.pending, id)
c.mu.Unlock()
return nil, &cutCall{module: module, verb: verb}
case <-timer.C:
c.mu.Lock()
delete(c.pending, id)