fix(server): stop both completion-wake task cohorts #15331
main fromrefs/pull/15331/head·merged by juliusmarminge View on GitHubStopping a completion-wake run disposes its incoming completion cohort, but tasks delegated during that wake can still deliver another completion. Stop now disposes both cohorts through the existing orchestrator path, reading pending events between disposals. Ordinary runs dispose their one cohort once; the broader holdQueue Stop behavior stays intact.
Fixes #15325. Rebuilt from @matsvarn’s #15331, preserving the original commits and merging current main.
Verification:
- Replaced the original regression with one lifecycle scenario in the existing
DelegatedCompletionDelivery.test.ts: both cohorts stop, incoming results survive, a late child result stays available without another wake, and newer user work remains unchanged. - Exact main: 20 passing cases and the new regression failing (
undefinedwake-cohort disposition, expectedstopped). Temporary minimum proof: all 21 pass. Candidate: all 21 pass; together withThreadStop.test.tsandBackgroundWorkStop.integration.test.ts, 65 tests pass. Server package typecheck, scoped type-aware lint, formatting and diff checks passed (two existing lint warnings). Independent full-diff Opus and Sol reviews found no code issues (one round). - Primary focused candidate rerun: ran the new lifecycle scenario against the final candidate successfully (1 passed, 20 unrelated cases skipped). The scenario exercises persisted Stop and late-completion outcomes; this is service-level verification, not a live provider demonstration.
- The test runs the real orchestrator and persistence services with deterministic provider boundaries. No UI changes; screenshots do not demonstrate this server behavior.
- Not verified with a real provider interrupt, remote/relay/tunnel connection, Electron desktop, macOS, Windows, iOS, or Android.
Models and harness: tests by Codex gpt-6-astra; implementation by Codex gpt-6.1-sol; independent reviews by Claude Opus 5.5 and Codex gpt-6-sol. T3 Code delegation through the Codex and Claude Agent harnesses.
- 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:S
Approvability#
Verdict: Approved at
be98547Macroscope's review found this PR approvable — This narrowly scoped server fix reuses the existing cohort-disposal path to stop both cohorts created by a completion wake, while leaving ordinary and hold-queue behavior unchanged. A focused lifecycle test covers late results and preservation of newer work.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Warning
Review limit reached#
Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.
Next included review available in 10 seconds.
View limit details
-
Limit details: You’ve used all 10 included reviews currently available.
Review configuration:
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
cf4b5ef1-19b8-4ea3-af67-84e6458e63a0
📥 Commits
-
Reviewing files that changed from the base of the PR and between d2120010593e8befd5821421f4bfb106c3a39b64 and be985477a3b5dcfde737b494e2d113c964e4a0b7.
📒 Files selected for processing: 2
-
apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.tsapps/server/src/orchestration-v2/Orchestrator.ts
-
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
0317decc-7885-408e-aeaa-7e97de328ee4
📥 Commits
-
Reviewing files that changed from the base of the PR and between a21702d0e58ad20263dc965d84472bb6d7eb38c8 and d2120010593e8befd5821421f4bfb106c3a39b64.
📒 Files selected for processing (2)
-
apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.tsapps/server/src/orchestration-v2/Orchestrator.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
📝 Walkthrough
-
When a delegated-completion wake run is interrupted, the orchestrator now disposes delegated completions for both the wake run and its owning run. A test checks the delivery and run dispositions.
Changes: Delegated completion interruption
Layer / File(s) Summary Dispose the completion cohort
apps/server/src/orchestration-v2/Orchestrator.ts,apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.tsThe interruption path processes the wake run and its owning run, reloading each projection with pending events before disposing the cohort. The test checks that the new task’s delivery is disposed and both runs have disposition stopped.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
juliusmarminge
### Architecture SummaryMerge Risk: ⚪ Minimal · up to
d2120-
The interruption fix is ready to merge after normal checks.
Architecture risk: 🟡 Medium · up to
d2120The change affects 1 system.
Changed systems:
apps/serverArchitecture concerns No architecture-level concerns identified.
Review details
-
Systems and components
- observed — apps/server (service) was modified; 2 changed files map to changed impact.
Before / after behavior
- observed — Modified behavior in apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts: Adds a test that seeds a claimed incoming task, starts its completion-wake run, creates a new task in that run, and interrupts it. The assertions expect the new task’s delivery to be disposed and both the wake run and origin run to be stopped.
- observed — Modified behavior in apps/server/src/orchestration-v2/Orchestrator.ts:
stopCompletionCohortnow processes both the delegated completion’s parent run (when present) and the interrupted run, instead of disposing only the single parent-or-current run previously selected. For each, it reloads the projection with pending events and disposes the cohort with dispositionstopped.
Reliability and maintainability
- inferred — Risk-relevant change factors for apps/server: blast_radius_1; direct_dependents_1
Pre-merge checks:
5-
Check name Status Explanation Docstring Coverage No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2… 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. Title check The title clearly and concisely identifies the main fix: stopping both completion-wake task cohorts. Description check The description explains the problem, the implementation, linked issue context, focused verification, test results, and known limitations. Although it does not use every template heading explicitly, i… Full details: Docstring Coverage
-
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.
Full details: Description check
-
Explanation
The description explains the problem, the implementation, linked issue context, focused verification, test results, and known limitations. Although it does not use every template heading explicitly, it provides the required information in a mostly complete form.
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
juliusmarminge added labelsmacroscope-review
juliusmarminge assignedjuliusmarminge
Taking over this one. I’ll port the Stop cleanup to current main, keep a focused regression test, and run independent reviews before pushing here. Thanks @matsvarn for isolating the bug.
juliusmarminge changed the title
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged this6cd6372
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed