Skip to content

#473: a handover's exit is no crash: the host flushes its last status, main takes mawsd's verdict (wire minor 48) - #683

Merged
SSFSKIM merged 6 commits into
masterfrom
fix/473-handover-exit-verdict
Nov 15, 2026
Merged

SSFSKIM merged 6 commits into
masterfrom
fix/473-handover-exit-verdict

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Fixes board #473: an engine host's planned handover exit was counted as a crash. It flaked e2e/supervisor.spec.ts (f), "no unexpected exit": red 3 times in 7 days, the latest in run 43425585102 at :802/:794.

Diagnosis

The full timeline is in the diagnosis comment on #473. Of maws-24's 11-05 plan, nothing had landed: fix/473-handover-inflight holds no commit past master's 11-05 head. The 11-13 reading shows two paths.

  1. New: the host's last status died with the process, so mawsd misjudged too. In the failing attempt mawsd's own supervisor logged asked to hand over, is gone, then exited unexpectedly (code null), and so did the mini's 11-10 swap. The host publishes holder.detached (the evidence that it handed over) just before its exit order. Its exit order then ran socket.end() and proc.exit() at once. On macOS an AF_UNIX stream holds 8 KiB, so with mawsd behind on reading, the status was still queued in user space and was lost. A standalone experiment showed it: 22.8 KB written to a paused peer, then end() and exit(0); the peer received 7.6 KB, and the last line was not among it.
  2. maws-24's race: main's own verdict. mawsd's drain drops main's relayed link at its start. Main then looks at the gone pid 200 ms after its own close (38.305), ahead of mawsd's verdict (38.356). It hears holder.detached only if the word crosses the departing relay in time.

The test reads the right signal: lastExit is main's verdict, which the app shows. So this is a product fix.

Fix

  • Host: closeClient now settles once each closed client's socket has finished or ended, and the socket host's exit order waits for that, bounded by CLOSE_GRACE_MS (1 s), before proc.exit. Files: socket-host.ts, socket-server.ts, socket-port.ts.
  • mawsd: the host supervisor tells a drain's end with its verdict (onHandover's ended: the old incarnation, plus handed over or crashed mid-drain, from lost's evidence-based replace verdict). mawsd posts it as daemon.engineHandover's optional ended on the none that ends the drain. It also retells the state under way to a machine.sock client as that client says ready (maws-24's late-attach case).
  • Main: for a relayed engine host that is gone with no handover mark, while a drain was reported, main waits for that end report, up to HANDOVER_VERDICT_WAIT_MS (5 s). Handed over starts the successor with no count. Any of these is a crash, as before: crashed mid-drain, an end report naming another process, or no report in time (an older mawsd).
  • Wire: minor 48 (renumbered from 47 at the merge of master 93905c9, whose U11g took 47 for connectors.addJson) adds one optional field. The manifest is regenerated. The fingerprint doesn't cover machine events and is unchanged. Older peers read the field tolerantly (dropped), and both cross-build peers are green.

Red before green

  • src/shared/host/socket-host.test.ts (new): a real Unix socket with a client that has stopped reading. The exit must wait until what was written has left. It failed before the change (exit called at once) and passes after.
  • src/shared/host/host-supervisor.test.ts, "a relayed engine host gone while its relay drained it": it fails on master (main never waits, and the exit is counted) and passes here. Its cases: handed over gives no count; crashed or silent is counted; no drain is judged at once.
  • src/shared/host/detached-transport.test.ts: the drain's end is told with its verdict, both handed over and crashed mid-drain.
  • src/mawsd/engine-handover-event.test.ts covers ended and retell. src/main/hosts/engine-handover.test.ts covers verdict.

Runs

Runs of record, on the merged head 5c67bc9 (master 93905c9 plus this branch, wire minor 48):

Gates Run Conclusion
static, unit, probes, e2e:supervisor-daemon 43687773351 success
e2e:cross-build, --peer-exact f1852de3a 43687773661 success
e2e:cross-build, --peer-exact 2c7044231 43687773646 success

Earlier runs, before the merge:

  • 772c633: run 43682204667. e2e:supervisor-daemon, unit and probes green; static red on 2 type errors (fixed). Cross-build runs 43682228421 (f1852de) and 43682226946 (2c70442), both green.
  • f94929c: run 43683670700. e2e:supervisor-daemon, unit and probes green; static red on 1 type error in a test fake (fixed).
  • 315709e: run 43685368361. Static and probes green; unit 1/4 red on Composer.test.tsx's menu chords, which this branch doesn't touch (logged in the tracker). Unit rerun 43686314363: green.

Review

doperpowers:reviewer-high, lens "handover and exit-verdict races between mawsd, the supervisor and main", on 1ce09aa61..772c633cc: no material findings, verdict correct. The commits since then are type fixes only.

Not verified

  • Whether (f) stops flaking: one green e2e:supervisor-daemon run per head can't prove a 3-in-7-days flake is gone. Tracker row (29) stays until it has been quiet for a while.
  • A real swap on the MacBook or the mini.
  • The macOS 8 KiB loss inside a real engine-host exit: it is shown by the standalone experiment and the unit test, not reproduced in the e2e.

Also logged in the tracker: detached-transport.test.ts:660 flakes locally on master at a load near 55 (2 red in 5 runs), unchanged by this branch.

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)

