← Back to Pull requests

fix(daemon): a claim's stall finding goes to its owner first, then once to its orchestrator #4144

Closed
unknown closed this pull request without merging on Nov 29, 2026 11:51 UTC
View on GitHub
unknown unknown commented on Nov 29, 2026 08:08 UTC
Author

A stuck-sweep finding about a claimed row (stalled after its claim, or past its close-by time) went to the owner's orchestrator first. The pickup module's own contract says "routed to the claimant first, then its orchestrator", and only the owner can say whether its work is moving, so the orchestrator was left to investigate a row it didn't hold. Once filed, a finding was only refreshed: one that nobody answered never moved on. And working activity held a claim off stalled-after-claim with no limit, so "busy" could hide a stopped claim indefinitely.

The change

Owner first. A finding about a claim goes to the row's owner, with the evidence #3999 added (the held-message count and a dated context sample). Its text now says:

  • answer on the row itself (a note, a park, a handoff or a close): that moves the row's stall clock, and the sweep closes the finding; picking the finding up also counts;

  • who hears next, and when, or that no orchestrator is declared and it stays with the owner;

  • a row whose work was folded into another row is the owner's to close or hand off: a mention in another row doesn't close it.
  • Straight to the orchestrator when the owner can't act on it:

  • the owner is waiting on input (a permission prompt or a question), as today;

  • the owner is confirmed missing: its orchestrator first, then the existing recovery seats (the operator agent, the operator seat, the row's creator). Before, a missing owner's overdue claim went straight to the recovery seats;

  • the owner is a seat stopped on purpose (the stop #4133 now reports), which only something else can start.
  • The existing no-wake re-routes (no wake route, a terminal seat) are unchanged.

    Once, when unanswered. An owner's finding that's still unclaimed after the wake ladder's suppression window (30 min by default; no new setting), on a row that's still stuck, is handed to the owner's orchestrator: its delegates_to parent, or its escalates_to route (the moved finding then carries the one-hop tag). An owner's finding also moves at once if the owner starts waiting on input, goes missing or is stopped. The moved finding is addressed to the orchestrator, so it never moves again. With no orchestrator, it stays with the owner.

    "Busy" has a ceiling. Working activity holds a claim off stalled-after-claim for up to 4 hours (WORKING_ACTIVITY_CEILING_MINUTES, the workflow deadline's fallback for a step with no closure_required_at). It's counted from the claim's last meaningful queue change, as the background-shell grace is. Past it, the stall is read and its finding goes to the owner first, so a false positive costs a busy owner one message, and any note on the row answers it. An explicit closure_required_at stays the claim's deadline (overdue-claim, unchanged). Callers without a timestamp keep their count rule.

    What doesn't change

  • No new setting, guard or activity classifier, and nothing reads another row's body.

  • Unclaimed, undelivered, wait-notice and parked-owner findings route as before.

  • A context percentage isn't read as a full context. With no positive sign that the owner can't act, an unanswered finding moves on the bound instead.
  • Downstream effect (the queue artery)

  • Who's woken: a claim's first finding wakes the owner, not the orchestrator. The orchestrator is woken 30 min later if the owner hasn't answered, or at once when the owner can't act.

  • Closing: unchanged. A queue change on the row closes the finding, whichever seat holds it.

  • Docs: docs/reference/edge-types.md and docs/as-built/architecture/coordination-primitive.md say where a claim's finding goes.

  • Scenario: there's no stub-agent scenario for the stuck sweep. The new tests run the real repository, SQLite, handoff and wake-intent store. A live-daemon journey on a test machine, compared with the published release, follows on this PR.
  • Tests

  • New queue-stuck-sweep-owner-first.test.ts (15 cases): owner first with the held count and the dated sample; the one move after the bound, and none after it; an answer on the row; picking the finding up; no orchestrator; an owner waiting on input, from the start and later; a missing owner and a missing orchestrator; a stopped owner, from the start and later; an overdue claim; a folded row; and the working ceiling, in the sweep and in derivePickup. On main (aa40675d), 13 fail; the 2 that pass pin behaviour main already has (waiting on input goes to the orchestrator; callers without a timestamp).

  • Two existing tests updated, each for the new route:

  • - queue-stuck-sweep.test.ts, "#2758 new recovery uses the current source scope after the sweep awaits another row's wake": it used the orchestrator resolver as its listing-time probe, and owner first no longer asks it at listing, so the probe reads the row's first getById instead.
    - quiet-waiting.test.ts, "a failed notice escalates once within pickup grace plus sweep…": the blocker's own stall finding now goes to its owner first and, unanswered, moves once to the orchestrator 40 min later. That move is the one new send it now asserts; the waiter's notice still doesn't re-send.
  • Ran on Linux (Node 22), on a test machine:

  • - the new file: 15/15 on aa40675d with this change, and 13 red without it;
    - the 43 daemon test files that touch the sweep or the pickup rule (1162 tests), green with the two updates above, on e85e704c before #4133 and before the stopped-seat case;
    - tsc --noEmit for the daemon, clean on aa40675d with this change;
    - the full daemon suite on aa40675d with this change is running; its result follows as a comment.
  • This branch is based on 6e6ae7b2; the two commits after aa40675d (#4118 and #4138) touch none of these files.
  • Refs #331

    🤖 Generated with Claude Code

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

    Summary by CodeRabbit

    New Features
    Stuck-claim findings go to the task owner first, with immediate routing to an orchestrator when the owner is missing, stopped, or waiting for input.
    Unanswered findings are handed off once after an answer window of at least 30 minutes, or twice the queue wake retry interval if longer. Meaningful task changes restart the window; notes do not change an accepted closure deadline.
    Working activity delays stalled-claim findings only up to a ceiling measured from the last meaningful task change. A task note can answer a finding while work remains active.
    Repeated detections reuse the existing finding without rerouting it.
    Documentation
    * Clarified claim routing, escalation timing, and fallback routes.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mvschwarz Review duration: 223m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.57 · 650 lines diff across 8 files
    0.57
    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.388
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #4144"
    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: 57% (MEDIUM) · Higher = larger blast radius
    57%
    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: 22.5% · Safe to merge
    22.5%