Skip to content

Fix Pi child-exit and workflow wake test flakes - #8084

Merged
ymichael merged 1 commit into
mainfrom
bb/fix-plugin-test-flakes-thr_nqp9hafw5g
Nov 24, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/fix-plugin-test-flakes-thr_nqp9hafw5g

Conversation

@ymichael

@ymichael ymichael commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Three CI flakes from the last week, each caused by its test rather than the product. The third one is already fixed on main by #8068, which landed the same settle change while this PR was open, so this PR now carries the first two.

Pi bridge: a child whose extension never reports ready is a construction error, not a hung tool call (Windows plugins-1, main 4d2fccc, run 44840631240). The harness decided a fake Pi child had exited only when the fake wrote an exit: line from its SIGTERM or stdin-EOF handler. On Windows, kill() closes stdin and then runs taskkill /T /F straight away. If the forced kill lands before the child handles EOF, the child dies without writing the line, so the test waits 10 s and fails with expected false to be true (12 040 ms in the failing log; passing runs take 1.9–3.1 s). The same self-reported exit backs the transient-login, catalog-eviction and catalog-close assertions in bridge.round2/bridge.lifecycle, and the refresh test in catalog.test.ts. All of them go through kill().

Workflows: wakes queued runs when settings frees capacity (ubuntu plugins-2, e1f97e4; attempt 2 passed on the same SHA). The test used fake timers and gave the queued run vi.waitFor({ timeout: 20, interval: 1 }) to reach succeeded. That is 20 ms of real time for an in-process QuickJS + SQLite run. Each check also advanced the fake clock by 1 ms, so the tight timeout was what kept the fake clock short of a polling tick. I measured the real time from freeing capacity to succeeded: p50 2–3 ms, but 5–16% of iterations take over 20 ms, up to 318 ms.

Render invariants: typing an Ask User Question answer renders nothing outside the question form (11-17 018f74a, expected [ …(41) ] to deeply equal []; the next push on that branch passed). settle() only waited for 1 s with no React commits. It did not check whether the page still had requests in flight. On a freshly seeded server under load, the requests the page sends at load (/system/providers, /system/execution-options, /system/providers?environmentId=…, /hosts/…/provider-clis/status) were still pending 6.5–7.5 s after load, when reset() ran. They finished about 1 s into the typing window, and their commits re-rendered the hidden follow-up composer (Send options, Prompt actions), a timeline row's menu and sidebar footer items. That only happens on the first page against a fresh server, which is why only the first test in typing.test.ts failed.

What changed

  • plugins/provider-pi/src/bridge/test-support.ts: readProcessLog().exited now lists the tracked fake-Pi ChildProcesses that have exited, from experimental_trackChildProcesses. It no longer reads the fake's self-written exit: lines, so it is right however the child died. spawned still comes from the log. This fixes every caller at once.
  • plugins/provider-pi/src/bridge/catalog.test.ts: the refresh-replacement test checks that only the second child is still running, instead of looking for an exit: line from the first.
  • plugins/workflows/src/service-policy.test.ts: both waits in the wake test use { timeout: 5_000, interval: 0 }. With interval 0 each check advances the fake clock by 0 ms, so no polling tick can fire and the run can only finish because of the wake. The real-time limit is only there to bound a failure.
  • tests/render-invariants/src/render-session.ts: no change here any more. Graduate six early adopter experiments #8068 made settle() wait for pending requests as well as React quiet, which is the fix for the root cause above, so I dropped my version of it when rebasing.

Not changed: the 11-18 render-invariants failure (run 44414918194: push.test and typing.test both timed out in waitForSelector('[data-timeline-row-id]') before any settle, with the first row never visible within 30 s). It happened once, in two files at the same moment, the next push on that branch passed, and it has not come back in about 130 Render invariants jobs since 11-19. I did not see it in about 15 local parallel runs, so I am leaving it alone.

How you verified

  • Pi. I made the fake ignore EOF and SIGTERM (FAKE_PI_HANG_ON_CLOSE=1), so it is killed without running its handler, the same as a Windows forced kill. The old harness then fails the test with the CI assertion (expected false to be true, 14 s), and the new harness passes. The touched files (bridge.round2, catalog, bridge.lifecycle, 31 tests) passed 10 of 10 loops under 16 CPU burners. turbo run test --filter=bb-plugin-provider-pi passes: 371 passed, 5 skipped.
  • Workflows. Mutation check: with wakeWorker() removed from updateSettings, the fixed test fails with expected 'queued' to be 'succeeded', so it still catches a wake that is missing. I measured real and fake time to succeeded over 100 repeats per variant, idle and under 48 burners. Fake time consumed is ≤2 ms with the old interval and 0 ms with the new one. The fixed test passed 600 of 600 repeats (100 × 3 variants × 2 runs) under 48 burners.
  • Render invariants (fixed on main by Graduate six early adopter experiments #8068; these numbers are from my equivalent change before the rebase). Before the fix, under 6 burners with all three files in parallel, it failed in 1 of 2 full-suite runs and in 2 of 5 instrumented first iterations on a fresh fixture. Request logging tied the failure to the pending provider requests described above. After the fix, 6 of 6 full-suite runs passed (7 of 7 tests each) under the same load.
  • turbo run typecheck lint passes for bb-plugin-provider-pi and bb-plugin-workflows after the rebase onto 22a9366 (Pi 371 passed, workflows 284 passed), and oxfmt is clean.

AGENT GENERATED

🤖 Generated with Claude Code

…a frozen clock

The Pi harness took a child's exit from a line the fake wrote in its
SIGTERM/EOF handler. On Windows kill() force-terminates the tree with
taskkill /F, which can land before the handler runs, so a dead child looked
alive. readProcessLog().exited now comes from the tracked ChildProcess exit,
and the catalog refresh test checks the tracker the same way.

The workflow wake test gave the queued run 20 ms of real time to finish
while each check advanced the fake clock 1 ms. The checks now leave the fake
clock where it is, so a polling tick still never fires, and wait up to 5 s
of real time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/fix-plugin-test-flakes-thr_nqp9hafw5g branch from 0c1e18e to 2bc12bc Compare November 24, 2026 05:12
@ymichael ymichael changed the title Fix Pi child-exit, workflow wake and render-invariant settle flakes Fix Pi child-exit and workflow wake test flakes Nov 24, 2026
@ymichael
ymichael merged commit 6a31e2f into main Nov 24, 2026
51 checks passed
@ymichael
ymichael deleted the bb/fix-plugin-test-flakes-thr_nqp9hafw5g branch November 24, 2026 05:26
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