… sockets

The engine host's exit order closed its client and exited at once, so
whatever the kernel had not yet taken from a slow reader's socket died
with the process: on macOS an AF_UNIX stream holds 8 KiB, and the
handover's last status (holder.detached, the evidence it handed over)
is written just before the exit. mawsd then read the planned exit as a
crash (run 43425585102: 'asked to hand over, is gone', then 'exited
unexpectedly'). closeClient now settles once each closed client's
socket has finished or ended, and the exit order waits for it within
CLOSE_GRACE_MS. socket-host.test.ts fails before the change (the exit
came while the client had taken nothing) and passes after.

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
… wire minor 47

On the daemon shape mawsd's drain drops main's relayed link before the
old host can say it handed over, and main's own look at the gone pid
(200 ms after its close) comes ahead of mawsd's verdict. So main read a
quick handover as a crash whenever the holder.detached word did not
cross the departing relay in time (maws-24's diagnosis of 11-05, never
landed).

- The host supervisor tells a drain's end with its verdict
  (onHandover's ended: the old incarnation, handed over or crashed
  mid-drain, lost's replace verdict on the evidence).
- mawsd posts it as daemon.engineHandover's ended on the none that ends
  the drain, and retells the state under way to a machine.sock client
  as it says ready.
- Main, for a relayed engine host gone with no mark while a drain was
  reported, waits for that end report (HANDOVER_VERDICT_WAIT_MS, 5 s):
  handed over starts the successor with no count; crashed mid-drain, an
  end report naming another process, or none in time is a crash, as
  before.
- WIRE_MINOR 47 (one optional field), the manifest regenerated; the
  fingerprint does not cover machine events and is unchanged.

Red first: host-supervisor.test.ts's relayed scene fails on master
(main never waits; the exit is counted), and passes here.

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…t host test's lock names

Class 1a on 772c633 (run 43682204667) found two type errors: the
replace branch tested a copy, so loss.crash no longer narrowed below
it, and the test's files named breakLock where LockNames has breaker.

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
Class 1a on f94929c (run 43683670700): the fake typed as
EngineHandoverWatch lacked the new member.

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T06:53:22.860986Z 02a7ba8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…erdict; #473's wire change renumbered to minor 48

U11g took WIRE_MINOR 47 (connectors.addJson). Only wire.ts conflicted:
U11g's (47) entry is kept, and #473's daemon.engineHandover ended is
appended as (48). The manifest was reset to master's minor 47 and
regenerated with pnpm wire:manifest's two files, so it records the one
additive entry at 48. The fingerprint is unchanged (machine events
are outside it).

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
@SSFSKIM SSFSKIM changed the title #473: a handover's exit is no crash: the host flushes its last status, main takes mawsd's verdict (wire minor 47) #473: a handover's exit is no crash: the host flushes its last status, main takes mawsd's verdict (wire minor 48) Nov 15, 2026
@SSFSKIM
SSFSKIM merged commit 63c97b5 into master Nov 15, 2026
@SSFSKIM
SSFSKIM deleted the fix/473-handover-exit-verdict branch November 15, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant