specdojo 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +77 -18
  3. package/dist/{catalog-build-references.js → catalog/build-references.js} +4 -4
  4. package/dist/catalog/build-render.js +32 -0
  5. package/dist/{catalog-build.js → catalog/build.js} +9 -9
  6. package/dist/{catalog.js → catalog/catalog.js} +10 -10
  7. package/dist/{catalog-generate.js → catalog/generate.js} +8 -8
  8. package/dist/catalog/paths.js +1 -0
  9. package/dist/{catalog-plan-generate.js → catalog/plan-generate.js} +4 -4
  10. package/dist/{catalog-plan.js → catalog/plan.js} +4 -4
  11. package/dist/{catalog-scaffold.js → catalog/scaffold.js} +3 -3
  12. package/dist/{agent.js → commands/agent.js} +11 -11
  13. package/dist/{build-command.js → commands/build.js} +2 -2
  14. package/dist/{init-command.js → commands/init.js} +98 -32
  15. package/dist/{orchestrator.js → commands/orchestrator.js} +2 -2
  16. package/dist/{watch.js → commands/watch.js} +3 -3
  17. package/dist/{dashboard-timeline.js → dashboard/dashboard-timeline.js} +2 -2
  18. package/dist/{dashboard.js → dashboard/dashboard.js} +11 -10
  19. package/dist/{dashboard-exec-records.js → dashboard/exec-records.js} +2 -2
  20. package/dist/{dashboard-routines.js → dashboard/routines.js} +6 -5
  21. package/dist/{dashboard-shared.js → dashboard/shared.js} +1 -1
  22. package/dist/{timeline-build.js → dashboard/timeline-build.js} +2 -1
  23. package/dist/{timeline.js → dashboard/timeline.js} +1 -1
  24. package/dist/{deliverable.js → deliverable/deliverable.js} +5 -5
  25. package/dist/{deliverable-trash.js → deliverable/trash.js} +5 -5
  26. package/dist/{devcontainer-command.js → devcontainer/command.js} +5 -3
  27. package/dist/{devcontainer-scaffold.js → devcontainer/scaffold.js} +94 -2
  28. package/dist/{doc-index.js → docs/doc-index.js} +1 -1
  29. package/dist/{frontmatter-namespace.js → docs/frontmatter-namespace.js} +1 -1
  30. package/dist/{index-command.js → docs/index-command.js} +1 -1
  31. package/dist/docs/template-resolution.js +1 -0
  32. package/dist/{viewpoint-document-kinds-check.js → docs/viewpoint-document-kinds-check.js} +1 -1
  33. package/dist/{yaml-pages-command.js → docs/yaml-pages-command.js} +1 -1
  34. package/dist/{yaml-pages.js → docs/yaml-pages.js} +2 -2
  35. package/dist/{exec-agent-config.js → exec/agent-config.js} +33 -4
  36. package/dist/{exec-agent-git-state.js → exec/agent-git-state.js} +1 -1
  37. package/dist/{exec-agent-protected-config.js → exec/agent-protected-config.js} +1 -1
  38. package/dist/{exec-commands.js → exec/commands.js} +22 -18
  39. package/dist/{exec-core.js → exec/core.js} +11 -11
  40. package/dist/{exec-events.js → exec/events.js} +2 -2
  41. package/dist/{exec-evidence.js → exec/evidence.js} +11 -6
  42. package/dist/exec/exec.js +2 -0
  43. package/dist/exec/format.js +1 -0
  44. package/dist/{exec-handoff.js → exec/handoff.js} +13 -12
  45. package/dist/{exec-limit.js → exec/limit.js} +93 -12
  46. package/dist/{exec-parent-validation.js → exec/parent-validation.js} +4 -4
  47. package/dist/{exec-pipeline-state.js → exec/pipeline-state.js} +16 -2
  48. package/dist/{exec-plans-core.js → exec/plans-core.js} +68 -114
  49. package/dist/{exec-plans-generation.js → exec/plans-generation.js} +53 -10
  50. package/dist/{exec-plans-storage.js → exec/plans-storage.js} +5 -5
  51. package/dist/{exec-plans.js → exec/plans.js} +3 -3
  52. package/dist/{exec-project.js → exec/project.js} +1 -1
  53. package/dist/{exec-protection-handoff.js → exec/protection-handoff.js} +3 -3
  54. package/dist/{exec-register-resume.js → exec/register-resume.js} +2 -2
  55. package/dist/{exec-register.js → exec/register.js} +92 -9
  56. package/dist/{exec-repo-integration-git.js → exec/repo-integration-git.js} +2 -2
  57. package/dist/{exec-repo-integration-sync.js → exec/repo-integration-sync.js} +4 -4
  58. package/dist/{exec-repo-integration.js → exec/repo-integration.js} +13 -10
  59. package/dist/{exec-repo-trace.js → exec/repo-trace.js} +3 -3
  60. package/dist/{exec-reporter-output.js → exec/reporter-output.js} +2 -2
  61. package/dist/{exec-reporter.js → exec/reporter.js} +29 -12
  62. package/dist/{exec-results.js → exec/results.js} +256 -22
  63. package/dist/{exec-run-agent-pipeline.js → exec/run/agent-pipeline.js} +32 -12
  64. package/dist/{exec-run-agent.js → exec/run/agent.js} +79 -27
  65. package/dist/{exec-run-in-place.js → exec/run/in-place.js} +56 -27
  66. package/dist/{exec-run-job.js → exec/run/job.js} +64 -35
  67. package/dist/{exec-run-lifecycle-commands.js → exec/run/lifecycle-commands.js} +30 -22
  68. package/dist/{exec-run-lock.js → exec/run/lock.js} +4 -3
  69. package/dist/{exec-run-mode-shared.js → exec/run/mode-shared.js} +3 -3
  70. package/dist/{exec-run-register-command.js → exec/run/register-command.js} +18 -10
  71. package/dist/{exec-run-register-core.js → exec/run/register-core.js} +46 -21
  72. package/dist/{exec-run-register-mode.js → exec/run/register-mode.js} +20 -16
  73. package/dist/{exec-run-register-resume.js → exec/run/register-resume.js} +22 -17
  74. package/dist/{exec-run-register-state.js → exec/run/register-state.js} +13 -10
  75. package/dist/{exec-run-register-worktree.js → exec/run/register-worktree.js} +54 -23
  76. package/dist/{exec-run.js → exec/run/run.js} +11 -11
  77. package/dist/{exec-run-schedule-mode.js → exec/run/schedule-mode.js} +17 -17
  78. package/dist/{exec-run-schedule-prepare.js → exec/run/schedule-prepare.js} +31 -18
  79. package/dist/{exec-run-schedule-task.js → exec/run/schedule-task.js} +45 -18
  80. package/dist/{exec-run-shared.js → exec/run/shared.js} +61 -11
  81. package/dist/{exec-schedule-calendar.js → exec/schedule/calendar.js} +1 -1
  82. package/dist/{exec-schedule-cpm.js → exec/schedule/cpm.js} +2 -2
  83. package/dist/{exec-schedule-gantt-chart-render.js → exec/schedule/gantt-chart-render.js} +2 -2
  84. package/dist/exec/schedule/gantt-chart.js +2 -0
  85. package/dist/{exec-schedule-hash.js → exec/schedule/hash.js} +2 -2
  86. package/dist/exec/schedule/index.js +1 -0
  87. package/dist/{exec-schedule-initial.js → exec/schedule/initial.js} +2 -2
  88. package/dist/{exec-schedule-progress.js → exec/schedule/progress.js} +2 -2
  89. package/dist/{exec-schedule-ready.js → exec/schedule/ready.js} +2 -2
  90. package/dist/{exec-schedule.js → exec/schedule/schedule.js} +11 -11
  91. package/dist/exec/shared.js +63 -0
  92. package/dist/exec/slot-lock.js +1 -0
  93. package/dist/{exec-strategy.js → exec/strategy.js} +2 -2
  94. package/dist/{exec-task-repos.js → exec/task-repos.js} +2 -2
  95. package/dist/{exec-task-view.js → exec/task-view.js} +4 -4
  96. package/dist/{exec-trial-commands.js → exec/trial-commands.js} +20 -22
  97. package/dist/{exec-trial-core.js → exec/trial-core.js} +6 -6
  98. package/dist/{exec-trial.js → exec/trial.js} +2 -2
  99. package/dist/{exec-worktree-command.js → exec/worktree-command.js} +25 -23
  100. package/dist/{exec-worktree-ops-commit.js → exec/worktree-ops-commit.js} +25 -60
  101. package/dist/{exec-worktree-ops-lifecycle.js → exec/worktree-ops-lifecycle.js} +13 -8
  102. package/dist/{exec-worktree-ops-merge.js → exec/worktree-ops-merge.js} +48 -7
  103. package/dist/{exec-worktree-ops.js → exec/worktree-ops.js} +3 -3
  104. package/dist/exec/worktree.js +305 -0
  105. package/dist/{grade-apply.js → grade/apply.js} +9 -9
  106. package/dist/{grade-command-apply.js → grade/command-apply.js} +7 -7
  107. package/dist/{grade-command-inspect.js → grade/command-inspect.js} +6 -6
  108. package/dist/{grade-command-plan.js → grade/command-plan.js} +5 -5
  109. package/dist/{grade-core.js → grade/core.js} +3 -3
  110. package/dist/grade/grade.js +19 -0
  111. package/dist/{grade-markdown.js → grade/markdown.js} +6 -6
  112. package/dist/{grade-pipeline-state.js → grade/pipeline-state.js} +4 -4
  113. package/dist/{grade-plan.js → grade/plan.js} +5 -5
  114. package/dist/{grade-result.js → grade/result.js} +5 -94
  115. package/dist/{grade-target-discovery.js → grade/target-discovery.js} +7 -7
  116. package/dist/{grade-targets.js → grade/targets.js} +11 -8
  117. package/dist/{job-definition.js → job/definition.js} +25 -6
  118. package/dist/{job.js → job/job.js} +12 -11
  119. package/dist/{kata-command.js → kata/command.js} +3 -3
  120. package/dist/{kata.js → kata/kata.js} +5 -5
  121. package/dist/register/approach.js +134 -0
  122. package/dist/{register-core.js → register/core.js} +13 -7
  123. package/dist/{register-create-commands.js → register/create-commands.js} +115 -8
  124. package/dist/{register-date.js → register/date.js} +1 -1
  125. package/dist/register/derivation.js +163 -0
  126. package/dist/{register-event-merge.js → register/event-merge.js} +32 -3
  127. package/dist/{register-events.js → register/events.js} +9 -3
  128. package/dist/{register-history.js → register/history.js} +7 -6
  129. package/dist/{register-item.js → register/item.js} +23 -5
  130. package/dist/register/lifecycle-lock.js +5 -0
  131. package/dist/{register-maintenance-commands.js → register/maintenance-commands.js} +13 -7
  132. package/dist/{register-migrate-timestamps.js → register/migrate-timestamps.js} +3 -3
  133. package/dist/{register-migration.js → register/migration.js} +4 -4
  134. package/dist/{register.js → register/register.js} +32 -27
  135. package/dist/{register-renumber.js → register/renumber.js} +38 -11
  136. package/dist/{register-transition-commands.js → register/transition-commands.js} +3 -3
  137. package/dist/{register-update.js → register/update.js} +5 -5
  138. package/dist/{register-views.js → register/views.js} +47 -7
  139. package/dist/{review-grade.js → review/grade.js} +2 -2
  140. package/dist/{review-plan.js → review/plan.js} +3 -3
  141. package/dist/{routine-definition.js → routine/definition.js} +2 -2
  142. package/dist/{routine.js → routine/routine.js} +49 -22
  143. package/dist/{schedule-approach.js → schedule/approach.js} +8 -8
  144. package/dist/{schedule-build.js → schedule/build.js} +7 -4
  145. package/dist/{schedule.js → schedule/schedule.js} +6 -6
  146. package/dist/{schedule-strategy-generate-document.js → schedule/strategy-generate-document.js} +2 -2
  147. package/dist/{schedule-strategy-generate-scope.js → schedule/strategy-generate-scope.js} +4 -4
  148. package/dist/{schedule-strategy-generate.js → schedule/strategy-generate.js} +10 -10
  149. package/dist/shared/agent-types.js +23 -0
  150. package/dist/shared/artifact-path.js +9 -0
  151. package/dist/{build-if-stale.js → shared/build-if-stale.js} +1 -1
  152. package/dist/{catalog-build-render.js → shared/catalog-render.js} +3 -32
  153. package/dist/{exec-slot-lock.js → shared/cross-process-lock.js} +3 -1
  154. package/dist/shared/fs.js +30 -0
  155. package/dist/{exec-worktree.js → shared/git.js} +83 -241
  156. package/dist/shared/grade-result.js +94 -0
  157. package/dist/{package-paths.js → shared/package-paths.js} +3 -3
  158. package/dist/shared/plan-templates.js +114 -0
  159. package/dist/{exec-provider-scaffold.js → shared/provider-scaffold.js} +3 -1
  160. package/dist/shared/random.js +4 -0
  161. package/dist/{exec-schedule-index.js → shared/schedule-index.js} +3 -1
  162. package/dist/shared/schedule-paths.js +9 -0
  163. package/dist/{specdojo-config.js → shared/specdojo-config.js} +93 -5
  164. package/dist/{exec-shared.js → shared/text.js} +0 -134
  165. package/dist/shared/time.js +28 -0
  166. package/dist/specdojo.js +22 -22
  167. package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +29 -17
  168. package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +1 -2
  169. package/docs/ja/specdojo/exec-templates/xep-register-template.md +1 -2
  170. package/docs/ja/specdojo/exec-templates/xer-template.md +1 -3
  171. package/docs/ja/specdojo/exec-templates/xrp-job-template.md +6 -4
  172. package/docs/ja/specdojo/guides/exec-config-guide.md +91 -16
  173. package/docs/ja/specdojo/guides/exec-operation-guide.md +145 -12
  174. package/docs/ja/specdojo/guides/exec-worktree-guide.md +2 -0
  175. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +31 -0
  176. package/docs/ja/specdojo/guides/quick-start-guide.md +81 -16
  177. package/docs/ja/specdojo/guides/register-operation-guide.md +2 -1
  178. package/docs/ja/specdojo/guides/remote-host-development-guide.md +10 -1
  179. package/docs/ja/specdojo/guides/review-guide.md +1 -1
  180. package/docs/ja/specdojo/guides/routine-operation-guide.md +5 -5
  181. package/docs/ja/specdojo/guides/use-case-guide.md +1 -1
  182. package/docs/ja/specdojo/references/command-reference.md +52 -28
  183. package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +17 -11
  184. package/docs/ja/specdojo/standards/job-definition-standard.md +20 -18
  185. package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +2 -2
  186. package/docs/ja/specdojo/templates/pjr-derived-items-template.md +22 -0
  187. package/docs/ja/specdojo/templates/pjr-index-template.md +1 -0
  188. package/docs/specdojo/schemas/v1/agent-members.schema.yaml +29 -2
  189. package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +20 -0
  190. package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +23 -0
  191. package/docs/specdojo/schemas/v1/job-run.schema.yaml +2 -2
  192. package/docs/specdojo/schemas/v1/job.schema.yaml +7 -0
  193. package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +26 -0
  194. package/docs/specdojo/schemas/v1/register-events.schema.yaml +3 -0
  195. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +70 -7
  196. package/docs/specdojo/schemas/v1/routine-run.schema.yaml +1 -1
  197. package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +1 -1
  198. package/package.json +1 -1
  199. package/templates/antigravity/README.md +5 -1
  200. package/templates/antigravity/agent-members-snippet.yaml +108 -12
  201. package/templates/antigravity/exec-defaults-snippet.yaml +8 -13
  202. package/templates/claude/README.md +27 -3
  203. package/templates/claude/agents/claude-executor.md +0 -1
  204. package/templates/claude/agents/claude-reporter.md +2 -1
  205. package/templates/claude/agents/claude-review-executor.md +0 -1
  206. package/templates/codex/README.md +23 -4
  207. package/templates/devcontainer/devcontainer.json +2 -2
  208. package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +69 -0
  209. package/templates/devcontainer/remote-host/ssh-config.sample +16 -0
  210. package/templates/init-agent-members.yaml +75 -25
  211. package/templates/init-exec-defaults.yaml +24 -8
  212. package/templates/opencode/README.md +17 -3
  213. package/templates/opencode/agents/opencode-executor.md +0 -1
  214. package/templates/opencode/agents/opencode-reporter.md +2 -1
  215. package/templates/opencode/agents/opencode-review-executor.md +0 -1
  216. package/dist/exec-schedule-gantt-chart.js +0 -2
  217. package/dist/exec.js +0 -2
  218. package/dist/grade.js +0 -19
  219. package/templates/claude/agents/claude-expert-review-executor.md +0 -14
  220. /package/dist/{catalog-plan-prompt.js → catalog/plan-prompt.js} +0 -0
  221. /package/dist/{catalog-types.js → catalog/types.js} +0 -0
  222. /package/dist/{template-frontmatter.js → docs/template-frontmatter.js} +0 -0
  223. /package/dist/{role-types.js → exec/role-types.js} +0 -0
  224. /package/dist/{exec-schedule-gantt-chart-scope.js → exec/schedule/gantt-chart-scope.js} +0 -0
  225. /package/dist/{exec-types.js → exec/types.js} +0 -0
  226. /package/dist/{grade-command-shared.js → grade/command-shared.js} +0 -0
  227. /package/dist/{register-command-types.js → register/command-types.js} +0 -0
  228. /package/dist/{review-types.js → review/types.js} +0 -0
  229. /package/dist/{schedule-phase-sets.js → schedule/phase-sets.js} +0 -0
  230. /package/dist/{schedule-strategy-profiles.js → schedule/strategy-profiles.js} +0 -0
  231. /package/dist/{agent-response.js → shared/agent-response.js} +0 -0
  232. /package/dist/{catalog-paths.js → shared/catalog-paths.js} +0 -0
  233. /package/dist/{dist-freshness.js → shared/dist-freshness.js} +0 -0
  234. /package/dist/{git-environment.js → shared/git-environment.js} +0 -0
  235. /package/dist/{exec-format.js → shared/markdown-format.js} +0 -0
  236. /package/dist/{practice-id.js → shared/practice-id.js} +0 -0
  237. /package/dist/{spawn-self.js → shared/spawn-self.js} +0 -0
  238. /package/dist/{specdojo-gitignore.js → shared/specdojo-gitignore.js} +0 -0
  239. /package/dist/{template-resolution.js → shared/template-resolution.js} +0 -0
  240. /package/dist/{yaml-schema-modeline.js → shared/yaml-schema-modeline.js} +0 -0
  241. /package/dist/{yaml.js → shared/yaml.js} +0 -0
@@ -1,9 +1,9 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { listFilesRecursive, readYaml } from "./exec-shared.js";
4
- import { acquirePoolSlot, releaseLock } from "./exec-slot-lock.js";
5
- import { specdojoRootDir, } from "./specdojo-config.js";
6
- import { resolveParentValidationConcurrency, resolveParentValidationDefinitions, } from "./exec-parent-validation.js";
3
+ import { listFilesRecursive, readYaml } from "./shared.js";
4
+ import { acquirePoolSlot, releaseLock } from "./slot-lock.js";
5
+ import { specdojoRootDir, } from "../shared/specdojo-config.js";
6
+ import { resolveParentValidationConcurrency, resolveParentValidationDefinitions, } from "./parent-validation.js";
7
7
  const PLACEHOLDER_PATTERN = /\{([a-z][a-z0-9_]*)\}/g;
8
8
  const BUILTIN_VARIABLE_NAMES = new Set(["nickname", "mode", "proficiency"]);
9
9
  // Mirror of the nickname pattern in docs/specdojo/schemas/v1/agent-members.schema.yaml.
@@ -53,6 +53,10 @@ function buildCommandVariables(provider, member, params) {
53
53
  variables.set(key, value);
54
54
  for (const [key, value] of Object.entries(byNickname ?? {}))
55
55
  variables.set(key, value);
56
+ // A concrete member's model is the source of truth. Legacy members without model keep using
57
+ // command_params, so existing one-level rosters and templates remain compatible.
58
+ if (member.model)
59
+ variables.set("model", member.model);
56
60
  return variables;
57
61
  }
58
62
  // Resolve the shell command that launches a member's agent. Returns undefined when the
@@ -88,6 +92,25 @@ export function resolveRateLimitPolicy(config, provider) {
88
92
  const override = provider ? config.providers?.[provider]?.rate_limit_policy : undefined;
89
93
  return override ?? config.rate_limit_policy;
90
94
  }
95
+ export const DEFAULT_PINNED_RATE_LIMIT_MAX_WAIT_SECONDS = 8 * 60 * 60;
96
+ /** Resolve and validate the policy used only for agents selected by nickname. */
97
+ export function resolvePinnedRateLimitPolicy(config, provider) {
98
+ const pinned = resolveRateLimitPolicy(config, provider)?.pinned;
99
+ const action = pinned?.action ?? "stop";
100
+ if (action !== "stop" && action !== "wait" && action !== "fallback") {
101
+ throw new Error(`rate_limit_policy.pinned.action in exec-defaults must be "stop", "wait", or "fallback": ${String(action)}`);
102
+ }
103
+ const maxWaitSeconds = pinned?.max_wait_seconds ?? DEFAULT_PINNED_RATE_LIMIT_MAX_WAIT_SECONDS;
104
+ if (!Number.isFinite(maxWaitSeconds) || maxWaitSeconds < 0) {
105
+ throw new Error(`rate_limit_policy.pinned.max_wait_seconds in exec-defaults must be a non-negative number: ${String(maxWaitSeconds)}`);
106
+ }
107
+ return {
108
+ action,
109
+ maxWaitSeconds,
110
+ ...(pinned?.fallback_executor_by ? { fallbackExecutorBy: pinned.fallback_executor_by } : {}),
111
+ ...(pinned?.fallback_reporter_by ? { fallbackReporterBy: pinned.fallback_reporter_by } : {}),
112
+ };
113
+ }
91
114
  // Resolve a provider's concurrency cap, validating the YAML-sourced value. A missing,
