Skip to content

Hosted-Mac flakes: O17 headless scenes 3 and 4 wait for MAWS's hello; E8 Stop's group probe reads macOS EPERM as still there - #510

Merged
SSFSKIM merged 4 commits into
masterfrom
fix/hosted-flakes-1107
Nov 7, 2026
Merged

SSFSKIM merged 4 commits into
masterfrom
fix/hosted-flakes-1107

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Fixes two hosted-Mac e2e flakes that CI-opt flagged past three sightings in seven days. Both causes were in the tests; the product code is unchanged.

(a) e2e/browser-cua.spec.ts:997 and :1028: O17 headless scenes 3 and 4, "not connected" at 0 ms

Cause. "not connected" is the stub cua host's own answer (test/support/cua-connector.mjs) to a request that arrives before it has heard MAWS's hello. scene.connector() (e2e/support/headless-browser.ts) returned as soon as the stub's control socket accepted. That socket starts listening as the stub dials MAWS, 1 to 5 ms before the hello. The session's first turn can end just as the connector boots, and the scene's start path returns at that moment, so the scene's first windows.query could beat the hello.

Evidence. Diagnostic run 42330414350 instrumented the stub, the engine stub and mawsd's cua path (a scratch commit, not on this branch). It recorded 22 first connections:

  • mawsd's cold socket listened 78 to 133 ms before the connector's first dial, and no dial was refused;
  • MAWS greeted 1 to 4 ms after the dial, the broker chunk's first load included;
  • in scene 3 the start returned 11 ms after the hello, one first-turn jitter away from the window.

Not a product race. MAWS is ready before cua dials and greets at once. Real cua's first browser call already waits for MAWS's hello: cua/src/mcp/connection.mjs's lazy start awaits waitForHellos(), bounded by HELLO_WAIT_MS. The stub did not model that wait, and the scene now does it.

Fix. The stub reports greeted (MAWS's hello heard on the current connection), and scene.connector() waits for it. This also covers the other call sites that drove cua at once (scenes 5, 6 and 8; render-host's and daemon-idle's scenes). Scene 8's symlinked render-directory case could previously pass on a not connected failure rather than the product's own refusal.

Reproduction. test/support/cua-engine.test.ts adds a backend that holds its hello. Driven through its control socket while connected is already true, the stub fails cua's creation sequence not connected at windows.query, which is the e2e's error. It succeeds once greeted is set.

(b) e2e/widgets.spec.ts:1106: E8 Stop on a CLI that ignores SIGTERM, kill EPERM

Cause. The spec's probe process.kill(-pgid, 0) rethrew anything but ESRCH. It threw inside the post-SIGKILL expect.poll, and Playwright's poll does not retry a throwing generator. On macOS, a group whose processes are dead but not yet reaped answers EPERM, not ESRCH. XNU's killpg1 (bsd/kern/kern_sig.c) finds the group, its iterate filter skips SZOMB members, and nfound == 0 returns posix ? EPERM : ESRCH. The CLI stays a zombie until the engine host reaps it, so a poll landing between the SIGKILL and the reap failed.

Evidence.

  • All three stacks fail at the post-SIGKILL poll.
  • A local probe on Darwin 25.6 read EPERM while the killed leader was unreaped (ps -g showed it in state Z) and ESRCH after the reap.

Product. The kill path in src/engine-host/plugins/runner.ts (hasMembers) already reads EPERM as members left, waiting up to REAP_GIVE_UP_MS. It was right and is unchanged.

Fix. test/support/process-group.ts reads EPERM as "still there" (ESRCH is still the only "gone"). The spec and plugin-cli-stub.test.ts use it.

Reproduction. test/support/process-group.test.ts (darwin-guarded, so unit:darwin runs it) holds the killed group unreaped. With the old probe it failed with Error: kill EPERM at the same call. It passes with the fix.

Repeated runs (no --repeat-each route exists in scripts/ci-gate.sh or gate.yml, so each gate ran separately)

group runs head flaky
e2e:browser-cua 42331497973, 42331519512, 42331547359 3e9fa99 0, 0, 0 (21 passed each; scenes 3 and 4 first try)
e2e:browser-cua 42332043727 0ac8292 0
e2e:browser-cua 42335748298 23ee350 (this head) 0
e2e:widgets 42330639321, 42330639084 8e27ab7 (cba81a8's tree before tsconfig.e2e.json gained the probe; Playwright does not typecheck) 0, 0 (29 passed each; E8 Stop first try)
e2e:widgets 42332043727 0ac8292 0
e2e:widgets 42333781636 23ee350 (this head) 0

Five browser-cua runs and four widgets runs, with no recurrence and no flaky pass in any job.

Gates

  • Static, 42330639591 on 8e27ab7: red with TS6307 (test/support/process-group.ts was missing from tsconfig.e2e.json). Fixed and folded into cba81a8.
  • Static, 42331053337 on 3e9fa99: green.
  • static, unit (4 shards), unit:darwin, probes, e2e:browser-cua, e2e:widgets, e2e:render-host, 42332043727 on 0ac8292: green in every job, 0 flaky. unit:darwin ran process-group.test.ts.
  • Static, 42332366992 on 23ee350 (docs only after 0ac8292): green.
  • Not --gates all: the change touches no main process, renderer or engine host code.

Review

  • Round 1, reviewer-medium on 6e92927..3e9fa99: one should-fix. The darwin unit case asserted EPERM from one snapshot 200 ms after SIGKILL, which a busy runner could beat. A fix-wave worker made it poll while blocked (0ac8292).
  • Round 2, reviewer-medium on 3e9fa99..0ac8292: no material findings.

Residue

  • The new test's 5 s wait cap is no extra headroom, since vitest's default per-test timeout is also 5 s. Either way it fails loudly; left as is.
  • e2e:daemon-idle (a measured group) calls scene.connector() too, so it now waits for the hello. It was not launched here; CI-opt launches measured groups.
  • mawsd's cold cua socket starts listening at the engine's first live status. If mawsd stalled past real cua serve's first dial, cua would retry after 5 s. Not observed (22/22 dials found the socket listening, with 78 ms or more of margin), so not changed.

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

…here; on macOS a group sent SIGKILL answers kill(-pgid, 0) with EPERM until its leader is reaped, which the probe threw on (widgets.spec.ts:1106's flake); the probe shared with the stub's test, a darwin case reproducing it

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
… heard MAWS's hello, not once its control socket listens; the connector's control socket listens as it dials, alongside the engine's first turn, so scenes 3 and 4 could send cua's creation sequence before the hello and have it answered 'not connected' (browser-cua.spec.ts:997, :1028); the connector reports greeted, its test reproducing the window

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
… rather than one snapshot 200 ms after SIGKILL (review round 1)

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
…closed by this branch's two fixes (the scene's connector waits for MAWS's hello; the E8 probe reads macOS's EPERM for an unreaped group as still there)

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

chatgpt-codex-connector Bot commented Nov 7, 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-07T03:59:51.769339Z 23ee350 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.

@SSFSKIM
SSFSKIM merged commit 7e8c4eb into master Nov 7, 2026
SSFSKIM added a commit that referenced this pull request Nov 7, 2026
… track's finding at doperpowers board #153); PR #510 closes the two 11-07 hosted flake rows

Sminos-Session: GUI AI agent workspace charter#37052769 (MAWS on macbook)
@SSFSKIM
SSFSKIM deleted the fix/hosted-flakes-1107 branch November 7, 2026 04:06
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