@fitlab-ai/agent-infra 0.10.0 → 0.11.1

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 (154) hide show
  1. package/README.md +2 -6
  2. package/README.zh-CN.md +2 -6
  3. package/bin/internal-cli.sh +0 -13
  4. package/dist/bin/internal-cli.js +11 -49
  5. package/dist/lib/internal/cli-route-inventory.js +3 -4
  6. package/dist/lib/internal/manual-validation.js +6 -2
  7. package/dist/lib/internal/platform-comment.js +60 -2
  8. package/dist/lib/internal/task-artifact.js +1 -1
  9. package/dist/lib/internal/task-finalization.js +2 -2
  10. package/dist/lib/internal/task-lifecycle.js +2 -2
  11. package/dist/lib/internal/task-operation-registry.js +22 -12
  12. package/dist/lib/internal/task-orchestration.js +2 -2
  13. package/dist/lib/internal/task-review.js +10 -5
  14. package/dist/lib/platform/activity-recovery.js +159 -0
  15. package/dist/lib/platform/issue-comments.js +84 -32
  16. package/dist/lib/platform/issues.js +3 -4
  17. package/dist/lib/platform/task-comment-projection.js +70 -0
  18. package/dist/lib/platform/task-recovery.js +55 -0
  19. package/dist/lib/platform/verification-sync.js +184 -162
  20. package/dist/lib/sandbox/control/executor.js +4 -2
  21. package/dist/lib/sandbox/control/task-workflow.js +1 -1
  22. package/dist/lib/sandbox/control/workflow-executor.js +90 -22
  23. package/dist/lib/server/process-state.js +17 -5
  24. package/dist/lib/task/artifact-command.js +6 -3
  25. package/dist/lib/task/artifact-lifecycle.js +15 -52
  26. package/dist/lib/task/artifact-operations.js +28 -2
  27. package/dist/lib/task/artifact-recovery.js +114 -68
  28. package/dist/lib/task/artifact-repair-intent.js +25 -8
  29. package/dist/lib/task/capabilities.js +0 -2
  30. package/dist/lib/task/control-authority.js +1 -1
  31. package/dist/lib/task/events.js +66 -49
  32. package/dist/lib/task/gate-policy.js +94 -0
  33. package/dist/lib/task/intermediate-cleanup.js +28 -3
  34. package/dist/lib/task/local-artifact-finalization.js +85 -18
  35. package/dist/lib/task/orchestration.js +8 -6
  36. package/dist/lib/task/review-artifacts.js +12 -6
  37. package/dist/lib/task/review-command.js +2 -2
  38. package/dist/lib/task/review-finalization.js +198 -11
  39. package/dist/lib/{host-control → task}/secure-fs.js +8 -19
  40. package/dist/lib/task/verification-engine.js +28 -17
  41. package/dist/lib/task/verification.js +25 -9
  42. package/dist/lib/task/workflow-command.js +2 -0
  43. package/dist/lib/task/workflow-dispatch.js +161 -0
  44. package/dist/lifecycle-build-manifest.json +3 -3
  45. package/lib/internal/cli-route-inventory.ts +3 -4
  46. package/lib/internal/manual-validation.ts +6 -2
  47. package/lib/internal/platform-comment.ts +53 -2
  48. package/lib/internal/task-artifact.ts +1 -1
  49. package/lib/internal/task-finalization.ts +1 -1
  50. package/lib/internal/task-lifecycle.ts +1 -1
  51. package/lib/internal/task-operation-registry.ts +22 -12
  52. package/lib/internal/task-orchestration.ts +1 -1
  53. package/lib/internal/task-review.ts +9 -5
  54. package/lib/platform/activity-recovery.ts +179 -0
  55. package/lib/platform/issue-comments.ts +98 -31
  56. package/lib/platform/issues.ts +3 -4
  57. package/lib/platform/task-comment-projection.ts +79 -0
  58. package/lib/platform/task-recovery.ts +54 -0
  59. package/lib/platform/verification-sync.ts +203 -188
  60. package/lib/sandbox/control/executor.ts +4 -2
  61. package/lib/sandbox/control/protocol.ts +1 -1
  62. package/lib/sandbox/control/task-workflow.ts +1 -1
  63. package/lib/sandbox/control/workflow-executor.ts +113 -22
  64. package/lib/server/process-state.ts +26 -5
  65. package/lib/task/artifact-command.ts +6 -4
  66. package/lib/task/artifact-lifecycle.ts +12 -49
  67. package/lib/task/artifact-operations.ts +28 -2
  68. package/lib/task/artifact-recovery.ts +120 -67
  69. package/lib/task/artifact-repair-intent.ts +38 -11
  70. package/lib/task/capabilities.ts +0 -1
  71. package/lib/task/control-authority.ts +1 -1
  72. package/lib/task/events.ts +55 -38
  73. package/lib/task/gate-policy.ts +133 -0
  74. package/lib/task/intermediate-cleanup.ts +18 -2
  75. package/lib/task/local-artifact-finalization.ts +91 -15
  76. package/lib/task/orchestration.ts +12 -7
  77. package/lib/task/review-artifacts.ts +8 -2
  78. package/lib/task/review-command.ts +1 -1
  79. package/lib/task/review-finalization.ts +198 -9
  80. package/lib/{host-control → task}/secure-fs.ts +10 -32
  81. package/lib/task/verification-engine.ts +24 -14
  82. package/lib/task/verification-types.ts +7 -0
  83. package/lib/task/verification.ts +25 -9
  84. package/lib/task/workflow-command.ts +2 -0
  85. package/lib/task/workflow-dispatch.ts +171 -0
  86. package/package.json +1 -1
  87. package/templates/.agents/rules/issue-sync.en.md +11 -1
  88. package/templates/.agents/rules/issue-sync.zh-CN.md +6 -2
  89. package/templates/.agents/rules/local-artifact-repair.en.md +18 -9
  90. package/templates/.agents/rules/local-artifact-repair.zh-CN.md +21 -11
  91. package/templates/.agents/skills/analyze-task/SKILL.en.md +2 -2
  92. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +2 -2
  93. package/templates/.agents/skills/analyze-task/config/verify.en.json +1 -10
  94. package/templates/.agents/skills/analyze-task/config/verify.zh-CN.json +1 -10
  95. package/templates/.agents/skills/block-task/config/verify.json +1 -3
  96. package/templates/.agents/skills/cancel-task/config/verify.json +1 -4
  97. package/templates/.agents/skills/code-task/SKILL.en.md +4 -4
  98. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +5 -5
  99. package/templates/.agents/skills/code-task/config/verify.en.json +1 -12
  100. package/templates/.agents/skills/code-task/config/verify.zh-CN.json +1 -12
  101. package/templates/.agents/skills/code-task/reference/dual-mode.en.md +1 -1
  102. package/templates/.agents/skills/code-task/reference/dual-mode.zh-CN.md +1 -1
  103. package/templates/.agents/skills/code-task/reference/report-template.en.md +11 -0
  104. package/templates/.agents/skills/code-task/reference/report-template.zh-CN.md +11 -0
  105. package/templates/.agents/skills/commit/config/verify.json +1 -5
  106. package/templates/.agents/skills/complete-manual-validation/config/verify.en.json +6 -6
  107. package/templates/.agents/skills/complete-manual-validation/config/verify.zh-CN.json +6 -6
  108. package/templates/.agents/skills/complete-task/config/verify.en.json +3 -14
  109. package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +3 -14
  110. package/templates/.agents/skills/create-pr/config/verify.json +1 -10
  111. package/templates/.agents/skills/create-task/config/verify.json +1 -4
  112. package/templates/.agents/skills/import-issue/config/verify.json +1 -2
  113. package/templates/.agents/skills/plan-task/SKILL.en.md +2 -2
  114. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +2 -2
  115. package/templates/.agents/skills/plan-task/config/verify.en.json +1 -10
  116. package/templates/.agents/skills/plan-task/config/verify.zh-CN.json +1 -10
  117. package/templates/.agents/skills/restore-task/SKILL.en.md +9 -4
  118. package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +10 -5
  119. package/templates/.agents/skills/review-analysis/SKILL.en.md +1 -1
  120. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +1 -1
  121. package/templates/.agents/skills/review-analysis/config/verify.en.json +1 -10
  122. package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +1 -10
  123. package/templates/.agents/skills/review-analysis/reference/report-template.en.md +2 -0
  124. package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +2 -0
  125. package/templates/.agents/skills/review-code/SKILL.en.md +3 -2
  126. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +3 -2
  127. package/templates/.agents/skills/review-code/config/verify.en.json +1 -10
  128. package/templates/.agents/skills/review-code/config/verify.zh-CN.json +1 -10
  129. package/templates/.agents/skills/review-code/reference/report-template.en.md +2 -0
  130. package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +2 -0
  131. package/templates/.agents/skills/review-plan/SKILL.en.md +1 -1
  132. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +1 -1
  133. package/templates/.agents/skills/review-plan/config/verify.en.json +1 -10
  134. package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +1 -10
  135. package/templates/.agents/skills/review-plan/reference/report-template.en.md +2 -0
  136. package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +2 -0
  137. package/templates/.agents/skills/review-pr/config/verify.en.json +1 -8
  138. package/templates/.agents/skills/review-pr/config/verify.zh-CN.json +1 -8
  139. package/templates/.agents/skills/run-manual-validation/config/verify.en.json +38 -13
  140. package/templates/.agents/skills/run-manual-validation/config/verify.zh-CN.json +38 -13
  141. package/dist/lib/host-control/audit.js +0 -19
  142. package/dist/lib/host-control/client.js +0 -142
  143. package/dist/lib/host-control/command.js +0 -49
  144. package/dist/lib/host-control/path.js +0 -160
  145. package/dist/lib/host-control/server.js +0 -159
  146. package/dist/lib/host-control/service.js +0 -112
  147. package/dist/lib/internal/host-control.js +0 -28
  148. package/lib/host-control/audit.ts +0 -22
  149. package/lib/host-control/client.ts +0 -172
  150. package/lib/host-control/command.ts +0 -60
  151. package/lib/host-control/path.ts +0 -167
  152. package/lib/host-control/server.ts +0 -180
  153. package/lib/host-control/service.ts +0 -133
  154. package/lib/internal/host-control.ts +0 -28
@@ -30,18 +30,7 @@
30
30
  ]
31
31
  },
32
32
  "platform-sync": {
33
- "when": "platform_issue_identity_exists",
34
- "expected_status_label": "status: in-progress",
35
- "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
36
- "verify_comment_content": true,
37
- "verify_task_comment_content": true,
38
- "verify_issue_type": true,
39
- "verify_issue_fields": false,
40
- "verify_in_labels_computed": true,
41
- "verify_milestone": true,
42
- "verify_milestone_specific": true,
43
- "expected_status_label_key": "inProgress",
44
- "expected_comment_marker_key": "artifact"
33
+ "when": "platform_issue_identity_exists"
45
34
  }
46
35
  }
47
36
  }
@@ -30,18 +30,7 @@
30
30
  ]
31
31
  },
32
32
  "platform-sync": {
33
- "when": "platform_issue_identity_exists",
34
- "expected_status_label": "status: in-progress",
35
- "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
36
- "verify_comment_content": true,
37
- "verify_task_comment_content": true,
38
- "verify_issue_type": true,
39
- "verify_issue_fields": false,
40
- "verify_in_labels_computed": true,
41
- "verify_milestone": true,
42
- "verify_milestone_specific": true,
43
- "expected_status_label_key": "inProgress",
44
- "expected_comment_marker_key": "artifact"
33
+ "when": "platform_issue_identity_exists"
45
34
  }
46
35
  }
47
36
  }
@@ -10,7 +10,7 @@ agent-infra-internal task-artifact {task-id} inspect --family code
10
10
 
11
11
  The core scans `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` in the task directory.
12
12
 
13
- `code.started` persists the plan identity and SHA-256 for the round in task.md frontmatter. `code.completed` must read the canonical plan from the implementation report's `Plan Input` field and match both that start context and the current latest plan; missing, mismatched, or changed input fails closed.
13
+ `code.started` persists the plan identity and SHA-256 for the round in task.md frontmatter. `code.completed` uses that start context and verifies the current latest plan; changed input fails closed. The implementation report's `Plan Input` field is reader-facing traceability, not lifecycle identity validation.
14
14
 
15
15
  ## Eight Branches
16
16
 
@@ -10,7 +10,7 @@ agent-infra-internal task-artifact {task-id} inspect --family code
10
10
 
11
11
  核心扫描任务目录中的 `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`。
12
12
 
13
- `code.started` 会在 task.md frontmatter 中绑定本轮方案文件及其 SHA-256。`code.completed` 必须从实现报告的“方案输入”/“Plan Input”字段读取 canonical plan,并同时匹配该开始上下文和当前最新 plan;缺失、身份不一致或内容变化均失败关闭。
13
+ `code.started` 会在 task.md frontmatter 中绑定本轮方案文件及其 SHA-256。`code.completed` 使用该开始上下文并校验当前最新 plan;内容变化失败关闭。实现报告的“方案输入”/“Plan Input”仅供读者追溯,不参与生命周期身份校验。
14
14
 
15
15
  ## 8 个分支
16
16
 
@@ -4,6 +4,8 @@
4
4
 
5
5
  Use this structure when creating `code.md` or `code-r{N}.md`.
6
6
 
7
+ > Implementation-input fields provide reader-facing traceability. Lifecycle identity uses the input frozen by `code.started` and the completion receipt; it is not parsed from this report body.
8
+
7
9
  ## Output Template
8
10
 
9
11
  ```markdown
@@ -103,6 +105,15 @@ Use this structure when creating `code.md` or `code-r{N}.md`.
103
105
  > Record the state-check command, task/artifact scope, key result, and uncovered parts; each command starts with `$ `.
104
106
  > Follow `.agents/rules/evidence-reporting.md`: record task/artifact scope, key result, and uncovered parts; do not paste complete successful stdout.
105
107
 
108
+ Record at least one actually executed `$ ` command and its result summary; prose-only status is insufficient. An implementation-stage report normally includes:
109
+
110
+ ```text
111
+ $ agent-infra-internal task-snapshot {task-id} --format text
112
+ {task state, implementation-artifact scope, and uncovered-area summary}
113
+ $ agent-infra-internal task-artifact {task-id} inspect --family code
114
+ {code artifact, upstream input, and next-step summary}
115
+ ```
116
+
106
117
  ## Raw Evidence
107
118
 
108
119
  > Follow `.agents/rules/evidence-reporting.md`: pair each claim with a `$ ` command and proportionate result summary; include a decisive raw excerpt only for failures, blocking conditions, or disputes.
@@ -4,6 +4,8 @@
4
4
 
5
5
  创建 `code.md` 或 `code-r{N}.md` 时,使用以下结构。
6
6
 
7
+ > “实现输入”字段用于读者追溯。生命周期身份以 `code.started` 冻结的输入和完成 receipt 为准,不从本报告正文解析。
8
+
7
9
  ## 输出模板
8
10
 
9
11
  ```markdown
@@ -103,6 +105,15 @@
103
105
  > 记录状态核对命令、任务/产物范围、关键结果和未覆盖部分;每条命令以 `$ ` 开头。
104
106
  > 按 `.agents/rules/evidence-reporting.md` 同时记录任务/产物范围、关键结果和未覆盖部分;正常成功不粘贴完整 stdout。
105
107
 
108
+ 必须记录至少一条实际执行的 `$ ` 命令及其结果摘要,不能只写自然语言状态。实现阶段通常包括:
109
+
110
+ ```text
111
+ $ agent-infra-internal task-snapshot {task-id} --format text
112
+ {任务状态、实现产物范围和未覆盖项摘要}
113
+ $ agent-infra-internal task-artifact {task-id} inspect --family code
114
+ {code artifact、上游输入和下一步摘要}
115
+ ```
116
+
106
117
  ## 证据原文
107
118
 
108
119
  > 遵循 `.agents/rules/evidence-reporting.md`:每条断言配对 `$ ` 命令和相称结果摘要;仅为失败、阻塞或争议附决定性原文摘录。
@@ -18,11 +18,7 @@
18
18
  "expected_action_pattern": "Commit"
19
19
  },
20
20
  "platform-sync": {
21
- "when": "pr_fact_bound",
22
- "expected_pr_comment_marker": "<!-- sync-pr:{task-id}:summary -->",
23
- "verify_in_labels_computed": true,
24
- "verify_pr_comment_last_commit_matches_head": true,
25
- "expected_pr_comment_marker_key": "prSummary"
21
+ "when": "pr_fact_bound"
26
22
  }
27
23
  }
28
24
  }
@@ -31,17 +31,17 @@
31
31
  "expected_action_pattern": "Complete Manual Validation"
32
32
  },
33
33
  "review-ledger": {
34
- "stage_scope": ["analysis", "plan", "code"]
34
+ "stage_scope": [
35
+ "analysis",
36
+ "plan",
37
+ "code"
38
+ ]
35
39
  },
36
40
  "platform-sync": {
37
41
  "when": "pr_fact_bound",
38
- "expected_pr_comment_marker_key": "prSummary",
39
42
  "expected_pr_comment_required_patterns": [
40
43
  "^### ✅ (?:人工验证已通过|Manual Validation Passed)$"
41
- ],
42
- "verify_task_comment_content": true,
43
- "verify_issue_type": true,
44
- "verify_issue_fields": false
44
+ ]
45
45
  }
46
46
  }
47
47
  }
@@ -31,17 +31,17 @@
31
31
  "expected_action_pattern": "Complete Manual Validation"
32
32
  },
33
33
  "review-ledger": {
34
- "stage_scope": ["analysis", "plan", "code"]
34
+ "stage_scope": [
35
+ "analysis",
36
+ "plan",
37
+ "code"
38
+ ]
35
39
  },
36
40
  "platform-sync": {
37
41
  "when": "pr_fact_bound",
38
- "expected_pr_comment_marker_key": "prSummary",
39
42
  "expected_pr_comment_required_patterns": [
40
43
  "^### ✅ (?:人工验证已通过|Manual Validation Passed)$"
41
- ],
42
- "verify_task_comment_content": true,
43
- "verify_issue_type": true,
44
- "verify_issue_fields": false
44
+ ]
45
45
  }
46
46
  }
47
47
  }
@@ -15,8 +15,7 @@
15
15
  "completed_at"
16
16
  ],
17
17
  "expected_status": "completed",
18
- "require_completed_at": true,
19
- "require_target_date": true
18
+ "require_completed_at": true
20
19
  },
21
20
  "activity-log": {
22
21
  "expected_action_pattern": "(Complete Task|Completed)"
@@ -28,21 +27,11 @@
28
27
  "manual-validation": {},
29
28
  "post-review-commit": {},
30
29
  "platform-sync-preflight": {
31
- "when": "platform_issue_identity_exists",
32
- "expected_comment_marker": "<!-- sync-issue:{task-id}:summary -->",
33
- "verify_task_comment_content": false,
34
- "sync_checked_requirements": true,
35
- "verify_issue_type": true,
36
- "verify_issue_fields": false,
37
- "verify_milestone": true,
38
- "verify_closed_issue_has_no_status_labels": false,
39
- "expected_comment_marker_key": "summary"
30
+ "when": "platform_issue_identity_exists"
40
31
  },
41
32
  "required-pr-delivery": {},
42
33
  "platform-sync": {
43
- "when": "platform_issue_identity_exists",
44
- "verify_task_comment_content": true,
45
- "verify_closed_issue_has_no_status_labels": true
34
+ "when": "platform_issue_identity_exists"
46
35
  },
47
36
  "artifact": {
48
37
  "file_pattern": "task.md",
@@ -15,8 +15,7 @@
15
15
  "completed_at"
16
16
  ],
17
17
  "expected_status": "completed",
18
- "require_completed_at": true,
19
- "require_target_date": true
18
+ "require_completed_at": true
20
19
  },
21
20
  "activity-log": {
22
21
  "expected_action_pattern": "(Complete Task|Completed)"
@@ -28,21 +27,11 @@
28
27
  "manual-validation": {},
29
28
  "post-review-commit": {},
30
29
  "platform-sync-preflight": {
31
- "when": "platform_issue_identity_exists",
32
- "expected_comment_marker": "<!-- sync-issue:{task-id}:summary -->",
33
- "verify_task_comment_content": false,
34
- "sync_checked_requirements": true,
35
- "verify_issue_type": true,
36
- "verify_issue_fields": false,
37
- "verify_milestone": true,
38
- "verify_closed_issue_has_no_status_labels": false,
39
- "expected_comment_marker_key": "summary"
30
+ "when": "platform_issue_identity_exists"
40
31
  },
41
32
  "required-pr-delivery": {},
42
33
  "platform-sync": {
43
- "when": "platform_issue_identity_exists",
44
- "verify_task_comment_content": true,
45
- "verify_closed_issue_has_no_status_labels": true
34
+ "when": "platform_issue_identity_exists"
46
35
  },
47
36
  "artifact": {
48
37
  "file_pattern": "task.md",
@@ -18,16 +18,7 @@
18
18
  "expected_action_pattern": "(Create PR|PR Created)"
19
19
  },
20
20
  "platform-sync": {
21
- "when": "platform_issue_identity_exists",
22
- "expected_pr_comment_marker": "<!-- sync-pr:{task-id}:summary -->",
23
- "verify_in_labels_match_pr": true,
24
- "verify_in_labels_computed": true,
25
- "verify_pr_type_label": true,
26
- "verify_pr_assignee": true,
27
- "verify_issue_fields": true,
28
- "verify_milestone": true,
29
- "verify_milestone_specific": true,
30
- "expected_pr_comment_marker_key": "prSummary"
21
+ "when": "platform_issue_identity_exists"
31
22
  }
32
23
  }
33
24
  }
@@ -22,10 +22,7 @@
22
22
  },
23
23
  "platform-sync": {
24
24
  "when": "platform_issue_identity_exists",
25
- "issue_must_exist": true,
26
- "verify_task_comment_content": true,
27
- "verify_milestone": true,
28
- "expected_status_label_key": "waitingForTriage"
25
+ "issue_must_exist": true
29
26
  }
30
27
  }
31
28
  }
@@ -22,8 +22,7 @@
22
22
  },
