Repository navigation
Closed
Labels
kind/infrastructureInfrastructure / host-portability workInfrastructure / host-portability workpriority/highImportant and time-sensitiveImportant and time-sensitive
Description
Defect: laptop-agent broker — no singleton across two implementations + silent CONNECT-pool wedge (two fleet-blind episodes, 2026-11-13)
Lineage: broker built under #5343 (laptop-agent design, closed). This issue is the broker-reliability defect record; #5343's scope (the daemon design) does not cover it.
All times CST (UTC−6); Z = UTC. Sandbox↔laptop traffic rides the session proxy (HTTP CONNECT) to the laptop tailnet IP 100.99.113.103; the broker listens on the unix socket ~/.cache/laptop-agent/broker.sock and pools CONNECT tunnels to the laptop agent on :4799.
Episode 1 — duplicate brokers + ensure churn (~16:43–17:27 CST)
~/.cache/laptop-agent/broker.logshows interleaved starts of two implementations on the same socket path all afternoon: the Python broker (laptop-agent broker on .../broker.sock, untimestamped lines) and the Rust fleet proxy (fleet proxy serve start implementation=fleet-proxy version=0.1.0 pool_size=50, pids 31923 @22:43:42Z, 39880 @22:55:22Z, 42268 @22:59:29Z), plus repeated tracebacks fromlaptop-agent-broker.pymain():OSError: [Errno 98] Address already in use.- Two Python broker processes ended up LISTENing on the socket simultaneously. Diagnosis at the time isolated the fault to the broker layer: a broker-bypass health call to the laptop succeeded while brokered calls failed.
- Fix applied ~17:27 CST: killed both brokers; a single broker (pid 19044) respawned; round-trip verified in 0.9s.
Episode 2 — single broker, silently wedged pool (from ~17:36 CST; fleet blind from ~17:48 CST)
- The broker that held the socket from 23:36:01Z (pid 25276, Python) was the sole listener (verified via
ss -xlpn: one listener, fd 3;broker.pidmatched) — this is not the duplicate condition. - It was nonetheless dead in place: 2 threads, zero outbound TCP tunnels (a healthy broker holds a keep-alive pool), and broker.log received no writes after its start (log mtime 23:36:02Z) — a ≥20-minute total silence during the wedge.
- Clients hung, not errored:
laptop-agent.py healthblocked insidetunnel_socket()atsock.recv(1)for the full client timeout (live repro 17:57 CST: 25.0s,CallTimeout). Observed failures: the 17:48 CST activity-refresh probe ("laptop-agent: proxy closed during CONNECT"), a direct probe at 17:54 CST (25.4s), and the 17:57 CST repro. A fleet worker's own note from the window reads "tunnel down since ~23:37Z", corroborating onset within a minute of this broker's start. - The log also contains an earlier uncaught
BlockingIOError: [Errno 11] Resource temporarily unavailabletraceback in the broker'sread_msg(laptop-agent-broker.py lines 216/238) — a plausible handler-thread-killing mechanism for the silent wedge. - The fleet queue was already in GitHub-comments fallback mode by 23:56Z ("queue backend is down"), i.e. the blind spot propagated beyond quota/supervision.
Remediation attempt — restart does not restore service (17:58 CST → 19:46 CST)
- 23:58Z: killed pid 25276; a fresh Python broker (pid 40681) auto-respawned and failed identically (24.8s, "proxy closed during CONNECT"). A broker-bypass direct CONNECT health call also failed (8.4s) — by then the refusal had moved to / was also present in the shared CONNECT leg.
- The sandbox VM recycled ~00:05–00:15Z. Post-recycle, a Python broker (pid 2704, 01:11:49Z) briefly owned the socket, after which
fleet proxy serve(pid 7861, started 01:18:01Z) took over the same socket path — andbroker.piddid not match the actual socket owner. - The fleet proxy fails fast and explicitly (better posture):
HTTP 502: broker: tunnel recovery for port 4799 still in flight; failing fast, thenHTTP 502: broker: tunnel to 100.99.113.103:4799: Resource temporarily unavailable (os error 11)— but its tunnel recovery cannot complete. - Raw CONNECT probe at 01:43Z (bypassing all broker code): the session proxy hung ≥15s with no response to
CONNECT 100.99.113.103:4799and closed instantly with an empty response toCONNECT 100.99.113.103:22, while general HTTPS egress through the same proxy answered GitHub in 1.4s. So at the tail of episode 2 the proxy↔DERP↔laptop leg itself refuses/hangs CONNECTs to the laptop on both ports. - As of 19:46 CST (01:46Z)
laptop-agent.py healthstill fails; the documented sandbox-side restart has been applied (wedged broker killed; successors respawned) but service is not restored, because the current blocker is upstream of any broker process.
Layer evidence summary
- Sandbox egress: healthy (GitHub via the same proxy, 1.4s).
- Laptop: healthy during episode 1 diagnosis (broker-bypass health call succeeded); unreachable by any sandbox path during episode 2's tail (both ports, raw CONNECT).
- Broker layer: at fault in episode 1 (duplicates) and at onset of episode 2 (silent single-broker wedge); not the current blocker at the tail of episode 2.
Acceptance
- Singleton across implementations. Exactly one process may own
broker.sock, whether the Python broker orfleet proxy serveprovides it. Concurrent ensure/start invocations from both implementations converge on one owner (no Errno 98 churn, no silent takeover);broker.pidalways names the socket owner (checkable againstss). Backed by a regression test or a documented invariant. (Two auto-started implementations racing for one socket path is the root architectural smell — pick one owner for the path, or partition the paths.) - Wedged-pool self-detection. A broker whose tunnel pool is empty/dead and cannot complete a CONNECT within a bounded time must log loudly, rebuild the pool or respawn, and fail clients fast (<5s) with an explicit error — never accept a client connection and hang it for 25s+ in silence. The Python broker logged nothing for the entire episode-2 wedge; fleet proxy's fail-fast 502s are the behavioral floor.
- Handler robustness. Uncaught
BlockingIOErrorin the request path (read_msg) must not silently kill request handling. - Log observability. Every broker log line carries a timestamp (Python broker lines currently have none), and tunnel death/recovery events are logged as they happen, so the next episode is diagnosable from the log alone.
Fleet impact
Quota refresh and summit supervision were blind from ~17:48 CST until at least 19:46 CST (episode 2), on top of the episode-1 window earlier in the afternoon. Restart-alone is proven insufficient as the runbook fix: it cured episode 1 and did nothing for episode 2.
Metadata
Metadata
Assignees
Labels
kind/infrastructureInfrastructure / host-portability workInfrastructure / host-portability workpriority/highImportant and time-sensitiveImportant and time-sensitive
Activity
dezren39 commentedon Nov 14, 2026
Downtime-investigation update (2026-11-14, Drew's order "fix why website keep go down"):
Current state verified live 2026-11-14 ~08:55Z: exactly ONE broker owns ~/.cache/laptop-agent/broker.sock - the Python broker, pid 1804; broker.pid = 1804 matches the socket owner in ss; no fleet-proxy process running; laptop-agent health round-trip 0.49s. The defect is latent right now, not active.
Still unmet, from the live tree/log:
This fix was also not in the fleet queue: no task referenced this issue (checked the queue DB by dedupe_key, title, and body on 2026-11-14). It is now queued: task 16540 (queue code-pilot, priority 20, dedupe fix-9611-broker-singleton-failfast) with the four acceptance criteria as its brief. Label queue/queued added.
dezren39 commentedon Nov 14, 2026
🤖 Agent note · partial fix landed (code), remainder parked
~/tools/laptop-agent-broker.py(takes effect on the next broker start — deliberately NOT restarted mid-shift); item 2 and the fleet-proxy leg of item 1 remain, with the activation/verification stepWhat this claim changed (file:
~/tools/laptop-agent-broker.py, sandbox tools)Verified:
python3 -m py_compilepasses; the currently running broker still serves normally (it runs its already-loaded copy — no restart was performed, so the fleet's laptop path was never put at risk by this change).Handler.handlenow wrapsread_msg(...)inexcept (BlockingIOError, OSError): return. The uncaught traceback in the log came from the inflight watchdog togglingsetblocking()on the client socket while the handler was receiving; a racingrecvraisedBlockingIOErrorstraight out of the handler. It now ends the handler quietly.log()helper prefixes every line with a UTC timestamp. Wired into: the startup line (now… laptop-agent broker: on <sock> pid=<pid>), every failed request attempt indo_request(tunnel death, as it happens, with "connection dropped, not repooled"), and keepalive health transitions (failure logged once with the error, recovery logged on the next success — previously keepalive failures were swallowed byexcept: pass, which is why episode 2's wedge logged nothing).main()now takes an exclusive non-blockingflockon~/.cache/laptop-agent/broker.lockbefore touching the socket and holds it for the process lifetime; a second Python start exits quietly instead of racing the probe-and-unlink path that produced the Errno 98 churn. The flock auto-releases on holder death, so a crashed broker cannot wedge the path. Also,broker.pidis now written only after the server socket is bound, so it names the actual owner.What remains (task 16540 parked for this)
fleet proxy servedoes not takebroker.lock. Either it must honor the same lock file before bindingbroker.sock, or the two implementations' socket paths must be partitioned. That is apkgs/fleetchange plus a coordinated rollout — not safely done from a queue claim on the live path.broker.pidmatchesss -xlpn's socket owner; a secondlaptop-agent-broker.pystart exits quietly while the first holds the lock; noBlockingIOErrortraceback appears inbroker.logunder load.dezren39 commentedon Nov 14, 2026
🤖 Agent note · parked — remainder is coordinated infra work, not a lane slice
~/tools/laptop-agent-broker.py(py_compile verified), deliberately not activated — the running broker still serves its already-loaded copy and no restart was performed mid-shift.dezren39 commentedon Nov 14, 2026
🤖 Agent note · all four acceptance legs addressed (task 16540)
~/tools/laptop-agent-broker.py(flock onbroker.lock,broker.pidwritten only by the socket owner) and is live. The missing fleet-proxy leg is PR fix(fleet-proxy): broker singleton lock + broker.pid ownership (#9611) #10056:fleet proxy servenow takes the samebroker.lockflock before probe/bind (converges with a log line + exit 0 when another implementation holds it) and writesbroker.pidafter binding, so the pid file names the owner whichever implementation it is. New unit test covers flock exclusivity;cargo test -p fleet-proxy --lib90/90 pass.sys.exitinside broker threads — a BaseException that bypassed every guard, the episode-2 wedge shape). Newbroker_tunnel_socket: broker-local CONNECT with a hard 5 s cap (LAPTOP_AGENT_TUNNEL_TIMEOUT), ordinaryOSErrors, credential only inside the CONNECT request as before. Connection acquisition moved insidedo_request's try, and a retry now happens only for a stale pooled connection — a fresh-tunnel failure fails the client immediately with a logged 502. Isolated test (dead proxy): 502 in 0.0 s, one attempt, timestamped log. The Rust broker already failed fast (its 502 posture is documented on this issue).BlockingIOErrorguard stands; acquisition-in-try removes the remaining uncaught-failure path out ofdo_request.~/.cache/laptop-agent/broker.logthroughout today, including this shift's 14:09Z and 14:27Z tunnel drops).broker.pid== 497014 (checked againstss -xlpn), client round-trip 0.46 s,fleet queue healthflowing through it. A duplicate-start test in an isolated HOME exits 0 quietly (singleton convergence).Merge pull request #10056 from developing-today/queue/16540-9611-brok…
dezren39 commentedon Nov 15, 2026
Acceptance follow-through (read-only): #10056 merged as
32dc1f922a0c31e4b84177298c4dc2647fb624bf. The existing acceptance note verifies the Python leg live and explicitly leaves Rust release/activation outstanding. A healthy transport probe cannot identify the socket owner or prove which Rust build is available to start. During the existing coordinated release, please attach the installed Fleet build/source receipt containing this commit and the isolated Python↔Rust shared-lock/PID-ownership result; no live duplicate start, restart, or reopening requested here.