fix(server): scheduled tasks for No project launch in a scratch folder #17451
main fromrefs/pull/17451/head·merged by juliusmarminge View on GitHubScheduled tasks for “No project” failed during workspace preparation because Scratch is a plain folder and worktree requests attempted Git operations there.
Scheduled saves now store Scratch worktree requests as root. Launches also normalize that strategy before allocating the existing per-thread Scratch folder, so tasks already saved with worktree mode start working without being re-saved. Fresh launches persist their allocated folder as existing_worktree for preparation retries. Ordinary Git-project worktrees keep their existing behavior.
Fixes #17309. Original implementation and tests by @Mnigos in #17451. Maintainer takeover retained the small service implementation and three behavior tests, merged current main without rewriting contributor history, and trimmed redundant comments.
Verification at fe977ecb27:
- With the save/launch fix reverted, all 3 regressions fail: direct Scratch launch has no folder, save retains
worktree, and an existing saved task’s run fails preparation. With production restored, 146 tests pass across 8 affected files. - Regressions cover save normalization, direct launch, previously saved tasks, persisted preparation and setup path, and unchanged Git-project worktree behavior. Real filesystem detector assertions remain in the existing ManagedProjectFolders suite.
- Scoped lint and formatting pass. One existing test-file lint warning remains outside the diff. Server typecheck passes.
- Independent full-diff review round 1: GPT-6-Sol and Claude Opus 5.5 found no blockers. Opus also reran the Scratch subset: 11 cases passed in 2 files. Current-head CI is monitored separately from older author-head results.
Headless Linux service verification uses the real scheduling, launch, and persistence paths with mocked Git and managed-folder boundaries; the folder suite separately exercises real filesystem behavior. Provider execution is disabled, so a run reaching starting proves preparation released, not provider completion. No fully integrated real-filesystem scheduler run or live-provider/client run is claimed. macOS, Windows, iOS, Android, and Electron desktop were not exercised. There is no visual UI change, so screenshots do not apply.
Existing corner case, outside this fix: if the server crashes after thread creation but before message dispatch, replay can persist root preparation even while the thread has a bound folder; a subsequent preparation failure and retry can fall back to the shared Scratch root. Normal fresh launches persist the corrected folder.
This handles Scratch only. It does not change arbitrary non-Git projects or repair already-failed run preparation; starting a new run of an existing saved task uses the corrected path. The PR remains unmerged.
Models: GPT-6-Astra (tests), GPT-6.1-Sol (implementation), GPT-6-Sol and Claude Opus 5.5 (review). Harnesses: Codex and Claude Code through T3 Code.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
fe977ecMacroscope's review found this PR approvable — This is a focused server-side bug fix that converts invalid worktree requests only for the non-Git Scratch project into the existing per-thread Scratch-folder flow. Existing Git-project behavior remains unchanged, and direct, scheduled, legacy-task, and isolation cases are covered by tests.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
309c0018-d181-4628-9460-20f0506324df
📥 Commits
-
Reviewing files that changed from the base of the PR and between 8943fcceb81e8ac57c384de15b7e65c2db37601c and 991f9e33602ec490f2dd9544cddf94a0b3c4a623.
📒 Files selected for processing: 4
-
apps/server/src/orchestration-v2/ThreadLaunchService.test.tsapps/server/src/orchestration-v2/ThreadLaunchService.tsapps/server/src/orchestration-v2/runtimeLayer.tsapps/server/src/scheduledTasks/ScheduledTaskService.interval.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
-
📝 Walkthrough
-
The managed-folder service now identifies Scratch projects. Thread launches and scheduled-task upserts convert requested worktree strategies to root strategies for Scratch projects. Tests cover Scratch and Git project behavior and provide the added service dependency.
Changes: Scratch workspace handling
Layer / File(s) Summary Identify Scratch projects
apps/server/src/project/ManagedProjectFolders.ts,apps/server/src/project/ManagedProjectFolders.test.tsManagedProjectFoldersexposesisScratchProject. It returns false when Scratch is unavailable and otherwise compares the project’s resolved workspace root with the Scratch root. Tests check Scratch and non-Scratch IDs.Handle Scratch launches as root workspaces
apps/server/src/orchestration-v2/ThreadLaunchService.ts,apps/server/src/orchestration-v2/ThreadLaunchService.test.tsThreadLaunchService.launchconverts a Scratch worktree request to a root request. Tests check managed-folder use for Scratch and worktree creation for a Git project.Normalize scheduled-task workspace strategy
apps/server/src/scheduledTasks/ScheduledTaskService.ts,apps/server/src/scheduledTasks/*test.ts,apps/server/src/scheduling/Scheduler.integration.test.ts,apps/server/src/orchestration-v2/runtimeLayer.ts,apps/server/src/orchestration-v2/ClaudeAutomaticDelivery.integration.test.ts,apps/server/src/orchestration-v2/ThreadLaunchService.test.tsScheduled-task upserts store rootfor Scratch projects that requestworktreeand preserve other strategies. The service wiring and test layers provideManagedProjectFolders. Tests also cover execution of a stored Scratch task with worktree strategy.Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers:
juliusmarminge
Merge Risk: ⚪ Minimal · up to
991f9-
Scratch launches and subsequent scheduled dispatch retain the assigned folder. No merge-blocking issue is identified; proceed with normal checks.
Security architecture risk: 🔵 Low · up to
991f9-
Previously failing Scratch tasks can now execute in dedicated thread folders. The change retains existing project, thread and execution-mode controls. No introduced security issue was identified, but historical failed-run recovery and live execution behavior remain limitations.
Retained concerns No architecture-level concerns identified.
Security review details
-
Security Blast Radius
- inferred — The changed execution reachability concerns Scratch worktree requests, including automated tasks that previously failed before provider startup. The inspected change retains the requested runtime mode and actor attribution rather than granting a different execution mode.
Trust Boundaries and Controls
- observed — Normalization remains ahead of the existing clone-state, project-resolution and enabled-provider checks. Reusing a thread requires an empty active thread in the target project, and receipt recovery checks project identity.
Resilience and Maintainability Implications
- observed — Scratch directory names use sanitized text and thread identifiers. Exclusive directory creation treats an existing name as a collision and selects another candidate, avoiding accidental folder sharing between concurrent allocations. These are existing controls reused by the new path, not an operating-system sandbox.
-
Pre-merge checks:
4-
Check name Status Explanation Linked Issues check Issue #17309concerns scheduled tasks for Scratch ("No project") failing when worktree creation is enabled.ThreadLaunchServiceconverts Scratchworktreelaunches toroot, and `ManagedProjectFol…Out of Scope Changes check The changes support issue #17309.ManagedProjectFolders.isScratchProjectcentralizes the existing Scratch-root check. Runtime-layer and test-fixture updates provide the new service dependency. The a…Title check The title uses a conventional prefix and clearly identifies the main fix for scheduled tasks launched in a Scratch folder. Description check The description explains the problem, implementation, scope, linked issues, verification results, limitations, and testing environment. It does not use the template headings, but it contains the requi… Full details: Linked Issues check
-
Explanation
Issue
#17309concerns scheduled tasks for Scratch ("No project") failing when worktree creation is enabled.ThreadLaunchServiceconverts Scratchworktreelaunches toroot, andManagedProjectFolders.folderForThreadprovides the per-thread Scratch folder.ScheduledTaskService.upsertstores Scratchworktreestrategies asroot, which also corrects new and updated tasks. The reported tests cover direct launches, existing stored tasks, upserts, Scratch detection, and unchanged Git-project worktrees.
Full details: Out of Scope Changes check
-
Explanation
The changes support issue
#17309.ManagedProjectFolders.isScratchProjectcentralizes the existing Scratch-root check. Runtime-layer and test-fixture updates provide the new service dependency. The added tests verify Scratch behavior and preserve Git-project behavior. The review evidence shows no unrelated feature or non-Scratch non-Git handling.
Full details: Description check
-
Explanation
The description explains the problem, implementation, scope, linked issues, verification results, limitations, and testing environment. It does not use the template headings, but it contains the required information and is sufficiently complete.
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
coderabbitai[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge added labelsmacroscope-review
We're hitting this too, on 0.1.1-nightly.20261017 (macOS). Two unbound
schedule_tasktasks in No project (one every 4 hours, one weekly) failed every run inGitWorkflowService.remoteExistson~/.t3/scratch, and the scheduler still recorded them assucceeded(#17889). We've paused both until a fix lands.We'd like to see this PR merged over #18583. Converting the strategy at launch means tasks already saved with a worktree start working without anyone re-saving them, and that's what we need.
One gap it leaves: other projects that aren't Git repos (for example the old per-environment Chat project, whose root is a plain temp folder) fail the same way. Could the launch-time check later cover any project whose root isn't a Git repo, not just Scratch?
juliusmarminge assignedjuliusmarminge
Taking over this one as maintainer for batch scheduler-tasks-03. I will retain the contributor commits and verify Scratch scheduled-task saves and existing-task launches in separate test, implementation, and review passes. This batch will not merge the PR.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged this1db05fa
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed