-
Notifications
You must be signed in to change notification settings - Fork 5.1k
docs(orchestration): clean up created_child worktrees after worker-release #19404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -157,3 +157,37 @@ or `release_unknown`, follow its exact recovery action. Never substitute | |
|
|
||
| `orchestration reset` is destructive recovery. Do not run it during active | ||
| coordination unless the user explicitly abandons that state. | ||
|
|
||
| ## Worktree cleanup after release | ||
|
|
||
| After `worker-release` accepts, check whether that Dispatch's own `effects` | ||
| recorded `{ "kind": "worktree", "action": "created_child" }`: | ||
|
|
||
| ```text | ||
| ORCA orchestration worker-show --dispatch <dispatch_id> --json | ||
| ``` | ||
|
|
||
| If it did, remove the checkout Orca created for it, using the exact path from | ||
| that same response's `terminal.worktreePath`: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Technical details# Worktree cleanup path source
## Affected sites
- skill-guides/orchestration/references/recovery-and-cleanup.md:171 — reads terminal.worktreePath from a post-release worker-show response
## Required outcome
- The recipe must obtain the created_child worktree identity from a field that survives release. Prefer `worker.worktreeId` (and/or the `id` on the `created_child` effect) from the `worker-show --json` response, then `ORCA worktree rm --force --worktree id:<worktreeId> --json`.
- If keeping `terminal.worktreePath`, note it must be read from an inspection run before release (when the terminal is still exact), and is never available for structured workers.
## Suggested approach (optional)
- `exposeWorker` already publishes `worktreeId` (parsed from `worker.worktree_id`) and `effects`; both are durable DB values, independent of process liveness. The `id:` selector resolves via `orca-runtime-resolve-worktree-selector.ts`. |
||
|
|
||
| ```text | ||
| ORCA worktree rm --force --worktree path:<worktreePath> --json | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Preserve local work before force removal.
Also applies to: 187-188 |
||
| ``` | ||
|
|
||
| `--force` skips the dirty-tree confirmation prompt; it never force-deletes the | ||
| underlying Git branch. Leave the worktree in place and report it instead when | ||
| any of the following hold: | ||
|
|
||
| - The user asked to keep the workspace, or the Dispatch recorded | ||
| `worker-retain`. | ||
| - The terminal was user-taken-over. | ||
| - The recorded start effect was `reused`, or the worker started with | ||
| `--worktree current` or an exact pre-existing workspace — never delete a | ||
| checkout this Dispatch did not create. | ||
| - The worker STOP'd or failed with unpushed, local-only commits (check | ||
| `git status` first). | ||
| - `worktree rm` itself errors — a locked worktree or unverifiable Git state. | ||
|
|
||
| This is coordinator hygiene layered on top of release, not a substitute for | ||
| it: run it only after `worker-release` has already closed the terminal, and | ||
| only for the exact `created_child` worktree that Dispatch created. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Require a terminal-closed release state before cleanup.
orchestration.workerReleasecan returnstate: "retained"while the terminal remains retained. Command acceptance is not proof that the terminal closed. Requirestate: "released"or"already_released"beforeworker-showandworktree rm; routeretained,release_pending, andrelease_unknownthrough recovery. This guard is necessary becauseworktree rm --forcealso setsallowUnverifiedPtyStop.Also applies to: 177-177