Close retired RPC connections after draining replies

Merged
AN
8h ago
+205-3

Close retired RPC connections after draining replies. Worker delivery rebased onto main; see the commit messages.


Summary by cubic

Fixes a stale-connection race where the OpenCode TUI's /claude menu briefly errored with "unauthorized" or a dropped connection after a plugin reload.

  • Stop now marks draining responses Connection: close and destroys all remaining owned sockets after replies drain.
  • The connection-pool opt-out (keepalive) is preserved through the loopback network guard and across redirects.
  • Adds deterministic tests for stop draining and pool opt-out preservation.