Repository navigation
Stabilize desktop, Git, and parser CI tests - #7680
Merged
Merged
Conversation
This was referenced Nov 17, 2026
ymichael
added a commit
that referenced
this pull request
Nov 24, 2026
## Human comments ## What was wrong All of group A failed the same way: Windows test shards timed out on real Git subprocess tests. None of these tests or their code changed on main since their last failures (latest: main `9f3a35d930`, 11-23). Each failure was a flake: other attempts on the same SHA or main passed. Passing Windows runs take 0.4–2 s per test, and failures need a 15–25x slowdown. Neighbouring tests in the same file ran 11–16 s in the same minute. So the cause is CPU/IO starvation on the 8-vCPU runner, which runs several vitest packages at once (turbo `--concurrency`). It is not a hang. On an idle Windows 11 VM, a git spawn costs about 60 ms, copying a `.git` tree about 50 ms, and a local `git fetch` 250–400 ms (it starts `sh.exe`, upload-pack, `rev-list` and `maintenance --auto`). Whether a test fails depends on how much of that work it does in one budget. Root cause per test: - **`workspace-git-fetch` › fetches and prunes only origin (interactive: true/false), skips … none named origin** (16 + 1 failures): every case copied the repo plus one bare remote per remote, so 4 `.git` trees for the two "only origin" cases. The case with 2 copies never failed. `git fetch` also started `git maintenance run --auto`. - **`workspace-git` › keeps the standard patch format under …** (9 failures): every case copied the template twice and ran 8 patch reads plus `git config` spawns. Half of that rebuilt the same unconfigured baseline each time. - **`workspace-git` › readDefaultBranchRefs** (5 test failures, plus 1 `beforeAll` timeout at 10 s): the `beforeAll` used 5 git processes, and the ahead/diverged cases ran `git commit` (plus its maintenance child). Production `compareBranchOids` then ran `merge-base --is-ancestor` twice. - **`plugins/git` workspace-status-cache › reuses committed comparisons across readers while refreshing edits and moved refs** (7 failures): one test made 7 sequential status reads, 79 git processes in one 15 s budget, and it ran first in the file. The other status-cache failure in the evidence (11-16, "cancels an over-budget squash command", an assertion error) came before #7680, which fixed that race, and it hasn't recurred. It is left alone. - **`github-pr-status` › reads a known PR by URL only on the branch it was found on** (2 failures at the package's default 5 s): two sequential `views` calls, each starting a fake `gh` (`cmd.exe` → `node.exe`) one after the other, plus 8 git processes. ## What changed - `workspace-git-fetch.test.ts`: all remotes point at the one read-only template remote. Fetching never writes to the remote, so a wrong fetch of `alpha`/`zeta` still adds `fresh` and prunes `stale`, and the test still catches it. The template turns off `maintenance.auto`. Each case now copies one repo instead of up to four. - `workspace-git.test.ts` patch-format cases: the baseline is computed once in `beforeAll`. Each case writes its settings to a `GIT_CONFIG_GLOBAL` file, the user's own config level, and reads the shared template's 4 patches in parallel. No repo copies and no `git config` spawns. Baseline and cases both use a hermetic global file. With bb's display overrides removed, all 9 cases still fail. - `workspace-git.test.ts` readDefaultBranchRefs: the template is `git init --template=` plus one `git fast-import`, which writes main, origin/main, and the local and remote tip commits. Each relation case applies its moves with one `update-ref --stdin`. The behind/ahead/diverged cases share one table and keep their names. - `workspace-git.ts` `compareBranchOids`: one `git merge-base <local> <origin>` replaces the two `--is-ancestor` checks. If the merge base is local, local is behind; if it is origin, local is ahead; otherwise, or with no common ancestor (exit 1), they have diverged; any other exit is unknown. This is exact, because when A is an ancestor of B the merge-base set is {A}. It saves one git process for every ahead or diverged default-branch read and branch-ref resolution in production. The now-unused `isAncestorRef` is removed. - `workspace-status-cache.test.ts`: the kitchen-sink test becomes "reuses a committed comparison across readers while refreshing worktree edits" and "recomputes the comparison when HEAD or the base branch moves", with the same assertions. The feature branch is built with `fast-import`, and the template turns off `maintenance.auto`. The largest single test drops from 79 to 50 git processes. - `github-pr-status/host.test.ts`: both known-URL reads go into one `views` call, as the client batches them. They share one batched `gh` process and their git reads run concurrently. The test asserts there is exactly one `resource(url:` selection, on `p0`, and that the other read is a `headRefName` lookup. - `github-pr-status/vitest.config.ts`: `testTimeout: 15_000`, the budget the git, github, docs and workflows plugins already use. This is the one budget raised, because the work is inherently slow on the slowest runner. Every test in `host.test.ts` starts real git plus a Node fake `gh` through `cmd.exe`, and `plugins-2` shares its runner with the environment plugins' 60 s-budget tests. On this PR's first Windows run, single-view neighbours took 1.6–2.1 s, the single-`gh` `git-host` tests up to 2.7 s, and the batched known-PR test 4.6 s. The 5 s vitest default is not enough headroom for any of them. No retries or CI settings changed. ## How you verified - `pnpm exec turbo run test typecheck lint --filter=bb-environment-provider-host --filter=bb-plugin-bb--git --filter=bb-plugin-bb--github-pr-status`: 74 + 293 + 182 tests pass; typecheck and lint are clean (the git plugin's 9 lint warnings are existing ones in `ui/diff`). - Mutation checks, each restored afterwards: removing `MACHINE_READ_GIT_CONFIG`'s display entries fails all 9 patch-format cases; fetching `--all` fails both "only origin" cases; swapping the behind/ahead result fails the relation table; always reusing the known URL fails the PR test. - Git processes per test, counted with a `git` PATH shim (top-level spawns only): patch-format case 10 → 4; "user Git settings" describe 100 → 57; status-cache test 79 → 41 / 50 after the split; PR test 2 `gh` processes → 1. Fetch cases drop 3 directory copies and a maintenance child; spawn counts are otherwise unchanged. - Local A/B, origin/main against this branch on one macOS host at load average about 140 from other workloads, 6 alternating rounds of the 4 files, 0 failures on either side. Summed per round: patch-format 4454 → 827 ms, fetch cases 1638 → 1060 ms, default-branch relations 1006 → 780 ms. The status-cache split totals 1956 → 2244 ms, but its slowest test p90 goes 2587 → 1350 ms. PR test p90 784 → 553 ms. - Windows 11 ARM64 VM (6 vCPU, Defender on), the four test files bundled from origin/main and from this branch, one vitest process per variant, 5 alternating rounds. Four rounds (base 1 and 5, new 4 and 5) were whole-VM stalls in which every file in both variants slowed down together and hooks timed out. Over the six clean rounds, 0 failures on either side. Summed per round: patch-format 22.4 → 4.4 s, fetch cases 6.5 → 3.4 s, default-branch relations 3.6 → 3.1 s, known-PR test 2.7 → 1.8 s. The old status-cache test took a 12.3 s median on the idle VM (82 % of its 15 s budget); the two split tests take 6.0 s and 4.6 s. - Windows CI on this PR: every row green on the first attempt with no reruns. In `packages-other`, none of the changed `environment-provider-host` tests passed vitest's 300 ms slow-test threshold. This shard ran only the affected packages, so it was less loaded than a full main run. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Nov 24, 2026
…races (#8079) ## Human comments ## What was wrong Each of these tests failed on CI in the past week, then passed on a rerun of the same SHA, or failed on `main` with no relevant change. I checked every failing job log and traced the cause. Most are the same class as #7745: real work charged against a fixed deadline on a loaded Windows runner. In each case the expensive step was not what the test is about. | Test | CI evidence | Root cause | |---|---|---| | `process-utils` `workload-priority.test.ts` › lowers a running process so the processes it starts later inherit the priority (Windows, 5 s) | 5 timeouts at 5.0 s, 4 of them after #7745, one on `main` ([job](https://github.com/get-bb/bb/actions/runs/44798992406/job/136506064404)); passing runs 2.8–4.9 s | #7745 stopped the grandchild from booting Node at low priority. The child still does. The test lowered the child right after `spawn`, so its whole Node bootstrap ran at below-normal priority. It then needed a second lowered wake-up (`"done"`) to kill the grandchild and exit. On a saturated Windows runner a below-normal thread can wait about 4 s for the anti-starvation boost, once for each burst. | | `agent-runtime` `runtime.process-lifecycle.test.ts` › does not wait for stalled replacement initialization during full shutdown (Windows) | `Timed out after 1000ms waiting for the replacement bridge to begin initialization`, twice ([job](https://github.com/get-bb/bb/actions/runs/44386079401/job/135091227510)) | The setup step polled for a marker file with the helper's 1 s budget. That window covers retiring one Node bridge and spawning another. The sibling test that does exactly that took 2.8 s in the same failing job. | | `local-open-targets` `workspace-open-targets.test.ts` › discovers and opens JetBrains Toolbox applications through bundled executables (Windows, 5 s) | 5.05 s and 5.08 s ([job](https://github.com/get-bb/bb/actions/runs/44814274981/job/136558617339)); passing runs 0.49 s and 1.07 s | The macOS listing walked the JetBrains Toolbox tree once for every JetBrains product (8), one readdir at a time: 54 readdirs in this test. In the same failing job, fs ops cost about 100 ms each (the TextMate test, about 8 fs ops, took 805 ms). The cost is in the product: every "Open in" listing on a Mac with Toolbox walks the tree 8 times. | | `thread-view` `tool-call-parsing-performance.test.ts` › bounds intent parsing work after a script's disqualifying write (Windows) | `expected 4.80 to be less than 4.77` on `main` ([job](https://github.com/get-bb/bb/actions/runs/45242326493/job/137930150703)), plus 2 more | The `/ 8` bound sits on the healthy ratio. Both commands pay the same O(n) cost to build, hash and cache the command string, so a correct early exit is only 6.5–8× cheaper on Windows (10–12× on an M-series Mac). The regression the test guards, scanning on after the write, gives a ratio of about 1. | | `desktop` `server-moved.test.ts` › closes the watcher and polls after a watch error (Linux) | `expected "vi.fn()" to be called once` ([job](https://github.com/get-bb/bb/actions/runs/44847337211/job/136670291512)) | A race in the test's manual scheduler. The first `flush()` starts the initial lock read. If that read is still in flight when the second `flush()` fires the poll, the poll only marks a recheck. The in-flight read then sees no lock and schedules a debounced check on the manual scheduler, which the test never flushed again. | | Windows app smoke on `main`: `bb plugin list failed with 1` / `bb-app SDK status failed with 1`, with no output ([run](https://github.com/get-bb/bb/actions/runs/44443547241), [run](https://github.com/get-bb/bb/actions/runs/44790721793)) | Both after "daemon join" | `waitForProcessExit` resolved on `'exit'`, which Node fires before the child's stdio is drained. The SDK step is a `node -e` script, and one that exits 1 always writes a stack trace to stderr, yet both failure messages were empty. Why the commands exited 1 is still unknown. This change makes the next occurrence show it. | Looked at and left alone: - `tool-call-parsing-performance` › scans long quoted thread messages in chunks: all 4 failures were on SHAs without #7680, which moved these benchmarks to thread CPU time. No failure since. - `plugin-sdk` `vendor-plugin-roots.test.ts` (Windows, 5 s, 3 failures): a victim of runner saturation, not of its own work. The resolver does 14–39 fs ops per test, none redundant. In the failing jobs every test in the file slowed from 5–100 ms to 2–6 s during one window, while `shared-declaration-emit` (9–16 s), `runtime-entries` (5–16 s) and `api-index` (5.7 s) were running too. In the last 19 `main` runs it reached 50% of its limit once. A larger timeout would only move the deadline. The real fix is Windows-shard oversubscription (unbounded `VITEST_MAX_WORKERS` × turbo concurrency on 8 vCPUs), which belongs in its own change. - `scripts` `ci-performance.test.mjs` › ENOTEMPTY removing the fixture's `.git` (Linux, once): I found no concurrent writer. Each `git commit` does leave a detached `git maintenance run --auto` behind. An strace (git 2.56) shows it only unlinks `objects/maintenance.lock`, and it creates nothing in `.git` after `commit` returns. 750 Linux iterations of the exact fixture sequence, under CPU contention, produced no failure. A retry would only hide whatever caused it. ## What changed - `packages/process-utils/test/workload-priority.test.ts`: the child prints `ready` after booting at normal priority, and only then is it lowered. The lowered work is now one wake-up and one `spawn`, the minimum the claim needs. The test reads the grandchild's priority, and `stop()` tears down the tree at normal priority (`taskkill /T`, or the process group). The child no longer has to be scheduled again to exit. The test gets a 15 s budget. That one wake-up can still wait about 4 s for Windows' anti-starvation boost on a saturated runner, and the inherent worst case of about 4 s + about 1 s bootstrap + taskkill is above 5 s. - `packages/agent-runtime/src/runtime.process-lifecycle.test.ts`: the stalled bridge writes a line to stderr when it receives `initialize`, and the test awaits it through the manager's `onStderr`. There is no polling budget. The real assertion is unchanged: shutdown completes within 1 s instead of waiting for the bridge's 3 s stall. - `packages/local-open-targets/src/index.ts`: the Toolbox `apps` tree is walked once per runtime, and each JetBrains adapter matches its prefixes against the collected bundles. Traversal order, depth limit and the executable check are unchanged, so results are the same. The daemon builds a new runtime for every request (`apps/host-daemon/src/local-api.ts`), so the walk is never stale across requests. In this test: 54 readdirs down to 12, 6 for the listing and 6 for the open. - `packages/thread-view/test/tool-call-parsing-performance.test.ts`: the bound is `readOnly / 3`. It sits between the healthy ratio (6.5–12×) and the regressed ratio (about 1×), with more than 2× margin on each side. - `apps/desktop/test/server-moved.test.ts`: the `waitFor` flushes the manual scheduler on each attempt, so a recheck that the in-flight initial read schedules also runs. - `packages/bb-app/scripts/smoke-tarball.mjs`: `runCommand` and the bridge `model/list` step wait for `'close'` (new `waitForProcessOutput`), after the process has exited and its stdio has closed, so a failing command's stdout and stderr reach the error. The forked plugin-host worker keeps `waitForProcessExit` (`'exit'`). Node never emits `'close'` once the parent disconnects the IPC channel, which I checked with a minimal fork/disconnect script, and the first local smoke run with `'close'` everywhere hung at that step. No wire, CLI or doc changes. ## How you verified All local numbers are from an M-series Mac. Other agents' suites were running on the same machine, with load averages of 100–700. | Test | Before (`origin/main`) | After | |---|---|---| | `workload-priority`, with the lowered child also put in macOS background QoS (`taskpolicy -b -p`) and 32 CPU burners, to model Windows' strict below-normal scheduling | Spawn to grandchild pid: 13.5–25.1 s, then another 1.7–11.2 s to exit (5 s limit) | Ready 26–102 ms at normal priority, lowered burst 48–913 ms, `stop()` about 105 ms (16 timed runs). macOS background QoS can starve a process indefinitely, which Windows does not: in a 50-run batch under this model a few runs still waited 30 s or more for that one burst. | | `workload-priority`, unmodified, 30 repeats | 30/30 | 30/30, about 160 ms per run instead of 65 ms, because `stop()` polls the process group at normal priority. No leaked grandchildren afterwards. | | `runtime.process-lifecycle` stalled-replacement test, with a preload that delays every child Node start by 1 s to model Windows spawn cost | Fails with the CI error, `Timed out after 1000ms waiting for the replacement bridge to begin initialization` | 20/20 | | Same test, unmodified, 30 repeats with 48 CPU burners, and with background QoS | passes | passes | | JetBrains Toolbox test, fs calls counted by wrapping `fs/promises` | 54 readdirs (46 listing + 8 open) | 12 readdirs (6 + 6). 100/100 repeats pass. | | Parser bound, 40 repeats | — | 40/40. Injected regression (keep scanning after the write, same result): `expected 57.0 to be less than 18.5`, still caught. | | `server-moved` watch-error test, with the first lock read delayed by 200 ms | Fails with the CI error, `expected "vi.fn()" to be called once with arguments` | Passes, and 500/500 unmodified. With `schedulePoll()` removed from the watch-error fallback it still fails. | | Smoke `waitForProcessExit` | Can't reproduce the lost output on macOS or Linux (Node's `'exit'`-before-stdio ordering shows up on Windows IOCP). | Local `turbo run smoke:tarball --filter=bb-app`: every step passes, including full stack, daemon join and plugin host worker | `pnpm exec turbo run lint typecheck --filter=@bb/process-utils --filter=@bb/thread-view --filter=@bb/agent-runtime --filter=@bb/local-open-targets --filter=@bb/desktop --filter=bb-app` passes. `pnpm exec turbo run test` for the same packages passes except `process-utils` `process-tree.test.ts` › finds and kills processes whose cwd is inside a directory. That file is untouched and also fails alone on this machine, which had about 1,020 processes running at the time. > 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
Desktop recovery tests sent retry clicks after a navigation started but before it completed, when the app still rejected retries. The fixture could also block on macOS keychain availability unrelated to recovery. Git tests assumed patch hashing started before a one-second deadline and that a freshly written file was already outside Git's racy timestamp window. A DiffTab first-load error case inherited another case's cached successful environment. Parser performance ratios used tiny wall-clock samples vulnerable to scheduling and coarse clock resolution.
What changed
Desktop recovery waits for the completed error navigation and explicitly models unavailable OS credential persistence while retaining real cookie handling. Git fixtures wait for hashing admission, advance the existing deadline, and establish stable timestamps. DiffTab's initial-failure fixture gets its own environment. Parser ratios use three sustained CPU samples of at least 100ms each and unique leading keys to avoid long-prefix cache collisions; the 4x/5x/8x thresholds remain unchanged.
Two GitHub rate-limit cases now use small shell/cmd executables instead of starting Node just to emit static stderr. They retain real command execution, argument validation, credential-scoped cooldown, and invocation counting.
No CI jobs, test retries, production timing policy, or timeouts changed. Parser sampling adds about 2.1 seconds in focused local runs (0.36s to 2.50s) to obtain meaningful measurements.
How you verified
Delayed navigation completion by 250ms: old desktop recovery fails, fixed recovery passes with the same delay.
Delayed pre-hash Git work and forced racy timestamps: both old failure signatures reproduce; fixed cases pass under the same conditions.
DiffTab seed 8821 fails before and passes after; the independent retained-status contract remains green.
Parser passes with four competing CPU workers; removing its chunk-scan optimization still fails the unchanged 4x gate.
Final shuffled verification passes all 1,454 tests in changed packages (desktop 626, Git 283, thread-view 545). Lint/typechecks and formatting pass. An unchanged process-utils profiler assertion failed in the broader second run and remains under separate investigation; that run is not claimed fully green. Native Windows parser verification is pending this PR's existing CI.
The GH plugin passes all 182 cases plus lint/typecheck. A credential-isolation mutation fails before and after. Expanded Windows ABBA measurements, eight samples each: median 204 ms before versus 113 ms after. This reduces fixture startup cost; the historical 5-second timeout was not reproduced.