Repository navigation
Run the remaining bridge-retirement checks on idle children - #8141
Merged
Merged
Conversation
Two process-manager tests still started the full scripted-echo bridge twice to check process bookkeeping (5.9-7.2 s and 2.7 s on CI). Use the idle provider manager from #8136, as the retire test now does. The old-hash test also launched its second process with the same launch as the first, so the thread-ownership guard it names was never exercised; it now uses the superseding launch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
fix/process-lifecycle-artifact-hash-test
branch
from
November 24, 2026 22:22
b9a200e to
9cbaff5
Compare
ymichael
added a commit
that referenced
this pull request
Nov 25, 2026
"does not wait for stalled replacement initialization during full shutdown" started and retired a full scripted-echo bridge before its stalled replacement, and that start and retirement took 3-12 s on loaded CI runners against a 15 s deadline. When it overran, the timed-out test body kept running after afterEach removed tmpDir and spawned the replacement into the missing cwd, which surfaced as an unhandled "spawn node ENOENT". The first process is now the idle child that #8136 and #8141 use for the sibling retirement tests; the stalled replacement still uses the real fake adapter so it receives initialize and holds its reply. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Nov 25, 2026
…ess start speed (#8147) ## Human comments ## What was wrong Two tests in `packages/agent-runtime/src/runtime.process-lifecycle.test.ts` fail at random in `Tests (packages-host)` on loaded runners. Both depend on how fast processes start under CPU load. **`drains provider stderr before reporting process exit`** fails with `expected null to be 'stderr-after-exit'`, for example on #8075's merge run ([job](https://github.com/get-bb/bb/actions/runs/45507748534/job/138847431154), 2286 ms). The fake provider spawned a grandchild that inherits stderr, then exited at once. The grandchild had to boot Node and wait 50 ms before writing. After a provider exits, the runtime waits at most `PROVIDER_PROCESS_CLOSE_GRACE_MS` (1 s) for stderr to close. On a loaded runner, Node startup alone can take longer than that. **`does not wait for stalled replacement initialization during full shutdown`** times out at 15 s, followed by an unhandled `Provider "fake" failed to start: spawn .../node ENOENT` ([job](https://github.com/get-bb/bb/actions/runs/45506198560/job/138847994142); it failed on all three attempts of that branch, and took 12.1 s on #8076's passing run). Before reaching its stalled replacement, the test started and retired a full scripted-echo bridge. #8141 measured a full start at 3.7–4.6 s under load, and stopping one can take up to 5 s plus kill and stderr grace periods. On other PRs' loaded runs the test took 3–12 s. When it overran, Vitest timed the test out but its body kept running. `afterEach` removed `tmpDir`, and the replacement then spawned into the missing cwd, which Node reports as `spawn <node> ENOENT`. The ENOENT is a consequence of the timeout, not its cause. #8136 and #8141 fixed the sibling retirement tests the same way; this one was left. ## What changed `runtime.process-lifecycle.test.ts` only. No runtime code changes. - **stderr drain:** the grandchild reports ready over IPC, the provider exits only after that, and the grandchild writes to stderr 50 ms after the IPC channel disconnects, which happens when the provider exits. The write still lands after the exit, but Node startup no longer counts toward the 1 s grace period. - **stalled shutdown:** the first process is the idle child (`process.stdin.resume()`, no post-initialize requests) that the sibling tests use. The adapter it uses is pulled out into a `createIdleAdapter` helper that `createIdleProviderManager` now shares. The replacement still uses the real fake adapter on the raw stalled script, so it receives `initialize` and holds its reply for 3 s, which is the behavior under test. ## How you verified CPU starvation locally: the test runs at background QoS (`taskpolicy -b`) next to 32 busy-loop processes on a 16-core Mac. This reproduces both CI failures. | Test | Before | After | |---|---|---| | stderr drain | 2 CI-assertion failures before I stopped it | 6 of 6 pass | | stalled shutdown | 2 of 4 time out (18.9 s, 21.4 s); passes took 13.1 s and 2.3 s | 4 of 4 pass in 198–358 ms | Both tests still catch the bugs they guard: - stderr drain: with `PROVIDER_PROCESS_CLOSE_GRACE_MS` temporarily set to 0, the new test fails 3 of 3. - stalled shutdown: with `shutdown()` temporarily changed to await in-flight provider starts, the new test fails. `pnpm exec turbo run typecheck lint test --filter=@bb/agent-runtime`: pass (316 tests, 1 skipped). > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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
#8136 moved
retires a threadless bridge process superseded by a new artifact hashonto idle children, because two full scripted-echo starts can exceed the 15 s test deadline under CI load. Two sibling process-manager tests still started the full bridge twice to check the same bookkeeping:keeps an old-hash bridge process that still owns a threadwaits for provider retirement before starting a same-key replacementReproduced in a Linux
node:22container under CPU load (24 busy loops on 16 cores). Each full bridge start took 3.7–4.6 s, while retiring a process took 20–40 ms, so these tests are one busy runner away from the same timeout.keeps an old-hash bridge process that still owns a threadalso didn't test what its name says. It launched the "new" process with the samebridgeLaunchas the old one, so the old process was never stale. The guard it names (threadIds.size === 0inretireStaleBridgeProcesses) could be deleted without the test failing.What changed
packages/agent-runtime/src/runtime.process-lifecycle.test.tsonly.createIdleProviderManagerfrom Keep bridge lifecycle checks independent of provider startup #8136.SUPERSEDING_BRIDGE_LAUNCH.No production code changes.
How you verified
providerProcess.identity.threadIds.size === 0removed fromretireStaleBridgeProcesses, the old-hash test now fails. Onmainit passes with that guard removed.pnpm exec turbo run test typecheck lint --filter=@bb/agent-runtimepasses: 314 passed, 1 skipped.🤖 Generated with Claude Code