Skip to content

Forward server gh credentials when the server has no local host daemon - #5161

Merged
ymichael merged 1 commit into
mainfrom
bb/fix-bb-issue-5133-thr_iprabv8vje
Oct 8, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/fix-bb-issue-5133-thr_iprabv8vje

Conversation

@ymichael

@ymichael ymichael commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

resolveHostEnvironment loaded the automatic GitHub credential bundle only when primaryHostId !== null && primaryHostId !== context.hostId. A server with no local host daemon (for example, bb-server alone in Kubernetes) has no host-id file, so primaryHostId is always null. No enrolled machine received GH_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.html

What changed

  • apps/server/src/services/hosts/host-environment.ts: dropped the primaryHostId !== null clause. 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, machineGitCredentialsEnabled still gates forwarding, and a user GH_TOKEN still takes precedence.
  • docs/configuration.md: one sentence stating that a server without a local host daemon forwards the built-in row to every machine.
  • The status row needed no change; it reported "logged in" correctly, and machines now actually receive the bundle.
  • Startup timing: the local daemon persists host-id immediately 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.
  • No wire change.

How you verified

  • New test in host-environment.test.ts: with no host-id file, an enrolled machine receives GH_TOKEN and GIT_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.
  • Not tested end to end against a real server-only deployment.

Fixes #5133

🤖 Generated with Claude Code

AGENT GENERATED

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
ymichael merged commit 1ca5e09 into main Oct 8, 2026
48 checks passed
@ymichael
ymichael deleted the bb/fix-bb-issue-5133-thr_iprabv8vje branch October 8, 2026 00:02
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]>
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.

Server gh login is never forwarded to machines when the server has no primary host

1 participant