specdojo 0.3.1 → 0.4.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 (260) hide show
  1. package/.github/agents/specdojo-orchestrator.md +61 -2
  2. package/CHANGELOG.md +90 -0
  3. package/README.md +85 -25
  4. package/dist/{catalog-build-references.js → catalog/build-references.js} +4 -4
  5. package/dist/catalog/build-render.js +32 -0
  6. package/dist/{catalog-build.js → catalog/build.js} +9 -9
  7. package/dist/{catalog.js → catalog/catalog.js} +10 -10
  8. package/dist/{catalog-generate.js → catalog/generate.js} +8 -8
  9. package/dist/catalog/paths.js +1 -0
  10. package/dist/{catalog-plan-generate.js → catalog/plan-generate.js} +4 -4
  11. package/dist/{catalog-plan.js → catalog/plan.js} +4 -4
  12. package/dist/{catalog-scaffold.js → catalog/scaffold.js} +3 -3
  13. package/dist/{agent.js → commands/agent.js} +11 -11
  14. package/dist/{build-command.js → commands/build.js} +2 -2
  15. package/dist/{init-command.js → commands/init.js} +168 -45
  16. package/dist/commands/night-orchestrator.js +287 -0
  17. package/dist/{orchestrator.js → commands/orchestrator.js} +12 -5
  18. package/dist/{watch.js → commands/watch.js} +3 -3
  19. package/dist/{dashboard-timeline.js → dashboard/dashboard-timeline.js} +2 -2
  20. package/dist/{dashboard.js → dashboard/dashboard.js} +11 -10
  21. package/dist/{dashboard-exec-records.js → dashboard/exec-records.js} +2 -2
  22. package/dist/{dashboard-routines.js → dashboard/routines.js} +6 -5
  23. package/dist/{dashboard-shared.js → dashboard/shared.js} +1 -1
  24. package/dist/{timeline-build.js → dashboard/timeline-build.js} +2 -1
  25. package/dist/{timeline.js → dashboard/timeline.js} +1 -1
  26. package/dist/{deliverable.js → deliverable/deliverable.js} +5 -5
  27. package/dist/{deliverable-trash.js → deliverable/trash.js} +5 -5
  28. package/dist/{devcontainer-command.js → devcontainer/command.js} +8 -4
  29. package/dist/devcontainer/scaffold.js +418 -0
  30. package/dist/{doc-index.js → docs/doc-index.js} +1 -1
  31. package/dist/{frontmatter-namespace.js → docs/frontmatter-namespace.js} +1 -1
  32. package/dist/{index-command.js → docs/index-command.js} +1 -1
  33. package/dist/docs/template-resolution.js +1 -0
  34. package/dist/{viewpoint-document-kinds-check.js → docs/viewpoint-document-kinds-check.js} +1 -1
  35. package/dist/{yaml-pages-command.js → docs/yaml-pages-command.js} +1 -1
  36. package/dist/{yaml-pages.js → docs/yaml-pages.js} +2 -2
  37. package/dist/{exec-agent-config.js → exec/agent-config.js} +92 -5
  38. package/dist/{exec-agent-git-state.js → exec/agent-git-state.js} +1 -1
  39. package/dist/{exec-agent-protected-config.js → exec/agent-protected-config.js} +1 -1
  40. package/dist/{exec-commands.js → exec/commands.js} +22 -18
  41. package/dist/{exec-core.js → exec/core.js} +11 -11
  42. package/dist/{exec-events.js → exec/events.js} +2 -2
  43. package/dist/{exec-evidence.js → exec/evidence.js} +11 -6
  44. package/dist/exec/exec.js +2 -0
  45. package/dist/exec/format.js +1 -0
  46. package/dist/{exec-handoff.js → exec/handoff.js} +13 -12
  47. package/dist/{exec-limit.js → exec/limit.js} +93 -12
  48. package/dist/{exec-parent-validation.js → exec/parent-validation.js} +18 -4
  49. package/dist/{exec-pipeline-state.js → exec/pipeline-state.js} +29 -2
  50. package/dist/{exec-plans-core.js → exec/plans-core.js} +68 -114
  51. package/dist/{exec-plans-generation.js → exec/plans-generation.js} +53 -10
  52. package/dist/{exec-plans-storage.js → exec/plans-storage.js} +5 -5
  53. package/dist/{exec-plans.js → exec/plans.js} +3 -3
  54. package/dist/{exec-project.js → exec/project.js} +1 -1
  55. package/dist/{exec-protection-handoff.js → exec/protection-handoff.js} +3 -3
  56. package/dist/{exec-register-resume.js → exec/register-resume.js} +2 -2
  57. package/dist/{exec-register.js → exec/register.js} +114 -9
  58. package/dist/{exec-repo-integration-git.js → exec/repo-integration-git.js} +2 -2
  59. package/dist/{exec-repo-integration-sync.js → exec/repo-integration-sync.js} +4 -4
  60. package/dist/{exec-repo-integration.js → exec/repo-integration.js} +14 -11
  61. package/dist/{exec-repo-trace.js → exec/repo-trace.js} +3 -3
  62. package/dist/{exec-reporter-output.js → exec/reporter-output.js} +2 -2
  63. package/dist/{exec-reporter.js → exec/reporter.js} +142 -25
  64. package/dist/{exec-results.js → exec/results.js} +287 -31
  65. package/dist/{exec-run-agent-pipeline.js → exec/run/agent-pipeline.js} +35 -12
  66. package/dist/{exec-run-agent.js → exec/run/agent.js} +115 -28
  67. package/dist/{exec-run-in-place.js → exec/run/in-place.js} +56 -27
  68. package/dist/{exec-run-job.js → exec/run/job.js} +65 -36
  69. package/dist/{exec-run-lifecycle-commands.js → exec/run/lifecycle-commands.js} +30 -22
  70. package/dist/{exec-run-lock.js → exec/run/lock.js} +4 -3
  71. package/dist/{exec-run-mode-shared.js → exec/run/mode-shared.js} +3 -3
  72. package/dist/{exec-run-register-command.js → exec/run/register-command.js} +38 -11
  73. package/dist/{exec-run-register-core.js → exec/run/register-core.js} +63 -21
  74. package/dist/{exec-run-register-mode.js → exec/run/register-mode.js} +58 -31
  75. package/dist/exec/run/register-post-review.js +420 -0
  76. package/dist/{exec-run-register-resume.js → exec/run/register-resume.js} +48 -27
  77. package/dist/{exec-run-register-state.js → exec/run/register-state.js} +13 -10
  78. package/dist/{exec-run-register-worktree.js → exec/run/register-worktree.js} +119 -24
  79. package/dist/{exec-run.js → exec/run/run.js} +11 -11
  80. package/dist/{exec-run-schedule-mode.js → exec/run/schedule-mode.js} +17 -17
  81. package/dist/{exec-run-schedule-prepare.js → exec/run/schedule-prepare.js} +31 -18
  82. package/dist/{exec-run-schedule-task.js → exec/run/schedule-task.js} +45 -18
  83. package/dist/{exec-run-shared.js → exec/run/shared.js} +78 -30
  84. package/dist/{exec-schedule-calendar.js → exec/schedule/calendar.js} +1 -1
  85. package/dist/{exec-schedule-cpm.js → exec/schedule/cpm.js} +2 -2
  86. package/dist/{exec-schedule-gantt-chart-render.js → exec/schedule/gantt-chart-render.js} +2 -2
  87. package/dist/exec/schedule/gantt-chart.js +2 -0
  88. package/dist/{exec-schedule-hash.js → exec/schedule/hash.js} +2 -2
  89. package/dist/exec/schedule/index.js +1 -0
  90. package/dist/{exec-schedule-initial.js → exec/schedule/initial.js} +2 -2
  91. package/dist/{exec-schedule-progress.js → exec/schedule/progress.js} +2 -2
  92. package/dist/{exec-schedule-ready.js → exec/schedule/ready.js} +2 -2
  93. package/dist/{exec-schedule.js → exec/schedule/schedule.js} +11 -11
  94. package/dist/exec/shared.js +63 -0
  95. package/dist/exec/slot-lock.js +1 -0
  96. package/dist/{exec-strategy.js → exec/strategy.js} +2 -2
  97. package/dist/{exec-task-repos.js → exec/task-repos.js} +104 -17
  98. package/dist/{exec-task-view.js → exec/task-view.js} +4 -4
  99. package/dist/{exec-trial-commands.js → exec/trial-commands.js} +20 -22
  100. package/dist/{exec-trial-core.js → exec/trial-core.js} +6 -6
  101. package/dist/{exec-trial.js → exec/trial.js} +2 -2
  102. package/dist/{exec-worktree-command.js → exec/worktree-command.js} +25 -23
  103. package/dist/{exec-worktree-ops-commit.js → exec/worktree-ops-commit.js} +25 -60
  104. package/dist/{exec-worktree-ops-lifecycle.js → exec/worktree-ops-lifecycle.js} +13 -8
  105. package/dist/{exec-worktree-ops-merge.js → exec/worktree-ops-merge.js} +48 -7
  106. package/dist/{exec-worktree-ops.js → exec/worktree-ops.js} +3 -3
  107. package/dist/exec/worktree.js +305 -0
  108. package/dist/{grade-apply.js → grade/apply.js} +9 -9
  109. package/dist/{grade-command-apply.js → grade/command-apply.js} +7 -7
  110. package/dist/{grade-command-inspect.js → grade/command-inspect.js} +6 -6
  111. package/dist/{grade-command-plan.js → grade/command-plan.js} +5 -5
  112. package/dist/{grade-core.js → grade/core.js} +3 -3
  113. package/dist/grade/grade.js +19 -0
  114. package/dist/{grade-markdown.js → grade/markdown.js} +6 -6
  115. package/dist/{grade-pipeline-state.js → grade/pipeline-state.js} +4 -4
  116. package/dist/{grade-plan.js → grade/plan.js} +5 -5
  117. package/dist/{grade-result.js → grade/result.js} +5 -94
  118. package/dist/{grade-target-discovery.js → grade/target-discovery.js} +7 -7
  119. package/dist/{grade-targets.js → grade/targets.js} +11 -8
  120. package/dist/{job-definition.js → job/definition.js} +25 -6
  121. package/dist/{job.js → job/job.js} +12 -11
  122. package/dist/{kata-command.js → kata/command.js} +3 -3
  123. package/dist/{kata.js → kata/kata.js} +5 -5
  124. package/dist/register/approach.js +134 -0
  125. package/dist/{register-core.js → register/core.js} +26 -8
  126. package/dist/{register-create-commands.js → register/create-commands.js} +171 -8
  127. package/dist/{register-date.js → register/date.js} +1 -1
  128. package/dist/register/derivation.js +163 -0
  129. package/dist/{register-event-merge.js → register/event-merge.js} +44 -3
  130. package/dist/{register-events.js → register/events.js} +13 -3
  131. package/dist/{register-history.js → register/history.js} +7 -6
  132. package/dist/{register-item.js → register/item.js} +32 -5
  133. package/dist/register/lifecycle-lock.js +5 -0
  134. package/dist/{register-maintenance-commands.js → register/maintenance-commands.js} +13 -7
  135. package/dist/{register-migrate-timestamps.js → register/migrate-timestamps.js} +3 -3
  136. package/dist/{register-migration.js → register/migration.js} +5 -4
  137. package/dist/{register.js → register/register.js} +32 -27
  138. package/dist/{register-renumber.js → register/renumber.js} +38 -11
  139. package/dist/{register-transition-commands.js → register/transition-commands.js} +3 -3
  140. package/dist/{register-update.js → register/update.js} +5 -5
  141. package/dist/{register-views.js → register/views.js} +47 -7
  142. package/dist/{review-grade.js → review/grade.js} +2 -2
  143. package/dist/{review-plan.js → review/plan.js} +3 -3
  144. package/dist/{routine-definition.js → routine/definition.js} +2 -2
  145. package/dist/{routine.js → routine/routine.js} +49 -22
  146. package/dist/{schedule-approach.js → schedule/approach.js} +8 -8
  147. package/dist/{schedule-build.js → schedule/build.js} +7 -4
  148. package/dist/{schedule.js → schedule/schedule.js} +6 -6
  149. package/dist/{schedule-strategy-generate-document.js → schedule/strategy-generate-document.js} +2 -2
  150. package/dist/{schedule-strategy-generate-scope.js → schedule/strategy-generate-scope.js} +4 -4
  151. package/dist/{schedule-strategy-generate.js → schedule/strategy-generate.js} +10 -10
  152. package/dist/shared/agent-types.js +23 -0
  153. package/dist/shared/artifact-path.js +9 -0
  154. package/dist/{build-if-stale.js → shared/build-if-stale.js} +1 -1
  155. package/dist/{catalog-build-render.js → shared/catalog-render.js} +3 -32
  156. package/dist/{exec-slot-lock.js → shared/cross-process-lock.js} +3 -1
  157. package/dist/shared/fs.js +30 -0
  158. package/dist/shared/git.js +346 -0
  159. package/dist/shared/grade-result.js +94 -0
  160. package/dist/{package-paths.js → shared/package-paths.js} +3 -3
  161. package/dist/shared/plan-templates.js +114 -0
  162. package/dist/{exec-provider-scaffold.js → shared/provider-scaffold.js} +6 -3
  163. package/dist/shared/random.js +4 -0
  164. package/dist/{exec-schedule-index.js → shared/schedule-index.js} +3 -1
  165. package/dist/shared/schedule-paths.js +9 -0
  166. package/dist/{specdojo-config.js → shared/specdojo-config.js} +162 -21
  167. package/dist/{exec-shared.js → shared/text.js} +4 -135
  168. package/dist/shared/time.js +28 -0
  169. package/dist/shared/workspace-scaffold.js +69 -0
  170. package/dist/specdojo.js +22 -22
  171. package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +31 -18
  172. package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +1 -2
  173. package/docs/ja/specdojo/exec-templates/xep-register-template.md +3 -2
  174. package/docs/ja/specdojo/exec-templates/xer-template.md +1 -3
  175. package/docs/ja/specdojo/exec-templates/xrp-job-template.md +6 -4
  176. package/docs/ja/specdojo/exec-templates/xrp-register-post-run-template.md +46 -0
  177. package/docs/ja/specdojo/guides/branch-workflow-guide.md +34 -1
  178. package/docs/ja/specdojo/guides/docs-structure-guide.md +2 -0
  179. package/docs/ja/specdojo/guides/exec-config-guide.md +169 -26
  180. package/docs/ja/specdojo/guides/exec-operation-guide.md +184 -13
  181. package/docs/ja/specdojo/guides/exec-worktree-guide.md +2 -0
  182. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +40 -3
  183. package/docs/ja/specdojo/guides/quick-start-guide.md +89 -21
  184. package/docs/ja/specdojo/guides/register-operation-guide.md +44 -1
  185. package/docs/ja/specdojo/guides/remote-host-development-guide.md +61 -6
  186. package/docs/ja/specdojo/guides/review-guide.md +1 -1
  187. package/docs/ja/specdojo/guides/routine-operation-guide.md +5 -5
  188. package/docs/ja/specdojo/guides/specdojo-overview-guide.md +1 -1
  189. package/docs/ja/specdojo/guides/use-case-guide.md +1 -1
  190. package/docs/ja/specdojo/guides/waza-guide.md +1 -1
  191. package/docs/ja/specdojo/references/command-reference.md +124 -55
  192. package/docs/ja/specdojo/references/specdojo-config-reference.md +33 -7
  193. package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +22 -13
  194. package/docs/ja/specdojo/standards/job-definition-standard.md +20 -18
  195. package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +2 -2
  196. package/docs/ja/specdojo/templates/pjr-derived-items-template.md +22 -0
  197. package/docs/ja/specdojo/templates/pjr-index-template.md +1 -0
  198. package/docs/specdojo/schemas/v1/agent-members.schema.yaml +29 -2
  199. package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +111 -17
  200. package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +28 -0
  201. package/docs/specdojo/schemas/v1/job-run.schema.yaml +2 -2
  202. package/docs/specdojo/schemas/v1/job.schema.yaml +7 -0
  203. package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +38 -0
  204. package/docs/specdojo/schemas/v1/register-events.schema.yaml +5 -0
  205. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +91 -7
  206. package/docs/specdojo/schemas/v1/routine-run.schema.yaml +1 -1
  207. package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +36 -1
  208. package/package.json +17 -17
  209. package/templates/antigravity/README.md +6 -2
  210. package/templates/antigravity/agent-members-snippet.yaml +108 -12
  211. package/templates/antigravity/exec-defaults-snippet.yaml +8 -13
  212. package/templates/antigravity/orchestrator.md +61 -2
  213. package/templates/claude/README.md +27 -3
  214. package/templates/claude/agents/claude-executor.md +0 -1
  215. package/templates/claude/agents/claude-reporter.md +2 -1
  216. package/templates/claude/agents/claude-review-executor.md +0 -1
  217. package/templates/claude/agents/specdojo-orchestrator.md +61 -2
  218. package/templates/codex/README.md +40 -4
  219. package/templates/codex/agents/specdojo-orchestrator.toml +61 -2
  220. package/templates/codex/orchestrator.md +61 -2
  221. package/templates/devcontainer/devcontainer.json +5 -2
  222. package/templates/devcontainer/post-create.sh +15 -7
  223. package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +102 -0
  224. package/templates/devcontainer/remote-host/ssh-config.sample +19 -0
  225. package/templates/devcontainer/vim/vimrc +37 -0
  226. package/templates/init-agent-members.yaml +75 -25
  227. package/templates/init-exec-defaults.yaml +44 -9
  228. package/templates/opencode/README.md +17 -3
  229. package/templates/opencode/agents/opencode-executor.md +0 -1
  230. package/templates/opencode/agents/opencode-reporter.md +2 -1
  231. package/templates/opencode/agents/opencode-review-executor.md +0 -1
  232. package/templates/opencode/agents/specdojo-orchestrator.md +61 -2
  233. package/dist/devcontainer-scaffold.js +0 -165
  234. package/dist/exec-schedule-gantt-chart.js +0 -2
  235. package/dist/exec-worktree.js +0 -474
  236. package/dist/exec.js +0 -2
  237. package/dist/grade.js +0 -19
  238. package/templates/claude/agents/claude-expert-review-executor.md +0 -14
  239. /package/dist/{catalog-plan-prompt.js → catalog/plan-prompt.js} +0 -0
  240. /package/dist/{catalog-types.js → catalog/types.js} +0 -0
  241. /package/dist/{template-frontmatter.js → docs/template-frontmatter.js} +0 -0
  242. /package/dist/{role-types.js → exec/role-types.js} +0 -0
  243. /package/dist/{exec-schedule-gantt-chart-scope.js → exec/schedule/gantt-chart-scope.js} +0 -0
  244. /package/dist/{exec-types.js → exec/types.js} +0 -0
  245. /package/dist/{grade-command-shared.js → grade/command-shared.js} +0 -0
  246. /package/dist/{register-command-types.js → register/command-types.js} +0 -0
  247. /package/dist/{review-types.js → review/types.js} +0 -0
  248. /package/dist/{schedule-phase-sets.js → schedule/phase-sets.js} +0 -0
  249. /package/dist/{schedule-strategy-profiles.js → schedule/strategy-profiles.js} +0 -0
  250. /package/dist/{agent-response.js → shared/agent-response.js} +0 -0
  251. /package/dist/{catalog-paths.js → shared/catalog-paths.js} +0 -0
  252. /package/dist/{dist-freshness.js → shared/dist-freshness.js} +0 -0
  253. /package/dist/{git-environment.js → shared/git-environment.js} +0 -0
  254. /package/dist/{exec-format.js → shared/markdown-format.js} +0 -0
  255. /package/dist/{practice-id.js → shared/practice-id.js} +0 -0
  256. /package/dist/{spawn-self.js → shared/spawn-self.js} +0 -0
  257. /package/dist/{specdojo-gitignore.js → shared/specdojo-gitignore.js} +0 -0
  258. /package/dist/{template-resolution.js → shared/template-resolution.js} +0 -0
  259. /package/dist/{yaml-schema-modeline.js → shared/yaml-schema-modeline.js} +0 -0
  260. /package/dist/{yaml.js → shared/yaml.js} +0 -0
@@ -1,13 +1,15 @@
1
- import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
2
- import { join } from "node:path";
1
+ import { execFileSync } from "node:child_process";
2
+ import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
3
+ import { dirname, join, resolve, sep } from "node:path";
3
4
  import { isDeepStrictEqual } from "node:util";
4
- import { buildSpecdojoFrontmatter, parseSpecdojoDocument } from "./frontmatter-namespace.js";
5
- import { expandTemplate, stripTerminalControlSequences } from "./exec-shared.js";
6
- import { formatMarkdownFile } from "./exec-format.js";
7
- import { deriveReporterFacts, mechanicallyNotApplicableReason, runnerOwnedValidationReason, } from "./exec-reporter.js";
8
- import { resolveSpecdojoPath, resolveSpecdojoPathIfExists } from "./template-resolution.js";
9
- import { dump } from "./yaml.js";
10
- const MISSING_CHANGED_FILE_SUMMARY = "reporter の説明がないため、変更差分を参照。";
5
+ import { buildSpecdojoFrontmatter, parseSpecdojoDocument } from "../docs/frontmatter-namespace.js";
6
+ import { escapeMarkdownInline, expandTemplate, stripTerminalControlSequences } from "./shared.js";
7
+ import { formatMarkdownFile } from "./format.js";
8
+ import { deriveReporterFacts, mechanicallyNotApplicableReason, runnerOwnedValidationReason, } from "./reporter.js";
9
+ import { resolveSpecdojoPath, resolveSpecdojoPathIfExists } from "../docs/template-resolution.js";
10
+ import { dump } from "../shared/yaml.js";
11
+ import { gitEnvironment } from "../shared/git-environment.js";
12
+ export const MAX_INDIVIDUAL_CHANGED_FILES = 50;
11
13
  // ---------------------------------------------------------------------------
12
14
  // Frontmatter helpers
13
15
  // ---------------------------------------------------------------------------
@@ -155,6 +157,16 @@ async function supersedePriorResults(resultsDir, taskId, nextResultPath, superse
155
157
  }
156
158
  return supersededPaths;
157
159
  }
160
+ const APPROACH_SECTION_WITH_APPROACH = [
161
+ "## 4. 進め方と実践の型の適用",
162
+ "",
163
+ "_TODO_: `approach` に従ってどう進めたか、その進め方の中で実践の型(rulebook / recipe / sample / template)をどう適用したかを記入する(`fully-guided` で rulebook / recipe / sample / template をどう使い分けたか、`recipe-guided` で recipe のみを基準にした内容、`freeform` で実践の型より優先した実例やプロジェクト文脈、`retrofit` で実際に参照した実装パス・抽出した現在動作・反映/新設判断・未反映の乖離・未確認範囲、`rulebook-maintenance` などの maintenance 系で見直した実践の型とその根拠、など)。実践の型を基準にしなかった場合は、その判断と代わりに根拠にした内容も記入する。複数文書間に矛盾があり rulebook を正として判断した箇所、参照範囲から外れていた文書とその代わりに根拠にした内容があれば、あわせて記録する。",
164
+ ].join("\n");
165
+ const APPROACH_SECTION_WITHOUT_APPROACH = [
166
+ "## 4. 進め方",
167
+ "",
168
+ "_TODO_: どう進めたか、根拠にした文書や規約を記入する。",
169
+ ].join("\n");
158
170
  export async function scaffoldResult(opts) {
159
171
  const { executionPath, taskId, mode, projectId, planRef, agent, startedAt, approach } = opts;
160
172
  const stem = opts.stem ?? taskId;
@@ -184,7 +196,12 @@ export async function scaffoldResult(opts) {
184
196
  ...(approach ? { approach } : {}),
185
197
  ...(opts.targets && opts.targets.length > 0 ? { targets: opts.targets } : {}),
186
198
  };
187
- const values = { _FRONTMATTER_: serializeFrontmatter(meta) };
199
+ const values = {
200
+ _FRONTMATTER_: serializeFrontmatter(meta),
201
+ _APPROACH_SECTION_: approach
202
+ ? APPROACH_SECTION_WITH_APPROACH
203
+ : APPROACH_SECTION_WITHOUT_APPROACH,
204
+ };
188
205
  // Finalize results pre-expand the confirmation record (done_criteria checklist and
189
206
  // ready-promotion targets) so every finalize is verified against the same items.
190
207
  // When the caller cannot resolve them, leave _TODO_ markers for manual fill-in.
@@ -192,7 +209,10 @@ export async function scaffoldResult(opts) {
192
209
  values._DONE_CRITERIA_CHECKLIST_ = opts.finalizeSections?.doneCriteriaChecklist ?? "_TODO_";
193
210
  values._FINALIZE_TARGETS_CHECKLIST_ = opts.finalizeSections?.targetsChecklist ?? "_TODO_";
194
211
  }
195
- const content = expandTemplate(template, values);
212
+ let content = expandTemplate(template, values);
213
+ if (!approach && content.includes("## 4. 進め方と実践の型の適用")) {
214
+ content = content.replace(APPROACH_SECTION_WITH_APPROACH, APPROACH_SECTION_WITHOUT_APPROACH);
215
+ }
196
216
  writeFileSync(resultPath, content, "utf8");
197
217
  await formatMarkdownFile(resultPath);
198
218
  const supersededPaths = await supersedePriorResults(resultsDir, taskId, resultPath, startedAt);
@@ -305,13 +325,154 @@ function reporterInlineText(value) {
305
325
  .replace(/>/g, ">")
306
326
  .trim();
307
327
  }
328
+ // reporter / executor 由来の自由記述は result の Markdown 本文へ直接入る。改行や山括弧を
329
+ // 正規化したうえで、強調と解釈される `_` / `*` 入りの ASCII トークンを code span にする。
330
+ // escapeMarkdownInline は既存の code span を保持するため、agent が意図して付けた書式は二重化しない。
331
+ function reporterFreeText(value) {
332
+ return escapeMarkdownInline(reporterInlineText(value));
333
+ }
334
+ // reporter や runner の文を `- ` の箇条書きに描くとき、文が自前のリスト記号(`1.`・`1)`・
335
+ // `-`・`*`・`+`)で始まると `- 1. ...` が入れ子のリストとして解釈され、markdownlint の
336
+ // MD029 などに当たって pre-commit hook で記帳の commit が失敗する。箇条書きの記号は runner が
337
+ // 付けるため、先頭の記号は外す(番号の意味は箇条書きの順序で保たれる)。
338
+ export function stripLeadingListMarker(text) {
339
+ let current = text.trim();
340
+ for (;;) {
341
+ const next = current.replace(/^(?:\d{1,9}[.)]|[-*+])(?:\s+|$)/u, "").trim();
342
+ if (next === current)
343
+ return current;
344
+ current = next;
345
+ }
346
+ }
308
347
  function reporterBulletList(values, empty) {
309
348
  if (values.length === 0)
310
349
  return `- ${empty}`;
311
- return values.map((value) => `- ${reporterInlineText(value)}`).join("\n");
350
+ return values
351
+ .map((value) => reporterFreeText(stripLeadingListMarker(reporterInlineText(value))))
352
+ .map((text) => `- ${text || empty}`)
353
+ .join("\n");
354
+ }
355
+ function findGitRoot(startDir) {
356
+ try {
357
+ let current = resolve(startDir);
358
+ while (true) {
359
+ if (existsSync(join(current, ".git"))) {
360
+ return current;
361
+ }
362
+ const parent = dirname(current);
363
+ if (parent === current)
364
+ return null;
365
+ current = parent;
366
+ }
367
+ }
368
+ catch {
369
+ return null;
370
+ }
371
+ }
372
+ function collectGitLineStats(worktreeDir, files) {
373
+ const stats = new Map();
374
+ try {
375
+ const raw = execFileSync("git", ["diff", "--numstat", "-z", "HEAD", "--"], {
376
+ cwd: worktreeDir,
377
+ env: gitEnvironment(),
378
+ encoding: "utf8",
379
+ stdio: ["ignore", "pipe", "ignore"],
380
+ });
381
+ const parts = raw.split("\0");
382
+ for (let i = 0; i < parts.length; i++) {
383
+ const part = parts[i];
384
+ if (!part)
385
+ continue;
386
+ const match = part.match(/^(\d+|-)\t(\d+|-)\t(.*)$/);
387
+ if (match) {
388
+ const adds = match[1] === "-" ? 0 : parseInt(match[1], 10);
389
+ const dels = match[2] === "-" ? 0 : parseInt(match[2], 10);
390
+ let p = match[3];
391
+ if (!p && i + 2 < parts.length) {
392
+ const oldPath = parts[++i];
393
+ const newPath = parts[++i];
394
+ p = newPath;
395
+ stats.set(newPath, { additions: adds, deletions: dels });
396
+ stats.set(`${oldPath} -> ${newPath}`, { additions: adds, deletions: dels });
397
+ continue;
398
+ }
399
+ stats.set(p, { additions: adds, deletions: dels });
400
+ }
401
+ }
402
+ }
403
+ catch {
404
+ // git diff failed or worktree is not a git repository
405
+ }
406
+ for (const file of files) {
407
+ const targetPath = file.path.includes(" -> ") ? file.path.split(" -> ")[1] : file.path;
408
+ if (!stats.has(targetPath) && !stats.has(file.path)) {
409
+ if (file.status === "??" || file.status.includes("A")) {
410
+ try {
411
+ const fullPath = join(worktreeDir, targetPath);
412
+ if (existsSync(fullPath)) {
413
+ const stat = statSync(fullPath);
414
+ if (stat.isFile()) {
415
+ const fileContent = readFileSync(fullPath, "utf8");
416
+ const lines = fileContent.length === 0 ? 0 : fileContent.split("\n").length;
417
+ const entry = { additions: lines, deletions: 0 };
418
+ stats.set(targetPath, entry);
419
+ if (file.path !== targetPath) {
420
+ stats.set(file.path, entry);
421
+ }
422
+ }
423
+ }
424
+ }
425
+ catch {
426
+ // ignore unreadable files
427
+ }
428
+ }
429
+ }
430
+ }
431
+ return stats;
432
+ }
433
+ function formatMissingSummary(file, stats) {
434
+ const isRename = file.status.includes("R") || file.path.includes(" -> ");
435
+ const isAdd = file.status === "??" || file.status.includes("A");
436
+ const isDelete = file.status.includes("D");
437
+ let action;
438
+ if (isRename) {
439
+ const oldPath = file.path.includes(" -> ") ? file.path.split(" -> ")[0] : undefined;
440
+ action = oldPath ? `名前の変更(${reporterInlineText(oldPath)} から)` : "名前の変更";
441
+ }
442
+ else if (isAdd) {
443
+ action = "追加";
444
+ }
445
+ else if (isDelete) {
446
+ action = "削除";
447
+ }
448
+ else {
449
+ action = "変更";
450
+ }
451
+ if (stats !== undefined) {
452
+ return `${action}、+${stats.additions} / -${stats.deletions} 行`;
453
+ }
454
+ return action;
312
455
  }
313
- function renderEditReporterBody(output, evidence) {
456
+ function getFileDirectory(filePath) {
457
+ let cleanPath = filePath;
458
+ let repoPrefix = "";
459
+ if (filePath.includes(":")) {
460
+ const colonIdx = filePath.indexOf(":");
461
+ repoPrefix = filePath.slice(0, colonIdx + 1);
462
+ cleanPath = filePath.slice(colonIdx + 1);
463
+ }
464
+ const dir = dirname(cleanPath).split(sep).join("/");
465
+ if (dir === "." || dir === "") {
466
+ return repoPrefix ? `${repoPrefix}./` : "./";
467
+ }
468
+ return repoPrefix ? `${repoPrefix}${dir}/` : `${dir}/`;
469
+ }
470
+ export function renderEditReporterBody(output, evidence, options) {
314
471
  const facts = deriveReporterFacts(evidence);
472
+ const lineStats = options?.lineStats ??
473
+ (options?.worktreeDir
474
+ ? collectGitLineStats(options.worktreeDir, facts.changed_files)
475
+ : undefined);
315
476
  const summariesByPath = new Map();
316
477
  for (const file of output.changed_files) {
317
478
  // The evidence path list remains authoritative. Ignore invented paths and keep the first
@@ -319,29 +480,108 @@ function renderEditReporterBody(output, evidence) {
319
480
  if (!summariesByPath.has(file.path))
320
481
  summariesByPath.set(file.path, file.summary);
321
482
  }
322
- const changedFiles = facts.changed_files.length === 0
323
- ? "- なし"
324
- : facts.changed_files
325
- .map((file) => `- \`${reporterInlineText(file.path).replace(/`/g, "'")}\`: ${reporterInlineText(summariesByPath.get(file.path) ?? MISSING_CHANGED_FILE_SUMMARY)}`)
483
+ const maxIndividual = options?.maxIndividualChangedFiles ?? MAX_INDIVIDUAL_CHANGED_FILES;
484
+ let changedFiles;
485
+ if (facts.changed_files.length === 0) {
486
+ changedFiles = "- なし";
487
+ }
488
+ else if (facts.changed_files.length <= maxIndividual) {
489
+ changedFiles = facts.changed_files
490
+ .map((file) => {
491
+ const displayPath = file.path.includes(" -> ") ? file.path.split(" -> ")[1] : file.path;
492
+ const reporterSummary = summariesByPath.get(displayPath) ?? summariesByPath.get(file.path);
493
+ const summary = reporterSummary !== undefined && reporterSummary.trim().length > 0
494
+ ? reporterSummary
495
+ : formatMissingSummary(file, lineStats?.get(displayPath) ?? lineStats?.get(file.path));
496
+ return `- \`${reporterInlineText(displayPath).replace(/`/g, "'")}\`: ${reporterFreeText(summary)}`;
497
+ })
326
498
  .join("\n");
499
+ }
500
+ else {
501
+ // Over threshold: list described files individually, and group undescribed files by directory.
502
+ const describedFiles = [];
503
+ const undescribedFiles = [];
504
+ const describedCountByDir = new Map();
505
+ for (const file of facts.changed_files) {
506
+ const displayPath = file.path.includes(" -> ") ? file.path.split(" -> ")[1] : file.path;
507
+ const reporterSummary = summariesByPath.get(displayPath) ?? summariesByPath.get(file.path);
508
+ if (reporterSummary !== undefined && reporterSummary.trim().length > 0) {
509
+ describedFiles.push({ displayPath, summary: reporterSummary });
510
+ const dir = getFileDirectory(displayPath);
511
+ describedCountByDir.set(dir, (describedCountByDir.get(dir) ?? 0) + 1);
512
+ }
513
+ else {
514
+ undescribedFiles.push({ displayPath, file });
515
+ }
516
+ }
517
+ const lines = [];
518
+ for (const entry of describedFiles) {
519
+ lines.push(`- \`${reporterInlineText(entry.displayPath).replace(/`/g, "'")}\`: ${reporterFreeText(entry.summary)}`);
520
+ }
521
+ const dirGroups = new Map();
522
+ for (const entry of undescribedFiles) {
523
+ const dir = getFileDirectory(entry.displayPath);
524
+ let group = dirGroups.get(dir);
525
+ if (!group) {
526
+ group = {
527
+ count: 0,
528
+ operations: new Map(),
529
+ additions: 0,
530
+ deletions: 0,
531
+ hasLineStats: false,
532
+ };
533
+ dirGroups.set(dir, group);
534
+ }
535
+ group.count++;
536
+ const isRename = entry.file.status.includes("R") || entry.file.path.includes(" -> ");
537
+ const isAdd = entry.file.status === "??" || entry.file.status.includes("A");
538
+ const isDelete = entry.file.status.includes("D");
539
+ const op = isRename ? "名前の変更" : isAdd ? "追加" : isDelete ? "削除" : "変更";
540
+ group.operations.set(op, (group.operations.get(op) ?? 0) + 1);
541
+ const stats = lineStats?.get(entry.displayPath) ?? lineStats?.get(entry.file.path);
542
+ if (stats !== undefined) {
543
+ group.additions += stats.additions;
544
+ group.deletions += stats.deletions;
545
+ group.hasLineStats = true;
546
+ }
547
+ }
548
+ const sortedDirs = [...dirGroups.keys()].sort((a, b) => a.localeCompare(b));
549
+ const operationOrder = ["変更", "追加", "削除", "名前の変更"];
550
+ for (const dir of sortedDirs) {
551
+ const group = dirGroups.get(dir);
552
+ const describedInDir = describedCountByDir.get(dir) ?? 0;
553
+ const countText = describedInDir > 0 ? `ほか ${group.count} 件` : `${group.count} 件`;
554
+ const sortedOps = [...group.operations.keys()].sort((a, b) => {
555
+ const idxA = operationOrder.indexOf(a);
556
+ const idxB = operationOrder.indexOf(b);
557
+ return (idxA === -1 ? 999 : idxA) - (idxB === -1 ? 999 : idxB);
558
+ });
559
+ const opParts = sortedOps.map((op) => `${op} ${group.operations.get(op)} 件`);
560
+ const lineStatsPart = group.hasLineStats
561
+ ? `、+${group.additions} / -${group.deletions} 行`
562
+ : "";
563
+ lines.push(`- \`${reporterInlineText(dir)}\`: ${countText}(${opParts.join("、")}${lineStatsPart})`);
564
+ }
565
+ changedFiles = lines.length === 0 ? "- なし" : lines.join("\n");
566
+ }
327
567
  const unchangedTargetNotes = (evidence?.target_coverage ?? [])
328
568
  .filter((entry) => entry.status === "unchanged")
329
569
  .map((entry) => {
330
570
  const target = reporterInlineText(entry.target).replace(/`/g, "'");
331
- return `対象 \`${target}\` は未変更: ${reporterInlineText(entry.reason)}`;
571
+ return `対象 \`${target}\` は未変更: ${reporterFreeText(entry.reason)}`;
332
572
  });
333
573
  const humanValidationNotes = evidence.validations
334
574
  .filter((validation) => validation.source !== "runner" && validation.status === "requires_human")
335
575
  .map((validation) => {
336
576
  const command = reporterInlineText(validation.command).replace(/`/g, "'");
337
- const summary = reporterInlineText(validation.summary) || "要約なし";
577
+ const summary = reporterFreeText(validation.summary) || "要約なし";
338
578
  return `人の確認が必要: \`${command}\`(${summary})`;
339
579
  });
340
580
  const notApplicableValidationNotes = evidence.validations
341
581
  .filter((validation) => validation.source !== "runner" && validation.status === "not_applicable")
342
582
  .map((validation) => {
343
583
  const command = reporterInlineText(validation.command).replace(/`/g, "'");
344
- const reason = reporterInlineText(validation.reason ?? "") || "理由なし";
584
+ const reason = reporterFreeText(validation.reason ?? "") || "理由なし";
345
585
  return `適用外の検証: \`${command}\`(${reason})`;
346
586
  });
347
587
  const changedPaths = evidence.changes.map((change) => change.path);
@@ -352,7 +592,7 @@ function renderEditReporterBody(output, evidence) {
352
592
  if (reason === undefined)
353
593
  return [];
354
594
  const command = reporterInlineText(validation.command).replace(/`/g, "'");
355
- return [`runner が担う検証: \`${command}\`(${reporterInlineText(reason)})`];
595
+ return [`runner が担う検証: \`${command}\`(${reporterFreeText(reason)})`];
356
596
  });
357
597
  const runnerJudgedNotApplicableNotes = evidence.validations
358
598
  .filter((validation) => validation.source !== "runner" && validation.status === "not_run")
@@ -361,8 +601,11 @@ function renderEditReporterBody(output, evidence) {
361
601
  if (reason === undefined)
362
602
  return [];
363
603
  const command = reporterInlineText(validation.command).replace(/`/g, "'");
364
- return [`適用外の検証(runner の判定): \`${command}\`(${reporterInlineText(reason)})`];
604
+ return [`適用外の検証(runner の判定): \`${command}\`(${reporterFreeText(reason)})`];
365
605
  });
606
+ const rateLimitRecoveryNotes = (evidence.rate_limit_events ?? []).map((event) => event.action === "wait"
607
+ ? `rate limit 後に ${event.resume_at ?? "再開可能時刻"} まで待ち、${event.to_actor} で ${event.resumed_at} に再開`
608
+ : `${event.trigger === "connection_error" ? "接続エラー" : "rate limit"}後に ${event.from_actor} から ${event.to_actor} へ切り替え、${event.resumed_at} に再開`);
366
609
  return [
367
610
  "# Edit Result",
368
611
  "",
@@ -383,26 +626,30 @@ function renderEditReporterBody(output, evidence) {
383
626
  ...runnerOwnedValidationNotes,
384
627
  ...runnerJudgedNotApplicableNotes,
385
628
  ...humanValidationNotes,
629
+ ...rateLimitRecoveryNotes,
386
630
  ], "なし"),
387
631
  "",
388
- "## 4. 進め方と実践の型の適用",
632
+ options?.approach ? "## 4. 進め方と実践の型の適用" : "## 4. 進め方",
389
633
  "",
390
- reporterInlineText(output.approach),
634
+ reporterFreeText(output.approach),
391
635
  ].join("\n");