23
23
  "platform-sync": {
24
24
  "when": "platform_issue_identity_exists",
25
- "issue_must_exist": true,
26
- "verify_task_comment_content": true
25
+ "issue_must_exist": true
27
26
  }
28
27
  }
29
28
  }
@@ -135,8 +135,8 @@ agent-infra-internal task-artifact {task-id} finalize-local --family plan --arti
135
135
  ```
136
136
 
137
137
  - On `status=passed`, save that result's `artifactSha256` and `semanticDigest`; the finalizer has recorded the matching one-shot local provenance intent.
138
- - 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.
139
- - 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.
138
+ - On `status=failed` with recovery context, after the completion gates pass, edit the returned `candidatePath` only once for this attempt, then rerun the finalizer completely with the same `recoveryId`; if it still fails with a new diagnostic and fingerprint while the gates continue to pass, continue to the next attempt; the formal artifact must remain unchanged until commit.
139
+ - The recovery candidate must match the recorded task, round, artifact, baseline, and request identity. On baseline conflict, unknown state, an unsafe repair, repeated diagnostics or fingerprints, no progress, or the shared edit limit, stop without publishing a completed event.
140
140
 
141
141
  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.
142
142
  - {YYYY-MM-DD HH:mm:ss±HH:MM} — **Plan Task (Round {N})** by {agent} — Plan completed, awaiting human review → {artifact-filename}
@@ -134,8 +134,8 @@ agent-infra-internal task-artifact {task-id} init --family plan --artifact {plan
134
134
  agent-infra-internal task-artifact {task-id} finalize-local --family plan --artifact {plan-artifact}
135
135
  ```
136
136
  - `status=passed`:保存本次返回的 `artifactSha256` 和 `semanticDigest`;finalizer 已记录对应的一次性本地 provenance intent。
137
- - `status=failed` 且返回 recovery context:完成门禁通过后,只编辑返回的 `candidatePath` 一次,然后使用同一个 `recoveryId` 完整重跑 finalizer;formal artifact 在 commit 前必须保持不变。
138
- - recovery candidate 必须与记录的任务、轮次、产物、baseline 和 request identity 匹配;基线冲突、未知状态、无进展或重复失败:停止,不发布 completed 事件。
137
+ - `status=failed` 且返回 recovery context:完成门禁通过后,本次只编辑返回的 `candidatePath` 一次,然后使用同一个 `recoveryId` 完整重跑 finalizer;若仍失败但诊断和指纹均未重复且安全门继续通过,继续下一轮;formal artifact 在 commit 前必须保持不变。
138
+ - recovery candidate 必须与记录的任务、轮次、产物、baseline 和 request identity 匹配;基线冲突、未知状态、无法安全修复、诊断或指纹重复、无进展,或达到共享规则的编辑上限时停止,不发布 completed 事件。
139
139
  - 使用同一次 `status=passed` 返回的摘要执行 `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}`,由核心登记链接、阶段、代理、时间、版本和 Activity Log。
140
140
 
141
141
  如果 task.md 中存在有效的 `platform_issue_identity`,执行以下同步操作(任一失败则跳过并继续):
@@ -28,16 +28,7 @@
28
28
  ]
29
29
  },
30
30
  "platform-sync": {
31
- "when": "platform_issue_identity_exists",
32
- "expected_status_label": "status: pending-design-work",
33
- "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
34
- "verify_comment_content": true,
35
- "verify_task_comment_content": true,
36
- "verify_issue_type": true,
37
- "verify_issue_fields": false,
38
- "verify_milestone": true,
39
- "expected_status_label_key": "pendingDesignWork",
40
- "expected_comment_marker_key": "artifact"
31
+ "when": "platform_issue_identity_exists"
41
32
  }
42
33
  }
43
34
  }
@@ -28,16 +28,7 @@
28
28
  ]
29
29
  },
30
30
  "platform-sync": {
31
- "when": "platform_issue_identity_exists",
32
- "expected_status_label": "status: pending-design-work",
33
- "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
34
- "verify_comment_content": true,
35
- "verify_task_comment_content": true,
36
- "verify_issue_type": true,
37
- "verify_issue_fields": false,
38
- "verify_milestone": true,
39
- "expected_status_label_key": "pendingDesignWork",
40
- "expected_comment_marker_key": "artifact"
31
+ "when": "platform_issue_identity_exists"
41
32
  }
42
33
  }
43
34
  }
@@ -45,13 +45,14 @@ Run `agent-infra-internal platform-comment list --issue {issue-token}` to read a
45
45
 
46
46
  ### 3. Determine the task-id and Files to Restore
47
47
 
48
- Filter comments by the task, artifact, and chunked artifact markers defined in `.agents/rules/issue-sync.md`.
48
+ Filter comments by the task, artifact, chunked artifact, and recovery markers defined in `.agents/rules/issue-sync.md`.
49
49
 
50
50
  Rules:
51
51
  - when `{task-id}` was provided, match only that task
52
52
  - when `{task-id}` was omitted, infer it from the task comment marker first
53
53
  - if you cannot determine a unique task-id, stop and tell the user
54
54
  - ignore `summary` marker comments because they are complete-task aggregate output rather than restorable local task files
55
+ - use the `task` comment only for the current projection and snapshot identity; the controlled recovery core validates `recovery-action`, `recovery-prepare`, and `recovery-commit` comments and reconstructs the complete `task.md`
55
56
  - map `{file-stem}` back to filenames:
56
57
  - `task` -> `task.md`
57
58
  - `analysis` / `analysis-r{N}` -> matching `.md`
@@ -68,7 +69,7 @@ Read `.agents/rules/issue-sync.md` before executing this step.
68
69
 
69
70
  For each file:
70
71
  - collect its single comment or chunked comments
