@fitlab-ai/agent-infra 0.9.15 → 0.10.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 (184) hide show
  1. package/dist/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.js +6 -2
  2. package/dist/lib/agent-clients/adapters/codex-lifecycle/store.js +43 -3
  3. package/dist/lib/fs/durable-write.js +2 -0
  4. package/dist/lib/internal/cli-route-inventory.js +1 -1
  5. package/dist/lib/internal/manual-validation.js +17 -8
  6. package/dist/lib/internal/task-artifact.js +1 -1
  7. package/dist/lib/internal/task-lifecycle.js +2 -2
  8. package/dist/lib/internal/task-operation-registry.js +0 -1
  9. package/dist/lib/internal/task-review.js +4 -4
  10. package/dist/lib/platform/issue-comments.js +16 -10
  11. package/dist/lib/platform/issues.js +1 -1
  12. package/dist/lib/platform/pr-change-report.js +5 -4
  13. package/dist/lib/platform/pr-summary.js +64 -32
  14. package/dist/lib/platform/pull-requests.js +3 -3
  15. package/dist/lib/platform/task-identities.js +2 -9
  16. package/dist/lib/platform/verification-sync.js +6 -2
  17. package/dist/lib/pr-review/evidence-grading.js +4 -8
  18. package/dist/lib/sandbox/commands/rm.js +21 -2
  19. package/dist/lib/sandbox/control/server.js +29 -9
  20. package/dist/lib/sandbox/control/state.js +7 -1
  21. package/dist/lib/sandbox/control/workflow-executor.js +4 -14
  22. package/dist/lib/sandbox/index.js +1 -2
  23. package/dist/lib/sandbox/removal.js +116 -1011
  24. package/dist/lib/sandbox/workspace-identity.js +17 -1
  25. package/dist/lib/task/artifact-command.js +6 -28
  26. package/dist/lib/task/artifact-operations.js +16 -230
  27. package/dist/lib/task/artifact-recovery.js +430 -0
  28. package/dist/lib/task/artifact-repair-intent.js +73 -39
  29. package/dist/lib/task/commit-operation.js +31 -4
  30. package/dist/lib/task/control-authority.js +38 -7
  31. package/dist/lib/task/control-recovery.js +14 -2
  32. package/dist/lib/task/create-service.js +1 -8
  33. package/dist/lib/task/delegation-receipts.js +64 -3
  34. package/dist/lib/task/events.js +164 -22
  35. package/dist/lib/task/human-override.js +5 -8
  36. package/dist/lib/task/intermediate-cleanup.js +66 -8
  37. package/dist/lib/task/lifecycle-recovery.js +549 -0
  38. package/dist/lib/task/lifecycle.js +12 -3
  39. package/dist/lib/task/local-artifact-finalization.js +148 -123
  40. package/dist/lib/task/manual-validation-receipt.js +5 -1
  41. package/dist/lib/task/orchestration.js +52 -2
  42. package/dist/lib/task/pr-delivery-fact.js +12 -56
  43. package/dist/lib/task/recovery-warning.js +19 -0
  44. package/dist/lib/task/review-command.js +1 -0
  45. package/dist/lib/task/review-finalization.js +104 -77
  46. package/dist/lib/task/short-id.js +15 -7
  47. package/dist/lib/task/task-execution-lock.js +1 -1
  48. package/dist/lib/task/verification-engine.js +3 -14
  49. package/dist/lib/task/workflow-command.js +0 -1
  50. package/dist/lib/version.js +1 -11
  51. package/dist/lifecycle-build-manifest.json +3 -3
  52. package/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.ts +7 -2
  53. package/lib/agent-clients/adapters/codex-lifecycle/store.ts +55 -3
  54. package/lib/fs/durable-write.ts +1 -0
  55. package/lib/internal/cli-route-inventory.ts +1 -1
  56. package/lib/internal/manual-validation.ts +17 -8
  57. package/lib/internal/task-artifact.ts +1 -1
  58. package/lib/internal/task-lifecycle.ts +4 -3
  59. package/lib/internal/task-operation-registry.ts +0 -1
  60. package/lib/internal/task-review.ts +4 -4
  61. package/lib/platform/issue-comments.ts +18 -10
  62. package/lib/platform/issues.ts +1 -1
  63. package/lib/platform/pr-change-report.ts +7 -5
  64. package/lib/platform/pr-summary.ts +64 -32
  65. package/lib/platform/pull-requests.ts +3 -3
  66. package/lib/platform/task-identities.ts +3 -14
  67. package/lib/platform/verification-sync.ts +6 -2
  68. package/lib/pr-review/evidence-grading.ts +4 -9
  69. package/lib/sandbox/commands/rm.ts +34 -2
  70. package/lib/sandbox/control/protocol.ts +5 -0
  71. package/lib/sandbox/control/server.ts +30 -10
  72. package/lib/sandbox/control/state.ts +9 -1
  73. package/lib/sandbox/control/workflow-executor.ts +4 -14
  74. package/lib/sandbox/index.ts +1 -2
  75. package/lib/sandbox/removal.ts +126 -1128
  76. package/lib/sandbox/workspace-identity.ts +19 -3
  77. package/lib/task/artifact-command.ts +8 -27
  78. package/lib/task/artifact-operations.ts +21 -251
  79. package/lib/task/artifact-recovery.ts +519 -0
  80. package/lib/task/artifact-repair-intent.ts +99 -51
  81. package/lib/task/commit-operation.ts +35 -4
  82. package/lib/task/control-authority.ts +47 -14
  83. package/lib/task/control-recovery.ts +13 -1
  84. package/lib/task/create-service.ts +1 -10
  85. package/lib/task/delegation-receipts.ts +73 -2
  86. package/lib/task/events.ts +187 -23
  87. package/lib/task/human-override.ts +5 -8
  88. package/lib/task/intermediate-cleanup.ts +50 -12
  89. package/lib/task/lifecycle-recovery.ts +691 -0
  90. package/lib/task/lifecycle.ts +13 -4
  91. package/lib/task/local-artifact-finalization.ts +176 -132
  92. package/lib/task/manual-validation-receipt.ts +5 -1
  93. package/lib/task/orchestration.ts +65 -0
  94. package/lib/task/pr-delivery-fact.ts +15 -62
  95. package/lib/task/recovery-warning.ts +21 -0
  96. package/lib/task/review-command.ts +1 -0
  97. package/lib/task/review-finalization.ts +106 -87
  98. package/lib/task/short-id.ts +27 -5
  99. package/lib/task/task-execution-lock.ts +1 -1
  100. package/lib/task/verification-engine.ts +3 -17
  101. package/lib/task/verification-types.ts +0 -2
  102. package/lib/task/workflow-command.ts +0 -1
  103. package/lib/version.ts +1 -15
  104. package/package.json +1 -1
  105. package/templates/.agents/rules/create-issue.en.md +1 -1
  106. package/templates/.agents/rules/create-issue.zh-CN.md +1 -1
  107. package/templates/.agents/rules/issue-sync.en.md +4 -2
  108. package/templates/.agents/rules/issue-sync.zh-CN.md +4 -3
  109. package/templates/.agents/rules/local-artifact-repair.en.md +46 -39
  110. package/templates/.agents/rules/local-artifact-repair.zh-CN.md +43 -36
  111. package/templates/.agents/skills/analyze-task/SKILL.en.md +6 -6
  112. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +6 -6
  113. package/templates/.agents/skills/analyze-task/config/verify.en.json +1 -1
  114. package/templates/.agents/skills/analyze-task/config/verify.zh-CN.json +1 -1
  115. package/templates/.agents/skills/block-task/SKILL.en.md +2 -2
  116. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +2 -2
  117. package/templates/.agents/skills/block-task/config/verify.json +1 -1
  118. package/templates/.agents/skills/cancel-task/SKILL.en.md +3 -3
  119. package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +3 -3
  120. package/templates/.agents/skills/cancel-task/config/verify.json +1 -1
  121. package/templates/.agents/skills/code-task/SKILL.en.md +7 -7
  122. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +7 -7
  123. package/templates/.agents/skills/code-task/config/verify.en.json +1 -1
  124. package/templates/.agents/skills/code-task/config/verify.zh-CN.json +1 -1
  125. package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +1 -1
  126. package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +1 -1
  127. package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +1 -1
  128. package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +1 -1
  129. package/templates/.agents/skills/complete-task/SKILL.en.md +2 -2
  130. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +2 -2
  131. package/templates/.agents/skills/complete-task/config/verify.en.json +2 -2
  132. package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +2 -2
  133. package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +1 -1
  134. package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +1 -1
  135. package/templates/.agents/skills/create-pr/SKILL.en.md +2 -2
  136. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +2 -2
  137. package/templates/.agents/skills/create-pr/config/verify.json +1 -1
  138. package/templates/.agents/skills/create-pr/reference/pr-body-template.en.md +2 -2
  139. package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +2 -2
  140. package/templates/.agents/skills/create-task/SKILL.en.md +5 -5
  141. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +5 -5
  142. package/templates/.agents/skills/create-task/config/verify.json +1 -1
  143. package/templates/.agents/skills/import-issue/SKILL.en.md +8 -8
  144. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +8 -8
  145. package/templates/.agents/skills/import-issue/config/verify.json +2 -2
  146. package/templates/.agents/skills/plan-task/SKILL.en.md +4 -4
  147. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +4 -4
  148. package/templates/.agents/skills/plan-task/config/verify.en.json +1 -1
  149. package/templates/.agents/skills/plan-task/config/verify.zh-CN.json +1 -1
  150. package/templates/.agents/skills/restore-task/SKILL.en.md +2 -2
  151. package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +2 -2
  152. package/templates/.agents/skills/restore-task/config/verify.json +1 -1
  153. package/templates/.agents/skills/review-analysis/SKILL.en.md +2 -2
  154. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +2 -2
  155. package/templates/.agents/skills/review-analysis/config/verify.en.json +1 -1
  156. package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +1 -1
  157. package/templates/.agents/skills/review-analysis/reference/report-template.en.md +7 -7
  158. package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +6 -6
  159. package/templates/.agents/skills/review-code/SKILL.en.md +2 -2
  160. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +2 -2
  161. package/templates/.agents/skills/review-code/config/verify.en.json +1 -1
  162. package/templates/.agents/skills/review-code/config/verify.zh-CN.json +1 -1
  163. package/templates/.agents/skills/review-code/reference/report-template.en.md +12 -12
  164. package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +12 -12
  165. package/templates/.agents/skills/review-plan/SKILL.en.md +2 -2
  166. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +2 -2
  167. package/templates/.agents/skills/review-plan/config/verify.en.json +1 -1
  168. package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +1 -1
  169. package/templates/.agents/skills/review-plan/reference/report-template.en.md +7 -7
  170. package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +7 -7
  171. package/templates/.agents/skills/review-pr/config/verify.en.json +1 -1
  172. package/templates/.agents/skills/review-pr/config/verify.zh-CN.json +1 -1
  173. package/templates/.agents/skills/review-pr/reference/evidence-grading.en.md +3 -3
  174. package/templates/.agents/skills/review-pr/reference/evidence-grading.zh-CN.md +3 -3
  175. package/templates/.agents/skills/run-manual-validation/config/verify.en.json +1 -1
  176. package/templates/.agents/skills/run-manual-validation/config/verify.zh-CN.json +1 -1
  177. package/templates/.agents/skills/run-task/SKILL.en.md +1 -1
  178. package/templates/.agents/skills/run-task/SKILL.zh-CN.md +1 -1
  179. package/templates/.agents/templates/task.en.md +1 -1
  180. package/templates/.agents/templates/task.zh-CN.md +1 -1
  181. package/templates/.claude/commands/import-issue.en.md +1 -1
  182. package/templates/.claude/commands/import-issue.zh-CN.md +1 -1
  183. package/templates/.claude/commands/restore-task.en.md +1 -1
  184. package/templates/.claude/commands/restore-task.zh-CN.md +1 -1
@@ -9,6 +9,6 @@ agent-infra-internal platform-issue create {task-id} --agent {standard-agent-tok
9
9
  agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --status waiting-for-triage --assignees current --milestone initial --issue-type --fields
10
10
  ```
11
11
 
12
- The core reads only persisted task identity, title, type, description, and requirements, and reuses deterministic `ai task issue-body` rendering. It owns template selection, upstream/capabilities, duplicate prevention, POST outcome boundaries, response validation, and atomic `issue_number` binding.
12
+ The core reads only persisted task identity, title, type, description, and requirements, and reuses deterministic `ai task issue-body` rendering. It owns template selection, upstream/capabilities, duplicate prevention, POST outcome boundaries, response validation, and atomic `platform_issue_identity` binding.
13
13
 
14
14
  `planned|applied|no-op|degraded` exit 0, `failed` exits 1, and `blocked` exits 2. Callers must not fall back to direct platform CLI or GraphQL orchestration.
@@ -8,7 +8,7 @@
8
8
  agent-infra-internal platform-issue create {task-id} --agent {standard-agent-token}
9
9
  ```
10
10
 
11
- 命令只从已落盘 task.md 读取身份、标题、类型、描述与需求,并复用 `ai task issue-body` 的确定性正文渲染。它负责模板选择、upstream/capability、已有绑定检查、非幂等 POST 边界、响应身份校验及通过任务写入内核回写 `issue_number`。
11
+ 命令只从已落盘 task.md 读取身份、标题、类型、描述与需求,并复用 `ai task issue-body` 的确定性正文渲染。它负责模板选择、upstream/capability、已有绑定检查、非幂等 POST 边界、响应身份校验及通过任务写入内核回写 `platform_issue_identity`。
12
12
 
13
13
  创建后的初始元数据使用同一适配层同步:
14
14
 
@@ -12,19 +12,21 @@
12
12
  | `summary` | `<!-- sync-issue:{task-id}:summary -->` |
13
13
  | `cancel` | `<!-- sync-issue:{task-id}:cancel -->` |
14
14
 
15
- `pr-review` content is synced only as an Issue artifact comment (via the `artifact` / `artifactChunk` markers) and is never a `restore-task` recovery source; restore still accepts only an Issue number and reads only registered Issue markers, with no PR source.
15
+ `pr-review` content is synced only as an Issue artifact comment (via the `artifact` / `artifactChunk` markers) and is never a `restore-task` recovery source; restore still accepts only an Issue token and reads only registered Issue markers, with no PR source.
16
16
 
17
17
  Comments use `platform-comment`; Issue resources use `platform-issue`:
18
18
 
19
19
  ```bash
20
20
  agent-infra-internal platform-issue inspect {task-id}
21
21
  agent-infra-internal platform-issue create {task-id} --agent {standard-agent-token}
22
- agent-infra-internal platform-issue bind {task-id} --issue {number} --agent {standard-agent-token}
22
+ agent-infra-internal platform-issue bind {task-id} --issue {issue-token} --agent {standard-agent-token}
23
23
  agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} {desired-state-flags}
24
24
  ```
25
25
 
26
26
  The core owns status/in labels, assignees, milestones, Issue Type, pinned fields, requirements, state, capabilities, dry-run, retries, errors, and idempotency. Omitted flags preserve values; `none` explicitly clears them. Status labels converge to at most one, and ambiguous requirement identity fails closed.
27
27
 
28
+ Task content over the platform comment byte limit is not uploaded; the core returns a skipped operation with `COMMENT_PAYLOAD_TOO_LARGE`. The local task file is unchanged, and platform verification skips the task marker/content check for the same oversized input.
29
+
28
30
  PR event `in:` synchronization uses `agent-infra-internal platform-pr sync-in-labels --pr <N> [--cwd <path>]`. PR files are the event evidence; a unique closing Issue is written and re-read before the PR. Zero or multiple closing Issues update only the PR and return `degraded`; unknown side effects or failed convergence return `blocked` with `IN_LABEL_SYNC_PARTIAL`.
29
31
 
30
32
  `planned|applied|no-op|degraded` exit 0; `failed` exits 1; `blocked` exits 2.
@@ -16,7 +16,7 @@
16
16
 
17
17
  `prSummary` 属于 `.agents/rules/pr-sync.md`,本规则不实现 PR 聚合。
18
18
 
19
- `pr-review` 原文只通过 `artifact` / `artifactChunk` marker 同步为 Issue artifact 评论,不作为 `restore-task` 恢复来源;恢复仍只接受 Issue 编号并只读注册的 Issue marker,不新增 PR 来源。
19
+ `pr-review` 原文只通过 `artifact` / `artifactChunk` marker 同步为 Issue artifact 评论,不作为 `restore-task` 恢复来源;恢复仍只接受 Issue 原始 token 并只读注册的 Issue marker,不新增 PR 来源。
20
20
 
21
21
  ## 平台 intent
22
22
 
@@ -24,7 +24,7 @@
24
24
 
25
25
  ```bash
26
26
  agent-infra-internal platform-context resolve [--cwd <path>]
27
- agent-infra-internal platform-comment list --issue <N> [--cwd <path>]
27
+ agent-infra-internal platform-comment list --issue <issue-token> [--cwd <path>]
28
28
  agent-infra-internal platform-comment owner <task-ref>
29
29
  agent-infra-internal platform-comment sync <task-ref> \
30
30
  --kind task|artifact|summary|cancel --agent {standard-agent-token} \
@@ -33,6 +33,7 @@ agent-infra-internal platform-comment sync <task-ref> \
33
33
 
34
34
  - `applied|no-op|degraded` → exit 0;`failed` → exit 1;`blocked` → exit 2。
35
35
  - task 评论保持 `<details>` frontmatter 可逆格式;artifact 原文内联并在超过 profile 上限时使用 `artifactChunk`。
36
+ - task 内容超过平台评论字节上限时不上传,返回 `COMMENT_PAYLOAD_TOO_LARGE` 的 skipped 操作;本地 task 文件保持不变,platform verification 同样跳过 task marker/content 检查。
36
37
  - 相同 intent 重放必须收敛为 `no-op`;重复 marker 返回 `COMMENT_MARKER_CONFLICT` 且不写入。
37
38
  - 外部贡献者锁定统一使用 `platform-comment owner`;不同作者且无 triage 时返回 `COMMENT_OWNER_CONFLICT`。
38
39
 
@@ -59,7 +60,7 @@ agent-infra-internal task-warning {task-id} add \
59
60
  ```bash
60
61
  agent-infra-internal platform-issue inspect {task-id}
61
62
  agent-infra-internal platform-issue create {task-id} --agent {standard-agent-token}
62
- agent-infra-internal platform-issue bind {task-id} --issue {number} --agent {standard-agent-token}
63
+ agent-infra-internal platform-issue bind {task-id} --issue {issue-token} --agent {standard-agent-token}
63
64
  agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} {desired-state-flags}
