@fitlab-ai/agent-infra 0.9.12 → 0.9.13

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 (239) hide show
  1. package/README.md +11 -11
  2. package/README.zh-CN.md +11 -11
  3. package/dist/bin/internal-cli.js +24 -19
  4. package/dist/lib/agent-clients/next-steps.js +6 -1
  5. package/dist/lib/decide.js +3 -3
  6. package/dist/lib/internal/platform-checks.js +3 -3
  7. package/dist/lib/internal/platform-comment.js +9 -9
  8. package/dist/lib/internal/platform-context.js +2 -2
  9. package/dist/lib/internal/platform-issue.js +8 -9
  10. package/dist/lib/internal/platform-pr-review.js +10 -10
  11. package/dist/lib/internal/platform-pr.js +63 -24
  12. package/dist/lib/internal/platform-release-notes.js +3 -3
  13. package/dist/lib/internal/pr-review-grade.js +11 -9
  14. package/dist/lib/internal/release-workflow.js +4 -4
  15. package/dist/lib/internal/sandbox-control.js +30 -4
  16. package/dist/lib/internal/task-activity.js +3 -3
  17. package/dist/lib/internal/task-artifact.js +76 -24
  18. package/dist/lib/internal/task-create.js +2 -2
  19. package/dist/lib/internal/task-event.js +6 -3
  20. package/dist/lib/internal/task-finalization.js +2 -2
  21. package/dist/lib/internal/task-invalidation.js +60 -0
  22. package/dist/lib/internal/task-ledger.js +9 -6
  23. package/dist/lib/internal/task-lifecycle.js +2 -2
  24. package/dist/lib/internal/task-override.js +4 -4
  25. package/dist/lib/internal/task-review.js +3 -3
  26. package/dist/lib/internal/task-verify.js +6 -6
  27. package/dist/lib/internal/task-warning.js +3 -3
  28. package/dist/lib/platform/adapters.js +1 -3
  29. package/dist/lib/platform/change-request-git-evidence.js +27 -7
  30. package/dist/lib/platform/completion-backfill.js +6 -5
  31. package/dist/lib/platform/context.js +70 -130
  32. package/dist/lib/platform/github-client.js +1 -1
  33. package/dist/lib/platform/github-provider.js +903 -0
  34. package/dist/lib/platform/in-label-sync.js +143 -0
  35. package/dist/lib/platform/issue-comments.js +94 -41
  36. package/dist/lib/platform/issues.js +335 -189
  37. package/dist/lib/platform/metadata-labels.js +6 -2
  38. package/dist/lib/platform/none-provider.js +28 -0
  39. package/dist/lib/platform/pr-change-report.js +551 -0
  40. package/dist/lib/platform/pr-checks.js +119 -104
  41. package/dist/lib/platform/pr-review.js +88 -72
  42. package/dist/lib/platform/pr-summary.js +520 -50
  43. package/dist/lib/platform/provider-bridge.js +45 -0
  44. package/dist/lib/platform/provider-contract.d.ts +487 -0
  45. package/dist/lib/platform/provider-contract.js +95 -0
  46. package/dist/lib/platform/provider-loader.js +251 -0
  47. package/dist/lib/platform/provider-validation.js +504 -0
  48. package/dist/lib/platform/pull-request-metadata.js +8 -6
  49. package/dist/lib/platform/pull-requests.js +783 -537
  50. package/dist/lib/platform/release-notes.js +78 -55
  51. package/dist/lib/platform/releases.js +79 -50
  52. package/dist/lib/platform/resource-identity.d.ts +26 -0
  53. package/dist/lib/platform/resource-identity.js +92 -0
  54. package/dist/lib/platform/task-identities.js +31 -0
  55. package/dist/lib/platform/verification-required.js +11 -12
  56. package/dist/lib/platform/verification-sync.js +112 -238
  57. package/dist/lib/pr-review/evidence-grading.js +19 -6
  58. package/dist/lib/run/index.js +63 -23
  59. package/dist/lib/sandbox/control/client.js +96 -15
  60. package/dist/lib/sandbox/control/executor.js +3 -3
  61. package/dist/lib/sandbox/control/protocol.js +77 -0
  62. package/dist/lib/sandbox/control/server.js +398 -25
  63. package/dist/lib/sandbox/control/state.js +204 -1
  64. package/dist/lib/server/protocol.js +38 -1
  65. package/dist/lib/task/activity-log.js +8 -1
  66. package/dist/lib/task/artifact-lifecycle.js +33 -5
  67. package/dist/lib/task/capabilities.js +239 -0
  68. package/dist/lib/task/commands/status.js +32 -0
  69. package/dist/lib/task/commit-operation.js +12 -1
  70. package/dist/lib/task/control-authority.js +8 -5
  71. package/dist/lib/task/create-service.js +8 -8
  72. package/dist/lib/task/current-contract.js +5 -1
  73. package/dist/lib/task/decision-details.js +1 -1
  74. package/dist/lib/task/events.js +297 -17
  75. package/dist/lib/task/finalization.js +37 -13
  76. package/dist/lib/task/human-override.js +58 -36
  77. package/dist/lib/task/invalidation-command.js +86 -0
  78. package/dist/lib/task/invalidation.js +260 -0
  79. package/dist/lib/task/ledger-intents.js +37 -0
  80. package/dist/lib/task/local-artifact-finalization.js +374 -0
  81. package/dist/lib/task/orchestration.js +49 -93
  82. package/dist/lib/task/pr-delivery-fact.js +102 -101
  83. package/dist/lib/task/review-fingerprint.js +24 -2
  84. package/dist/lib/task/rework-intent.js +138 -0
  85. package/dist/lib/task/skill-scope.js +23 -0
  86. package/dist/lib/task/task-execution-lock.js +27 -17
  87. package/dist/lib/task/verification-engine.js +43 -16
  88. package/dist/lib/task/verification.js +3 -3
  89. package/dist/lib/task/workflow-warning-intents.js +1 -1
  90. package/dist/lib/task/write.js +11 -0
  91. package/dist/lib/version.js +11 -1
  92. package/dist/lifecycle-build-manifest.json +3 -3
  93. package/lib/agent-clients/next-steps.ts +6 -1
  94. package/lib/decide.ts +3 -3
  95. package/lib/init.ts +1 -1
  96. package/lib/internal/platform-checks.ts +3 -3
  97. package/lib/internal/platform-comment.ts +8 -8
  98. package/lib/internal/platform-context.ts +2 -2
  99. package/lib/internal/platform-issue.ts +7 -8
  100. package/lib/internal/platform-pr-review.ts +9 -9
  101. package/lib/internal/platform-pr.ts +47 -22
  102. package/lib/internal/platform-release-notes.ts +3 -3
  103. package/lib/internal/pr-review-grade.ts +10 -8
  104. package/lib/internal/release-workflow.ts +4 -4
  105. package/lib/internal/sandbox-control.ts +27 -3
  106. package/lib/internal/task-activity.ts +3 -3
  107. package/lib/internal/task-artifact.ts +65 -22
  108. package/lib/internal/task-create.ts +2 -2
  109. package/lib/internal/task-event.ts +6 -3
  110. package/lib/internal/task-finalization.ts +3 -3
  111. package/lib/internal/task-invalidation.ts +39 -0
  112. package/lib/internal/task-ledger.ts +11 -8
  113. package/lib/internal/task-lifecycle.ts +2 -2
  114. package/lib/internal/task-override.ts +6 -6
  115. package/lib/internal/task-review.ts +3 -3
  116. package/lib/internal/task-verify.ts +6 -6
  117. package/lib/internal/task-warning.ts +3 -3
  118. package/lib/platform/adapters.ts +3 -2
  119. package/lib/platform/change-request-git-evidence.ts +36 -9
  120. package/lib/platform/completion-backfill.ts +9 -8
  121. package/lib/platform/context.ts +97 -134
  122. package/lib/platform/github-client.ts +2 -2
  123. package/lib/platform/github-provider.ts +910 -0
  124. package/lib/platform/in-label-sync.ts +208 -0
  125. package/lib/platform/issue-comments.ts +97 -47
  126. package/lib/platform/issues.ts +344 -174
  127. package/lib/platform/metadata-labels.ts +5 -2
  128. package/lib/platform/none-provider.ts +35 -0
  129. package/lib/platform/pr-change-report.ts +645 -0
  130. package/lib/platform/pr-checks.ts +126 -106
  131. package/lib/platform/pr-review.ts +88 -85
  132. package/lib/platform/pr-summary.ts +560 -53
  133. package/lib/platform/provider-bridge.ts +82 -0
  134. package/lib/platform/provider-contract.ts +536 -0
  135. package/lib/platform/provider-loader.ts +307 -0
  136. package/lib/platform/provider-validation.ts +529 -0
  137. package/lib/platform/pull-request-metadata.ts +10 -7
  138. package/lib/platform/pull-requests.ts +826 -543
  139. package/lib/platform/release-notes.ts +76 -59
  140. package/lib/platform/releases.ts +77 -43
  141. package/lib/platform/resource-identity.ts +121 -0
  142. package/lib/platform/task-identities.ts +40 -0
  143. package/lib/platform/types.ts +4 -2
  144. package/lib/platform/verification-required.ts +11 -13
  145. package/lib/platform/verification-sync.ts +112 -292
  146. package/lib/pr-review/evidence-grading.ts +25 -8
  147. package/lib/run/index.ts +57 -22
  148. package/lib/sandbox/control/client.ts +105 -15
  149. package/lib/sandbox/control/executor.ts +4 -4
  150. package/lib/sandbox/control/protocol.ts +113 -0
  151. package/lib/sandbox/control/server.ts +431 -23
  152. package/lib/sandbox/control/state.ts +251 -1
  153. package/lib/server/protocol.ts +36 -1
  154. package/lib/task/activity-log.ts +8 -0
  155. package/lib/task/artifact-lifecycle.ts +32 -6
  156. package/lib/task/capabilities.ts +262 -0
  157. package/lib/task/commands/status.ts +38 -0
  158. package/lib/task/commit-operation.ts +12 -1
  159. package/lib/task/control-authority.ts +11 -8
  160. package/lib/task/create-service.ts +8 -8
  161. package/lib/task/current-contract.ts +6 -1
  162. package/lib/task/decision-details.ts +6 -2
  163. package/lib/task/events.ts +296 -16
  164. package/lib/task/finalization.ts +50 -14
  165. package/lib/task/human-override.ts +70 -46
  166. package/lib/task/invalidation-command.ts +86 -0
  167. package/lib/task/invalidation.ts +332 -0
  168. package/lib/task/ledger-intents.ts +35 -1
  169. package/lib/task/local-artifact-finalization.ts +563 -0
  170. package/lib/task/orchestration.ts +52 -85
  171. package/lib/task/pr-delivery-fact.ts +131 -148
  172. package/lib/task/review-fingerprint.ts +23 -2
  173. package/lib/task/rework-intent.ts +165 -0
  174. package/lib/task/skill-scope.ts +24 -0
  175. package/lib/task/task-execution-lock.ts +23 -14
  176. package/lib/task/verification-engine.ts +52 -17
  177. package/lib/task/verification.ts +4 -4
  178. package/lib/task/workflow-warning-intents.ts +1 -1
  179. package/lib/task/write.ts +19 -0
  180. package/lib/update.ts +1 -1
  181. package/lib/version.ts +15 -1
  182. package/package.json +7 -1
  183. package/templates/.agents/rules/README.en.md +1 -1
  184. package/templates/.agents/rules/README.zh-CN.md +1 -1
  185. package/templates/.agents/rules/issue-pr-commands.en.md +1 -1
  186. package/templates/.agents/rules/issue-pr-commands.zh-CN.md +1 -1
  187. package/templates/.agents/rules/issue-sync.en.md +2 -0
  188. package/templates/.agents/rules/issue-sync.zh-CN.md +2 -0
  189. package/templates/.agents/rules/local-artifact-repair.en.md +9 -2
  190. package/templates/.agents/rules/local-artifact-repair.zh-CN.md +9 -2
  191. package/templates/.agents/rules/pr-sync.en.md +10 -4
  192. package/templates/.agents/rules/pr-sync.zh-CN.md +17 -4
  193. package/templates/.agents/rules/task-short-id.en.md +1 -4
  194. package/templates/.agents/rules/task-short-id.zh-CN.md +1 -3
  195. package/templates/.agents/skills/analyze-task/SKILL.en.md +13 -3
  196. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +10 -3
  197. package/templates/.agents/skills/check-task/SKILL.en.md +16 -37
  198. package/templates/.agents/skills/check-task/SKILL.zh-CN.md +16 -37
  199. package/templates/.agents/skills/code-task/SKILL.en.md +27 -8
  200. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +29 -10
  201. package/templates/.agents/skills/code-task/config/verify.en.json +1 -0
  202. package/templates/.agents/skills/code-task/config/verify.zh-CN.json +1 -0
  203. package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +2 -0
  204. package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +2 -0
  205. package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +3 -3
  206. package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +3 -3
  207. package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +5 -3
  208. package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +5 -3
  209. package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +4 -3
  210. package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +4 -3
  211. package/templates/.agents/skills/complete-task/SKILL.en.md +21 -3
  212. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +20 -3
  213. package/templates/.agents/skills/create-pr/SKILL.en.md +7 -6
  214. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +7 -7
  215. package/templates/.agents/skills/create-pr/config/verify.json +1 -0
  216. package/templates/.agents/skills/create-pr/reference/change-report.en.md +16 -4
  217. package/templates/.agents/skills/create-pr/reference/change-report.zh-CN.md +16 -4
  218. package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +5 -3
  219. package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +5 -3
  220. package/templates/.agents/skills/create-pr/reference/pr-body-template.en.md +1 -1
  221. package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +1 -1
  222. package/templates/.agents/skills/create-pr/scripts/change-report.mjs +3 -0
  223. package/templates/.agents/skills/plan-task/SKILL.en.md +13 -3
  224. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +10 -3
  225. package/templates/.agents/skills/review-analysis/SKILL.en.md +3 -3
  226. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +3 -3
  227. package/templates/.agents/skills/review-code/SKILL.en.md +4 -4
  228. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +4 -4
  229. package/templates/.agents/skills/review-plan/SKILL.en.md +3 -3
  230. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +3 -3
  231. package/templates/.agents/skills/run-manual-validation/SKILL.en.md +4 -2
  232. package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +4 -2
  233. package/templates/.agents/skills/watch-pr/SKILL.en.md +2 -2
  234. package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +2 -2
  235. package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +6 -0
  236. package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +6 -0
  237. package/templates/.agents/templates/task.en.md +18 -1
  238. package/templates/.agents/templates/task.zh-CN.md +18 -1
  239. package/templates/.github/workflows/pr-label.yml +7 -26
