Skip to content

mode:start can queue after the thread becomes active while its host is suspended #3987

Closed

Description

@AlexeySapsay

Summary

A mode: "start" send can be evaluated from a stale idle Thread object after the persisted thread status has become active. When the host is suspended, dispatch currently checks host readiness first and queues host-offline instead of returning thread_not_writable/already_active. The dispatcher should refresh thread state and reject the stale start before the host-wait path.

Versions and environment

Source checkout based on 7c54dbf7d4ecf9fc818c96e15fe059edeae1d52f (bb-app 0.43.3), Ubuntu 24.04. The affected order is still unchanged on current main at c00623d16ea93bbf18779f4f2b3062d956fe82ea; I have not rerun the full suite on that newer SHA.

Steps to reproduce

  1. Seed a provider-backed thread and retain its initial idle row as the request snapshot.
  2. Set the backing host to phase: "suspended".
  3. Apply run.started so the persisted thread becomes active, while keeping the stale idle snapshot.
  4. Call acceptThreadSendRequest with the stale snapshot and { mode: "start" }.
  5. Inspect the result and queued messages.

A deterministic regression test is included in the linked fork commit.

Expected vs actual

Actual: dispatch enters the suspended-host path, queues the message with `waitingOn: { kind: "host-offline" }`, and requests host readiness. The caller does not receive the active-thread conflict.

Expected: dispatch refreshes thread state first and returns HTTP 409 with `code: "thread_not_writable"` and `details.reason: "already_active"`. `queue-if-active` must keep its existing host-wait behavior.

Evidence

Patch and regression tests: AlexeySapsay@f81db13

The patch moves the current-thread freshness check and explicit mode: "start" active-thread rejection before host readiness handling. It also verifies that queue-if-active still waits for a suspended host. Targeted regression tests passed 2/2; the adjacent dispatch group passed 30/30.

What you ruled out

  • Not caused by the client adapter: the wrong wait outcome is produced inside server dispatch.
  • Not a generic suspended-host bug: queue-if-active should still wait and has a regression test.
  • Exact searches for already_active host-offline and queue-if-active suspended found no open or closed duplicate issue.

AGENT GENERATED — implementation and evidence: AlexeySapsay@f81db13

Suggested priority and effort (optional)

Medium. No data loss. A start request can receive incorrect queued semantics and wait on host readiness. Workaround: refresh state and avoid sending mode:start to an active thread.

Checks

  • I reproduced this on the latest release or on main, or I say above that I could not.
  • I searched open and closed issues for the same problem.
  • If an agent wrote this, the body ends with > AGENT GENERATED and links the thread or report.

Activity

  1. added theissue type on Sep 22, 2026
  2. added
    threads
    confirmed-repro
    on Sep 22, 2026
  3. bb-slop-cop commented on Sep 22, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Classification: Bug · Priority: Medium · Effort: Low · threads.

    Reproduction report: REPRODUCED, high root-cause confidence; label: confirmed-repro.

    Host readiness queues the message before refreshing thread state and rejecting an explicit start on an active thread. The regression failed in two clean trusted-main checkouts for both stale and fresh snapshots; the queue-if-active control passed.

    Fix: PR #4038 — ready, not merged. Two files, 120 changed text lines. All 118 relevant tests, server typecheck, and diff checks passed after the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reprothreads

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions