@tea-agent/loop-agent 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/AGENTS.md +91 -87
  2. package/CHANGELOG.md +89 -52
  3. package/README.md +195 -180
  4. package/bin/agent-worker.js +22 -0
  5. package/bin/loop-agent.js +21 -21
  6. package/dist/application/dag/args.js +6 -0
  7. package/dist/application/dag/generate-task-dag.js +2 -0
  8. package/dist/application/dag/run-dag.js +3 -0
  9. package/dist/application/dag/validate-dag.js +40 -0
  10. package/dist/cli/command-definitions.js +2 -2
  11. package/dist/cli/program.js +24 -4
  12. package/dist/commands/init.js +1011 -459
  13. package/dist/commands/loop-benchmark.js +11 -11
  14. package/dist/commands/pi-reuse-benchmark.js +16 -16
  15. package/dist/executors/cursor-executor.js +1 -1
  16. package/dist/executors/dag-pi-executor.js +8 -1
  17. package/dist/task/runtime.js +27 -27
  18. package/dist/worker/cli.js +119 -0
  19. package/dist/worker/loop-agent/command-result.js +1 -0
  20. package/dist/worker/loop-agent/loop-agent-client.js +105 -0
  21. package/dist/worker/loop-agent/parse-json.js +14 -0
  22. package/dist/worker/materialize/harness-task-materializer.js +157 -0
  23. package/dist/worker/pool/failure-routing.js +98 -0
  24. package/dist/worker/pool/run-store.js +117 -0
  25. package/dist/worker/pool/types.js +1 -0
  26. package/dist/worker/preflight.js +108 -0
  27. package/dist/worker/profile-mapping.js +76 -0
  28. package/dist/worker/progress-reporter.js +81 -0
  29. package/dist/worker/report/morning-report.js +69 -0
  30. package/dist/worker/repos/repo-resolver.js +23 -0
  31. package/dist/worker/run-task/run-task.js +359 -0
  32. package/dist/worker/runner/run-ready.js +216 -0
  33. package/dist/worker/task-graph/acceptance-schema.js +25 -0
  34. package/dist/worker/task-graph/ready-queue.js +23 -0
  35. package/dist/worker/task-graph/task-graph-schema.js +28 -0
  36. package/dist/worker/task-graph/types.js +1 -0
  37. package/dist/worker/task-graph/validate.js +188 -0
  38. package/dist/worker/task-spec/complexity-mapping.js +8 -0
  39. package/dist/worker/task-spec/schema.js +116 -0
  40. package/dist/worker/task-spec/types.js +1 -0
  41. package/dist/worker/task-spec/validate.js +352 -0
  42. package/dist/workflows/dag/canvas-observer.js +275 -275
  43. package/dist/workflows/dag/dynamic-runtime/loop-until.js +2 -1
  44. package/dist/workflows/dag/dynamic-runtime/map.js +1 -0
  45. package/dist/workflows/dag/init-hybrid.js +3 -3
  46. package/dist/workflows/dag/skills.js +3 -3
  47. package/dist/workflows/dag/types.js +2 -0
  48. package/dist/workflows/dynamic/compile.js +11 -0
  49. package/dist/workflows/dynamic/spec.js +1 -0
  50. package/docs/README.md +72 -65
  51. package/docs/agent-dag-recovery-playbook.md +184 -184
  52. package/docs/agent-dag-runner.md +42 -40
  53. package/docs/architecture/runtime-boundaries.md +147 -147
  54. package/docs/cursor-executor-usage.md +25 -25
  55. package/docs/decisions/README.md +3 -3
  56. package/docs/design/README.md +36 -36
  57. package/docs/development-principles.md +73 -71
  58. package/docs/dynamic-workflow-dag-engine-roadmap.md +1749 -1749
  59. package/docs/exec-plans/README.md +6 -6
  60. package/docs/exec-plans/active/README.md +7 -10
  61. package/docs/exec-plans/completed/README.md +19 -9
  62. package/docs/feature-workflow.md +186 -186
  63. package/docs/harness-methodology-debugging.md +153 -153
  64. package/docs/harness-methodology-tdd.md +130 -130
  65. package/docs/harness-methodology-verification.md +27 -27
  66. package/docs/init-surface.manifest.json +175 -0
  67. package/docs/loop-agent-harness.md +42 -42
  68. package/docs/production-readiness.md +96 -96
  69. package/docs/progress/README.md +3 -3
  70. package/docs/reports/README.md +5 -5
  71. package/docs/skills/README.md +6 -0
  72. package/docs/skills/vetted-skill-registry.md +26 -0
  73. package/docs/templates/adr.md +60 -60
  74. package/docs/templates/agent-dag-authority-surface-audit.prompt.md +94 -94
  75. package/docs/templates/agent-dag-decision-envelope.schema.json +213 -213
  76. package/docs/templates/agent-dag-decision-gate-dogfood-report.md +117 -117
  77. package/docs/templates/agent-dag-decision-gate.prompt.md +246 -246
  78. package/docs/templates/agent-dag-process-supervisor.prompt.md +98 -98
  79. package/docs/templates/agent-dag-report.schema.json +454 -454
  80. package/docs/templates/agent-dag-review-verdict.prompt.md +68 -68
  81. package/docs/templates/agent-dag.base.json +195 -195
  82. package/docs/templates/agent-dag.final-verification.json +190 -190
  83. package/docs/templates/agent-dag.schema.json +316 -316
  84. package/docs/templates/agent-dag.supervised-implementation.json +500 -500
  85. package/docs/templates/exec-plan.md +64 -64
  86. package/docs/templates/feature-spec.md +53 -53
  87. package/docs/templates/hybrid-dag.json +193 -193
  88. package/docs/templates/init-evolution-review.md +33 -0
  89. package/docs/templates/production-readiness-checklist.md +57 -57
  90. package/docs/templates/progress-log.md +17 -17
  91. package/docs/templates/project-start-checklist.md +9 -9
  92. package/docs/templates/qa-report.md +48 -48
  93. package/docs/templates/sprint-contract.md +29 -29
  94. package/docs/verification-matrix.md +41 -41
  95. package/examples/decision-gate-agent-dag.json +123 -123
  96. package/examples/example-dag.json +51 -51
  97. package/examples/hybrid-loop-agent-dag.json +194 -194
  98. package/harness.json +94 -92
  99. package/package.json +66 -62
  100. package/skills/ai-engineering-context/SKILL.md +48 -48
  101. package/skills/code-review-core/SKILL.md +20 -0
  102. package/skills/codebase-scout/SKILL.md +19 -0
  103. package/skills/init-capability-evolution/SKILL.md +69 -0
  104. package/skills/loop-agent/SKILL.md +147 -145
  105. package/skills/loop-agent/references/README.md +67 -67
  106. package/skills/loop-agent/references/command-reference.md +403 -357
  107. package/skills/loop-agent/references/harness-policy.md +259 -258
  108. package/skills/loop-agent/references/hybrid-dag.md +216 -216
  109. package/skills/loop-agent/references/learned/README.md +21 -21
  110. package/skills/loop-agent/references/long-running-loop.md +59 -59
  111. package/skills/loop-agent/references/model-routing.md +36 -36
  112. package/skills/loop-agent/references/multi-worktree.md +54 -54
  113. package/skills/loop-agent/references/one-shot-runs.md +85 -85
  114. package/skills/loop-agent/references/orchestrator-and-interventions.md +169 -169
  115. package/skills/loop-agent/references/pi-prompt.md +23 -23
  116. package/skills/loop-agent/references/pi-subagent-assisted-mode.md +81 -81
  117. package/skills/loop-agent/references/post-implementation-and-patterns.md +44 -44
  118. package/skills/loop-agent/references/task-workflow.md +84 -84
  119. package/skills/loop-agent/references/verification-and-failure-handling.md +128 -128
  120. package/skills/requesting-code-review/SKILL.md +101 -101
  121. package/skills/requesting-code-review/code-reviewer.md +168 -168
  122. package/skills/systematic-debugging/CREATION-LOG.md +119 -119
  123. package/skills/systematic-debugging/SKILL.md +296 -296
  124. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -158
  125. package/skills/systematic-debugging/condition-based-waiting.md +115 -115
  126. package/skills/systematic-debugging/defense-in-depth.md +122 -122
  127. package/skills/systematic-debugging/find-polluter.sh +63 -63
  128. package/skills/systematic-debugging/root-cause-tracing.md +169 -169
  129. package/skills/systematic-debugging/test-academic.md +14 -14
  130. package/skills/systematic-debugging/test-pressure-1.md +58 -58
  131. package/skills/systematic-debugging/test-pressure-2.md +68 -68
  132. package/skills/systematic-debugging/test-pressure-3.md +69 -69
  133. package/skills/test-driven-development/SKILL.md +20 -0
  134. package/skills/verification-before-completion/SKILL.md +154 -154
  135. package/skills/webapp-testing/SKILL.md +19 -0