392
636
  }
393
637
  // review result の章立ては xrr-template.md と一致させる。review は成果物を再評価しないため、
394
638
  // 観点別の結果ではなく評価結果の確認・判断根拠・改善指示・verdict を記録する。
395
- function renderReviewReporterBody(output) {
639
+ function renderReviewReporterBody(output, evidence) {
640
+ const rateLimitRecoveryNotes = (evidence.rate_limit_events ?? []).map((event) => event.action === "wait"
641
+ ? `rate limit 後に ${event.resume_at ?? "再開可能時刻"} まで待ち、${event.to_actor} で ${event.resumed_at} に再開`
642
+ : `${event.trigger === "connection_error" ? "接続エラー" : "rate limit"}後に ${event.from_actor} から ${event.to_actor} へ切り替え、${event.resumed_at} に再開`);
396
643
  return [
397
644
  "# Review Result",
398
645
  "",
399
646
  "## 1. 評価結果の確認",
400
647
  "",
401
- reporterInlineText(output.grade_check),
648
+ reporterFreeText(output.grade_check),
402
649
  "",
403
650
  "## 2. 判断根拠",
404
651
  "",
405
- reporterBulletList(output.rationale, "なし"),
652
+ reporterBulletList([...output.rationale, ...rateLimitRecoveryNotes], "なし"),
406
653
  "",
407
654
  "## 3. 未充足事項・改善指示",
408
655
  "",
@@ -410,7 +657,7 @@ function renderReviewReporterBody(output) {
410
657
  "",
411
658
  "## 4. approach に応じた確認",
412
659
  "",
413
- reporterInlineText(output.approach),
660
+ reporterFreeText(output.approach),
414
661
  "",
415
662
  "## 5. decision",
416
663
  "",
@@ -421,7 +668,7 @@ function renderReviewReporterBody(output) {
421
668
  * Replaces only the result body from schema-validated reporter data. The scaffolded frontmatter
422
669
  * remains byte-for-byte runner-owned until the lifecycle status update serializes it.
423
670
  */
424
- export async function renderReporterResult(resultPath, output, evidence) {
671
+ export async function renderReporterResult(resultPath, output, evidence, options) {
425
672
  if (!existsSync(resultPath))
426
673
  throw new Error(`Result not found: ${resultPath}`);
427
674
  const content = readFileSync(resultPath, "utf8");
@@ -432,9 +679,18 @@ export async function renderReporterResult(resultPath, output, evidence) {
432
679
  const frontmatter = content.match(/^---\r?\n[\s\S]*?\r?\n---/)?.[0];
433
680
  if (!frontmatter)
434
681
  throw new Error(`Result frontmatter not found: ${resultPath}`);
682
+ const approach = options?.approach ??
683
+ (typeof parsed.data.approach === "string" && parsed.data.approach.trim().length > 0
684
+ ? parsed.data.approach
685
+ : undefined);
686
+ const resolvedOptions = {
687
+ ...options,
688
+ ...(approach ? { approach } : {}),
689
+ worktreeDir: options?.worktreeDir ?? findGitRoot(dirname(resultPath)) ?? undefined,
690
+ };
435
691
  const body = output.mode === "edit"
436
- ? renderEditReporterBody(output, evidence)
437
- : renderReviewReporterBody(output);
692
+ ? renderEditReporterBody(output, evidence, resolvedOptions)
693
+ : renderReviewReporterBody(output, evidence);
438
694
  writeFileSync(resultPath, frontmatterWithBody(frontmatter, body), "utf8");
439
695
  await formatMarkdownFile(resultPath);
440
696
  }
@@ -1,13 +1,13 @@
1
1
  import { relative, sep } from "node:path";
2
- import { recordExecutorEvidence, recordParentValidationFailureOutput, recordReporterFailureOutput, snapshotWorktreeChanges, writeExecutorEvidence, } from "./exec-evidence.js";
3
- import { failedParentValidationReason, hasRecordedParentValidations, parentValidationRoots, replaceParentValidationResults, } from "./exec-parent-validation.js";
4
- import { createPipelineState, pipelineStateLocation, updatePipelineStage, writePipelineState, } from "./exec-pipeline-state.js";
5
- import { deriveReporterFacts, evidenceForReporter, runReporterWithFormatRetry, } from "./exec-reporter.js";
6
- import { renderReporterResult } from "./exec-results.js";
7
- import { randomHex } from "./exec-shared.js";
8
- import { withProductRepoPrompt } from "./exec-task-repos.js";
9
- import { worktreeStatusPaths } from "./exec-worktree-ops.js";
10
- import { agentEnvironment, appendParentValidationsToExecutorEvidence, buildExecutorPrompt, extractBlockReason, resumedTargetCoverageFailure, runConfiguredParentValidationBatch, runWithRetry, } from "./exec-run-agent.js";
2
+ import { recordExecutorEvidence, recordParentValidationFailureOutput, recordReporterFailureOutput, snapshotWorktreeChanges, writeExecutorEvidence, } from "../evidence.js";
3
+ import { failedParentValidationReason, hasRecordedParentValidations, parentValidationRoots, replaceParentValidationResults, } from "../parent-validation.js";
4
+ import { createPipelineState, pipelineStateLocation, updatePipelineStage, writePipelineState, } from "../pipeline-state.js";
5
+ import { deriveReporterFacts, evidenceForReporter, runReporterWithFormatRetry, } from "../reporter.js";
6
+ import { renderReporterResult } from "../results.js";
7
+ import { randomHex } from "../shared.js";
8
+ import { withProductRepoPrompt } from "../task-repos.js";
9
+ import { worktreeStatusPaths } from "../worktree-ops.js";
10
+ import { agentEnvironment, appendParentValidationsToExecutorEvidence, buildExecutorPrompt, extractBlockReason, resumedTargetCoverageFailure, runConfiguredParentValidationBatch, runWithRetry, } from "./agent.js";
11
11
  export async function refreshParentValidationsForReporterResume(params) {
12
12
  const configuredEntries = params.execDefaults.pipeline?.parent_validations;
13
13
  const force = params.force === true && (configuredEntries?.length ?? 0) > 0;
@@ -56,13 +56,17 @@ export async function runReporterStage(params) {
56
56
  writePipelineState(params.statePath, state);
57
57
  process.stdout.write(` Running reporter: ${reporterCandidates[0]?.command ?? ""}\n`);
58
58
  let reporterAttempts = 0;
59
+ let reporterActor = reporterCandidates[0]?.actor;
60
+ const rateLimitEvents = [];
59
61
  const runReporter = () => runReporterWithFormatRetry({
60
62
  plan: params.planPrompt,
61
63
  evidence: reporterEvidence,
62
64
  mode: params.mode ?? "edit",
63
65
  invoke: async (reporterPrompt) => {
64
- const reporterOutcome = await runWithRetry(reporterCandidates, reporterPrompt, execDefaults, cwd, env, params.resultPath);
66
+ const reporterOutcome = await runWithRetry(reporterCandidates, reporterPrompt, execDefaults, cwd, env, params.resultPath, params.rateLimitOptions);
65
67
  reporterAttempts += reporterOutcome.attempts;
68
+ reporterActor = reporterOutcome.actor ?? reporterActor;
69
+ rateLimitEvents.push(...reporterOutcome.rateLimitEvents);
66
70
  return {
67
71
  result: reporterOutcome.result,
68
72
  stdout: reporterOutcome.stdout,
@@ -73,6 +77,14 @@ export async function runReporterStage(params) {
73
77
  const reporter = params.providerConcurrencyGate
74
78
  ? await params.providerConcurrencyGate.run(reporterCandidates[0]?.provider, runReporter, `${params.evidence.task_id} reporter`)
75
79
  : await runReporter();
80
+ if (rateLimitEvents.length > 0) {
81
+ params.evidence.rate_limit_events = [
82
+ ...(params.evidence.rate_limit_events ?? []),
83
+ ...rateLimitEvents,
84
+ ];
85
+ reporterEvidence.rate_limit_events = params.evidence.rate_limit_events;
86
+ writeExecutorEvidence(params.evidencePath, params.evidence);
87
+ }
76
88
  let exitCode = 1;
77
89
  let blockReason;
78
90
  if (reporter.result === "success") {
@@ -104,10 +116,12 @@ export async function runReporterStage(params) {
104
116
  state = updatePipelineStage(state, "reporter", {
105
117
  status: exitCode === 0 ? "succeeded" : reporter.result === "rate_limit" ? "rate_limited" : "failed",
106
118
  attempts: state.stages.reporter.attempts + reporterAttempts,
119
+ actor: reporterActor ?? null,
107
120
  completed_at: reporterCompletedAt,
108
121
  artifact_ref: reporter.result === "success"
109
122
  ? relative(cwd, params.resultPath).split(sep).join("/")
110
123
  : state.stages.reporter.artifact_ref,
124
+ ...(rateLimitEvents.length > 0 ? { rate_limit_events: rateLimitEvents } : {}),
111
125
  }, reporterCompletedAt);
112
126
  writePipelineState(params.statePath, state);
113
127
  const runResult = exitCode === 0 ? "success" : reporter.result === "rate_limit" ? "rate_limit" : "failure";
@@ -143,6 +157,9 @@ export async function runAgentPipeline(params) {
143
157
  plan_ref: relative(repoRoot, params.planPath).split(sep).join("/"),
144
158
  result_ref: relative(cwd, resultPath).split(sep).join("/"),
145
159
  },
160
+ ...(params.integrationBranchOverrides
161
+ ? { integrationBranches: { ...params.integrationBranchOverrides } }
162
+ : {}),
146
163
  });
147
164
  state = updatePipelineStage(state, "executor", { status: "running", started_at: startedAt }, startedAt);
148
165
  writePipelineState(stateLocation.path, state);
@@ -157,7 +174,7 @@ export async function runAgentPipeline(params) {
157
174
  ...(params.resumedExecutor ? { resumeHandoff: params.resumeHandoff ?? [] } : {}),
158
175
  }), params.productWorktrees);
159
176
  const changesBeforeAttempt = snapshotWorktreeChanges(cwd, params.productWorktrees);
160
- const runExecutor = () => runWithRetry([executor], executorPrompt, execDefaults, cwd, env, resultPath);
177
+ const runExecutor = () => runWithRetry([executor], executorPrompt, execDefaults, cwd, env, resultPath, params.executorRateLimitOptions);
161
178
  const outcome = params.providerConcurrencyGate
162
179
  ? await params.providerConcurrencyGate.run(executor.provider, runExecutor, `${taskId} executor`)
163
180
  : await runExecutor();
@@ -167,7 +184,7 @@ export async function runAgentPipeline(params) {
167
184
  executionPath,
168
185
  taskId,
169
186
  runId,
170
- actor: executor.actor,
187
+ actor: outcome.actor ?? executor.actor,
171
188
  status: outcome.result === "success"
172
189
  ? "succeeded"
173
190
  : outcome.result === "rate_limit"
@@ -181,6 +198,7 @@ export async function runAgentPipeline(params) {
181
198
  stderr: outcome.stderr,
182
199
  changesBeforeAttempt,
183
200
  productWorktrees: params.productWorktrees,
201
+ rateLimitEvents: outcome.rateLimitEvents,
184
202
  });
185
203
  const coverageFailure = outcome.result === "success"
186
204
  ? resumedTargetCoverageFailure({
@@ -203,8 +221,10 @@ export async function runAgentPipeline(params) {
203
221
  ? "rate_limited"
204
222
  : "failed",
205
223
  attempts: outcome.attempts,
224
+ actor: outcome.actor ?? executor.actor,
206
225
  completed_at: executorCompletedAt,
207
226
  artifact_ref: evidenceRef,
227
+ ...(outcome.rateLimitEvents.length > 0 ? { rate_limit_events: outcome.rateLimitEvents } : {}),
208
228
  }, executorCompletedAt);
209
229
  writePipelineState(stateLocation.path, state);
210
230
  process.stdout.write(` Executor evidence: ${evidenceRef}\n`);
@@ -219,6 +239,7 @@ export async function runAgentPipeline(params) {
219
239
  blockReason,
220
240
  stateRef: stateLocation.ref,
221
241
  evidenceRef,
242
+ rateLimitEvents: outcome.rateLimitEvents,
222
243
  };
223
244
  }
224
245
  recorded.evidence = await appendParentValidationsToExecutorEvidence({
@@ -245,6 +266,7 @@ export async function runAgentPipeline(params) {
245
266
  providerConcurrencyGate: params.providerConcurrencyGate,
246
267
  productWorktrees: params.productWorktrees,
247
268
  mode: params.mode,
269
+ rateLimitOptions: params.reporterRateLimitOptions,
248
270
  });
249
271
  return {
250
272
  exitCode: reporterOutcome.exitCode,
@@ -252,5 +274,6 @@ export async function runAgentPipeline(params) {
252
274
  blockReason: reporterOutcome.blockReason,
253
275
  stateRef: stateLocation.ref,
254
276
  evidenceRef,
277
+ rateLimitEvents: recorded.evidence.rate_limit_events ?? [],
255
278
  };
256
279
  }