orch: require explicit dispatch execution mode

This commit is contained in:
2026-03-20 19:27:30 +08:00
parent 7840b2767f
commit 5859ff219e
43 changed files with 277 additions and 312 deletions
+19 -11
View File
@@ -53,12 +53,12 @@ Those belong to `inbox`.
## Workspace Model
For code-writing tasks, `orch` should allocate one Git worktree per attempt.
For `--execution-mode code`, `orch` should allocate one Git worktree per attempt.
Strict policy:
- dispatch from a concrete committed `base_ref`
- fail dispatch if strict mode is enabled and the leader is implicitly relying on uncommitted state
- fail dispatch if the leader is implicitly relying on uncommitted state
- create a fresh worktree for every retry
- do not let workers edit the user's primary checkout
@@ -180,23 +180,24 @@ Suggested flags:
- `--run RUN_ID`
- `--task TASK_ID`
- `--execution-mode analysis|code`
- `--to AGENT`
- `--repo-path PATH`
- `--base-ref REF`
- `--workspace-root PATH`
- `--strict-worktree`
- `--body TEXT`
- `--body-file PATH`
Behavior:
- creates a new attempt
- automatically enables strict worktree mode for code-like tasks inferred from task metadata when worktree flags are omitted
- 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
- requires the caller to choose `--execution-mode analysis|code`
- in `analysis` mode, stays thread-only and does not allocate a worktree
- in `code` mode, resolves the source repository from `--repo-path` or the current working directory
- in `code` mode, resolves a committed base revision
- in `code` mode, creates a branch and worktree for the attempt
- creates or links an `inbox` thread
- writes workspace metadata into attempt storage and task payload
- writes `execution_mode` into the inbox task payload and writes workspace metadata for code tasks into attempt storage and task payload
- moves the task to `dispatched`
- does not start a worker runtime on its own
@@ -205,7 +206,7 @@ Integration note:
- a higher-level Codex bridge may save this JSON output, render a worker brief, and then spawn a worker sub-agent
- that bridge should remain outside the core `orch` runtime so the scheduling contract stays portable
Strict-mode recommendation:
Code-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
@@ -416,7 +417,7 @@ Default behavior:
`orch` should be implemented as a control plane on top of `inbox`.
- `orch dispatch` writes the first `task` message into `inbox`
- `orch dispatch` also writes worktree metadata for code tasks into the attempt record and inbox payload
- `orch dispatch` also writes `execution_mode` into the inbox payload and writes worktree metadata for code tasks into the attempt record and inbox payload
- workers claim and update status through `inbox`
- `orch reconcile` reads thread state and converts it into task state
- `orch answer` writes an inbox `answer` message to the active thread
@@ -459,6 +460,12 @@ Suggested success shape:
"base_commit": "abc1234",
"branch_name": "orch/blog_mvp_001/T4/attempt-1",
"worktree_path": ".orch/worktrees/blog_mvp_001/T4/attempt-1"
},
"message": {
"kind": "task",
"payload_json": {
"execution_mode": "code"
}
}
}
```
@@ -602,6 +609,7 @@ Use this skill when you are the leader and need to control the task graph throug
- Reconcile inbox state before making new dispatch decisions.
- If nothing is actionable, use `orch wait` instead of manual sleep loops.
- For code tasks, dispatch from a committed base and allocate a fresh worktree per attempt.
- Choose `--execution-mode analysis` for read-only or review work and `--execution-mode code` for repository-writing work.
- Keep tasks small enough to be checkable and to minimize clarification loops.
- Use `inbox` directly only for inspection or manual repair.
- Keep user-facing discussion in the leader.
@@ -613,7 +621,7 @@ orch run init --run blog_mvp_001 --goal "Build blog MVP" --summary "Public blog
orch task add --run blog_mvp_001 --task T1 --title "Project skeleton" --summary "Initialize app structure and database wiring" --default-to foundation-worker --json
orch dep add --run blog_mvp_001 --task T2 --depends-on T1 --json
orch ready --run blog_mvp_001 --json
orch dispatch --run blog_mvp_001 --task T1 --to foundation-worker --base-ref main --workspace-root .orch/worktrees --strict-worktree --body-file tasks/t1.md --json
orch dispatch --run blog_mvp_001 --task T1 --execution-mode code --to foundation-worker --base-ref main --workspace-root .orch/worktrees --body-file tasks/t1.md --json
orch reconcile --run blog_mvp_001 --json
orch wait --run blog_mvp_001 --for task_blocked,task_done,task_failed --after-event 0 --timeout-seconds 900 --json
orch blocked --run blog_mvp_001 --json