Repository navigation
Forward server gh credentials when the server has no local host daemon - #5161
Merged
Merged
Conversation
resolveHostEnvironment required a non-null primary-host ID before loading the automatic GitHub credential bundle. Server-only deployments have no host-id file, so no enrolled machine received GH_TOKEN, the credential helper, or SSH rewrites, while the status row reported "logged in". Treat a missing primary host as "no host to exclude": every machine now receives the bundle, the primary host is still excluded when one exists, and the forwarding setting still gates it. Fixes #5133 Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Oct 8, 2026
…ty throttling (#5186) ## 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).** #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](https://claude.com/claude-code) > AGENT GENERATED --------- Co-authored-by: qa <qa@x> 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
resolveHostEnvironmentloaded the automatic GitHub credential bundle only whenprimaryHostId !== null && primaryHostId !== context.hostId. A server with no local host daemon (for example,bb-serveralone in Kubernetes) has nohost-idfile, soprimaryHostIdis alwaysnull. No enrolled machine receivedGH_TOKEN, the credential helper or the SSH→HTTPS rewrites, while Settings → Environment variables still reported the built-in row as "logged in". The null check treated "there is no local daemon to exclude" as "forward to no one". Report: https://get-bb.github.io/reports/issues/5133.htmlWhat changed
apps/server/src/services/hosts/host-environment.ts: dropped theprimaryHostId !== nullclause. A missing primary host now means there is no host to exclude, so every machine receives the bundle. The primary host is still excluded when one exists,machineGitCredentialsEnabledstill gates forwarding, and a userGH_TOKENstill takes precedence.docs/configuration.md: one sentence stating that a server without a local host daemon forwards the built-in row to every machine.host-idimmediately after enrollment and before it connects its session. No work is dispatched to a host before it connects, so a server with a local daemon cannot briefly forward to that daemon.How you verified
host-environment.test.ts: with nohost-idfile, an enrolled machine receivesGH_TOKENandGIT_CONFIG_COUNT, and receives nothing once forwarding is disabled. It fails without the fix (AssertionError: expected [] to deeply equal ArrayContaining{…}) and passes with it.pnpm exec turbo run test --filter=@bb/server -- src/services/hosts/host-environment.test.ts src/services/machines/: 6 files, 37 tests passed.pnpm exec turbo run typecheck lint --filter=@bb/server: passed.Fixes #5133
🤖 Generated with Claude Code