Add sub-task self-landing coordinator flow#145
Open
brooksc wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Dependency
This PR is based on #138 (
terminal-hmr-lifecycle). PR138 preserves task PTYs across renderer remounts; this PR builds on that terminal lifecycle work and does not reimplement it. Until #138 lands, this PR is stacked on top of that branch.Problem
Coordinator mode was spending too much attention on successful sub-tasks. The OpenSpec goal is to let one coordinator manage larger batches of routine sub-tasks without one coordinator interaction per completed task. Before this change, the coordinator had to inspect completion, decide whether verification was real, merge the branch, close the task, and keep track of interleaved task state.
That led to several concrete failures during testing:
get_task_statusstill reportedrunning.land_self/signal_donetools after restore/hydration because MCP launch args were not rebuilt correctly.mainin one run, despite the spec requiring the coordinator branch as the default base.Design Principle
The core architecture is the OpenSpec split:
The sub-task knows what it changed and what verification it ran. The backend knows how to merge safely in the coordinator worktree under the existing repo lock, clean up the child task, and update renderer state. The sub-task should not run raw
git merge; the backend should.Fix
Added the
land_selfhappy path for sub-tasks. A sub-task can now commit its work, report structured verification, and ask the backend to land it. On success, the backend merges into the coordinator branch, records landed metadata, strips backend-owned injected artifacts, removes the sub-task worktree/branch/MCP config, and closes the child task.Made
land_selfterminal from the sub-task agent’s perspective. A successfulland_selfdoes not requiresignal_done,merge_task, orclose_task. The completed child disappears from the active task list unless cleanup failed.Added guarded automerge checks.
land_selfrejects missing, blocked, failed, or unknown verification; dirty worktrees; orphaned tasks; invalid ownership; branch/worktree mismatch; merge conflicts; and cleanup failures. Cleanup failures stay visible because they still need attention.Preserved manual coordinator landing.
merge_taskremains available for manual-review/escalated paths, but backend rejects normal coordinator merges for still-running tasks unless they are in an allowed manual-review or landing-escalation state.Tightened active-task ownership guidance. Coordinator instructions now say
get_task_statusis authoritative: if a sub-task is stillrunning, route fixes throughsend_promptand let the sub-agent fix, test, commit, and land. Manual takeover requires a stated reason and evidence.Fixed MCP restore for Codex sub-tasks. Hydrated/restored Codex tasks now rebuild inline MCP launch args so
land_selfandsignal_doneremain available. Claude/Docker.mcp.jsonflows are still allowed to rely on config-file discovery.Fixed prompt/control handoff. Coordinator-created sub-tasks start in coordinator control, and automatic handoff to human control is suppressed during startup/auto-trust/recent prompt echo cases. The coordinator instructions/tool descriptions also warn not to resend assignments just because a stale placeholder like
Improve documentation in @filenameis visible.Fixed stale desktop notifications. Pending task-error/needs-input notifications are reconciled against current task state and removed if the task recovers or is removed before the notification fires.
Fixed base-branch behavior. Coordinator MCP registration now carries the coordinator task branch, and backend
create_taskdefaults childbaseBranchto that coordinator branch when the tool omits an override. The coordinator prompt andcreate_tasktool docs now describe that default explicitly.Verification
nice git diff --check origin/terminal-hmr-lifecycle..HEADnice /Users/brooksc/.codex/skills/parallel-code-pr/scripts/run-pr-verification.shnpm run checknpm test: 64 test files, 1086 passed, 12 skippednpm run checkandnpm testsuccessfully.Notes
Known unrelated static checks are unchanged:
lint:deadreports existing Knip findings.lint:archreports existing store dependency cycles.Runtime log review of
/tmp/parallel-code-20260524-222023.outfound no new unfixed Parallel Code issue beyond the already-fixedbaseBranch=mainbehavior.