feat(server): delegate tasks to another local project #28859
main fromrefs/pull/28859/head·opened View on GitHubProblem#
An agent in project A cannot use delegate_task to run a child in project B on the same environment. Launching a top-level thread instead loses the parent's completion wake. Allowing cross-project children also requires project removal to stop the delegated work it owns outside that project.
Change#
Allow local target.projectId through delegation, child creation, and destination provider checks. Shared children use the target root; worktrees use the target repository's cached primary-remote default-branch commit, without fetching. Accepted retries reuse the committed child's provider/model/options selection. Preserve completion wakes, status/cancellation, mode ceilings, and access declarations. Fenced linked callers cannot cross local project boundaries; missing or deleted destinations fail explicitly.
Removing a project deliberately stops the delegated work its threads started in other projects, including nested delegates. The event-sink transaction checks persisted owner tombstones when admitting children, tasks, and runs: work committed before deletion remains discoverable for recursive stopping; stale delegation and continuation commits after deletion roll back. Deletion durably queues recursive shutdown before cleanup. Ownership records survive failed shutdown and server restart, and purge waits for shutdown to succeed. The retained tombstone continues fencing descendants after ownership content is purged. Unrelated work in the destination project remains available.
The alternative is to reject project removal while descendant work is active or resumable, under the same admission fence. This PR chooses recursive shutdown; maintainers can change that behavior if they prefer rejection.
Scope#
Fixes pingdotgg/t3code#30329. Destination selection and delegated ownership belong together: moving the child to another project must preserve both its completion wake and its owner's lifecycle.
Verification#
vp run check:changed: format, lint, both knip checks, GraphQL generation, typecheck of 39 affected/dependent packages, and 378 tests in 18 files passed, including the agent-context budget.- Focused deletion/event-sink/maintenance/stop suites: 68 passed before the additional returning-owner case; the final changed-file run includes both topologies.
- Regression failed before the fence: a stale child commit succeeded after owner deletion. Coverage now checks project removal with a child in B and a nested delegate, stale delegation and continuation writes, A → B → A → B ownership, queue-resume rejection after deletion, held queued work, failed-shutdown ownership retention, purge after successful recursive stopping, post-purge admission rejection, and unrelated destination work.
- Full local server run: 10,131 passed, 14 failed, 40 existing skips across 563 files. Failures are in unchanged Git, macOS launcher, case-sensitive plugin-path, filesystem-watcher, and POSIX-shell tests. The Git-lane assertion also fails in isolation. Five missing-Chromium failures were resolved by installing the test browser and rerunning the preview suite: 114 passed. No tests were disabled.
- CI on
c74d6b84a3: all eight server shards, build/typecheck, lint, and agent-context budget passed. Web 2 failed beforeRightPanelTabs.browser.test.tsxconnected to Vitest's browser runner (Cannot connect to the server in 60 seconds); all 2,871 tests that ran passed. The affected file passes locally (4 tests). The aggregate Check failed because Web 2 failed. The rerun request was denied withMust have admin rights to Repository; an upstream maintainer needs to rerun the failed checks. - Prior delegation MCP eval dry runs covered seven relevant cases. No model-facing text changed in this lifecycle fix; live model evals remain unverified because the earlier runs lacked the required credentials/configuration.
Runtime observation through the real services: remove A → child and grandchild interrupted; stale child/run commits rejected; failed shutdown retains ownership; successful shutdown permits purge; subsequent descendant admission remains rejected.
Model: GPT-6.1 Sol. Harness: Codex.
- 1
- 2
- 3
Pushedbe4a541
github-actions[bot](GitHub profile, opens in a new tab) removed labelsneeds-rebase
Sign in to join this conversation.
This PR changes the test suite by +4 test cases (browser 0, unit 0, server +4; +792 test lines).
Proof of a fix is not automatically a permanent CI test—keep new tests only when they clear the keep bar in Testing.