Repository navigation
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
Conversation
…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)
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:997and:1028: O17 headless scenes 3 and 4, "not connected" at 0 msCause. "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 firstwindows.querycould 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:
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 awaitswaitForHellos(), bounded byHELLO_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), andscene.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 anot connectedfailure rather than the product's own refusal.Reproduction.
test/support/cua-engine.test.tsadds a backend that holds its hello. Driven through its control socket whileconnectedis already true, the stub fails cua's creation sequencenot connectedatwindows.query, which is the e2e's error. It succeeds oncegreetedis set.(b)
e2e/widgets.spec.ts:1106: E8 Stop on a CLI that ignores SIGTERM,kill EPERMCause. The spec's probe
process.kill(-pgid, 0)rethrew anything but ESRCH. It threw inside the post-SIGKILLexpect.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'skillpg1(bsd/kern/kern_sig.c) finds the group, its iterate filter skips SZOMB members, andnfound == 0returnsposix ? 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.
ps -gshowed 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.tsreads EPERM as "still there" (ESRCH is still the only "gone"). The spec andplugin-cli-stub.test.tsuse 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 withError: kill EPERMat the same call. It passes with the fix.Repeated runs (no
--repeat-eachroute exists inscripts/ci-gate.shorgate.yml, so each gate ran separately)tsconfig.e2e.jsongained the probe; Playwright does not typecheck)Five browser-cua runs and four widgets runs, with no recurrence and no flaky pass in any job.
Gates
test/support/process-group.tswas missing fromtsconfig.e2e.json). Fixed and folded into cba81a8.process-group.test.ts.--gates all: the change touches no main process, renderer or engine host code.Review
Residue
e2e:daemon-idle(a measured group) callsscene.connector()too, so it now waits for the hello. It was not launched here; CI-opt launches measured groups.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)