Repository navigation
Description
Cites: P5 composite docs/doperpowers/plans/2026-10-27-p5-org.md, child O16 (the engine host's handover, M3/M3b/M3c).
What happens
On an update with a session live, the old engine host hands its session over and exits (exiting (handover)), and the successor adopts it. If main has a host.interest call in flight to the old host at that moment, main logs [sessions] host.interest failed … engine-host disconnected before answering host.interest and then [hosts] engine-host exited unexpectedly (code null). So the handover's planned exit is counted as a crash: lastExit is set, it is entered in the crash window, and the app may say so.
Seen once: e2e/supervisor.spec.ts:847 case (f), first attempt, failing at :859 ('no unexpected exit'), green on retry. Run 41960398446 (O7 M9's final gate, 2026-11-05 03:56Z, tree 4899a282f). M9 does not reach this path. The host log has handover armed: 1 hosted rows frozen, 0 calls in flight and exiting (handover), and adoption: 1 of 1 … adopted. So the host-side handover is correct, and the defect is in how main classifies the exit.
Where
src/shared/host/host-supervisor.ts: exited() (:925) and the detached transport's :696) both log "exited unexpectedly". Find which path a handover exit takes when a request was pending on the transport, and why the handover's expected-exit state is not applied there. Likely an ordering issue: the pending call's disconnect is processed before the handover cause is recorded.unexpected (
Acceptance
- A handover exit is never classified unexpected, whatever main has in flight to the old host at the time. The pending call is held and re-sent to the successor, or fails as
host_unavailablewithout counting as an exit. - Red first: a unit test in the host supervisor's test file that holds a
host.interest(or any) request in flight while the host reports its handover and exits. It must fail on master and pass after. e2e/supervisor.spec.ts(f) stays green, and there is no new flaky signature ine2e:supervisor-daemon.
Not in scope: changes to the handover protocol itself (M3c's D63 first-quiet-report rule stands).
Activity
SSFSKIM commentedon Nov 5, 2026
Diagnosis (maws-24): the in-flight call is incidental; the cause is the daemon shape's relay dropping main before the handover
Read from run 41960398446's artifacts (
e2e-supervisor-daemon, case (f) first attempt vs-retry1).The failure is on the daemon shape, and main's
host.interestfailure is a symptom of its link closing, not the cause. Timeline (mawsd log, main stdout/stderr):engine-host.sockis welcomed: main is served old host pid 9237 through the relaydrain():setHandover(draining)(posted on machine.sock), thentransition(restarting)daemon.ts:874→engineRelay.dropApp('the engine host is restarting'): main's engine-host link is closed with no reason on the wiredrainingpost; the next resend would come 5 s later, and the drain is over by thenexiting (handover)closed()(exitAsked null) looks at the pid onePID_POLL_MS(200 ms) after the close: gone →lost({crash})→unexpected→lastExitsetMain has no evidence of the handover at its verdict:
holder.detachedstatus goes out on mawsd's draining link, and mawsd relays engine-host events only to the attached app, whose link is already dropped, sohandedOverin main'shost-supervisor.tsis never marked;daemon.engineHandover'sdrainingwas posted before main's machine link was up, andhandingOverAtfeeds only the start budget anyway.The retry passed only because main's first hello reached mawsd after the handover was finished. Main never had a welcomed link to 9237, so it never had a verdict to make. In general, on the daemon shape, a quick handover (0 calls in flight, the common case) is read as a crash whenever main is attached when mawsd asks: the old pid dies about 30 ms after the drop, well inside main's 200 ms look. Deferred handovers escape it because the old pid is still alive at the look (
quiet).Proposed fix (needs a call from O16's owner: it touches the
daemon.engineHandoverreport)daemon.engineHandovernames the old host's incarnation and mawsd's own evidence-based verdict (theplannedit already computes inlost'sreplacebranch). It also posts the current state to each machine.sock client as it attaches, not only at changes and every 5 s.ENGINE_HANDOVER_FRESH_MS, before judging. Handed over is read asreplace/planned, so the successor starts with no crash count. Crashed mid-drain is read as a crash, as before. This keeps the wave-2 rule that the verdict rests on evidence, not intent.The issue's acceptance criteria still hold. The one exception is "Red first … a
host.interestrequest in flight": the in-flight request isn't needed to reproduce the bug.SSFSKIM commentedon Nov 5, 2026
[board] in-progress: maws-24 implementing the re-diagnosed fix (mawsd end-report verdict + main defers relayed gone-pid verdict); O16 owner approved
SSFSKIM commentedon Nov 10, 2026
Sighting at the mini's swap to cf30daf (2026-11-10, reported by mini-ops): one 'error: [hosts] engine-host exited unexpectedly (code null)' at 01:07:08.212Z, 5 ms after the old supervisor (asked to hand over, 6 live) was logged gone; the successor came up 1.2 s later with all 6 sessions live. The mini's 1-minute load was 40.7. It reads as this ticket's mislabelled planned exit. The MacBook and dc-linux171-1e68 swaps at the same master logged no error.
SSFSKIM commentedon Nov 15, 2026
Diagnosis of the 11-13 reading (run 43425585102): a second path, and maws-24's race still open on master
What of maws-24's plan landed: nothing.
fix/473-handover-inflighthas no commit beyond master's 11-05 head (01c0b239c, an ancestor of master), no PR was opened from it, anddaemon.engineHandoveron master still carries only{state, inFlight, tool?, at}: no end report, and main has no deferred verdict. PR #490 is a tracker-row update and #650 (U9) only cites this ticket.The case. The 11-13 red is
(f) … an update waits for a running tool call(e2e/supervisor.spec.ts:802), the deferred update. maws-24 thought a deferred handover escapes because the old pid still lives at main's look. Here it doesn't escape: the hold ends, the next status is quiet, and the drain runs at once with 0 calls in flight.Timeline (failing attempt;
scratch-mawsd.log,scratch-host.log, main's stdout and stderr, all on one clock):engine-host pid 20112, of another build, is quiet; asking it to hand its sessions overengine-host.sock: closing the app's connection: the engine host is restartingasking supervisor pid 20112 to hand its sessions overhandover armed: 2 hosted rows frozen, 0 calls in flightdetached (handover);Supervision'sdetachedcallback publishes the status withholder.detached: trueexiting (handover)engine-host.sock: client disconnected(main's side of the relay has ended)is handing its sessions over; its successor follows its exit: it read the host's answer about 50 ms after the host wrote it, so mawsd was slow to readlastExit.at: main's own verdict, its transport's 200 ms look after its relay closed ([hosts] engine-host exited unexpectedly (code null)in main's stderr; noleft after handing its sessions overline)supervisor pid 20112, asked to hand over, is gone; starting its successor, thenerror: [hosts] engine-host exited unexpectedly (code null)The retry's main logs
engine-host pid 21379 left after handing its sessions over; starting its successor.Path 1 (new): the host's last status dies with the process, so mawsd misjudges too. mawsd's own supervisor counted the exit as a crash. maws-24's 11-05 run didn't show that line, and the 11-10 mini sighting does ("5 ms after the old supervisor (asked to hand over, 6 live) was logged gone"). In
lost's replace branch, the exit had code null and no signal, and mawsd's drain link heard the host's events (drainHears: an app was streaming). So the only way to read it as planned is theholder.detachedmark. That status was published at 38.102 and never reached mawsd. The cause is the host's exit order (socket-host.tsstop):clients.closeClient()callssocket.end(), and thenproc.exit(code)runs at once. Whatever the kernel has not yet taken from the socket's user-space write queue is lost with the process. On macOS an AF_UNIX stream holds 8 KiB (net.local.stream.sendspace: 8192), and the freeze, the detaches and their statuses add up to more than that while mawsd is behind on reading. A standalone experiment showed it: a server writes 22.8 KB plus one last line to a client that has paused, then callsend()andprocess.exit(0). The client received 7.6 KB, and the last line was not among it. Main gets the mark only from mawsd's relay, so this path breaks main's verdict as well.Path 2 (maws-24's, still open): main's verdict on the relayed shape is a race even when mawsd hears the mark. Main's relayed link was dropped at 38.064 and its side ended at 38.113, before the host even froze. Main hears
holder.detachedonly through the departing relay, and only if mawsd reads it before main's side ends. Main then judges 200 ms after its own close (38.305), not after mawsd's verdict (38.356). In the retry the mark crossed in time. Here it could not have. Fixing path 1 alone leaves (f) flaky.The test reads the right signal.
lastExitis main's verdict, which the app shows. So this is a product fix:proc.exit, so the evidence the drain published reaches mawsd.daemon.engineHandover's end report (none) names the drained host's incarnation and mawsd's evidence-based verdict (lost'splanned). mawsd also tells the current state to a machine.sock client when it says ready, not only at changes and every 5 s (maws-24's late-attach case). This is a wire minor.mawsdthat sends no end report keeps today's verdict once the bound runs out.#473 (3): typecheck: lost narrows on the loss itself again; the socke…
#473 (4): typecheck: status.test's watch fake carries verdict
Tracker: the Composer menu-chord unit flake seen on #473's head
SSFSKIM commentedon Nov 15, 2026
[board] in-review: two paths fixed: host flushes its last status before exit; main waits for mawsd's end-report verdict (wire minor 47); gates green, review clean
Merge origin/master (93905c9, U11g #684) into fix/473-handover-exit-v…
Merge PR #683: #473, an engine host's handover exit is no longer coun…
SSFSKIM commentedon Nov 15, 2026
[board] done: Landed by PR #683, merge 63c97b5. Row (29) case (f) stays open until it stops flaking.