@@ -46,6 +46,7 @@
46
46
  "verify_task_comment_content": true,
47
47
  "verify_issue_type": true,
48
48
  "verify_issue_fields": false,
49
+ "verify_in_labels_computed": true,
49
50
  "verify_milestone": true,
50
51
  "verify_milestone_specific": true,
51
52
  "expected_status_label_key": "inProgress",
@@ -46,6 +46,7 @@
46
46
  "verify_task_comment_content": true,
47
47
  "verify_issue_type": true,
48
48
  "verify_issue_fields": false,
49
+ "verify_in_labels_computed": true,
49
50
  "verify_milestone": true,
50
51
  "verify_milestone_specific": true,
51
52
  "expected_status_label_key": "inProgress",
@@ -14,6 +14,8 @@ Call one declarative intent. The internal core owns diff computation, repository
14
14
  agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --in-labels from-diff --base {base-branch} --requirements
15
15
  ```
16
16
 
17
+ If `--base` is supplied, it must exactly match task.md's `delivery_base_ref`; the core uses that task-bound ref as the only diff evidence and never falls back to `main` or a repository default. The `in:` target is the intersection of the `labels.in` mapping and repository labels, and unrelated labels are preserved.
18
+
17
19
  ## Error Handling
18
20
 
19
21
  Treat sync failures as warnings only. Do not block an already completed `git commit`.
@@ -14,6 +14,8 @@
14
14
  agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --in-labels from-diff --base {base-branch} --requirements
15
15
  ```
16
16
 
17
+ `--base`(如保留)必须与 task.md 的 `delivery_base_ref` 完全一致;core 以 task-bound base 作为唯一 diff evidence,不回退到 `main` 或仓库默认分支。`in:` target 只来自 `labels.in` 映射与仓库实际 labels 的交集,并保留其他 labels。
18
+
17
19
  ## 错误处理
18
20
 
19
21
  同步失败只记为警告,不阻塞已完成的 `git commit`。
@@ -2,8 +2,8 @@
2
2
 
3
3
  Run only when `{task-id}` is valid and task.md has a `bound/verified` `pr_delivery_fact`.
4
4
 
5
- 1. Run `agent-infra-internal platform-pr summary-context {task-id}`.
6
- 2. Generate the plain summary body per `.agents/rules/pr-sync.md` and write it to a temporary file.
7
- 3. Run `agent-infra-internal platform-pr summary-sync {task-id} --agent {standard-agent-token} --body-file {summary-body-file} --result no_op`. The commit path only synchronizes an existing PR summary and neither creates nor reuses a PR, so `no_op` explicitly represents the unchanged PR identity.
5
+ 1. Run `agent-infra-internal platform-pr summary-context {task-id}` to obtain canonical inputs and report status; rebuild a stale/missing sidecar through the `change-report` flow for the current head.
6
+ 2. Generate the plain summary body per `.agents/rules/pr-sync.md`, with exactly one `<!-- canonical-pr-change-report -->` placeholder, and write it to a temporary file.
7
+ 3. Run `agent-infra-internal platform-pr summary-sync {task-id} --agent {standard-agent-token} --body-file {summary-body-file} --change-report-file .agents/workspace/active/{task-id}/pr-change-report.json --result no_op`. The commit path only synchronizes an existing PR summary and neither creates nor reuses a PR, so `no_op` explicitly represents the unchanged PR identity.
8
8
 
9
9
  Failure records a warning but never blocks or rolls back the completed commit. `no-op` maps to `summary skipped (no diff)`.
@@ -2,8 +2,8 @@
2
2
 
3
3
  仅当 `{task-id}` 有效且 `task.md` 存在 `bound/verified` 的 `pr_delivery_fact` 时执行;否则跳过。
4
4
 
5
- 1. 调用 `agent-infra-internal platform-pr summary-context {task-id}` 获取 canonical 聚合输入。
6
- 2. 按 `.agents/rules/pr-sync.md` 生成纯摘要正文并写入临时文件。
7
- 3. 调用 `agent-infra-internal platform-pr summary-sync {task-id} --agent {standard-agent-token} --body-file {summary-body-file} --result no_op`。commit 路径只同步已有 PR 摘要,不创建或复用 PR,因此固定使用 `no_op` 表示 PR 身份未变化。
5
+ 1. 调用 `agent-infra-internal platform-pr summary-context {task-id}` 获取 canonical 聚合输入和报告状态;sidecar stale/missing 时先按 `change-report` 流程重建当前 head 报告。
6
+ 2. 按 `.agents/rules/pr-sync.md` 生成只含一次 `<!-- canonical-pr-change-report -->` 的纯摘要正文并写入临时文件。
7
+ 3. 调用 `agent-infra-internal platform-pr summary-sync {task-id} --agent {standard-agent-token} --body-file {summary-body-file} --change-report-file .agents/workspace/active/{task-id}/pr-change-report.json --result no_op`。commit 路径只同步已有 PR 摘要,不创建或复用 PR,因此固定使用 `no_op` 表示 PR 身份未变化。
8
8
 
9
9
  同步失败只记录 warning,不阻塞或回滚已经完成的 commit。`no-op` 回传 `summary skipped (no diff)`。
@@ -9,6 +9,8 @@ description: >
9
9
  # Complete Manual Validation
10
10
  > `--agent` values are defined in `.agents/rules/task-management.md` under “Collaborator Token Specification”.
11
11
 
12
+ Lifecycle events require explicit trigger data: use `{trigger-initiator}=orchestrator` for orchestration and `model` otherwise; `{request-id}` is a stable single-line identifier for this task and artifact round, and `{reason-code}` is `user-request` or `validation-rerun`. Reuse the same values for started and completed.
13
+
12
14
 
13
15
  ## Boundary / Critical Rules
14
16
 
@@ -38,7 +40,7 @@ agent-infra-internal task-snapshot {task-id} --format text
38
40
 
39
41
  ## Step Start: Write the started Marker
40
42
 
41
- After resolving the artifact context and before this round's first artifact action, run `agent-infra-internal task-event {task-id} manual-validation.started --agent {standard-agent-token}` and record the returned `artifactContext`.
43
+ After resolving the artifact context and before this round's first artifact action, run `agent-infra-internal task-event {task-id} manual-validation.started --agent {standard-agent-token} --initiator {trigger-initiator} --request-id {request-id} --reason-code {reason-code}` and record the returned `artifactContext`.
42
44
 
43
45
  ## Steps
44
46
 
@@ -86,7 +88,7 @@ Before this step, read `reference/report-template.md`. Create `{manual-validatio
86
88
 
87
89
  ### 6. Update task.md
88
90
 
89
- Run `agent-infra-internal task-event {task-id} manual-validation.completed --agent {standard-agent-token} --artifact {manual-validation-artifact} --summary-result "{summary-result}"`. The core keeps `current_step` unchanged while atomically recording the implementation-notes link, metadata, and done log.
91
+ Run `agent-infra-internal task-event {task-id} manual-validation.completed --agent {standard-agent-token} --initiator {trigger-initiator} --request-id {request-id} --reason-code {reason-code} --artifact {manual-validation-artifact} --summary-result "{summary-result}"`. The core keeps `current_step` unchanged while atomically recording the implementation-notes link, metadata, and done log.
90
92
 
91
93
  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}`.
92
94
 
@@ -109,7 +111,7 @@ Report:
109
111
  - Artifact path
110
112
  - PR summary sync result
111
113
  - Current verification output
112
- - Suggested next step: enter the final closing flow and run /complete-task {task-ref}
114
+ - Suggested next step: enter the final closing flow and run /complete-task --task {task-ref}
113
115
 
114
116
  Before rendering the final output, read `.agents/rules/next-step-output.md` and append `Completed at: YYYY-MM-DD HH:mm:ss` as the absolute last line.
115
117
 
@@ -9,6 +9,8 @@ description: >
9
9
  # 完成人工验证
10
10
  > `--agent` 取值见 `.agents/rules/task-management.md`「合作者 token 规范」。
11
11
 
12
+ 生命周期事件必须携带显式触发信息:编排调用使用 `{trigger-initiator}=orchestrator`,否则使用 `model`;`{request-id}` 是本任务与本轮产物的稳定单行标识,`{reason-code}` 使用 `user-request` 或 `validation-rerun`;started 与 completed 使用同一组值。
13
+
12
14
 
13
15
  ## 行为边界 / 关键规则
14
16
 
@@ -38,7 +40,7 @@ agent-infra-internal task-snapshot {task-id} --format text
38
40
 
39
41
  ## 步骤开始:声明 started 事件
40
42
 
41
- 确认前置条件和产物上下文后、本轮第一个产出动作之前执行 `agent-infra-internal task-event {task-id} manual-validation.started --agent {standard-agent-token}`,并以返回的 `artifactContext` 记录本轮身份。
43
+ 确认前置条件和产物上下文后、本轮第一个产出动作之前执行 `agent-infra-internal task-event {task-id} manual-validation.started --agent {standard-agent-token} --initiator {trigger-initiator} --request-id {request-id} --reason-code {reason-code}`,并以返回的 `artifactContext` 记录本轮身份。
42
44
 
43
45
  ## 执行步骤
44
46
 
