You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
spawn --base-branch <name> resolves the stale local ref; only remote-prefixed names are fetched #1917
bb thread spawn --base-branch main provisions the new managed worktree from the stale localrefs/heads/main rather than origin/main, silently. A branch name without a remote prefix skips the fetch entirely.
Mechanism
In packages/host-workspace/src/provisioning.ts, createWorktree() calls fetchRemoteBaseBranch()only when baseBranch contains a remote prefix, then passes the bare baseBranch through to git worktree add. A bare main therefore resolves against whatever refs/heads/main happens to be on the host, which on a machine that fetches but never checks out main can be arbitrarily far behind.
The existing test fetches remote base branches before creating worktrees exercises only the explicit origin/main form, so the bare-name path has no coverage.
Impact
Measured on a working host: local main was 5 commits behind origin/main at spawn time. An earlier occurrence was worse — a spawned agent branched ~70 PRs behind and spent its session reading documentation from a contract version 11 releases stale, reasoning confidently from it.
Three properties make this worse than an ordinary stale checkout:
Silent — spawn reports success; nothing indicates the base was stale.
Material — the agent reads and reasons from the stale tree, and may rebuild work that already exists.
Recurring — it fires on every spawn on that host until someone refreshes the local ref by hand, which is easy to forget precisely because nothing surfaces it.
Suggested resolution
Resolve <branch> against origin/<branch> when a remote-tracking ref exists.
Fall back to the local ref when no remote-tracking ref exists (a genuinely local base branch is legitimate).
Refuse only genuinely ambiguous or missing refs. A missing origin or a detached HEAD must not crash.
A refusal that names the divergence and its size would also be defensible, and is arguably more honest than silently picking one — but it is more disruptive, so (1) seems the better default.
Workaround
Pass --base-branch origin/main explicitly. That form takes the fetch path and resolves correctly today.
Verdict: PARTIALLY REPRODUCED · root-cause confidence: high
Root cause (short): Daemon createWorktree only fetches remote-qualified bases (resolveRemoteBaseBranch returns null for names without '/'), so a bare name goes verbatim to git worktree add and resolves the stale local refs/heads/; PR Resolve a named default base branch against origin when spawning #2152 (merge 52083aa, in base) added a server-side rewrite to origin/ only when the named branch is the checkout's default branch, so the reported --base-branch main case is already fixed while any non-default plain name (--base-branch develop) still lands on the stale local ref with no fetch and no warning.
Proposed fix: Generalise the Resolve a named default base branch against origin when spawning #2152 server policy from 'the default branch' to 'any named branch with an origin/ remote-tracking ref': (1) daemon listHostBranches (apps/host-daemon/src/command-handlers/host-branches.ts) computes selectedBranchRelation + selectedBranchOrigin for command.selectedBranch by exporting and generalising the module-private readDefaultBranchRelation in packages/host-workspace/src/git.ts:1257 to readBranchRelation(cwd, localBranch, originBranch); reuse the DefaultBranchRelation enum from packages/domain/src/git-checkout.ts and add the two fields to projectSourceCheckoutSchema th…
Caveats: Revision addressed all verifier findings by re-running, not rewording: the worktree was at origin/main (b735da1) when I started, so I checked out 494f665, rebuilt, and redid both the unit tests and the full 4b flow on a fresh instance (App :14461 / Server :22461 / daemon :30461) with rewritten scripts that derive host id (bb machine list), project id (POST response), env ids (bb thread show --…
The report is self-contained: copy-paste repro steps with the test or script inline, expected vs actual output, screenshots where the bug is visual, and code permalinks at the base commit. It was independently re-executed by a second agent (see its Verification section).
The important scope difference: #3955 additionally proposes freshness checks before subsequent turns, safe refresh of clean zero-ahead worktrees, and visible dirty/ahead/diverged/offline status. Those are broader policy changes than initial provisioning. Existing #1917 evidence also distinguishes default-branch handling added by #2152 from stale non-default plain refs; do not assume every historical trigger remains unchanged.
Keep this as the canonical provisioning tracker and #3955 open for the additional turn-freshness policy. Coordinate implementation and reuse the evidence rather than independently fixing provisioning twice. No prototype is approved or merged by this cross-link.
Activity
SawyerHood commentedon Aug 24, 2026
---Auto-Generated---
Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1917.html
git worktree addand resolves the stale local refs/heads/; PR Resolve a named default base branch against origin when spawning #2152 (merge 52083aa, in base) added a server-side rewrite to origin/ only when the named branch is the checkout's default branch, so the reported--base-branch maincase is already fixed while any non-default plain name (--base-branch develop) still lands on the stale local ref with no fetch and no warning.The report is self-contained: copy-paste repro steps with the test or script inline, expected vs actual output, screenshots where the bug is visual, and code permalinks at the base commit. It was independently re-executed by a second agent (see its Verification section).
SawyerHood commentedon Sep 22, 2026
Cross-linking #3955 at the maintainer's request. Its provisioning portion overlaps this stale-local-base tracker. Preserve its newer evidence and prototype at https://github.com/pixexid/bb/tree/bb/fix-upstream-bb-3955-stale-worktree-freshness-thr_2rbxdhu9cb (latest reviewed fork head reported there: b7d3866).
The important scope difference: #3955 additionally proposes freshness checks before subsequent turns, safe refresh of clean zero-ahead worktrees, and visible dirty/ahead/diverged/offline status. Those are broader policy changes than initial provisioning. Existing #1917 evidence also distinguishes default-branch handling added by #2152 from stale non-default plain refs; do not assume every historical trigger remains unchanged.
Keep this as the canonical provisioning tracker and #3955 open for the additional turn-freshness policy. Coordinate implementation and reuse the evidence rather than independently fixing provisioning twice. No prototype is approved or merged by this cross-link.
Resolve named worktree bases against origin and reuse non-git parent …
Resolve local-vs-origin branch refs with one shared resolver (#7719)