Add orch strict worktree dispatch

This commit is contained in:
2026-03-19 13:52:51 +08:00
parent 07f4a6fdae
commit 1b0cd723d7
9 changed files with 776 additions and 48 deletions
+28 -8
View File
@@ -25,10 +25,11 @@ As of now:
- an inbox skill forward-test plan directory now exists under `docs/tests/inbox-skill/`, with a shared execution template and multiple scenario cases
- an execution-roadmap workflow now exists under `docs/roadmaps/active/` and `docs/roadmaps/archive/` for agent-level work traces and completion archives
- `orch` now implements `run init/show`, `task add`, `dep add`, `ready`, `dispatch`, `reconcile`, `blocked`, `answer`, and `status`
- `orch` can create runs, gate tasks through dependencies, dispatch work through `inbox`, reconcile worker thread state back into task state, and answer blocked tasks
- automated integration tests now cover the main `orch` scheduler slice, including dependency gating, dispatch, blocked-answer flow, and reconcile
- `orch` can create runs, gate tasks through dependencies, dispatch work through `inbox`, reconcile worker thread state back into task state, answer blocked tasks, and create per-attempt Git worktrees during strict dispatch
- `orch dispatch` now supports `--repo-path`, `--workspace-root`, and `--strict-worktree`, resolves committed base revisions, records workspace metadata on attempts, and writes that metadata into inbox task payloads
- automated integration tests now cover the main `orch` scheduler slice, including dependency gating, dispatch, blocked-answer flow, reconcile, strict worktree creation, and dirty-repo rejection rules
This means the project now has a working `orch` core scheduler and is ready for strict worktree-backed execution support.
This means the project now has a working `orch` core scheduler plus strict worktree-backed dispatch, and is ready for leader-side wait/retry/reassign follow-on work.
## Source Of Truth
@@ -69,9 +70,10 @@ Current implementation status:
- `Milestone 2: Shared DB Layer` is complete enough for both CLIs
- `Milestone 3: Inbox Happy Path` is complete
- `Milestone 4: Orch Core Scheduling` is complete for the current non-worktree scheduler scope
- `Milestone 5: Strict Worktree Support` is complete for the current explicit dispatch worktree mode
- `Milestone 6: Waiting Primitives` is partially complete through `inbox wait-reply`
The next practical coding target is `Milestone 5: Strict Worktree Support`.
The next practical coding target is `Milestone 6: Waiting Primitives`.
### Milestone 1: Go Skeleton
@@ -239,7 +241,6 @@ Completed so far:
Remaining:
- strict worktree provisioning on dispatch
- `orch wait`
- retry, reassign, cancel, and cleanup workflows
@@ -260,6 +261,24 @@ Definition of done:
- a code task dispatch creates a real worktree
- the assigned worktree path appears in attempt metadata and inbox payload
Status:
- completed for the current explicit `orch dispatch` worktree mode
Completed so far:
- `orch dispatch` can use `--repo-path` to target a source Git repository without relying on the caller's current working directory
- `orch dispatch --strict-worktree` resolves `base_ref` to a concrete commit, defaults to `HEAD` on clean repositories, and rejects dirty repositories when `--base-ref` is omitted
- dispatch creates a fresh branch and Git worktree per attempt and persists `base_ref`, `base_commit`, `branch_name`, `worktree_path`, and `workspace_status`
- dispatch writes workspace metadata into the inbox task payload for worker runtimes
- reconcile now advances `workspace_status` from `created` to `active`, `completed`, or `abandoned` based on thread state
- CLI integration tests cover strict worktree creation, explicit-base dispatch on dirty repos, and strict dirty-repo rejection
Remaining:
- automatic code-task detection so worktree mode can be selected without explicit flags
- `orch cleanup` for removing completed or abandoned worktrees
### Milestone 6: Waiting Primitives
Goal:
@@ -299,11 +318,11 @@ Definition of done:
If a new agent is taking over now, the next concrete step should be:
1. start `Milestone 5: Strict Worktree Support`
2. add real worktree metadata population to `orch dispatch`
1. start `Milestone 6: Waiting Primitives`
2. implement `orch wait` over the run-scoped event stream
3. keep the authored inbox test-plan set in `docs/tests/inbox/` synchronized if CLI behavior changes during further `orch` work
The inbox implementation and its human-readable test-plan set are already in place, and the initial `orch` scheduler loop now exists, so the next meaningful project step is to isolate code-writing attempts in real worktrees.
The inbox implementation and its human-readable test-plan set are already in place, and `orch` now supports strict worktree-backed dispatch, so the next meaningful project step is to give the leader a blocking wait primitive and finish the remaining scheduler controls.
## Recommended Driver Choices
@@ -326,6 +345,7 @@ Completed so far:
- inbox workflow lifecycle coverage
- orch scheduler lifecycle coverage for run/task/dependency/dispatch/reconcile
- orch blocked-question and answer coverage
- orch strict worktree creation and dirty-repo policy coverage
Still recommended before the codebase grows too much:
+3
View File
@@ -177,6 +177,7 @@ Suggested flags:
- `--run RUN_ID`
- `--task TASK_ID`
- `--to AGENT`
- `--repo-path PATH`
- `--base-ref REF`
- `--workspace-root PATH`
- `--strict-worktree`
@@ -186,6 +187,7 @@ Suggested flags:
Behavior:
- creates a new attempt
- resolves the source repository from `--repo-path` or the current working directory
- resolves a committed base revision
- creates a branch and worktree for the attempt when the task writes code
- creates or links an `inbox` thread
@@ -197,6 +199,7 @@ Strict-mode recommendation:
- if `--base-ref` is omitted and the repository is clean, default to `HEAD`
- if `--base-ref` is omitted and the repository is dirty, fail dispatch
- if `--base-ref` is provided, resolve it to a commit and use it exactly
- if `--workspace-root` is omitted in worktree mode, default to `.orch/worktrees` under the source repository
### `orch reconcile`
@@ -0,0 +1,63 @@
# Orch Strict Worktree Support
## Status
- `completed`
## Owner
- codex
## Started At
- `2026-03-19`
## Goal
- implement dispatch-time strict worktree support so `orch` can resolve a committed base, create a branch and worktree per attempt, and persist workspace metadata into attempt storage and inbox payload
## Scope
- extend `orch dispatch` to support Git-backed worktree creation
- enforce strict-mode base resolution and dirty-repo checks
- persist `base_ref`, `base_commit`, `branch_name`, `worktree_path`, and `workspace_status`
- add integration tests for successful worktree dispatch and strict-mode rejection on dirty repositories
- update project-level implementation roadmap after the work is validated
## Checklist
- [x] inspect current worktree design docs and dispatch constraints
- [x] implement git helpers for repo discovery, base resolution, branch naming, and worktree creation
- [x] wire worktree metadata into `orch dispatch` attempt storage and inbox payload
- [x] add integration coverage for strict worktree success and dirty-repo failure
- [x] run `go test ./...`
- [x] update `docs/implementation-roadmap.md`
- [x] archive this roadmap with completion summary
## Files
- `docs/roadmaps/archive/orch-strict-worktree-support.md`
- `docs/implementation-roadmap.md`
- `internal/cli/orch/dispatch.go`
- `internal/cli/orch/integration_test.go`
- `internal/cli/orch/worktree.go`
- `internal/store/orch.go`
## Decisions
- use the current working directory as the default source repo for `orch dispatch`, with an explicit override flag only if implementation needs it
- keep worktree creation tied to dispatch so failed workspace creation cannot silently leave a task marked as dispatched
## Blockers
- none
## Next Step
- implement `orch wait`, then continue with retry/reassign/cancel/cleanup on top of the now worktree-aware dispatch model
## Completion Summary
- `orch dispatch` now supports strict Git-backed worktree provisioning with repo discovery, committed base resolution, branch naming, and per-attempt worktree paths
- dispatch persists workspace metadata on attempts and includes the same metadata in inbox task payloads for worker runtimes
- integration tests now cover successful strict worktree creation, dirty-repo rejection without `--base-ref`, and explicit-base dispatch on dirty repositories
+1
View File
@@ -60,6 +60,7 @@ This keeps worker execution reproducible and avoids hidden divergence from the l
For one task attempt, `orch` should:
- resolve the source repository from the caller context or an explicit repo-path override
- pick a `base_ref`
- create an attempt record
- choose a branch name