71
- - for `task.md` comments, reverse the `<details>` frontmatter wrapper described in issue-sync.md before reassembling the file body
72
+ - do not reverse the projected task comment directly into `task.md`; the complete task content must come from a recovery commit matching the current projection
72
73
  - when a chunk marker includes part and total indexes, sort by part and verify the set is complete
73
74
  - extract the file body by removing the hidden marker, heading, and footer
74
75
  - concatenate chunk bodies into the final file content
@@ -83,10 +84,14 @@ If the directory already exists, stop immediately and tell the user to handle it
83
84
 
84
85
  Create the controlled staging directory and write files back in this order:
85
86
 
86
- 1. `task.md`
87
+ 1. call the recovery core to write `task.md`:
88
+ ```bash
89
+ agent-infra-internal platform-comment recover --issue {issue-token} --task-id {task-id} \
90
+ --output "{staging-dir}/task.md"
91
+ ```
87
92
  2. every other restored artifact file in filename order
88
93
 
89
- Write only files that were actually recovered from Issue comments. Do not invent missing files.
94
+ Write only files that were actually recovered from Issue comments. Do not invent missing files. Stop without calling the lifecycle intent if the recovery core fails.
90
95
 
91
96
  ### 6. Apply the Restore Lifecycle Intent
92
97
 
@@ -44,13 +44,14 @@ description: >
44
44
 
45
45
  ### 3. 确定 task-id 与待恢复文件
46
46
 
47
- 按 `.agents/rules/issue-sync.md` 中定义的 task、artifact 和分片 artifact 标记筛选评论。
47
+ 按 `.agents/rules/issue-sync.md` 中定义的 task、artifact 与分片 artifact 标记筛选评论。
48
48
 
49
49
  处理规则:
50
50
  - 用户提供了 `{task-id}` 时,仅匹配该任务
51
51
  - 未提供时,优先从 task 评论标记推断
52
52
  - 若找不到唯一 task-id,立即停止并告知用户
53
53
  - 忽略 `summary` 标记评论;它是 complete-task 的聚合产物,不对应本地任务文件
54
+ - `task`、artifact 和交付摘要评论顶部的折叠恢复元数据由受控 recovery core 验证并重建活动日志。
54
55
  - 将 `{file-stem}` 映射回文件名:
55
56
  - `task` -> `task.md`
56
57
  - `analysis` / `analysis-r{N}` -> 对应 `.md`
@@ -67,9 +68,9 @@ description: >
67
68
 
68
69
  对每个文件执行:
69
70
  - 收集单条评论或分片评论
70
- - 对 `task.md` 评论按 issue-sync.md 中的 `<details>` frontmatter 格式反向拆解,提取 frontmatter 后再与正文拼合
71
+ - 从 task 评论恢复当前任务投影,再只从通过校验的 artifact 恢复元数据重建活动日志;不得根据缺失记录推测过程状态
71
72
  - 如分片标记中存在 part 和 total 序号,按 part 升序排序并校验分片完整
72
- - 从评论正文中提取文件内容,去掉隐藏标记、标题和页脚
73
+ - 从评论正文中提取文件内容,去掉隐藏标记、标题、恢复元数据和页脚
73
74
  - 拼接得到最终文件内容
74
75
 
75
76
  在写文件前检查:
@@ -82,10 +83,14 @@ description: >
82
83
 
83
84
  创建受控 staging 目录,按以下顺序写回:
84
85
 
85
- 1. `task.md`
86
+ 1. 调用 recovery core 写入 `task.md`:
87
+ ```bash
88
+ agent-infra-internal platform-comment recover --issue {issue-token} --task-id {task-id} \
89
+ --output "{staging-dir}/task.md"
90
+ ```
86
91
  2. 其余产物文件(按文件名排序)
87
92
 
88
- 仅写回从 Issue 评论中实际恢复出的文件,不补造缺失文件。
93
+ 仅写回从 Issue 评论中实际恢复出的文件,不补造缺失文件。recovery core 返回失败时停止,不调用 lifecycle intent。
89
94
 
90
95
  ### 6. 执行 restore 生命周期意图
91
96
 
@@ -83,7 +83,7 @@ Create `.agents/workspace/active/{task-id}/{review-artifact}`.
83
83
 
84
84
  ### 6. Update Task Status
85
85
 
86
- After the report, submit each new finding with `agent-infra-internal task-ledger {task-id} finding-upsert --stage analysis --review-artifact {review-artifact} --ordinal {n} --severity {blocker|major|minor} --evidence {review-artifact}#{anchor}`; submit prior-response dispositions with `finding-review --id {ledger-id} --status {confirmed|closed|open|needs-human-decision} --evidence {evidence}`. Do not scan ids or edit ledger rows. After all ledger writes, make the initial call to `agent-infra-internal task-review {task-id} finalize-summary --stage analysis --artifact {review-artifact} {execution-flag}`; after a failure, follow `.agents/rules/local-artifact-repair.md` to decide whether to edit and rerun, and never treat an error type or `changed=false` as automatic authorization.
86
+ After the report, call `agent-infra-internal task-review {task-id} preflight --stage analysis --artifact {review-artifact} {execution-flag}` before any ledger write. On failure, follow `.agents/rules/local-artifact-repair.md`; on success, bind `{recovery-id}` from the response. Only after preflight passes, submit each new finding with `agent-infra-internal task-ledger {task-id} finding-upsert --stage analysis --review-artifact {review-artifact} --ordinal {n} --severity {blocker|major|minor} --evidence {review-artifact}#{anchor}` or prior-response dispositions with `finding-review --id {ledger-id} --status {confirmed|closed|open|needs-human-decision} --evidence {evidence}`. Do not scan ids or edit ledger rows. After all ledger writes, call `agent-infra-internal task-review {task-id} finalize-summary --stage analysis --artifact {review-artifact} --recovery-id {recovery-id} {execution-flag}`; never treat an error type or `changed=false` as automatic authorization.
87
87
 