92
115
  // non-integer, or non-positive value means "no limit" (returns undefined).
93
116
  export function resolveMaxConcurrency(config, provider) {
@@ -266,5 +289,11 @@ export function loadExecDefaultsConfig(configPath, executionPath) {
266
289
  resolveParentValidationDefinitions(defaults.pipeline?.parent_validations);
267
290
  resolveParentValidationConcurrency(defaults.pipeline?.parent_validation_concurrency);
268
291
  resolveRegisterExecution(defaults);
292
+ resolvePinnedRateLimitPolicy(defaults);
293
+ for (const provider of Object.keys(defaults.providers ?? {})) {
294
+ if (defaults.providers?.[provider]?.rate_limit_policy) {
295
+ resolvePinnedRateLimitPolicy(defaults, provider);
296
+ }
297
+ }
269
298
  return defaults;
270
299
  }
@@ -1,4 +1,4 @@
1
- import { gitResult } from "./exec-worktree.js";
1
+ import { gitResult } from "./worktree.js";
2
2
  function commandSnapshot(repoRoot, args) {
3
3
  const result = gitResult(repoRoot, args);
4
4
  const stdout = typeof result.stdout === "string" ? result.stdout : "";
@@ -2,7 +2,7 @@ import { spawnSync } from "node:child_process";
2
2
  import { createHash } from "node:crypto";
3
3
  import { existsSync, lstatSync, readdirSync, readFileSync, readlinkSync } from "node:fs";
4
4
  import { join, relative, sep } from "node:path";
5
- import { gitEnvironment, gitResult } from "./exec-worktree.js";
5
+ import { gitEnvironment, gitResult } from "./worktree.js";
6
6
  // PJR-3S8Q で agent の書き込み対象外とした、親 runner / hook / CI の実行内容を
7
7
  // 変えられる設定パス。provider 設定から注入できない固定定義として CLI 側に持つ。
8
8
  export const PROTECTED_DIRECTORY_PREFIXES = [
@@ -1,23 +1,23 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { join, resolve as pathResolve } from "node:path";
3
- import { validateCatalogLocalIds, validateRulebookKata } from "./catalog-build.js";
4
- import { acquireSchedulerLock, canBlockTask, canCancelTask, canClaimTask, canCompleteTask, canReleaseTask, canReopenTask, canUnblockTask, computeReadyIds, readAllEventFiles, releaseSchedulerLock, schedulerLockPath, writeEventFile, } from "./exec-events.js";
5
- import { eventsDirForProject, generatedDirForProject } from "./exec-project.js";
6
- import { assertValidActor, getProjectViewpointsPath, loadConfig, specdojoRootDir, } from "./specdojo-config.js";
7
- import { buildScheduleIndex, computeCpm, exitWithCode, printValidateResult, selectNextTask, validateAll, writeCpmFiles, writeGeneratedCore, writeScheduleHashAndDiff, } from "./exec-schedule.js";
8
- import { readReadySnapshot } from "./exec-schedule-ready.js";
9
- import { displayWidth, nowUtcIsoSeconds, padEndDisplay, requireNonEmpty } from "./exec-shared.js";
10
- import { archivePlan, buildInPlaceStem, generateDeliverablePlan, generateSinglePlan, resolveDeliverableTarget, stemFromPlanPath, } from "./exec-plans.js";
11
- import { runProviderScaffold, specdojoPackageRootDir } from "./exec-provider-scaffold.js";
12
- import { generateRegisterPlan, normalizePjrId, resolveRegisterRunTarget } from "./exec-register.js";
13
- import { scaffoldViewpoints } from "./review-plan.js";
14
- import { registerCycleCommand, registerResumeCommand, registerRunCommand, registerSlotsCommand, } from "./exec-run.js";
15
- import { buildTaskView } from "./exec-task-view.js";
16
- import { registerExecWorktreeCommands } from "./exec-worktree-command.js";
17
- import { registerExecTrialCommands } from "./exec-trial.js";
18
- import { registerExecHandoffCommands } from "./exec-handoff.js";
19
- import { resolveOwnerForLocalId } from "./exec-strategy.js";
20
- import { DEFAULT_EVENT_MESSAGES, KNOWN_OWNER_LABELS, KNOWN_OWNER_LABELS_TEXT, addCommonAddOptions, addForceOption, addLockOptions, addOwnerOptions, addProjectOptions, ensureActorCanClaimNext, findRosterMember, loadRosterForOpts, loadValidatedExecState, parseApproach, parseTaskMode, printCommandError, resolveClaimOwner, resolveForceOverride, resolveProjectContext, resolveProjectId, resolveSchedulerStrategy, runLockedEventCommand, runReleaseAllBlocked, runSimpleEventCommand, scaffoldClaimResult, } from "./exec-core.js";
3
+ import { validateCatalogLocalIds, validateRulebookKata } from "../catalog/build.js";
4
+ import { acquireSchedulerLock, canBlockTask, canCancelTask, canClaimTask, canCompleteTask, canReleaseTask, canReopenTask, canUnblockTask, computeReadyIds, readAllEventFiles, releaseSchedulerLock, schedulerLockPath, writeEventFile, } from "./events.js";
5
+ import { eventsDirForProject, generatedDirForProject } from "./project.js";
6
+ import { assertValidActor, getProjectViewpointsPath, loadConfig, specdojoRootDir, } from "../shared/specdojo-config.js";
7
+ import { buildScheduleIndex, computeCpm, exitWithCode, printValidateResult, selectNextTask, validateAll, writeCpmFiles, writeGeneratedCore, writeScheduleHashAndDiff, } from "./schedule/schedule.js";
8
+ import { readReadySnapshot } from "./schedule/ready.js";
9
+ import { displayWidth, nowUtcIsoSeconds, padEndDisplay, requireNonEmpty } from "./shared.js";
10
+ import { archivePlan, buildInPlaceStem, generateDeliverablePlan, generateSinglePlan, resolveDeliverableTarget, stemFromPlanPath, } from "./plans.js";
11
+ import { runProviderScaffold, specdojoPackageRootDir } from "../shared/provider-scaffold.js";
12
+ import { generateRegisterPlan, normalizePjrId, resolveRegisterRunTarget } from "./register.js";
13
+ import { scaffoldViewpoints } from "../review/plan.js";
14
+ import { registerCycleCommand, registerResumeCommand, registerRunCommand, registerSlotsCommand, } from "./run/run.js";
15
+ import { buildTaskView } from "./task-view.js";
16
+ import { registerExecWorktreeCommands } from "./worktree-command.js";
17
+ import { registerExecTrialCommands } from "./trial.js";
18
+ import { registerExecHandoffCommands } from "./handoff.js";
19
+ import { resolveOwnerForLocalId } from "./strategy.js";
20
+ import { DEFAULT_EVENT_MESSAGES, KNOWN_OWNER_LABELS, KNOWN_OWNER_LABELS_TEXT, addCommonAddOptions, addForceOption, addLockOptions, addOwnerOptions, addProjectOptions, ensureActorCanClaimNext, findRosterMember, loadRosterForOpts, loadValidatedExecState, parseApproach, parseTaskMode, printCommandError, resolveClaimOwner, resolveForceOverride, resolveProjectContext, resolveProjectId, resolveSchedulerStrategy, runLockedEventCommand, runReleaseAllBlocked, runSimpleEventCommand, scaffoldClaimResult, } from "./core.js";
21
21
  export function registerExecCommands(program) {
22
22
  const exec = program.command("exec").description("Execution helpers");
23
23
  registerExecHandoffCommands(exec);
@@ -184,6 +184,10 @@ export function registerExecCommands(program) {
184
184
  const generated = await generateRegisterPlan({
185
185
  executionPath,
186
186
  projectId,
187
+ ...(catalogPath ? { catalogPath } : {}),
188
+ ...(rolesPath ? { rolesPath } : {}),
189
+ ...(viewpointsPath ? { viewpointsPath } : {}),
190
+ ...(projectContext ? { projectContext } : {}),
187
191
  registerPaths,
188
192
  item,
189
193
  stem,
@@ -1,14 +1,14 @@
1
- import { acquireSchedulerLock, buildEvent, canReleaseTask, collectRepeatable, findDoingTasksForActor, foldEventsToState, readAllEventFiles, releaseSchedulerLock, writeEventFile, } from "./exec-events.js";
2
- import { activateResolvedProjectPaths, resolveProjectPaths } from "./exec-project.js";
3
- import { assertValidActor, loadConfig, loadMemberRoster, specdojoRootDir, } from "./specdojo-config.js";
4
- import { buildScheduleIndex, computeCpm, exitWithCode, printValidateResult, validateAll, writeCpmFiles, writeGeneratedCore, writeScheduleHashAndDiff, } from "./exec-schedule.js";
5
- import { qualifyTaskId, requireNonEmpty } from "./exec-shared.js";
6
- import { finalizeResultSectionsForDeliverable, targetDocIdsForScheduledTask, } from "./exec-plans.js";
7
- import { resetResultForClaim, scaffoldResult } from "./exec-results.js";
8
- import { discardStaleExecWorktree } from "./exec-worktree-ops.js";
9
- import { configuredProductRepos } from "./exec-task-repos.js";
10
- import { buildInitialStateFromStrategy } from "./exec-schedule-initial.js";
11
- import { buildPhaseModeIndex, resolveApproach, resolveTaskExecution, resolveTaskMode, } from "./exec-strategy.js";
1
+ import { acquireSchedulerLock, buildEvent, canReleaseTask, collectRepeatable, findDoingTasksForActor, foldEventsToState, readAllEventFiles, releaseSchedulerLock, writeEventFile, } from "./events.js";
2
+ import { activateResolvedProjectPaths, resolveProjectPaths } from "./project.js";
3
+ import { assertValidActor, loadConfig, loadMemberRoster, specdojoRootDir, } from "../shared/specdojo-config.js";
4
+ import { buildScheduleIndex, computeCpm, exitWithCode, printValidateResult, validateAll, writeCpmFiles, writeGeneratedCore, writeScheduleHashAndDiff, } from "./schedule/schedule.js";
5
+ import { qualifyTaskId, requireNonEmpty } from "./shared.js";
6
+ import { finalizeResultSectionsForDeliverable, targetDocIdsForScheduledTask } from "./plans.js";
7
+ import { resetResultForClaim, scaffoldResult } from "./results.js";
8
+ import { discardStaleExecWorktree } from "./worktree-ops.js";
9
+ import { configuredProductRepos } from "./task-repos.js";
10
+ import { buildInitialStateFromStrategy } from "./schedule/initial.js";
11
+ import { buildPhaseModeIndex, resolveApproach, resolveTaskExecution, resolveTaskMode, } from "./strategy.js";
12
12
  export const KNOWN_OWNER_LABELS = ["PO", "PM", "BA", "ARC", "DEV", "QE", "UX", "OPS"];
13
13
  export const KNOWN_OWNER_LABELS_TEXT = KNOWN_OWNER_LABELS.join("|");
14
14
  const KNOWN_APPROACHES = [
@@ -1,7 +1,7 @@
1
1
  import { extname, join, resolve } from "node:path";
2
2
  import { mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
3
- import { collectRepeatable, ensureDir, isUtcIsoSeconds, listFilesRecursive, nowUtcIsoSeconds, parseKeyValuePairs, randomHex, readJson, requireNonEmpty, safeSlug, sleepMs, toArtifactPath, tsForFilenameUtc, writeJson, } from "./exec-shared.js";
4
- import { eventsDirForProject, executionRootForProject } from "./exec-project.js";
3
+ import { collectRepeatable, ensureDir, isUtcIsoSeconds, listFilesRecursive, nowUtcIsoSeconds, parseKeyValuePairs, randomHex, readJson, requireNonEmpty, safeSlug, sleepMs, toArtifactPath, tsForFilenameUtc, writeJson, } from "./shared.js";
4
+ import { eventsDirForProject, executionRootForProject } from "./project.js";
5
5
  export { collectRepeatable };
6
6
  export function validateEventShape(obj, source) {
7
7
  const errs = [];
@@ -1,7 +1,7 @@
1
1
  import { readFileSync, renameSync, writeFileSync } from "node:fs";
2
2
  import { dirname, join, relative, sep } from "node:path";
3
- import { ensureDir, redactSensitiveText, safeSlug } from "./exec-shared.js";
4
- import { gitOutput } from "./exec-worktree.js";
3
+ import { ensureDir, redactSensitiveText, safeSlug } from "./shared.js";
4
+ import { gitOutput } from "./worktree.js";
5
5
  const MAX_LOG_BYTES = 64 * 1024;
6
6
  const MAX_CHANGE_FILES = 1_000;
7
7
  const MAX_FINAL_MESSAGE_LENGTH = 4_000;
@@ -29,7 +29,7 @@ function boundedLog(value) {
29
29
  truncated: true,
30
30
  };
31
31
  }
32
- export { redactSensitiveText } from "./exec-shared.js";
32
+ export { redactSensitiveText } from "./shared.js";
33
33
  function boundedText(value, limit) {
34
34
  return truncate(redactSensitiveText(typeof value === "string" ? value.trim() : ""), limit);
35
35
  }
@@ -311,6 +311,7 @@ export function buildExecutorEvidence(input) {
311
311
  },
312
312
  validations,
313
313
  ...(report.targetCoverage.length > 0 ? { target_coverage: report.targetCoverage } : {}),
314
+ ...(input.rateLimitEvents?.length ? { rate_limit_events: input.rateLimitEvents } : {}),
314
315
  final_message: report.finalMessage,
315
316
  ...(input.status === "succeeded"
316
317
  ? {}
@@ -374,6 +375,7 @@ export function recordExecutorEvidence(input) {
374
375
  diffStat,
375
376
  logRefPath: repoRelative(input.worktreePath, logPath),
376
377
  parentValidations: input.parentValidations,
378
+ rateLimitEvents: input.rateLimitEvents,
377
379
  });
378
380
  writeFileSync(logPath, logExcerpt, "utf8");
379
381
  writeFileSync(evidencePath, `${JSON.stringify(evidence, null, 2)}\n`, "utf8");
@@ -408,11 +410,12 @@ export function recordCommandEvidence(input) {
408
410
  writeFileSync(stderrPath, boundedStderr.content, "utf8");
409
411
  const stdoutRef = repoRelative(input.worktreePath, stdoutPath);
410
412
  const stderrRef = repoRelative(input.worktreePath, stderrPath);
411
- const succeeded = input.exitCode === 0 && !input.error;
413
+ const succeeded = !input.error && (input.exitCode === 0 || input.accepted === true);
414
+ const acceptedNonzero = succeeded && input.exitCode !== 0;
412
415
  const safeCommand = boundedText(input.command, 16_000);
413
416
  const summary = input.error
414
417
  ? `spawn failed: ${boundedText(input.error, MAX_VALIDATION_SUMMARY_LENGTH)}`
415
- : `exit ${input.exitCode ?? "unknown"}`;
418
+ : `exit ${input.exitCode ?? "unknown"}${acceptedNonzero ? " (accepted)" : ""}`;
416
419
  const evidence = {
417
420
  schema_version: 1,
418
421
  task_id: input.taskId,
@@ -423,7 +426,9 @@ export function recordCommandEvidence(input) {
423
426
  status: succeeded ? "succeeded" : "failed",
424
427
  started_at: input.startedAt,
425
428
  completed_at: input.completedAt,
426
- exit_code: input.exitCode,
429
+ // The stage exit code represents whether the executor pipeline may continue. The actual
430
+ // command exit code remains authoritative in command.exit_code below.
431
+ exit_code: succeeded ? 0 : input.exitCode,
427
432
  attempts: 1,
428
433
  },
429
434
  changes,
@@ -0,0 +1,2 @@
1
+ export { resolveClaimOwner } from "./core.js";
2
+ export { registerExecCommands } from "./commands.js";
@@ -0,0 +1 @@
1
+ export * from "../shared/markdown-format.js";
@@ -3,16 +3,16 @@ import { existsSync, lstatSync, mkdtempSync, readFileSync, readdirSync, rmSync,
3
3
  import { tmpdir } from "node:os";
4
4
  import { createInterface } from "node:readline/promises";
5
5
  import { join, posix, resolve } from "node:path";
6
- import { isAgentProtectedConfigPath } from "./exec-agent-protected-config.js";
7
- import { PROTECTION_HANDOFF_MARKER } from "./exec-protection-handoff.js";
8
- import { normalizePjrId, resolveRegisterRunTarget } from "./exec-register.js";
9
- import { refsTrailer, withCommitTrailers } from "./exec-repo-trace.js";
10
- import { configuredProductReposForProject } from "./exec-task-repos.js";
11
- import { parseSpecdojoDocument } from "./frontmatter-namespace.js";
12
- import { qualifyTaskId } from "./exec-shared.js";
13
- import { specdojoRootDir } from "./specdojo-config.js";
14
- import { findExecWorktree, gitEnvironment, gitOutput, gitResult } from "./exec-worktree.js";
15
- import { stageCommitTargets, stabilizeCommitTargets, unstageCommitTargets, worktreeStatusPaths, } from "./exec-worktree-ops.js";
6
+ import { isAgentProtectedConfigPath } from "./agent-protected-config.js";
7
+ import { PROTECTION_HANDOFF_MARKER } from "./protection-handoff.js";
8
+ import { normalizePjrId, resolveRegisterRunTarget } from "./register.js";
9
+ import { refsTrailer, withCommitTrailers } from "./repo-trace.js";
10
+ import { configuredProductReposForProject } from "./task-repos.js";
11
+ import { parseSpecdojoDocument } from "../docs/frontmatter-namespace.js";
12
+ import { qualifyTaskId } from "./shared.js";
13
+ import { specdojoRootDir } from "../shared/specdojo-config.js";
14
+ import { findExecWorktree, formatGitResultFailure, gitEnvironment, gitOutput, gitResult, } from "./worktree.js";
15
+ import { stageCommitTargets, stabilizeCommitTargets, unstageCommitTargets, worktreeStatusPaths, } from "./worktree-ops.js";
16
16
  const HANDOFF_MECHANISM = "agent-config-write";
17
17
  const TRUNCATED_EVIDENCE_RE = /^\.\.\. \((?:\d+ 行を省略|文字数上限で切り詰め)\)$/m;
18
18
  function sectionAfterMarker(content) {
@@ -182,11 +182,12 @@ function applyAndCommit(repo, message) {
182
182
  throw new Error(gitApplyError(applied));
183
183
  try {
184
184
  stageCommitTargets(repo.root, repo.paths);
185
- const staged = gitResult(repo.root, ["diff", "--cached", "--quiet", "--", ...repo.paths]);
185
+ const stagedArgs = ["diff", "--cached", "--quiet", "--", ...repo.paths];
186
+ const staged = gitResult(repo.root, stagedArgs);
186
187
  if (staged.status !== 1) {
187
188
  if (staged.status === 0)
188
189
  throw new Error("The proposed patch produced no staged change.");
189
- throw new Error("Could not inspect the staged handoff change.");
190
+ throw new Error(`Could not inspect the staged handoff change: ${formatGitResultFailure(stagedArgs, staged)}`);
190
191
  }
191
192
  const commit = gitResult(repo.root, ["commit", "-m", message, "--", ...repo.paths]);
192
193
  if (commit.status !== 0) {
@@ -17,6 +17,12 @@ function limitKind(output) {
17
17
  return "oom";
18
18
  return "rate_limit";
19
19
  }
20
+ function outputLines(output) {
21
+ return output
22
+ .split(/\r?\n/)
23
+ .map((line) => line.trim())
24
+ .filter(Boolean);
25
+ }
20
26
  function diagnosticLine(output, kind) {
21
27
  const patterns = {
22
28
  rate_limit: /rate limit|too many requests|\b429\b|retry.after/i,
@@ -26,11 +32,11 @@ function diagnosticLine(output, kind) {
26
32
  timeout: /timeout|timed out/i,
27
33
  oom: /out of memory|\boom\b/i,
28
34
  };
29
- const lines = output
30
- .split(/\r?\n/)
31
- .map((line) => line.trim())
32
- .filter(Boolean);
33
- const matched = lines.find((line) => patterns[kind].test(line)) ?? lines.at(-1) ?? "limit reached";
35
+ const lines = outputLines(output);
36
+ // The provider prints its limit notice at the end; earlier matches can be transcript echoes.
37
+ const matched = [...lines].reverse().find((line) => patterns[kind].test(line)) ??
38
+ lines.at(-1) ??
39
+ "limit reached";
34
40
  return matched.length > RAW_MESSAGE_MAX_LENGTH
35
41
  ? `${matched.slice(0, RAW_MESSAGE_MAX_LENGTH)}…`
36
42
  : matched;
@@ -89,12 +95,28 @@ function parseProviderReset(output, observedAt) {
89
95
  if (!Number.isNaN(parsed.getTime()) && parsed > observedAt)
90
96
  return parsed;
91
97
  }
92
- const timeOnly = output.match(/resets?(?:\s+at)?\s+(\d{1,2}):(\d{2})\s*(am|pm)?(?:\s*\(([^)]+)\)|\s+(UTC|GMT|JST|(?:UTC|GMT)?[+-]\d{1,2}(?::?\d{2})?))?/i);
98
+ // Antigravity reports a relative reset such as "Resets in 4h36m50s".
99
+ const relative = output.match(/\bresets?\s+in\s+(\d+\s*[dhms](?:\s*\d+\s*[dhms])*)\b/i);
100
+ if (relative) {
101
+ const unitMilliseconds = {
102
+ d: 86_400_000,
103
+ h: 3_600_000,
104
+ m: 60_000,
105
+ s: 1000,
106
+ };
107
+ let totalMilliseconds = 0;
108
+ for (const part of relative[1].matchAll(/(\d+)\s*([dhms])/gi)) {
109
+ totalMilliseconds += Number.parseInt(part[1], 10) * unitMilliseconds[part[2].toLowerCase()];
110
+ }
111
+ if (totalMilliseconds > 0)
112
+ return new Date(observedAt.getTime() + totalMilliseconds);
113
+ }
114
+ const timeOnly = output.match(/(?:\bresets?(?:\s+at)?|\b(?:retry|try)\s+again\s+at)\s+(\d{1,2}):(\d{2})\s*(am|pm)?(?:\s*\(([^)]+)\)|\s+(UTC|GMT|JST|(?:UTC|GMT)?[+-]\d{1,2}(?::?\d{2})?))?/i);
93
115
  if (!timeOnly)
94
116
  return undefined;
95
- const offset = timezoneOffsetMinutes(timeOnly[4] ?? timeOnly[5]);
96
- if (offset === undefined)
97
- return undefined;
117
+ // Provider CLIs commonly omit the timezone for a reset shown in the operator's local time
118
+ // (for example, "try again at 1:29 AM"). In that form use the process-local offset.
119
+ const offset = timezoneOffsetMinutes(timeOnly[4] ?? timeOnly[5]) ?? -observedAt.getTimezoneOffset();
98
120
  let hour = Number.parseInt(timeOnly[1], 10);
99
121
  const minute = Number.parseInt(timeOnly[2], 10);
100
122
  const meridiem = timeOnly[3]?.toLowerCase();
@@ -108,12 +130,38 @@ function parseProviderReset(output, observedAt) {
108
130
  }
109
131
  return nextTimeOfDayUtc(observedAt, hour, minute, offset);
110
132
  }
133
+ const RESUME_HINT_PATTERN = /reset|retry|try\s+again/i;
134
+ // The agent output is the whole transcript: codex exec echoes the prompt and every command output
135
+ // before the limit notice. A first match over the whole text can therefore pick an echoed example
136
+ // such as "resets 4:10am (UTC)" from a config file. Read the resume time per line, starting from
137
+ // the last line, so the provider's own notice at the end wins over earlier echoes.
138
+ function parseResumeTime(output, observedAt) {
139
+ const lines = outputLines(output);
140
+ for (let index = lines.length - 1; index >= 0; index--) {
141
+ const line = lines[index];
142
+ if (!RESUME_HINT_PATTERN.test(line))
143
+ continue;
144
+ const retryAfter = parseRetryAfter(line, observedAt);
145
+ if (retryAfter)
146
+ return { retryAfter };
147
+ const providerReset = parseProviderReset(line, observedAt);
148
+ if (providerReset)
149
+ return { providerReset };
150
+ }
151
+ return {};
152
+ }
111
153
  export function normalizeAgentLimit(input) {
112
154
  const observedAt = input.observedAt ?? new Date();
113
155
  const kind = limitKind(input.output);
114
- const retryableKind = kind !== "quota_exhausted";
115
- const retryAfter = retryableKind ? parseRetryAfter(input.output, observedAt) : undefined;
116
- const providerReset = retryableKind ? parseProviderReset(input.output, observedAt) : undefined;
156
+ const { retryAfter: parsedRetryAfter, providerReset: parsedProviderReset } = parseResumeTime(input.output, observedAt);
157
+ // A quota/usage limit is normally not safe to auto-resume, but an explicit future retry/reset
158
+ // supplied by the provider is authoritative. Vague text such as "resets tomorrow" remains
159
+ // non-retryable and does not pick up a configured cooldown.
160
+ const retryableKind = kind !== "quota_exhausted" ||
161
+ parsedRetryAfter !== undefined ||
162
+ parsedProviderReset !== undefined;
163
+ const retryAfter = retryableKind ? parsedRetryAfter : undefined;
164
+ const providerReset = retryableKind ? parsedProviderReset : undefined;
117
165
  const configuredCooldown = input.cooldownSeconds?.[kind];
118
166
  const cooldown = retryableKind &&
119
167
  configuredCooldown !== undefined &&
@@ -143,6 +191,39 @@ export function normalizeAgentLimit(input) {
143
191
  ...(resumeSource ? { resume_source: resumeSource } : {}),
144
192
  };
145
193
  }
194
+ // Decide whether a pinned agent waits for its limit reset. Each skip reason has its own message so
195
+ // the run log tells an unreadable reset time apart from one that is too far away.
196
+ export function decidePinnedWait(limit, now, maxWaitSeconds) {
197
+ const limitLine = limit?.raw_message ?? "-";
198
+ const resumeAt = limit?.resume_at ? new Date(limit.resume_at) : undefined;
199
+ if (!resumeAt || Number.isNaN(resumeAt.getTime())) {
200
+ return {
201
+ action: "skip",
202
+ reason: "unreadable",
203
+ message: "Pinned-agent wait skipped: resume time could not be read from the agent output. " +
204
+ `Limit line: ${limitLine}`,
205
+ };
206
+ }
207
+ const source = limit?.resume_source ?? "unknown";
208
+ const waitMilliseconds = resumeAt.getTime() - now.getTime();
209
+ if (waitMilliseconds < 0) {
210
+ return {
211
+ action: "skip",
212
+ reason: "past",
213
+ message: `Pinned-agent wait skipped: resume time ${resumeAt.toISOString()} (${source}) ` +
214
+ `has already passed. Limit line: ${limitLine}`,
215
+ };
216
+ }
217
+ if (waitMilliseconds > maxWaitSeconds * 1000) {
218
+ return {
219
+ action: "skip",
220
+ reason: "exceeds",
221
+ message: `Pinned-agent wait skipped: resume time ${resumeAt.toISOString()} (${source}) is ` +
222
+ `${Math.ceil(waitMilliseconds / 1000)}s away and exceeds the limit of ${maxWaitSeconds}s.`,
223
+ };
224
+ }
225
+ return { action: "wait", resumeAt, waitMilliseconds };
226
+ }
146
227
  function metaString(meta, key) {
147
228
  const value = meta?.[key];
148
229
  return typeof value === "string" ? value : undefined;
@@ -1,9 +1,9 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { join } from "node:path";
3
- import { gitEnvironment } from "./exec-worktree.js";
4
- import { acquirePoolSlot, getActiveExecLocksDir, releaseLock } from "./exec-slot-lock.js";
5
- import { redactSensitiveText } from "./exec-evidence.js";
6
- import { PROJECT_REPO_WORKTREE_DIRNAME, REPO_NAME_PATTERN } from "./specdojo-config.js";
3
+ import { gitEnvironment } from "./worktree.js";
4
+ import { acquirePoolSlot, getActiveExecLocksDir, releaseLock } from "./slot-lock.js";
5
+ import { redactSensitiveText } from "./evidence.js";
6
+ import { PROJECT_REPO_WORKTREE_DIRNAME, REPO_NAME_PATTERN } from "../shared/specdojo-config.js";
7
7
  export const MAX_PARENT_VALIDATION_STREAM_BYTES = 1024 * 1024;
8
8
  const MAX_SUMMARY_LENGTH = 1_000;
9
9
  const CAPTURE_MARKER_RESERVE_BYTES = 256;
@@ -1,6 +1,6 @@
1
1
  import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
2
2
  import { dirname, join, relative, resolve, sep } from "node:path";
3
- import { ensureDir, safeSlug } from "./exec-shared.js";
3
+ import { ensureDir, safeSlug } from "./shared.js";
4
4
  function emptyStage(actor) {
5
5
  return {
6
6
  status: "pending",
@@ -39,6 +39,19 @@ function isStageState(value) {
39
39
  if (!value || typeof value !== "object" || Array.isArray(value))
40
40
  return false;
41
41
  const stage = value;
42
+ const events = stage.rate_limit_events;
43
+ const validEvents = events === undefined ||
44
+ (Array.isArray(events) &&
45
+ events.every((event) => {
46
+ if (!event || typeof event !== "object" || Array.isArray(event))
47
+ return false;
48
+ const record = event;
49
+ return ((record.action === "wait" || record.action === "fallback") &&
50
+ typeof record.from_actor === "string" &&
51
+ typeof record.to_actor === "string" &&
52
+ typeof record.resumed_at === "string" &&
53
+ (record.resume_at === undefined || typeof record.resume_at === "string"));
54
+ }));
42
55
  return ((stage.status === "pending" ||
43
56
  stage.status === "running" ||
44
57
  stage.status === "succeeded" ||
@@ -50,7 +63,8 @@ function isStageState(value) {
50
63
  stage.attempts >= 0 &&
51
64
  (typeof stage.started_at === "string" || stage.started_at === null) &&
52
65
  (typeof stage.completed_at === "string" || stage.completed_at === null) &&
53
- (typeof stage.artifact_ref === "string" || stage.artifact_ref === null));
66
+ (typeof stage.artifact_ref === "string" || stage.artifact_ref === null) &&
67
+ validEvents);
54
68
  }
55
69
  function isRepoIntegrationState(value) {
56
70
  if (!value || typeof value !== "object" || Array.isArray(value))