fix(server): keep old failures from waking snoozed V2 threads - #9903
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a narrowly scoped server bug fix that prevents stale failures from waking snoozed threads, with regression tests covering the relevant timestamp cases. The production impact is limited to correcting automatic-settlement candidate filtering, with no schema, configuration, or sensitive-area changes. You can add or adjust custom eligibility rules. Learn more. |
b82facd to
2ac9bfe
Compare
60c1f1c to
ce9ecd9
Compare
…apping' into landing/pr-9903
There was a problem hiding this comment.
reviewed diff and relevant surrounding code at 669f993becd191d19d0e4923cdff47a602ec79f3. no blocking findings.
old, equal-time and absent completion timestamps keep the failed thread snoozed; later completion and expired snooze allow settlement. six isolated cases passed using the actual candidate function with the queued-turn guard stubbed false. no code changes needed. the full service suite was not rerun.
ci snapshot: no failing or pending checks; some checks are skipped. this is a comment review, not an approval or merge.
415ed0f
into
pingdotgg:t3code/codex-turn-mapping
A thread snoozed after a failed run can immediately become eligible for automatic settlement because V2 treats any failed status as a fresh wake-up.
Compare the failed run's completion timestamp with the snooze timestamp. Older failures, equal timestamps, and missing completion timestamps preserve the snooze; fresh failures and completed work can still wake it.
Validation: 11 focused settlement tests passed, including a regression that failed before the fix. Scoped typecheck and targeted lint passed. Cross-provider review was unavailable after the direct Claude Opus 5 high process failed OAuth authentication (exit 1, no model ran).
Targets the Orchestrator V2 branch in #2829. Implemented and reviewed by GPT-6 Astra in Codex/T3.
Note
Medium Risk
Changes eligibility for automatic thread settlement on snoozed threads, which can affect sidebar lifecycle timing but is scoped to one guard with new regression tests.
Overview
Snoozed Orchestrator V2 threads no longer become auto-settlement candidates just because
statusisfailed. The early-wake path inisAutoSettlementCandidatenow treats a failure as waking the thread only when the latest run completed after snooze started (or when there is nosnoozedAt). Pre-snooze failures, completion exactly at snooze time, and failed status with no completion timestamp keep the thread parked untilsnoozedUntil.Fresh failures after snooze and completion-based early wake are unchanged. Tests in
ThreadSettlementService.test.tslock in those edge cases.Reviewed by Cursor Bugbot for commit ce9ecd9. Bugbot is set up for automated code reviews on this repo. Configure here.
Current-base verification
Updated to V2 base
26a48b007at669f993becd191d19d0e4923cdff47a602ec79f3. Fresh focused regression runs pass (11 tests), along with targeted lint and affected package typechecks. The contribution files remain byte-for-byte identical to the previously reviewed PR head; this update incorporates the current target branch. Earlier verification above is retained with its original scope and limitations. Fresh independent Claude review is unavailable:claude auth statusreports signed out. Refreshed by GPT-6 Astra in the Codex harness.Note
Fix
isAutoSettlementCandidateso old failures don't wake snoozed V2 threadsChanges the failed-run early-wake condition in
isAutoSettlementCandidateso a failed snoozed thread only qualifies for auto-settlement when it has no snooze-start timestamp or its latest run completed strictly after that timestamp. Threads completed before or exactly at snooze time remain ineligible. Tests in ThreadSettlementService.test.ts cover the before, coincident, and absent-completion cases.Macroscope summarized 669f993.