Skip to content

Build source CLI before host daemon startup - #1971

Merged
ymichael merged 1 commit into
mainfrom
bb/build-cli-before-source-host-daemon
Aug 19, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/build-cli-before-source-host-daemon

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

What was wrong

The source host daemon injected apps/cli/bin/bb into agent shells without ensuring its gitignored dist/index.js runtime had been built. From a fresh daemon worktree, the first bb invocation therefore attempted the wrapper lazy build inside that separate checkout; sandboxed threads could not write its .turbo directories and every injected CLI command failed.

What changed

  • Made @bb/host-daemon#dev depend on @bb/cli#build, so Turbo restores or builds the CLI runtime before starting the source daemon.
  • Added a source-startup guard that reports a missing CLI runtime immediately rather than publishing a wrapper that will fail later inside a thread.
  • Added regression coverage for both built and missing runtime states.
  • No host-daemon wire contract changed, so HOST_DAEMON_PROTOCOL_VERSION is unchanged. No CLI command, flag, or configuration surface changed, so guide documentation is unchanged.

The added host-daemon critical-path cost measured about 9 ms on a local Turbo cache hit and about 230 ms for a cold CLI build on the test machine; app and server startup remain parallel.

How you verified

  • pnpm exec turbo run test typecheck --filter=@bb/host-daemon --force — 48 test files and 587 tests passed; typecheck passed.
  • pnpm exec turbo run dev --filter=@bb/host-daemon --dry=json --no-update-notifier — confirmed @bb/cli#build is a direct prerequisite of @bb/host-daemon#dev.
  • pnpm exec turbo run build --filter=@bb/cli --force followed by env -u BB_CLI ./apps/cli/bin/bb --version — built and launched successfully (0.39.0).
  • The new missing-runtime test reproduces the prior unbuilt state and verifies the daemon now fails before startup with an actionable error.

Fixes #1970

AGENT GENERATED: by GPT-5

@bb-slop-cop

bb-slop-cop Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · review

I am the SlopCop. I started a security, code quality, performance, architecture, and end-to-end review.

@ymichael
ymichael merged commit 35732c5 into main Aug 19, 2026
12 checks passed
@ymichael
ymichael deleted the bb/build-cli-before-source-host-daemon branch August 19, 2026 23:25
Comment thread turbo.json
// gitignored runtime before the daemon starts so a sandboxed thread never
// has to write back into the daemon's checkout to bootstrap `bb`.
"dependsOn": [
"@bb/cli#build",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 slopcop/review — The new CLI build prerequisite does not cover direct source-daemon commands.

pnpm dev:host-daemon and the @bb/scripts command start the source daemon without this Turbo task. A fresh worktree has no apps/cli/dist/index.js, so the new runtime guard stops these supported commands before the wrapper can build the CLI.

Please route every source-daemon command through one CLI preparation step. Add coverage for a missing runtime and a failed CLI build.

@bb-slop-cop bb-slop-cop Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 SLOP COP 🚨 · review

Plain-English summary: This PR builds the developer CLI before the main source daemon starts. It also gives a clear error when the CLI runtime is absent.

I found one P2 startup regression. The Turbo dependency protects the normal pnpm dev path. However, pnpm dev:host-daemon and the @bb/scripts command bypass Turbo. A fresh worktree has no built CLI runtime, so the new guard stops those commands.

Please use one CLI preparation step for every supported source-daemon command. Test a missing runtime and a failed CLI build through those commands.

The security review found no issues. The performance review found no other issue. The architecture scan found no useful shared abstraction for the repeated CLI runtime path.

The focused test passed all 16 tests. The Turbo source startup returned HTTP 200, and the built CLI ran successfully. GitHub CI is green. One separate local full-suite run hit an unrelated deadline test failure.

No browser route changed, so browser validation did not apply. The independent GPT-5.6 review gate confirmed the P2 regression.

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.

Source host daemon injects an unbuilt CLI into sandboxed threads from fresh worktrees

1 participant