Skip to content

Prebuild agent-runtime test bridges for recovery restarts - #2367

Merged
ymichael merged 1 commit into
mainfrom
bb/ci-flake-fix-runtime-restartrecommended-recovery-thr_apec7qjf5m
Aug 25, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/ci-flake-fix-runtime-restartrecommended-recovery-thr_apec7qjf5m

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

What was wrong

The real-process recovery suite launched both the provider bridge worker and the scripted-echo bridge from TypeScript source, so every restartRecommended replacement process paid the same tsx transform/import cost again. Under package-shard CPU contention, the runtime had already shut down the original bridge and registered the replacement child, but the replacement had not reached the bridge's top-level spawn log or answered thread/resume before the tests' unchanged 5-second hang detector expired. That one startup path caused both same-SHA signatures in CI attempt 2 and attempt 4; the polling-order bug fixed by #2352 was not involved.

What changed

  • Added a Turbo-cached @bb/agent-runtime#generate:test-bridges task that bundles the real provider bridge worker and real scripted-echo bridge once per test run.
  • Pointed the standard scripted-echo runtime harness at those JavaScript artifacts, while preserving source mode for tests that deliberately inject a custom bridge module.
  • Added bounded failure diagnostics to the two affected waits so a future failure reports process lifecycle, resumed thread IDs, runtime provider state, and restart stderr.

The tests still exercise real child-process shutdown, replacement, Provider Bridge Protocol initialization, and thread/resume; no timeout, retry budget, assertion, product behavior, or wire contract changed, so HOST_DAEMON_PROTOCOL_VERSION is unchanged.

How you verified

  • Deterministic pre-fix reproduction: ran the two exact tests with 512 CPU burners on a 16-logical-CPU host. Both failed with the CI errors (10.810s and 14.256s). Added diagnostics showed processLog=[spawn:<old pid>,...,exit:<old pid>], resumedThreadIds=[], and runningProviders=[fake]: the replacement child existed but was still before bridge top-level startup.
  • Same-load post-fix comparison: the identical two-test command passed both cases in 12.348s total (5.361s and 6.986s) with the original 5-second waits unchanged; the pre-fix run took 25.067s and failed both.
  • pnpm exec turbo run test --filter=@bb/agent-runtime --force -- 'src/runtime.recovery.test.ts' -t 'restartRecommended: an idle thread|restartRecommended read while' — 1 file, 2 tests passed.
  • pnpm exec turbo run build typecheck test --filter=@bb/agent-runtime --force — 7 Turbo tasks passed; 22 files / 318 tests passed.
  • pnpm exec prettier --check packages/agent-runtime/package.json packages/agent-runtime/scripts/build-test-bridges.mjs packages/agent-runtime/src/test/runtime-test-harness.ts packages/agent-runtime/vitest.config.ts turbo.json and git diff --check — passed.

Fixes: no issue — repeated exact and broad open GitHub issue/PR searches returned no matches, and the only exact bb thread match was this worker.

AGENT GENERATED: by GPT-5.6-Sol

@ymichael
ymichael merged commit 7fa66ab into main Aug 25, 2026
15 checks passed
@ymichael
ymichael deleted the bb/ci-flake-fix-runtime-restartrecommended-recovery-thr_apec7qjf5m branch August 25, 2026 00:06
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