GeezerVison is showing github.com — fix(server): serialize scheduled task run transitions by juliusmarminge · Pull Request #21793 · pingdotgg/t3code
Conversation
Stack: #21791 → #21792 → #21793.
Problem
A scheduled-task definition can change between its due read and reservation or between dispatch and completion. Runs should reserve and complete using a consistent live definition without overwriting a newer edit.
Change
A task edit can commit between the scheduler’s due read and reservation, or between dispatch and completion. Read the live definition and write each reservation, completion, missed-run reschedule, and stuck-run release inside its write transaction. Keep provider execution outside the transaction and guard cleanup by the reservation timestamp. Manual runs recheck the live trigger and project before launching.
Scope and approval
Maintainer takeover of @saphid’s #11592, announced in the takeover comment. This stack rebuilds the same atomic-edit and scheduler concurrency scope against current main. The publishing maintainer, @juliusmarminge, is listed in the explicit maintainer triage exemptions; contribution eligibility is separate from correctness approval. This work remains unmerged and subject to current-head CI and human review.
Verification
Rebuilt from @saphid’s #11592.
After integrating main, bottom scheduler/webhook suites pass 44/44 and the full integrated scheduler/webhook suites pass 47/47. The project-ownership regression covers three timings: before the request, before the dispatch re-read, and immediately before the reservation update. The last timing failed before the predicate fix and passes now. On this layer its hook injects a synthetic nested mutation inside the write transaction; it checks the defensive predicate and rollback, not physical independent-connection contention.
Web/mobile builder suites were rerun and pass 72/72. Targeted service/test lint and the integrated server-only typecheck pass. Earlier web/mobile typechecks and MCP/contracts/runtime checks passed. No repository-wide checks were run.
The takeover adds 26 cases in five existing files (738 added/4 removed primary test lines), replacing the original 66 cases/2,071 lines. Main integration retains one additional existing webhook retry regression; it is not counted as a new takeover test. An earlier broader focused run passed 123 cases before later parameterized regressions; that broader run was not repeated.
This is the third takeover layer. The client layer embeds web proof captured before the nonvisual reservation fix and main integration, which leave those scheduler save flows unchanged. No live provider was launched for scheduler proof; native platforms, process-interruption injection, actual older-server runtime, relay/tunnel runtime, and physical multi-connection SQLite contention were not exercised.
Three independent review rounds addressed binding-mode, live-trigger, legacy-interval, model-selection, and project-scope findings. A later bot finding exposed a move between the dispatch re-read and reservation update. One additional timing case reproduced it, and the reservation now also matches the expected project. The fourth independent round (Claude Opus 5.5 and GPT-6 Sol) found no additional code blockers in each individual layer or the complete stack. Main was then integrated to retain its webhook acceptance claim cleanup; the fixture conflict preserves both incoming retry coverage and takeover credential/binding coverage. The fifth independent round (Claude Opus 5.5 and GPT-6 Sol) found no additional code blockers in each layer or the combined stack against the integrated main base. Current-head CI and bot reassessment remain required.
Implementation: GPT-6.1 Sol (high), Codex harness through T3 Code. Tests: GPT-6 Astra (high), Codex. Independent review: Claude Opus 5.5 and GPT-6 Sol through T3 Code.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
juliusmarminge
changed the title
scheduler tasks 05/dispatch transactions
fix(server): serialize scheduled task run transitions
Oct 19, 2026
Approvability
Verdict: Approved at 78fa3e5
Macroscope's review found this PR approvable — This is a focused scheduler concurrency fix that serializes task-definition reads with run-state transitions and guards completion against stale reservations. The production change is localized, keeps provider execution outside database transactions, and includes targeted regression tests.
No code changes detected at 169c0f3. Prior analysis still applies.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Oct 19, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
7ac4c01c-10a2-4a68-882c-0ca443a0b769
📥 Commits
-
Reviewing files that changed from the base of the PR and between bc26b21 and 78fa3e5.
📒 Files selected for processing: 2
-
apps/server/src/scheduledTasks/ScheduledTaskService.test.ts
apps/server/src/scheduledTasks/ScheduledTaskService.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
📝 Walkthrough
-
Scheduled task reservation, completion, failure recovery, and missed-run rescheduling now check current task state within transactions. Regression tests cover task changes during reservation and completion.
Changes: Scheduled task execution
| Layer / File(s) |
Summary |
Validate and reserve runs apps/server/src/scheduledTasks/ScheduledTaskService.ts, apps/server/src/scheduledTasks/ScheduledTaskService.test.ts |
Reservation rereads and validates the task before marking a run as running. Tests cover project changes and webhook conversion before reservation. |
Record completion and recover failed runs apps/server/src/scheduledTasks/ScheduledTaskService.ts, apps/server/src/scheduledTasks/ScheduledTaskService.test.ts |
Completion rereads the task in a transaction. Failure recovery updates only the matching running attempt. A test checks that a pause committed before completion is preserved. |
Reschedule missed runs apps/server/src/scheduledTasks/ScheduledTaskService.ts |
Missed-run rescheduling proceeds only when the current task remains enabled and its next-run time and schedule match the polled snapshot. |
Priority: ⬇️ Low
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Suggested reviewers: maria-rcks
Merge Risk: ⚪ Minimal · up to 78fa3
-
No confirmed issue blocks merging after normal checks.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title is concise, specific, and accurately describes the main change: serializing scheduled task run transitions. |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
| Description check |
 |
