Skip to content

Fix CI lifecycle, readiness, generation, and test isolation flakes - #4976

Merged
ymichael merged 3 commits into
mainfrom
bb/test-flake-followups
Oct 6, 2026
Merged

ymichael merged 3 commits into
mainfrom
bb/test-flake-followups

Conversation

@ymichael

@ymichael ymichael commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Recent CI failures came from independent lifecycle and readiness races, shared test state, and live registry resolution. A review of 900 recent CI runs classified 213 distinct failing test names; broad shuffled runs then exposed additional icon-generation and app teardown/order failures. A refresh of newer main runs found three more failures from the generated-bundle checker race fixed here. This follows #4963.

Evidence includes host/ACP failures, browser ownership, Claude permissions, Pi PID reuse, server move, environment cleanup, and registry resolution.

What changed

  • Host plugin shutdown now shares one directory-cleanup promise instead of deleting the same directory concurrently.
  • ACP and browser child fixtures publish usable readiness after signal handlers are installed. Pi fixtures use actual child handles rather than probing retired, potentially reused PIDs.
  • Claude permission tests wait for the expected request; server retirement and environment cleanup tests await lifecycle completion; Tasks tests wait until form submission is enabled.
  • The server-move fixture retains its listening socket until the child accepts ownership, removing the free-port selection race.
  • The integration harness stops plugins and closes WebSockets during shutdown, matching production.
  • External scaffolds install the packed SDK offline using locked local dependencies.
  • PWA generation skips unchanged assets and publishes changed files atomically, preventing concurrent checks from reading truncated icons.
  • The provider-literal checker excludes generated Wrangler and SDK runtime-test bundles while continuing to scan adjacent source files. A native Windows reproduction identified apps/demo-server/.wrangler/tmp/dev-*/worker.js as the extra provider-reference source.
  • The filesystem-watcher test awaits actual change events under its existing test watchdog and propagates errors received after readiness.
  • The cold-loading toast test runs in its own isolated environment. Palette tests complete Radix's scheduled focus cleanup before disposing jsdom.
  • Replay initialization is limited to four simultaneous workers; initialized replays retain their existing concurrency. Queue slots release on initialization, timeout, exit, signal, and spawn failure.

No wire, public API, or user-facing configuration changes.

How you verified

Controlled before/after failures cover duplicate directory cleanup, readiness publication, stale PID probes, delayed permission delivery, retirement/cleanup scheduling, occupied ports, disabled form submission, open WebSocket shutdown, concurrent icon checking, shuffled toast startup, unfinished focus cleanup, delayed native filesystem events, and generated bundles appearing in the source scan. The replay regression launches eight real workers, checks the initialization bound, then verifies all eight can replay concurrently; failure cases verify queued work completes and children exit.

  • First repository shuffle (seed 61973) passed 14,512 tests outside the app; its icon precheck and subsequent app failures produced the fixes above.
  • Focused verification passes: six replay-helper regressions, all 59 recorded parity cases, 616 host source tests, all 74 integration tests, all 41 Tasks manage tests, and 17 affected app tests. Changed-package lint/typechecks pass.
  • Native Windows shutdown verification passes the formerly failing live-WebSocket regression and three environment-isolation repetitions.
  • Windows startup measurements: limiting startup to four reduced maximum cold initialization from 15.8s to 2.8s and suite duration from 44.1s to 27.3s, while keeping peak live replays at 16. The original 60-second initialization timeout did not reproduce; this is a measured contention mitigation, not a proven diagnosis of that exact failure.
  • Second repository shuffle (seed 82317): 19,886 tests passed, including all 5,370 app tests; one watcher readiness failure led to the final event-wait fix. The complete watcher suite then passed (56 tests), and the scripts suite passed all 201 tests with the artifact exclusions.
  • CI at 2712483 passed 30 checks; its sole failure was the generated-bundle checker race fixed in f4e976b.
  • Final repository-wide shuffle (seed 90071) passes: 19,889 tests across 92 package suites; all 106 Turbo tasks passed, with no unhandled errors.
  • Native Windows scanner after-proof passes 15 demo tests and the source scan with exactly 14 references across six allowlisted source files.
  • Linux/Windows CI at f4e976ba87 is green: all 31 non-skipped checks passed (three intentionally skipped).

Diff scope: four production/tooling files (+392/-317, mostly replay-helper try/finally indentation) and 23 tests/support files (+745/-230).

AGENT GENERATED

@ymichael ymichael changed the title Fix more process lifecycle and asynchronous test flakes Fix CI lifecycle, readiness, generation, and test isolation flakes Oct 6, 2026
@ymichael
ymichael marked this pull request as ready for review October 6, 2026 00:58
@ymichael
ymichael merged commit 9f4ee4d into main Oct 6, 2026
34 checks passed
@ymichael
ymichael deleted the bb/test-flake-followups branch October 6, 2026 02:42
ymichael pushed a commit that referenced this pull request Dec 2, 2026
## Human comments

## What was wrong

The provider-literal ratchet walked the file system, so files that a
test run leaves in the tree counted as core code. `bb-app`'s
managed-json-process test bundles into
`packages/bb-app/.managed-json-cli-*`. When turbo cancels that test, the
bundle stays, and the ratchet fails until someone deletes it. This is
the third artifact of the kind. The first two got a path exclusion each
(#4064, #4976).

## What changed

- `scripts/check-provider-literal-ratchet.mjs`: `scanTree` lists files
with `git ls-files -z`, so untracked files never count. The same
`isIncluded` filter applies. The file walk is removed, together with the
exclusions that only skipped untracked artifacts
(`.packaged-plugin-build-`, `.runtime-test-`, `.wrangler`). Git tracks
no file under them. A new core file now counts locally after `git add`.
CI scans the committed tree, so the merge check is unchanged.
- `packages/scripts/test/provider-literal-ratchet.test.mjs`: each
fixture is a temporary git repository. `write()` stages the file, and
artifacts are written untracked. A case for
`packages/bb-app/.managed-json-cli-*/bb-app.mjs` is added.
- `.gitignore`: ignores `packages/bb-app/.managed-json-cli-*` and
`packages/plugin-sdk/.runtime-test-*`, like
`apps/cli/.packaged-plugin-build-*`, so `git add -A` cannot commit a
leaked bundle.
- `docs/debugging-and-qa.md`: says that the ratchet counts git-tracked
files.

Why not one more exclusion: it would fix only this artifact. Filtering
on git fixes the class and removes about 20 lines.

## How you verified

| check | main | this PR |
|---|---|---|
| `node scripts/check-provider-literal-ratchet.mjs --base origin/main`
(CI command), untracked `.managed-json-cli-PROBE/bb-app.mjs` present |
`FAILED vs origin/main`, exit 1 | exit 0 |
| same, clean tree | exit 0 | exit 0 |
| git-tracked scan vs file walk on the clean repo | - | identical: 13
references in 6 files |
| new test "does not count the untracked artifact
packages/bb-app/.managed-json-cli-…" | fails | passes (25/25) |

`turbo run typecheck lint test --filter=@bb/scripts` and `oxlint -c
.oxlintrc.type-aware.json scripts .github ./*.ts` pass.

Fixes #8527

> AGENT GENERATED
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