Skip to content

fix: queue steers while turns start - #2816

Merged
ymichael merged 1 commit into
mainfrom
bb/explain-turn-submit-startup-error-thr_hsrjru7isz
Sep 1, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/explain-turn-submit-startup-error-thr_hsrjru7isz

Conversation

@ymichael

@ymichael ymichael commented Sep 1, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

The server marks a thread active when its first turn is accepted, before the provider's root turn/started event records the active turn id. An immediate steer, steer-if-active, or active-thread auto send therefore tried to submit while startup was still in flight. The daemon could reject it as a competing turn, and the follow-up was not reliably delivered. The existing thread-busy wait cannot represent this state because it intentionally waits for the current turn to finish and dispatches the message as a later turn.

What changed

  • Added the distinct persisted queue wait waitingOn.kind: "turn-starting" for join-turn sends against an active thread that has no recorded root turn id yet.
  • Root turn/started events wake those rows in queue order and re-attempt them as steers into the newly identified turn. Ordinary thread-busy rows remain untouched and continue waiting for the turn to finish.
  • Parent system notices use the same startup wait while preserving their execution settings and system-message taxonomy.
  • Added the queue label, icon, Send-now restriction, CLI description, built-in bb-cli skill guidance, and thread guide documentation.
  • Added regressions for multiple ordered startup steers, the real event wakeup, separation from thread-busy, and parent-system-message delivery. Updated older fixtures that previously modeled a live steer without recording turn/started.
  • Bumped the Plugin SDK to 0.4.34 and refreshed its public API inventory because the queued-message DTO exposes the new wait kind.
  • No host-daemon wire contract changed, so HOST_DAEMON_PROTOCOL_VERSION is unchanged. The solution is provider-agnostic and adds no Pi-specific behavior or held daemon command.

This covers the startup-race portion investigated in closed PR #2417 with a server-owned persistent queue. It does not port #2417's separate provider-busy/compaction refusal handling.

How you verified

On the final rebase against origin/main (026572964):

  • pnpm exec turbo run test typecheck --filter=@get-bb/plugin-sdk --filter=@bb/plugin-api-map --filter=@bb/app --filter=bb-plugin-plugin-api-docs — 11/11 tasks passed; the app suite passed 3,688 tests and the Plugin Guide suite passed 74 tests.
  • pnpm exec turbo run test --filter=@bb/server --force -- test/threads/thread-send-dispatch.test.ts test/threads/dispatch-hooks.test.ts test/public/public-thread-fork.test.ts — 43/43 tests passed.
  • pnpm exec turbo run typecheck --filter=@bb/server --filter=@bb/domain --filter=@bb/db --filter=@bb/cli --filter=@bb/templates — 8/8 tasks passed.
  • bb plugin build plugins/plugin-api-docs — backend and app artifacts built successfully.
  • Plugin SDK version guard and git diff --check passed.
  • Manual QA with sawyerhood/dev-browser rendered a real queued row showing Waiting for turn to start, with the thread still working and Send now unavailable.

Related to #2370

AGENT GENERATED

@ymichael
ymichael force-pushed the bb/explain-turn-submit-startup-error-thr_hsrjru7isz branch from db400f3 to ce01b98 Compare September 1, 2026 18:17
@ymichael
ymichael merged commit 68da041 into main Sep 1, 2026
15 checks passed
@ymichael
ymichael deleted the bb/explain-turn-submit-startup-error-thr_hsrjru7isz branch September 1, 2026 19:25
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.

1 participant