88
88
  Bind and reuse this structured mapping from that one response:
89
89
 
@@ -86,7 +86,7 @@ agent-infra-internal task-artifact {task-id} init --family review-analysis --art
86
86
 
87
87
  ### 6. 更新任务状态
88
88
 
89
- 报告完成后,新 finding 逐条调用 `agent-infra-internal task-ledger {task-id} finding-upsert --stage analysis --review-artifact {review-artifact} --ordinal {n} --severity {blocker|major|minor} --evidence {review-artifact}#{anchor}`;复核上一轮响应时调用 `finding-review --id {ledger-id} --status {confirmed|closed|open|needs-human-decision} --evidence {相称证据}`。不得扫描编号或手写账本行。全部账本写入完成后首次调用 `agent-infra-internal task-review {task-id} finalize-summary --stage analysis --artifact {review-artifact} {execution-flag}`;失败后是否继续编辑并重跑,必须遵循 `.agents/rules/local-artifact-repair.md`,不能把失败类型或 `changed=false` 当作自动授权。
89
+ 报告完成后,先调用 `agent-infra-internal task-review {task-id} preflight --stage analysis --artifact {review-artifact} {execution-flag}`,不得先写入账本。失败后是否继续编辑并重跑,必须遵循 `.agents/rules/local-artifact-repair.md`;通过时从返回值绑定 `{recovery-id}`。只有 preflight 通过后,才逐条调用 `agent-infra-internal task-ledger {task-id} finding-upsert --stage analysis --review-artifact {review-artifact} --ordinal {n} --severity {blocker|major|minor} --evidence {review-artifact}#{anchor}`,或复核上一轮响应时调用 `finding-review --id {ledger-id} --status {confirmed|closed|open|needs-human-decision} --evidence {相称证据}`。不得扫描编号或手写账本行。全部账本写入完成后调用 `agent-infra-internal task-review {task-id} finalize-summary --stage analysis --artifact {review-artifact} --recovery-id {recovery-id} {execution-flag}`;不能把失败类型或 `changed=false` 当作自动授权。
90
90
 
91
91
  从该次返回值绑定并复用以下结构化映射:
92
92
 
@@ -27,16 +27,7 @@
27
27
  "expected_action_pattern": "(Review Analysis|Analysis Review) \\(Round \\d+\\)"
28
28
  },
29
29
  "platform-sync": {
30
- "when": "platform_issue_identity_exists",
31
- "expected_status_label": "status: pending-design-work",
32
- "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
33
- "verify_comment_content": true,
34
- "verify_task_comment_content": true,
35
- "verify_issue_type": true,
36
- "verify_issue_fields": false,
37
- "verify_milestone": true,
38
- "expected_status_label_key": "pendingDesignWork",
39
- "expected_comment_marker_key": "artifact"
30
+ "when": "platform_issue_identity_exists"
40
31
  }
41
32
  }
42
33
  }
@@ -27,16 +27,7 @@
27
27
  "expected_action_pattern": "(Review Analysis|Analysis Review) \\(Round \\d+\\)"
28
28
  },
29
29
  "platform-sync": {
30
- "when": "platform_issue_identity_exists",
31
- "expected_status_label": "status: pending-design-work",
32
- "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
33
- "verify_comment_content": true,
34
- "verify_task_comment_content": true,
35
- "verify_issue_type": true,
36
- "verify_issue_fields": false,
37
- "verify_milestone": true,
38
- "expected_status_label_key": "pendingDesignWork",
39
- "expected_comment_marker_key": "artifact"
30
+ "when": "platform_issue_identity_exists"
40
31
  }
41
32
  }
42
33
  }
@@ -4,6 +4,8 @@
4
4
 
5
5
  Use this template when writing `review-analysis.md` or `review-analysis-r{N}.md`.
6
6
 
7
+ > The `Review Input` field provides reader-facing traceability. Lifecycle identity uses the input frozen by `review-analysis.started` and the completion receipt; it is not parsed from this report body.
8
+
7
9
  ## Output Template
8
10
 
9
11
  ```markdown
@@ -4,6 +4,8 @@
4
4
 
5
5
  编写 `review-analysis.md` 或 `review-analysis-r{N}.md` 时使用本模板。
6
6
 
7
+ > “审查输入”字段用于读者追溯。生命周期身份以 `review-analysis.started` 冻结的输入和完成 receipt 为准,不从本报告正文解析。
8
+
7
9
  ## 输出模板
8
10
 
9
11
  ```markdown
@@ -111,8 +111,9 @@ Create `.agents/workspace/active/{task-id}/{review-artifact}`.
111
111
  ### 6. Update Task Status
112
112
 
113
113
  Update task.md:
