@fitlab-ai/agent-infra 0.9.15 → 0.11.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 (224) hide show
  1. package/README.md +2 -6
  2. package/README.zh-CN.md +2 -6
  3. package/bin/internal-cli.sh +0 -13
  4. package/dist/bin/internal-cli.js +11 -49
  5. package/dist/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.js +6 -2
  6. package/dist/lib/agent-clients/adapters/codex-lifecycle/store.js +43 -3
  7. package/dist/lib/fs/durable-write.js +2 -0
  8. package/dist/lib/internal/cli-route-inventory.js +3 -4
  9. package/dist/lib/internal/manual-validation.js +17 -8
  10. package/dist/lib/internal/platform-comment.js +60 -2
  11. package/dist/lib/internal/task-artifact.js +1 -1
  12. package/dist/lib/internal/task-finalization.js +2 -2
  13. package/dist/lib/internal/task-lifecycle.js +4 -4
  14. package/dist/lib/internal/task-operation-registry.js +22 -13
  15. package/dist/lib/internal/task-orchestration.js +2 -2
  16. package/dist/lib/internal/task-review.js +12 -7
  17. package/dist/lib/platform/activity-recovery.js +159 -0
  18. package/dist/lib/platform/issue-comments.js +89 -31
  19. package/dist/lib/platform/issues.js +1 -1
  20. package/dist/lib/platform/pr-change-report.js +5 -4
  21. package/dist/lib/platform/pr-summary.js +64 -32
  22. package/dist/lib/platform/pull-requests.js +3 -3
  23. package/dist/lib/platform/task-comment-projection.js +70 -0
  24. package/dist/lib/platform/task-identities.js +2 -9
  25. package/dist/lib/platform/task-recovery.js +55 -0
  26. package/dist/lib/platform/verification-sync.js +45 -7
  27. package/dist/lib/pr-review/evidence-grading.js +4 -8
  28. package/dist/lib/sandbox/commands/rm.js +21 -2
  29. package/dist/lib/sandbox/control/executor.js +4 -2
  30. package/dist/lib/sandbox/control/server.js +29 -9
  31. package/dist/lib/sandbox/control/state.js +7 -1
  32. package/dist/lib/sandbox/control/task-workflow.js +1 -1
  33. package/dist/lib/sandbox/control/workflow-executor.js +87 -35
  34. package/dist/lib/sandbox/index.js +1 -2
  35. package/dist/lib/sandbox/removal.js +116 -1011
  36. package/dist/lib/sandbox/workspace-identity.js +17 -1
  37. package/dist/lib/server/process-state.js +17 -5
  38. package/dist/lib/task/artifact-command.js +11 -30
  39. package/dist/lib/task/artifact-operations.js +17 -231
  40. package/dist/lib/task/artifact-recovery.js +476 -0
  41. package/dist/lib/task/artifact-repair-intent.js +90 -39
  42. package/dist/lib/task/commit-operation.js +31 -4
  43. package/dist/lib/task/control-authority.js +39 -8
  44. package/dist/lib/task/control-recovery.js +14 -2
  45. package/dist/lib/task/create-service.js +1 -8
  46. package/dist/lib/task/delegation-receipts.js +64 -3
  47. package/dist/lib/task/events.js +165 -23
  48. package/dist/lib/task/human-override.js +5 -8
  49. package/dist/lib/task/intermediate-cleanup.js +91 -8
  50. package/dist/lib/task/lifecycle-recovery.js +549 -0
  51. package/dist/lib/task/lifecycle.js +12 -3
  52. package/dist/lib/task/local-artifact-finalization.js +212 -123
  53. package/dist/lib/task/manual-validation-receipt.js +5 -1
  54. package/dist/lib/task/orchestration.js +52 -2
  55. package/dist/lib/task/pr-delivery-fact.js +12 -56
  56. package/dist/lib/task/recovery-warning.js +19 -0
  57. package/dist/lib/task/review-command.js +3 -2
  58. package/dist/lib/task/review-finalization.js +294 -74
  59. package/dist/lib/{host-control → task}/secure-fs.js +8 -19
  60. package/dist/lib/task/short-id.js +15 -7
  61. package/dist/lib/task/task-execution-lock.js +1 -1
  62. package/dist/lib/task/verification-engine.js +3 -14
  63. package/dist/lib/task/workflow-command.js +2 -1
  64. package/dist/lib/task/workflow-dispatch.js +161 -0
  65. package/dist/lib/version.js +1 -11
  66. package/dist/lifecycle-build-manifest.json +3 -3
  67. package/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.ts +7 -2
  68. package/lib/agent-clients/adapters/codex-lifecycle/store.ts +55 -3
  69. package/lib/fs/durable-write.ts +1 -0
  70. package/lib/internal/cli-route-inventory.ts +3 -4
  71. package/lib/internal/manual-validation.ts +17 -8
  72. package/lib/internal/platform-comment.ts +53 -2
  73. package/lib/internal/task-artifact.ts +1 -1
  74. package/lib/internal/task-finalization.ts +1 -1
  75. package/lib/internal/task-lifecycle.ts +5 -4
  76. package/lib/internal/task-operation-registry.ts +22 -13
  77. package/lib/internal/task-orchestration.ts +1 -1
  78. package/lib/internal/task-review.ts +11 -7
  79. package/lib/platform/activity-recovery.ts +179 -0
  80. package/lib/platform/issue-comments.ts +105 -30
  81. package/lib/platform/issues.ts +1 -1
  82. package/lib/platform/pr-change-report.ts +7 -5
  83. package/lib/platform/pr-summary.ts +64 -32
  84. package/lib/platform/pull-requests.ts +3 -3
  85. package/lib/platform/task-comment-projection.ts +79 -0
  86. package/lib/platform/task-identities.ts +3 -14
  87. package/lib/platform/task-recovery.ts +54 -0
  88. package/lib/platform/verification-sync.ts +48 -11
  89. package/lib/pr-review/evidence-grading.ts +4 -9
  90. package/lib/sandbox/commands/rm.ts +34 -2
  91. package/lib/sandbox/control/executor.ts +4 -2
  92. package/lib/sandbox/control/protocol.ts +6 -1
  93. package/lib/sandbox/control/server.ts +30 -10
  94. package/lib/sandbox/control/state.ts +9 -1
  95. package/lib/sandbox/control/task-workflow.ts +1 -1
  96. package/lib/sandbox/control/workflow-executor.ts +106 -35
  97. package/lib/sandbox/index.ts +1 -2
  98. package/lib/sandbox/removal.ts +126 -1128
  99. package/lib/sandbox/workspace-identity.ts +19 -3
  100. package/lib/server/process-state.ts +26 -5
  101. package/lib/task/artifact-command.ts +12 -29
  102. package/lib/task/artifact-operations.ts +22 -252
  103. package/lib/task/artifact-recovery.ts +572 -0
  104. package/lib/task/artifact-repair-intent.ts +126 -51
  105. package/lib/task/commit-operation.ts +35 -4
  106. package/lib/task/control-authority.ts +48 -15
  107. package/lib/task/control-recovery.ts +13 -1
  108. package/lib/task/create-service.ts +1 -10
  109. package/lib/task/delegation-receipts.ts +73 -2
  110. package/lib/task/events.ts +188 -24
  111. package/lib/task/human-override.ts +5 -8
  112. package/lib/task/intermediate-cleanup.ts +66 -12
  113. package/lib/task/lifecycle-recovery.ts +691 -0
  114. package/lib/task/lifecycle.ts +13 -4
  115. package/lib/task/local-artifact-finalization.ts +249 -131
  116. package/lib/task/manual-validation-receipt.ts +5 -1
  117. package/lib/task/orchestration.ts +65 -0
  118. package/lib/task/pr-delivery-fact.ts +15 -62
  119. package/lib/task/recovery-warning.ts +21 -0
  120. package/lib/task/review-command.ts +2 -1
  121. package/lib/task/review-finalization.ts +298 -84
  122. package/lib/{host-control → task}/secure-fs.ts +10 -32
  123. package/lib/task/short-id.ts +27 -5
  124. package/lib/task/task-execution-lock.ts +1 -1
  125. package/lib/task/verification-engine.ts +3 -17
  126. package/lib/task/verification-types.ts +0 -2
  127. package/lib/task/workflow-command.ts +2 -1
  128. package/lib/task/workflow-dispatch.ts +171 -0
  129. package/lib/version.ts +1 -15
  130. package/package.json +1 -1
  131. package/templates/.agents/rules/create-issue.en.md +1 -1
  132. package/templates/.agents/rules/create-issue.zh-CN.md +1 -1
  133. package/templates/.agents/rules/issue-sync.en.md +12 -2
  134. package/templates/.agents/rules/issue-sync.zh-CN.md +13 -5
  135. package/templates/.agents/rules/local-artifact-repair.en.md +47 -39
  136. package/templates/.agents/rules/local-artifact-repair.zh-CN.md +45 -36
  137. package/templates/.agents/skills/analyze-task/SKILL.en.md +6 -6
  138. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +6 -6
  139. package/templates/.agents/skills/analyze-task/config/verify.en.json +1 -1
  140. package/templates/.agents/skills/analyze-task/config/verify.zh-CN.json +1 -1
  141. package/templates/.agents/skills/block-task/SKILL.en.md +2 -2
  142. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +2 -2
  143. package/templates/.agents/skills/block-task/config/verify.json +1 -1
  144. package/templates/.agents/skills/cancel-task/SKILL.en.md +3 -3
  145. package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +3 -3
  146. package/templates/.agents/skills/cancel-task/config/verify.json +1 -1
  147. package/templates/.agents/skills/code-task/SKILL.en.md +7 -7
  148. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +8 -8
  149. package/templates/.agents/skills/code-task/config/verify.en.json +1 -1
  150. package/templates/.agents/skills/code-task/config/verify.zh-CN.json +1 -1
  151. package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +1 -1
  152. package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +1 -1
  153. package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +1 -1
  154. package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +1 -1
  155. package/templates/.agents/skills/complete-task/SKILL.en.md +2 -2
  156. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +2 -2
  157. package/templates/.agents/skills/complete-task/config/verify.en.json +2 -2
  158. package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +2 -2
  159. package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +1 -1
  160. package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +1 -1
  161. package/templates/.agents/skills/create-pr/SKILL.en.md +2 -2
  162. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +2 -2
  163. package/templates/.agents/skills/create-pr/config/verify.json +1 -1
  164. package/templates/.agents/skills/create-pr/reference/pr-body-template.en.md +2 -2
  165. package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +2 -2
  166. package/templates/.agents/skills/create-task/SKILL.en.md +5 -5
  167. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +5 -5
  168. package/templates/.agents/skills/create-task/config/verify.json +1 -1
  169. package/templates/.agents/skills/import-issue/SKILL.en.md +8 -8
  170. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +8 -8
  171. package/templates/.agents/skills/import-issue/config/verify.json +2 -2
  172. package/templates/.agents/skills/plan-task/SKILL.en.md +4 -4
  173. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +4 -4
  174. package/templates/.agents/skills/plan-task/config/verify.en.json +1 -1
  175. package/templates/.agents/skills/plan-task/config/verify.zh-CN.json +1 -1
  176. package/templates/.agents/skills/restore-task/SKILL.en.md +11 -6
  177. package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +11 -6
  178. package/templates/.agents/skills/restore-task/config/verify.json +1 -1
  179. package/templates/.agents/skills/review-analysis/SKILL.en.md +3 -3
  180. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +3 -3
  181. package/templates/.agents/skills/review-analysis/config/verify.en.json +1 -1
  182. package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +1 -1
  183. package/templates/.agents/skills/review-analysis/reference/report-template.en.md +7 -7
  184. package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +6 -6
  185. package/templates/.agents/skills/review-code/SKILL.en.md +5 -4
  186. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +5 -4
  187. package/templates/.agents/skills/review-code/config/verify.en.json +1 -1
  188. package/templates/.agents/skills/review-code/config/verify.zh-CN.json +1 -1
  189. package/templates/.agents/skills/review-code/reference/report-template.en.md +12 -12
  190. package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +12 -12
  191. package/templates/.agents/skills/review-plan/SKILL.en.md +3 -3
  192. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +3 -3
  193. package/templates/.agents/skills/review-plan/config/verify.en.json +1 -1
  194. package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +1 -1
  195. package/templates/.agents/skills/review-plan/reference/report-template.en.md +7 -7
  196. package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +7 -7
  197. package/templates/.agents/skills/review-pr/config/verify.en.json +1 -1
  198. package/templates/.agents/skills/review-pr/config/verify.zh-CN.json +1 -1
  199. package/templates/.agents/skills/review-pr/reference/evidence-grading.en.md +3 -3
  200. package/templates/.agents/skills/review-pr/reference/evidence-grading.zh-CN.md +3 -3
  201. package/templates/.agents/skills/run-manual-validation/config/verify.en.json +1 -1
  202. package/templates/.agents/skills/run-manual-validation/config/verify.zh-CN.json +1 -1
  203. package/templates/.agents/skills/run-task/SKILL.en.md +1 -1
  204. package/templates/.agents/skills/run-task/SKILL.zh-CN.md +1 -1
  205. package/templates/.agents/templates/task.en.md +1 -1
  206. package/templates/.agents/templates/task.zh-CN.md +1 -1
  207. package/templates/.claude/commands/import-issue.en.md +1 -1
  208. package/templates/.claude/commands/import-issue.zh-CN.md +1 -1
  209. package/templates/.claude/commands/restore-task.en.md +1 -1
  210. package/templates/.claude/commands/restore-task.zh-CN.md +1 -1
  211. package/dist/lib/host-control/audit.js +0 -19
  212. package/dist/lib/host-control/client.js +0 -142
  213. package/dist/lib/host-control/command.js +0 -49
  214. package/dist/lib/host-control/path.js +0 -160
  215. package/dist/lib/host-control/server.js +0 -159
  216. package/dist/lib/host-control/service.js +0 -112
  217. package/dist/lib/internal/host-control.js +0 -28
  218. package/lib/host-control/audit.ts +0 -22
  219. package/lib/host-control/client.ts +0 -172
  220. package/lib/host-control/command.ts +0 -60
  221. package/lib/host-control/path.ts +0 -167
  222. package/lib/host-control/server.ts +0 -180
  223. package/lib/host-control/service.ts +0 -133
  224. package/lib/internal/host-control.ts +0 -28
@@ -1,57 +1,66 @@
1
- # 通用规则 - 模型驱动的本地产物修复
1
+ # 通用规则 - 模型驱动的本地产物恢复
2
2
 
3
- 本规则适用于 `analyze-task`、`plan-task`、`code-task` 在 completed 事件前处理**同一个受控本地产物**,以及 `review-analysis`、`review-plan`、`review-code` 在 finalizer 失败后处理**同一个受控 review artifact** 的场景。它不适用于 task.md、账本、receipt、源码、Git、平台资源或生命周期状态。
3
+ 本规则适用于 `analyze-task`、`plan-task`、`code-task` 的本地产物完成前门禁,以及三个 review skill 的 summary finalizer。它只处理当前 task 目录内的一个 canonical artifact;不适用于 `task.md`、账本、receipt、源码、Git、平台资源或生命周期状态。
4
4
 
5
- ## 分析、方案和代码产物完成前门禁
5
+ ## 完成前门禁
6
6
 
7
- - `analyze-task`、`plan-task` 和 `code-task` 必须在发布 completed 事件前调用 `task-artifact ... finalize-local`;只有同一次返回的 `artifactSha256` 和 `semanticDigest` 才能传给 completed 事件。
8
- - `finalize-local` 不修改产物或任务状态,但会在仓库工作区写入一次性的本地 provenance intent。返回 `failed` 时,只有 `repairable=true` 且诊断明确为一个可证明安全的结构操作(当前共享引擎操作为 `replace-line` 或 `insert-section`),模型才可在同一产物中执行一次最小编辑,然后完整重跑同一调用;每次实际字节修改计一次,最多 8 次。
9
- - 首次可修复失败的 semantic digest 会保存在该 intent 中;后续 `passed` 必须匹配该基线,completed event 还必须在任务锁内验证并在写 task.md 前原子转换为 `consumed` 状态。消费失败时不得写任务;转换后的 intent 是可重试的 durable 记录,成功写入后不再执行可能失败的后置删除。不得用重新计算的新摘要替换失败基线,也不得绕过 finalizer 直接发布 completed event。
10
- - 返回 `failed`、无进展、诊断或指纹重复时不得发布 completed 事件;返回 `passed` 后也不得重新扫描或手工补写摘要。
7
+ - 完成事件前必须运行对应 finalizer;只有同一次返回的 `artifactSha256` 和 `semanticDigest` 才能传给 completed event。
8
+ - preflight 先对当前 stable-read candidate 完整验证,并将验证的 `R` 写入 digest-addressed、只读的 generation;在 journal CAS 前正式 artifact 必须保持 baseline `B`。
9
+ - candidate SHA 是 awaiting 状态的最后一次 stable-read 观测值,不是下一次编辑的 guard。合法 `S` 编辑必须重新验证并在成功后 CAS 为 `R`。
10
+ - 只有在机械安全门通过后,模型才可编辑返回的 `candidatePath`;每次实际字节变化后,用同一 task、stage/family、artifact 和 `--recovery-id` 完整重跑 finalizer。不得直接编辑正式 artifact 后假设它属于候选。
11
+ - preflight 按 `preflight-ready → preflight-commit-started → preflight-passed` 发布 immutable `R`;业务 finalizer 再按 `full-finalizer-ready → commit-started → passed` 将 `F` 发布。`F=R` 复用 active generation。
12
+ - preflight-ready 后 publish 只读取 active/pending generation,绝不再读取可编辑 candidate。
13
+ - candidate-only 是协议授权边界,不是操作系统隔离:拥有同一 UID 且可任意写入宿主文件系统的进程可能篡改 recovery 内部文件;协议会通过身份、指纹和状态校验发现异常并失败关闭,但不承诺独立权限主体或跨平台隔离。
11
14
 
