feat(ack): reclaim verified worker terminals via script after round end

This commit is contained in:
2026-08-23 23:14:29 +08:00
parent 5a906f24fa
commit 1c52a3996c
5 changed files with 468 additions and 22 deletions
+23 -13
View File
@@ -321,19 +321,29 @@ orca orchestration send \
## 整轮结束时回收 worker
只有 Coordinator 已把本轮最终结论写入 `tasks.yaml` 后才开始回收。先按 receipt 的
`binding.handle` 聚合任务引用:只有一个 handle 关联的全部任务都为 `verified`,且没有
未解决环境事件,才允许关闭。`open`、`dispatched`、`fixed_by_dev`、`retesting`、
`blocked`、`failed_retest`、`leftover` 以及状态不明任务关联的 handle 全部保留,不设置
TTL。普通用户 Shell 和 Coordinator 自己的终端不在回收范围。
只有 Coordinator 已把本轮最终结论写入 `tasks.yaml` 后才开始回收。统一使用回收脚本,
不要手工逐个 close
逐个回收时:
```bash
# 第一步:dry-run 审阅决策(不关闭任何终端)
python3 <ack-skill-dir>/scripts/reclaim_workers.py --project-root <project-root>
1. `orca terminal show --terminal <handle> --json`,把 runtimeId、handle、incarnationId
和 worktree 与 receipt 逐项核对;不匹配就停止并报告。
2. `orca terminal close --terminal <handle> --tab --json`。
3. 核对关闭回执的 runtimeId、handle、tab 和关闭模式,再确认终端不在 live list。
4. 关闭结果不确定时保留记录并报告,禁止盲目重试或标记为已回收。
# 第二步:审阅输出后真正回收
python3 <ack-skill-dir>/scripts/reclaim_workers.py \
--project-root <project-root> --apply
```
关闭终端不删除 `workerReceipts`、dispatch 证据或测试记录;这些仍是审计事实。保留下来
的 blocked/failed worker 只在后续任务得到验证或用户明确要求清理时回收。
脚本按 receipt 的 `binding.handle` 聚合任务引用,规则固定:
- **关闭**:handle 关联的全部任务都为 `verified`,且没有未解决环境事件。
- **保留(不设置 TTL)**:任一关联任务处于 `open`、`dispatched`、`fixed_by_dev`、
`retesting`、`blocked`、`failed_retest`、`leftover`,或存在未解决
`environmentIncidents`,或 receipt 引用未知任务。失败三次的 worker(
`failed_retest` / `leftover` / `blocked`)按此保留。
- **不触碰**`workerReceipts` 之外的 handleCoordinator 终端、用户 Shell)。
`--apply` 时脚本对每个待关闭 handle 执行 `orca terminal show` 核对身份 →
`orca terminal close --tab` → 重新 `terminal list` 确认 handle 已消失;任何一步
不确定都保留并标记 `uncertain`,禁止盲目重试。关闭终端不删除 `workerReceipts`、
dispatch 证据或测试记录;这些仍是审计事实。保留下来的 blocked/failed worker 只在
后续任务得到验证或用户明确要求清理时回收。