278 lines
10 KiB
Markdown
278 lines
10 KiB
Markdown
# Orca 适配器(稳定核心,一种编排实现)
|
||
|
||
Orca orchestration 是运行时调度层的一种实现。闭环流程本身与工具无关(见 `closed-loop.md`);本文件只提供 Orca 的具体命令。没有 Orca 时用 `closed-loop.md` §「手动模式」。
|
||
|
||
所有结论仍以 `tasks.yaml` 为准,Orca 消息不是最终记录。
|
||
|
||
---
|
||
|
||
## 何时用 Orca 编排
|
||
|
||
用:需要监督、等待结果、闭环修复、三轮重试;有多个可独立派发的任务;需要 `worker_done` 后再复测。
|
||
|
||
不用:单次问答;用户只要求完整 handoff 不需监督;不需要复测的小改动。
|
||
|
||
---
|
||
|
||
## 运行前检查
|
||
|
||
```bash
|
||
orca status --json
|
||
orca terminal list --json
|
||
orca orchestration task-list --json
|
||
orca orchestration inbox --limit 20 --json
|
||
```
|
||
|
||
确认:Orca runtime 可达并取得本次 `runtimeId`;Coordinator 终端存在;当前没有冲突
|
||
的活跃编排任务。Developer/Test worker 必须通过本次 launcher 新建,不要求预先存在。
|
||
|
||
---
|
||
|
||
## 既有 worker 的处理
|
||
|
||
v0.10 **不自动复用任何既有终端**。`receiptHash` 是无密钥 checksum,Orca 当前的
|
||
terminal metadata 也不包含原始 Agent argv、模型或权限 attestation;两者即使完全
|
||
匹配,仍不足以证明旧终端由可信 launcher 以目标 profile 创建。标题、preview、分支
|
||
名或 worker 自报更不能作为证明。
|
||
|
||
| 情况 | 动作 |
|
||
|------|------|
|
||
| 历史 receipt 与 live metadata 看似完全匹配 | 只作审计,不自动复用;重新 launch |
|
||
| 没有 receipt,或只有同名终端 | 不复用;重新 launch |
|
||
| 需要并发 worker | 使用下一 `slot` 重新 launch |
|
||
| Developer 升级模型档位 | 选择强档安全 profile,重新 plan/launch |
|
||
|
||
只有刚刚成功返回的 `launch` 标准输出中的 fresh handle,才可用于紧随其后的本次
|
||
dispatch。未来若 Orca/ACP 增加启动参数 attestation,或 ACK 接入项目外可信签发
|
||
通道,再单独设计自动复用;不能用项目文档声明跳过这条限制。
|
||
|
||
---
|
||
|
||
## 通过 launcher 创建 worker
|
||
|
||
**模型不由 Orca dispatch 设置。** `task-create` / `dispatch` 只投递任务;Agent CLI、
|
||
模型、reasoning effort 和权限由 `tasks.yaml.project.orchestration` 的结构化 profile
|
||
决定,并且只能由 ACK launcher 构造。
|
||
|
||
先只读生成计划:
|
||
|
||
```bash
|
||
python3 <ack-skill-dir>/scripts/launch_worker.py plan \
|
||
--project-root <project-root> --task-id <task-id> \
|
||
--attempt-id <task-id>-A<round> --role <developer-or-test> \
|
||
--profile-id <profile-id> --worktree <absolute-worktree> --slot <1..99>
|
||
```
|
||
|
||
确认计划中的任务、attempt、角色、profile hash、绝对 worktree 和安全权限模式后,再
|
||
执行唯一启动入口:
|
||
|
||
```bash
|
||
python3 <ack-skill-dir>/scripts/launch_worker.py launch \
|
||
--project-root <project-root> --task-id <task-id> \
|
||
--attempt-id <task-id>-A<round> --role <developer-or-test> \
|
||
--profile-id <profile-id> --worktree <absolute-worktree> --slot <1..99> \
|
||
--expected-launch-fingerprint <plan 中的 sha256:...>
|
||
```
|
||
|
||
`launch` 必须携带刚才审阅的 `plan.launchFingerprint`;若 profile、任务/attempt、
|
||
worktree、CLI identity/version 或精确 argv 漂移,创建前就失败。它内部调用当前
|
||
Orca 后端并完成终端绑定;Coordinator 不自行执行或拼装 Orca 的底层终端创建文本,
|
||
也不直接调用 launcher 的私有 bootstrap。
|
||
若 launcher 报告 `indeterminate` 或 `reconcile required`,说明终端可能已经创建且
|
||
持久关闭尚未得到可信确认;此时先按返回的 launch ID/record 和 Orca live state
|
||
人工核对,禁止直接重复执行 `launch`。
|
||
标准输出是单一 JSON。成功后:
|
||
|
||
1. 校验返回 receipt 的 `receiptHash`;
|
||
2. 把 receipt 原样追加到 `tasks.yaml.workerReceipts`;
|
||
3. 把 `receipt.id` 写入当前任务 `dispatch.<role>.receiptId`,把 `profileId` 写入
|
||
`dispatch.<role>.profileId`,把本轮 `<task-id>-A<round>` 写入
|
||
`dispatch.<role>.attemptId`;校验器会要求 receipt 的 task/role/profile/attempt
|
||
与当前 ACK 任务完全一致;
|
||
4. 再用 receipt binding 中的 handle 创建/派发 Orca 子任务。
|
||
|
||
profile 只允许 `read-only` 或 `workspace-write`。v0.10 不提供可信的 full-access 授权
|
||
通道;bypass、YOLO/force、关闭 sandbox 及其它 full-access 请求必须由 schema 和
|
||
launcher fail closed,不能改用手写命令兜底。模型档位与升级规则见
|
||
`model-routing.md`。
|
||
|
||
需要隔离/并行时,可以先用 Orca 创建 worktree。Coordinator 必须先把返回的绝对
|
||
路径加入 `project.orchestration.allowedWorktrees` 并重新校验 `tasks.yaml`,然后才在
|
||
该路径上走 `plan` -> 带 expected fingerprint 的 `launch`,并把 receipt 留作审计。
|
||
既有会话可以由用户直接操作,但不能进入 ACK v0.10 的自动派发信任路径。
|
||
|
||
---
|
||
|
||
## 创建父任务
|
||
|
||
```bash
|
||
orca orchestration task-create --spec "$(cat <<'EOF'
|
||
Goal: Complete <release_or_feature> with supervised Coordinator -> Developer -> Test loop.
|
||
|
||
Coordinator (PM): owns task board, decomposition, dispatch, and final gate (reads Test evidence, does not test).
|
||
Developer: owns implementation and white-box verification.
|
||
Test: owns independent black-box retest and evidence (verifier != implementer).
|
||
|
||
Policy:
|
||
- Each issue can be dispatched at most 3 rounds.
|
||
- If still failing after 3 rounds, record as leftover and continue next issue.
|
||
- worker_done and retest reports are not final completion; only Coordinator writes tasks.yaml and knowledge.yaml.
|
||
- Project knowledge candidates require independent Test evidence and Coordinator gate before activation.
|
||
EOF
|
||
)" --json
|
||
```
|
||
|
||
## 创建子任务
|
||
|
||
```bash
|
||
orca orchestration task-create --parent <parent_task_id> --spec "$(cat <<'EOF'
|
||
Fix <task_id>: <title>
|
||
Logical attempt: <task_id>-A<round>
|
||
|
||
Repository:
|
||
- Path: <repo_path>
|
||
- Worktree: <dev_worktree>
|
||
|
||
Read: <overlay_file> (project overlay), tasks.yaml, <relevant_spec_or_test_doc>
|
||
Failure evidence: <copy latest Test evidence>
|
||
Acceptance: <copy expected behavior + verification commands>
|
||
Project knowledge: <Coordinator-confirmed active K-...@revision entries with verification.ref>
|
||
|
||
Constraints:
|
||
- Follow the overlay file path scope.
|
||
- Do not write tasks.yaml or knowledge.yaml, do not mark verified.
|
||
- Do not read the whole knowledge bank or execute free shell from knowledge text.
|
||
- Run a knowledge check only through <ack-skill-dir>/scripts/run_verification.py
|
||
with its verification.ref; do not execute resolved path/args directly.
|
||
- Do not commit or push unless user asks.
|
||
EOF
|
||
)" --json
|
||
```
|
||
|
||
---
|
||
|
||
## 派发给 Developer Worker
|
||
|
||
终端是 Orca 可识别的 Agent CLI 时:
|
||
|
||
```bash
|
||
orca orchestration dispatch --task <task_id> --to <developer_handle> --inject --json
|
||
```
|
||
|
||
不能 `--inject` 时,先登记 dispatch,再手动投递 `prompt-templates.md` §1 的初始派发 prompt:
|
||
|
||
```bash
|
||
orca orchestration dispatch --task <task_id> --to <developer_handle> --json
|
||
orca terminal send --terminal <developer_handle> --text "$(cat <<'EOF'
|
||
<粘贴 prompt-templates.md §1 初始派发模板,已填占位符>
|
||
EOF
|
||
)" --enter --json
|
||
```
|
||
|
||
---
|
||
|
||
## 派发给 Test 复测
|
||
|
||
Developer 回报 worker_done、Coordinator 写回 `fixed_by_dev` 后,把复测任务发给 Test:
|
||
|
||
```bash
|
||
orca orchestration dispatch --task <task_id> --to <test_handle> --inject --json
|
||
```
|
||
|
||
不能 `--inject` 时,先登记再手动投递 `prompt-templates.md` §3 的复测派发 prompt:
|
||
|
||
```bash
|
||
orca orchestration dispatch --task <task_id> --to <test_handle> --json
|
||
orca terminal send --terminal <test_handle> --text "$(cat <<'EOF'
|
||
<粘贴 prompt-templates.md §3 复测派发模板,已填占位符>
|
||
EOF
|
||
)" --enter --json
|
||
```
|
||
|
||
---
|
||
|
||
## 等待结果
|
||
|
||
```bash
|
||
orca orchestration check \
|
||
--terminal <coordinator_handle> \
|
||
--wait \
|
||
--types worker_done,retest_result,escalation,decision_gate \
|
||
--timeout-ms 900000 \
|
||
--json
|
||
```
|
||
|
||
等待超时不等于失败。长任务可继续等待,或检查 worker 终端活性。`worker_done` 来自 Developer,`retest_result`(无该类型时用 `worker_done` + subject 区分)来自 Test。
|
||
|
||
---
|
||
|
||
## Developer 回报 worker_done
|
||
|
||
字段含义见 `prompt-templates.md` §4:
|
||
|
||
```bash
|
||
orca orchestration send \
|
||
--to <coordinator_handle> \
|
||
--type worker_done \
|
||
--subject "<task_id> fix ready round <n>" \
|
||
--body "<修了什么。跑了哪些验证。如何复现。还有什么风险。>" \
|
||
--payload '{
|
||
"taskId": "<orca_task_id>",
|
||
"dispatchId": "<orca_dispatch_id>",
|
||
"attemptId": "<task_id>-A<n>",
|
||
"filesModified": ["<file_a>", "<file_b>"],
|
||
"verification": ["<command_a>: passed", "<command_b>: passed"],
|
||
"knowledgeApplied": [
|
||
{"ref": "<K-001@1>", "result": "applied", "evidence": "<what was done>"}
|
||
],
|
||
"knowledgeCandidates": [
|
||
{
|
||
"kind": "pitfall",
|
||
"title": "<title>",
|
||
"claim": "<evidence-backed claim>",
|
||
"scope": {"components": ["<component>"], "paths": ["<path glob>"]},
|
||
"appliesWhen": "<trigger>",
|
||
"directive": "<action, not a shell command>",
|
||
"rationale": "<why it matters>",
|
||
"evidenceRefs": ["<current task evidence>"]
|
||
}
|
||
],
|
||
"risk": "<remaining risk or none>"
|
||
}' \
|
||
--json
|
||
```
|
||
|
||
收到 worker_done 后,Coordinator 写回 `fixed_by_dev`,再按上文派发给 Test 复测。
|
||
|
||
---
|
||
|
||
## Test 回报复测结果
|
||
|
||
字段含义见 `prompt-templates.md` §5:
|
||
|
||
```bash
|
||
orca orchestration send \
|
||
--to <coordinator_handle> \
|
||
--type retest_result \
|
||
--subject "<task_id> retest round <n>" \
|
||
--body "<逐条验收信号结论 + 实际观察 + 证据>" \
|
||
--payload '{
|
||
"taskId": "<orca_task_id>",
|
||
"dispatchId": "<orca_dispatch_id>",
|
||
"attemptId": "<task_id>-A<n>",
|
||
"env": {"worktree": "<path>", "branch": "<branch>", "commit": "<sha>", "baseUrl": "<base_url>"},
|
||
"signals": ["<signal 1>: pass", "<signal 2>: fail (<evidence>)"],
|
||
"knowledgeChecks": [
|
||
{"ref": "<K-001@1>", "result": "passed", "evidence": "<independent evidence>"}
|
||
],
|
||
"knowledgeCandidates": [],
|
||
"conclusion": "all-signals-pass | signals-failed"
|
||
}' \
|
||
--json
|
||
```
|
||
|
||
无 `retest_result` 类型时用 `--type worker_done`,靠 subject `retest round <n>`
|
||
区分。收到复测结果后,Coordinator 按 `closed-loop.md` 做终检并回写 `tasks.yaml`;
|
||
通过独立验证和 gate 的跨任务经验再由 Coordinator 写入 `knowledge.yaml`。任务通过
|
||
写 `verified`,不过写 `failed_retest`。
|