12
15
  ## 授权边界
13
16
 
14
- - finalizer 只负责读取事实、校验状态、规范化成功结果和原子写入;它不维护可修复错误码白名单,不推断 repairability,也不自动选择要删除的报告内容。
15
- - 首次 finalizer 调用不计入修复次数。只有在机械安全门通过后,模型明确判断当前问题能通过最小、可解释的 artifact 修改解决时,才允许编辑。
16
- - 模型只能修改当前 skill 声明的一个普通本地产物,且该文件必须位于当前 task 目录。不得修改 task.md、审查分歧账本、receipt、源码、其他报告或远端资源。
17
- - `changed=false`、错误码或某个格式形状只是诊断事实,不是自动批准。模型必须结合完整诊断、artifact 内容和上下文逐例判断。
17
+ - finalizer 和 recovery core 只校验身份、状态、权限、稳定读取、完整 artifact 语义和指纹;不根据错误码猜测“可修复”,也不提供文本操作白名单。
18
+ - 模型只能修改当前 skill 声明的一个普通 artifact。不得修改 task.md、账本、receipt、源码、其他报告或远端资源。
19
+ - `changed=false`、错误码和格式形状只是诊断事实,不是编辑授权。人工裁决、并发、权限、I/O、身份、provenance 或未知状态无法证明安全时,立即停止。
18
20
 
19
21
  ## 不可绕过的机械安全门
20
22
 
21
- 在每次模型编辑前确认:
23
+ 每次编辑候选前确认:
22
24
 
23
- 1. finalizer 返回失败,且没有已提交的 artifact operation;
24
- 2. 任务、stage、artifact、review round、身份和 provenance 仍然一致;
25
- 3. 目标是当前 task 目录内的普通文件,没有并发冲突、权限错误、I/O 不确定性或目标被替换;
26
- 4. 不改变人工裁决语义、裁决详情或账本身份,也不涉及任务状态、receipt、Git、平台或其他外部副作用;已知且可核验的 pending 人工裁决可以保留,但模型必须证明本次修改与该裁决无关。
25
+ 1. finalizer 返回失败并提供同一 recovery context,且没有正式提交;
26
+ 2. task、family/stage、round、artifact、request/authority 和 baseline 指纹仍匹配;
27
+ 3. `candidatePath` 是 recovery core 生成的受控普通文件,formal target 没有外部变化;
28
+ 4. 修改不改变人工裁决语义、详情或账本身份,也不引入其他副作用。
27
29
 
28
- 任一条件不满足,立即停止,不调用模型编辑。安全门不能被模型的语义判断绕过。
30
+ 任一条件不满足,停止,不编辑、不发布 completed。
29
31
 
30
- ## 动态收敛循环
32
+ ## Durable recovery 状态
33
+
34
+ | 状态 | formal artifact | 允许动作 |
35
+ | --- | --- | --- |
36
+ | `awaiting-preflight-recovery` | baseline `B` | 只编辑 candidate `S`,稳定读取、验证并生成 `R` |
37
+ | `preflight-ready` / `preflight-commit-started` | `B` 或 `R` | 只可从 active immutable `R` reconcile/publish |
38
+ | `preflight-passed` | `R` | 执行业务 finalizer,生成或复用 `F` |
39
+ | `full-finalizer-ready` / `commit-started` | `R` 或 `F` | 只可从 pending immutable `F` reconcile/publish |
40
+ | `passed` | `F` | completed event 校验 final digest 后消费 |
41
+ | `consumed` | `F` | 可由中间产物清理流程回收受控 staging/backup |
42
+ | `aborted` | 已确认恢复的 `B` | 只保留诊断,不得伪造成功 |
31
43
 
32
- 1. 使用固定的 task、stage、artifact 和 orchestrated intent 执行首次 finalizer。
33
- 2. 成功时使用这一次完整结果进入既有完成前门禁;不得重新扫描账本或手工补写摘要。
34
- 3. 失败且安全门通过时,模型读取结构化诊断、当前 artifact 和必要上下文,决定继续修复或停止,并说明修改范围和理由。
35
- 4. 模型选择继续时,只做一次最小 artifact 编辑。只有文件字节实际发生变化,才增加一次 `repairAttempts`,然后完整重跑同一个 finalizer intent。
36
- 5. 每次重跑都重新执行全部安全校验。修复后出现新的、独立且仍局限于该 artifact 的问题,可以再次交给模型判断;不能沿用上一次“可修复”的结论。
37
- 6. 模型无法证明下一步安全,或判断问题属于环境、权限、并发、身份、provenance、状态未知、人工裁决语义/详情不确定或其他非本地问题时,立即停止。已知人工裁决本身不是停止条件。
38
- 7. 诊断重复、artifact 指纹重复、没有实际字节进展或模型没有提出可验证的最小修改时,立即停止。
39
- 8. 每次 skill invocation 最多允许 8 次实际 artifact 修改作为紧急熔断。该上限只防止死循环和资源失控,不是正常业务停止条件,也不表示最多只能修复 8 个问题。达到上限时保留最后结构化诊断并停止。
44
+ intent 使用 current-only schema version 4。旧 schema 直接失败关闭;不添加迁移、adapter 或双写。candidate、baseline、generation 和 intent 位于 repo-local 受控目录,使用 canonical recovery ID、普通文件检查、stable read、task lock 和 expected-value CAS。跨文件不宣称原子性;未知组合返回 indeterminate 并保留现场。
45
+
46
+ ## 动态收敛循环
40
47
 
41
- 修复次数只存在于当前 skill invocation 的内存上下文,不写入 task.md、ledger 或公共 receipt。不得按错误码、技能或问题类型设置不同的正常预算。
48
+ 1. 用固定 invocation 运行 finalizer。
49
+ 2. 失败且安全门通过时,读取结构化诊断和 `candidatePath`,只作一次最小、可解释的候选编辑。
50
+ 3. 确认字节变化后,使用同一 `--recovery-id` 完整重跑全部 finalizer 校验。
51
+ 4. 诊断或指纹重复、无字节进展、恢复状态未知或达到当前 invocation 的 8 次编辑上限时停止;不发布 completed,不生成跨阶段 next-step。
42
52
 
43
- ## 共享结构引擎
53
+ ## 共享入口
44
54
 
45
- 报告骨架由 `agent-infra-internal task-artifact {task-id} init --family {family} --artifact {artifact}` 创建。骨架只写身份、标题和 `artifact-section:{family}:{section-id}` marker,不代表语义完成;槽位必须由当前 skill 填入真实内容。finalizer 返回单一可证明结构操作时,使用同一返回值的 SHA 和 semantic digest 调用 `task-artifact {task-id} repair --family {family} --artifact {artifact} --expected-sha256 {artifact-sha256} --expected-semantic-digest {semantic-digest}`。repair 只执行共享引擎给出的一个结构操作,不写 task.md、ledger、receipt、Git 或平台资源,之后必须完整重跑原 finalizer。
55
+ `task-artifact ... inspect|init|preflight|finalize-local` 和 `task-review ... finalize-summary` 是当前入口。preflight 不发布 task metadata、ledger、formal provenance、completed event 或平台状态;恢复重试使用 finalizer 返回的 `recoveryId`,例如:
46
56
 
47
- ## 完成事件与用户输出
57
+ ```text
58
+ agent-infra-internal task-artifact {task-id} finalize-local --family code --artifact {code-artifact} --recovery-id {recovery-id}
59
+ agent-infra-internal task-review {task-id} finalize-summary --stage code --artifact {review-artifact} --recovery-id {recovery-id}
60
+ ```
48
61
 