64
65
  ```
65
66
 
@@ -1,57 +1,64 @@
1
- # General Rule - Model-Driven Local Artifact Repair
1
+ # General Rule - Model-Driven Local Artifact Recovery
2
2
 
3
- This rule applies when `analyze-task`, `plan-task`, or `code-task` handles **the same controlled local artifact** before its completed event, and when `review-analysis`, `review-plan`, or `review-code` handles a finalizer failure for **the same controlled review artifact**. It does not apply to `task.md`, the ledger, receipts, source code, Git, platform resources, or lifecycle state.
3
+ This rule covers the pre-completion gate for `analyze-task`, `plan-task`, and `code-task`, plus the summary finalizers for the three review skills. It handles one canonical artifact in the current task directory only. It does not authorize changes to `task.md`, ledgers, receipts, source code, Git, platform resources, or lifecycle state.
4
4
 
5
- ## Pre-completion gate for analysis, plan, and code artifacts
5
+ ## Pre-completion gate
6
6
 
7
- - `analyze-task`, `plan-task`, and `code-task` must call `task-artifact ... finalize-local` before publishing a completed event; pass only that call's `artifactSha256` and `semanticDigest` to the completed event.
8
- - `finalize-local` does not modify the artifact or task state, but it writes a one-shot local provenance intent in the repository workspace. After `failed`, the model may make one minimal edit in the same artifact only when `repairable=true` and the diagnostic explicitly describes one provably safe structural operation (the current shared engine operations are `replace-line` and `insert-section`), then rerun the same call completely; count each byte-changing edit, up to 8.
9
- - The first repairable failure's semantic digest is retained in that intent; a later `passed` result must match the baseline, and the completed event must verify and atomically transition the same intent to `consumed` before writing `task.md` under the task lock. A consumption failure must not write the task; the consumed intent is durable and retryable, so no failure-prone post-write deletion is attempted. Do not replace a failed baseline with a newly computed digest or publish a completed event without the finalizer.
10
- - After `failed`, no progress, or a repeated diagnostic or fingerprint, do not publish a completed event. After `passed`, do not rescan or manually write summary data.
7
+ - Run the applicable finalizer before a completed event; pass only that invocation's `artifactSha256` and `semanticDigest` to the event.
8
+ - When artifact content is invalid, the finalizer returns a controlled `recovery` with a `recoveryId`, `candidatePath`, and baseline digests. The formal artifact remains unchanged until recovery commit.
9
+ - After the mechanical safety gates pass, the model may edit only the returned `candidatePath`. After each byte-changing edit, rerun the complete finalizer with the same task, stage/family, artifact, and `--recovery-id`. Never edit the formal artifact directly and call it a candidate.
10
+ - A successful finalizer commits through `finalize-ready → commit-started → passed`; completed events accept only matching `passed` final digests and consume the intent under the task lock.
11
+ - Before `finalize-ready`, the recovery core seals the validated final bytes in the controlled `final.md`; later commit ignores the editable `candidate.md` and validates/publishes only that sealed snapshot, so a post-prepare candidate replacement cannot be published.
12
+ - Candidate-only is a protocol authorization boundary, not OS isolation: a same-UID process with arbitrary host filesystem write access may tamper with recovery internals. Identity, fingerprint, and state checks detect such anomalies and fail closed, but the protocol does not claim an independent security principal or cross-platform isolation.
11
13
 
12
- ## Authorization Boundary
14
+ ## Authorization boundary
13
15
 
14
- - The finalizer only reads facts, validates state, normalizes successful results, and performs atomic writes. It does not maintain a recoverable-error allowlist, infer repairability, or choose report content to delete.
15
- - The initial finalizer call is not counted as a repair attempt. Editing is allowed only after the mechanical safety gates pass and the model explicitly determines that the current problem can be solved by a minimal, explainable artifact change.
16
- - The model may edit only the one ordinary local artifact declared by the current skill, and the file must be inside the current task directory. It must not edit `task.md`, the review disagreement ledger, receipts, source code, other reports, or remote resources.
17
- - `changed=false`, an error code, or a format shape is diagnostic evidence, not automatic authorization. The model must judge each case using the complete diagnostic, artifact content, and context.
16
+ - The finalizer and recovery core validate identity, state, permissions, stable reads, complete artifact semantics, and fingerprints. They do not infer repairability or expose a text-operation allow-list.
17
+ - The model may edit only the one ordinary artifact declared by the current skill. It must not edit `task.md`, ledgers, receipts, source code, other reports, or remote resources.
18
+ - `changed=false`, an error code, or a format shape is diagnostic evidence, not edit authorization. Stop on unproven human-decision semantics, concurrency, permission, I/O, identity, provenance, or unknown state.
18
19
 
19
- ## Non-bypassable Mechanical Safety Gates
20
+ ## Non-bypassable mechanical gates
20
21
 
21
- Before every model edit, confirm that:
22
+ Before every candidate edit, confirm that:
22
23
 
23
- 1. the finalizer returned a failure and no artifact operation was committed;
24
- 2. the task, stage, artifact, review round, identity, and provenance still match;
25
- 3. the target is an ordinary file inside the current task directory, with no concurrency conflict, permission error, I/O uncertainty, or target replacement;
26
- 4. the change does not alter human-decision semantics, decision-detail or ledger identity, and does not involve task state, receipts, Git, platform, or any other external side effect. A known and verifiable pending human decision may remain when the model proves the edit is unrelated to that decision.
24
+ 1. the finalizer failed with the same controlled recovery context and nothing formal was committed;
25
+ 2. task, family/stage, round, artifact, request/authority, and baseline fingerprints still match;
26
+ 3. `candidatePath` is the ordinary file generated by the recovery core and the formal target has not changed externally;
27
+ 4. the edit does not change human-decision semantics, detail or ledger identity, and introduces no other side effect.
27
28
 
28
- If any condition fails, stop immediately without invoking a model edit. The model cannot bypass these gates.
29
+ If any condition fails, stop without editing or publishing a completed event.
29
30
 
30
- ## Dynamic Convergence Loop
31
+ ## Durable recovery states
31
32
 
32
- 1. Run the initial finalizer with the fixed task, stage, artifact, and orchestrated intent.
33
- 2. On success, use that complete result for the existing completion gates; do not rescan the ledger or write summary fields manually.
34
- 3. On failure with the safety gates passed, let the model read the structured diagnostic, current artifact, and required context, then decide whether to repair or stop. It must explain the scope and reason for the proposed change.
35
- 4. If the model continues, perform one minimal edit to the artifact. Increment `repairAttempts` only when the file bytes actually change, then rerun the same finalizer intent completely.
36
- 5. Re-run every safety check after each retry. A new, independent problem still limited to the same artifact may be offered to the model for another decision; the previous repairability decision must not be reused automatically.
37
- 6. Stop immediately when the model cannot establish safety or identifies an environment, permission, concurrency, identity, provenance, unknown-state, uncertain human-decision semantics/details, or other non-local problem. A known human decision is not itself a stop condition.
38
- 7. Stop when the diagnostic or artifact fingerprint repeats, no byte-level progress occurs, or the model cannot propose a verifiable minimal change.
39
- 8. Allow at most 8 actual artifact edits per skill invocation as an emergency circuit breaker. This cap only prevents infinite loops and resource exhaustion; it is not a normal business stop condition and does not mean that at most eight problems may be repaired. Preserve the final structured diagnostic when the cap is reached.
33
+ | State | Formal artifact | Allowed action |
34
+ | --- | --- | --- |
35
+ | `awaiting-recovery` | baseline `B` | Edit only controlled candidate `S`; rerun the same finalizer |
36
+ | `finalize-ready` | `B` | Recovery core starts the commit under the task lock |
37
+ | `commit-started` | `B` or final `F` | Reconcile only; retry, confirm, or restore from verified `B/F` fingerprints |
38
+ | `passed` | `F` | Completed event validates the final digest and consumes the intent |
39
+ | `consumed` | `F` | Cleanup may reclaim the controlled staging and backup |
40
+ | `aborted` | verified restored `B` | Preserve diagnostics; never fabricate success |
40
41
 
41
- The repair count exists only in the in-memory context of the current skill invocation. Do not write it to `task.md`, the ledger, or a public receipt. Do not create different normal budgets by error code, skill, or problem type.
42
+ The intent is current-only schema version 3. Legacy schemas fail closed; do not add migration, adapters, or dual writes. Candidate, baseline, and intent files live in controlled repo-local directories and use canonical recovery IDs, regular-file checks, stable reads, the task lock, and expected-value CAS. No cross-file atomicity is claimed; unknown combinations remain indeterminate and retain their evidence.
42
43
 
43
- ## Shared Structural Engine
44
+ ## Dynamic convergence loop
44
45
 
45
- The report skeleton is created by `agent-infra-internal task-artifact {task-id} init --family {family} --artifact {artifact}`. The skeleton writes only identity, headings, and `artifact-section:{family}:{section-id}` markers; it does not represent semantic completion. The current skill must fill each slot with real content. When the finalizer returns one provably safe structural operation, use that result's SHA and semantic digest with `task-artifact {task-id} repair --family {family} --artifact {artifact} --expected-sha256 {artifact-sha256} --expected-semantic-digest {semantic-digest}`. Repair executes only the one operation from the shared engine, does not write `task.md`, the ledger, receipts, Git, or platform resources, and must be followed by a complete rerun of the original finalizer.
46
+ 1. Run the finalizer with the fixed invocation.
47
+ 2. If it fails and the gates pass, read the structured diagnostic and `candidatePath`, then make one minimal, explainable candidate edit.
48
+ 3. Confirm byte-level progress and rerun every finalizer check with the same `--recovery-id`.
49
+ 4. Stop on repeated diagnostics or fingerprints, no byte progress, unknown recovery state, or the eight-edit limit for the current invocation. Do not publish a completed event or generate a cross-stage next step.
46
50
 
47
- ## Completion Events and User Output
51
+ ## Shared entry points
48
52
 
49
- - After the final complete finalizer result succeeds, publish the review completed event using that same result's provenance, ledger state, verdict, and counts. Generate cross-stage next-step commands only when `stageStatus.canAdvance=true` and the verdict is Approved; when `canAdvance=false`, still record the result and route to same-stage revision/review.
50
- - On failure, model stop, lack of progress, repeated diagnostics, or the emergency cap, do not publish a completed event, advance the lifecycle, generate cross-stage commands, or fabricate an approval.
51
- - Stopping advancement does not discard review results. User output must show the artifact path, the last safely readable summary/findings, actual `repairAttempts`, the last structured diagnostic, and the stop reason.
52
- - If the summary cannot be safely parsed, show only the artifact path and the raw structured diagnostic; do not infer counts or add a conclusion, and state that lifecycle advancement stopped while the artifact remains available.
53
- - A stop path may only suggest rerunning the current review skill or handling the issue manually. It must not invoke cross-stage helpers such as `code-task` or `complete-task`.
53
+ The current entry points are `task-artifact ... inspect|init|finalize-local` and `task-review ... finalize-summary`. Recovery retries use the `recoveryId` returned by the finalizer, for example:
54
54
 
55
- ## Lifecycle Isolation
55
+ ```text
56
+ agent-infra-internal task-artifact {task-id} finalize-local --family code --artifact {code-artifact} --recovery-id {recovery-id}
57
+ agent-infra-internal task-review {task-id} finalize-summary --stage code --artifact {review-artifact} --recovery-id {recovery-id}
58
+ ```
56
59
 
57
- `complete-task`, alert closing, task restoration, and other task-lifecycle/task-finalization entry points involve task state, receipts, remote results, or archival side effects and do not consume this rule. They retain their own hard-stop, same-intent retry, and unknown-state semantics.
60
+ There is no `task-artifact repair`, `replace-line`, `insert-section`, or `repairable` authorization. The structural engine returns diagnostics and digests only; the current skill's gates and the model decide whether and how to edit the candidate.
61
+
62
+ ## Lifecycle isolation
63
+
64
+ A completed event may legitimately modify `task.md`, but only after finalizer recovery is `passed` and digest, round, request, and authority all match. If authority consumption fails after the event write, retain the formal artifact and use the existing lifecycle recovery compensation; do not replay the completed write or roll back a passed artifact.
@@ -1,57 +1,64 @@
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
+ - finalizer 发现 artifact 内容错误时,返回受控 `recovery`(`recoveryId`、`candidatePath`、baseline 指纹)。正式 artifact 在 recovery commit 前必须保持不变。
9
+ - 只有在机械安全门通过后,模型才可编辑返回的 `candidatePath`;每次实际字节变化后,用同一 task、stage/family、artifact 和 `--recovery-id` 完整重跑 finalizer。不得直接编辑正式 artifact 后假设它属于候选。
10
+ - finalizer 通过后,recovery core 按 `finalize-ready → commit-started → passed` 提交候选;completed event 只接受匹配的 `passed`/final digest,并在任务锁内消费 intent。
11
+ - `finalize-ready` 前 recovery core 会把已校验的最终字节封存为受控 `final.md`;后续 commit 忽略可编辑的 `candidate.md`,只校验并发布该封存快照,避免候选在准备后被替换。
12
+ - candidate-only 是协议授权边界,不是操作系统隔离:拥有同一 UID 且可任意写入宿主文件系统的进程可能篡改 recovery 内部文件;协议会通过身份、指纹和状态校验发现异常并失败关闭,但不承诺独立权限主体或跨平台隔离。
11
13
 
12
14
  ## 授权边界
13
15
 
14
- - finalizer 只负责读取事实、校验状态、规范化成功结果和原子写入;它不维护可修复错误码白名单,不推断 repairability,也不自动选择要删除的报告内容。
15
- - 首次 finalizer 调用不计入修复次数。只有在机械安全门通过后,模型明确判断当前问题能通过最小、可解释的 artifact 修改解决时,才允许编辑。
16
- - 模型只能修改当前 skill 声明的一个普通本地产物,且该文件必须位于当前 task 目录。不得修改 task.md、审查分歧账本、receipt、源码、其他报告或远端资源。
17
- - `changed=false`、错误码或某个格式形状只是诊断事实,不是自动批准。模型必须结合完整诊断、artifact 内容和上下文逐例判断。
16
+ - finalizer 和 recovery core 只校验身份、状态、权限、稳定读取、完整 artifact 语义和指纹;不根据错误码猜测“可修复”,也不提供文本操作白名单。
17
+ - 模型只能修改当前 skill 声明的一个普通 artifact。不得修改 task.md、账本、receipt、源码、其他报告或远端资源。
18
+ - `changed=false`、错误码和格式形状只是诊断事实,不是编辑授权。人工裁决、并发、权限、I/O、身份、provenance 或未知状态无法证明安全时,立即停止。
18
19
 
19
20
  ## 不可绕过的机械安全门
20
21
 
21
- 在每次模型编辑前确认:
22
+ 每次编辑候选前确认:
22
23
 
23
- 1. finalizer 返回失败,且没有已提交的 artifact operation;
24
- 2. 任务、stage、artifact、review round、身份和 provenance 仍然一致;
25
- 3. 目标是当前 task 目录内的普通文件,没有并发冲突、权限错误、I/O 不确定性或目标被替换;
26
- 4. 不改变人工裁决语义、裁决详情或账本身份,也不涉及任务状态、receipt、Git、平台或其他外部副作用;已知且可核验的 pending 人工裁决可以保留,但模型必须证明本次修改与该裁决无关。
24
+ 1. finalizer 返回失败并提供同一 recovery context,且没有正式提交;
25
+ 2. task、family/stage、round、artifact、request/authority 和 baseline 指纹仍匹配;
26
+ 3. `candidatePath` 是 recovery core 生成的受控普通文件,formal target 没有外部变化;
27
+ 4. 修改不改变人工裁决语义、详情或账本身份,也不引入其他副作用。
27
28
 
28
- 任一条件不满足,立即停止,不调用模型编辑。安全门不能被模型的语义判断绕过。
29
+ 任一条件不满足,停止,不编辑、不发布 completed。
29
30
 
30
- ## 动态收敛循环
31
+ ## Durable recovery 状态
32
+
33
+ | 状态 | formal artifact | 允许动作 |
34
+ | --- | --- | --- |
35
+ | `awaiting-recovery` | baseline `B` | 只编辑受控 candidate `S`,重跑同一 finalizer |
36
+ | `finalize-ready` | `B` | recovery core 在锁内开始提交 |
37
+ | `commit-started` | `B` 或 final `F` | 只允许 reconcile;按 `B/F` 指纹重试、确认或回滚 |
38
+ | `passed` | `F` | completed event 校验 final digest 后消费 |
39
+ | `consumed` | `F` | 可由中间产物清理流程回收受控 staging/backup |
40
+ | `aborted` | 已确认恢复的 `B` | 只保留诊断,不得伪造成功 |
31
41
 
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 个问题。达到上限时保留最后结构化诊断并停止。
42
+ intent 使用 current-only schema version 3。旧 schema 直接失败关闭;不添加迁移、adapter 或双写。candidate、baseline 和 intent 位于 repo-local 受控目录,使用 canonical recovery ID、普通文件检查、stable read、task lock 和 expected-value CAS。跨文件不宣称原子性;未知组合返回 indeterminate 并保留现场。
43
+
44
+ ## 动态收敛循环
40
45
 
41
- 修复次数只存在于当前 skill invocation 的内存上下文,不写入 task.md、ledger 或公共 receipt。不得按错误码、技能或问题类型设置不同的正常预算。
46
+ 1. 用固定 invocation 运行 finalizer。
47
+ 2. 失败且安全门通过时,读取结构化诊断和 `candidatePath`,只作一次最小、可解释的候选编辑。
48
+ 3. 确认字节变化后,使用同一 `--recovery-id` 完整重跑全部 finalizer 校验。
49
+ 4. 诊断或指纹重复、无字节进展、恢复状态未知或达到当前 invocation 的 8 次编辑上限时停止;不发布 completed,不生成跨阶段 next-step。
42
50
 
43
- ## 共享结构引擎
51
+ ## 共享入口
44
52
 
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。
53
+ `task-artifact ... inspect|init|finalize-local` 和 `task-review ... finalize-summary` 是当前入口。恢复重试使用 finalizer 返回的 `recoveryId`,例如:
46
54
 
47
- ## 完成事件与用户输出
55
+ ```text
56
+ agent-infra-internal task-artifact {task-id} finalize-local --family code --artifact {code-artifact} --recovery-id {recovery-id}
57
+ agent-infra-internal task-review {task-id} finalize-summary --stage code --artifact {review-artifact} --recovery-id {recovery-id}
58
+ ```
48
59
 
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。
60
+ 不再存在 `task-artifact repair`、`replace-line`、`insert-section` 或 `repairable` 授权。结构引擎只返回诊断和 digest;候选是否安全、如何修改以及何时停止由当前 skill 的机械门和模型逐例判断。
54
61
 
55
62
  ## 生命周期隔离
56
63
 
57
- `complete-task`、告警关闭、恢复任务和其他 task-lifecycle/task-finalization 入口涉及任务状态、receipt、远端结果或归档副作用,不消费本规则。它们继续使用各自的硬失败、同一 intent 重试和状态未知语义。
64
+ 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"