← Back to Pull requests

fix(daemon): a person's turn stays held for its Stop when the bridge's waiter expires mid-turn #4185

Closed
unknown closed this pull request without merging on Nov 29, 2026 23:36 UTC
View on GitHub
unknown unknown commented on Nov 29, 2026 19:29 UTC
Author

What a user gets


On a Claude seat that opted in to the hook bridge, a message waiting while the person's turn runs is delivered at the turn's end through the bridge, even when the bridge's waiter reaches its own deadline mid-turn. Before, the expiry handed it to typing into the running turn.

What changed


  • HookBridge.live() stays true for a person's turn after its waiter expires, when three things hold:

  • - UserPromptSubmit recorded the turn before the waiter expired;
    - the seat is opted in;
    - its waiter had armed.

    The turn's Stop then arms a new waiter, which delivers at the boundary.

  • The 15-minute turn bound still counts from the turn's start. With no Stop (Claude Code doesn't run Stop on an interrupt or an API error), the message is typed at the bound, with the expiry as its reason.

  • Unchanged:

  • - a waiter that expires while the seat is idle, or before a turn began, is typed after the 20 s live bound;
    - stale and never-armed waiters, opted-out seats, another occupant's messages, ordering, the typing guard and effect reconciliation.
  • docs/reference/seat-delivery.md states both cases and the cost.
  • Timing (a person's turn; its waiter expires mid-turn)


    | | Before | After |
    |---|---|---|
    | The turn's Stop arrives | typed into the running turn at the next 5 s sweep, once the message has waited 20 s (within seconds of the expiry for one queued earlier) | delivered by the new waiter at the Stop; nothing typed |
    | No Stop | the same | typed at the turn's start + 15 min |

    The cost: an opted-in seat whose Stop hook stops reporting can get a message up to the rest of the turn's 15 minutes later than before.

    Tests


  • hook-bridge.test.ts:

  • - the hold, through to the Stop's delivery;
    - the missing-Stop path, typed exactly at the turn's start + 15 min;
    - a turn begun after the expiry, and an opted-out seat, aren't held.
  • session-transport-hook-bridge.test.ts: the pending-at-expiry case is split in two.

  • - An idle seat's expiry: typed after the live bound, under the typing guard, with the expiry as its reason, as before.
    - A person's turn: held for the Stop. A new send during the turn is bridged, nothing is typed, and with no Stop it's typed at the bound.
    - A preference-switch test no longer starts an incidental turn.
  • Red on main: 4 fail.

  • Green: 76 of 76; the 13 daemon test files that use the bridge, 641 of 641; daemon tsc; npm run test:repo.
  • Not covered


    A dialog that opens between a typed message's last input check and its Enter. This change only stops this path typing into a held person's turn.

    Refs #3270

    🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    Messages queued during a person’s turn remain queued after the delivery waiter expires. A Stop can re-arm delivery; otherwise, messages fall back to typing at the turn’s original 15-minute deadline.
    A new prompt can end the wait sooner and start typed fallback. Turns that begin at or after waiter expiry retain the existing fallback behavior.
    If the waiter expires while idle or before a turn, queued messages retain the 20-second typed fallback.
    Documentation
    Clarified message delivery behavior when the waiter expires during or around a turn.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 437 lines (+327 / -110) across 5 files Reviewer: mvschwarz Review duration: 246m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 437 lines diff across 5 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.364
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #4185"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.2% (MEDIUM) · Higher = larger blast radius
    50.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.8% · Safe to merge
    19.8%