@@ -86,7 +88,7 @@ complete-manual-validation [--task <ref> | -t <ref>] [{pr-ref}] {verification-su
86
88
 
87
89
  ### 6. 更新 task.md
88
90
 
89
- 执行 `agent-infra-internal task-event {task-id} manual-validation.completed --agent {standard-agent-token} --artifact {manual-validation-artifact} --summary-result "{summary-result}"`,由核心在保持 `current_step` 不变的同时原子登记实现备注链接、时间/版本和完成日志。
91
+ 执行 `agent-infra-internal task-event {task-id} manual-validation.completed --agent {standard-agent-token} --initiator {trigger-initiator} --request-id {request-id} --reason-code {reason-code} --artifact {manual-validation-artifact} --summary-result "{summary-result}"`,由核心在保持 `current_step` 不变的同时原子登记实现备注链接、时间/版本和完成日志。
90
92
 
91
93
  如任务存在有效 `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}`。
92
94
 
@@ -109,7 +111,7 @@ agent-infra-internal task-verify {task-id} manual-validation.completed --artifac
109
111
  - 产物路径
110
112
  - PR 摘要同步结果
111
113
  - 当次完成校验输出
112
- - 下一步建议:进入最终收尾流程,运行 /complete-task {task-ref}
114
+ - 下一步建议:进入最终收尾流程,运行 /complete-task --task {task-ref}
113
115
 
114
116
  渲染最终输出前,先读取 `.agents/rules/next-step-output.md`,并在绝对最后一行追加 `Completed at: YYYY-MM-DD HH:mm:ss`。
115
117
 
@@ -6,11 +6,12 @@ Follow `.agents/rules/pr-sync.md` for the shared summary structure and failure s
6
6
 
7
7
  1. After the canonical `manual-validation*` artifact is written, run `agent-infra-internal platform-pr summary-context {task-id}`.
8
8
  2. Rebuild the summary from canonical inputs and render `### ✅ Manual Validation Passed` with the validation time and explanation.
9
- 3. Write the plain body to a temporary file and run:
9
+ 3. Write the plain body with exactly one `<!-- canonical-pr-change-report -->` placeholder to a temporary file and run:
10
10
 
11
11
  ```bash
12
12
  agent-infra-internal platform-pr summary-sync {task-id} \
13
- --agent {standard-agent-token} --body-file {summary-body-file}
13
+ --agent {standard-agent-token} --body-file {summary-body-file} \
14
+ --change-report-file .agents/workspace/active/{task-id}/pr-change-report.json --result no_op
14
15
  ```
15
16
 
16
- The core owns marker/HEAD wrapping, pagination, and in-place reconciliation. If context says no manual validation is required, stop without marking it passed.
17
+ The core owns the rendered report, marker/authoritative PR-head wrapping, pagination, and in-place reconciliation. If context says no manual validation is required, stop without marking it passed.
@@ -6,13 +6,14 @@
6
6
 
7
7
  1. 在 canonical `manual-validation*` artifact 落盘后,调用 `agent-infra-internal platform-pr summary-context {task-id}`。
8
8
  2. 从返回的最新产物重新聚合摘要,将人工校验段渲染为 `### ✅ 人工验证已通过`,写明验证时间和说明。
9
- 3. 把纯正文写入临时文件,调用:
9
+ 3. 把只含一次 `<!-- canonical-pr-change-report -->` 的纯正文写入临时文件,调用:
10
10
 
11
11
  ```bash
12
12
  agent-infra-internal platform-pr summary-sync {task-id} \
13
- --agent {standard-agent-token} --body-file {summary-body-file}
13
+ --agent {standard-agent-token} --body-file {summary-body-file} \
14
+ --change-report-file .agents/workspace/active/{task-id}/pr-change-report.json --result no_op
14
15
  ```
15
16
 
16
- marker、当前 HEAD、分页查找和原地更新由 core 负责。若当前 context 表明无需人工校验,则停止并返回 `summary failed: no manual validation required`,不误标通过。
17
+ marker、报告段、权威 PR head、分页查找和原地更新由 core 负责。若当前 context 表明无需人工校验,则停止并返回 `summary failed: no manual validation required`,不误标通过。
17
18
 
18
19
  结果回传:`summary updated`、`summary skipped (no diff)` 或 `summary failed: <reason>`。
@@ -87,14 +87,14 @@ agent-infra-internal platform-pr resolve-external {task-id} --agent {standard-ag
87
87
  Two-option guidance for absent + `pending`:
88
88
  ```
89
89
  Task {task-id} has no PR delivery decision yet (pr_delivery_fact: unbound). Choose one:
90
- - Go through the PR flow: /create-pr {task-ref}
91
- - Explicitly skip and complete: /complete-task {task-ref} --skip-pr
90
+ - Go through the PR flow: /create-pr --task {task-ref}
91
+ - Explicitly skip and complete: /complete-task --task {task-ref} --skip-pr
92
92
  ```
93
93
 
94
94
  Stop message for `required` + `pending`/`skipped`:
95
95
  ```
96
96
  This project enforces the PR flow (prFlow: "required") and the task has no PR yet.
97
- Run /create-pr {task-ref} first, then complete; --skip-pr is not accepted under a mandatory PR flow.
97
+ Run /create-pr --task {task-ref} first, then complete; --skip-pr is not accepted under a mandatory PR flow.
98
98
  ```
99
99
 
100
100
  Before lifecycle, verify only the hard gates:
@@ -198,6 +198,24 @@ Handle the result as follows:
198
198
 
199
199
  Keep the gate output in your reply as fresh evidence. Do not claim completion without output from this run.
200
200
 
201
+ ### Accepted sandbox-control result recovery
202
+
203
+ When this skill is invoked from a sandbox and the control client reports an
204
+ accepted request without a terminal result, preserve the request identity. The
205
+ client prints `SANDBOX_CONTROL_REQUEST_ID: <request-id>` on stderr for this
206
+ case. After the broker is healthy again, recover the same terminal response:
207
+
208
+ ```bash
209
+ agent-infra-internal sandbox-control recover <request-id>
210
+ ```
211
+
212
+ Do not submit a new request for an accepted task finalization. The broker's
213
+ `processing/<request-id>/result.json` is private transport evidence; it is not
214
+ a task receipt and cannot by itself prove completion. The finalization receipt
215
+ and the host completion gate remain authoritative. If the request was rejected
216
+ before acceptance, a new request ID may be used according to the error's
217
+ retryability.
218
+
201
219
  ### 8. Inform User
202
220
 
203
221
  > Execute this step only after the verification gate passes.
@@ -86,14 +86,14 @@ agent-infra-internal platform-pr resolve-external {task-id} --agent {standard-ag
86
86
  缺省 + `pending` 的二选一引导消息:
87
87
  ```
88
88
  任务 {task-id} 尚未决定 PR 交付(pr_delivery_fact: unbound)。请二选一:
89
- - 走 PR 流程:/create-pr {task-ref}
90
- - 显式跳过并完成:/complete-task {task-ref} --skip-pr
89
+ - 走 PR 流程:/create-pr --task {task-ref}
90
+ - 显式跳过并完成:/complete-task --task {task-ref} --skip-pr
91
91
  ```
92
92
 
93
93
  `required` + `pending`/`skipped` 的停止消息:
94
94
  ```
95
95
  当前项目强制 PR 流程(prFlow: "required"),任务尚未创建 PR。
96
- 请先运行 /create-pr {task-ref} 创建 PR 后再完成;--skip-pr 在强制 PR 下不被接受。
96
+ 请先运行 /create-pr --task {task-ref} 创建 PR 后再完成;--skip-pr 在强制 PR 下不被接受。
97
97
  ```
98
98
 
99
99
  生命周期前只验证硬门禁:
@@ -197,6 +197,23 @@ agent-infra-internal task-verify {task-id} complete-task.completed --format text
197
197
 
198
198
  将校验输出保留在回复中作为当次验证输出。没有当次校验输出,不得声明完成。
199
199
 
200
+ ### accepted 后的 sandbox-control 结果恢复
201
+
202
+ 如果本技能在沙箱内执行,且 control client 报告请求已经 accepted 但没有
203
+ terminal result,必须保留原 request identity。此时 client 会在 stderr 输出
204
+ `SANDBOX_CONTROL_REQUEST_ID: <request-id>`。broker 恢复健康后,使用同一个
205
+ request ID 读取 terminal response:
206
+
207
+ ```bash
208
+ agent-infra-internal sandbox-control recover <request-id>
209
+ ```
210
+
211
+ accepted 的 task finalization 不得提交新请求。broker 的
212
+ `processing/<request-id>/result.json` 只是私有 transport evidence,不是 task
213
+ receipt,单凭它不能证明任务完成;finalization receipt 和宿主完成校验仍是
214
+ 权威。如果请求在 accepted 之前已被拒绝,则可依据错误的 retryability 使用
215
+ 新的 request ID。
216
+
200
217
  ### 8. 告知用户
201
218
 
202
219
  > 仅在校验通过后执行本步骤。
@@ -74,19 +74,19 @@ If `{task-id}` is available and the related task provides `issue_number`, keep `
74
74
 
75
75
  ### 6. Sync PR Metadata
76
76
 
77
- Capture the `result` field from `platform-pr create` (`pr_created`, `pr_reused`, or `no_op`), then run `agent-infra-internal platform-pr sync {task-id} --agent {standard-agent-token} --metadata --closing-issue --result {primary-result}`. The core copies type / `in:` labels, assignee, and a specific milestone from the Issue and maintains the closing association. Permission-bound items degrade independently, and the Issue is never updated in reverse. After the PR identity is bound, metadata or summary sync failures produce `pr_created_with_warnings`, `pr_reused_with_warnings`, or `no_op_with_warnings` from that primary result, preserve the primary-action fact, and retry only unfinished sync steps.
77
+ Capture the `result` field from `platform-pr create` (`pr_created`, `pr_reused`, or `no_op`), then run `agent-infra-internal platform-pr sync {task-id} --agent {standard-agent-token} --metadata --closing-issue --result {primary-result}`. The shared core computes one `in:` target from task-bound diff/PR evidence and the repository mapping, converges a unique closing Issue before the PR, and syncs other metadata from the Issue. It never copies `in:` labels back from the Issue or removes unrelated labels. Permission failures degrade independently; partial side effects return blocked/`IN_LABEL_SYNC_PARTIAL`.
78
78
 
79
79
  ### 7. Generate the PR Code Change Report
80
80
 
81
- After creating or uniquely reusing the PR, run `agent-infra-internal platform-pr inspect {task-id}` to obtain the authoritative base/head SHAs, then follow `reference/change-report.md` to classify the complete PR line counts, Git blob byte sizes, renames, and potentially unnecessary changes. Read that reference before this step.
81
+ After creating or uniquely reusing the PR, run `agent-infra-internal platform-pr inspect {task-id}` to obtain the authoritative base/head SHAs, then follow `reference/change-report.md` for the mechanical complete-PR report. Combine the task goal with the complete three-dot diff to produce a six-check precheck candidate with file evidence, then run `platform-pr change-report` to write the task-bound `pr-change-report.json` sidecar. Read that reference before this step.
82
82
 
83
- The report is part of the reviewer summary below and must also appear in the final user response. Do not provide only total lines, omit byte changes, or inspect only the last commit.
83
+ The core renderer owns the report section. It is part of the reviewer summary below and must also appear in the final user response. Do not provide only total lines, omit byte changes, inspect only the last commit, or let the caller assemble the report section.
84
84
 
85
85
  ### 8. Publish the Review Summary
86
86
 
87
87
  Read the latest context artifacts when they exist: `plan.md` / `plan-r{N}.md`, `review-plan.md` / `review-plan-r{N}.md`, `code.md` / `code-r{N}.md`, and `review-code.md` / `review-code-r{N}.md`.
88
88
 
89
- Aggregate a reviewer-facing summary from those artifacts, append the `### PR Code Changes` section generated in step 7, and maintain a single idempotent summary comment via the hidden marker. Pass the same `--result {primary-result}` to `summary-sync`; a sync substep must not infer whether the PR was created or reused.
89
+ Aggregate a reviewer-facing summary from those artifacts with exactly one `<!-- canonical-pr-change-report -->` placeholder, and maintain a single idempotent summary comment via the hidden marker. Pass `--change-report-file .agents/workspace/active/{task-id}/pr-change-report.json` and the same `--result {primary-result}` to `summary-sync`; a sync substep must not infer whether the PR was created or reused.
90
90
 
91
91
  > Canonical context, aggregation, and the `summary-sync` call live in `reference/comment-publish.md`, which points to `.agents/rules/pr-sync.md`. Read that reference before publishing.
92
92
 
@@ -139,14 +139,15 @@ Next step (alternative) - Skip active monitoring and attempt completion:
139
139
 
140
140
  - Review every commit in the branch, not only the latest one
141
141
  - `create-pr` must not defer type-label mapping to another skill; inline the mapping here when `{task-id}` is available
142
- - The summary marker and current HEAD are wrapped by `platform-pr summary-sync`
142
+ - The summary marker, authoritative PR head, and `### PR Code Changes` section are wrapped by `platform-pr summary-sync`
143
+ - An existing PR still goes through binding, report generation, summary synchronization, and result verification; reuse must not end the flow early
143
144
  - When metadata inheritance from the Issue fails, continue with task.md and branch-based fallbacks
144
145
 
145
146
  ## Error Handling
146
147
 
147
148
  - No commits found between `{target}` and `HEAD`
148
149
  - Push rejected: suggest `git pull --rebase`
149
- - Existing PR found: show the current PR URL and stop
150
+ - Existing PR found: continue through binding, report generation, summary synchronization, and result verification before showing the current PR URL
150
151
  - Inaccessible Issue metadata: skip inheritance and continue
151
152
  - PR creation failed with an associated `{task-id}`: run `agent-infra-internal task-warning {task-id} add --step create-pr --severity ACTION_REQUIRED --code PR_CREATE_FAILED --target pr --message "{reason}" --action "Fix push, permission, or platform issues and rerun create-pr"` to submit a structured warning intent, and do not write an incomplete `pr_delivery_fact`
152
153
  - PR summary comment failed with an associated `{task-id}`: record a `COMMENT_SYNC_FAILED` warning per `.agents/rules/pr-sync.md`, without rolling back an already-created PR
@@ -74,19 +74,19 @@ description: >
74
74
 
75
75
  ### 6. 同步 PR 元数据
76
76
 
77
- 记录 `platform-pr create` 结构化结果中的 `result`(`pr_created`、`pr_reused` 或 `no_op`),并调用 `agent-infra-internal platform-pr sync {task-id} --agent {standard-agent-token} --metadata --closing-issue --result {primary-result}`。core 从 Issue 复制 type / `in:` labels、assignee 和具体 milestone,并维护 Development 关联;逐项权限不足返回 degraded,不反向更新 Issue。PR 已成功绑定后,metadata/summary 同步失败只产生与 primary result 对应的 `pr_created_with_warnings`、`pr_reused_with_warnings` 或 `no_op_with_warnings`,保留主动作事实,重试只执行未完成的同步步骤。
77
+ 记录 `platform-pr create` 结构化结果中的 `result`(`pr_created`、`pr_reused` 或 `no_op`),并调用 `agent-infra-internal platform-pr sync {task-id} --agent {standard-agent-token} --metadata --closing-issue --result {primary-result}`。`in:` target 由 shared core 根据 task-bound diff/PR evidence 和仓库映射计算,唯一 closing Issue 按 Issue→PR 顺序收敛,其他 metadata 仍从 Issue 同步;不从 Issue 反向复制 `in:`,也不清除非 `in:` labels。权限不足逐项返回 degraded,部分副作用返回 blocked/`IN_LABEL_SYNC_PARTIAL`。
78
78
 
79
79
  ### 7. 生成 PR 代码增减报告
80
80
 
81
- 创建或唯一复用 PR 后,调用 `agent-infra-internal platform-pr inspect {task-id}` 取得权威 base/head SHA,并按 `reference/change-report.md` 统计完整 PR 的分类行数、Git blob 字节数、rename 与疑似不必要变化。执行本步骤前先读取该 reference。
81
+ 创建或唯一复用 PR 后,调用 `agent-infra-internal platform-pr inspect {task-id}` 取得权威 base/head SHA,并按 `reference/change-report.md` 生成完整 PR 的机械统计。结合任务目标与完整三点 diff 生成六项带文件证据的 precheck candidate,再调用 `platform-pr change-report` 写入任务绑定的 `pr-change-report.json` sidecar。执行本步骤前先读取该 reference。
82
82
 
83
- 报告既是下方 reviewer 摘要的一部分,也必须出现在最终用户回复中;不得只给总行数、忽略字节变化或只统计最后一个 commit。
83
+ 报告由 core renderer 生成,既是下方 reviewer 摘要的一部分,也必须出现在最终用户回复中;不得只给总行数、忽略字节变化、只统计最后一个 commit,或由调用方自行拼接报告段。
84
84
 
85
85
  ### 8. 发布审查摘要
86
86
 
87
87
  读取最新的上下文产物:`plan.md` / `plan-r{N}.md`、`review-plan.md` / `review-plan-r{N}.md`、`code.md` / `code-r{N}.md`、`review-code.md` / `review-code-r{N}.md`(存在时)。
88
88
 
89
- 基于这些产物聚合 reviewer 摘要,并追加第 7 步生成的 `### PR 代码增减` 段落,再使用隐藏标记维护唯一且幂等的摘要评论。调用 `summary-sync` 时继续传递同一个 `--result {primary-result}`,不得根据同步子步骤猜测 PR 是创建还是复用。
89
+ 基于这些产物聚合 reviewer 摘要,正文只放一次 `<!-- canonical-pr-change-report -->` 占位符,再使用隐藏标记维护唯一且幂等的摘要评论。调用 `summary-sync` 时传入 `--change-report-file .agents/workspace/active/{task-id}/pr-change-report.json`,并继续传递同一个 `--result {primary-result}`;不得根据同步子步骤猜测 PR 是创建还是复用。
90
90
 
91
91
  > canonical context、摘要聚合和 `summary-sync` 调用见 `reference/comment-publish.md`(其引用 `.agents/rules/pr-sync.md`)。发布摘要前先读取该 reference。
92
92
 
@@ -139,15 +139,15 @@ agent-infra-internal task-verify {task-id} create-pr.completed --format text
139
139
 
140
140
  - 必须检查分支中的全部提交,而不是只看最后一个
141
141
  - `create-pr` 不能把 type label 映射委托给其他技能,必须在获取到 `{task-id}` 时于本技能内内联处理
142
- - summary marker 与当前 HEAD 由 `platform-pr summary-sync` 统一包装
143
- - 如果当前分支已存在 PR,直接告知用户 PR URL 并结束,不做重复同步
142
+ - summary marker、权威 PR head 和 `### PR 代码增减` 由 `platform-pr summary-sync` 统一包装
143
+ - 如果当前分支已存在 PR,仍须完成绑定、报告生成、摘要同步和结果校验;不得因复用而直接结束
144
144
  - 如果从 Issue 继承元数据失败,继续使用 task.md 和分支推断兜底
145
145
 
146
146
  ## 错误处理
147
147
 
148
148
  - `{target}` 与 `HEAD` 之间没有可提交内容
149
149
  - 推送被拒绝:建议执行 `git pull --rebase`
150
- - 已存在 PR:直接输出当前 PR URL 并结束
150
+ - 已存在 PR:继续完成绑定、报告生成、摘要同步和结果校验后输出当前 PR URL
151
151
  - 无法访问 Issue 元数据:跳过继承并继续
152
152
  - PR 创建失败且已关联 `{task-id}`:调用 `agent-infra-internal task-warning {task-id} add --step create-pr --severity ACTION_REQUIRED --code PR_CREATE_FAILED --target pr --message "{reason}" --action "修复推送、权限或平台问题后重跑 create-pr"` 提交结构化 warning 意图,不写不完整 `pr_delivery_fact`
153
153
  - PR 摘要评论失败且已关联 `{task-id}`:按 `.agents/rules/pr-sync.md` 记录 `COMMENT_SYNC_FAILED` 告警,不回滚已创建 PR
@@ -21,6 +21,7 @@
21
21
  "when": "issue_number_exists",
22
22
  "expected_pr_comment_marker": "<!-- sync-pr:{task-id}:summary -->",
23
23
  "verify_in_labels_match_pr": true,
24
+ "verify_in_labels_computed": true,
24
25
  "verify_pr_type_label": true,
25
26
  "verify_pr_assignee": true,
26
27
  "verify_issue_fields": true,
@@ -4,7 +4,7 @@
4
4
  {"source":"platform-pr-inspect","diff":"three-dot-find-renames","metrics":["numstat-lines","git-blob-bytes"],"publish":["pr-summary","user-response"]}
5
5
  -->
6
6
 
7
- After a PR is created or uniquely reused, use the authoritative `base.sha` and `head.sha` returned by `platform-pr inspect` to measure the complete PR diff. Do not substitute the last commit or current worktree state.
7
+ After a PR is created or uniquely reused, use the authoritative `base.sha` and `head.sha` returned by `platform-pr inspect` to measure the complete PR diff. Do not substitute the last commit or current worktree state. The task-intent digest covers only the semantic section from `# Task`/`# 任务` through `## Context`/`## 上下文`, so lifecycle logs, receipts, and version metadata do not stale a sidecar for the same head.
8
8
 
9
9
  ## Evidence Commands
10
10
 
@@ -14,6 +14,18 @@ git diff --find-renames --name-status {base-sha}...{head-sha}
14
14
  git diff --find-renames --summary {base-sha}...{head-sha}
15
15
  ```
16
16
 
17
+ Pass the script JSON and the model-generated six-check precheck candidate to the typed core:
18
+
19
+ ```bash
20
+ agent-infra-internal platform-pr change-report {task-id} \
21
+ --agent {standard-agent-token} --mechanical-file {mechanical-report-file} \
22
+ --precheck-file {precheck-candidate-file}
23
+ ```
24
+
25
+ The core validates the task-intent digest, PR identity, complete patch SHA, totals, and the ordered checks `target-alignment`, `change-composition`, `compatibility-policy`, `legacy-path-cleanup`, `redundancy`, and `scope-discipline`. A `needs-review` check routes to `review-code`; `formalReview` remains `false`.
26
+
27
+ When generating the candidate, each check's `rationale` must state its actual finding: `target-alignment` explains the goal relationship, `change-composition` summarizes where new code concentrates responsibilities, `compatibility-policy` states the compatibility result, `legacy-path-cleanup` states how legacy paths were handled, `redundancy` states the redundancy result, and `scope-discipline` states the scope judgment. Do not reuse generic phrases such as "within scope" across checks; each check must provide at least one directly relevant path, line range, and concise `detail`, using the deployed skill's language. Chinese skill deployments must use Chinese. These high-level rationales and evidence are rendered in the canonical summary.
28
+
17
29
  The script calculates both `numstat` line counts and exact Git blob byte sizes between the merge base and head. Bytes provide a stable unit, cover binary files, and reveal same-line compaction; submodules are not blobs and contribute zero bytes. Added files have zero old bytes, deleted files have zero new bytes, pure renames have zero net bytes, and copies count only the new destination content.
18
30
 
19
31
  Count binary files in the file total but do not invent line counts for `-` numstat values. Explain renames and copies from the script's per-file records, `name-status`, and `summary` so moves are not reported as full rewrites.
@@ -31,7 +43,7 @@ Using the repository's actual structure, assign every file to exactly one closes
31
43
 
32
44
  The table must contain component, file count, added lines, deleted lines, net lines, old bytes, new bytes, and net bytes, followed by a total row. Byte columns describe the blob content size of files involved in this change, not disk usage for the entire repository or worktree. Use exact integers; optional KiB/MiB values may aid readability but must not replace byte counts.
33
45
 
34
- Category line and byte totals must each reconcile exactly with the script's `totals`. Then list the largest files by line change and absolute net-byte change, distinguishing source, tests, template mirrors, and pure renames.
46
+ Category line and byte totals must each reconcile exactly with the script's `totals`. Then, for text files only, list the largest files by line change and absolute net-byte change, distinguishing source, tests, and template mirrors. Keep binary files in the category totals only; do not rank or interpret their content. Show renames as path changes without inferring a "pure rename" label.
35
47
 
36
48
  ## Required Analysis
37
49
 
@@ -40,7 +52,7 @@ Briefly explain:
40
52
  - where growth is concentrated and how runtime code compares with tests, docs, and templates;
41
53
  - whether net line and net byte changes tell different stories, especially for substantial same-line compaction or expansion;
42
54
  - which line changes are path moves, bilingual mirrors, or mechanical synchronization;
43
- - whether any change cannot be traced directly to the PR goal and may be unnecessary; if none, state the evidence;
55
+ - whether any change cannot be traced directly to the PR goal and may be unnecessary; if none, state the evidence; every check must cite file and line evidence;
44
56
  - when a test fixture is much larger than production changes, what risk it covers instead of judging it only by size.
45
57
 
46
- Add the complete report as a `### PR Code Changes` section in the reviewer summary body. Preserve the same table and conclusion in the user-visible create-pr completion response. Do not create a second PR comment for this report.
58
+ Do not write the `### PR Code Changes` section in the caller. Put exactly one `<!-- canonical-pr-change-report -->` placeholder in the plain body and let `summary-sync --change-report-file .agents/workspace/active/{task-id}/pr-change-report.json --result {primary-result}` replace it through the core renderer. Do not create a second PR comment for this report.
@@ -4,7 +4,7 @@
4
4
  {"source":"platform-pr-inspect","diff":"three-dot-find-renames","metrics":["numstat-lines","git-blob-bytes"],"publish":["pr-summary","user-response"]}
5
5
  -->
6
6
 
7
- PR 创建或复用成功后,使用 `platform-pr inspect` 返回的权威 `base.sha` 与 `head.sha` 统计完整 PR 差异,不以最后一个 commit 或工作树状态代替。
7
+ PR 创建或复用成功后,使用 `platform-pr inspect` 返回的权威 `base.sha` 与 `head.sha` 统计完整 PR 差异,不以最后一个 commit 或工作树状态代替。任务意图 digest 只覆盖 `# 任务`/`# Task` 到 `## 上下文`/`## Context` 的语义区间,因此生命周期日志、收据和版本元数据不会使同一 head 的 sidecar 失效。
8
8
 
9
9
  ## 证据命令
10
10
 
@@ -14,6 +14,18 @@ git diff --find-renames --name-status {base-sha}...{head-sha}
14
14
  git diff --find-renames --summary {base-sha}...{head-sha}
15
15
  ```
16
16
 
17
+ 将脚本 JSON 和模型生成的六项 precheck candidate 交给 typed core:
18
+
19
+ ```bash
20
+ agent-infra-internal platform-pr change-report {task-id} \
21
+ --agent {standard-agent-token} --mechanical-file {mechanical-report-file} \
22
+ --precheck-file {precheck-candidate-file}
23
+ ```
24
+
25
+ core 校验任务意图 digest、PR identity、完整 patch SHA、统计合计和固定顺序的 `target-alignment`、`change-composition`、`compatibility-policy`、`legacy-path-cleanup`、`redundancy`、`scope-discipline`。任一项为 `needs-review` 时路由到 `review-code`,`formalReview` 仍为 `false`。
26
+
27
+ 生成 candidate 时,六项 `rationale` 必须分别写出实际检查结论:`target-alignment` 说明目标对应关系,`change-composition` 概括新增代码集中承担的职责,`compatibility-policy` 说明兼容策略,`legacy-path-cleanup` 说明旧路径处理,`redundancy` 说明冗余检查结果,`scope-discipline` 说明范围判断。不得六项复用“符合范围”等泛化套话;每项至少提供一条直接支持结论的路径、行号和简短 `detail`,并遵循当前已部署技能的语言。中文技能必须使用中文。这些高层理由和证据会直接展示在 canonical 摘要中。
28
+
17
29
  脚本在 merge base 与 head 之间同时计算 `numstat` 行数和 Git blob 的精确字节数。字节比字符具有稳定口径,也能覆盖二进制文件和同行内缩减;子模块不是 blob,按 0 字节贡献核算。新增文件的旧字节数为 0,删除文件的新字节数为 0,纯 rename 的净字节数为 0,copy 只计新增目标内容。
18
30
 
19
31
  `numstat` 中的二进制文件计入文件数,但不虚构行数。rename/copy 依据脚本的逐文件记录、`name-status` 与 `summary` 单独说明,避免把移动误报为整文件重写。
@@ -31,7 +43,7 @@ git diff --find-renames --summary {base-sha}...{head-sha}
31
43
 
32
44
  输出表格必须包含“部分、文件数、新增行、删除行、净增行、旧字节、新字节、净字节”,并有合计行。字节列表示本次变更涉及文件的 blob 内容体积,不表示整个仓库或工作树的磁盘占用。使用精确整数;可附加 KiB/MiB 便于阅读,但不能替代字节数。
33
45
 
34
- 各类别的行数和字节数之和必须分别与脚本的 `totals` 一致。随后分别列出行数变化和绝对净字节变化最大的文件,并区分源码、测试、模板镜像和纯 rename。
46
+ 各类别的行数和字节数之和必须分别与脚本的 `totals` 一致。随后仅针对文本文件,分别列出行数变化和绝对净字节变化最大的文件,并区分源码、测试和模板镜像;二进制文件只保留在分类合计中,不参与代表性文件排序或内容判断。rename 只按路径变化展示,不推断“纯 rename”。
35
47
 
36
48
  ## 分析要求
37
49
 
@@ -40,7 +52,7 @@ git diff --find-renames --summary {base-sha}...{head-sha}
40
52
  - 增长主要集中在哪里,运行时代码与测试/文档/模板各占多少;
41
53
  - 行数净变化与净字节变化是否给出不同结论,尤其指出同行内明显缩减或膨胀;
42
54
  - 哪些行数只是路径迁移、双语镜像或机械同步;
43
- - 是否存在与 PR 目标无法直接对应、疑似不必要的变化;若没有,明确说明判断依据;
55
+ - 是否存在与 PR 目标无法直接对应、疑似不必要的变化;若没有,明确说明判断依据;每项结论必须给出文件和行号证据;
44
56
  - 若某个测试 fixture 明显大于生产改动,解释它覆盖的风险,而不是仅以行数评价。
45
57
 
46
- 将完整报告以 `### PR 代码增减` 段落写入 reviewer 摘要正文,并在 create-pr 的用户可见完成回复中原样保留同一张统计表与结论。不要把报告另建成第二条 PR 评论。
58
+ 调用方不要自行写入 `### PR 代码增减`。把恰好包含一次 `<!-- canonical-pr-change-report -->` 的普通摘要正文交给 `summary-sync --change-report-file .agents/workspace/active/{task-id}/pr-change-report.json --result {primary-result}`,由 core renderer 替换并发布。报告不另建第二条 PR 评论。
@@ -2,11 +2,13 @@
2
2
 
3
3
  After PR creation, run `agent-infra-internal platform-pr summary-context {task-id}` and aggregate the reviewer summary only from its canonical artifacts according to `.agents/rules/pr-sync.md`.
4
4
 
5
- Write the plain summary body to a temporary file, then run:
5
+ Write the plain summary body, containing exactly one `<!-- canonical-pr-change-report -->` placeholder and no report heading/JSON, marker, or HEAD metadata, to a temporary file, then run:
6
6
 
7
7
  ```bash
8
8
  agent-infra-internal platform-pr summary-sync {task-id} \
9
- --agent {standard-agent-token} --body-file {summary-body-file} --result {primary-result}
9
+ --agent {standard-agent-token} --body-file {summary-body-file} \
10
+ --change-report-file .agents/workspace/active/{task-id}/pr-change-report.json \
11
+ --result {primary-result}
10
12
  ```
11
13
 
12
- The caller does not add markers, HEAD metadata, or comment API parameters. `--result` is required and must be passed unchanged from `platform-pr create`; `no_op` maps to `no_op_with_warnings` if summary synchronization degrades. Summary failures do not roll back a created or reused PR.
14
+ The caller does not add markers, HEAD metadata, report sections, or comment API parameters. The typed core rechecks the task-bound sidecar against the authoritative PR snapshot and renders the report. `--result` is required and must be passed unchanged from `platform-pr create`; `no_op` maps to `no_op_with_warnings` if summary synchronization degrades. Missing/stale/invalid sidecars or body bypasses do not publish, and summary failures do not roll back a created or reused PR.
@@ -2,11 +2,13 @@
2
2
 
3
3
  创建 PR 后先调用 `agent-infra-internal platform-pr summary-context {task-id}`,只根据返回的 canonical 产物按 `.agents/rules/pr-sync.md` 聚合 reviewer 摘要。
4
4
 
5
- 把纯摘要正文写入临时文件,再调用:
5
+ 把恰好包含一次 `<!-- canonical-pr-change-report -->` 且不含报告标题/JSON、marker 或 HEAD 元数据的纯摘要正文写入临时文件,再调用:
6
6
 
7
7
  ```bash
8
8
  agent-infra-internal platform-pr summary-sync {task-id} \
9
- --agent {standard-agent-token} --body-file {summary-body-file} --result {primary-result}
9
+ --agent {standard-agent-token} --body-file {summary-body-file} \
10
+ --change-report-file .agents/workspace/active/{task-id}/pr-change-report.json \
11
+ --result {primary-result}
10
12
  ```
11
13
 
12
- 调用方不添加 marker、HEAD 或评论 API 参数。`--result` 是必填的,必须把 `platform-pr create` 的 `result` 原样传入;摘要失败沿用该 primary result 映射 warning(`no_op` 对应 `no_op_with_warnings`),不回滚已创建或复用的 PR。结果映射沿用 `.agents/rules/pr-sync.md`。
14
+ 调用方不添加 marker、HEAD、报告段或评论 API 参数。typed core 会重新校验任务绑定 sidecar 与权威 PR snapshot 并渲染报告。`--result` 是必填的,必须把 `platform-pr create` 的 `result` 原样传入;sidecar 缺失/过期/非法或正文旁路时不发布,摘要失败沿用该 primary result 映射 warning(`no_op` 对应 `no_op_with_warnings`),不回滚已创建或复用的 PR。结果映射沿用 `.agents/rules/pr-sync.md`。
@@ -42,7 +42,7 @@ Type label mapping:
42
42
 
43
43
  Metadata sync order:
44
44
  1. query Issue labels and milestone via the Issue read command in `.agents/rules/issue-pr-commands.md`
45
- 2. build `{label-args}` from the mapped type label, non-`type:` / non-`status:` Issue labels, and the current Issue `in:` labels (commit already computed them, so do not recompute them here and do not write back to the Issue)
45
+ 2. build `{label-args}` from the mapped type label and non-`type:` / non-`status:` Issue labels; `in:` labels are computed once by the shared platform core from task-bound diff/PR evidence, so do not recompute them here or copy them back from the Issue
46
46
  3. build `{milestone-arg}` by following "Phase 3: `create-pr`" in `.agents/rules/milestone-inference.md` and reusing the Issue milestone directly
47
47
  4. pass `{label-args}` and `{milestone-arg}` atomically by using the create-PR command template and permission-degradation rules in `.agents/rules/issue-pr-commands.md`
48
48
  5. ensure the PR body contains `Closes #{issue-number}` or an equivalent closing keyword
@@ -42,7 +42,7 @@ git diff <target-branch>...HEAD
42
42
 
43
43
  元数据同步顺序:
44
44
  1. 通过 `.agents/rules/issue-pr-commands.md` 的 Issue 读取命令查询 Issue labels 和 milestone
45
- 2. 从映射出的 type label、非 `type:` / 非 `status:` 的 Issue labels,以及当前 Issue `in:` labels 构建 `{label-args}`(commit 已经计算过,不在此重算,也不写回 Issue)
45
+ 2. 从映射出的 type label 和非 `type:` / 非 `status:` 的 Issue labels 构建 `{label-args}`;`in:` labels 由 shared platform core 根据 task-bound diff/PR evidence 统一计算,不在正文生成步骤重算,也不从 Issue 反向复制
46
46
  3. 按 `.agents/rules/milestone-inference.md` 的 "阶段 3:`create-pr`" 复用 Issue milestone 构建 `{milestone-arg}`
47
47
  4. 按 `.agents/rules/issue-pr-commands.md` 的创建 PR 命令模板与权限降级规则,将 `{label-args}` 和 `{milestone-arg}` 原子化传入
48
48
  5. 确保 PR 正文包含 `Closes #{issue-number}` 或等价关闭关键字
@@ -1,4 +1,5 @@
1
1
  import { execFileSync } from "node:child_process";
2
+ import { createHash } from "node:crypto";
2
3
 
3
4
  function fail(message) {
4
5
  process.stderr.write(`${message}\n`);
@@ -128,6 +129,7 @@ function numericLineCount(value) {
128
129
  function main() {
129
130
  const options = parseArgs(process.argv.slice(2));
130
131
  const mergeBase = git(["merge-base", options.base, options.head], options).trim();
132
+ const patch = git(["diff", "--no-ext-diff", "--binary", "--find-renames", mergeBase, options.head], options, null);
131
133
  const diffArgs = ["diff", "--no-ext-diff", "--find-renames", "-z", mergeBase, options.head];
132
134
  const files = parseRawDiff(git([...diffArgs.slice(0, 2), "--raw", "--abbrev=64", ...diffArgs.slice(2)], options, null));
133
135
  const numstat = parseNumstat(git([...diffArgs.slice(0, 2), "--numstat", ...diffArgs.slice(2)], options, null));
@@ -191,6 +193,7 @@ function main() {
191
193
  base: options.base,
192
194
  head: options.head,
193
195
  mergeBase,
196
+ patchSha256: createHash("sha256").update(patch).digest("hex"),
194
197
  files: reportFiles,
195
198
  totals
196
199
  }, null, 2)}\n`);
@@ -9,7 +9,7 @@ description: >
9
9
  # Design Technical Plan
10
10
  > `--agent` values are defined in `.agents/rules/task-management.md` under “Collaborator Token Specification”.
11
11
 
12
- If the entry operands contain `--orchestrated`, bind `{execution-flag}` to `--orchestrated` and forward it unchanged to the completed event; otherwise bind it to an empty value. Never infer it from `orchestration.json`, environment variables, or prior artifacts.
12
+ If the entry operands contain `--orchestrated`, bind `{execution-flag}` to `--orchestrated` and forward it unchanged to the completed event; otherwise bind it to an empty value. Never infer it from `orchestration.json`, environment variables, or prior artifacts. Lifecycle events also require explicit trigger data: use `{trigger-initiator}=orchestrator` for orchestration and `model` otherwise; `{request-id}` is a stable single-line identifier for this task and artifact round, and `{reason-code}` is `user-request`, `new-requirement`, or `upstream-fact-doubt`. Reuse the same values for started and completed.
13
13
 
14
14
  ## Boundary / Critical Rules
15
15
 
@@ -41,7 +41,7 @@ Before the state check is complete, do not make external-state assertions such a
41
41
 
42
42
  ## Step Start: Write the started Marker
43
43
 
44
- After resolving the artifact context and before this round's first artifact action, run `agent-infra-internal task-event {task-id} plan.started --agent {standard-agent-token}` and verify the returned `artifactContext`.
44
+ After resolving the artifact context and before this round's first artifact action, run `agent-infra-internal task-event {task-id} plan.started --agent {standard-agent-token} --initiator {trigger-initiator} --request-id {request-id} --reason-code {reason-code}` and verify the returned `artifactContext`.
45
45
 
46
46
  ## Steps
47
47
 
@@ -115,7 +115,17 @@ Update `.agents/workspace/active/{task-id}/task.md`:
115
115
  - Overwrite the `effort` field in frontmatter with the new value
116
116
  - Append a `## Effort Re-estimate` section to this round's plan artifact `{plan-artifact}`, recording: `effort {old} → {new} (rationale: {short basis grounded in this plan})`
117
117
  If the re-estimated value matches the current value, skip it: do not write the `## Effort Re-estimate` section. The Flow A sync that follows reads the possibly updated frontmatter and propagates the new value to the Issue automatically.
118
- After the business fields are updated, run `agent-infra-internal task-event {task-id} plan.completed --agent {standard-agent-token} --artifact {plan-artifact} {execution-flag}` so the core atomically records the link, stage, agent, metadata, and Activity Log.
118
+ After writing the local artifact, run the pre-completion gate:
119
+
120
+ ```bash
121
+ agent-infra-internal task-artifact {task-id} finalize-local --family plan --artifact {plan-artifact}
122
+ ```
123
+
124
+ - On `status=passed`, save that result's `artifactSha256` and `semanticDigest`; the finalizer has recorded the matching one-shot local provenance intent.
125
+ - 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.
126
+ - 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.
127
+
128
+ Use the digests from that same `status=passed` result in `agent-infra-internal task-event {task-id} plan.completed --agent {standard-agent-token} --initiator {trigger-initiator} --request-id {request-id} --reason-code {reason-code} --artifact {plan-artifact} --artifact-sha256 {artifact-sha256} --semantic-digest {semantic-digest} {execution-flag}` so the core records the link, stage, agent, metadata, and Activity Log atomically.
119
129
  - {YYYY-MM-DD HH:mm:ss±HH:MM} — **Plan Task (Round {N})** by {agent} — Plan completed, awaiting human review → {artifact-filename}
120
130
  ```
121
131