@@ -1,44 +1,44 @@
1
- # 实现后处理与常见模式
2
-
3
- 用于 post-verify handoff、多 item PRD 处理、fast bounded task、快速 status 检查与 Pi timeout 处理。
4
-
5
- ## 实现后处理
6
-
7
- DAG run、promotion、closeout 和最终验证完成后:
8
- 1. 检查 git diff 确认预期变更
9
- 2. 用 git commit 并 push
10
- 3. 用户说「继续」时,跑 `status` 看 task 是否 `completed`,再创建下一个 task
11
-
12
- ## 常见模式
13
-
14
- ### 处理多 item PRD
15
- ```
16
- 1. new-task <id>-r1 → 准备 source → dag run-task → dag validate → run-dag → promote/closeout
17
- 2. new-task <id>-r2 → 重复
18
- 3. ...
19
- ```
20
-
21
- ### Bounded task 路径
22
- ```
23
- 1. new-task <id>
24
- 2. 写 source/需求.md + source/执行约束.md
25
- 3. dag run-task <id> --profile auto --strict-models --output <temp-dir>/<id>-dag.json
26
- 4. dag validate --dag <temp-dir>/<id>-dag.json --strict-models --strict-governance
27
- 5. run-dag --dag <temp-dir>/<id>-dag.json --cwd <repo-root>
28
- 6. promote-run / closeout / final verification
29
- ```
30
-
31
- `<temp-dir>` 表示平台原生临时目录;实际命令中使用 macOS/Windows 本机路径。
32
-
33
- **关键**:实现 work 由 DAG node 和 executor 执行;main session 负责审 DAG、审 writeSet、跑验证和 handoff。
34
-
35
- ### 跨所有 task 快速 status
36
- ```bash
37
- loop-agent stats
38
- ```
39
-
40
- ### 处理 pi timeout
41
- - 默认每 step timeout 现为 30 分钟 — 通常足够
42
- - pi step 仍 timeout 时,用 `stats` 看 duration 分布
43
- - Bash tool call 应用宽松 timeout:analyze/plan 300s,implement 480s+,verify/retrospective 240s+
44
- - 失败时优先读 `dag report` / `dag doctor`,再决定 repair DAG、bounded Cursor fix 或暂停
1
+ # 实现后处理与常见模式
2
+
3
+ 用于 post-verify handoff、多 item PRD 处理、fast bounded task、快速 status 检查与 Pi timeout 处理。
4
+
5
+ ## 实现后处理
6
+
7
+ DAG run、promotion、closeout 和最终验证完成后:
8
+ 1. 检查 git diff 确认预期变更
9
+ 2. 用 git commit 并 push
10
+ 3. 用户说「继续」时,跑 `status` 看 task 是否 `completed`,再创建下一个 task
11
+
12
+ ## 常见模式
13
+
14
+ ### 处理多 item PRD
15
+ ```
16
+ 1. new-task <id>-r1 → 准备 source → dag run-task → dag validate → run-dag → promote/closeout
17
+ 2. new-task <id>-r2 → 重复
18
+ 3. ...
19
+ ```
20
+
21
+ ### Bounded task 路径
22
+ ```
23
+ 1. new-task <id>
24
+ 2. 写 source/需求.md + source/执行约束.md
25
+ 3. dag run-task <id> --profile auto --strict-models --output <temp-dir>/<id>-dag.json
26
+ 4. dag validate --dag <temp-dir>/<id>-dag.json --strict-models --strict-governance
27
+ 5. run-dag --dag <temp-dir>/<id>-dag.json --cwd <repo-root>
28
+ 6. promote-run / closeout / final verification
29
+ ```
30
+
31
+ `<temp-dir>` 表示平台原生临时目录;实际命令中使用 macOS/Windows 本机路径。
32
+
33
+ **关键**:实现 work 由 DAG node 和 executor 执行;main session 负责审 DAG、审 writeSet、跑验证和 handoff。
34
+
35
+ ### 跨所有 task 快速 status
36
+ ```bash
37
+ loop-agent stats
38
+ ```
39
+
40
+ ### 处理 pi timeout
41
+ - 默认每 step timeout 现为 30 分钟 — 通常足够
42
+ - pi step 仍 timeout 时,用 `stats` 看 duration 分布
43
+ - Bash tool call 应用宽松 timeout:analyze/plan 300s,implement 480s+,verify/retrospective 240s+
44
+ - 失败时优先读 `dag report` / `dag doctor`,再决定 repair DAG、bounded Cursor fix 或暂停
@@ -1,84 +1,84 @@
1
- # Task Workflow 规则
2
-
3
- 本文只保留 legacy task 目录和 source material 的读取规则。历史顺序式 `run analyze|plan|spec|implement|verify|auto|loop|continue` 工作流已经移除,不再作为 micro、fallback 或 compatibility 执行路径。
4
-
5
- ## 当前执行入口
6
-
7
- 所有需要可恢复、可验证、可交接的实现工作都走 DAG 路径:
8
-
9
- ```bash
10
- loop-agent new-task <task-id> "Task Title"
11
- loop-agent dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
12
- loop-agent dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
13
- loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <repo-root>
14
- ```
15
-
16
- `<temp-dir>` 表示平台原生临时目录。实际文件路径必须兼容 macOS 和 Windows;只有 repo refs、JSON/Markdown 证据 refs 和 glob 约定默认使用 `/`。
17
-
18
- 当目标仓库是 loop-agent 本仓库时,`loop-agent` 命令必须来自 npm 上已发布的安装包。首次安装或有意升级可用 `@tea-agent/loop-agent@latest`,但一次自举任务启动后不要中途升级控制器,并记录 `npm list -g @tea-agent/loop-agent --depth=0` 显示的实际版本。不要用当前工作区的 `npm link` 或 `npm run dev` 控制会改动 CLI、DAG runtime、executor、package metadata 或 build output 的任务;源码开发和 focused debugging 才使用 `npm run dev -- <args>`。
19
-
20
- 低风险的一行修正文档或配置时,可以由 main session 做 surgical patch,但仍必须记录 scope 并运行对应验证命令。
21
-
22
- ## Source Materials
23
-
24
- `new-task` 后至少维护:
25
-
26
- ```text
27
- .harness/tasks/<task-id>/
28
- source/
29
- 需求.md
30
- 执行约束.md
31
- task.json
32
- ```
33
-
34
- - `需求.md` 写清目标、验收标准和非目标。
35
- - `执行约束.md` 写清允许文件、禁止改动、硬约束和验证命令。
36
- - 若 `docs/` 已有权威 plan/spec/PRD,应在 `需求.md` 引用或摘要,避免 task source 与 repo status source 分叉。
37
-
38
- ## Task State
39
-
40
- 当前 task 状态由 DAG-oriented read model 推导:
41
-
42
- - source readiness
43
- - DAG draft
44
- - latest DAG run
45
- - promotion
46
- - closeout
47
- - loop state
48
- - legacy workflow snapshot
49
-
50
- 旧 `.workflow_state.json` 只能作为兼容读取输入,不是新任务 next action 或完成状态的权威来源。
51
-
52
- ## Repo Adapters
53
-
54
- loop-agent 自动检测所在 repo,并按目标 repo 的 `harness.json` 与治理根目录选择验证入口。跨目录操作时显式传入目标仓库:
55
-
56
- ```bash
57
- loop-agent --repo-root /path/to/target-repo <command>
58
- ```
59
-
60
- ## Task Config
61
-
62
- 新任务不应写入旧 `flow` 字段。常用字段是:
63
-
64
- - `taskId`
65
- - `title`
66
- - `complexity`
67
- - `allowedPaths`
68
- - `forbiddenPaths`
69
- - `hardConstraints`
70
- - `verifyCommands` / adapter verification settings
71
- - `dagFallbackReason`,仅用于记录为何某个长期 loop 缺少 DAG round evidence
72
-
73
- ## Verification
74
-
75
- 完成声明必须来自新鲜验证证据。按目标 repo 的 `docs/verification-matrix.md` 选择最小证明命令;loop-agent 自身常用:
76
-
77
- ```bash
78
- npm run typecheck
79
- npm test
80
- bash scripts/check-repo.sh
81
- bash scripts/ci.sh
82
- ```
83
-
84
- Windows 上通过 Git Bash 或配置好的兼容 Bash 运行 `scripts/*.sh`;不要把 POSIX 路径假设写入 CLI、模板或 task source。
1
+ # Task Workflow 规则
2
+
3
+ 本文只保留 legacy task 目录和 source material 的读取规则。历史顺序式 `run analyze|plan|spec|implement|verify|auto|loop|continue` 工作流已经移除,不再作为 micro、fallback 或 compatibility 执行路径。
4
+
5
+ ## 当前执行入口
6
+
7
+ 所有需要可恢复、可验证、可交接的实现工作都走 DAG 路径:
8
+
9
+ ```bash
10
+ loop-agent new-task <task-id> "Task Title"
11
+ loop-agent dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
12
+ loop-agent dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
13
+ loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <repo-root>
14
+ ```
15
+
16
+ `<temp-dir>` 表示平台原生临时目录。实际文件路径必须兼容 macOS 和 Windows;只有 repo refs、JSON/Markdown 证据 refs 和 glob 约定默认使用 `/`。
17
+
18
+ 当目标仓库是 loop-agent 本仓库时,`loop-agent` 命令必须来自 npm 上已发布的安装包。首次安装或有意升级可用 `@tea-agent/loop-agent@latest`,但一次自举任务启动后不要中途升级控制器,并记录 `npm list -g @tea-agent/loop-agent --depth=0` 显示的实际版本。不要用当前工作区的 `npm link` 或 `npm run dev` 控制会改动 CLI、DAG runtime、executor、package metadata 或 build output 的任务;源码开发和 focused debugging 才使用 `npm run dev -- <args>`。
19
+
20
+ 低风险的一行修正文档或配置时,可以由 main session 做 surgical patch,但仍必须记录 scope 并运行对应验证命令。
21
+
22
+ ## Source Materials
23
+
24
+ `new-task` 后至少维护:
25
+
26
+ ```text
27
+ .harness/tasks/<task-id>/
28
+ source/
29
+ 需求.md
30
+ 执行约束.md
31
+ task.json
32
+ ```
33
+
34
+ - `需求.md` 写清目标、验收标准和非目标。
35
+ - `执行约束.md` 写清允许文件、禁止改动、硬约束和验证命令。
36
+ - 若 `docs/` 已有权威 plan/spec/PRD,应在 `需求.md` 引用或摘要,避免 task source 与 repo status source 分叉。
37
+
38
+ ## Task State
39
+
40
+ 当前 task 状态由 DAG-oriented read model 推导:
41
+
42
+ - source readiness
43
+ - DAG draft
44
+ - latest DAG run
45
+ - promotion
46
+ - closeout
47
+ - loop state
48
+ - legacy workflow snapshot
49
+
50
+ 旧 `.workflow_state.json` 只能作为兼容读取输入,不是新任务 next action 或完成状态的权威来源。
51
+
52
+ ## Repo Adapters
53
+
54
+ loop-agent 自动检测所在 repo,并按目标 repo 的 `harness.json` 与治理根目录选择验证入口。跨目录操作时显式传入目标仓库:
55
+
56
+ ```bash
57
+ loop-agent --repo-root /path/to/target-repo <command>
58
+ ```
59
+
60
+ ## Task Config
61
+
62
+ 新任务不应写入旧 `flow` 字段。常用字段是:
63
+
64
+ - `taskId`
65
+ - `title`
66
+ - `complexity`
67
+ - `allowedPaths`
68
+ - `forbiddenPaths`
69
+ - `hardConstraints`
70
+ - `verifyCommands` / adapter verification settings
71
+ - `dagFallbackReason`,仅用于记录为何某个长期 loop 缺少 DAG round evidence
72
+
73
+ ## Verification
74
+
75
+ 完成声明必须来自新鲜验证证据。按目标 repo 的 `docs/verification-matrix.md` 选择最小证明命令;loop-agent 自身常用:
76
+
77
+ ```bash
78
+ npm run typecheck
79
+ npm test
80
+ bash scripts/check-repo.sh
81
+ bash scripts/ci.sh
82
+ ```
83
+
84
+ Windows 上通过 Git Bash 或配置好的兼容 Bash 运行 `scripts/*.sh`;不要把 POSIX 路径假设写入 CLI、模板或 task source。
@@ -1,128 +1,128 @@
1
- # Verification 与失败处理
2
-
3
- 选择 verify strategy knobs、解读 verify 结果、决定失败后是否继续,或 closeout workflow/runtime/docs/skill 变更时使用本文。
4
-
5
- ## Verify strategy 与 completion audit
6
-
7
- ## Production Readiness v0.1
8
-
9
- 低/中风险单 repo DAG 任务如果声明 production-ready v0.1,必须按 `docs/production-readiness.md` 和 `docs/templates/production-readiness-checklist.md` 收口。
10
-
11
- 支持范围:
12
-
13
- - single repo
14
- - bounded task
15
- - explicit task source
16
- - explicit `allowedPaths` / `forbiddenPaths` / write scope
17
- - shell verification
18
- - report / doctor / closeout handoff
19
-
20
- 非目标:
21
-
22
- - automatic merge
23
- - automatic release
24
- - production secrets
25
- - production database
26
- - high-risk migration
27
- - online Worker Pool
28
- - writable Dynamic Workflow sharded migration
29
-
30
- 失败分类是路由字段,不是主状态;不要覆盖 `.harness/dag-runs/completed/**` 的原始事实。报告和 handoff 应保留:
31
-
32
- ```text
33
- raw_failure_category
34
- dag_normalized_failure_category
35
- product_line_failure_category
36
- recommended_follow_up
37
- ```
38
-
39
- product-line taxonomy 的事实源是 `docs/design/state-and-failure-taxonomy.md`。
40
-
41
- ### Verify 始终在本地跑
42
- `verify` step 跑确定性命令(check-repo.sh + tests + typecheck)。**不**调用 pi。因此快且可靠。
43
-
44
- ### Verify strategy knobs
45
- 需要更紧的 verify 控制时,用 task-level config:
46
- ```json
47
- {
48
- "verifyPreset": "auto",
49
- "verifyMode": "parallel",
50
- "verifyRetryCount": 0,
51
- "verifyFailFast": false
52
- }
53
- ```
54
-
55
- - `verifyPreset`:`auto | quick | standard | full`
56
- - `auto`:`small -> quick`,`medium -> standard`,`large -> full`
57
- - 默认 `parallel`
58
- - 命令争抢共享资源时用 `serial`
59
- - `verifyFailFast` 仅在 `serial` mode 有意义
60
- - retry 保持小;用于 flaky 环境问题,不要掩盖真实失败
61
-
62
- ### Verify 后的 goal completion audit
63
- - 有 active task goal 且 `verify` 通过时,loop-agent 跑 goal completion audit。
64
- - 若 `source/需求.md` 仍有未勾 checklist(`- [ ]`),task **不会**以 completed 结束。
65
- - 若确定性 requirement coverage audit 发现未覆盖需求,task **不会**以 completed 结束。
66
- - `explicitly_out_of_scope` 需求(如 `## 非目标` 下)**不算** coverage gap。
67
- - 独立 audit 报告用 `handoff coverage <task-id> [--json|--markdown]`。
68
- - task status、source/artifacts、DAG outcome、verification 记录可能 drift 时用 `dag reconcile-tasks --glob '<pattern>' [--json|--markdown]`。默认仅报告;`--patch` 不能伪造 verification evidence。
69
-
70
- ### Verify 默认保存进度
71
- `verify` 成功后,loop-agent 默认:
72
-
73
- 1. 在当前 task scope 内选文件
74
- 2. 跑 `git add`
75
- 3. 创建 commit 保存已验证进度
76
-
77
- 默认行为:
78
-
79
- - `autoCommitAfterVerify: true`
80
- - commit message:`chore(task): save verified progress for <taskId>`
81
-
82
- `task.json` 可选覆盖:
83
-
84
- ```json
85
- {
86
- "autoCommitAfterVerify": false,
87
- "autoCommitMessage": "docs(workflow): save verified progress"
88
- }
89
- ```
90
-
91
- 最佳实践:保持 `allowedPaths` 准确。auto-commit 用 task path 约束,避免把无关 dirty 文件扫进 progress commit。
92
-
93
- ### Cursor bounded write 后的独立复核
94
-
95
- Cursor bounded execution 完成后,主会话必须独立执行:
96
-
97
- ```bash
98
- git status --short
99
- git diff --stat
100
- bash scripts/check-repo.sh
101
- npm run lint
102
- npm test
103
- npm run typecheck
104
- loop-agent inspect
105
- loop-agent docs audit
106
- loop-agent handoff check <task-id>
107
- ```
108
-
109
- Cursor 自己报告的完成不算 verification fact;以上命令的 exit code 与输出才是完成声明的证据。
110
-
111
- ### 失败处理
112
-
113
- child agent 失败时:
114
-
115
- - **业务/测试失败**:让 child agent 在同一 task bounds 内修复
116
- - **Workflow runtime 失败**(如 `loop-agent` runtime 问题、部分 artifact 生成、输出聚合 crash):保持 task contract,但允许 main agent 或 child agent 在同一 scoped implementation 内手动完成,仍跑 `verify`
117
- - **意外残留**(tmp 文件、探索性 mock、scratch 输出):handoff 前删除
118
-
119
- ### Closeout 规则
120
- workflow/runtime/docs/skill 变更结束时:
121
- ```bash
122
- loop-agent docs audit
123
- loop-agent handoff check <task-id>
124
- ```
125
-
126
- active exec plan 实质完成时,用 `docs archive` 归档并更新 active/completed 索引,勿留 stale active status。
127
-
128
- failed DAG run 不应生成成功式 closeout。它应该生成 failure handoff,至少包含 what failed、evidence、classification、recommended follow-up、safe retry conditions 和 human decision needed。
1
+ # Verification 与失败处理
2
+
3
+ 选择 verify strategy knobs、解读 verify 结果、决定失败后是否继续,或 closeout workflow/runtime/docs/skill 变更时使用本文。
4
+
5
+ ## Verify strategy 与 completion audit
6
+
7
+ ## Production Readiness v0.1
8
+
9
+ 低/中风险单 repo DAG 任务如果声明 production-ready v0.1,必须按 `docs/production-readiness.md` 和 `docs/templates/production-readiness-checklist.md` 收口。
10
+
11
+ 支持范围:
12
+
13
+ - single repo
14
+ - bounded task
15
+ - explicit task source
16
+ - explicit `allowedPaths` / `forbiddenPaths` / write scope
17
+ - shell verification
18
+ - report / doctor / closeout handoff
19
+
20
+ 非目标:
21
+
22
+ - automatic merge
23
+ - automatic release
24
+ - production secrets
25
+ - production database
26
+ - high-risk migration
27
+ - online Worker Pool
28
+ - writable Dynamic Workflow sharded migration
29
+
30
+ 失败分类是路由字段,不是主状态;不要覆盖 `.harness/dag-runs/completed/**` 的原始事实。报告和 handoff 应保留:
31
+
32
+ ```text
33
+ raw_failure_category
34
+ dag_normalized_failure_category
35
+ product_line_failure_category
36
+ recommended_follow_up
37
+ ```
38
+
39
+ product-line taxonomy 的事实源是 `docs/design/state-and-failure-taxonomy.md`。
40
+
41
+ ### Verify 始终在本地跑
42
+ `verify` step 跑确定性命令(check-repo.sh + tests + typecheck)。**不**调用 pi。因此快且可靠。
43
+
44
+ ### Verify strategy knobs
45
+ 需要更紧的 verify 控制时,用 task-level config:
46
+ ```json
47
+ {
48
+ "verifyPreset": "auto",
49
+ "verifyMode": "parallel",
50
+ "verifyRetryCount": 0,
51
+ "verifyFailFast": false
52
+ }
53
+ ```
54
+
55
+ - `verifyPreset`:`auto | quick | standard | full`
56
+ - `auto`:`small -> quick`,`medium -> standard`,`large -> full`
57
+ - 默认 `parallel`
58
+ - 命令争抢共享资源时用 `serial`
59
+ - `verifyFailFast` 仅在 `serial` mode 有意义
60
+ - retry 保持小;用于 flaky 环境问题,不要掩盖真实失败
61
+
62
+ ### Verify 后的 goal completion audit
63
+ - 有 active task goal 且 `verify` 通过时,loop-agent 跑 goal completion audit。
64
+ - 若 `source/需求.md` 仍有未勾 checklist(`- [ ]`),task **不会**以 completed 结束。
65
+ - 若确定性 requirement coverage audit 发现未覆盖需求,task **不会**以 completed 结束。
66
+ - `explicitly_out_of_scope` 需求(如 `## 非目标` 下)**不算** coverage gap。
67
+ - 独立 audit 报告用 `handoff coverage <task-id> [--json|--markdown]`。
68
+ - task status、source/artifacts、DAG outcome、verification 记录可能 drift 时用 `dag reconcile-tasks --glob '<pattern>' [--json|--markdown]`。默认仅报告;`--patch` 不能伪造 verification evidence。
69
+
70
+ ### Verify 默认保存进度
71
+ `verify` 成功后,loop-agent 默认:
72
+
73
+ 1. 在当前 task scope 内选文件
74
+ 2. 跑 `git add`
75
+ 3. 创建 commit 保存已验证进度
76
+
77
+ 默认行为:
78
+
79
+ - `autoCommitAfterVerify: true`
80
+ - commit message:`chore(task): save verified progress for <taskId>`
81
+
82
+ `task.json` 可选覆盖:
83
+
84
+ ```json
85
+ {
86
+ "autoCommitAfterVerify": false,
87
+ "autoCommitMessage": "docs(workflow): save verified progress"
88
+ }
89
+ ```
90
+
91
+ 最佳实践:保持 `allowedPaths` 准确。auto-commit 用 task path 约束,避免把无关 dirty 文件扫进 progress commit。
92
+
93
+ ### Cursor bounded write 后的独立复核
94
+
95
+ Cursor bounded execution 完成后,主会话必须独立执行:
96
+
97
+ ```bash
98
+ git status --short
99
+ git diff --stat
100
+ bash scripts/check-repo.sh
101
+ npm run lint
102
+ npm test
103
+ npm run typecheck
104
+ loop-agent inspect
105
+ loop-agent docs audit
106
+ loop-agent handoff check <task-id>
107
+ ```
108
+
109
+ Cursor 自己报告的完成不算 verification fact;以上命令的 exit code 与输出才是完成声明的证据。
110
+
111
+ ### 失败处理
112
+
113
+ child agent 失败时:
114
+
115
+ - **业务/测试失败**:让 child agent 在同一 task bounds 内修复
116
+ - **Workflow runtime 失败**(如 `loop-agent` runtime 问题、部分 artifact 生成、输出聚合 crash):保持 task contract,但允许 main agent 或 child agent 在同一 scoped implementation 内手动完成,仍跑 `verify`
117
+ - **意外残留**(tmp 文件、探索性 mock、scratch 输出):handoff 前删除
118
+
119
+ ### Closeout 规则
120
+ workflow/runtime/docs/skill 变更结束时:
121
+ ```bash
122
+ loop-agent docs audit
123
+ loop-agent handoff check <task-id>
124
+ ```
125
+
126
+ active exec plan 实质完成时,用 `docs archive` 归档并更新 active/completed 索引,勿留 stale active status。
127
+
128
+ failed DAG run 不应生成成功式 closeout。它应该生成 failure handoff,至少包含 what failed、evidence、classification、recommended follow-up、safe retry conditions 和 human decision needed。