Route CLI agents through a five-candidate chain with Codex last #648

Merged
weichen merged 14 commits from feature/cli-agent-fallback-chain into main 2026-10-20 08:01:14 +00:00
5 changed files with 468 additions and 48 deletions
@@ -0,0 +1,410 @@
# feature/cli-agent-fallback-chain 任务卡
任务主记录:PR #648 https://git-home.u1680832.nyat.app:30319/weichen/Agent-System-Dev/pulls/648;状态:已完成(合入前闭合);owner:weichen
## 基线与授权
- 权威仓:ssh://git@git-ssh.u1680832.nyat.app:31411/weichen/Agent-System-Dev.git;目标分支:main;R0(initial_base_sha)= d2035c76dc1cb15e01d2c184af5155d9d773cd9f
- 工作区:/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain(worktree);分支:feature/cli-agent-fallback-chain
- 分支类型:standalone;root_target:main;immediate_target:main;accepting_requirements:false
- 需求分流:verdict=NEW;selected_initiative=无;requirement_sha256=8817d4906061c95f5116cecb7e6b185dc6882b638ea71d2dde2db6e437903610;triage_receipt=/tmp/cli-fallback-chain-triage.json;receipt_sha256=555d302ea9cc489bc4b9ef51c0c5857332df08494cd57267646f93c1eabfaf7b
- 授权与交付终点:用户 2026-10-20 要求修改执行规范:CLI Agent 安全失败后不询问用户、自动换下一候选;候选为 cursor(auto)、agy(Gemini 3.8 Flash)、pi(GLM-5.3-flash)、pi(MiniMax-M3),前三类顺序不限,Codex(GPT-6.1-Sol) 必须最后;每候选 3 次,全部失败后暂停询问是否重试。授权范围内实施、验证、Review、PR 合入 Dev main 与安全收口。不改 DM 控制器、不部署、不发布版本、不改分支保护。
- 交付模式:goal-first(目标、范围和交付终点一次确认;范围内连续推进)
- 实施执行:agent-per-unit(配置:AGENT-EXECUTION.md)
- 合入执行:agent(已授权交付范围内,Review 通过、冲突解决且当前 HEAD 的 CI 通过后合入)
- 人工决策点:仅限目标/范围/验收变更、重大取舍、高后果操作或无法自动判定的业务验收
- 当前阶段:实施与自检;当前增量:I1(AGENT-EXECUTION.md 候选链 + 规范文字)
- 流程依据:仓库根目录 policy/delivery.md(归档后仍按仓库根目录定位)
## 目标与非目标
目标:`AGENT-EXECUTION.md` 的四个角色候选均为 cursor(`auto`)、antigravity(`gemini-3.8-flash-high`)、pi-glm(`zai-coding-cn/glm-5.3-flash`)、pi(`minimax-cn/MiniMax-M3`),codex(`gpt-6.1-sol`) 固定为最后候选;去掉 `emergency_profile`,`max_attempts_per_profile: 3` 对含 Codex 在内的每个候选生效。`policy/delivery.md`、`policy/governance.md`、`policy/tool-adaptation-matrix.md` 同步:安全可恢复失败自动换候选、不询问用户;Codex 之外的候选顺序可按角色调整但 Codex 必须最后;全部安全耗尽后 host 暂停并询问用户是否重试,仍不代写。
验收:`make agent-exec-validate` 通过;文档与机器块一致;PR HEAD 完整 CI 通过。
非目标:不改 DM 控制器(不实现运行时随机顺序;“顺序不限”由声明顺序满足);fail-stop 终态(`failed-unknown` 等)语义不变;不改 `deps/development-guidelines`。
## Agent 实施收据
路由与 fail-stop 规则见根目录 AGENT-EXECUTION.md 与 policy/delivery.md;每次尝试一行,原始日志留在源码外收据路径。
| 单元 ID | 预期范围 | 配置摘要 | 角色 | 候选顺序 | attempt | CLI/模型 | 终态 | transport | fallback | 源码外收据路径 |
|---|---|---|---|---|---|---|---|---|---|---|
| dev-cli-agent-fallback-chain | `AGENT-EXECUTION.md`、`policy/{delivery,governance,tool-adaptation-matrix}.md` | config_digest=d2e3574ebf5a…(run 时 AGENT-EXECUTION.md 为 R0 版本) | implementation | [cursor, antigravity, pi] | 1 | cursor-agent-stable / auto | completed (success) | refs/agent-exec/68343647…/536ff962e681 → 8e21b66db4606c20a1d7de4f1293fbcd61780658 | 否 | /tmp/cli-fallback-chain-receipt.json(单元包 /tmp/cli-fallback-chain-unit.json) |
## 关联方向与规划
- 适用状态:不适用(用户直接提出的执行路由调整,无对应规划条目)
- 主记录路径/版本:不适用
- 对应里程碑:不适用
## 需求分析
| ID | 描述 | 项目符合度及依据 | 优先级 | 验收条件 | 依赖 | 结论 |
|---|---|---|---|---|---|---|
| R1 | 五个候选(含第二个 PI 档与 Codex)各 3 次、Codex 最后、全部失败暂停询问 | 符合:控制器已按声明顺序对 `unavailable`/`failed-clean` 自动续跑;模型 ID 经本机冒烟(agy `gemini-3.8-flash-high`、pi `zai-coding-cn/glm-5.3-flash`、codex `gpt-6.1-sol` 均回 OK,SELF) | P2 | validate 通过;文档一致;CI 通过 | 无 | 接受 |
## 方案与计划
- 方案引用:纯配置:Codex 从应急档改为各角色最后一个正常候选(校验器禁止应急档进入普通角色列表,且应急档只跑 1 次,故不保留 `emergency_profile`);新增 `pi-glm` 档
- 实施计划引用:I1 / R1:单一 Agent 单元改 `AGENT-EXECUTION.md` 与三份 policy 文本
- 测试计划引用:R1:`make agent-exec-validate`;PR HEAD 完整 CI
## 阶段记录
| 阶段 | 对象版本 | 状态 | 决策/执行者 | 时间 | 依据 |
|---|---|---|---|---|---|
| 需求拆解 | d2035c7 | 已完成 | host | 2026-10-20 | 用户直接请求 |
| 需求评估 | d2035c7 | 已完成 | host | 2026-10-20 | R1 接受 |
| 需求表确认 | d2035c7 | 跳过 | — | 2026-10-20 | 用户请求已明确目标与验收,无取舍 |
| 方案设计 | 890313e | 已完成 | host | 2026-10-20 | 本卡方案与计划段 |
| 实施计划 | 890313e | 已完成 | host | 2026-10-20 | 本卡方案与计划段 |
| 实施与自检 | 8e21b66 | 已完成 | cursor-agent-stable | 2026-10-20 | Agent 实施收据表 |
| 正式测试与验收 | 8e21b66 | 已完成(SELF;GATE 待 CI) | host | 2026-10-20 | 证据表 |
| 代码 Review | 8e21b66 | PASS | host 主模型 | 2026-10-20 | 合入与清理段 |
| 合入 | 待定 | 待执行 | — | — | — |
| 合入核验与收口 | 待定 | 待执行 | — | — | — |
## 探索试验与迭代
| 增量/试验 | 假设 | 范围 | 判断和停止条件 | 授权/决策依据 | 结果 | 变更影响 | 需重审补测 |
|---|---|---|---|---|---|---|---|
| I1 | 纯配置即可实现五候选链、Codex 最后、每候选 3 次 | AGENT-EXECUTION.md + 3 份 policy | validate 与 CI 通过即停 | 用户直接请求 | 三个新模型 ID 冒烟回 OK(SELF);validate PASS | 全部角色路由 | 否 |
## 同步记录
| 节点 | sync_base_sha | tested_head_sha | checked_at |
|---|---|---|---|
| 启动 | d2035c76dc1cb15e01d2c184af5155d9d773cd9f | d2035c76dc1cb15e01d2c184af5155d9d773cd9f | 2026-10-20T05:56:50Z |
## 证据(Evidence)
<!-- CMD="<命令>" make evidence 写入;手抄/转写输出视为无效证据(AGENTS.md 证据与验证门禁)。 -->
| 时间(UTC) | 命令 | 被测HEAD | exit | 来源 | sha256(16) |
|---|---|---|---|---|---|
## 交付调度
- 调度状态:窗口已领取;调度记录:#518 comment 8226(mq-dev-20261020-cli-agent-fallback-chain-01)
- entry_id:无;attempt_id:无;窗口执行者:无
- 固定候选:无(base/head、组件与相关配置引用实际尝试)
- 调度依据:policy/delivery.md#合入调度
- 固定后证据:源码外 RECEIPT;实际结果后按授权原样导入和闭合
## 结果与验证
- 结果:四个角色候选链为 cursor(auto) → antigravity(`gemini-3.8-flash-high`) → pi-glm(`zai-coding-cn/glm-5.3-flash`) → pi(`minimax-cn/MiniMax-M3`) → codex(`gpt-6.1-sol`)(test/review 前四项顺序不同,Codex 均最后),每候选最多 3 次;去掉 `emergency_profile`;policy 三份文本同步“自动换候选不询问、全部耗尽暂停询问是否重试”。
- 验证:`make agent-exec-validate` PASS;`make test-governance` PASS(513 tests,skipped=18);`make task-sync` PASS;三个新模型 ID 冒烟 PASS(SELF,未入证据表);PR HEAD 完整 CI 待 GATE。
- 影响与剩余项:仅影响 Agent 执行路由。运行时随机顺序未实现(非目标,声明顺序满足“顺序不限、Codex 最后”);`failed-unknown` 等 fail-stop 仍立即停止、不换候选。
## 规划进展与下一步
- 本次推进/剩余:R1 完成,无剩余
- 首选下一任务:无(独立小改动)
- 推荐依据:不适用
- 前置条件/待确认:无
- 预期产物/验收条件:不适用
- 重复任务核对:远端分流 NEW(唯一候选 rdm-two-trees-followup 无关)
- 启动授权:未授权(建议不自动启动新任务,仍须明确授权)
## 合入与清理
- Review 记录:host 主模型(未撰写实施单元;平台账号 weichen)审阅 890313e..8e21b66 实际 diff(AGENT-EXECUTION.md 机器块与说明、delivery/governance/tool-adaptation-matrix 指定段落),重放 `make agent-exec-validate`;结论 PASS,无阻塞项(非阻塞:AGENT-EXECUTION.md 一行超过 78 列)。
- 冲突记录:窗口内 `make task-sync` 合入 main f1866dc(changed=1),无冲突;main 侧对 AGENT-EXECUTION.md 仅在 cursor 档加注释,与本改动正交;合并后重跑 `make agent-exec-validate` PASS。
- CI 记录:NOT_RUN(当前 HEAD 完整 SHA、全部必需检查、运行链接、执行身份及 GATE 结果)
- 合入记录:NOT_RUN(交付授权范围、PR、被核验 HEAD、合入 SHA、目标分支及内容核验)
- 清理记录:NOT_RUN(授权依据、写者退出确认、worktree/分支/任务卡处置)
<!-- Local receipt: SELF. Digests detect corruption; they do not authenticate a reviewer or CI. -->
```json
{
"summary_schema": 1,
"source": "SELF",
"timestamp": "2026-10-20T05:55:50.540864+00:00",
"command": "make precheck",
"exit_code": 0,
"cwd": "/home/weichen/projects/Agent-System-Dev",
"before_head": "d2035c76dc1cb15e01d2c184af5155d9d773cd9f",
"after_head": "d2035c76dc1cb15e01d2c184af5155d9d773cd9f",
"branch": "main",
"target_branch": "main",
"target_head": "d2035c76dc1cb15e01d2c184af5155d9d773cd9f",
"root_target": "main",
"immediate_target": "main",
"before_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"after_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"output_tail": [
"make[1]: Entering directory '/home/weichen/projects/Agent-System-Dev'",
"[repo] branch=main head=d2035c76dc",
"[remote] origin/main=d2035c76dc ahead=0 behind=0",
"[tree] clean submodules_drift=0 uninit=0",
"[worktrees] linked=7",
"[initiatives] local cards (not authoritative): none",
"[hooks] core.hooksPath=scripts/hooks(pre-commit/post-merge 实际接线)",
"[facts] policy/facts.md 6 条事实均在有效期内",
"[required-reading] core/baseline.md, workflows/delivery.md §1, policy/delivery.md",
"[R0] d2035c76dc(完整:d2035c76dc1cb15e01d2c184af5155d9d773cd9f)",
"[worktree] before-sync: recursive component checks passed",
"[verdict] READY — 保留本次 precheck receipt 后建任务工作区:PRECHECK_RECEIPT=/tmp/task-precheck.json make task-start NAME=feature/your-branch",
"make[1]: Leaving directory '/home/weichen/projects/Agent-System-Dev'"
],
"output_sha256": "ecc7f16b6bcabae29ac639e9d5d31ab0bc39f85e0fe0b51449d7b69412ba2d08",
"receipt_sha256": "a8789614c5e3adf44db1e46a6fee98cfabea7b7e79708756d63c4aa756359b79",
"receipt_path": "/home/weichen/.cache/agent-system-dev/evidence/a8789614c5e3adf44db1e46a6fee98cfabea7b7e79708756d63c4aa756359b79.json"
}
```
<!-- Local receipt: SELF. Digests detect corruption; they do not authenticate a reviewer or CI. -->
```json
{
"summary_schema": 1,
"source": "SELF",
"timestamp": "2026-10-20T06:00:53.614147+00:00",
"command": "make agent-exec-validate",
"exit_code": 0,
"cwd": "/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain",
"before_head": "8e21b66db4606c20a1d7de4f1293fbcd61780658",
"after_head": "8e21b66db4606c20a1d7de4f1293fbcd61780658",
"branch": "feature/cli-agent-fallback-chain",
"target_branch": "main",
"target_head": "d2035c76dc1cb15e01d2c184af5155d9d773cd9f",
"root_target": "main",
"immediate_target": "main",
"before_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"after_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"output_tail": [
"make[1]: Entering directory '/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain'",
"scripts/agent-exec validate --repo .",
"validate: ok",
"make[1]: Leaving directory '/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain'"
],
"output_sha256": "74357235852380ff3b7cbcb532b030dc924e8d11a6b2e39dfcb729717e460660",
"receipt_sha256": "1f3ed60af7d5c96fd19ba0b2f89142237b61597e30e7c9578ec20b8c6bfb60f5",
"receipt_path": "/home/weichen/.cache/agent-system-dev/evidence/1f3ed60af7d5c96fd19ba0b2f89142237b61597e30e7c9578ec20b8c6bfb60f5.json"
}
```
<!-- Local receipt: SELF. Digests detect corruption; they do not authenticate a reviewer or CI. -->
```json
{
"summary_schema": 1,
"source": "SELF",
"timestamp": "2026-10-20T06:01:05.726907+00:00",
"command": "make task-sync",
"exit_code": 0,
"cwd": "/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain",
"before_head": "95aba5d68d68f1e3f35887a93aec41b464638a95",
"after_head": "95aba5d68d68f1e3f35887a93aec41b464638a95",
"branch": "feature/cli-agent-fallback-chain",
"target_branch": "main",
"target_head": "d2035c76dc1cb15e01d2c184af5155d9d773cd9f",
"root_target": "main",
"immediate_target": "main",
"before_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"after_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"output_tail": [
"make[1]: Entering directory '/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain'",
"[worktree] before-sync: recursive component checks passed",
"[worktree] before-update: recursive component checks passed",
"[worktree] materialize: recursive component checks passed",
"[worktree] after-sync: recursive component checks passed",
"[evidence] WARN JSON receipt line 120: recorded HEAD predates non-card changes ——关键检查须重跑并以 make evidence 重新写入",
"[synced] sync_base=d2035c76dc1cb15e01d2c184af5155d9d773cd9f tested_head=95aba5d68d68f1e3f35887a93aec41b464638a95 checked_at=2026-10-20T06:01:57Z changed=0 sync_target=main",
"[next] 跑正式验收(make test 等),证据写入任务卡",
"make[1]: Leaving directory '/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain'"
],
"output_sha256": "e797ab5e6a3e9bd075c44fdfe89f72e36a3e2f2fa892e6194501f7c88f46ceb1",
"receipt_sha256": "d05e26eda35110298bb7721e35872f95cdc6c62964c0bf8a84e6db0f06e07775",
"receipt_path": "/home/weichen/.cache/agent-system-dev/evidence/d05e26eda35110298bb7721e35872f95cdc6c62964c0bf8a84e6db0f06e07775.json"
}
```
<!-- Local receipt: SELF. Digests detect corruption; they do not authenticate a reviewer or CI. -->
```json
{
"summary_schema": 1,
"source": "SELF",
"timestamp": "2026-10-20T06:04:41.162206+00:00",
"command": "make task-sync",
"exit_code": 0,
"cwd": "/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain",
"before_head": "c41e773d1e11a052ff53b32d493a3fa3e025ea99",
"after_head": "c41e773d1e11a052ff53b32d493a3fa3e025ea99",
"branch": "feature/cli-agent-fallback-chain",
"target_branch": "main",
"target_head": "d2035c76dc1cb15e01d2c184af5155d9d773cd9f",
"root_target": "main",
"immediate_target": "main",
"before_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"after_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"output_tail": [
"make[1]: Entering directory '/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain'",
"[worktree] before-sync: recursive component checks passed",
"[worktree] before-update: recursive component checks passed",
"[worktree] materialize: recursive component checks passed",
"[worktree] after-sync: recursive component checks passed",
"[evidence] WARN JSON receipt line 120: recorded HEAD predates non-card changes ——关键检查须重跑并以 make evidence 重新写入",
"[synced] sync_base=d2035c76dc1cb15e01d2c184af5155d9d773cd9f tested_head=c41e773d1e11a052ff53b32d493a3fa3e025ea99 checked_at=2026-10-20T06:05:34Z changed=0 sync_target=main",
"[next] 跑正式验收(make test 等),证据写入任务卡",
"make[1]: Leaving directory '/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain'"
],
"output_sha256": "40878f3432df9e7aa449f4304ca79a36a9f2c9d3253e229481283dd119efc992",
"receipt_sha256": "cf538efd2a1d13e0f740447675779b37e3ae0db15fa78cc6553856ac2dbb6cc1",
"receipt_path": "/home/weichen/.cache/agent-system-dev/evidence/cf538efd2a1d13e0f740447675779b37e3ae0db15fa78cc6553856ac2dbb6cc1.json"
}
```
<!-- Local receipt: SELF. Digests detect corruption; they do not authenticate a reviewer or CI. -->
```json
{
"summary_schema": 1,
"source": "SELF",
"timestamp": "2026-10-20T06:06:03.531305+00:00",
"command": "make task-sync",
"exit_code": 0,
"cwd": "/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain",
"before_head": "3a6ffb97ad0cab5c215f684f27108dbd92f23129",
"after_head": "3a6ffb97ad0cab5c215f684f27108dbd92f23129",
"branch": "feature/cli-agent-fallback-chain",
"target_branch": "main",
"target_head": "d2035c76dc1cb15e01d2c184af5155d9d773cd9f",
"root_target": "main",
"immediate_target": "main",
"before_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"after_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"output_tail": [
"make[1]: Entering directory '/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain'",
"[worktree] before-sync: recursive component checks passed",
"[worktree] before-update: recursive component checks passed",
"[worktree] materialize: recursive component checks passed",
"[worktree] after-sync: recursive component checks passed",
"[evidence] WARN JSON receipt line 120: recorded HEAD predates non-card changes ——关键检查须重跑并以 make evidence 重新写入",
"[synced] sync_base=d2035c76dc1cb15e01d2c184af5155d9d773cd9f tested_head=3a6ffb97ad0cab5c215f684f27108dbd92f23129 checked_at=2026-10-20T06:06:49Z changed=0 sync_target=main",
"[next] 跑正式验收(make test 等),证据写入任务卡",
"make[1]: Leaving directory '/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain'"
],
"output_sha256": "1be7bf73418483205369a97f0b90f7ff7a2709effd5ca44875e59f6ff1b2d955",
"receipt_sha256": "2756940470feebd40744bd42504690f19dfeebd9d76cca06369b57e36fe7caa3",
"receipt_path": "/home/weichen/.cache/agent-system-dev/evidence/2756940470feebd40744bd42504690f19dfeebd9d76cca06369b57e36fe7caa3.json"
}
```
<!-- Local receipt: SELF. Digests detect corruption; they do not authenticate a reviewer or CI. -->
```json
{
"summary_schema": 1,
"source": "SELF",
"timestamp": "2026-10-20T06:08:38.659173+00:00",
"command": "make test-governance",
"exit_code": 0,
"cwd": "/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain",
"before_head": "286c3ab0c16fff6ead69a62f470977de4cec656e",
"after_head": "286c3ab0c16fff6ead69a62f470977de4cec656e",
"branch": "feature/cli-agent-fallback-chain",
"target_branch": "main",
"target_head": "d2035c76dc1cb15e01d2c184af5155d9d773cd9f",
"root_target": "main",
"immediate_target": "main",
"before_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"after_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"output_tail": [
"test_feature_missing_parent_is_allowed (test_write_guard.WriteGuardTests.test_feature_missing_parent_is_allowed) ... ok",
"test_invalid_json_is_denied (test_write_guard.WriteGuardTests.test_invalid_json_is_denied) ... ok",
"test_missing_parent_on_main_is_denied (test_write_guard.WriteGuardTests.test_missing_parent_on_main_is_denied) ... ok",
"test_missing_unknown_and_malformed_write_input_are_denied (test_write_guard.WriteGuardTests.test_missing_unknown_and_malformed_write_input_are_denied) ... ok",
"test_non_git_destination_is_explicitly_outside_scope (test_write_guard.WriteGuardTests.test_non_git_destination_is_explicitly_outside_scope) ... ok",
"test_nonwrite_tools_are_outside_scope (test_write_guard.WriteGuardTests.test_nonwrite_tools_are_outside_scope) ... ok",
"test_relative_path_uses_hook_cwd_not_process_cwd (test_write_guard.WriteGuardTests.test_relative_path_uses_hook_cwd_not_process_cwd) ... ok",
"test_symlink_into_main_with_missing_parents_is_denied (test_write_guard.WriteGuardTests.test_symlink_into_main_with_missing_parents_is_denied) ... ok",
"test_valid_multi_file_patch_on_feature_is_allowed (test_write_guard.WriteGuardTests.test_valid_multi_file_patch_on_feature_is_allowed) ... ok",
"",
"----------------------------------------------------------------------",
"Ran 513 tests in 365.638s",
"",
"OK (skipped=18)",
"make[1]: Leaving directory '/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain'"
],
"output_sha256": "750f575e91446dc8480ec53ac70d500852145ae12a75d19ef96390baaf6d55a2",
"receipt_sha256": "14ba55cc1c8585e2a24ef81e0f4edaf74277b83fb47d76fa7bd95dda815cceec",
"receipt_path": "/home/weichen/.cache/agent-system-dev/evidence/14ba55cc1c8585e2a24ef81e0f4edaf74277b83fb47d76fa7bd95dda815cceec.json"
}
```
| 同步(记录前对象) | f1866dc3bb4537ac6446fdd26e696cb636b543ef | 16913620d8cbf214bf81792c5ff03eaee94752cd | 2026-10-20T07:48:20Z |
<!-- Local receipt: SELF. Digests detect corruption; they do not authenticate a reviewer or CI. -->
```json
{
"summary_schema": 1,
"source": "SELF",
"timestamp": "2026-10-20T07:47:26.429534+00:00",
"command": "make task-sync",
"exit_code": 0,
"cwd": "/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain",
"before_head": "6bf1000547cc533b914dcb79ad37573b7d33cf61",
"after_head": "f60effc6326ae8847cb1a39bef469c83d812c385",
"branch": "feature/cli-agent-fallback-chain",
"target_branch": "main",
"target_head": "f1866dc3bb4537ac6446fdd26e696cb636b543ef",
"root_target": "main",
"immediate_target": "main",
"before_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"after_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"output_tail": [
" create mode 100644 docker/verify-env.sh",
" create mode 100644 docs/superpowers/specs/2026-10-20-fast-slow-o2-i1-review.md",
"[worktree] before-update: recursive component checks passed",
"[worktree] materialize: recursive component checks passed",
"[worktree] after-sync: recursive component checks passed",
"admit: ok",
"[evidence] WARN JSON receipt line 120: recorded HEAD predates non-card changes ——关键检查须重跑并以 make evidence 重新写入",
"[evidence] WARN JSON receipt line 159: recorded HEAD predates non-card changes ——关键检查须重跑并以 make evidence 重新写入",
"[evidence] WARN JSON receipt line 189: recorded HEAD predates non-card changes ——关键检查须重跑并以 make evidence 重新写入",
"[evidence] WARN JSON receipt line 224: recorded HEAD predates non-card changes ——关键检查须重跑并以 make evidence 重新写入",
"[evidence] WARN JSON receipt line 259: recorded HEAD predates non-card changes ——关键检查须重跑并以 make evidence 重新写入",
"[evidence] WARN JSON receipt line 294: recorded HEAD predates non-card changes ——关键检查须重跑并以 make evidence 重新写入",
"[synced] sync_base=f1866dc3bb4537ac6446fdd26e696cb636b543ef tested_head=f60effc6326ae8847cb1a39bef469c83d812c385 checked_at=2026-10-20T07:48:20Z changed=1 sync_target=main",
"[next] 跑正式验收(make test 等),证据写入任务卡",
"make[1]: Leaving directory '/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain'"
],
"output_sha256": "9671a18a5835bfbad2bade03cd21602d59eb40b92f070c258b186ecea7ae9a58",
"receipt_sha256": "c4547470f11d63491ea2f2c4b23c6a46425e5362f37dd23d13f1770165e32057",
"receipt_path": "/home/weichen/.cache/agent-system-dev/evidence/c4547470f11d63491ea2f2c4b23c6a46425e5362f37dd23d13f1770165e32057.json"
}
```
<!-- Local receipt: SELF. Digests detect corruption; they do not authenticate a reviewer or CI. -->
```json
{
"summary_schema": 1,
"source": "SELF",
"timestamp": "2026-10-20T07:48:38.505764+00:00",
"command": "make agent-exec-validate",
"exit_code": 0,
"cwd": "/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain",
"before_head": "b90d3aaee9550271cb7c2acd200267f3605d6fca",
"after_head": "b90d3aaee9550271cb7c2acd200267f3605d6fca",
"branch": "feature/cli-agent-fallback-chain",
"target_branch": "main",
"target_head": "f1866dc3bb4537ac6446fdd26e696cb636b543ef",
"root_target": "main",
"immediate_target": "main",
"before_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"after_tracked_diff_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"output_tail": [
"make[1]: Entering directory '/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain'",
"scripts/agent-exec validate --repo .",
"validate: ok",
"make[1]: Leaving directory '/home/weichen/projects/Agent-System-Dev-wt-feature-cli-agent-fallback-chain'"
],
"output_sha256": "74357235852380ff3b7cbcb532b030dc924e8d11a6b2e39dfcb729717e460660",
"receipt_sha256": "8a2946c846a8e64c76222cefd05e91161131d1fae4d8b8412dd4e8d90c562fd7",
"receipt_path": "/home/weichen/.cache/agent-system-dev/evidence/8a2946c846a8e64c76222cefd05e91161131d1fae4d8b8412dd4e8d90c562fd7.json"
}
```
## 闭合记录(合入前折叠)
- 本卡在 PR #648(https://git-home.u1680832.nyat.app:30319/weichen/Agent-System-Dev/pulls/648)合入前闭合并归档,随该 PR 一同合入。
- 该 PR 的合并提交即本任务的落地记录。
- 合入后无需回填,也无需单独的闭合 PR。
+43 -34
View File
@@ -7,20 +7,22 @@ parser accepts exactly one `agent-execution` fenced block.
U3's execution controller and U4's project wiring are integrated. This file is
the execution-routing authority for implementation, repair, test, and review.
Normal implementation, repair, and test routes stay Cursor, Antigravity
(`agy`), and PI. Each of those profiles may be attempted up to
`max_attempts_per_profile`, which is exactly 3 whenever `emergency_profile`
is configured. Only after those candidates safely exhaust their attempts does
the enabled emergency `codex` profile run once. Codex remains out of the three
normal role lists and may also appear in review. `fallback_to_host` is
`never`: the controller does not emit `host-fallback-authorized` and does not
increment host fallback authorizations. Safe exhaustion without an emergency
candidate ends `unavailable` or `blocked`, and that result does not authorize
the host to write the unit. The legacy value `all-unavailable` remains
parseable and likewise grants no host write authority. Cursor uses
`cursor-agent-stable`. `model: auto` makes Cursor receive an explicit
`--model auto`; the other CLIs omit the model flag and use their configured
default. Any other value is passed to that CLI as its model selector. The
Implementation, repair, test, and review all use the candidates Cursor,
Antigravity (`agy`), PI with GLM (`pi-glm`), PI with MiniMax (`pi`), and
Codex. Each candidate may be attempted up to `max_attempts_per_profile` (3)
times on safe recoverable failures (`unavailable`, `failed-clean`); after that
the controller moves to the next candidate automatically, and the host does
not ask the user. The order of the non-Codex candidates may differ per role,
but Codex must stay the last candidate in every role list. There is no
`emergency_profile`. `fallback_to_host` is `never`: the controller does not
emit `host-fallback-authorized` and does not increment host fallback
authorizations. When every candidate is safely exhausted the run ends
`unavailable` or `blocked`; the host pauses that unit and asks the user
whether to retry, and does not write the unit. The legacy value
`all-unavailable` remains parseable and likewise grants no host write
authority. Cursor uses `cursor-agent-stable`. `model: auto` makes Cursor
receive an explicit `--model auto`; the other CLIs omit the model flag and use
their configured default. Any other value is passed to that CLI as its model selector. The
`integration` block declares the host-exempt paths and the transport, admission,
and cleanup entry points.
@@ -37,13 +39,12 @@ execution:
summary_bytes: 16384
raw_output_bytes: 10485760
max_attempts_per_profile: 3
emergency_profile: codex
roles:
implementation: [cursor, antigravity, pi]
repair: [cursor, antigravity, pi]
test: [pi, antigravity, cursor]
review: [pi, antigravity, cursor, codex]
implementation: [cursor, antigravity, pi-glm, pi, codex]
repair: [cursor, antigravity, pi-glm, pi, codex]
test: [pi-glm, pi, antigravity, cursor, codex]
review: [pi-glm, pi, antigravity, cursor, codex]
profiles:
cursor:
@@ -59,7 +60,13 @@ profiles:
antigravity:
adapter: antigravity
executable: agy
model: auto
model: gemini-3.8-flash-high
enabled: true
pi-glm:
adapter: pi
executable: pi
model: zai-coding-cn/glm-5.3-flash
enabled: true
pi:
@@ -71,7 +78,7 @@ profiles:
codex:
adapter: codex
executable: codex
model: auto
model: gpt-6.1-sol
enabled: true
integration:
@@ -96,23 +103,25 @@ section records only this project's choices.
- Planning, design and implementation plans: Codex or Claude when available,
in the host or a fresh CLI session. This is a preference, not a routing role.
- Bounded implementation, repair and test units: the existing normal
candidates in the configured role order above. Requested models:
- PI: `minimax-cn/MiniMax-M3`, passed as `--model provider/id`. PI
actual events have reported `minimax-cn` / `MiniMax-M3` and the local
offline catalog lists that profile; each run still records the effective
model from that run's events.
- Bounded implementation, repair, test and review units: the candidates in
the configured role order above, with Codex last. Requested models:
- Cursor: `auto`, passed explicitly as `--model auto` (Cursor Auto).
- agy: Gemini 3.8 Flash is requested, but its exact selectable model ID and
effective identity are `NOT_VERIFIED` (the `agy` models query needs a
login that was not available). The profile therefore stays `model: auto`
until an observed model ID exists; do not claim Gemini 3.8 Flash is active.
- agy: `gemini-3.8-flash-high`. `agy models` listed it on 2026-10-20 and a
one-line smoke run answered; the effective identity is still taken from
each run's events.
- PI GLM profile (`pi-glm`): `zai-coding-cn/glm-5.3-flash`, passed as
`--model provider/id`.
- PI MiniMax profile (`pi`): `minimax-cn/MiniMax-M3`, passed as
`--model provider/id`. PI actual events have reported `minimax-cn` /
`MiniMax-M3` and the local offline catalog lists that profile; each run
still records the effective model from that run's events.
- Codex: `gpt-6.1-sol`, always the last candidate.
- Assigning a different candidate or model to a unit needs a concrete,
task-specific reason recorded in the task record, and stays within the
existing roles and candidate lists. It is not a silent permission or routing
change. Role lists, attempt limits, timeouts, output limits, the single
Codex emergency attempt, stage isolation and `fallback_to_host: never` are
unchanged by these preferences.
change. Role lists, attempt limits, timeouts, output limits, Codex as the
last candidate, stage isolation and `fallback_to_host: never` are unchanged
by these preferences.
- A requested model is prompt/config intent. Only the model reported in a
run's actual event envelope counts as effective; when the CLI does not report
it, record `not-observable`. Unknown context capacity, a missing agy login
+11 -10
View File
@@ -73,18 +73,19 @@
[AGENT-EXECUTION.md](../AGENT-EXECUTION.md) 为唯一权威;按角色声明的候选顺序在新进程与
隔离工作区中尝试外部 Agent。不得跨单元复用同一外部进程,也不得 resume 同一次尝试。
实施、修复与测试的正常候选只有 Cursor、Antigravity(`agy`)和 PI。每个候选对安全可恢复失败
最多 3 次全新尝试:`unavailable`,或外部无副作用已被机制证明的 `failed-clean`。三次仍属这类失败后才进入
下一候选。单元包的 `network=false` 与 `external_cost=false` 只是声明,不证明外部干净;当前没有强制的
实施、修复、测试与 Review 的候选为 Cursor、Antigravity(`agy`)、PI(GLM 与 MiniMax 两个档)和
Codex。每个候选对安全可恢复失败最多 3 次全新尝试:`unavailable`,或外部无副作用已被机制证明的
`failed-clean`。三次仍属这类失败后由控制器自动进入下一候选,host 不为此询问用户。
单元包的 `network=false` 与 `external_cost=false` 只是声明,不证明外部干净;当前没有强制的
网络/外部费用隔离或可信对账,所以已启动的失败尝试即使私有克隆可精确恢复,也记为 `failed-unknown`
并保留现场。三个正常候选都安全耗尽后,才允许一次全新的 Codex CLI 紧急尝试;这次不按每候选 3 次计算。
紧急尝试若仍是安全可恢复失败,运行停在 `blocked`。host 不接过该单元继续撰写。
并保留现场。
Codex 平时只用于规划、方案设计、实施计划,或独立 Review。执行配置没有单独的 plan 角色;
上述规划与设计工作可以直接使用 Codex CLI。`review` 角色的候选可以包含 Codex,并按该角色自己的
顺序和尝试上限执行。Codex 不出现在实施、修复、测试的正常候选里;这三个角色上的一次紧急尝试是唯一例外。
Codex 之外的候选顺序可按角色在 [AGENT-EXECUTION.md](../AGENT-EXECUTION.md) 中调整,但 Codex
必须是每个角色的最后一个候选,不设单次紧急尝试。全部候选安全耗尽后运行停在 `unavailable` 或
`blocked`,host 暂停该单元并询问用户是否重试,不接过该单元继续撰写。Codex 另可直接用于规划、
方案设计、实施计划(执行配置没有单独的 plan 角色)。
显式 fail-stop 立即停止整次运行,不重试、不换候选、不启动紧急尝试:`failed-unknown`、
显式 fail-stop 立即停止整次运行,不重试、不换候选:`failed-unknown`、
`scope-expansion`、`blocked`、`cancelled`、无效配置、未对账的 Git 状态与安全失败。总超时,
以及 stdin/stdout/stderr 都没有活动的空闲超时,归入 `failed-unknown`。
@@ -123,7 +124,7 @@ host 可以直接编写并提交的豁免只有 `.task/**`、`docs/superpowers/s
`docs/superpowers/plans/**`。除此之外,host 不直接撰写实施单元。
安全耗尽不发出 `host-fallback-authorized`,`host_fallback_authorizations` 保持为 0。
未配置紧急候选时终态为 unavailable 或 blocked,不授权 host 撰写实施单元。现行
安全耗尽的终态为 unavailable 或 blocked,不授权 host 撰写实施单元。现行
[AGENT-EXECUTION.md](../AGENT-EXECUTION.md) 的 `fallback_to_host` 是 `never`。旧值
`all-unavailable` 仍可解析,但同样不产生 host 撰写授权。已归档任务卡里的旧表述保持原样,
不改写成现行规则。
+3 -3
View File
@@ -11,12 +11,12 @@
### Agent 实施收据与来源
每次外部实施尝试须在任务卡「Agent 实施收据」记录:配置摘要(`AGENT-EXECUTION.md` digest)、
角色、声明候选顺序、attempt、CLI/模型、终态、transport、fallback(只表示该行是否为 Codex
紧急尝试),以及源码外原始收据路径。初始生成状态为 `NOT_RUN`。原始事件流与超限输出保留在
角色、声明候选顺序、attempt、CLI/模型、终态、transport、fallback(是否为应急尝试;现行配置无
应急档,恒为否),以及源码外原始收据路径。初始生成状态为 `NOT_RUN`。原始事件流与超限输出保留在
源码外;未知终态(`failed-unknown`)与 `scope-expansion` 的隔离工作区须保留待对账,不得静默丢弃。
清理须有精确恢复或保留现场的可复核证据。
候选、尝试上限、Codex 紧急尝试、fallback、fail-stop、尝试结束条件,以及 transport/admit
候选、尝试上限、fallback、fail-stop、尝试结束条件,以及 transport/admit
与 host 豁免路径,以[迭代交付](delivery.md#agent-实施单元与主模型职责)为唯一权威。
## 启动与恢复
+1 -1
View File
@@ -14,7 +14,7 @@
| A5 回收 | 本地命令检查;写者退出须可证明,无法证明时才请求 owner 决策 | 登记根目录、锁/操作状态、父子仓与唯一文件、合入核验 | `tests/test_task.py` |
| A6 秘密 | 本地脱敏及 CI 获取边界;权限与宿主隔离另验 | 命令/输出/摘要脱敏,凭据不持久写 Git 配置 | `tests/test_evidence.py`、`tests/test_ci_credentials.py` |
| A7 证据 | 本地 SELF 收据;外部来源独立核验 | 首次捕获、完整脱敏输出/摘要、对象记录、原样导入 | `tests/test_evidence.py`;CI/审阅链接另核 |
| A8 阶段记录与迭代 | goal-first + agent-per-unit(AGENT-EXECUTION.md);模板默认连续执行,仅真实决策点需人工,没有全流程授权强制;实施/修复/测试仅 Cursor、agy、PI,每候选对安全可恢复失败最多 3 次全新尝试,全部安全耗尽后一次 Codex CLI 紧急尝试;Codex 平时仅规划、设计、计划或独立 Review;显式 fail-stop 立即停止;不限制推理时长、工具次数、规划方式或首次写文件时间;集成经成功 transport 的 agent-exec apply,或 pre-commit admit 精确内容来源;host 豁免仅为 .task/** 与 docs/superpowers/specs/**、plans/**;host 不直接实施;fallback_to_host 为 never;安全耗尽不发出 host-fallback-authorized,终态为 unavailable 或 blocked | policy/delivery.md、AGENT-EXECUTION.md;任务卡分别记录阶段状态、决策点、Agent 实施收据(配置摘要/角色/候选/attempt/CLI-模型/终态/transport/紧急尝试/源码外路径)、Review、冲突、当前 HEAD 的 CI 和合入;post-merge 默认仅提示 | `tests/test_task.py` 核对 goal-first/agent-per-unit 模板、正常路由、尝试上限、fail-stop、空闲超时与 apply/admit 来源表述,及钩子不自动写入;`scripts/agent-exec validate`(CI)与 parser·adapter·controller 假 CLI 契约(Development-Manager internal/agentexec 测试,经 deps/development-manager 钉住)为本地 SELF 强制行为;已安装 provider/model 身份待 U5,远端平台准入为 GATE;智能体核对授权范围、实施单元边界、Review、冲突及匹配 HEAD 的 CI/平台准入 |
| A8 阶段记录与迭代 | goal-first + agent-per-unit(AGENT-EXECUTION.md);模板默认连续执行,仅真实决策点需人工,没有全流程授权强制;实施/修复/测试/Review 候选为 Cursor、agy、PI(GLM、MiniMax)与最后的 Codex,每候选对安全可恢复失败最多 3 次全新尝试并自动换候选,全部安全耗尽后暂停询问用户是否重试;显式 fail-stop 立即停止;不限制推理时长、工具次数、规划方式或首次写文件时间;集成经成功 transport 的 agent-exec apply,或 pre-commit admit 精确内容来源;host 豁免仅为 .task/** 与 docs/superpowers/specs/**、plans/**;host 不直接实施;fallback_to_host 为 never;安全耗尽不发出 host-fallback-authorized,终态为 unavailable 或 blocked | policy/delivery.md、AGENT-EXECUTION.md;任务卡分别记录阶段状态、决策点、Agent 实施收据(配置摘要/角色/候选/attempt/CLI-模型/终态/transport/fallback/源码外路径)、Review、冲突、当前 HEAD 的 CI 和合入;post-merge 默认仅提示 | `tests/test_task.py` 核对 goal-first/agent-per-unit 模板、正常路由、尝试上限、fail-stop、空闲超时与 apply/admit 来源表述,及钩子不自动写入;`scripts/agent-exec validate`(CI)与 parser·adapter·controller 假 CLI 契约(Development-Manager internal/agentexec 测试,经 deps/development-manager 钉住)为本地 SELF 强制行为;已安装 provider/model 身份待 U5,远端平台准入为 GATE;智能体核对授权范围、实施单元边界、Review、冲突及匹配 HEAD 的 CI/平台准入 |
| A9 长期方向与后续任务 | manual;模板不校验规划有效性或自动调度任务 | policy/delivery.md;PROJECT.md 提供规划入口,任务卡关联规划/里程碑并记录下一步建议 | `tests/test_task.py` 核对生成字段与未授权默认值;智能体核对当前规划、进展、重复任务和建议依据,新任务仍不自动获得授权 |
| A10 交付窗口 | manual;无自动互斥或接管 | [合入调度](delivery.md#合入调度)与 #518:同一目标一个最终窗口,等待分支不追 main;轮到后同步、固定、验证并由智能体合入 | 每个实际 PR 核对窗口记录、精确 HEAD 三项 GATE、Review 和合入后 main;不要求额外试行或全写者审计 |
| A11 固定后证据 | manual 选择源码外位置;工具捕获绝对未用路径/原始输出;无 OS 冻结 | policy/governance.md;RECEIPT 捕获,后续授权闭合再原样导入 | `tests/test_evidence.py` 固定对象、权限、覆盖拒绝、原样导入与幂等 |