49
- - 最终一次完整 finalizer 成功后,必须使用同一次返回的 provenance、账本状态、verdict 和计数发布 review completed 事件;`stageStatus.canAdvance=true` 且结论为 Approved 时才可生成跨阶段 next-step 命令,`canAdvance=false` 时仍须登记结果并路由到同阶段修订/复审。
50
- - 失败、模型停止、无进展、诊断重复或紧急熔断时,不发布 completed 事件,不推进生命周期,不生成跨阶段命令,也不伪造通过结论。
51
- - 停止推进不等于丢弃审查结果。用户输出必须展示 artifact 路径、已安全读取的最后有效 summary/findings、实际 `repairAttempts`、最后结构化诊断和停止原因。
52
- - summary 无法安全解析时,只展示 artifact 路径和原始结构化诊断,不推算计数、不补写结论,并明确生命周期推进已停止但产物仍可查看。
53
- - 停止路径只提示重新运行当前 review skill 或进行人工处理;不能调用 `code-task`、`complete-task` 等跨阶段 helper。
62
+ 不再存在 `task-artifact repair`、`replace-line`、`insert-section` 或 `repairable` 授权。结构引擎只返回诊断和 digest;候选是否安全、如何修改以及何时停止由当前 skill 的机械门和模型逐例判断。
54
63
 
55
64
  ## 生命周期隔离
56
65
 
57
- `complete-task`、告警关闭、恢复任务和其他 task-lifecycle/task-finalization 入口涉及任务状态、receipt、远端结果或归档副作用,不消费本规则。它们继续使用各自的硬失败、同一 intent 重试和状态未知语义。
66
+ completed event 合法地修改 task.md,但必须发生在 finalizer recovery 已 `passed` 且 digest、round、request/authority 全部匹配之后。若 event 写入后 authority 消费失败,保留正式 artifact,使用既有 lifecycle recovery compensation;不得重放 completed 写入或回滚已通过的 artifact。
@@ -72,7 +72,7 @@ Read `task.md` carefully to understand:
72
72
  - currently known affected files and constraints
73
73
 
74
74
  If `task.md` contains these source fields, also read the corresponding source information:
75
- - `issue_number` - Issue
75
+ - `platform_issue_identity` - canonical Issue identity
76
76
  - `codescan_alert_number` - Code Scanning alert
77
77
  - `security_alert_number` - Dependabot alert
78
78
 
