Skip to content

Keep machine recovery off the HTTP readiness path - #8200

Merged
ymichael merged 1 commit into
mainfrom
slopcop/issue-8199
Nov 25, 2026
Merged

ymichael merged 1 commit into
mainfrom
slopcop/issue-8199

Conversation

@bb-slop-cop

@bb-slop-cop bb-slop-cop Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🚨 SLOP COP 🚨 · new-issue-autopilot

Human comments

What was wrong

Startup awaited the machine lifecycle recovery step before opening HTTP. A persisted machine still being created could hold that step until the item sweep detached after 60 seconds, exhausting the launcher's separate 60-second health deadline. The real Manual provider reproduces this while waiting for enrollment.

Verified report: https://get-bb.github.io/reports/issues/8199.html

What changed

Run only the machine recovery step in the background through the existing error-handled startup helper. Keep the preceding startup repairs awaited, and retain the existing machine-operation tracking, deduplication, failure handling, and periodic sweep completion behavior. Add a real-SQLite regression that proves startup completes while creation is pending and that creation subsequently reaches active.

Scope: 65 changed text lines (64 additions + 1 deletion), 2 files, one server recovery subsystem. No dependency, generated file, stored-data, public API, wire protocol, or security-boundary changes.

How you verified

  • The focused regression fails against unchanged production code, including trusted main 85521e8a1aa64bf9a225eadd86210b83122e49f5: startup must not wait for machine setup to finish: expected false to be true.
  • Two clean trusted-main checkouts reproduce the real-server timeout with the real Manual provider and exported launcher health helper: 60,017 / 60,088 ms to timeout, then 61,170 / 61,136 ms to eventual readiness. A focused diagnostic also measures the 59,999 / 60,000 ms detach transition within each checkout; these checks were performed by the same agent.
  • After the fix, the same live sequence reaches health in 1,372 ms with the machine still creating; the script stops its server, deletes its temporary data and confirms both ports are free.
  • pnpm exec turbo run test --filter=@bb/server -- test/services/startup-machine-recovery.test.ts test/services/periodic-sweeps.test.ts test/system/item-sweep.test.ts test/system/periodic-sweep-jobs.test.ts test/services/machines/provider-orchestration.test.ts test/services/machines/lifecycle-recovery.test.ts test/threads/machine-lifecycle.test.ts — 7 files, 49 tests passed.
  • pnpm exec turbo run typecheck lint lint:type-aware --filter=@bb/server — passed; type-aware lint reports zero warnings/errors.
  • git diff --check — passed. The new test is formatted; an existing formatter-only union-type reflow elsewhere in the production file is intentionally excluded.

Fixes #8199

AGENT GENERATED

@ymichael
ymichael merged commit b78ae9d into main Nov 25, 2026
32 checks passed
@ymichael
ymichael deleted the slopcop/issue-8199 branch November 25, 2026 22:43
SawyerHood added a commit that referenced this pull request Nov 30, 2026
## What was wrong

`pnpm start` failed every time with `Server failed to become healthy:
Timed out waiting for health` after a bb process was killed while
threads were being created.

Startup awaits `runStartupRecoverySweep` before opening HTTP, and its
`thread-orphan-cleanup` step ran the thread provisioning sweep inline.
For each thread left in `starting`, `advanceThreadProvisioning` reaches
`buildThreadStartCommand`, which awaits
`providerRegistry.whenRegistrationsSettled()`. Provider plugins only
register after the server listens (`startServerPlugins` runs after
"Server listening"), so each such thread waits the full
`REGISTRATIONS_SETTLED_TIMEOUT_MS` (30s). With three stuck threads,
startup needs 90s+ and the launcher's 60s health deadline kills it,
which leaves the same threads behind for the next attempt.

Found on a real data dir with logpoints in the built server: every step
up to `runStartupRecoverySweep` finished within a second; the sweep
stopped in `thread-provisioning` → `requestThreadStart` →
`buildThreadStartCommand` → `whenRegistrationsSettled`.

## What changed

Same shape as #8200 (machine recovery): run only the thread provisioning
step in the background through the existing error-handled
`runStartupRecoveryStep`, and keep archived/deleted thread teardown
awaited. The periodic sweep still runs provisioning then teardown in
order.

## How I verified

- New `test/services/startup-thread-provisioning.test.ts` holds a
starting thread's provisioning open and asserts startup recovery still
finishes. It fails without the fix (`startup must not wait for thread
provisioning to finish: expected false to be true`) and passes with it.
- `turbo run test --filter=@bb/server -- startup-thread-provisioning
startup-machine-recovery periodic-sweeps item-sweep periodic-sweep-jobs
thread-live-start-handoff environments/provider-orchestration` passes.
- `turbo run typecheck lint --filter=@bb/server` passes.
- The real data dir that hung starts once the patch is applied (see
below).
scowalt pushed a commit to scowalt/bb that referenced this pull request Dec 1, 2026
## What was wrong

`pnpm start` failed every time with `Server failed to become healthy:
Timed out waiting for health` after a bb process was killed while
threads were being created.

Startup awaits `runStartupRecoverySweep` before opening HTTP, and its
`thread-orphan-cleanup` step ran the thread provisioning sweep inline.
For each thread left in `starting`, `advanceThreadProvisioning` reaches
`buildThreadStartCommand`, which awaits
`providerRegistry.whenRegistrationsSettled()`. Provider plugins only
register after the server listens (`startServerPlugins` runs after
"Server listening"), so each such thread waits the full
`REGISTRATIONS_SETTLED_TIMEOUT_MS` (30s). With three stuck threads,
startup needs 90s+ and the launcher's 60s health deadline kills it,
which leaves the same threads behind for the next attempt.

Found on a real data dir with logpoints in the built server: every step
up to `runStartupRecoverySweep` finished within a second; the sweep
stopped in `thread-provisioning` → `requestThreadStart` →
`buildThreadStartCommand` → `whenRegistrationsSettled`.

## What changed

Same shape as get-bb#8200 (machine recovery): run only the thread provisioning
step in the background through the existing error-handled
`runStartupRecoveryStep`, and keep archived/deleted thread teardown
awaited. The periodic sweep still runs provisioning then teardown in
order.

## How I verified

- New `test/services/startup-thread-provisioning.test.ts` holds a
starting thread's provisioning open and asserts startup recovery still
finishes. It fails without the fix (`startup must not wait for thread
provisioning to finish: expected false to be true`) and passes with it.
- `turbo run test --filter=@bb/server -- startup-thread-provisioning
startup-machine-recovery periodic-sweeps item-sweep periodic-sweep-jobs
thread-live-start-handoff environments/provider-orchestration` passes.
- `turbo run typecheck lint --filter=@bb/server` passes.
- The real data dir that hung starts once the patch is applied (see
below).
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.

Server fails to start while a machine setup is pending: the startup sweep waits 60 s, the launcher's health limit

2 participants