Contain Codex child stdin release races - #2506
Open
ymichael wants to merge 1 commit into
Open
Conversation
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.
Human comments
What was wrong
The recurring packages failure was amplified by package-shard CPU oversubscription but rooted in two lifecycle races. First, the topology test started a 200 ms real-time request deadline before the app-server subprocess had executed, then required the fake to have logged both
spawn:andexit:; under contention the runtime correctly released the construction before the fake ran its first line, sospawned() === 1 && exited() === 1was impossible forever. Instrumentation reproduced that state in all 40/40 stressed failures (spawned=0, no live PID, no failed-release warning). Second, once the test made the construction boundary deterministic, release could kill the app-server while the Codex bridge was making its next initialization write; the resulting child-stdinEPIPEwas unhandled and crashed the shared bridge. This is distinct from #2352: its predicate-before-deadline polling fix remains intact, and these failures were real lifecycle states that never satisfied the predicate. The independently verified merge base is524b2fe4b0df74185bdd29a274fb77cd6765b2b3.What changed
EPIPEduring an already-started release cannot schedule duplicate kill sequences or crash the bridge.thread/start, freeze only the runtime request clock until the real child has started, advance the existing 200 ms deadline, and assert the recorded PID is actually gone. This covers both graceful SIGTERM and the connection's intentional SIGKILL escalation.There is no server/daemon wire-contract change, so
HOST_DAEMON_PROTOCOL_VERSIONis unchanged. There are no CLI, guide, or configuration-surface changes.How you verified
Timed out after 10000ms waiting for the late-constructed child was releasedsignature. Test-body p50/p95/max were 2.59 s / 3.01 s / 12.62 s.pnpm exec turbo run test --filter=@bb/agent-runtime --force -- --run src/runtime.codex-topology.test.ts— 1 file / 4 tests passed.pnpm exec turbo run test --filter=bb-plugin-provider-codex --force -- --run src/bridge/app-server-connection.test.ts— 1 file / 1 test passed.pnpm exec turbo run test --filter=@bb/agent-runtime --filter=bb-plugin-provider-codex --force— agent-runtime 22 files / 318 tests and Codex provider 25 files / 239 tests passed.pnpm exec turbo run typecheck --filter=@bb/agent-runtime --filter=bb-plugin-provider-codex --force— passed.pnpm exec turbo run build --filter=@bb/agent-runtime --filter=bb-plugin-provider-codex --force— applicable Turbo build graph passed (the two scoped packages have no direct build scripts).pnpm exec prettier --check packages/agent-runtime/src/runtime.codex-topology.test.ts plugins/provider-codex/src/bridge/app-server-connection.ts plugins/provider-codex/src/bridge/app-server-connection.test.ts plugins/provider-codex/src/bridge/fake-codex-app-server.mjs— passed.Fixes: no issue — exact and fuzzy open issue/PR searches found no active recurrence fix.