@@ -114,7 +114,7 @@ Runs after Step 0 state check and Step 3 (questioning is an external-state actio
114
114
  - if a `pending_question` already exists (the previous question is still unanswered) → restate that `pending_question`, do **not** modify it and do **not** increment `question_count`;
115
115
  - otherwise (no pending question) → pick the single highest-value question (acceptance criteria > scope > ambiguity) and write `## Brainstorming`: `status: asking`, `pending_question: <question>`, `question_count += 1`.
116
116
  2. If `start_date` is empty, write today (`date +%F`), then run `agent-infra-internal task-event {task-id} analyze.awaiting-input --agent {standard-agent-token} --question {question_count}` so the core updates base metadata and Activity Log.
117
- 3. Issue sync (when `issue_number` exists, skip on any failure): run `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}` to update only the **task comment**; keep the `status` label at `pending-design-work`; do **not** publish an analysis artifact comment.
117
+ 3. Issue sync (when a valid `platform_issue_identity` exists, skip on any failure): run `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}` to update only the **task comment**; keep the `status` label at `pending-design-work`; do **not** publish an analysis artifact comment.
118
118
  4. Verification (replaces the step 8 artifact gate): `agent-infra-internal task-verify {task-id} analyze.awaiting-input --format text` (the early-exit set `current_step: requirement-analysis` and wrote `start_date`, so it should pass); also keep `rg -n 'Analyze Task \(Brainstorming\)' .agents/workspace/active/{task-id}/task.md` and the task-comment sync evidence. Do **not** run the artifact gate, nor `check activity-log` / `check platform-sync` (both bind to the analysis artifact path).
119
119
  5. User output: show only the current **single question** plus how to answer/continue (re-trigger `analyze-task {task-ref}` with the answer), and append the `Completed at` line per `.agents/rules/next-step-output.md`.
120
120
  6. **STOP** and wait for the answer. The next trigger returns to this step.
@@ -140,7 +140,7 @@ Before writing this round's `{analysis-artifact}`, create the controlled report
140
140
  agent-infra-internal task-artifact {task-id} init --family analysis --artifact {analysis-artifact} --locale en
141
141
  ```
142
142
 
143
- The skeleton contains identity metadata, stable section markers, and required headings only; real analysis content is required before the completion gate can pass. If the finalizer returns one provably safe structural error, call `task-artifact {task-id} repair --family analysis --artifact {analysis-artifact} --expected-sha256 {artifact-sha256} --expected-semantic-digest {semantic-digest}`, then rerun the same finalizer.
143
+ The skeleton contains identity metadata, stable section markers, and required headings only; real analysis content is required before the completion gate can pass. If the finalizer returns one provably safe structural error, it returns a controlled recovery candidate; edit only its `candidatePath`, then rerun `task-artifact {task-id} finalize-local --family analysis --artifact {analysis-artifact} --recovery-id {recovery-id}` with the same `recoveryId`. Candidate-only is a protocol authorization boundary, not OS isolation; arbitrary same-UID host writers are outside the protocol's protection claim, and fingerprint/state checks fail closed on anomalies.
144
144
 
145
145
  > Steps 6–9 are the **Scenario A (normal output)** path. **Scenario B (ask and early-exit)** already finished its state update, task-comment sync, and verification inside step 4 and STOPped, so it does not enter these steps.
146
146
 
@@ -223,14 +223,14 @@ agent-infra-internal task-artifact {task-id} finalize-local --family analysis --
223
223
  ```
224
224
 
225
225
  - On `status=passed`, save that result's `artifactSha256` and `semanticDigest`; the finalizer has recorded the matching one-shot local provenance intent.
226
- - On `status=failed` with `repairable=true`, apply only the diagnostic's `replace-line` operation once, then rerun the same command completely; count an attempt only after bytes change, up to 8 attempts.
227
- - The first repairable failure's `semanticDigest` is retained as the baseline; a retried `status=passed` result must match it. On baseline mismatch, any other failure, no progress, or a repeated diagnostic, stop without publishing a completed event.
226
+ - On `status=failed` with recovery context, edit only the returned `candidatePath` once after the completion gates pass, then rerun the finalizer completely with the same `recoveryId`; the formal artifact must remain unchanged until commit.
227
+ - The recovery candidate must match the recorded task, round, artifact, baseline, and request identity. On baseline conflict, unknown state, no progress, or repeated failure, stop without publishing a completed event.
228
228
 
229
229
  Use the digests from that same `status=passed` result in `agent-infra-internal task-event {task-id} analyze.completed --agent {standard-agent-token} --initiator {trigger-initiator} --request-id {request-id} --reason-code {reason-code} --artifact {analysis-artifact} --artifact-sha256 {artifact-sha256} --semantic-digest {semantic-digest} {execution-flag}` so the core records the link, stage, agent, metadata, and Activity Log atomically.
230
230
  - {YYYY-MM-DD HH:mm:ss±HH:MM} — **Analyze Task (Round {N})** by {agent} — Analysis completed → {analysis-artifact}
231
231
  ```
232
232
 
233
- If task.md contains a valid `issue_number`, perform these sync actions (skip and continue on any failure):
233
+ If task.md contains a valid `platform_issue_identity`, perform these sync actions (skip and continue on any failure):
234
234
  - Run `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --status pending-design-work --fields`
235
235
  - Run `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`
236
236
  - Run `agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {analysis-artifact} --agent {standard-agent-token}`
@@ -75,7 +75,7 @@ agent-infra-internal task-event {task-id} analyze.started --agent {standard-agen
75
75
  - 当前已知的受影响文件和约束
76
76
 
77
77
  如 `task.md` 包含以下来源字段,补充读取对应来源信息:
78
- - `issue_number` - Issue
78
+ - `platform_issue_identity` - Issue 的 canonical identity
79
79
  - `codescan_alert_number` - Code Scanning 告警
80
80
  - `security_alert_number` - Dependabot 告警
81
81
 
@@ -117,7 +117,7 @@ agent-infra-internal task-event {task-id} analyze.started --agent {standard-agen
117
117
  - 若已存在 `pending_question`(上一问尚未得到答案)→ 复述该 `pending_question`,**不**修改它、**不**增加 `question_count`;
118
118
  - 否则(无待答问题)→ 选最高价值的一个问题(验收标准 > 范围 > 歧义),写入 `## Brainstorming`:`status: asking`、`pending_question: <问题>`、`question_count += 1`。
119
119
  2. 若 `start_date` 为空,写入当日日期(`date +%F`);随后执行 `agent-infra-internal task-event {task-id} analyze.awaiting-input --agent {standard-agent-token} --question {question_count}`,由核心统一更新基础 frontmatter 和 Activity Log。
120
- 3. Issue 同步(存在 `issue_number` 时,任一失败跳过):调用 `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}` 更新 **task 评论**;`status` label 维持 `pending-design-work`;**不**发布分析产物评论。
120
+ 3. Issue 同步(存在有效 `platform_issue_identity` 时,任一失败跳过):调用 `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}` 更新 **task 评论**;`status` label 维持 `pending-design-work`;**不**发布分析产物评论。
121
121
  4. 校验(替代步骤 8 的 artifact gate):`agent-infra-internal task-verify {task-id} analyze.awaiting-input --format text`(早退已置 `current_step: requirement-analysis` 且已写入 `start_date`,预期通过);并保留 `rg -n 'Analyze Task \(Brainstorming\)' .agents/workspace/active/{task-id}/task.md` 与 task 评论同步证据。**不**跑 artifact gate,也不跑 `check activity-log` / `check platform-sync`(二者绑定分析产物路径)。
122
122
  5. 用户输出:只展示当前**单个问题** + 如何回答/继续(再次触发 `analyze-task {task-ref}` 并附答案),并按 `.agents/rules/next-step-output.md` 在末行追加 `Completed at`。
123
123
  6. **STOP**,等待回答。下一次触发回到本步骤。
@@ -143,7 +143,7 @@ agent-infra-internal task-event {task-id} analyze.started --agent {standard-agen
143
143
  agent-infra-internal task-artifact {task-id} init --family analysis --artifact {analysis-artifact}
144
144
  ```
145
145
 
146
- 骨架只包含身份元数据、稳定 section marker 和必需标题;必须填入真实分析内容后才能通过完成门禁。finalizer 返回可证明的单个结构错误时,使用其 SHA 和 semantic digest 调用 `task-artifact {task-id} repair --family analysis --artifact {analysis-artifact} --expected-sha256 {artifact-sha256} --expected-semantic-digest {semantic-digest}`,然后完整重跑 finalizer。
146
+ 骨架只包含身份元数据、稳定 section marker 和必需标题;必须填入真实分析内容后才能通过完成门禁。finalizer 返回可证明的单个结构错误时,会返回受控 recovery candidate;只能编辑返回的 `candidatePath`,然后使用同一个 `recoveryId` 重跑 `task-artifact {task-id} finalize-local --family analysis --artifact {analysis-artifact} --recovery-id {recovery-id}`。candidate-only 是协议授权边界,不是操作系统隔离;同 UID 的任意宿主写入者不在本协议的防护承诺内,异常由指纹/状态校验失败关闭。
147
147
 
148
148
  > 步骤 6–9 属**场景 A(正常产出)**路径。**场景 B(提问早退)**已在步骤 4 内完成状态更新、task 评论同步与校验并 STOP,不进入这些步骤。
149
149
 
@@ -226,11 +226,11 @@ agent-infra-internal task-artifact {task-id} init --family analysis --artifact {
226
226
  agent-infra-internal task-artifact {task-id} finalize-local --family analysis --artifact {analysis-artifact}
227
227
  ```
228
228
  - `status=passed`:保存本次返回的 `artifactSha256` 和 `semanticDigest`;finalizer 已记录对应的一次性本地 provenance intent。
229
- - `status=failed` 且 `repairable=true`:仅按诊断中的 `replace-line` 操作做一次最小修改,然后完整重跑同一命令;实际字节发生变化才计一次 `repairAttempts`,最多 8 次。
230
- - 首次可修复失败的 `semanticDigest` 由 finalizer 保留为基线;重试后的 `status=passed` 必须匹配该基线。基线不匹配、其他失败、无进展或重复诊断:停止,不发布 completed 事件。
229
+ - `status=failed` 且返回 recovery context:完成门禁通过后,只编辑返回的 `candidatePath` 一次,然后使用同一个 `recoveryId` 完整重跑 finalizer;formal artifact 在 commit 前必须保持不变。
230
+ - recovery candidate 必须与记录的任务、轮次、产物、baseline 和 request identity 匹配;基线冲突、未知状态、无进展或重复失败:停止,不发布 completed 事件。
231
231
  - 使用同一次 `status=passed` 返回的摘要执行 `agent-infra-internal task-event {task-id} analyze.completed --agent {standard-agent-token} --initiator {trigger-initiator} --request-id {request-id} --reason-code {reason-code} --artifact {analysis-artifact} --artifact-sha256 {artifact-sha256} --semantic-digest {semantic-digest} {execution-flag}`,由核心登记链接、阶段、代理、时间、版本和 Activity Log。
232
232
 
233
- 如果 task.md 中存在有效的 `issue_number`,执行以下同步操作(任一失败则跳过并继续):
233
+ 如果 task.md 中存在有效的 `platform_issue_identity`,执行以下同步操作(任一失败则跳过并继续):
234
234
  - 调用 `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --status pending-design-work --fields`
235
235
  - 调用 `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`
236
236
  - 调用 `agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {analysis-artifact} --agent {standard-agent-token}`
@@ -24,7 +24,7 @@
24
24
  "expected_action_pattern": "(Analyze Task|Requirement Analysis) \\(Round \\d+\\)"
25
25
  },
26
26
  "platform-sync": {
27
- "when": "issue_number_exists",
27
+ "when": "platform_issue_identity_exists",
28
28
  "expected_status_label": "status: pending-design-work",
29
29
  "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
30
30
  "verify_comment_content": true,
@@ -24,7 +24,7 @@
24
24
  "expected_action_pattern": "(Analyze Task|Requirement Analysis) \\(Round \\d+\\)"
25
25
  },
26
26
  "platform-sync": {
27
- "when": "issue_number_exists",
27
+ "when": "platform_issue_identity_exists",
28
28
  "expected_status_label": "status: pending-design-work",
29
29
  "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
30
30
  "verify_comment_content": true,
@@ -73,9 +73,9 @@ ls .agents/workspace/blocked/{task-id}/task.md
73
73
 
74
74
  ### 6. Sync to Issue (Optional)
75
75
 
76
- Check whether `task.md` includes a valid `issue_number`. If not, skip this step.
76
+ Check whether `task.md` includes a valid `platform_issue_identity`. If not, skip this step.
77
77
 
78
- If a valid `issue_number` exists, run `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --status blocked`.
78
+ If a valid `platform_issue_identity` exists, run `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --status blocked`.
79
79
  Then run `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`.
80
80
 
81
81
  ### 7. Verification Gate
@@ -74,9 +74,9 @@ ls .agents/workspace/blocked/{task-id}/task.md
74
74
 
75
75
  ### 6. 同步到 Issue(可选)
76
76
 
77
- 检查 `task.md` 中是否存在有效的 `issue_number`。如果没有,跳过。
77
+ 检查 `task.md` 中是否存在有效的 `platform_issue_identity`。如果没有,跳过。
78
78
 
79
- 如果存在有效的 `issue_number`,调用 `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --status blocked`。
79
+ 如果存在有效的 `platform_issue_identity`,调用 `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --status blocked`。
80
80
  随后调用 `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}` 更新 task 评论。
81
81
 
82
82
  ### 7. 完成校验
@@ -21,7 +21,7 @@
21
21
  "expected_action_pattern": "(Block Task|Blocked)"
22
22
  },
23
23
  "platform-sync": {
24
- "when": "issue_number_exists",
24
+ "when": "platform_issue_identity_exists",
25
25
  "expected_status_label": "status: blocked",
26
26
  "expected_status_label_key": "blocked"
27
27
  }
@@ -14,7 +14,7 @@ description: >
14
14
 
15
15
  - This command terminates a task that no longer needs to continue and moves it into `completed/`
16
16
  - Cancel only when the task no longer needs implementation, review, or follow-up work
17
- - When a valid `issue_number` exists, Issue sync is required
17
+ - When a valid `platform_issue_identity` exists, Issue sync is required
18
18
 
19
19
  Version stamp rule: when creating or updating `task.md` frontmatter, read `.agents/rules/version-stamp.md` first and write or refresh `agent_infra_version`.
20
20
 
@@ -74,9 +74,9 @@ Confirm the task directory was moved successfully.
74
74
 
75
75
  ### 6. Sync to Issue
76
76
 
77
- Check whether `task.md` contains a valid `issue_number`. If not, skip this step.
77
+ Check whether `task.md` contains a valid `platform_issue_identity`. If not, skip this step.
78
78
 
79
- If a valid `issue_number` exists:
79
+ If a valid `platform_issue_identity` exists:
80
80
  - Run `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --status {reason} --in-labels none --assignees none --milestone none --state closed --close-reason not_planned`
81
81
  - Write the cancellation body to a temporary file and run `agent-infra-internal platform-comment sync {task-id} --kind cancel --body-file {path} --agent {standard-agent-token}`
82
82
  - Run `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`
@@ -14,7 +14,7 @@ description: >
14
14
 
15
15
  - 本命令用于终止一个不再需要继续执行的任务,并转移到 `completed/`
16
16
  - 只有在确认该任务无需继续实现、审查或修复时才可取消
17
- - 有效 `issue_number` 存在时,Issue 同步属于必做项
17
+ - 有效 `platform_issue_identity` 存在时,Issue 同步属于必做项
18
18
 
19
19
  版本戳规则:创建或更新 `task.md` frontmatter 时,先读取 `.agents/rules/version-stamp.md`,并写入或刷新 `agent_infra_version`。
20
20
 
@@ -73,9 +73,9 @@ ls .agents/workspace/completed/{task-id}/task.md
73
73
 
74
74
  ### 6. 同步到 Issue
75
75
 
76
- 检查 `task.md` 中是否存在有效的 `issue_number`。如果没有,跳过此步骤。
76
+ 检查 `task.md` 中是否存在有效的 `platform_issue_identity`。如果没有,跳过此步骤。
77
77
 
78
- 如果存在有效的 `issue_number`:
78
+ 如果存在有效的 `platform_issue_identity`:
79
79
  - 调用 `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --status {reason} --in-labels none --assignees none --milestone none --state closed --close-reason not_planned`
80
80
  - 将取消正文写入临时文件,调用 `agent-infra-internal platform-comment sync {task-id} --kind cancel --body-file {path} --agent {standard-agent-token}`
81
81
  - 调用 `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`
@@ -22,7 +22,7 @@
22
22
  "expected_action_pattern": "(Cancel Task|Cancelled)"
23
23
  },
