Skip to content

Start project-default threads on the project's machine when the primary host has no source - #6054

Merged
ymichael merged 1 commit into
get-bb:mainfrom
alexandre-vl:bb/project-default-source-host
Oct 22, 2026
Merged

ymichael merged 1 commit into
get-bb:mainfrom
alexandre-vl:bb/project-default-source-host

Conversation

@alexandre-vl

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

A thread created with no environment (project-default) and no live parent always resolved to the primary host. Examples are a Tasks preset, an automation run, or bb thread spawn without an environment flag. resolveProjectDefaultThreadEnvironment took requireConnectedPrimaryHostId and then looked up the project's checkout on that host. It never checked that the project had a checkout there. A project whose only checkout lives on another machine, such as a laptop, therefore failed with 404 Project has no local-path source for host (#4446).

What changed

  • thread-default-policy.ts: the new resolveProjectDefaultHostId keeps the primary host whenever it has a checkout of the project, so today's placement is unchanged for those projects. Otherwise it takes a persistent machine that holds a checkout. It skips destroyed and removing machines, and prefers the project's default source, then the oldest one. That machine is readied the way an explicitly chosen one is (ensureHostSessionReadyForWork):
    • a suspended machine is woken;
    • an offline machine answers 502, so the thread never silently moves to another machine.
  • project-sources.ts: getProjectSourceOnPersistentHost, one join query.
  • bb guide threads says where a thread with no environment flag starts.
  • No server/daemon wire change, so no HOST_DAEMON_PROTOCOL_VERSION bump.

How you verified

  • A new project-default machine block runs against the real server and a migrated SQLite database. Each test creates a project-default thread through the public API. The "main" column comes from running the same file against main's server code (b143a2286): 4 tests failed and 2 passed.

    Project checkouts main This PR
    Only on a laptop (not the primary) 404, expected 404 to be 201 201, worktree on the laptop
    On the primary and a laptop, default source on the laptop 201 on the primary 201 on the primary
    Default source on a temporary machine, another on a laptop 404, expected 404 to be 201 201 on the laptop
    On an offline laptop 404, expected 404 to be 502 502, no fallback to the primary
    On a suspended laptop 404, expected 404 to be 201 201, laptop woken
    Only on a temporary machine 404 404

    If the fix only requires a connected machine instead of waking it, the suspended-machine test fails with expected 502 to be 201.

  • pnpm exec turbo run typecheck lint --filter=@bb/server passed.

  • The six server suites that cover project-default placement passed (177 tests): thread-default-policy, environment-providers, public-threads.project-default, thread-runtime-config, provider-management and plugin-sdk.

  • Before the wake was added, pnpm exec turbo run typecheck test --filter=@bb/server --filter=@bb/db --filter=@bb/templates passed @bb/server 3631, @bb/db 632 and @bb/templates 46.

  • No UI change, so there are no screenshots; the status codes above are the before and after. I did not reproduce it in a live instance, which needs a second enrolled machine.

Fixes #4446

AGENT GENERATED

…ry host has no source

A project-default thread always resolved on the primary host, so a project
whose only source lives on another machine failed with 404 "Project has no
local-path source for host". When the primary host has no source of the
project, use the persistent machine that holds its default source, or its
oldest source on a persistent machine. Projects with a source on the primary
host keep today's placement; an offline project machine fails with 502
instead of moving the thread.

Fixes get-bb#4446
@ymichael
ymichael merged commit ccd3829 into get-bb:main Oct 22, 2026
46 checks passed
alexandre-vl added a commit to alexandre-vl/bb that referenced this pull request Oct 23, 2026
…-environment

After get-bb#6122 moved the composer into plugins/composer, the carry
merged after bb/project-default-environment through three merge bases
whose virtual base conflicts in plugins/automations/detail-view.tsx, so
Fork Sync skipped it. Merged first, its bases are main and two commits
upstream already has (get-bb#6054, get-bb#6005), and bb/project-default-environment
then arrives already included.
alexandre-vl added a commit to alexandre-vl/bb that referenced this pull request Oct 30, 2026
- bb/daemon-self-update-node-npm-cli (get-bb#6083): superseded by
  upstream get-bb#6194.
- bb/project-default-source-host (get-bb#6054) and
  bb/explain-failed-automations-thr_agcnkvvvke (get-bb#6005): merged upstream;
  each merges into main with main's own tree.
- carry/automation-environment-composer: it only reconciled the composer
  branch with explain-failed, and the updated
  bb/automation-environment-composer merges without it.
- carry/github-plugin-inbox: it breaks bb-plugin-github#typecheck on
  current main; the updated github-plugin-inbox carries the inbox itself.
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.

Tasks: project-default preset always dispatches to the primary host, fails for projects on other machines

2 participants