queue: a retained wake never consumes a one-shot park timer, original or shared #1222
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
Real PR Conversation Timeline
1 comments
"Review active on #1222"
general
weight: 0.35
mvschwarz
What changes
A one-shot
--wake-afterpark timer whose wake is held back (aretaineddelivery: the typing guard kept it because the owner was typing) was not delivered. Until now the queue's wake records still treated that held-back attempt as the timer's one fire, which went wrong two ways:--wake-watchdog, after the original task was handed off or stopped. If the one wake to it was retained, the shared timer was retired at its next check, and the wake was lost.Now a retained attempt never consumes a one-shot wake, on the timer's own task or on a task attached to it.
retainedin its history, its backstop stays live, and nothing waits on the owner for an undelivered wake.None of this is a delivery guarantee, and nothing bypasses permissions, the typing guard or the outbox.
Also: a consumed shared one-shot is retired at once
When the original task has been handed off or stopped, and an attempt (delivered or failed) consumes the last attachment of its one-shot timer:
activeuntil its next check, and only then did the pre-delivery guard retire it. In that window,--wake-watchdogaccepted a new attachment to it: the attach checks only that the job is active and targets the parked owner. That new task got another wake.recordWatchdogWakeAttemptretires the job right after recording that attempt, with the guard's own reason (park_timer_target_terminal), when no current generated binding and no live attachment remain. So a--wake-watchdogattach after that point is refused withwake_watchdog_not_live, where main accepted it in that window.- this applies to non-queue-wait jobs only, so repeating queue-wait jobs keep their lifecycle;
- the timer's own-task path is unchanged;
- a retained attempt still leaves the attachment live, so it doesn't retire anything.
Where
queue-wake-repository.ts, for one-shot timers (theisRepeatingTimerfalse branches), plus the immediate retirement above inrecordWatchdogWakeAttempt(queue-repository.ts):findBlockedQitemsByWatchdog: aretainedfire no longer drops the row, so the attempt after it is recorded byrecordWatchdogWakeAttempt. For the timer's own task, that retires the job (park_timer_fired_once); for an attached task, it consumes the attachment.findLiveQitemsByAttachedWatchdog: aretainedfire no longer consumes an attachment, so the pre-delivery guard (resolveWatchdogPreDeliveryTerminalReason) lets the attached task's next attempt through. A failed fire still consumes a one-shot attachment, as a failed fire already consumes the timer's own task.getStatus: after aretainedfire the backstop staysliveand the wake isn'tunconsumed, whilephase: firedanddeliveryStatus: retainedkeep the history. Because the status is live, leaving the set-aside state, or a new park, retires the old timer at once, as it does before any fire.Unchanged:
Every caller of the two predicates:
recordWatchdogWakeAttempt(bindings and targets): records the post-retained attempt.retireParkGeneratedTimer(statusliveplus live attachments): an attachment with only retained attempts still protects the shared job, like an unfired one; the timer's own task now retires its timer on exit after a retained attempt.previousJobId): an attachment with only retained attempts blocks reuse of the shared job, like an unfired one.evaluateWaitReminder: queue-wait (repeating) only, so unaffected.Readers of the status (
live,unconsumed) after a retained one-shot attempt, which now see a live, not-yet-used timer:rig queue parkedno longer flags the row as unhealthy.The page (
docs/reference/keeping-a-watch.md) now says what the code does: a held-back wake doesn't use the timer up; it's tried again at each interval until an attempt goes through (delivered or failed), which retires it; the same rule applies to a shared timer's attached task; and none of this is a delivery guarantee.Tests
daemon/test/queue-park-wake.test.ts, through the realWatchdogScheduler(a test clock, one tick per interval), the queue's wake recorder and the status:- a retained attempt, then a delivery that retires it;
- three retained attempts then ok, and three retained then failed: each stays eligible, the last consumes it, and later ticks deliver nothing;
- the status after a retained attempt (
fired,retained,live, notunconsumed);- leaving the set-aside state retires it;
- a new park supersedes it, with no further delivery.
- a retained wake to the attached task, then a delivery that retires the job at that attempt;
- two retained, then failed, retired at that attempt;
- after the consuming attempt, a late
--wake-watchdogattach is refused (wake_watchdog_not_live).- a delivered or failed first attempt still retires after one (own timer and shared);
- a standalone operator watchdog keeps repeating;
- the existing repeating (queue-wait) retained test still passes.
Against main, the new retained, status, supersession and late-attach tests fail, and the controls pass.
Existing test expectations that changed (
queue-park-wake.test.ts), each for one-shot jobs only:<exit>" (repeating=false), for claim, handoff, handoff-and-complete, cross-host, complete, auto-unpark and re-park. These asserted the job staysactiveafter the attached task's delivery and is retired at the next evaluation. They now assert it'sterminalright after that delivery, with reasonpark_timer_target_terminal. Therepeating=truecases are unchanged.activeafter the attachment's delivery; it now assertsterminal. It still asserts that the pre-delivery guard let the attachment's wake through.Full gate on
a8bf206dagainst a fresh baseline at main005b0e05on the same box:npm run buildandnpm run lint: pass.npm test, branch / main:- repo checks: 290 / 290;
- CLI: 4,265 / 4,265 (3 skipped each);
- TUI: 941 / 941;
- daemon: 15,153 passed and 9 failed / 15,143 passed and 9 failed (the 10 new tests).
2c7ec6fe(the immediate retirement, added after the gate):queue-park-wake71/71, and the queue and watchdog suites (park-wake, wake, parked-query, queue-repository, watchdog, stuck-sweep, queue-wait) 435/435. Lint passes.stub-cli-journeysverified-send pair, which differ only in their generated ids and ports.A note on the commit log: the first commit (
1bbafe8c, the tests on their own) says a retained wake "fires once more". The final semantics replace that: a retained attempt is retried at the interval with no retry limit, until an attempt goes through. The test titles and this description use the final wording.Hermetic only. Native: NOT RUN.
🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
Bug Fixes
Periodic reminders held back while you are typing are retried at each interval. A one-time timer retires after a delivery succeeds or fails; repeating timers retain their retry behavior.
A shared watchdog remains active for its other task after a handoff or stop, and follows the same retry rule.
Documentation
* Clarified that these retry behaviors do not guarantee delivery.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->