Skip to content

Fix Windows CI flakes from real gh calls in tests and wall-clock parity throttling - #5186

Merged
ymichael merged 2 commits into
mainfrom
bb/fix-ci-red-on-main-thr_p57hqwrkmf
Oct 8, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/fix-ci-red-on-main-thr_p57hqwrkmf

Conversation

@ymichael

@ymichael ymichael commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Two Windows-only CI flakes kept main red.

  1. child-outcome-gaps.test.ts (Windows server-1, 5 of the last 7 red main runs). Forward server gh credentials when the server has no local host daemon #5161 dropped the primaryHostId !== null guard in resolveHostEnvironment, so a server with no host-id file forwards GitHub credentials to every host. The server test harness has no host-id file, so every turn dispatch in a harness test began running the real gh auth token and gh api user. That takes ~1 s locally and longer on Windows. The test advances fake timers and then asserts on the dispatched parent notice, so it failed whenever the subprocess outlasted the advance. Locally, 5 of the 7 tests in the file failed on every run. Harness tests were also reading the runner's or developer's real gh login.
  2. provider-parity claude-code/subagent replay (Windows packages-other, latest run). createBridgeDeltaEventCollector throttled progress events against the wall clock (500 ms). The recorded lane is assembled in a synchronous loop, always inside the throttle. The replay is assembled live while the bridge subprocess streams, so on a slow runner the item.open → item.progress gap passed 500 ms and emitted an extra item/backgroundTask/progress.

What changed

  • apps/server/test/helpers/test-app.ts: the harness disables machineGitCredentialsEnabled by default.
    • Tests that cover forwarding (machine-environment, public-project-clone-sources, public-terminals) mock resolveGitCredentials and opt back in.
    • Five tests that disabled it by hand drop that setup, and one redundant [] mock is removed.
    • The /system/config defaults test lists the harness override.
  • packages/provider-bridge-protocol/src/testing/bridge-delta-assembly.ts: the testing collector pins its clock (now: () => 0), alongside its existing textDeltaFlushMs: 0, so both parity sides coalesce progress identically regardless of runner speed. The signature is unchanged and no SDK surface file is touched.

No production code, wire, or CLI changes.

How you verified

  • Before: vitest run test/threads/child-outcome-gaps.test.ts failed 5/7 locally on every run. Instrumentation showed resolveThreadRuntimeCommandConfig taking ~1000 ms inside resolveGitCredentials. After: it passes, and the touched files pass 91/91.
  • pnpm exec turbo run test typecheck lint --filter=@bb/server: 3398 passed with 2 failures. The general-settings defaults test is now fixed. builtin-plugins hot-reload passed when rerun in isolation and is unrelated. Both files pass on rerun.
  • Parity: a replay-side-only clock advancing 600 ms per read reproduced the exact CI diff (extra item/backgroundTask/progress). With the pinned clock all 56 cells pass.
  • pnpm exec turbo run test typecheck lint --filter=@bb/provider-bridge-protocol --filter=@bb/provider-parity --filter=bb-plugin-echo-provider --filter=@get-bb/plugin-sdk: 13/13 tasks passed.

🤖 Generated with Claude Code

AGENT GENERATED

qa and others added 2 commits October 7, 2026 21:28
Since #5161 dropped the `primaryHostId !== null` guard, a server with no
host-id file forwards GitHub credentials to every host. The server test
harness has no host-id file, so every turn dispatch in a harness test now
ran the real `gh auth token` and `gh api user` through
resolveHostEnvironment. That took ~1 s locally and longer on Windows, so
tests that advance fake timers and then assert on the dispatched turn
(child-outcome-gaps.test.ts) failed whenever the subprocess outlived the
fake-timer advance. It also read the runner's or developer's real gh login.

The harness now disables machineGitCredentialsEnabled by default. Tests
that cover forwarding mock resolveGitCredentials and opt back in; tests
that disabled it by hand drop the now-redundant setup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
createBridgeDeltaEventCollector throttled progress events against the
wall clock. Parity self-tests assemble the recorded lane in a tight
synchronous loop, always inside the 500 ms throttle, but assemble the
replay live while the bridge subprocess streams. On a slow Windows
runner the replay's item.open -> item.progress gap exceeded 500 ms and
emitted an extra item/backgroundTask/progress for claude-code/subagent.

The collector already pins text flushing (textDeltaFlushMs: 0) for
determinism; it now pins its clock too, so both sides coalesce
identically regardless of runner speed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 53c1e87 into main Oct 8, 2026
47 checks passed
@ymichael
ymichael deleted the bb/fix-ci-red-on-main-thr_p57hqwrkmf branch October 8, 2026 04:35
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