24
24
  "platform-sync": {
25
- "when": "issue_number_exists",
25
+ "when": "platform_issue_identity_exists",
26
26
  "expected_comment_marker": "<!-- sync-issue:{task-id}:cancel -->",
27
27
  "verify_task_comment_content": true,
28
28
  "expected_comment_marker_key": "cancel"
@@ -24,7 +24,7 @@ Before generating the implementation report, read `.agents/rules/evidence-report
24
24
  - Before generating task or lifecycle Markdown that will be synchronized to an Issue, read `.agents/rules/sync-content-generation.md` and apply its producer-side constraints; the sync path does not parse or rewrite the body
25
25
  - Read `.agents/rules/compatibility-policy.md` before implementation. Implement only the compatibility budget explicitly approved by the plan; never retain old branches, result contracts, or migration shims merely to be “safe”
26
26
  - Fix mode verifies each finding of the latest `review-code` one by one: fix it if it holds, or rebut it and record it under unresolved if it is unfounded/hallucinated; do not expand to issues the review did not list; manual-validation items are out of scope
27
- - Before `code.completed`, the implementation report must pass `task-artifact ... finalize-local --family code`; follow `.agents/rules/local-artifact-repair.md` for any provably safe minimal structural repair in that same report, and pass only that successful call's digests to the completion event
27
+ - Before a checkpoint, ledger write, or `code.completed`, the implementation report must pass `task-artifact ... preflight --family code`. Preflight only validates and seals a generation; `finalize-local` publishes the matching final digest later.
28
28
  - If implementation encounters a key design decision not covered by the plan, run `agent-infra-internal task-ledger {task-id} decision-next-id`, write the returned `HD-N` detail block per `.agents/rules/human-decision-context.md` and determine whether implementation is required, then run `decision-upsert --id {HD-N} --stage code --artifact {code-artifact} --needs-implementation {true|false}`. Do not scan ids, assemble ledger rows, ask mid-flow, or silently expand scope
29
29
  - Do not invoke the `commit` skill or push to a remote; after tests pass, call the shared commit core with `delivery: { mode: 'local' }` to create the local checkpoint. The durable intent must close only after the checkpoint and task state sync succeed; only then emit `code.completed`
30
30
  - Create a new code artifact for each round and never overwrite an older one
@@ -64,7 +64,7 @@ Read `reference/branch-management.md`, ensure the current branch matches the tas
64
64
 
65
65
  ### 3. Narrow the Milestone
66
66
 
67
- **Mandatory; do not skip.** If task.md has a valid `issue_number`, run `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --milestone specific`.
67
+ **Mandatory; do not skip.** If task.md has a valid `platform_issue_identity`, run `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --milestone specific`.
68
68
 
69
69
  > If the milestone remains `X.Y.x`, step 12 `task-verify code.completed` blocks through the typed milestone check.
70
70
 
@@ -112,7 +112,7 @@ When triaging a test failure or unexpected behavior, first read `.agents/rules/d
112
112
 
113
113
  After tests pass, call the shared commit core with `agent-infra-internal git-workflow commit --input {checkpoint-input}`. Pass `delivery: { "mode": "local" }`, explicit paths, expected HEAD/tree, task ref, agent, and the code round. This creates only a local checkpoint and does not contact a remote. The core writes a durable intent before committing and removes it after task-writer synchronization; do not emit `code.completed` if either checkpoint or task synchronization fails.
114
114
 
115
- After the checkpoint succeeds, when task.md has an `issue_number`, run `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --in-labels from-diff --base {delivery-base-ref}`. The task-bound `delivery_base_ref` is the only source for Issue `in:` evidence; record a warning and stop this round without emitting `code.completed` if this sync fails.
115
+ After the checkpoint succeeds, when task.md has a `platform_issue_identity`, run `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --in-labels from-diff --base {delivery-base-ref}`. The task-bound `delivery_base_ref` is the only source for Issue `in:` evidence; record a warning and stop this round without emitting `code.completed` if this sync fails.
116
116
 
117
117
  ### 9. Write the Code Report
118
118
 
@@ -122,7 +122,7 @@ Before writing this round's `{code-artifact}`, create the controlled report skel
122
122
  agent-infra-internal task-artifact {task-id} init --family code --artifact {code-artifact} --locale en
123
123
  ```
124
124
 
125
- The skeleton contains identity metadata, stable section markers, and required headings only; real implementation and verification content is required before the completion gate can pass. If the finalizer returns one provably safe structural error, call `task-artifact {task-id} repair --family code --artifact {code-artifact} --expected-sha256 {artifact-sha256} --expected-semantic-digest {semantic-digest}`, then rerun the same finalizer.
125
+ The skeleton contains identity metadata, stable section markers, and required headings only; real implementation and verification content is required before the completion gate can pass. If the finalizer returns one provably safe structural error, it returns a controlled recovery candidate; edit only its `candidatePath`, then rerun `task-artifact {task-id} finalize-local --family code --artifact {code-artifact} --recovery-id {recovery-id}` with the same `recoveryId`. Candidate-only is a protocol authorization boundary, not OS isolation; arbitrary same-UID host writers are outside the protocol's protection claim, and fingerprint/state checks fail closed on anomalies.
126
126
 
127
127
  Create `.agents/workspace/active/{task-id}/{code-artifact}`.
128
128
 
@@ -139,8 +139,8 @@ echo "$finalizer"
139
139
  ```
140
140
 
141
141
  - `status=0` with `finalizer.status="passed"`: bind `{artifact-sha256}` and `{semantic-digest}` from this result.
142
- - `status=1` with `repairable=true` and a diagnostic explicitly describing a one-line replacement: confirm task, round, artifact, and provenance are unchanged; edit only that `code*.md` once, confirm the bytes changed, then rerun the same command completely.
143
- - For any other failure, lack of progress, repeated diagnostic, or eight actual report edits, stop without publishing `code.completed`.
142
+ - `status=1` with recovery context: confirm task, round, artifact, baseline, and request identity are unchanged; edit only the returned `candidatePath` once, confirm the bytes changed, then rerun the same finalizer completely with the same `recoveryId`; `baseline`, `final`, `publish`, and `intent` remain framework-internal state and must not be edited.
143
+ - For any other failure, external formal-artifact change, lack of progress, or recovery identity mismatch, stop without publishing `code.completed`.
144
144
 
145
145
  Do not rescan or manually write digest data; the completion event must include `--artifact-sha256 {artifact-sha256} --semantic-digest {semantic-digest}` from the successful finalizer result.
146
146
 
@@ -148,7 +148,7 @@ Do not rescan or manually write digest data; the completion event must include `
148
148
 
149
149
  After requirement checkboxes are updated, run the initial event `agent-infra-internal task-event {task-id} code.completed --agent {standard-agent-token} --initiator {trigger-initiator} --request-id {request-id} --reason-code {reason-code} --artifact {code-artifact} --artifact-sha256 {artifact-sha256} --semantic-digest {semantic-digest} --files-modified {n} --tests-passed {n} {execution-flag}`; in fix mode add `--fix-for {review-artifact} --blockers {n} --major {n} --minor {n} --manual-validation {n} {execution-flag}` instead; in decision mode add `--implementation-input {input-id}` to the initial counts. The core atomically records the artifact link, stage, metadata, done log, and decision-input consumption.
150
150
 
151
- If task.md has a valid `issue_number`, read `.agents/rules/issue-sync.md`, then (status/comment failures follow the warning rules; an Issue `in:` evidence failure must not emit `code.completed`):
151
+ If task.md has a valid `platform_issue_identity`, read `.agents/rules/issue-sync.md`, then (status/comment failures follow the warning rules; an Issue `in:` evidence failure must not emit `code.completed`):
152
152
  - Run `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --status in-progress`
153
153
  - Run `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`
154
154
  - Run `agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {code-artifact} --agent {standard-agent-token}`
@@ -24,7 +24,7 @@ description: >
24
24
  - 生成会同步到 Issue 的任务或生命周期 Markdown 前,先读取 `.agents/rules/sync-content-generation.md` 并遵循其中的生成端约束;同步端不解析或改写正文
25
25
  - 实现前读取 `.agents/rules/compatibility-policy.md`;只实现方案明确批准的兼容预算,不以“稳妥”为由保留旧分支、旧结果契约或迁移 shim
26
26
  - 修复模式逐条核实最新 `review-code` 的发现:成立则修复,判定为不成立/幻觉则在报告中反驳并记入 unresolved;不擅自扩大到审查未列出的问题;manual-validation 项不在修复范围
27
- - 实现报告在 `code.completed` 前必须通过 `task-artifact ... finalize-local --family code`;按 `.agents/rules/local-artifact-repair.md` 处理同一报告内可证明安全的最小结构修复,并只把同一次通过结果的摘要传给完成事件
27
+ - 实现报告在 checkpoint、账本和 `code.completed` 前必须先通过 `task-artifact ... preflight --family code`;preflight 只验证并封存 generation,不发布 formal/task/ledger/platform 状态。随后 `finalize-local` 才发布同一次通过的 digest。
28
28
  - 实现中遇到方案未覆盖的关键设计决策时,先调用 `agent-infra-internal task-ledger {task-id} decision-next-id` 取得 `HD-N`,按 `.agents/rules/human-decision-context.md` 写入实现报告的 `## 人工裁决待办` 详情块并判断是否需要实现,再调用 `decision-upsert --id {HD-N} --stage code --artifact {code-artifact} --needs-implementation {true|false}`;不得扫描编号、手写账本行、中途提问或擅自扩范围
29
29
  - 不调用 `commit` 技能,也不推送远端;测试通过后直接调用共享 commit core 的 `delivery: { mode: 'local' }` 创建本地 checkpoint。checkpoint 使用 durable intent,只有 checkpoint 与 task 状态同步成功后才发送 `code.completed`
30
30
  - 每轮实现都创建新的实现产物,不覆盖旧文件
@@ -91,7 +91,7 @@ agent-infra-internal task-snapshot {task-id} --format text
91
91
 
92
92
  ### 3. 收窄里程碑
93
93
 
94
- **必须执行,不得跳过。** 如果 task.md 中存在有效的 `issue_number`,调用 `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --milestone specific`;里程碑推断、权限降级与幂等写入由 internal core 处理。
94
+ **必须执行,不得跳过。** 如果 task.md 中存在有效的 `platform_issue_identity`,调用 `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --milestone specific`;里程碑推断、权限降级与幂等写入由 internal core 处理。
95
95
 
96
96
  > 若跳过或收窄后仍为 `X.Y.x`,步骤 12 的 `task-verify code.completed` 会通过 typed milestone check 截停本轮。
97
97
 
@@ -148,9 +148,9 @@ echo "$result"
148
148
 
149
149
  如果测试失败,先尝试修复并重新运行测试。只有在确认存在外部阻塞、环境缺失或需求不明确且超出任务范围时,才可以停止。
150
150
 
151
- 测试通过后,通过 `agent-infra-internal git-workflow commit --input {checkpoint-input}` 调用共享 commit core,输入 `delivery: { "mode": "local" }`、明确 paths、expected HEAD/tree、task ref、agent 和 code round。该调用只创建本地 checkpoint,不访问远端;core 会在 commit 前写入 durable intent,并在 task writer 成功后清理 intent。checkpoint 失败或 task 状态未闭合时,不得发送 `code.completed`。
151
+ 测试通过后,先创建报告并运行 `task-artifact {task-id} preflight --family code --artifact {code-artifact}`;preflight 失败只允许在同一受控 candidate 中修复并完整重跑,且不得产生 checkpoint、ledger、completed 或平台副作用。preflight 通过后,才通过 `agent-infra-internal git-workflow commit --input {checkpoint-input}` 调用共享 commit core,输入 `delivery: { "mode": "local" }`、明确 paths、expected HEAD/tree、task ref、agent 和 code round。该调用只创建本地 checkpoint,不访问远端;core 会在 commit 前写入 durable intent,并在 task writer 成功后清理 intent。checkpoint 失败或 task 状态未闭合时,不得发送 `code.completed`。
152
152
 
153
- checkpoint 成功后,若任务存在 `issue_number`,调用 `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --in-labels from-diff --base {delivery-base-ref}`,由 task-bound `delivery_base_ref` 产生 Issue 的 `in:` target;该同步失败时记录 warning 并停止本轮,不发送 `code.completed`。
153
+ checkpoint 成功后,若任务存在 `platform_issue_identity`,调用 `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --in-labels from-diff --base {delivery-base-ref}`,由 task-bound `delivery_base_ref` 产生 Issue 的 `in:` target;该同步失败时记录 warning 并停止本轮,不发送 `code.completed`。
154
154
 
155
155
  排查测试失败或行为不符合预期时,先读取 `.agents/rules/debugging-guide.md`,按其四阶段流程定位根因,禁止盲目改代码重试。
156
156
 
@@ -162,7 +162,7 @@ checkpoint 成功后,若任务存在 `issue_number`,调用 `agent-infra-inte
162
162
  agent-infra-internal task-artifact {task-id} init --family code --artifact {code-artifact}
163
163
  ```
164
164
 
165
- 骨架只包含身份元数据、稳定 section marker 和必需标题;必须填入真实实现与验证内容后才能通过完成门禁。finalizer 返回可证明的单个结构错误时,使用其 SHA 和 semantic digest 调用 `task-artifact {task-id} repair --family code --artifact {code-artifact} --expected-sha256 {artifact-sha256} --expected-semantic-digest {semantic-digest}`,然后完整重跑 finalizer。
165
+ 骨架只包含身份元数据、稳定 section marker 和必需标题;必须填入真实实现与验证内容后才能通过完成门禁。finalizer 返回可证明的单个结构错误时,会返回受控 recovery candidate;只能编辑返回的 `candidatePath`,然后使用同一个 `recoveryId` 重跑 `task-artifact {task-id} finalize-local --family code --artifact {code-artifact} --recovery-id {recovery-id}`。candidate-only 是协议授权边界,不是操作系统隔离;同 UID 的任意宿主写入者不在本协议的防护承诺内,异常由指纹/状态校验失败关闭。
166
166
 
167
167
  创建 `.agents/workspace/active/{task-id}/{code-artifact}`。
168
168
 
@@ -179,8 +179,8 @@ echo "$finalizer"
179
179
  ```
180
180
 
181
181
  - `status=0` 且 `finalizer.status="passed"`:绑定这一次返回的 `{artifact-sha256}` 和 `{semantic-digest}`。
182
- - `status=1` 且返回 `repairable=true`、诊断明确为当前报告中的单行替换:确认任务、轮次、产物和 provenance 未变化后,只编辑该 `code*.md` 一次,确认字节确实变化,再完整重跑同一命令。
183
- - 其他失败、无进展、诊断重复或达到 8 次实际报告编辑:停止,不发布 `code.completed`。
182
+ - `status=1` 且返回 recovery context:确认任务、轮次、产物、baseline 和 request identity 未变化后,只编辑返回的 `candidatePath` 一次,确认字节确实变化,再使用同一个 `recoveryId` 完整重跑同一 finalizer;baseline、final、publish 和 intent 均属于框架内部状态,不得编辑。
183
+ - 其他失败、formal artifact 外部变化、无进展或 recovery identity 不匹配:停止,不发布 `code.completed`。
184
184
 
185
185
  不得重新扫描或手工补写摘要;完成事件必须携带本次 `passed` 结果的 `--artifact-sha256 {artifact-sha256} --semantic-digest {semantic-digest}`。
186
186
 
@@ -194,7 +194,7 @@ echo "$finalizer"
194
194
  - 修复模式:`agent-infra-internal task-event {task-id} code.completed --agent {standard-agent-token} --initiator {trigger-initiator} --request-id {request-id} --reason-code {reason-code} --artifact {code-artifact} --artifact-sha256 {artifact-sha256} --semantic-digest {semantic-digest} --fix-for {review-artifact} --blockers {n} --major {n} --minor {n} --manual-validation {n} {execution-flag}`
195
195
  - 裁决模式:`agent-infra-internal task-event {task-id} code.completed --agent {standard-agent-token} --initiator {trigger-initiator} --request-id {request-id} --reason-code {reason-code} --artifact {code-artifact} --artifact-sha256 {artifact-sha256} --semantic-digest {semantic-digest} --implementation-input {input-id} --files-modified {n} --tests-passed {n} {execution-flag}`
196
196
 
197
- 如果 task.md 中存在有效的 `issue_number`,执行以下同步操作(状态/评论失败按规则记录 warning;Issue `in:` evidence 同步失败不得发送 `code.completed`;边界见 `.agents/rules/issue-sync.md`):
197
+ 如果 task.md 中存在有效的 `platform_issue_identity`,执行以下同步操作(状态/评论失败按规则记录 warning;Issue `in:` evidence 同步失败不得发送 `code.completed`;边界见 `.agents/rules/issue-sync.md`):
198
198
  - 调用 `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --status in-progress`
199
199
  - 调用 `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`
200
200
  - 调用 `agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {code-artifact} --agent {standard-agent-token}`
@@ -30,7 +30,7 @@
30
30
  ]
31
31
  },
32
32
  "platform-sync": {
33
- "when": "issue_number_exists",
33
+ "when": "platform_issue_identity_exists",
34
34
  "expected_status_label": "status: in-progress",
35
35
  "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
36
36
  "verify_comment_content": true,
@@ -30,7 +30,7 @@
30
30
  ]
31
31
  },
32
32
  "platform-sync": {
33
- "when": "issue_number_exists",
33
+ "when": "platform_issue_identity_exists",
34
34
  "expected_status_label": "status: in-progress",
35
35
  "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
36
36
  "verify_comment_content": true,
@@ -4,7 +4,7 @@
4
4
 
5
5
  Run this step only when all of the following are true:
6
6
  - `{task-id}` is valid
7
- - `task.md` frontmatter contains a valid `issue_number`
7
+ - `task.md` frontmatter contains a valid `platform_issue_identity`
8
8
 
9
9
  If either condition is missing, skip this step.
10
10
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  仅当以下条件同时满足时执行:
6
6
  - `{task-id}` 有效
7
- - `task.md` frontmatter 中存在有效 `issue_number`
7
+ - `task.md` frontmatter 中存在有效 `platform_issue_identity`
8
8
 
9
9
  任一条件不满足时,跳过本步骤。
10
10
 
@@ -106,7 +106,7 @@ The coordinator owns pending summary, receipt, completion log, final promotion,
106
106
 
107
107
  After the transaction coordinator succeeds, the core has atomically recorded `manual-validation.completed` with the same transaction/receipt/head identity. Do not append the Activity Log manually.
108
108
 
109
- If the task has a valid `issue_number`, run `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`, then `agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {manual-validation-artifact} --agent {standard-agent-token}`.
109
+ If the task has a valid `platform_issue_identity`, run `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`, then `agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {manual-validation-artifact} --agent {standard-agent-token}`.
110
110
 
111
111
  ### 8. Verification Gate
112
112
 
@@ -106,7 +106,7 @@ coordinator 负责 pending summary、receipt、通过日志、final promotion
106
106
 
107
107
  transaction coordinator 成功后,核心已使用同一 transaction/receipt/head identity 原子登记 `manual-validation.completed`;不要手工补写 Activity Log。
108
108
 
109
- 如任务存在有效 `issue_number`,调用 `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`,再调用 `agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {manual-validation-artifact} --agent {standard-agent-token}`。
109
+ 如任务存在有效 `platform_issue_identity`,调用 `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`,再调用 `agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {manual-validation-artifact} --agent {standard-agent-token}`。
110
110
 
111
111
  ### 8. 完成校验
112
112
 
@@ -135,11 +135,11 @@ Do not write `status/current_step/completed_at/updated_at/agent_infra_version`,
135
135
 
136
136
  ### 4. Sync the Platform While Active
137
137
 
138
- Check whether task.md has a valid `issue_number`. If it does not, skip this step without output.
138
+ Check whether task.md has a valid `platform_issue_identity`. If it does not, skip this step without output.
139
139
 
140
140
  > Issue metadata boundaries live in `.agents/rules/issue-sync.md`; comments use internal platform intents.
141
141
 
142
- When an `issue_number` exists, execute in this exact order:
142
+ When a valid `platform_issue_identity` exists, execute in this exact order:
143
143
 
144
144
  1. Run `agent-infra-internal platform-comment backfill {task-id} --agent {standard-agent-token}` so core publishes only the completion canonical inventory in fixed order and resolves matching historical warnings only after full success.
145
145
  2. Run `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --requirements --fields`.
@@ -134,11 +134,11 @@ Please satisfy the hard prerequisite first, then retry complete-task.
134
134
 
135
135
  ### 4. 在 active 阶段同步平台
136
136
 
137
- 检查 `task.md` 中是否存在有效的 `issue_number`。如果没有,跳过本步骤且不输出任何内容。
137
+ 检查 `task.md` 中是否存在有效的 `platform_issue_identity`。如果没有,跳过本步骤且不输出任何内容。
138
138
 
139
139
  > Issue 元数据边界见 `.agents/rules/issue-sync.md`;评论同步统一调用 internal platform intent。
140
140
 
141
- 如果存在有效的 `issue_number`,严格按以下顺序执行:
141
+ 如果存在有效的 `platform_issue_identity`,严格按以下顺序执行:
142
142
 
143
143
  1. 调用 `agent-infra-internal platform-comment backfill {task-id} --agent {standard-agent-token}`,由 core 仅按 completion canonical inventory 固定顺序补发产物并在全部成功后精确恢复目标历史告警。
144
144
  2. 调用 `agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --requirements --fields`。
@@ -28,7 +28,7 @@
28
28
  "manual-validation": {},
29
29
  "post-review-commit": {},
30
30
  "platform-sync-preflight": {
31
- "when": "issue_number_exists",
31
+ "when": "platform_issue_identity_exists",
32
32
  "expected_comment_marker": "<!-- sync-issue:{task-id}:summary -->",
33
33
  "verify_task_comment_content": false,
34
34
  "sync_checked_requirements": true,
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "required-pr-delivery": {},
42
42
  "platform-sync": {
43
- "when": "issue_number_exists",
43
+ "when": "platform_issue_identity_exists",
44
44
  "verify_task_comment_content": true,
45
45
  "verify_closed_issue_has_no_status_labels": true
46
46
  },
@@ -28,7 +28,7 @@
28
28
  "manual-validation": {},
29
29
  "post-review-commit": {},
30
30
  "platform-sync-preflight": {
31
- "when": "issue_number_exists",
31
+ "when": "platform_issue_identity_exists",
32
32
  "expected_comment_marker": "<!-- sync-issue:{task-id}:summary -->",
33
33
  "verify_task_comment_content": false,
34
34
  "sync_checked_requirements": true,
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "required-pr-delivery": {},
42
42
  "platform-sync": {
43
- "when": "issue_number_exists",
43
+ "when": "platform_issue_identity_exists",
44
44
  "verify_task_comment_content": true,
45
45
  "verify_closed_issue_has_no_status_labels": true
46
46
  },