specdojo 0.7.0 → 0.8.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.
- package/.github/agents/specdojo-orchestrator.md +3 -2
- package/CHANGELOG.md +153 -0
- package/dist/catalog/build.js +24 -1
- package/dist/catalog/plan.js +1 -1
- package/dist/catalog/scaffold.js +4 -1
- package/dist/commands/init.js +5 -1
- package/dist/commands/night-orchestrator.js +6 -4
- package/dist/dashboard/dashboard-timeline.js +18 -16
- package/dist/dashboard/dashboard.js +612 -259
- package/dist/dashboard/epic-plan.js +81 -0
- package/dist/dashboard/exec-records.js +16 -20
- package/dist/dashboard/routines.js +8 -6
- package/dist/dashboard/timeline-build.js +5 -9
- package/dist/dashboard/timeline.js +9 -4
- package/dist/devcontainer/scaffold.js +18 -0
- package/dist/docs/frontmatter-namespace.js +1 -48
- package/dist/docs/yaml-pages.js +125 -3
- package/dist/exec/agent-config.js +22 -0
- package/dist/exec/agent-plan.js +3 -2
- package/dist/exec/commands.js +69 -21
- package/dist/exec/commit-hook-skips.js +78 -0
- package/dist/exec/core.js +19 -7
- package/dist/exec/events.js +159 -8
- package/dist/exec/evidence.js +64 -16
- package/dist/exec/handoff.js +9 -13
- package/dist/exec/limit.js +1 -1
- package/dist/exec/mechanical-result.js +45 -0
- package/dist/exec/migrate-records.js +249 -0
- package/dist/exec/parent-validation.js +153 -12
- package/dist/exec/pipeline-state.js +27 -5
- package/dist/exec/plans-condense-findings.js +89 -0
- package/dist/exec/plans-core.js +24 -17
- package/dist/exec/plans-generation.js +48 -25
- package/dist/exec/plans-grade-findings.js +8 -3
- package/dist/exec/plans-kata-findings.js +61 -0
- package/dist/exec/plans-planning.js +3 -3
- package/dist/exec/plans-storage.js +12 -24
- package/dist/exec/register-resume.js +55 -56
- package/dist/exec/register.js +26 -22
- package/dist/exec/repo-integration-sync.js +8 -4
- package/dist/exec/repo-integration.js +21 -1
- package/dist/exec/reporter.js +121 -23
- package/dist/exec/results.js +85 -24
- package/dist/exec/review-completion.js +47 -0
- package/dist/exec/review-kata.js +109 -0
- package/dist/exec/run/agent-pipeline.js +75 -6
- package/dist/exec/run/agent.js +20 -7
- package/dist/exec/run/in-place.js +69 -32
- package/dist/exec/run/job.js +81 -24
- package/dist/exec/run/lifecycle-commands.js +188 -36
- package/dist/exec/run/mode-shared.js +11 -3
- package/dist/exec/run/register-command.js +6 -10
- package/dist/exec/run/register-core.js +20 -13
- package/dist/exec/run/register-mode.js +12 -12
- package/dist/exec/run/register-post-review.js +21 -9
- package/dist/exec/run/register-resume.js +28 -18
- package/dist/exec/run/register-state.js +10 -7
- package/dist/exec/run/register-worktree.js +60 -30
- package/dist/exec/run/schedule-mode.js +4 -4
- package/dist/exec/run/schedule-prepare.js +201 -59
- package/dist/exec/run/schedule-task.js +129 -25
- package/dist/exec/run/shared.js +4 -3
- package/dist/exec/run/trailing-records.js +35 -0
- package/dist/exec/run-records.js +2 -0
- package/dist/exec/strategy.js +1 -0
- package/dist/exec/trailing-records.js +242 -0
- package/dist/exec/trial-commands.js +3 -2
- package/dist/exec/validate-records-commit.js +110 -0
- package/dist/exec/validate-records.js +148 -0
- package/dist/exec/worktree-command.js +29 -16
- package/dist/exec/worktree-ops-commit.js +119 -48
- package/dist/exec/worktree-ops-lifecycle.js +77 -48
- package/dist/exec/worktree-ops-merge.js +13 -2
- package/dist/exec/worktree-ops.js +2 -2
- package/dist/exec/worktree.js +19 -2
- package/dist/grade/apply.js +32 -6
- package/dist/grade/command-inspect.js +2 -2
- package/dist/grade/command-run.js +2 -0
- package/dist/grade/command-shared.js +1 -1
- package/dist/grade/core.js +18 -5
- package/dist/grade/markdown.js +3 -3
- package/dist/grade/pipeline-state.js +15 -11
- package/dist/grade/plan.js +37 -17
- package/dist/grade/result.js +3 -3
- package/dist/grade/run.js +23 -3
- package/dist/grade/target-discovery.js +17 -4
- package/dist/grade/targets.js +12 -11
- package/dist/job/job.js +31 -17
- package/dist/job/noop.js +104 -0
- package/dist/register/core.js +2 -0
- package/dist/register/create-commands.js +28 -3
- package/dist/register/deliverable-target.js +9 -1
- package/dist/register/epic.js +104 -26
- package/dist/register/event-merge.js +3 -0
- package/dist/register/events.js +4 -0
- package/dist/register/external-project.js +3 -0
- package/dist/register/item.js +6 -0
- package/dist/register/maintenance-commands.js +4 -1
- package/dist/register/planning.js +7 -14
- package/dist/register/register.js +43 -9
- package/dist/register/track-domains.js +34 -0
- package/dist/register/track-plan.js +78 -0
- package/dist/register/transition-commands.js +8 -0
- package/dist/register/work-table.js +64 -0
- package/dist/review/grade.js +35 -13
- package/dist/routine/definition.js +4 -3
- package/dist/routine/failure.js +30 -0
- package/dist/routine/routine.js +56 -32
- package/dist/routine/storage.js +33 -0
- package/dist/schedule/schedule.js +1 -0
- package/dist/schedule/strategy-generate-document.js +26 -14
- package/dist/schedule/strategy-generate-scope.js +17 -45
- package/dist/schedule/strategy-generate.js +33 -3
- package/dist/schedule/strategy-profiles.js +86 -12
- package/dist/shared/agent-types.js +2 -0
- package/dist/shared/condense-records.js +25 -0
- package/dist/shared/deprecation.js +8 -0
- package/dist/shared/document-metadata.js +20 -0
- package/dist/shared/finding-cause.js +20 -0
- package/dist/shared/frontmatter-namespace.js +48 -0
- package/dist/shared/git.js +142 -15
- package/dist/shared/grade-result.js +17 -1
- package/dist/shared/local-state.js +20 -0
- package/dist/shared/markdownlint-config.js +8 -3
- package/dist/shared/plan-conventions.js +129 -0
- package/dist/shared/plan-templates.js +57 -41
- package/dist/shared/run-records.js +224 -0
- package/dist/shared/specdojo-config.js +39 -21
- package/dist/shared/text.js +65 -5
- package/dist/shared/timeline-index.js +2 -0
- package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +9 -2
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +4 -74
- package/docs/ja/specdojo/exec-templates/xep-condense-template.md +50 -0
- package/docs/ja/specdojo/exec-templates/xep-draft-template.md +17 -5
- package/docs/ja/specdojo/exec-templates/xep-fully-guided-template.md +16 -3
- package/docs/ja/specdojo/exec-templates/xep-recipe-guided-template.md +15 -5
- package/docs/ja/specdojo/exec-templates/xep-recipe-maintenance-template.md +6 -0
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +1 -1
- package/docs/ja/specdojo/exec-templates/xep-rulebook-maintenance-template.md +6 -0
- package/docs/ja/specdojo/exec-templates/xep-sample-maintenance-template.md +6 -0
- package/docs/ja/specdojo/exec-templates/xep-template-maintenance-template.md +6 -0
- package/docs/ja/specdojo/exec-templates/xer-condense-template.md +25 -0
- package/docs/ja/specdojo/exec-templates/xp-common-conventions-template.md +50 -0
- package/docs/ja/specdojo/exec-templates/xrp-common-conventions-template.md +30 -0
- package/docs/ja/specdojo/guides/branch-workflow-guide.md +1 -1
- package/docs/ja/specdojo/guides/docs-editing-guide.md +12 -0
- package/docs/ja/specdojo/guides/docs-structure-guide.md +48 -15
- package/docs/ja/specdojo/guides/exec-config-guide.md +47 -16
- package/docs/ja/specdojo/guides/exec-operation-guide.md +53 -17
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +20 -11
- package/docs/ja/specdojo/guides/plan-result-lifecycle-guide.md +92 -55
- package/docs/ja/specdojo/guides/project-move-guide.md +381 -0
- package/docs/ja/specdojo/guides/quick-start-guide.md +70 -14
- package/docs/ja/specdojo/guides/register-operation-guide.md +25 -5
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +2 -0
- package/docs/ja/specdojo/guides/review-guide.md +22 -19
- package/docs/ja/specdojo/guides/routine-operation-guide.md +14 -8
- package/docs/ja/specdojo/guides/ryu-guide.md +23 -13
- package/docs/ja/specdojo/guides/schedule-design-guide.md +7 -4
- package/docs/ja/specdojo/guides/schedule-operation-guide.md +27 -3
- package/docs/ja/specdojo/guides/specdojo-overview-guide.md +5 -4
- package/docs/ja/specdojo/guides/timeline-design-guide.md +27 -144
- package/docs/ja/specdojo/guides/use-case-guide.md +92 -155
- package/docs/ja/specdojo/recipes/bac-recipe.md +94 -0
- package/docs/ja/specdojo/recipes/bes-recipe.md +105 -0
- package/docs/ja/specdojo/recipes/br-recipe.md +84 -0
- package/docs/ja/specdojo/recipes/cdfd-uc-recipe.md +36 -24
- package/docs/ja/specdojo/recipes/cnd-recipe.md +125 -0
- package/docs/ja/specdojo/recipes/cpd-recipe.md +126 -0
- package/docs/ja/specdojo/recipes/cxd-recipe.md +145 -0
- package/docs/ja/specdojo/recipes/ifd-recipe.md +134 -0
- package/docs/ja/specdojo/recipes/ifx-cmd-recipe.md +135 -86
- package/docs/ja/specdojo/recipes/ifx-index-recipe.md +130 -0
- package/docs/ja/specdojo/recipes/pm-organization-recipe.md +29 -26
- package/docs/ja/specdojo/recipes/pm-plan-recipe.md +35 -26
- package/docs/ja/specdojo/recipes/pm-quality-management-plan-recipe.md +38 -28
- package/docs/ja/specdojo/recipes/pm-raci-recipe.md +39 -31
- package/docs/ja/specdojo/recipes/pm-roles-recipe.md +26 -28
- package/docs/ja/specdojo/recipes/prj-assumptions-constraints-dependencies-recipe.md +10 -8
- package/docs/ja/specdojo/recipes/prj-comparison-of-alternatives-recipe.md +18 -17
- package/docs/ja/specdojo/recipes/stsd-recipe.md +100 -62
- package/docs/ja/specdojo/recipes/sysd-critical-flows-recipe.md +106 -0
- package/docs/ja/specdojo/recipes/sysd-cross-cutting-policy-recipe.md +137 -0
- package/docs/ja/specdojo/recipes/sysd-index-recipe.md +122 -0
- package/docs/ja/specdojo/references/command-reference.md +79 -64
- package/docs/ja/specdojo/references/deliverables-reference.md +9 -4
- package/docs/ja/specdojo/references/directory-layout-reference.md +3 -2
- package/docs/ja/specdojo/references/specdojo-config-reference.md +17 -16
- package/docs/ja/specdojo/rulebooks/bac-rulebook.md +72 -290
- package/docs/ja/specdojo/rulebooks/bdd-rulebook.md +212 -79
- package/docs/ja/specdojo/rulebooks/bds-rulebook.md +138 -154
- package/docs/ja/specdojo/rulebooks/bes-index-rulebook.md +147 -59
- package/docs/ja/specdojo/rulebooks/bes-rulebook.md +100 -96
- package/docs/ja/specdojo/rulebooks/br-rulebook.md +88 -108
- package/docs/ja/specdojo/rulebooks/ccd-mermaid-rulebook.md +126 -211
- package/docs/ja/specdojo/rulebooks/cdfd-uc-rulebook.md +56 -35
- package/docs/ja/specdojo/rulebooks/cdsd-rulebook.md +102 -68
- package/docs/ja/specdojo/rulebooks/cdt-rulebook.md +152 -0
- package/docs/ja/specdojo/rulebooks/cld-rulebook.md +9 -184
- package/docs/ja/specdojo/rulebooks/clis-rulebook.md +187 -0
- package/docs/ja/specdojo/rulebooks/cnd-rulebook.md +93 -247
- package/docs/ja/specdojo/rulebooks/cpd-rulebook.md +104 -241
- package/docs/ja/specdojo/rulebooks/cxd-rulebook.md +124 -257
- package/docs/ja/specdojo/rulebooks/dct-index-rulebook.md +87 -98
- package/docs/ja/specdojo/rulebooks/dct-rulebook.md +9 -7
- package/docs/ja/specdojo/rulebooks/dec-rulebook.md +2 -1
- package/docs/ja/specdojo/rulebooks/dss-rulebook.md +193 -0
- package/docs/ja/specdojo/rulebooks/gl-rulebook.md +100 -54
- package/docs/ja/specdojo/rulebooks/ifd-mermaid-rulebook.md +69 -252
- package/docs/ja/specdojo/rulebooks/ifx-cmd-rulebook.md +91 -76
- package/docs/ja/specdojo/rulebooks/ifx-file-rulebook.md +252 -226
- package/docs/ja/specdojo/rulebooks/ifx-index-rulebook.md +118 -40
- package/docs/ja/specdojo/rulebooks/imp-business-rulebook.md +11 -11
- package/docs/ja/specdojo/rulebooks/imp-data-rulebook.md +9 -9
- package/docs/ja/specdojo/rulebooks/imp-interface-rulebook.md +4 -4
- package/docs/ja/specdojo/rulebooks/imp-operations-rulebook.md +11 -11
- package/docs/ja/specdojo/rulebooks/imp-test-rulebook.md +11 -11
- package/docs/ja/specdojo/rulebooks/mm-rulebook.md +4 -3
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +34 -29
- package/docs/ja/specdojo/rulebooks/pm-change-request-log-rulebook.md +8 -8
- package/docs/ja/specdojo/rulebooks/pm-issue-log-rulebook.md +2 -2
- package/docs/ja/specdojo/rulebooks/pm-organization-rulebook.md +50 -56
- package/docs/ja/specdojo/rulebooks/pm-plan-rulebook.md +46 -55
- package/docs/ja/specdojo/rulebooks/pm-quality-management-plan-rulebook.md +57 -54
- package/docs/ja/specdojo/rulebooks/pm-raci-rulebook.md +50 -65
- package/docs/ja/specdojo/rulebooks/pm-risk-register-rulebook.md +2 -2
- package/docs/ja/specdojo/rulebooks/pm-roles-rulebook.md +70 -97
- package/docs/ja/specdojo/rulebooks/pr-rulebook.md +2 -1
- package/docs/ja/specdojo/rulebooks/prj-assumptions-constraints-dependencies-rulebook.md +47 -56
- package/docs/ja/specdojo/rulebooks/prj-comparison-of-alternatives-rulebook.md +61 -135
- package/docs/ja/specdojo/rulebooks/sf-index-rulebook.md +116 -32
- package/docs/ja/specdojo/rulebooks/sf-rulebook.md +118 -61
- package/docs/ja/specdojo/rulebooks/sld-rulebook.md +152 -57
- package/docs/ja/specdojo/rulebooks/stsd-mermaid-rulebook.md +51 -39
- package/docs/ja/specdojo/rulebooks/stsd-rulebook.md +101 -46
- package/docs/ja/specdojo/rulebooks/sysd-critical-flows-rulebook.md +72 -329
- package/docs/ja/specdojo/rulebooks/sysd-cross-cutting-policy-rulebook.md +74 -263
- package/docs/ja/specdojo/rulebooks/sysd-index-rulebook.md +78 -195
- package/docs/ja/specdojo/rulebooks/tml-rulebook.md +4 -9
- package/docs/ja/specdojo/rulebooks/trc-requirements-to-specs-rulebook.md +3 -4
- package/docs/ja/specdojo/rulebooks/trc-requirements-to-tests-rulebook.md +3 -3
- package/docs/ja/specdojo/rulebooks/uis-rulebook.md +140 -143
- package/docs/ja/specdojo/samples/bac-sample.md +106 -21
- package/docs/ja/specdojo/samples/bdd-sample.yaml +143 -35
- package/docs/ja/specdojo/samples/bds-sample.md +100 -21
- package/docs/ja/specdojo/samples/bes-index-sample.md +59 -20
- package/docs/ja/specdojo/samples/bes-sample.md +80 -21
- package/docs/ja/specdojo/samples/br-sample.md +68 -14
- package/docs/ja/specdojo/samples/ccd-sample.md +81 -19
- package/docs/ja/specdojo/samples/cdfd-sample.md +172 -99
- package/docs/ja/specdojo/samples/cdfd-uc-sample.md +9 -7
- package/docs/ja/specdojo/samples/cdsd-sample.md +89 -20
- package/docs/ja/specdojo/samples/cdt-sample.md +116 -0
- package/docs/ja/specdojo/samples/cld-sample.md +3 -30
- package/docs/ja/specdojo/samples/clis-sample.md +132 -0
- package/docs/ja/specdojo/samples/cnd-sample.md +127 -21
- package/docs/ja/specdojo/samples/cpd-sample.md +136 -22
- package/docs/ja/specdojo/samples/cxd-sample.md +108 -22
- package/docs/ja/specdojo/samples/dct-index-sample.yaml +63 -17
- package/docs/ja/specdojo/samples/dss-sample.md +175 -0
- package/docs/ja/specdojo/samples/gl-sample.yaml +50 -14
- package/docs/ja/specdojo/samples/ifd-sample.md +105 -21
- package/docs/ja/specdojo/samples/ifx-cmd-sample.yaml +91 -60
- package/docs/ja/specdojo/samples/ifx-file-sample.md +462 -21
- package/docs/ja/specdojo/samples/ifx-index-sample.yaml +87 -19
- package/docs/ja/specdojo/samples/pm-members-sample.yaml +37 -13
- package/docs/ja/specdojo/samples/pm-organization-sample.md +52 -20
- package/docs/ja/specdojo/samples/pm-plan-sample.md +84 -26
- package/docs/ja/specdojo/samples/pm-quality-management-plan-sample.md +55 -22
- package/docs/ja/specdojo/samples/pm-raci-sample.md +69 -28
- package/docs/ja/specdojo/samples/pm-roles-sample.yaml +13 -12
- package/docs/ja/specdojo/samples/prj-assumptions-constraints-dependencies-sample.md +50 -26
- package/docs/ja/specdojo/samples/prj-comparison-of-alternatives-sample.md +89 -62
- package/docs/ja/specdojo/samples/sf-index-sample.md +89 -20
- package/docs/ja/specdojo/samples/sf-sample.md +121 -21
- package/docs/ja/specdojo/samples/sld-sample.md +107 -21
- package/docs/ja/specdojo/samples/stsd-sample.md +54 -26
- package/docs/ja/specdojo/samples/sysd-critical-flows-sample.md +166 -21
- package/docs/ja/specdojo/samples/sysd-cross-cutting-policy-sample.md +178 -21
- package/docs/ja/specdojo/samples/sysd-index-sample.md +82 -21
- package/docs/ja/specdojo/samples/tml-sample.yaml +4 -1
- package/docs/ja/specdojo/samples/uis-sample.md +164 -20
- package/docs/ja/specdojo/standards/document-metadata-standard.md +33 -4
- package/docs/ja/specdojo/standards/id-and-file-naming-standard.md +3 -1
- package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +1 -0
- package/docs/ja/specdojo/templates/bac-template.md +76 -0
- package/docs/ja/specdojo/templates/bes-template.md +56 -0
- package/docs/ja/specdojo/templates/br-template.md +64 -0
- package/docs/ja/specdojo/templates/cdfd-template.md +81 -54
- package/docs/ja/specdojo/templates/cdfd-uc-template.md +9 -5
- package/docs/ja/specdojo/templates/cnd-template.md +137 -0
- package/docs/ja/specdojo/templates/cpd-template.md +129 -0
- package/docs/ja/specdojo/templates/cxd-template.md +105 -0
- package/docs/ja/specdojo/templates/dct-data-model-cdt-template.yaml +40 -0
- package/docs/ja/specdojo/templates/dct-data-model-cld-template.yaml +7 -14
- package/docs/ja/specdojo/templates/dct-index-template.md +9 -20
- package/docs/ja/specdojo/templates/dct-project-management-template.yaml +5 -1
- package/docs/ja/specdojo/templates/ifd-template.md +86 -0
- package/docs/ja/specdojo/templates/ifx-cmd-template.yaml +44 -28
- package/docs/ja/specdojo/templates/ifx-index-template.yaml +40 -0
- package/docs/ja/specdojo/templates/opr-template.md +2 -4
- package/docs/ja/specdojo/templates/pm-organization-template.md +9 -3
- package/docs/ja/specdojo/templates/pm-plan-template.md +4 -4
- package/docs/ja/specdojo/templates/pm-quality-management-plan-template.md +17 -9
- package/docs/ja/specdojo/templates/pm-raci-template.md +24 -13
- package/docs/ja/specdojo/templates/pm-roles-template.yaml +3 -2
- package/docs/ja/specdojo/templates/prj-assumptions-constraints-dependencies-template.md +6 -3
- package/docs/ja/specdojo/templates/prj-comparison-of-alternatives-template.md +22 -19
- package/docs/ja/specdojo/templates/stsd-template.md +46 -21
- package/docs/ja/specdojo/templates/sysd-critical-flows-template.md +94 -0
- package/docs/ja/specdojo/templates/sysd-cross-cutting-policy-template.md +122 -0
- package/docs/ja/specdojo/templates/sysd-index-template.md +89 -0
- package/docs/specdojo/lib/yaml-metadata.cjs +7 -0
- package/docs/specdojo/schemas/v1/bdd.schema.yaml +25 -57
- package/docs/specdojo/schemas/v1/condense-records.schema.yaml +26 -0
- package/docs/specdojo/schemas/v1/dct.schema.yaml +10 -0
- package/docs/specdojo/schemas/v1/deliverable-frontmatter.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/esil.schema.yaml +7 -141
- package/docs/specdojo/schemas/v1/exec-common.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +53 -3
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/exec-plan-frontmatter.schema.yaml +14 -0
- package/docs/specdojo/schemas/v1/exec-result-frontmatter.schema.yaml +18 -0
- package/docs/specdojo/schemas/v1/finding-cause.schema.yaml +22 -0
- package/docs/specdojo/schemas/v1/grade-pipeline-state.schema.yaml +1 -1
- package/docs/specdojo/schemas/v1/grade-result.schema.yaml +2 -0
- package/docs/specdojo/schemas/v1/ifx-cmd.schema.yaml +65 -5
- package/docs/specdojo/schemas/v1/ifx-index.schema.yaml +142 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +2 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +17 -1
- package/package.json +2 -2
- package/templates/antigravity/orchestrator.md +3 -2
- package/templates/claude/agents/specdojo-orchestrator.md +3 -2
- package/templates/codex/agents/specdojo-orchestrator.toml +3 -2
- package/templates/codex/orchestrator.md +3 -2
- package/templates/devcontainer/tmux.conf +6 -0
- package/templates/opencode/agents/specdojo-orchestrator.md +3 -2
package/dist/exec/run/job.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
+
import { readPlanFile } from "../../shared/plan-conventions.js";
|
|
1
2
|
import { spawnSync } from "node:child_process";
|
|
2
3
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
4
|
import { relative, resolve, sep } from "node:path";
|
|
5
|
+
import { completeJobRun, executeJobCommand, generateJobReviewPlan, isJobCommandTask, jobRunUsesReviewedIntegration, loadJobDefinition, loadJobRunRecord, materializeJobRun, recordJobRunReview, resolveJobPaths, resolveJobReviewAgentNominations, } from "../../job/job.js";
|
|
4
6
|
import { selfRunArgs } from "../../shared/spawn-self.js";
|
|
7
|
+
import { specdojoRootDir } from "../../shared/specdojo-config.js";
|
|
5
8
|
import { loadExecDefaultsConfig, resolveMemberCommand, } from "../agent-config.js";
|
|
9
|
+
import { recordCommandEvidence } from "../evidence.js";
|
|
10
|
+
import { formatMarkdownFile } from "../format.js";
|
|
11
|
+
import { createPipelineState, pipelineStateLocation, updatePipelineStage, writePipelineState, } from "../pipeline-state.js";
|
|
6
12
|
import { activateResolvedProjectPaths, resolveProjectPaths } from "../project.js";
|
|
7
|
-
import {
|
|
8
|
-
import { ROUTINE_BUSY_SKIP_EXIT_CODE, ROUTINE_EXEC_ENV } from "./lock.js";
|
|
13
|
+
import { evidenceForReporter } from "../reporter.js";
|
|
9
14
|
import { isResultUnfilled, readResultFrontmatterSnapshot, renderReporterResult, scaffoldResult, stripLeadingListMarker, updateResultStatus, } from "../results.js";
|
|
10
|
-
import {
|
|
11
|
-
import { completeJobRun, executeJobCommand, generateJobReviewPlan, isJobCommandTask, jobRunUsesReviewedIntegration, loadJobDefinition, loadJobRunRecord, materializeJobRun, recordJobRunReview, resolveJobPaths, resolveJobReviewAgentNominations, } from "../../job/job.js";
|
|
12
|
-
import { ensureExecWorktree, formatGitResultFailure, gitOutput, gitResult, resolveWorktreeBase, summarizeGitHookFailure, } from "../worktree.js";
|
|
15
|
+
import { taskRecordPrefixes } from "../run-records.js";
|
|
13
16
|
import { mergeWorktreeIntoCurrent, removeWorktree, stabilizeCommitTargets, stageCommitTargets, worktreeStatusPaths, } from "../worktree-ops.js";
|
|
14
|
-
import {
|
|
15
|
-
import { evidenceForReporter } from "../reporter.js";
|
|
16
|
-
import { createPipelineState, pipelineStateLocation, updatePipelineStage, writePipelineState, } from "../pipeline-state.js";
|
|
17
|
-
import { configuredWorktreeBase, resolveAgentOverride, resolveExecDefaultsPath, selectCandidates, } from "./shared.js";
|
|
18
|
-
import { executorRequirements, expandPromptRefs, loadRosterForExecutionPath, resolveReporterAgentCandidates, } from "./agent.js";
|
|
17
|
+
import { ensureExecWorktree, formatGitResultFailure, gitEnvironment, gitOutput, gitResult, resolveWorktreeBase, summarizeGitHookFailure, } from "../worktree.js";
|
|
19
18
|
import { runAgentPipeline, runReporterStage } from "./agent-pipeline.js";
|
|
19
|
+
import { executorRequirements, expandPromptRefs, loadRosterForExecutionPath, resolveReporterAgentCandidates, } from "./agent.js";
|
|
20
20
|
import { resolveInPlaceCommand, spawnAgentInPlace } from "./in-place.js";
|
|
21
|
+
import { ROUTINE_BUSY_SKIP_EXIT_CODE, ROUTINE_EXEC_ENV } from "./lock.js";
|
|
22
|
+
import { configuredWorktreeBase, resolveAgentOverride, resolveExecDefaultsPath, selectCandidates, } from "./shared.js";
|
|
23
|
+
import { localJobNoopPath, snapshotJobOutput } from "../../job/noop.js";
|
|
21
24
|
async function runCommandJobMode(params) {
|
|
22
25
|
const { opts, record, runPath, planPath, projectId, schedulePath, executionPath } = params;
|
|
23
26
|
if (!isJobCommandTask(record.task))
|
|
@@ -77,7 +80,7 @@ async function runCommandJobMode(params) {
|
|
|
77
80
|
startedAt: new Date().toISOString(),
|
|
78
81
|
...(record.task.targets ? { targets: record.task.targets } : {}),
|
|
79
82
|
});
|
|
80
|
-
const evidenceRunId =
|
|
83
|
+
const evidenceRunId = record.run_id;
|
|
81
84
|
process.stdout.write(`Running Job Run ${record.run_id} command in place.\n`);
|
|
82
85
|
const commandOutcome = await executeJobCommand(record.task.command, repoRoot);
|
|
83
86
|
const commandPartial = !commandOutcome.error &&
|
|
@@ -149,14 +152,12 @@ async function runCommandJobMode(params) {
|
|
|
149
152
|
}
|
|
150
153
|
else if (commandPartial) {
|
|
151
154
|
process.stdout.write(`Job Run partial: ${record.run_id}\n`);
|
|
152
|
-
if (record.trigger === "routine") {
|
|
153
|
-
process.stdout.write(`[routine-job] complete run_id=${record.run_id} state=partial\n`);
|
|
154
|
-
}
|
|
155
155
|
}
|
|
156
156
|
else {
|
|
157
157
|
process.stdout.write(`Job Run failed: ${record.run_id}\n`);
|
|
158
158
|
process.exitCode = commandOutcome.exitCode || 1;
|
|
159
159
|
}
|
|
160
|
+
process.stdout.write(`[routine-job] complete run_id=${record.run_id} state=${commandSucceeded ? "succeeded" : commandPartial ? "partial" : "failed"}\n`);
|
|
160
161
|
return;
|
|
161
162
|
}
|
|
162
163
|
const stateLocation = pipelineStateLocation({
|
|
@@ -191,7 +192,7 @@ async function runCommandJobMode(params) {
|
|
|
191
192
|
schedulePath,
|
|
192
193
|
executionPath,
|
|
193
194
|
reporterCandidates: [analysisCandidate],
|
|
194
|
-
planPrompt: expandPromptRefs(
|
|
195
|
+
planPrompt: expandPromptRefs(readPlanFile(planPath)),
|
|
195
196
|
resultPath,
|
|
196
197
|
execDefaults,
|
|
197
198
|
evidence: recorded.evidence,
|
|
@@ -211,14 +212,12 @@ async function runCommandJobMode(params) {
|
|
|
211
212
|
});
|
|
212
213
|
if (reporterOutcome.exitCode === 0) {
|
|
213
214
|
process.stdout.write(`Job Run ${commandPartial ? "partial" : "complete"}: ${record.run_id}\n`);
|
|
214
|
-
if (commandPartial && record.trigger === "routine") {
|
|
215
|
-
process.stdout.write(`[routine-job] complete run_id=${record.run_id} state=partial\n`);
|
|
216
|
-
}
|
|
217
215
|
}
|
|
218
216
|
else {
|
|
219
217
|
process.stdout.write(`Job Run failed: ${record.run_id}\n`);
|
|
220
218
|
process.exitCode = 1;
|
|
221
219
|
}
|
|
220
|
+
process.stdout.write(`[routine-job] complete run_id=${record.run_id} state=${reporterOutcome.exitCode === 0 ? (commandPartial ? "partial" : "succeeded") : "failed"}\n`);
|
|
222
221
|
}
|
|
223
222
|
const ACCEPTED_JOB_REVIEW_VERDICTS = new Set(["complete", "complete-with-findings"]);
|
|
224
223
|
function acceptsJobReview(record, verdict) {
|
|
@@ -383,6 +382,8 @@ async function runJobWorktreeMode(opts) {
|
|
|
383
382
|
});
|
|
384
383
|
if (preview.duplicateComplete) {
|
|
385
384
|
process.stdout.write(`Job Run already complete: ${preview.record.run_id} (${preview.record.state})\n`);
|
|
385
|
+
if (preview.record.state === "noop")
|
|
386
|
+
process.stdout.write(`[routine-job] noop state=noop\n`);
|
|
386
387
|
if (trigger === "routine" && preview.record.state === "partial") {
|
|
387
388
|
process.stdout.write(`[routine-job] complete run_id=${preview.record.run_id} state=partial\n`);
|
|
388
389
|
}
|
|
@@ -420,7 +421,7 @@ async function runJobWorktreeMode(opts) {
|
|
|
420
421
|
const child = spawnSync(executable, fullArgs, {
|
|
421
422
|
cwd: worktree.path,
|
|
422
423
|
env: {
|
|
423
|
-
...
|
|
424
|
+
...gitEnvironment(),
|
|
424
425
|
[ROUTINE_EXEC_ENV]: trigger === "routine" ? "1" : "0",
|
|
425
426
|
[JOB_REVIEW_WORKTREE_CHILD_ENV]: "1",
|
|
426
427
|
},
|
|
@@ -441,10 +442,23 @@ async function runJobWorktreeMode(opts) {
|
|
|
441
442
|
const worktreeExecutionPath = resolve(worktree.path, executionRel);
|
|
442
443
|
const worktreeJobPaths = resolveJobPaths(projectId);
|
|
443
444
|
const runPath = resolve(worktree.path, relative(repoRoot, preview.runPath));
|
|
445
|
+
if (child.status === 0 && existsSync(localJobNoopPath(executionPath, preview.record.run_id))) {
|
|
446
|
+
removeWorktree({
|
|
447
|
+
context: { repoRoot, schedulePath, executionPath },
|
|
448
|
+
worktree,
|
|
449
|
+
taskId: `${preview.record.run_id}-review`,
|
|
450
|
+
deleteBranch: true,
|
|
451
|
+
});
|
|
452
|
+
process.stdout.write(`[routine-job] noop state=noop\n`);
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
444
455
|
if (!existsSync(runPath)) {
|
|
445
456
|
throw new Error(`Job Run record was not created in worktree: ${preview.record.run_id}`);
|
|
446
457
|
}
|
|
447
458
|
let record = loadJobRunRecord(runPath);
|
|
459
|
+
// The child may fail before printing a completion marker. Its worktree still owns
|
|
460
|
+
// the diagnostic Run record even if commit or review subsequently fails.
|
|
461
|
+
process.stdout.write(`[routine-job] recorded run_id=${record.run_id} state=${record.state}\n`);
|
|
448
462
|
const outputPaths = worktreeStatusPaths(worktree.path);
|
|
449
463
|
const outputCommit = commitJobPaths(worktree.path, outputPaths, `chore(routine): ${preview.definition.name}`, `Job Run: ${record.run_id}\nState: ${record.state}`);
|
|
450
464
|
const reviewTaskId = `${record.run_id}-review`;
|
|
@@ -491,7 +505,7 @@ async function runJobWorktreeMode(opts) {
|
|
|
491
505
|
executor: agents.executor,
|
|
492
506
|
reporterCandidates: agents.reporterCandidates,
|
|
493
507
|
planPath,
|
|
494
|
-
planPrompt: expandPromptRefs(
|
|
508
|
+
planPrompt: expandPromptRefs(readPlanFile(planPath)),
|
|
495
509
|
resultPath,
|
|
496
510
|
execDefaults,
|
|
497
511
|
mode: "review",
|
|
@@ -527,7 +541,7 @@ async function runJobWorktreeMode(opts) {
|
|
|
527
541
|
process.chdir(originalCwd);
|
|
528
542
|
}
|
|
529
543
|
const allowedReviewPrefixes = [
|
|
530
|
-
|
|
544
|
+
...taskRecordPrefixes(relative(worktree.path, worktreeExecutionPath), reviewTaskId),
|
|
531
545
|
];
|
|
532
546
|
const allowedReviewFiles = new Set([
|
|
533
547
|
relative(worktree.path, planPath).split(sep).join("/"),
|
|
@@ -584,10 +598,9 @@ async function runJobWorktreeMode(opts) {
|
|
|
584
598
|
});
|
|
585
599
|
process.stdout.write(`[routine-job] merged run_id=${record.run_id} state=${record.state} review=${verdict} branch=${worktree.branch}\n`);
|
|
586
600
|
}
|
|
587
|
-
|
|
601
|
+
async function runJobModeUnchecked(opts, resolvePipelineAgents, isWorktreeChild) {
|
|
588
602
|
const resolvedPaths = resolveProjectPaths({ project: opts.project });
|
|
589
603
|
activateResolvedProjectPaths(resolvedPaths);
|
|
590
|
-
const isWorktreeChild = process.env[JOB_REVIEW_WORKTREE_CHILD_ENV] === "1";
|
|
591
604
|
if (!isWorktreeChild) {
|
|
592
605
|
// A Job's task.review declaration takes precedence over the caller: it routes the Run
|
|
593
606
|
// through the reviewed integration path even without --worktree (routine action.commit).
|
|
@@ -624,6 +637,8 @@ export async function runJobMode(opts, resolvePipelineAgents) {
|
|
|
624
637
|
}
|
|
625
638
|
if (materialized.duplicateComplete) {
|
|
626
639
|
process.stdout.write(`Job Run already complete: ${record.run_id} (${record.state})\n`);
|
|
640
|
+
if (record.state === "noop")
|
|
641
|
+
process.stdout.write(`[routine-job] noop state=noop\n`);
|
|
627
642
|
if (trigger === "routine" && record.state === "partial") {
|
|
628
643
|
process.stdout.write(`[routine-job] complete run_id=${record.run_id} state=partial\n`);
|
|
629
644
|
}
|
|
@@ -696,7 +711,7 @@ export async function runJobMode(opts, resolvePipelineAgents) {
|
|
|
696
711
|
...(record.task.targets ? { targets: record.task.targets } : {}),
|
|
697
712
|
});
|
|
698
713
|
const resultScaffold = readResultFrontmatterSnapshot(resultPath);
|
|
699
|
-
const prompt = expandPromptRefs(
|
|
714
|
+
const prompt = expandPromptRefs(readPlanFile(planPath));
|
|
700
715
|
const repoRoot = specdojoRootDir();
|
|
701
716
|
let exitCode;
|
|
702
717
|
let reason;
|
|
@@ -743,4 +758,46 @@ export async function runJobMode(opts, resolvePipelineAgents) {
|
|
|
743
758
|
process.stdout.write(`Job Run failed: ${record.run_id}\n`);
|
|
744
759
|
process.exitCode = effectiveExit || 1;
|
|
745
760
|
}
|
|
761
|
+
process.stdout.write(`[routine-job] complete run_id=${record.run_id} state=${effectiveExit === 0 ? "succeeded" : "failed"}\n`);
|
|
762
|
+
}
|
|
763
|
+
export async function runJobMode(opts, resolvePipelineAgents) {
|
|
764
|
+
const isWorktreeChild = process.env[JOB_REVIEW_WORKTREE_CHILD_ENV] === "1";
|
|
765
|
+
// This marker routes only this Job's re-entry. Preconditions, commands, agents and
|
|
766
|
+
// their tests must choose their own worktree/review mode rather than inherit it.
|
|
767
|
+
delete process.env[JOB_REVIEW_WORKTREE_CHILD_ENV];
|
|
768
|
+
const paths = resolveProjectPaths({ project: opts.project });
|
|
769
|
+
activateResolvedProjectPaths(paths);
|
|
770
|
+
const projectId = paths.projectId ?? opts.project;
|
|
771
|
+
const definition = loadJobDefinition(resolveJobPaths(projectId), String(opts.job).trim());
|
|
772
|
+
if (opts.dryRun ||
|
|
773
|
+
jobRunUsesReviewedIntegration(definition, {
|
|
774
|
+
worktree: opts.worktree,
|
|
775
|
+
isWorktreeChild,
|
|
776
|
+
}) ||
|
|
777
|
+
// In-place command Jobs also support projects without a Git repository. There is
|
|
778
|
+
// nothing to commit there, and no reliable Git diff for suppressing Run records.
|
|
779
|
+
gitResult(specdojoRootDir(), ["rev-parse", "--is-inside-work-tree"]).status !== 0) {
|
|
780
|
+
await runJobModeUnchecked(opts, resolvePipelineAgents, isWorktreeChild);
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
const preview = await materializeJobRun({
|
|
784
|
+
projectId,
|
|
785
|
+
jobId: String(opts.job).trim(),
|
|
786
|
+
inputs: opts.input,
|
|
787
|
+
scheduledAt: opts.scheduledAt,
|
|
788
|
+
dryRun: true,
|
|
789
|
+
});
|
|
790
|
+
if (preview.duplicateComplete) {
|
|
791
|
+
await runJobModeUnchecked(opts, resolvePipelineAgents, isWorktreeChild);
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
const snapshot = snapshotJobOutput(specdojoRootDir(), paths.executionPath, preview.record);
|
|
795
|
+
await runJobModeUnchecked({ ...opts, scheduledAt: preview.record.scheduled_at }, resolvePipelineAgents, isWorktreeChild);
|
|
796
|
+
if (!existsSync(preview.runPath))
|
|
797
|
+
return;
|
|
798
|
+
const record = loadJobRunRecord(preview.runPath);
|
|
799
|
+
if (record.state === "succeeded" && !snapshot.hasChanges()) {
|
|
800
|
+
snapshot.discard(completeJobRun({ projectId, runPath: preview.runPath, status: "noop" }));
|
|
801
|
+
process.stdout.write(`[routine-job] noop state=noop\n`);
|
|
802
|
+
}
|
|
746
803
|
}
|
|
@@ -1,28 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { withPlanConventionsFiles } from "../../shared/plan-conventions.js";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import {
|
|
3
|
+
import { specdojoRootDir } from "../../shared/specdojo-config.js";
|
|
4
4
|
import { loadExecDefaultsConfig, providerSlotPoolPath, resolveMaxConcurrency, resolveMaxConcurrentRuns, } from "../agent-config.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { acquireSchedulerLock, buildEvent, claimOwnerOf, foldEventsToState, readAllEventFiles, releaseSchedulerLock, writeEventFile, } from "../events.js";
|
|
6
|
+
import { gradeCheckpointPaths } from "../grade-checkpoint.js";
|
|
7
7
|
import { selectDueDeferredLimitTasks } from "../limit.js";
|
|
8
|
-
import {
|
|
8
|
+
import { parentValidationPoolPath, resolveParentValidationConcurrency, } from "../parent-validation.js";
|
|
9
|
+
import { integratedRepoNames, loadPipelineResumeCheckpoint, } from "../pipeline-state.js";
|
|
10
|
+
import { activateResolvedProjectPaths, resolveProjectPaths } from "../project.js";
|
|
11
|
+
import { loadRegisterResumeCandidates, selectScheduleExecutorResume, } from "../register-resume.js";
|
|
12
|
+
import { readResultFrontmatterSnapshot, updateResultStatus } from "../results.js";
|
|
13
|
+
import { recordPathForRead } from "../run-records.js";
|
|
9
14
|
import { buildInitialStateFromStrategy } from "../schedule/initial.js";
|
|
15
|
+
import { buildScheduleIndex } from "../schedule/schedule.js";
|
|
10
16
|
import { qualifyTaskId } from "../shared.js";
|
|
11
|
-
import {
|
|
12
|
-
import { collectExecLockUsage, execLocksDir, formatExecLockUsage } from "./lock.js";
|
|
17
|
+
import { configuredProductRepos, withProductWorktrees } from "../task-repos.js";
|
|
13
18
|
import { buildTaskView } from "../task-view.js";
|
|
14
|
-
import {
|
|
19
|
+
import { PROJECT_REPO_NAME, mergeInProgress } from "../repo-integration-git.js";
|
|
20
|
+
import { syncTaskWorktreesWithIntegrationTargets, } from "../repo-integration-sync.js";
|
|
15
21
|
import { findExecWorktree, resolveWorktreeBase } from "../worktree.js";
|
|
16
|
-
import {
|
|
17
|
-
import { parentValidationPoolPath, resolveParentValidationConcurrency, } from "../parent-validation.js";
|
|
18
|
-
import { loadPipelineResumeCheckpoint } from "../pipeline-state.js";
|
|
19
|
-
import { loadRegisterResumeCandidates, selectScheduleExecutorResume, } from "../register-resume.js";
|
|
20
|
-
import { buildTaskPhaseMap, configuredWorktreeBase, parseParallel, resolveExecDefaultsPath, withProjectExecRunLock, } from "./shared.js";
|
|
22
|
+
import { currentBranch, isExecBranchMergedIntoCurrent } from "../worktree-ops.js";
|
|
21
23
|
import { loadRosterForExecutionPath, pathInsideWorktree } from "./agent.js";
|
|
24
|
+
import { collectExecLockUsage, execLocksDir, formatExecLockUsage } from "./lock.js";
|
|
25
|
+
import { spawnBlock, spawnIndexBuild, spawnRefresh, spawnValidate, stageActorMeta, } from "./mode-shared.js";
|
|
26
|
+
import { rebuildStaleGeneratedTracksForCycle, resolveClaimingActor, runBatchMode, } from "./schedule-mode.js";
|
|
22
27
|
import { findClaimEventPath, prepareSingleTask, } from "./schedule-prepare.js";
|
|
23
28
|
import { runPreparedTask } from "./schedule-task.js";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
29
|
+
import { withTrailingRunRecords } from "./trailing-records.js";
|
|
30
|
+
import { branchOwnedRunRecordPaths } from "../trailing-records.js";
|
|
31
|
+
import { repoRelative } from "../../shared/git.js";
|
|
32
|
+
import { buildTaskPhaseMap, configuredWorktreeBase, parseParallel, resolveExecDefaultsPath, withProjectExecRunLock, } from "./shared.js";
|
|
26
33
|
// 同じ project の exec run が共有する枠(主 run・--join run・register lifecycle・provider の
|
|
27
34
|
// max_concurrency・親検証)の上限と現在の使用数を表示する。ロックは取得しない。
|
|
28
35
|
export function formatExecSlotsReport(executionPath, execDefaults) {
|
|
@@ -153,7 +160,7 @@ export async function runCycleMode(opts) {
|
|
|
153
160
|
// Step 4/5: validate + refresh schedule state before selecting Ready tasks.
|
|
154
161
|
process.stdout.write("[cycle] step 4/5: validate + refresh schedule state\n");
|
|
155
162
|
if (dryRun) {
|
|
156
|
-
process.stdout.write(" [dry-run] specdojo exec validate\n");
|
|
163
|
+
process.stdout.write(" [dry-run] specdojo exec validate --schedule-only\n");
|
|
157
164
|
process.stdout.write(" [dry-run] specdojo exec refresh\n");
|
|
158
165
|
stepOutcomes.push("refresh=success");
|
|
159
166
|
}
|
|
@@ -231,7 +238,7 @@ export function registerCycleCommand(exec) {
|
|
|
231
238
|
cmd.option("--dry-run", "Print resolved steps without executing", false);
|
|
232
239
|
cmd.action(async (opts) => {
|
|
233
240
|
try {
|
|
234
|
-
await withProjectExecRunLock(opts, "cycle", () => runCycleMode(opts));
|
|
241
|
+
await withProjectExecRunLock(opts, "cycle", () => withTrailingRunRecords(opts, "cycle", () => runCycleMode(opts)));
|
|
235
242
|
}
|
|
236
243
|
catch (error) {
|
|
237
244
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -267,23 +274,27 @@ export function prepareScheduleIntegrationResume(params) {
|
|
|
267
274
|
checkpoint.state.stages.reporter.status !== "succeeded") {
|
|
268
275
|
throw new Error(`integration resume requires succeeded executor and reporter stages for ${task.id}`);
|
|
269
276
|
}
|
|
270
|
-
const resultPath =
|
|
277
|
+
const resultPath = recordPathForRead(executionPath, "result", task.id);
|
|
271
278
|
const worktreeResultPath = pathInsideWorktree(repoRoot, worktree.path, resultPath);
|
|
272
279
|
if (!existsSync(resultPath) || !existsSync(worktreeResultPath)) {
|
|
273
280
|
throw new Error(`result is missing for integration resume: ${task.id}-result.md`);
|
|
274
281
|
}
|
|
275
282
|
// 統合再開でも、root に未 commit のまま残る claim / plan / result の作業コピーを merge 前に
|
|
276
283
|
// 解放できるよう、通常実行と同じ checkpoint パスを持たせる。
|
|
277
|
-
const claimEventPath = findClaimEventPath(schedulePath, task.id
|
|
278
|
-
|
|
279
|
-
|
|
284
|
+
const claimEventPath = findClaimEventPath(schedulePath, task.id, {
|
|
285
|
+
repoRoot,
|
|
286
|
+
worktreePath: worktree.path,
|
|
287
|
+
});
|
|
288
|
+
const checkpointPaths = withPlanConventionsFiles([
|
|
289
|
+
recordPathForRead(executionPath, "plan", task.id),
|
|
280
290
|
resultPath,
|
|
281
291
|
...(claimEventPath ? [claimEventPath] : []),
|
|
282
292
|
...gradeCheckpointPaths({ repoRoot, executionPath }),
|
|
283
|
-
];
|
|
293
|
+
]);
|
|
284
294
|
return {
|
|
285
295
|
task,
|
|
286
296
|
actor,
|
|
297
|
+
claimActor: claimOwnerOf(taskState) ?? actor,
|
|
287
298
|
agentCandidates: [],
|
|
288
299
|
plan: "",
|
|
289
300
|
prompt: "",
|
|
@@ -296,6 +307,74 @@ export function prepareScheduleIntegrationResume(params) {
|
|
|
296
307
|
pipelineStateRef: stateRef,
|
|
297
308
|
};
|
|
298
309
|
}
|
|
310
|
+
// 統合の段(reporter の後の commit・検査・merge)まで進んでから止まった run か。
|
|
311
|
+
function stoppedInIntegration(state) {
|
|
312
|
+
return (state.stages.reporter.status === "succeeded" || (state.stages.integrate?.attempts ?? 0) > 0);
|
|
313
|
+
}
|
|
314
|
+
// task 自身の run の記録(repo 相対)。block の後の記帳 commit(PJR-DVNV)が統合先へ入れた
|
|
315
|
+
// 作業コピーは、exec branch 側の同じ記録と両側の追加として競合する。再開の取り込みでは exec branch
|
|
316
|
+
// 側を採る。統合の merge と同じ向きで、再開した executor はこの記録を引き継いで書き直し、後の統合も
|
|
317
|
+
// 統合先の側に変更が無いため競合しない。
|
|
318
|
+
function taskRunRecordPaths(params) {
|
|
319
|
+
const paths = params.branches.flatMap((branch) => branchOwnedRunRecordPaths({ ...params, branch }).map((path) => repoRelative(params.repoRoot, path)));
|
|
320
|
+
return [...new Set(paths)].sort();
|
|
321
|
+
}
|
|
322
|
+
// 統合の段で止まった task を executor へ戻す前の準備(PJR-ED0K)。worktree が merge の途中なら、
|
|
323
|
+
// 解消に `git merge --abort` が要り stage 済みの成果を失うため、状態を変えずに止める。止まって
|
|
324
|
+
// いなければ、統合先(project は root の現在ブランチ)の直しを exec branch へ取り込む。
|
|
325
|
+
// 未 commit の成果と run の記録は取り込みの前に控えて戻し、戻せない場合は取り込み前へ戻して止める。
|
|
326
|
+
export function prepareExecutorResumeFromIntegration(params) {
|
|
327
|
+
const { taskId, worktree, repoRoot } = params;
|
|
328
|
+
const context = {
|
|
329
|
+
repoRoot,
|
|
330
|
+
schedulePath: params.schedulePath,
|
|
331
|
+
executionPath: params.executionPath,
|
|
332
|
+
};
|
|
333
|
+
if (isExecBranchMergedIntoCurrent({ context, worktree })) {
|
|
334
|
+
throw new Error(`cannot resume the executor for ${taskId}: ${worktree.branch} is already merged; ` +
|
|
335
|
+
`run exec resume --task ${taskId} to finish the integration cleanup`);
|
|
336
|
+
}
|
|
337
|
+
const merging = [
|
|
338
|
+
...(worktree.repos ?? [])
|
|
339
|
+
.filter((product) => existsSync(product.path) && mergeInProgress(product.path))
|
|
340
|
+
.map((product) => product.name),
|
|
341
|
+
...(mergeInProgress(worktree.path) ? [PROJECT_REPO_NAME] : []),
|
|
342
|
+
];
|
|
343
|
+
if (merging.length > 0) {
|
|
344
|
+
throw new Error(`cannot resume the executor for ${taskId}: a merge is in progress in ${merging.join(", ")} ` +
|
|
345
|
+
`(${worktree.path}); aborting it would discard staged changes. Commit or resolve the ` +
|
|
346
|
+
`merge in the worktree, then run exec resume --task ${taskId} --resume-from executor again`);
|
|
347
|
+
}
|
|
348
|
+
if (params.dryRun)
|
|
349
|
+
return [];
|
|
350
|
+
process.stdout.write(` Syncing integration targets before executor resume: ${taskId}\n`);
|
|
351
|
+
let synced;
|
|
352
|
+
try {
|
|
353
|
+
const projectTarget = currentBranch(repoRoot);
|
|
354
|
+
synced = syncTaskWorktreesWithIntegrationTargets({
|
|
355
|
+
worktree,
|
|
356
|
+
projectTarget,
|
|
357
|
+
message: `exec(${taskId}): merge integration target before executor resume`,
|
|
358
|
+
projectOursPaths: taskRunRecordPaths({
|
|
359
|
+
repoRoot,
|
|
360
|
+
executionPath: params.executionPath,
|
|
361
|
+
branches: [worktree.branch, projectTarget],
|
|
362
|
+
taskId,
|
|
363
|
+
}),
|
|
364
|
+
integratedProducts: integratedRepoNames(params.state),
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
catch (error) {
|
|
368
|
+
throw new Error(`cannot sync the worktree with the integration target before executor resume of ` +
|
|
369
|
+
`${taskId}: ${error instanceof Error ? error.message : String(error)}; ` +
|
|
370
|
+
`resolve it in ${worktree.path} and run exec resume --task ${taskId} --resume-from executor again`, { cause: error });
|
|
371
|
+
}
|
|
372
|
+
for (const entry of synced) {
|
|
373
|
+
process.stdout.write(` [sync] ${entry.repo}: ${entry.status} (${entry.target})` +
|
|
374
|
+
`${entry.detail ? ` — ${entry.detail}` : ""}\n`);
|
|
375
|
+
}
|
|
376
|
+
return synced;
|
|
377
|
+
}
|
|
299
378
|
function validateScheduleResumeOptions(opts) {
|
|
300
379
|
if (opts.resumeFrom !== undefined) {
|
|
301
380
|
if (opts.resumeFrom !== "executor")
|
|
@@ -330,6 +409,10 @@ export async function runResumeMode(opts) {
|
|
|
330
409
|
const events = readAllEventFiles(schedulePath);
|
|
331
410
|
const initTasks = buildInitialStateFromStrategy(schedulePath, schedule);
|
|
332
411
|
let snapshot = foldEventsToState(events, schedule, schedulePath, initTasks);
|
|
412
|
+
const initialTaskStates = new Map(Object.entries(snapshot.tasks).map(([id, state]) => [
|
|
413
|
+
id,
|
|
414
|
+
{ ...state, ...(state.meta ? { meta: { ...state.meta } } : {}) },
|
|
415
|
+
]));
|
|
333
416
|
let doingIds;
|
|
334
417
|
let executorResume;
|
|
335
418
|
let executorWorktree;
|
|
@@ -341,12 +424,14 @@ export async function runResumeMode(opts) {
|
|
|
341
424
|
if (!task.agent_pipeline)
|
|
342
425
|
throw new Error("--resume-from requires an agent_pipeline task.");
|
|
343
426
|
const taskState = snapshot.tasks[opts.task];
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
427
|
+
const blockedStage = taskState?.state === "blocked" ? taskState.meta?.pipeline_stage : undefined;
|
|
428
|
+
// A blocked executor stage is accepted here; selectScheduleExecutorResume admits it only when
|
|
429
|
+
// the runner rejected the executor report before the reporter (PJR-1GCD).
|
|
347
430
|
if (taskState?.state !== "doing" &&
|
|
348
|
-
|
|
349
|
-
|
|
431
|
+
blockedStage !== "reporter" &&
|
|
432
|
+
blockedStage !== "integrate" &&
|
|
433
|
+
blockedStage !== "executor") {
|
|
434
|
+
throw new Error("--resume-from executor requires a doing task or a blocked reporter, integrate, or executor stage.");
|
|
350
435
|
}
|
|
351
436
|
const worktreeTaskId = qualifyTaskId(projectId, opts.task);
|
|
352
437
|
const found = findExecWorktree(repoRoot, worktreeTaskId);
|
|
@@ -364,6 +449,17 @@ export async function runResumeMode(opts) {
|
|
|
364
449
|
throw new Error("no executor stage to resume");
|
|
365
450
|
executorResume = lookup.target;
|
|
366
451
|
executorWorktree = withProductWorktrees(found, configuredProductRepos(schedulePath), worktreeTaskId);
|
|
452
|
+
if (stoppedInIntegration(executorResume.state)) {
|
|
453
|
+
prepareExecutorResumeFromIntegration({
|
|
454
|
+
taskId: opts.task,
|
|
455
|
+
worktree: executorWorktree,
|
|
456
|
+
state: executorResume.state,
|
|
457
|
+
repoRoot,
|
|
458
|
+
schedulePath,
|
|
459
|
+
executionPath,
|
|
460
|
+
dryRun,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
367
463
|
}
|
|
368
464
|
if (opts.due) {
|
|
369
465
|
let lockDir = "";
|
|
@@ -425,7 +521,7 @@ export async function runResumeMode(opts) {
|
|
|
425
521
|
blockedPipelineStage === "integrate") &&
|
|
426
522
|
typeof taskState.meta?.pipeline_state_ref === "string";
|
|
427
523
|
if (canResumeBlockedPipeline) {
|
|
428
|
-
const actor = taskState
|
|
524
|
+
const actor = claimOwnerOf(taskState) ?? opts.by ?? "exec-pipeline-resume";
|
|
429
525
|
if (!dryRun) {
|
|
430
526
|
const resumeMeta = {
|
|
431
527
|
...taskState.meta,
|
|
@@ -447,7 +543,7 @@ export async function runResumeMode(opts) {
|
|
|
447
543
|
: "resume executor from persisted pipeline state",
|
|
448
544
|
meta,
|
|
449
545
|
});
|
|
450
|
-
if (executorResume)
|
|
546
|
+
if (executorResume || opts.executorBy)
|
|
451
547
|
pendingExecutorUnblock = event;
|
|
452
548
|
else
|
|
453
549
|
writeEventFile(schedulePath, event);
|
|
@@ -483,11 +579,12 @@ export async function runResumeMode(opts) {
|
|
|
483
579
|
try {
|
|
484
580
|
const task = buildTaskView(schedulePath, executionPath, taskId);
|
|
485
581
|
const resolved = resolveClaimingActor(snapshot.tasks[taskId], opts.by);
|
|
486
|
-
|
|
582
|
+
// --resume-from executor は統合の段で止まった task でも executor から再実行する。
|
|
583
|
+
const prepared = !executorResume && snapshot.tasks[taskId]?.meta?.pipeline_stage === "integrate"
|
|
487
584
|
? prepareScheduleIntegrationResume({
|
|
488
585
|
task,
|
|
489
586
|
taskState: snapshot.tasks[taskId],
|
|
490
|
-
actor: resolved.actor ?? snapshot.tasks[taskId]
|
|
587
|
+
actor: resolved.actor ?? claimOwnerOf(snapshot.tasks[taskId]) ?? "exec-pipeline-resume",
|
|
491
588
|
projectId,
|
|
492
589
|
repoRoot,
|
|
493
590
|
executionPath,
|
|
@@ -511,9 +608,61 @@ export async function runResumeMode(opts) {
|
|
|
511
608
|
: {}),
|
|
512
609
|
}, opts);
|
|
513
610
|
if (typeof prepared !== "string") {
|
|
514
|
-
|
|
515
|
-
|
|
611
|
+
const priorTaskState = initialTaskStates.get(taskId);
|
|
612
|
+
const previousActor = claimOwnerOf(priorTaskState);
|
|
613
|
+
const resumingExecutorStage = prepared.pipelineResumeStage !== "reporter" &&
|
|
614
|
+
prepared.pipelineResumeStage !== "integrate";
|
|
615
|
+
if (resumingExecutorStage &&
|
|
616
|
+
previousActor &&
|
|
617
|
+
prepared.actor &&
|
|
618
|
+
prepared.actor !== previousActor) {
|
|
619
|
+
if (!dryRun) {
|
|
620
|
+
const releaseEvent = buildEvent("release", {
|
|
621
|
+
task: taskId,
|
|
622
|
+
by: previousActor,
|
|
623
|
+
msg: opts.resumeFrom === "executor"
|
|
624
|
+
? `release claim to switch executor to ${prepared.actor} (--resume-from executor)`
|
|
625
|
+
: `release claim to switch executor to ${prepared.actor}`,
|
|
626
|
+
meta: ["pipeline_resume_released=true", `replaced_by=${prepared.actor}`],
|
|
627
|
+
});
|
|
628
|
+
const resumeMeta = {
|
|
629
|
+
...(priorTaskState?.meta ?? {}),
|
|
630
|
+
...(executorResume
|
|
631
|
+
? { pipeline_stage: "executor", pipeline_state_ref: executorResume.stateRef }
|
|
632
|
+
: {}),
|
|
633
|
+
pipeline_resume_claimed: "true",
|
|
634
|
+
previous_actor: previousActor,
|
|
635
|
+
};
|
|
636
|
+
const meta = Object.entries(resumeMeta).map(([key, value]) => `${key}=${String(value)}`);
|
|
637
|
+
const claimEvent = buildEvent("claim", {
|
|
638
|
+
task: taskId,
|
|
639
|
+
by: prepared.actor,
|
|
640
|
+
msg: opts.resumeFrom === "executor"
|
|
641
|
+
? `claim task as resumed executor ${prepared.actor} (--resume-from executor)`
|
|
642
|
+
: `claim task as resumed executor ${prepared.actor}`,
|
|
643
|
+
meta,
|
|
644
|
+
});
|
|
645
|
+
writeEventFile(schedulePath, releaseEvent);
|
|
646
|
+
writeEventFile(schedulePath, claimEvent);
|
|
647
|
+
}
|
|
516
648
|
pendingExecutorUnblock = undefined;
|
|
649
|
+
snapshot.tasks[taskId] = {
|
|
650
|
+
...snapshot.tasks[taskId],
|
|
651
|
+
state: "doing",
|
|
652
|
+
last_by: prepared.actor,
|
|
653
|
+
claimed_by: prepared.actor,
|
|
654
|
+
last_type: "claim",
|
|
655
|
+
};
|
|
656
|
+
prepared.claimActor = prepared.actor;
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
if (pendingExecutorUnblock) {
|
|
660
|
+
if (!dryRun)
|
|
661
|
+
writeEventFile(schedulePath, pendingExecutorUnblock);
|
|
662
|
+
pendingExecutorUnblock = undefined;
|
|
663
|
+
}
|
|
664
|
+
// The claim stays with its holder when --by or a stage override runs another agent.
|
|
665
|
+
prepared.claimActor = snapshot.tasks[taskId]?.last_by ?? prepared.claimActor;
|
|
517
666
|
}
|
|
518
667
|
const attempts = snapshot.tasks[taskId]?.meta?.limit_attempts;
|
|
519
668
|
prepared.priorLimitAttempts =
|
|
@@ -529,7 +678,7 @@ export async function runResumeMode(opts) {
|
|
|
529
678
|
const message = error instanceof Error ? error.message : String(error);
|
|
530
679
|
process.stderr.write(`[resume] setup error for ${taskId}: ${message}\n`);
|
|
531
680
|
if (opts.due && !dryRun) {
|
|
532
|
-
spawnBlock(projectId, taskId, snapshot.tasks[taskId]
|
|
681
|
+
spawnBlock(projectId, taskId, claimOwnerOf(snapshot.tasks[taskId]) ?? "exec-limit-resume", `resume setup error: ${message}`);
|
|
533
682
|
}
|
|
534
683
|
process.exitCode = 1;
|
|
535
684
|
}
|
|
@@ -546,7 +695,10 @@ export async function runResumeMode(opts) {
|
|
|
546
695
|
const completedAt = new Date().toISOString();
|
|
547
696
|
if (prepared.resultPath)
|
|
548
697
|
await updateResultStatus(prepared.resultPath, "blocked", completedAt);
|
|
549
|
-
spawnBlock(projectId, prepared.task.id, prepared.
|
|
698
|
+
spawnBlock(projectId, prepared.task.id, prepared.claimActor, `runner error: ${message}`, {
|
|
699
|
+
limit_deferred: "false",
|
|
700
|
+
...stageActorMeta(prepared.claimActor, prepared.actor),
|
|
701
|
+
});
|
|
550
702
|
}
|
|
551
703
|
process.exitCode = 1;
|
|
552
704
|
}
|
|
@@ -590,7 +742,7 @@ export function registerResumeCommand(exec) {
|
|
|
590
742
|
process.exitCode = 1;
|
|
591
743
|
return;
|
|
592
744
|
}
|
|
593
|
-
await withProjectExecRunLock(opts, "resume", () => runResumeMode(opts));
|
|
745
|
+
await withProjectExecRunLock(opts, "resume", () => withTrailingRunRecords(opts, "resume", () => runResumeMode(opts)));
|
|
594
746
|
}
|
|
595
747
|
catch (error) {
|
|
596
748
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import {
|
|
3
|
+
import { relative, sep } from "node:path";
|
|
4
4
|
import { selfRunArgs } from "../../shared/spawn-self.js";
|
|
5
5
|
import { specdojoRootDir } from "../../shared/specdojo-config.js";
|
|
6
6
|
import { readPipelineState, updatePipelineRepoIntegration, updatePipelineStage, writePipelineState, } from "../pipeline-state.js";
|
|
7
|
+
import { runLogPath } from "../run-records.js";
|
|
7
8
|
export function spawnSelf(args, cwd = specdojoRootDir()) {
|
|
8
9
|
const [exe, fullArgs] = selfRunArgs(args);
|
|
9
10
|
const result = spawnSync(exe, fullArgs, { stdio: "inherit", cwd });
|
|
10
11
|
return result.status === 0;
|
|
11
12
|
}
|
|
12
13
|
export function spawnValidate(projectId) {
|
|
13
|
-
|
|
14
|
+
// Run records can still be incomplete at startup or resume, and the run lock is held.
|
|
15
|
+
// Audit persisted records explicitly or in CI, independently of schedule readiness.
|
|
16
|
+
const args = ["exec", "validate", "--schedule-only"];
|
|
14
17
|
if (projectId)
|
|
15
18
|
args.push("--project", projectId);
|
|
16
19
|
return spawnSelf(args);
|
|
@@ -82,6 +85,11 @@ export function pipelineRecoveryMeta(input) {
|
|
|
82
85
|
...(input.runId ? { pipeline_run_id: input.runId } : {}),
|
|
83
86
|
};
|
|
84
87
|
}
|
|
88
|
+
// The runner blocks a failed task as the actor holding its claim, because another agent may have
|
|
89
|
+
// run the failed stage (fallback, --executor-by, --reporter-by). Record both actors on the event.
|
|
90
|
+
export function stageActorMeta(claimActor, stageActor) {
|
|
91
|
+
return { claim_actor: claimActor, stage_actor: stageActor || claimActor };
|
|
92
|
+
}
|
|
85
93
|
export function spawnBlock(projectId, taskId, by, reason, meta = { limit_deferred: "false" }) {
|
|
86
94
|
const args = ["exec", "block", "--task", taskId, "--by", by, "--msg", reason];
|
|
87
95
|
for (const [key, value] of Object.entries(meta))
|
|
@@ -136,5 +144,5 @@ export function recordRepoIntegration(statePath, repo, patch) {
|
|
|
136
144
|
}
|
|
137
145
|
}
|
|
138
146
|
export function integrateLogPath(statePath) {
|
|
139
|
-
return statePath ?
|
|
147
|
+
return statePath ? runLogPath(statePath, "integrate.log") : undefined;
|
|
140
148
|
}
|