Repository navigation
Description
Summary
Starting a new thread on a project checkout destroys that checkout's existing environment if the environment was first created with a branch: { kind: "new" } input. The new thread fails about 1–3 s after spawn with Provisioning thread failed / Environment is destroyed. The files on disk are untouched, because project-checkout remove() is a no-op, but the environment row is gone for good. Starting the same thread again succeeds and creates a new environment. Expected: the new thread adopts the idle environment and starts.
Versions and environment
- bb 0.43.4 (
npx bb-app@latest, server version endpoint reportscurrentVersion: 0.43.4), Linux (WSL2) server - Host daemons 0.43.4 on 8 enrolled Ubuntu machines (manual provider),
--auto-update - claude-code provider; not provider-specific (failure happens before any turn)
project-checkoutenvironment provider, long-lived user-maintained checkouts (one per machine per project)
Steps to reproduce
Observed three times today on 0.43.4: twice from the desktop new-thread composer (Project checkout on a machine) and once from the CLI. I have not yet repeated it on a scratch project. The steps below are the smallest sequence that the evidence and code point to:
- Create a thread on a project checkout with a new-branch input, so that
environment_provider_selection.inputs.branchis stored on the environment:bb thread spawn --project <proj> --machine <host> \ --environment-provider project-checkout \ --environment-inputs '{"branch":{"kind":"new","baseBranch":"develop"}}' \ --prompt "Reply only with ok."
- Archive it once it is idle:
bb thread archive <thr>. The environment staysready,lifecycle.phase: active,retireAt: null, since project-checkout hasretireGraceMs: null. - Start a new thread on the same checkout without a branch input:
bb thread spawn --project <proj> --machine <host> \ --environment /home/<user>/repos/<repo> --prompt "Reply only with ok."
bb thread log <new-thr>→ provisioning fails within ~3 s;bb environment show <old-env>→destroyed.
Did not reproduce with: checkout environments whose stored selection has no branch input ({"machine":…,"inputs":{"path":…}}). Two of those were adopted normally by a path spawn today (env_5u2r9k57wk, env_2gzwgkvvgf). A spawn with --environment <env_id> (reuse intent) was also fine.
Expected vs actual
Actual (bb thread log, all three occurrences identical):
── Provisioning thread failed ──────────────────────────────
Preparing workspace
Preparing Project checkout…
Provisioning thread failed (3s)
── Error ───────────────────────────────────────────────────
Provisioning thread failed
Environment is destroyed
$ bb environment show env_jn7khv32fh
Status: destroyed
Lifecycle: destroyed
Teardown: removed (attempt 1)
Provider: project-checkout
Expected: the new thread adopts the idle checkout environment, or gets a fresh one, and starts. An environment with no live threads under a provider with retireGraceMs: null should not be torn down just because a new thread arrived with a different selection.
Evidence
Timeline (UTC). "Destroyed" is the environment row's updated_at:
| environment | last live thread archived | new thread created | env destroyed | Δ |
|---|---|---|---|---|
env_znwxv5e7d4 |
thr_rs997aha8t 2026-09-23T15:21:34Z |
thr_gvbisidxfg 15:29:36.41Z |
15:29:39.65Z | 3.2 s |
env_ixkm7i2drg |
thr_y9j4z9e2is 2026-09-23T01:07:44Z |
thr_629c8wyqei 15:29:06.42Z |
15:29:09.78Z | 3.4 s |
env_jn7khv32fh |
thr_g7u2kjezsf 2026-09-22T18:32:51Z |
thr_bx6zmkj9c2 16:02:16.27Z |
16:02:17.24Z | 1.0 s |
The time since archive ranges from 8 minutes to 21 hours, so this is not a grace-period expiry. Each environment was destroyed about 1–3 s after a spawn.
Rows after the failure (read-only query of bb.db). All three have the same shape: owner_thread_id is the new thread, and the stored selection carries the old thread's branch: new input:
env_jn7khv32fh status=destroyed teardown_status=removed teardown_attempt=1 retire_at=NULL
owner_thread_id=thr_bx6zmkj9c2 (the new, failed thread)
environment_provider_instance_key=thr_g7u2kjezsf (the original thread)
environment_provider_selection={"machine":{"type":"existing","hostId":"host_xqsevvg7y6"},
"inputs":{"path":"/home/<user>/repos/<repo>","branch":{"kind":"new","baseBranch":"develop"}}}
The environments that were adopted correctly have inputs: {"path": …} with no branch.
My reading of the path at desktop-v0.43.4 (9b8c1d3). This is inferred from code, not traced with a debugger:
- The path spawn reserves a fresh row. The project-checkout
createattaches and returns the existing checkout path, andbindEnvironmentPath(called fromenvironment-engine.ts#L421) adopts the existing row. It movesownerThreadIdto the new thread but keepsenvironmentProviderSelection: existing.environmentProviderSelection(L577), which is the oldbranch: newselection. - On the next provisioning pass,
prepareProviderEnvironmentcompares that stored selection with the new request's{machine, inputs}.changedis true, so it callscancelProviderEnvironmentCreation. cancelProviderEnvironmentCreationsetsteardownStatus: "running". InsweepProviderEnvironmentInSlot,cancelledis then true and there are no live threads, soretireAt = now. That bypasses the provider'sretireGraceMs: null(checkout plugin L148). Removal runs, the no-opremove()returnsremoved, anddestroy.recordedis applied.startThreadIfEnvironmentReadythen seesstatus: destroyed→Environment is destroyed.
So the cancel meant for the new thread's own abandoned reservation ends up tearing down a shared, adopted environment. Possible fixes (maintainers' call): have bindEnvironmentPath take the current selection when it adopts a row, or have the placement changed check skip teardown for an adopted environment that has no pending creation.
What you ruled out
- Files are not lost.
git ls-filescounts, branches, stashes and working-tree status on all three affected checkouts were unchanged after the failures. - Not version skew. Server, all 8 daemons and the CLI are 0.43.4 (checked each daemon's
bb-apppackage.jsonover SSH). - Not Archiving a thread fails with 409 once its environment row has been pruned #1924 or Thread storage is never removed for a deleted thread whose environment row was already pruned #4160. Those concern threads whose environment row was already pruned. Here the row is destroyed by the spawn itself.
- Not Concurrent spawns attaching to the same checkout path fail with "Cannot checkout branch" though no branch is requested #3609 (concurrent spawns on one checkout path). Each failure was a single spawn with no other thread starting on that path.
- Not An interrupted teardown hook leaves a managed environment retrying forever, with no backoff and no recovery command #4158 or
destroyed-environment-pruneblocks the event loop for 1–8 s per statement #4161 (worktree teardown retries, prune performance). - Not caused by the machine or daemon being offline. All hosts were
connected, and other threads started on the same hosts at the same time. - Unchanged on
mainatb1930486. None of the 39 commits sincedesktop-v0.43.4touchpackages/db/src/data/environments.ts,environment-engine.ts,thread-environment-placement.tsor the checkout plugin. - Searched open and closed issues for
environment destroyed,Environment is destroyed,provisioning thread failed,retire environment,project checkout destroyed,last live thread; no duplicate.
Suggested priority and effort
Medium: any project-checkout user who ever spawned with a new-branch input hits it on their next thread on that checkout, from both the composer and the CLI. You can't see it coming: the environment looks ready / active right up to the spawn. No data is lost and retrying the spawn works. The fix looks local to adoption or the selection comparison.
- Reproduced on the latest release: three live occurrences on 0.43.4. Not yet repeated on a scratch project.
- Searched open and closed issues for the same problem.
- Agent-written. The investigation ran in a Claude Code session outside bb, so there is no bb thread to link. The thread and environment ids above are from that install.
AGENT GENERATED
Activity
bb-slop-cop commentedon Sep 23, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotBug · Priority: Medium · Effort: Medium. Applied
workspacesandconfirmed-repro.REPRODUCED · High confidence. Adoption preserves the old provider selection; the next preparation pass mistakes it for a changed request and cancels the ready environment. A focused regression reproduced the resulting
destroyedstate in two clean trusted-main checkouts using migrated SQLite and an in-process provider. Live CLI/UI attachment was not exercised.Reproduction and root-cause report · Fix PR #4187
The regression fails before the fix and passes afterward. All 83 relevant tests and server typecheck pass. The ready, unmerged PR changes 46 text lines across two files.
Keep shared project checkout environments when a starting thread is c…
alanagoyal commentedon Oct 14, 2026
Additional production occurrence from the reporter’s bb logs, investigated on 2026-10-13. This appears to be the same adoption/selection-mismatch bug on desktop 0.43.4, with a useful variant: no new-branch input is present. The old selection contains
inputs.path, while the new reservation containsinputs: {}.Versions and environment
/Applications/bb.app; bothCFBundleShortVersionStringand bundledbb-app/package.jsonreport 0.43.4.bb --versionalso reports 0.43.4.host_6tasqdyqm3, projectproj_5xhs8fecxp(investor-update-emails), standard~/.bbdata directory; Connect requests are present in the server log.gpt-6.1-sol, high reasoning. No provider session started in the failed thread. Installed Codex currently reportscodex-cli 0.162.1; its version at the incident was not captured.98706229e4e088b46f1b676280c891f224d4a071; this is not the commit of the installed app. No fresh reproduction or fix verification was performed; this evidence comes from the retained production event log and read-only database queries.Observed workflow / reproduction status
The user started “Add the linked X post” in the investor-update-emails project with:
The thread failed during checkout preparation. The screenshot shows
Provisioning thread failed,Environment is destroyed, and the composer’sEnvironment archivedstate. The failed thread was subsequently archived, over an hour after the failure; archive was not the trigger.Faithful candidate reproduction (not independently rerun): use a 0.43.4 project-checkout environment whose recorded selection has
inputs: {path: <checkout>}, archive its existing threads, then start a new thread through the project’s default checkout selection (inputs: {}). Expected: adopt the existing checkout and start. Actual retained occurrence: adoption is followed immediately by teardown and provisioning failure.Thread event evidence
Affected thread:
thr_8i5qrh33m2; provisioning ID:tpv_xscvjw6tan; request ID:creq_98bkw23vf4.UTC timeline reconstructed from
bb thread log thr_8i5qrh33m2 --all --jsonand environment row timestamps:env_cyfx4rbmk9createdenv_cyfx4rbmk9env_dmgbpvbpupsystem/error: provisioning failedVerbatim error event payload (seq 8):
{ "code": "thread_provisioning_failed", "message": "Provisioning thread failed", "detail": "Environment is destroyed" }bb thread log thr_8i5qrh33m2 --allends with:Read-only database evidence
The old environment was created on October 1. Its two preceding threads (
thr_76sv5u8k6e,thr_en9adqjthv) were both archived that day. The earlier thread’s retained provisioning events show successful workspace preparation onmain; its later agent error was an unsupported model, a separate failure.Relevant
~/.bb/logs/server.21.logentries confirm the failed thread was served successfully through Connect, rather than failing to load:{"level":30,"time":1791919280886,"component":"server","msg":"[plugin:connect] bb connect thread load path=/api/v1/threads/thr_8i5qrh33m2/timeline status=200 originTtfbMs=3.8 originBodyMs=0.1 totalMs=3.8 responseBytes=765 contentEncoding=br"} {"level":30,"time":1791919281108,"component":"server","msg":"[plugin:connect] bb connect thread load path=/api/v1/threads/thr_8i5qrh33m2/conversation-outline status=200 originTtfbMs=6.4 originBodyMs=0.2 totalMs=6.7 responseBytes=213 contentEncoding=identity"}No matching thread/environment diagnostic was found in
host-daemon.21.log; the decisive error is persisted in the thread event log. The precise teardown caller was not traced, so the selection-mismatch diagnosis remains an inference from the matching sequence and stored selections.Relationship to the fix / ruled out
384666f97669029e8bdb70fb16f941119848766d. The investigation checkout includes the ready-environment selection guard and an adoption regression test. This report does not establish a regression after that fix.Investigation thread:
thr_rip7xgkudz(“Find errored thread and open issue”); original affected thread:thr_8i5qrh33m2(“Add the linked X post”).alanagoyal commentedon Oct 14, 2026
Follow-up after the reporter clarified that this happened today (2026-10-13): verified the actual installed server code, rather than relying on its version label.
The installed desktop app’s source map at
/Applications/bb.app/Contents/Resources/app.asar.unpacked/node_modules/bb-app/server/dist/start-server.js.map, source../src/services/threads/thread-environment-placement.ts, contains:This does not contain the
row.status !== "ready"selection guard added by #4187. The installed artifact therefore still contains the faulty comparison, despite the fix having merged in the repository. The explicit-path versus default-input mismatch in today’s environment rows hits that comparison.Correction to the interpretation of the preceding report: this is a current, user-visible failure on the installed 0.43.4 desktop artifact, not a resolved experience for this user. A merged source fix does not establish that their installed release includes it. Whether a newer published desktop release includes the fix has not been checked. No fresh spawn was performed and no claim is made that the running process was independently fingerprinted; the retained incident and the installed artifact both support the original defect.
Investigation:
thr_rip7xgkudz; affected thread:thr_8i5qrh33m2.