114
- - After the report, submit each new finding with `agent-infra-internal task-ledger {task-id} finding-upsert --stage code --review-artifact {review-artifact} --ordinal {n} --severity {blocker|major|minor} --evidence {review-artifact}#{anchor}`; submit prior-response dispositions with `finding-review --id {ledger-id} --status {confirmed|closed|open|needs-human-decision} --evidence {evidence}`. When escalating to `needs-human-decision`, append `--needs-implementation true|false` using the judgment recorded in the detail block. Do not scan ids or edit ledger rows
115
- - After all ledger writes, make the initial call to `agent-infra-internal task-review {task-id} finalize-summary --stage code --artifact {review-artifact} {execution-flag}`; after a failure, follow `.agents/rules/local-artifact-repair.md` to decide whether to edit and rerun, and never treat an error type or `changed=false` as automatic authorization
114
+ - After the report, call `agent-infra-internal task-review {task-id} preflight --stage code --artifact {review-artifact} {execution-flag}` before any ledger write. On failure, follow `.agents/rules/local-artifact-repair.md`; on success, bind `{recovery-id}` from the response.
115
+ - Only after preflight passes, submit each new finding with `agent-infra-internal task-ledger {task-id} finding-upsert --stage code --review-artifact {review-artifact} --ordinal {n} --severity {blocker|major|minor} --evidence {review-artifact}#{anchor}`; submit prior-response dispositions with `finding-review --id {ledger-id} --status {confirmed|closed|open|needs-human-decision} --evidence {evidence}`. When escalating to `needs-human-decision`, append `--needs-implementation true|false` using the judgment recorded in the detail block. Do not scan ids or edit ledger rows
116
+ - After all ledger writes, call `agent-infra-internal task-review {task-id} finalize-summary --stage code --artifact {review-artifact} --recovery-id {recovery-id} {execution-flag}`; never treat an error type or `changed=false` as automatic authorization
116
117
 
117
118
  Bind and reuse this structured mapping from that one response:
118
119
 
@@ -109,8 +109,9 @@ agent-infra-internal task-artifact {task-id} init --family review-code --artifac
109
109
 
110
110
  ### 6. 更新任务状态
111
111
 
112
- - 报告完成后,新 finding 逐条调用 `agent-infra-internal task-ledger {task-id} finding-upsert --stage code --review-artifact {review-artifact} --ordinal {n} --severity {blocker|major|minor} --evidence {review-artifact}#{anchor}`;复核上一轮响应时调用 `finding-review --id {ledger-id} --status {confirmed|closed|open|needs-human-decision} --evidence {相称证据}`。升级为 `needs-human-decision` 时,按详情块中的判断追加 `--needs-implementation true|false`。不得扫描编号或手写账本行
113
- - 全部账本写入完成后首次调用 `agent-infra-internal task-review {task-id} finalize-summary --stage code --artifact {review-artifact} {execution-flag}`;失败后是否继续编辑并重跑,必须遵循 `.agents/rules/local-artifact-repair.md`,不能把失败类型或 `changed=false` 当作自动授权
112
+ - 报告完成后,先调用 `agent-infra-internal task-review {task-id} preflight --stage code --artifact {review-artifact} {execution-flag}`,不得先写入账本。失败后是否继续编辑并重跑,必须遵循 `.agents/rules/local-artifact-repair.md`;通过时从返回值绑定 `{recovery-id}`。
113
+ - 只有 preflight 通过后,新 finding 才逐条调用 `agent-infra-internal task-ledger {task-id} finding-upsert --stage code --review-artifact {review-artifact} --ordinal {n} --severity {blocker|major|minor} --evidence {review-artifact}#{anchor}`;复核上一轮响应时调用 `finding-review --id {ledger-id} --status {confirmed|closed|open|needs-human-decision} --evidence {相称证据}`。升级为 `needs-human-decision` 时,按详情块中的判断追加 `--needs-implementation true|false`。不得扫描编号或手写账本行
114
+ - 全部账本写入完成后调用 `agent-infra-internal task-review {task-id} finalize-summary --stage code --artifact {review-artifact} --recovery-id {recovery-id} {execution-flag}`;不能把失败类型或 `changed=false` 当作自动授权
114
115
 
115
116
  从该次返回值绑定并复用以下结构化映射:
116
117
 
@@ -28,16 +28,7 @@
28
28
  "expected_action_pattern": "(Review Code|Code Review) \\(Round \\d+\\)"
29
29
  },
30
30
  "platform-sync": {
31
- "when": "platform_issue_identity_exists",
32
- "expected_status_label": "status: in-progress",
33
- "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
34
- "verify_comment_content": true,
35
- "verify_task_comment_content": true,
36
- "verify_issue_type": true,
37
- "verify_issue_fields": false,
38
- "verify_milestone": true,
39
- "expected_status_label_key": "inProgress",
40
- "expected_comment_marker_key": "artifact"
31
+ "when": "platform_issue_identity_exists"
41
32
  }
42
33
  }
43
34
  }
@@ -28,16 +28,7 @@
28
28
  "expected_action_pattern": "(Review Code|Code Review) \\(Round \\d+\\)"
29
29
  },
30
30
  "platform-sync": {
31
- "when": "platform_issue_identity_exists",
32
- "expected_status_label": "status: in-progress",
33
- "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
34
- "verify_comment_content": true,
35
- "verify_task_comment_content": true,
36
- "verify_issue_type": true,
37
- "verify_issue_fields": false,
38
- "verify_milestone": true,
39
- "expected_status_label_key": "inProgress",
40
- "expected_comment_marker_key": "artifact"
31
+ "when": "platform_issue_identity_exists"
41
32
  }
42
33
  }
43
34
  }
@@ -4,6 +4,8 @@
4
4
 
5
5
  Use this template when writing `review-code.md` or `review-code-r{N}.md`.
6
6
 
7
+ > The `Review Input` field provides reader-facing traceability. Lifecycle identity uses the input frozen by `review-code.started` and the completion receipt; it is not parsed from this report body.
8
+
7
9
  ## Output Template
8
10
 
9
11
  ```markdown
@@ -4,6 +4,8 @@
4
4
 
5
5
  编写 `review-code.md` 或 `review-code-r{N}.md` 时使用本模板。
6
6
 
7
+ > “审查输入”字段用于读者追溯。生命周期身份以 `review-code.started` 冻结的输入和完成 receipt 为准,不从本报告正文解析。
8
+
7
9
  ## 输出模板
8
10
 
9
11
  ```markdown