The pull request includes all required sections: Problem, Change, Scope and approval, and Verification. It describes the concurrency issue, implementation, maintainer approval context, focused test re… |
Full details: Description check
-
Explanation
The pull request includes all required sections: Problem, Change, Scope and approval, and Verification. It describes the concurrency issue, implementation, maintainer approval context, focused test results, limitations, and agent details.
✨ Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Thread transfer impact
✅ Thread transfer remains within every enforced ceiling.
ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.
| Provider |
Metric |
Main baseline |
This PR |
Impact |
PR ceiling |
|
| Codex |
Total thread wire |
— |
5.0 KiB |
— |
6.8 KiB |
✅ |
| Codex |
Thread snapshot wire |
— |
3.8 KiB |
— |
4.9 KiB |
✅ |
| Codex |
Live turn WebSocket wire |
— |
1.2 KiB |
— |
2.0 KiB |
✅ |
| Codex |
Live turn WebSocket decoded |
— |
20.9 KiB |
— |
29.3 KiB |
✅ |
| Codex |
Live turn messages |
— |
2 |
— |
8 |
✅ |
| Claude |
Total thread wire |
— |
5.0 KiB |
— |
6.8 KiB |
✅ |
| Claude |
Thread snapshot wire |
— |
3.8 KiB |
— |
4.9 KiB |
✅ |
| Claude |
Live turn WebSocket wire |
— |
1.2 KiB |
— |
2.0 KiB |
✅ |
| Claude |
Live turn WebSocket decoded |
— |
21.2 KiB |
— |
29.3 KiB |
✅ |
| Claude |
Live turn messages |
— |
2 |
— |
8 |
✅ |
Baseline: unavailable · PR result: 169c0f3 · Source CI: success
Scenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Complete saphid's atomic scheduling intent by reserving scoped runs and updating completion schedules under SQLite write transactions.
Note 🤖 Claude Opus 5.5 responding on behalf of Theo
#28474 merged as ce9e016. It moves the activeRuns reservation in runTask into an Effect.acquireUseRelease at the end of the function, so this PR now conflicts in runTask. When you rebase, keep the run body in the bracket's use step so an interrupt still releases the reservation.
Verified by two focused tests that fail on the old main, plus all 102 scheduled task tests and CI on the merged head.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 3, 2026
This was referenced Nov 6, 2026
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
macroscope-review
Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews
size:L
100-499 changed lines (additions + deletions).
vouch:trusted
Author is trusted by repo permissions or the VOUCHED list.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|