specdojo 0.7.0 → 0.9.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 +7 -3
- package/CHANGELOG.md +217 -0
- package/dist/catalog/build.js +24 -1
- package/dist/catalog/catalog.js +16 -14
- package/dist/catalog/plan.js +1 -1
- package/dist/catalog/scaffold.js +4 -1
- package/dist/commands/agent.js +5 -3
- package/dist/commands/build.js +69 -10
- package/dist/commands/git.js +206 -0
- package/dist/commands/init.js +9 -3
- package/dist/commands/night-orchestrator.js +6 -4
- package/dist/commands/where.js +25 -0
- package/dist/dashboard/dashboard-timeline.js +18 -16
- package/dist/dashboard/dashboard.js +616 -261
- package/dist/dashboard/epic-plan.js +81 -0
- package/dist/dashboard/exec-records.js +16 -20
- package/dist/dashboard/routines.js +11 -12
- package/dist/dashboard/timeline-build.js +5 -9
- package/dist/dashboard/timeline.js +23 -18
- package/dist/devcontainer/scaffold.js +18 -0
- package/dist/docs/frontmatter-namespace.js +1 -48
- package/dist/docs/index-command.js +2 -2
- package/dist/docs/yaml-business-tables.js +243 -0
- package/dist/docs/yaml-interface-tables.js +106 -0
- package/dist/docs/yaml-pages-command.js +5 -3
- package/dist/docs/yaml-pages.js +268 -3
- package/dist/docs/yaml-table-shared.js +70 -0
- package/dist/docs/yaml-tables.js +39 -0
- package/dist/exec/agent-config.js +31 -0
- package/dist/exec/agent-plan.js +3 -2
- package/dist/exec/agent-protected-config.js +2 -0
- package/dist/exec/commands.js +100 -39
- package/dist/exec/commit-hook-skips.js +78 -0
- package/dist/exec/core.js +19 -7
- package/dist/exec/events.js +179 -8
- package/dist/exec/evidence.js +77 -19
- 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 +209 -15
- package/dist/exec/pipeline-state.js +27 -5
- package/dist/exec/plans-condense-findings.js +89 -0
- package/dist/exec/plans-core.js +45 -19
- package/dist/exec/plans-generation.js +52 -30
- 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/post-integration.js +162 -0
- package/dist/exec/queue-command.js +166 -0
- package/dist/exec/queue.js +285 -0
- package/dist/exec/register-foreign-wait.js +84 -0
- package/dist/exec/register-resume.js +55 -56
- package/dist/exec/register.js +26 -22
- package/dist/exec/repo-integration-sync.js +21 -5
- package/dist/exec/repo-integration.js +21 -1
- package/dist/exec/reporter.js +121 -23
- package/dist/exec/results.js +106 -25
- package/dist/exec/review-completion.js +47 -0
- package/dist/exec/review-kata.js +112 -0
- package/dist/exec/run/agent-pipeline.js +78 -8
- package/dist/exec/run/agent.js +32 -13
- package/dist/exec/run/change-scope.js +365 -0
- package/dist/exec/run/deferred-cleanup.js +31 -0
- package/dist/exec/run/in-place.js +73 -33
- package/dist/exec/run/job-lock.js +66 -0
- package/dist/exec/run/job-sequence.js +137 -0
- package/dist/exec/run/job.js +135 -41
- package/dist/exec/run/lifecycle-commands.js +189 -37
- package/dist/exec/run/lock.js +22 -1
- package/dist/exec/run/mode-shared.js +11 -3
- package/dist/exec/run/register-command.js +14 -15
- package/dist/exec/run/register-core.js +20 -13
- package/dist/exec/run/register-mode.js +77 -17
- package/dist/exec/run/register-post-review.js +21 -9
- package/dist/exec/run/register-resume.js +95 -31
- package/dist/exec/run/register-state.js +23 -15
- package/dist/exec/run/register-worktree.js +184 -139
- package/dist/exec/run/schedule-mode.js +79 -18
- package/dist/exec/run/schedule-prepare.js +204 -59
- package/dist/exec/run/schedule-task.js +203 -49
- package/dist/exec/run/shared.js +9 -3
- package/dist/exec/run/trailing-records.js +35 -0
- package/dist/exec/run-records.js +2 -0
- package/dist/exec/schedule/schedule.js +116 -4
- package/dist/exec/shared.js +1 -1
- package/dist/exec/smoke.js +190 -0
- package/dist/exec/strategy.js +14 -3
- package/dist/exec/task-view.js +6 -4
- package/dist/exec/trailing-records.js +242 -0
- package/dist/exec/trial-commands.js +8 -4
- package/dist/exec/trial-core.js +6 -1
- package/dist/exec/validate-records-commit.js +110 -0
- package/dist/exec/validate-records.js +148 -0
- package/dist/exec/validation-metrics.js +181 -0
- package/dist/exec/worktree-cleanup-lock.js +26 -0
- package/dist/exec/worktree-command.js +38 -17
- 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 +32 -4
- package/dist/grade/apply.js +32 -6
- package/dist/grade/command-apply.js +3 -3
- package/dist/grade/command-inspect.js +7 -5
- package/dist/grade/command-plan.js +1 -1
- package/dist/grade/command-run.js +7 -1
- 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 +87 -11
- package/dist/grade/target-discovery.js +17 -4
- package/dist/grade/targets.js +12 -11
- package/dist/job/definition.js +84 -8
- package/dist/job/job.js +109 -39
- package/dist/job/noop.js +104 -0
- package/dist/register/authoring-sources.js +22 -16
- 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 +6 -3
- package/dist/register/planning.js +7 -14
- package/dist/register/register.js +74 -16
- 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 +13 -3
- package/dist/routine/failure.js +30 -0
- package/dist/routine/routine.js +189 -71
- package/dist/routine/status.js +62 -0
- package/dist/routine/storage.js +33 -0
- package/dist/schedule/schedule.js +39 -39
- 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 +7 -0
- package/dist/shared/condense-records.js +25 -0
- package/dist/shared/cross-process-lock.js +9 -1
- package/dist/shared/deprecation.js +8 -0
- package/dist/shared/dist-freshness.js +8 -2
- 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-environment.js +2 -1
- package/dist/shared/git.js +186 -16
- package/dist/shared/grade-result.js +17 -1
- package/dist/shared/lefthook-scaffold.js +3 -0
- package/dist/shared/local-config.js +244 -0
- 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 +73 -41
- package/dist/shared/specdojo-gitignore.js +1 -0
- package/dist/shared/text.js +74 -6
- package/dist/shared/timeline-index.js +2 -0
- package/dist/shared/where-alias.js +13 -0
- package/dist/specdojo.js +4 -0
- package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +11 -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 +69 -19
- package/docs/ja/specdojo/guides/exec-operation-guide.md +97 -18
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +20 -11
- package/docs/ja/specdojo/guides/job-sequence-guide.md +77 -0
- 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 +73 -17
- package/docs/ja/specdojo/guides/register-operation-guide.md +26 -6
- 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 +23 -12
- package/docs/ja/specdojo/guides/ryu-guide.md +23 -13
- package/docs/ja/specdojo/guides/schedule-design-guide.md +27 -21
- 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/guides/waza-guide.md +12 -8
- package/docs/ja/specdojo/recipes/bac-recipe.md +111 -0
- package/docs/ja/specdojo/recipes/bes-recipe.md +141 -0
- package/docs/ja/specdojo/recipes/bps-recipe.md +88 -139
- package/docs/ja/specdojo/recipes/br-recipe.md +77 -0
- package/docs/ja/specdojo/recipes/cdfd-overview-recipe.md +97 -109
- package/docs/ja/specdojo/recipes/cdfd-recipe.md +85 -146
- package/docs/ja/specdojo/recipes/cdfd-uc-recipe.md +92 -99
- package/docs/ja/specdojo/recipes/cnd-recipe.md +135 -0
- package/docs/ja/specdojo/recipes/cpd-recipe.md +140 -0
- package/docs/ja/specdojo/recipes/cxd-recipe.md +162 -0
- package/docs/ja/specdojo/recipes/ifd-recipe.md +145 -0
- package/docs/ja/specdojo/recipes/ifx-cmd-recipe.md +112 -90
- package/docs/ja/specdojo/recipes/ifx-index-recipe.md +164 -0
- package/docs/ja/specdojo/recipes/pm-communication-plan-recipe.md +60 -49
- package/docs/ja/specdojo/recipes/pm-members-recipe.md +50 -51
- package/docs/ja/specdojo/recipes/pm-organization-recipe.md +59 -48
- package/docs/ja/specdojo/recipes/pm-plan-recipe.md +72 -50
- package/docs/ja/specdojo/recipes/pm-quality-management-plan-recipe.md +40 -49
- package/docs/ja/specdojo/recipes/pm-raci-recipe.md +42 -48
- package/docs/ja/specdojo/recipes/pm-roles-recipe.md +52 -81
- package/docs/ja/specdojo/recipes/prj-assumptions-constraints-dependencies-recipe.md +64 -91
- package/docs/ja/specdojo/recipes/prj-charter-recipe.md +71 -106
- package/docs/ja/specdojo/recipes/prj-comparison-of-alternatives-recipe.md +78 -156
- package/docs/ja/specdojo/recipes/prj-issues-and-approach-recipe.md +62 -111
- package/docs/ja/specdojo/recipes/prj-scope-recipe.md +67 -123
- package/docs/ja/specdojo/recipes/prj-stakeholder-register-recipe.md +60 -96
- package/docs/ja/specdojo/recipes/prj-success-criteria-and-acceptance-criteria-recipe.md +61 -105
- package/docs/ja/specdojo/recipes/stsd-recipe.md +88 -80
- package/docs/ja/specdojo/recipes/sysd-critical-flows-recipe.md +129 -0
- package/docs/ja/specdojo/recipes/sysd-cross-cutting-policy-recipe.md +146 -0
- package/docs/ja/specdojo/recipes/sysd-index-recipe.md +141 -0
- package/docs/ja/specdojo/recipes/tsd-recipe.md +149 -129
- package/docs/ja/specdojo/references/command-reference.md +303 -148
- package/docs/ja/specdojo/references/deliverables-reference.md +30 -16
- package/docs/ja/specdojo/references/directory-layout-reference.md +3 -2
- package/docs/ja/specdojo/references/specdojo-config-reference.md +54 -18
- package/docs/ja/specdojo/rulebooks/atc-index-rulebook.md +101 -257
- package/docs/ja/specdojo/rulebooks/atc-rulebook.md +102 -228
- package/docs/ja/specdojo/rulebooks/bac-rulebook.md +63 -290
- package/docs/ja/specdojo/rulebooks/bdd-rulebook.md +162 -80
- package/docs/ja/specdojo/rulebooks/bds-rulebook.md +118 -155
- package/docs/ja/specdojo/rulebooks/bes-index-rulebook.md +128 -60
- package/docs/ja/specdojo/rulebooks/bes-rulebook.md +70 -94
- package/docs/ja/specdojo/rulebooks/bps-rulebook.md +24 -56
- package/docs/ja/specdojo/rulebooks/br-rulebook.md +58 -103
- package/docs/ja/specdojo/rulebooks/ccd-mermaid-rulebook.md +103 -223
- package/docs/ja/specdojo/rulebooks/cdfd-d2-rulebook.md +18 -93
- package/docs/ja/specdojo/rulebooks/cdfd-mermaid-rulebook.md +18 -52
- package/docs/ja/specdojo/rulebooks/cdfd-overview-rulebook.md +109 -147
- package/docs/ja/specdojo/rulebooks/cdfd-rulebook.md +80 -108
- package/docs/ja/specdojo/rulebooks/cdfd-uc-rulebook.md +51 -55
- package/docs/ja/specdojo/rulebooks/cdr-rulebook.md +144 -0
- package/docs/ja/specdojo/rulebooks/cdsd-rulebook.md +81 -68
- package/docs/ja/specdojo/rulebooks/cdt-rulebook.md +139 -0
- package/docs/ja/specdojo/rulebooks/cld-rulebook.md +9 -184
- package/docs/ja/specdojo/rulebooks/clis-rulebook.md +170 -0
- package/docs/ja/specdojo/rulebooks/cnd-mermaid-rulebook.md +33 -86
- package/docs/ja/specdojo/rulebooks/cnd-rulebook.md +79 -249
- package/docs/ja/specdojo/rulebooks/cop-index-rulebook.md +45 -131
- package/docs/ja/specdojo/rulebooks/cop-rulebook.md +69 -275
- package/docs/ja/specdojo/rulebooks/cpd-mermaid-rulebook.md +20 -112
- package/docs/ja/specdojo/rulebooks/cpd-rulebook.md +79 -249
- package/docs/ja/specdojo/rulebooks/cxd-mermaid-rulebook.md +12 -145
- package/docs/ja/specdojo/rulebooks/cxd-rulebook.md +115 -256
- package/docs/ja/specdojo/rulebooks/dct-index-rulebook.md +79 -109
- package/docs/ja/specdojo/rulebooks/dct-rulebook.md +119 -174
- package/docs/ja/specdojo/rulebooks/dec-rulebook.md +6 -14
- package/docs/ja/specdojo/rulebooks/dmd-index-rulebook.md +22 -66
- package/docs/ja/specdojo/rulebooks/dmd-rulebook.md +36 -94
- package/docs/ja/specdojo/rulebooks/dss-rulebook.md +171 -0
- package/docs/ja/specdojo/rulebooks/etc-index-rulebook.md +31 -131
- package/docs/ja/specdojo/rulebooks/etc-rulebook.md +50 -104
- package/docs/ja/specdojo/rulebooks/gl-rulebook.md +93 -57
- package/docs/ja/specdojo/rulebooks/ifd-mermaid-rulebook.md +63 -253
- package/docs/ja/specdojo/rulebooks/ifx-api-rulebook.md +14 -20
- package/docs/ja/specdojo/rulebooks/ifx-cmd-rulebook.md +79 -76
- package/docs/ja/specdojo/rulebooks/ifx-file-rulebook.md +182 -237
- package/docs/ja/specdojo/rulebooks/ifx-index-rulebook.md +111 -40
- package/docs/ja/specdojo/rulebooks/ifx-msg-rulebook.md +14 -22
- package/docs/ja/specdojo/rulebooks/imp-business-rulebook.md +23 -46
- package/docs/ja/specdojo/rulebooks/imp-data-rulebook.md +41 -64
- package/docs/ja/specdojo/rulebooks/imp-interface-rulebook.md +16 -40
- package/docs/ja/specdojo/rulebooks/imp-operations-rulebook.md +34 -61
- package/docs/ja/specdojo/rulebooks/imp-test-rulebook.md +27 -50
- package/docs/ja/specdojo/rulebooks/itc-index-rulebook.md +70 -199
- package/docs/ja/specdojo/rulebooks/itc-rulebook.md +65 -153
- package/docs/ja/specdojo/rulebooks/mip-index-rulebook.md +74 -150
- package/docs/ja/specdojo/rulebooks/mm-rulebook.md +12 -23
- package/docs/ja/specdojo/rulebooks/mtp-rulebook.md +99 -176
- package/docs/ja/specdojo/rulebooks/nfr-availability-rulebook.md +35 -61
- package/docs/ja/specdojo/rulebooks/nfr-index-rulebook.md +75 -117
- package/docs/ja/specdojo/rulebooks/nfr-integrity-rulebook.md +31 -60
- package/docs/ja/specdojo/rulebooks/nfr-maintainability-rulebook.md +26 -81
- package/docs/ja/specdojo/rulebooks/nfr-operations-rulebook.md +32 -70
- package/docs/ja/specdojo/rulebooks/nfr-performance-rulebook.md +45 -87
- package/docs/ja/specdojo/rulebooks/nfr-reliability-rulebook.md +48 -101
- package/docs/ja/specdojo/rulebooks/nfr-security-safety-rulebook.md +44 -80
- package/docs/ja/specdojo/rulebooks/nfr-usability-rulebook.md +59 -127
- package/docs/ja/specdojo/rulebooks/opd-index-rulebook.md +31 -50
- package/docs/ja/specdojo/rulebooks/opd-rulebook.md +42 -109
- package/docs/ja/specdojo/rulebooks/opr-index-rulebook.md +29 -42
- package/docs/ja/specdojo/rulebooks/opr-rulebook.md +29 -87
- package/docs/ja/specdojo/rulebooks/otp-index-rulebook.md +62 -84
- package/docs/ja/specdojo/rulebooks/otp-rulebook.md +11 -61
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +92 -102
- package/docs/ja/specdojo/rulebooks/pm-change-request-log-rulebook.md +25 -34
- package/docs/ja/specdojo/rulebooks/pm-communication-plan-rulebook.md +30 -53
- package/docs/ja/specdojo/rulebooks/pm-issue-log-rulebook.md +23 -35
- package/docs/ja/specdojo/rulebooks/pm-members-rulebook.md +27 -45
- package/docs/ja/specdojo/rulebooks/pm-organization-rulebook.md +45 -59
- package/docs/ja/specdojo/rulebooks/pm-plan-rulebook.md +56 -66
- package/docs/ja/specdojo/rulebooks/pm-quality-management-plan-rulebook.md +54 -62
- package/docs/ja/specdojo/rulebooks/pm-raci-rulebook.md +46 -65
- package/docs/ja/specdojo/rulebooks/pm-risk-register-rulebook.md +28 -35
- package/docs/ja/specdojo/rulebooks/pm-roles-rulebook.md +65 -97
- package/docs/ja/specdojo/rulebooks/pr-rulebook.md +6 -18
- package/docs/ja/specdojo/rulebooks/prj-assumptions-constraints-dependencies-rulebook.md +48 -78
- package/docs/ja/specdojo/rulebooks/prj-charter-rulebook.md +23 -97
- package/docs/ja/specdojo/rulebooks/prj-comparison-of-alternatives-rulebook.md +61 -153
- package/docs/ja/specdojo/rulebooks/prj-issues-and-approach-rulebook.md +43 -116
- package/docs/ja/specdojo/rulebooks/prj-scope-rulebook.md +16 -51
- package/docs/ja/specdojo/rulebooks/prj-stakeholder-register-rulebook.md +47 -92
- package/docs/ja/specdojo/rulebooks/prj-success-criteria-and-acceptance-criteria-rulebook.md +25 -84
- package/docs/ja/specdojo/rulebooks/sac-rulebook.md +44 -107
- package/docs/ja/specdojo/rulebooks/sf-index-rulebook.md +106 -32
- package/docs/ja/specdojo/rulebooks/sf-rulebook.md +111 -61
- package/docs/ja/specdojo/rulebooks/sld-rulebook.md +129 -59
- package/docs/ja/specdojo/rulebooks/stc-index-rulebook.md +90 -189
- package/docs/ja/specdojo/rulebooks/stc-rulebook.md +45 -105
- package/docs/ja/specdojo/rulebooks/stsd-mermaid-rulebook.md +46 -40
- package/docs/ja/specdojo/rulebooks/stsd-rulebook.md +104 -68
- package/docs/ja/specdojo/rulebooks/sysd-critical-flows-rulebook.md +64 -330
- package/docs/ja/specdojo/rulebooks/sysd-cross-cutting-policy-rulebook.md +70 -263
- package/docs/ja/specdojo/rulebooks/sysd-index-rulebook.md +58 -200
- package/docs/ja/specdojo/rulebooks/sysd-rulebook.md +47 -60
- package/docs/ja/specdojo/rulebooks/tml-rulebook.md +4 -9
- package/docs/ja/specdojo/rulebooks/trc-requirements-to-specs-rulebook.md +69 -71
- package/docs/ja/specdojo/rulebooks/trc-requirements-to-tests-rulebook.md +65 -72
- package/docs/ja/specdojo/rulebooks/tsd-index-rulebook.md +35 -46
- package/docs/ja/specdojo/rulebooks/tsd-rulebook.md +49 -66
- package/docs/ja/specdojo/rulebooks/tsp-index-rulebook.md +64 -139
- package/docs/ja/specdojo/rulebooks/uis-rulebook.md +91 -161
- package/docs/ja/specdojo/rulebooks/utc-index-rulebook.md +49 -144
- package/docs/ja/specdojo/rulebooks/utc-rulebook.md +67 -155
- 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 +87 -21
- package/docs/ja/specdojo/samples/bes-index-sample.md +42 -20
- package/docs/ja/specdojo/samples/bes-sample.md +70 -21
- package/docs/ja/specdojo/samples/bps-sample.md +42 -54
- package/docs/ja/specdojo/samples/br-sample.md +57 -15
- package/docs/ja/specdojo/samples/ccd-sample.md +80 -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/cdr-sample.md +78 -0
- package/docs/ja/specdojo/samples/cdsd-sample.md +73 -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 +125 -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/dec-sample.md +2 -3
- 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-api-sample.yaml +0 -2
- 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/ifx-msg-sample.yaml +0 -2
- package/docs/ja/specdojo/samples/job-sequence.yaml +67 -0
- package/docs/ja/specdojo/samples/mip-index-sample.md +98 -20
- package/docs/ja/specdojo/samples/pm-communication-plan-sample.md +26 -19
- package/docs/ja/specdojo/samples/pm-members-sample.yaml +37 -13
- package/docs/ja/specdojo/samples/pm-organization-sample.md +42 -21
- package/docs/ja/specdojo/samples/pm-plan-sample.md +78 -26
- package/docs/ja/specdojo/samples/pm-quality-management-plan-sample.md +41 -22
- package/docs/ja/specdojo/samples/pm-raci-sample.md +63 -28
- package/docs/ja/specdojo/samples/pm-roles-sample.yaml +13 -12
- package/docs/ja/specdojo/samples/prj-assumptions-constraints-dependencies-sample.md +33 -25
- package/docs/ja/specdojo/samples/prj-charter-sample.md +42 -59
- package/docs/ja/specdojo/samples/prj-comparison-of-alternatives-sample.md +83 -62
- package/docs/ja/specdojo/samples/prj-success-criteria-and-acceptance-criteria-sample.md +30 -33
- package/docs/ja/specdojo/samples/sf-index-sample.md +47 -20
- package/docs/ja/specdojo/samples/sf-sample.md +109 -21
- package/docs/ja/specdojo/samples/sld-sample.md +88 -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 +141 -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/job-definition-standard.md +24 -9
- 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/cdr-template.md +58 -0
- 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 +5 -1
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +95 -8
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +38 -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/job-run.schema.yaml +23 -0
- package/docs/specdojo/schemas/v1/job.schema.yaml +63 -2
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +2 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +17 -1
- package/docs/specdojo/schemas/v1/sch-strategy.schema.yaml +2 -2
- package/package.json +10 -7
- package/templates/antigravity/orchestrator.md +7 -3
- package/templates/claude/agents/specdojo-orchestrator.md +7 -3
- package/templates/codex/agents/specdojo-orchestrator.toml +7 -3
- package/templates/codex/orchestrator.md +7 -3
- package/templates/devcontainer/tmux.conf +6 -0
- package/templates/init-exec-defaults.yaml +13 -0
- package/templates/lefthook/tools/specdojo-pre-commit.mjs +8 -0
- package/templates/opencode/agents/specdojo-orchestrator.md +8 -4
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { readSpecdojoNamespace } from "../shared/frontmatter-namespace.js";
|
|
5
|
+
import { listFilesRecursive } from "../shared/fs.js";
|
|
6
|
+
import { gitEnvironment } from "../shared/git.js";
|
|
7
|
+
import { rebasePlanConventions } from "../shared/plan-conventions.js";
|
|
8
|
+
import { recordIdentity, taskRecordPaths } from "../shared/run-records.js";
|
|
9
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
10
|
+
import { addProjectOptions, resolveProjectContext, resolveProjectId } from "./core.js";
|
|
11
|
+
import { qualifyTaskId } from "./shared.js";
|
|
12
|
+
import { listRegisteredWorktrees, worktreeNameFromTaskId } from "./worktree.js";
|
|
13
|
+
const posix = (path) => path.split(sep).join("/");
|
|
14
|
+
const json = (path) => JSON.parse(readFileSync(path, "utf8"));
|
|
15
|
+
/** Retain formatting and every non-reference value, including historical change paths. */
|
|
16
|
+
function rewriteJsonPaths(source, rewrite) {
|
|
17
|
+
JSON.parse(source);
|
|
18
|
+
const stack = [];
|
|
19
|
+
return source.replace(/"(?:[^"\\]|\\.)*"|[{}[\]]/g, (token, offset) => {
|
|
20
|
+
const parent = stack.at(-1);
|
|
21
|
+
if (token === "{" || token === "[") {
|
|
22
|
+
stack.push({ field: parent?.key ?? "", key: "" });
|
|
23
|
+
}
|
|
24
|
+
else if (token === "}" || token === "]") {
|
|
25
|
+
stack.pop();
|
|
26
|
+
}
|
|
27
|
+
else if (/^\s*:/.test(source.slice(offset + token.length))) {
|
|
28
|
+
if (parent)
|
|
29
|
+
parent.key = JSON.parse(token);
|
|
30
|
+
}
|
|
31
|
+
else if (parent &&
|
|
32
|
+
(/(?:_ref|_path)$/.test(parent.key) ||
|
|
33
|
+
(parent.key === "path" && stack.some((frame) => frame.field === "log_refs")))) {
|
|
34
|
+
return JSON.stringify(rewrite(JSON.parse(token)));
|
|
35
|
+
}
|
|
36
|
+
return token;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** Plan first, validate every destination, then mutate. No clock or random identity is used. */
|
|
40
|
+
export function planRecordMigration(repoRoot, executionPath, projectId) {
|
|
41
|
+
const root = resolve(repoRoot);
|
|
42
|
+
const execution = resolve(executionPath);
|
|
43
|
+
const repoRef = (path) => posix(relative(root, path));
|
|
44
|
+
const pairs = new Map();
|
|
45
|
+
for (const kind of ["plan", "result"]) {
|
|
46
|
+
for (const path of listFilesRecursive(join(execution, "exec", `${kind}s`)).sort()) {
|
|
47
|
+
if (!path.endsWith(`-${kind}.md`))
|
|
48
|
+
throw new Error(`Unknown legacy record: ${path}`);
|
|
49
|
+
const stem = basename(path).replace(new RegExp(`-${kind}\\.md$`), "");
|
|
50
|
+
const fm = readSpecdojoNamespace(readFileSync(path, "utf8"));
|
|
51
|
+
if (typeof fm.task_id !== "string" || !fm.task_id.trim())
|
|
52
|
+
throw new Error(`Missing task_id: ${path}`);
|
|
53
|
+
const pair = pairs.get(stem) ?? { stem, task: fm.task_id };
|
|
54
|
+
if (pair[kind] || pair.task !== fm.task_id)
|
|
55
|
+
throw new Error(`Ambiguous pair: ${stem}`);
|
|
56
|
+
pair[kind] = path;
|
|
57
|
+
pairs.set(stem, pair);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const evidenceRoot = join(execution, "exec", "evidence");
|
|
61
|
+
const directories = new Map();
|
|
62
|
+
for (const path of listFilesRecursive(evidenceRoot).sort()) {
|
|
63
|
+
const directory = dirname(path);
|
|
64
|
+
directories.set(directory, [...(directories.get(directory) ?? []), path]);
|
|
65
|
+
}
|
|
66
|
+
const groups = [];
|
|
67
|
+
for (const [directory, files] of directories) {
|
|
68
|
+
const parts = relative(evidenceRoot, directory).split(sep);
|
|
69
|
+
if (parts.length !== 2)
|
|
70
|
+
throw new Error(`Unknown evidence directory: ${directory}`);
|
|
71
|
+
const metadata = ["pipeline-state.json", "evidence.json"]
|
|
72
|
+
.map((name) => join(directory, name))
|
|
73
|
+
.filter(existsSync)
|
|
74
|
+
.map(json);
|
|
75
|
+
const state = metadata.find((record) => record.artifacts);
|
|
76
|
+
const artifacts = state?.artifacts;
|
|
77
|
+
const task = metadata[0]?.task_id ?? parts[0];
|
|
78
|
+
const run = metadata[0]?.run_id ?? parts[1];
|
|
79
|
+
if (typeof task !== "string" || typeof run !== "string")
|
|
80
|
+
throw new Error(`Invalid evidence identity: ${directory}`);
|
|
81
|
+
if (metadata.some((record) => record.task_id !== task || record.run_id !== run))
|
|
82
|
+
throw new Error(`Conflicting evidence identities: ${directory}`);
|
|
83
|
+
groups.push({
|
|
84
|
+
task,
|
|
85
|
+
run,
|
|
86
|
+
files,
|
|
87
|
+
refs: Object.values(artifacts ?? {}).filter((value) => typeof value === "string"),
|
|
88
|
+
updated: String(metadata[0]?.updated_at ?? run),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
// A retained exec worktree may still resume with the old paths and its own index.
|
|
92
|
+
// Refuse even dry-runs before planning updates; stopped processes alone are insufficient.
|
|
93
|
+
const tasks = new Set([...pairs.values(), ...groups].map(({ task }) => task));
|
|
94
|
+
if (tasks.size) {
|
|
95
|
+
for (const worktree of listRegisteredWorktrees(root)) {
|
|
96
|
+
if (!worktree.branch?.startsWith("exec/") || !existsSync(worktree.path))
|
|
97
|
+
continue;
|
|
98
|
+
for (const task of tasks) {
|
|
99
|
+
const names = [task, recordIdentity(task).itemId].map(worktreeNameFromTaskId);
|
|
100
|
+
const branchTask = worktree.branch.slice("exec/".length);
|
|
101
|
+
const matches = names.some((name) => branchTask === name ||
|
|
102
|
+
(projectId
|
|
103
|
+
? branchTask === worktreeNameFromTaskId(qualifyTaskId(projectId, name))
|
|
104
|
+
: branchTask.endsWith(`-${name}`)));
|
|
105
|
+
if (matches)
|
|
106
|
+
throw new Error(`Migration target ${task} has a retained exec worktree: ${worktree.path} ` +
|
|
107
|
+
`(${worktree.branch}). Finish or discard the run and remove its worktree before migrating`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const virtualRefs = [];
|
|
112
|
+
const moves = [];
|
|
113
|
+
const add = (from, to) => moves.push({ from: repoRef(from), to: repoRef(to) });
|
|
114
|
+
for (const group of groups) {
|
|
115
|
+
const records = taskRecordPaths(execution, group.task, group.run);
|
|
116
|
+
for (const path of group.files)
|
|
117
|
+
add(path, records.log(basename(path)));
|
|
118
|
+
virtualRefs.push({ from: repoRef(dirname(group.files[0])), to: repoRef(records.directory) });
|
|
119
|
+
}
|
|
120
|
+
const missing = [];
|
|
121
|
+
for (const pair of pairs.values()) {
|
|
122
|
+
if (!pair.plan || !pair.result)
|
|
123
|
+
missing.push({ stem: pair.stem, missing: pair.plan ? "result" : "plan" });
|
|
124
|
+
// Exact checkpoint refs are authoritative. For pre-checkpoint records, associate only
|
|
125
|
+
// an unambiguous task/pair; otherwise retain separate runs instead of guessing by time.
|
|
126
|
+
let candidates = groups.filter((group) => group.refs.some((ref) => [pair.plan, pair.result].some((path) => path && (ref === repoRef(path) || ref === posix(relative(execution, path))))));
|
|
127
|
+
if (candidates.length === 0 &&
|
|
128
|
+
[...pairs.values()].filter((p) => p.task === pair.task).length === 1)
|
|
129
|
+
candidates = groups.filter((group) => group.task === pair.task && group.refs.length === 0);
|
|
130
|
+
const latest = candidates
|
|
131
|
+
.sort((a, b) => a.updated.localeCompare(b.updated) || a.run.localeCompare(b.run))
|
|
132
|
+
.at(-1);
|
|
133
|
+
const records = taskRecordPaths(execution, pair.task, latest?.run ?? pair.stem);
|
|
134
|
+
if (pair.plan)
|
|
135
|
+
add(pair.plan, records.plan);
|
|
136
|
+
if (pair.result)
|
|
137
|
+
add(pair.result, records.result);
|
|
138
|
+
for (const kind of ["plan", "result"]) {
|
|
139
|
+
if (!pair[kind])
|
|
140
|
+
virtualRefs.push({
|
|
141
|
+
from: repoRef(join(execution, "exec", `${kind}s`, `${pair.stem}-${kind}.md`)),
|
|
142
|
+
to: repoRef(records[kind]),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
moves.sort((a, b) => a.from.localeCompare(b.from));
|
|
147
|
+
const destinations = new Set();
|
|
148
|
+
for (const move of moves) {
|
|
149
|
+
if (destinations.has(move.to) || existsSync(join(root, move.to)))
|
|
150
|
+
throw new Error(`Migration destination already exists: ${move.to}`);
|
|
151
|
+
if (isAbsolute(move.to) || move.to.startsWith("../"))
|
|
152
|
+
throw new Error(`Migration destination outside repository: ${move.to}`);
|
|
153
|
+
destinations.add(move.to);
|
|
154
|
+
}
|
|
155
|
+
// References can be repository-relative, execution-relative, or absolute under a previous
|
|
156
|
+
// checkout. Match the execution suffix without changing prose, commands, IDs, or log bodies.
|
|
157
|
+
const refs = new Map();
|
|
158
|
+
for (const move of [...moves, ...virtualRefs]) {
|
|
159
|
+
refs.set(move.from, move.to);
|
|
160
|
+
refs.set(posix(relative(execution, join(root, move.from))), posix(relative(execution, join(root, move.to))));
|
|
161
|
+
}
|
|
162
|
+
const rewrite = (value) => {
|
|
163
|
+
const direct = refs.get(value);
|
|
164
|
+
if (direct)
|
|
165
|
+
return direct;
|
|
166
|
+
for (let slash = value.indexOf("/"); slash >= 0; slash = value.indexOf("/", slash + 1)) {
|
|
167
|
+
const target = refs.get(value.slice(slash + 1));
|
|
168
|
+
if (target)
|
|
169
|
+
return `${value.slice(0, slash + 1)}${target}`;
|
|
170
|
+
}
|
|
171
|
+
return value;
|
|
172
|
+
};
|
|
173
|
+
const updates = [];
|
|
174
|
+
const targets = new Map(moves.map((move) => [move.from, move.to]));
|
|
175
|
+
const structured = [
|
|
176
|
+
...moves.map((move) => join(root, move.from)),
|
|
177
|
+
...listFilesRecursive(join(execution, "jobs", "runs")),
|
|
178
|
+
];
|
|
179
|
+
for (const path of structured) {
|
|
180
|
+
if (!/\.(json|md)$/.test(path))
|
|
181
|
+
continue;
|
|
182
|
+
const original = readFileSync(path, "utf8");
|
|
183
|
+
let content = original;
|
|
184
|
+
if (path.endsWith(".json")) {
|
|
185
|
+
content = rewriteJsonPaths(original, rewrite);
|
|
186
|
+
}
|
|
187
|
+
else if (path.endsWith(".md")) {
|
|
188
|
+
content = original.replace(/^---\r?\n[\s\S]*?\r?\n---/, (fm) => fm.replace(/^(\s*[\w]+(?:_ref|_path):\s*)([^\r\n]+)$/gm, (_line, key, raw) => {
|
|
189
|
+
const quote = raw.startsWith('"') ? '"' : raw.startsWith("'") ? "'" : "";
|
|
190
|
+
const value = quote ? raw.slice(1, -1) : raw;
|
|
191
|
+
return `${key}${quote}${rewrite(value)}${quote}`;
|
|
192
|
+
}));
|
|
193
|
+
if (path.endsWith("-plan.md"))
|
|
194
|
+
content = rebasePlanConventions(content, path, join(root, targets.get(repoRef(path))));
|
|
195
|
+
}
|
|
196
|
+
if (content !== original)
|
|
197
|
+
updates.push({ path: targets.get(repoRef(path)) ?? repoRef(path), content });
|
|
198
|
+
}
|
|
199
|
+
return { moves, updates, missing, skipped: [] };
|
|
200
|
+
}
|
|
201
|
+
export function applyRecordMigration(repoRoot, plan) {
|
|
202
|
+
if (!plan.moves.length && !plan.updates.length)
|
|
203
|
+
return;
|
|
204
|
+
const tracked = spawnSync("git", ["ls-files", "-z"], {
|
|
205
|
+
cwd: repoRoot,
|
|
206
|
+
env: gitEnvironment(),
|
|
207
|
+
encoding: "utf8",
|
|
208
|
+
});
|
|
209
|
+
if (tracked.status !== 0)
|
|
210
|
+
throw new Error(`git ls-files failed: ${tracked.stderr}`);
|
|
211
|
+
const files = new Set(tracked.stdout.split("\0"));
|
|
212
|
+
for (const move of plan.moves) {
|
|
213
|
+
if (!files.has(move.from))
|
|
214
|
+
throw new Error(`Migration source is not tracked: ${move.from}`);
|
|
215
|
+
}
|
|
216
|
+
for (const move of plan.moves) {
|
|
217
|
+
mkdirSync(dirname(join(repoRoot, move.to)), { recursive: true });
|
|
218
|
+
const result = spawnSync("git", ["mv", "--", move.from, move.to], {
|
|
219
|
+
cwd: repoRoot,
|
|
220
|
+
env: gitEnvironment(),
|
|
221
|
+
encoding: "utf8",
|
|
222
|
+
});
|
|
223
|
+
if (result.status !== 0)
|
|
224
|
+
throw new Error(`git mv failed: ${move.from}: ${result.stderr}`);
|
|
225
|
+
}
|
|
226
|
+
for (const update of plan.updates)
|
|
227
|
+
writeFileSync(join(repoRoot, update.path), update.content);
|
|
228
|
+
}
|
|
229
|
+
export function registerRecordMigrationCommand(exec) {
|
|
230
|
+
const command = exec
|
|
231
|
+
.command("migrate-records")
|
|
232
|
+
.description("Move tracked legacy run records with git mv");
|
|
233
|
+
addProjectOptions(command);
|
|
234
|
+
command.option("--dry-run", "List moves and reference updates without writing", false);
|
|
235
|
+
command.action((opts) => {
|
|
236
|
+
try {
|
|
237
|
+
const { executionPath } = resolveProjectContext(opts);
|
|
238
|
+
const root = specdojoRootDir();
|
|
239
|
+
const plan = planRecordMigration(root, executionPath, resolveProjectId(opts));
|
|
240
|
+
process.stdout.write(`${JSON.stringify({ ...plan, updates: plan.updates.map(({ path }) => path) }, null, 2)}\n`);
|
|
241
|
+
if (!opts.dryRun)
|
|
242
|
+
applyRecordMigration(root, plan);
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
process.stderr.write(`blocked: ${error instanceof Error ? error.message : String(error)}; need=resolve migration precondition; ref=${opts.project ?? "current project"}\n`);
|
|
246
|
+
process.exitCode = 1;
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { performance } from "node:perf_hooks";
|
|
4
|
+
import { StringDecoder } from "node:string_decoder";
|
|
5
|
+
import { recordValidationGateWait, validationMetric, ValidationTestFiles, } from "./validation-metrics.js";
|
|
3
6
|
import { gitEnvironment } from "./worktree.js";
|
|
4
7
|
import { acquirePoolSlot, getActiveExecLocksDir, releaseLock } from "./slot-lock.js";
|
|
5
|
-
import { redactSensitiveText } from "./evidence.js";
|
|
8
|
+
import { MAX_CHANGE_FILES, redactSensitiveText } from "./evidence.js";
|
|
6
9
|
import { PROJECT_REPO_WORKTREE_DIRNAME, REPO_NAME_PATTERN } from "../shared/specdojo-config.js";
|
|
7
10
|
export const MAX_PARENT_VALIDATION_STREAM_BYTES = 1024 * 1024;
|
|
8
11
|
const MAX_SUMMARY_LENGTH = 1_000;
|
|
@@ -164,15 +167,25 @@ function isRecord(value) {
|
|
|
164
167
|
function assignmentLabel(id, repo) {
|
|
165
168
|
return repo === PARENT_VALIDATION_PROJECT_REPO ? id : `${repo}:${id}`;
|
|
166
169
|
}
|
|
170
|
+
function parsePaths(value, where) {
|
|
171
|
+
if (value === undefined)
|
|
172
|
+
return undefined;
|
|
173
|
+
if (!Array.isArray(value) ||
|
|
174
|
+
value.length === 0 ||
|
|
175
|
+
!value.every((pattern) => typeof pattern === "string" && pattern.trim().length > 0)) {
|
|
176
|
+
throw new Error(`${where}.paths must be a non-empty array of non-empty glob strings`);
|
|
177
|
+
}
|
|
178
|
+
return value.map((pattern) => pattern.trim());
|
|
179
|
+
}
|
|
167
180
|
function parseEntry(entry, index) {
|
|
168
181
|
const where = `pipeline.parent_validations[${index}] in exec-defaults`;
|
|
169
182
|
if (typeof entry === "string")
|
|
170
183
|
return { id: entry, repo: PARENT_VALIDATION_PROJECT_REPO };
|
|
171
184
|
if (!isRecord(entry)) {
|
|
172
|
-
throw new Error(`${where} must be a validation id or { id, repo }: ${JSON.stringify(entry)}`);
|
|
185
|
+
throw new Error(`${where} must be a validation id or { id, repo?, paths? }: ${JSON.stringify(entry)}`);
|
|
173
186
|
}
|
|
174
187
|
const unknownKeys = Object.keys(entry)
|
|
175
|
-
.filter((key) => key !== "id" && key !== "repo")
|
|
188
|
+
.filter((key) => key !== "id" && key !== "repo" && key !== "paths")
|
|
176
189
|
.sort();
|
|
177
190
|
if (unknownKeys.length > 0) {
|
|
178
191
|
throw new Error(`${where}: unknown key(s) ${unknownKeys.map((key) => `"${key}"`).join(", ")}`);
|
|
@@ -180,17 +193,22 @@ function parseEntry(entry, index) {
|
|
|
180
193
|
if (typeof entry.id !== "string" || entry.id.length === 0) {
|
|
181
194
|
throw new Error(`${where}.id must be a non-empty string`);
|
|
182
195
|
}
|
|
183
|
-
|
|
196
|
+
const paths = parsePaths(entry.paths, where);
|
|
197
|
+
if (entry.repo === undefined && paths === undefined) {
|
|
198
|
+
throw new Error(`${where} must set repo or paths when written as an object`);
|
|
199
|
+
}
|
|
200
|
+
const repo = entry.repo ?? PARENT_VALIDATION_PROJECT_REPO;
|
|
201
|
+
if (typeof repo !== "string" || !REPO_NAME_PATTERN.test(repo)) {
|
|
184
202
|
throw new Error(`${where}.repo must match ${String(REPO_NAME_PATTERN)} (got ${JSON.stringify(entry.repo)})`);
|
|
185
203
|
}
|
|
186
|
-
return { id: entry.id, repo:
|
|
204
|
+
return { id: entry.id, repo, ...(paths ? { paths } : {}) };
|
|
187
205
|
}
|
|
188
206
|
export function resolveParentValidationAssignments(entries) {
|
|
189
207
|
if (!entries)
|
|
190
208
|
return [];
|
|
191
209
|
const seen = new Set();
|
|
192
210
|
return entries.map((entry, index) => {
|
|
193
|
-
const { id, repo } = parseEntry(entry, index);
|
|
211
|
+
const { id, repo, paths } = parseEntry(entry, index);
|
|
194
212
|
const label = assignmentLabel(id, repo);
|
|
195
213
|
if (seen.has(label)) {
|
|
196
214
|
throw new Error(`Duplicate parent validation id in exec-defaults: ${label}`);
|
|
@@ -202,9 +220,76 @@ export function resolveParentValidationAssignments(entries) {
|
|
|
202
220
|
if (!definition) {
|
|
203
221
|
throw new Error(`Unknown parent validation id in exec-defaults: ${id} (allowed: ${Object.keys(PARENT_VALIDATION_REGISTRY).join(", ")})`);
|
|
204
222
|
}
|
|
205
|
-
return { definition, repo, label };
|
|
223
|
+
return { definition, repo, label, ...(paths ? { paths } : {}) };
|
|
206
224
|
});
|
|
207
225
|
}
|
|
226
|
+
function escapeRegExp(value) {
|
|
227
|
+
return value.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
228
|
+
}
|
|
229
|
+
// lefthook の glob と同じ書き方のうち、`**`・`*`・`?`・入れ子のない `{a,b}` だけを扱う。
|
|
230
|
+
function globSource(pattern) {
|
|
231
|
+
let source = "";
|
|
232
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
233
|
+
const char = pattern[index];
|
|
234
|
+
if (char === "*" && pattern[index + 1] === "*") {
|
|
235
|
+
const followedBySlash = pattern[index + 2] === "/";
|
|
236
|
+
source += followedBySlash ? "(?:.*/)?" : ".*";
|
|
237
|
+
index += followedBySlash ? 2 : 1;
|
|
238
|
+
}
|
|
239
|
+
else if (char === "*") {
|
|
240
|
+
source += "[^/]*";
|
|
241
|
+
}
|
|
242
|
+
else if (char === "?") {
|
|
243
|
+
source += "[^/]";
|
|
244
|
+
}
|
|
245
|
+
else if (char === "{" && pattern.indexOf("}", index) > index) {
|
|
246
|
+
const end = pattern.indexOf("}", index);
|
|
247
|
+
const alternatives = pattern
|
|
248
|
+
.slice(index + 1, end)
|
|
249
|
+
.split(",")
|
|
250
|
+
.map(globSource);
|
|
251
|
+
source += `(?:${alternatives.join("|")})`;
|
|
252
|
+
index = end;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
source += escapeRegExp(char);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return source;
|
|
259
|
+
}
|
|
260
|
+
export function matchesParentValidationPaths(path, patterns) {
|
|
261
|
+
return patterns.some((pattern) => new RegExp(`^${globSource(pattern)}$`).test(path));
|
|
262
|
+
}
|
|
263
|
+
// evidence の変更一覧は、プロジェクトの変更を相対パス、プロダクトの変更を `<repo>:<path>`、
|
|
264
|
+
// 名前の変更を `old -> new` で記録する。割り当てたリポジトリの相対パスへ戻して照合する。
|
|
265
|
+
function changedPathsForRepo(changedPaths, repo, productRepos) {
|
|
266
|
+
const sides = changedPaths.flatMap((path) => path.split(" -> "));
|
|
267
|
+
if (repo !== PARENT_VALIDATION_PROJECT_REPO) {
|
|
268
|
+
const prefix = `${repo}:`;
|
|
269
|
+
return sides.filter((path) => path.startsWith(prefix)).map((path) => path.slice(prefix.length));
|
|
270
|
+
}
|
|
271
|
+
return sides.filter((path) => !productRepos.some((name) => path.startsWith(`${name}:`)));
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Selection from the executor's recorded changes. A truncated change list (the evidence keeps at
|
|
275
|
+
* most MAX_CHANGE_FILES entries) is treated as unknown so no validation is skipped.
|
|
276
|
+
*/
|
|
277
|
+
export function parentValidationSelectionForEvidence(evidence) {
|
|
278
|
+
if (evidence.changes.length >= MAX_CHANGE_FILES)
|
|
279
|
+
return {};
|
|
280
|
+
return { changedPaths: evidence.changes.map((change) => change.path) };
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Whether a validation declared with `paths` is skipped for the given change set. Validations
|
|
284
|
+
* without `paths` always run, and so does every validation when the change set is unknown.
|
|
285
|
+
*/
|
|
286
|
+
export function isParentValidationSkipped(assignment, selection, productRepos = []) {
|
|
287
|
+
const patterns = assignment.paths;
|
|
288
|
+
const changedPaths = selection?.changedPaths;
|
|
289
|
+
if (!patterns || changedPaths === undefined)
|
|
290
|
+
return false;
|
|
291
|
+
return !changedPathsForRepo(changedPaths, assignment.repo, productRepos).some((path) => matchesParentValidationPaths(path, patterns));
|
|
292
|
+
}
|
|
208
293
|
export function resolveParentValidationDefinitions(entries) {
|
|
209
294
|
return resolveParentValidationAssignments(entries).map((assignment) => assignment.definition);
|
|
210
295
|
}
|
|
@@ -224,21 +309,30 @@ async function invokeParentValidation(definition, cwd) {
|
|
|
224
309
|
const stderrCapture = { chunks: [], totalBytes: 0 };
|
|
225
310
|
let settled = false;
|
|
226
311
|
let timedOut = false;
|
|
312
|
+
const testFiles = new ValidationTestFiles();
|
|
313
|
+
const stdoutDecoder = new StringDecoder("utf8");
|
|
227
314
|
const child = spawn(definition.command, [...definition.args], {
|
|
228
315
|
cwd,
|
|
229
|
-
env: gitEnvironment(),
|
|
316
|
+
env: { ...gitEnvironment(), SPECDOJO_PARENT_VALIDATION_METRICS: "1" },
|
|
230
317
|
shell: false,
|
|
231
318
|
stdio: ["ignore", "pipe", "pipe"],
|
|
232
319
|
windowsHide: true,
|
|
233
320
|
});
|
|
234
321
|
child.stdout.on("data", (chunk) => {
|
|
235
322
|
appendBounded(stdoutCapture, chunk);
|
|
323
|
+
testFiles.observe(stdoutDecoder.write(chunk));
|
|
236
324
|
});
|
|
237
325
|
child.stderr.on("data", (chunk) => {
|
|
238
326
|
appendBounded(stderrCapture, chunk);
|
|
239
327
|
});
|
|
240
328
|
const timer = setTimeout(() => {
|
|
241
329
|
timedOut = true;
|
|
330
|
+
validationMetric("validation-timeout", {
|
|
331
|
+
id: definition.id,
|
|
332
|
+
cwd,
|
|
333
|
+
timeout_ms: definition.timeoutMs,
|
|
334
|
+
...testFiles.snapshot(),
|
|
335
|
+
});
|
|
242
336
|
child.kill("SIGTERM");
|
|
243
337
|
}, definition.timeoutMs);
|
|
244
338
|
const finish = (result) => {
|
|
@@ -291,15 +385,33 @@ function validationSummary(result) {
|
|
|
291
385
|
* without spawning anything. Results carry `repo` when the run spans product repositories or the
|
|
292
386
|
* assignment names one, so single-repository evidence keeps its previous shape.
|
|
293
387
|
*/
|
|
294
|
-
export async function runParentValidationBatch(entries, cwd, invoke = invokeParentValidation) {
|
|
388
|
+
export async function runParentValidationBatch(entries, cwd, invoke = invokeParentValidation, selection) {
|
|
295
389
|
const assignments = resolveParentValidationAssignments(entries);
|
|
296
390
|
const roots = typeof cwd === "string" ? { project: cwd } : cwd;
|
|
297
391
|
const recordsRepo = Object.keys(roots.repos ?? {}).length > 0 ||
|
|
298
392
|
assignments.some((assignment) => assignment.repo !== PARENT_VALIDATION_PROJECT_REPO);
|
|
299
393
|
const validations = [];
|
|
300
394
|
const failureOutputs = [];
|
|
301
|
-
|
|
395
|
+
const productRepos = Object.keys(roots.repos ?? {});
|
|
396
|
+
for (const assignment of assignments) {
|
|
397
|
+
const { definition, repo } = assignment;
|
|
302
398
|
const repoField = recordsRepo ? { repo } : {};
|
|
399
|
+
if (isParentValidationSkipped(assignment, selection, productRepos)) {
|
|
400
|
+
// 変更の種類に合わない検証は流さず、記録だけを残す(PJR-T01P)。ラベルの並びを保つため、
|
|
401
|
+
// 再開時の hasRecordedParentValidations は流し直しを要求しない。
|
|
402
|
+
const reason = truncateHead(`skipped by change type: no changed file matches paths (${(assignment.paths ?? []).join(", ")})`, MAX_SUMMARY_LENGTH);
|
|
403
|
+
validations.push({
|
|
404
|
+
id: definition.id,
|
|
405
|
+
source: "runner",
|
|
406
|
+
...repoField,
|
|
407
|
+
command: definition.displayCommand,
|
|
408
|
+
status: "not_applicable",
|
|
409
|
+
summary: reason,
|
|
410
|
+
reason,
|
|
411
|
+
});
|
|
412
|
+
validationMetric("validation-skipped", { id: definition.id, repo, reason });
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
303
415
|
const root = repo === PARENT_VALIDATION_PROJECT_REPO
|
|
304
416
|
? roots.project
|
|
305
417
|
: Object.hasOwn(roots.repos ?? {}, repo)
|
|
@@ -317,8 +429,38 @@ export async function runParentValidationBatch(entries, cwd, invoke = invokePare
|
|
|
317
429
|
});
|
|
318
430
|
continue;
|
|
319
431
|
}
|
|
320
|
-
const
|
|
432
|
+
const startedAt = new Date().toISOString();
|
|
433
|
+
const started = performance.now();
|
|
434
|
+
validationMetric("validation-start", {
|
|
435
|
+
id: definition.id,
|
|
436
|
+
repo,
|
|
437
|
+
started_at: startedAt,
|
|
438
|
+
timeout_ms: definition.timeoutMs,
|
|
439
|
+
});
|
|
440
|
+
let result;
|
|
441
|
+
try {
|
|
442
|
+
result = await invoke(definition, root);
|
|
443
|
+
}
|
|
444
|
+
catch (error) {
|
|
445
|
+
validationMetric("validation-end", {
|
|
446
|
+
id: definition.id,
|
|
447
|
+
repo,
|
|
448
|
+
started_at: startedAt,
|
|
449
|
+
duration_ms: performance.now() - started,
|
|
450
|
+
error: String(error),
|
|
451
|
+
});
|
|
452
|
+
throw error;
|
|
453
|
+
}
|
|
321
454
|
const passed = result.exitCode === 0 && !result.error && !result.timedOut;
|
|
455
|
+
validationMetric("validation-end", {
|
|
456
|
+
id: definition.id,
|
|
457
|
+
repo,
|
|
458
|
+
started_at: startedAt,
|
|
459
|
+
duration_ms: performance.now() - started,
|
|
460
|
+
exit_code: result.exitCode,
|
|
461
|
+
timed_out: result.timedOut === true,
|
|
462
|
+
status: passed ? "passed" : "failed",
|
|
463
|
+
});
|
|
322
464
|
validations.push({
|
|
323
465
|
id: definition.id,
|
|
324
466
|
source: "runner",
|
|
@@ -338,8 +480,8 @@ export async function runParentValidationBatch(entries, cwd, invoke = invokePare
|
|
|
338
480
|
}
|
|
339
481
|
return { validations, failureOutputs };
|
|
340
482
|
}
|
|
341
|
-
export async function runParentValidations(entries, cwd, invoke = invokeParentValidation) {
|
|
342
|
-
return (await runParentValidationBatch(entries, cwd, invoke)).validations;
|
|
483
|
+
export async function runParentValidations(entries, cwd, invoke = invokeParentValidation, selection) {
|
|
484
|
+
return (await runParentValidationBatch(entries, cwd, invoke, selection)).validations;
|
|
343
485
|
}
|
|
344
486
|
/** `<id>` or `<repo>:<id>` of a recorded runner validation (no `repo` means the project). */
|
|
345
487
|
export function recordedParentValidationLabel(validation) {
|
|
@@ -384,14 +526,24 @@ export class ParentValidationGate {
|
|
|
384
526
|
this.lockRoot = lockRoot;
|
|
385
527
|
}
|
|
386
528
|
async run(label, ids, task) {
|
|
529
|
+
const queued = performance.now();
|
|
530
|
+
validationMetric("gate-queued", {
|
|
531
|
+
ids,
|
|
532
|
+
running: [...this.active],
|
|
533
|
+
queued: this.waiters.length,
|
|
534
|
+
});
|
|
387
535
|
await this.acquire(label, ids);
|
|
536
|
+
const localWaitMs = performance.now() - queued;
|
|
388
537
|
try {
|
|
389
|
-
if (!this.lockRoot)
|
|
538
|
+
if (!this.lockRoot) {
|
|
539
|
+
recordValidationGateWait(queued, localWaitMs);
|
|
390
540
|
return await task();
|
|
541
|
+
}
|
|
391
542
|
const slot = await acquirePoolSlot(parentValidationPoolPath(this.lockRoot), this.limit, { actor: "parent-validation", label }, {
|
|
392
543
|
onWait: () => this.log(` Waiting for parent validation slot held by another exec run: ${label} (${ids.join(", ")})\n`),
|
|
393
544
|
});
|
|
394
545
|
try {
|
|
546
|
+
recordValidationGateWait(queued, localWaitMs);
|
|
395
547
|
return await task();
|
|
396
548
|
}
|
|
397
549
|
finally {
|
|
@@ -439,11 +591,53 @@ export function parentValidationGateFor(execDefaults, lockRoot = getActiveExecLo
|
|
|
439
591
|
return gate;
|
|
440
592
|
}
|
|
441
593
|
export function failedParentValidationReason(validations) {
|
|
442
|
-
|
|
594
|
+
// runner の `not_applicable` は、`paths` に合う変更が無く流さなかった検証である(PJR-T01P)。
|
|
595
|
+
const failed = validations.filter((validation) => validation.source === "runner" &&
|
|
596
|
+
validation.status !== "passed" &&
|
|
597
|
+
validation.status !== "not_applicable");
|
|
443
598
|
if (failed.length === 0)
|
|
444
599
|
return undefined;
|
|
445
600
|
return `parent validation failed: ${failed.map(recordedParentValidationLabel).join(", ")}`;
|
|
446
601
|
}
|
|
602
|
+
// PJR-Q2AT: executor が親検証をまとめて 1 行(例: `parent runner: lint-ts, lint-fm`、
|
|
603
|
+
// `親 runner 指定検査(lint-ts, lint-fm)`)に書いた場合に、末尾の区切り列を検証ラベルとして取り出す。
|
|
604
|
+
const AGGREGATE_LABEL_PATTERN = "(?:[A-Za-z0-9][A-Za-z0-9_-]*:)?[a-z][a-z0-9-]*";
|
|
605
|
+
const AGGREGATE_LINE_PATTERN = new RegExp(`^(\\S.*?)(?:[::((\\[]|\\s)\\s*(${AGGREGATE_LABEL_PATTERN}(?:\\s*[,、]\\s*${AGGREGATE_LABEL_PATTERN})*)\\s*[))\\]]?\\s*$`, "u");
|
|
606
|
+
// コマンドそのもの(`npm run lint:md` など)をまとめた行と取り違えない。
|
|
607
|
+
const COMMAND_PREFIX_PATTERN = /^(?:npm|npx|pnpm|yarn|node|tsx|specdojo)(?:\s|$)/u;
|
|
608
|
+
function aggregatedParentValidationLabels(command) {
|
|
609
|
+
const normalized = command.trim().replace(/\s+/gu, " ");
|
|
610
|
+
if (COMMAND_PREFIX_PATTERN.test(normalized))
|
|
611
|
+
return undefined;
|
|
612
|
+
const match = AGGREGATE_LINE_PATTERN.exec(normalized);
|
|
613
|
+
if (!match)
|
|
614
|
+
return undefined;
|
|
615
|
+
return match[2].split(/\s*[,、]\s*/u).filter((label) => label.length > 0);
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Whether an executor validation line that lists parent validation labels together
|
|
619
|
+
* (e.g. `parent runner: lint-ts, lint-fm`) is covered by the runner's own results.
|
|
620
|
+
* Every listed label must have a runner record (so it is configured in
|
|
621
|
+
* `pipeline.parent_validations`) that passed or was skipped by change type.
|
|
622
|
+
*/
|
|
623
|
+
export function isAggregatedParentValidationSatisfied(command, validations) {
|
|
624
|
+
const labels = aggregatedParentValidationLabels(command);
|
|
625
|
+
if (!labels || labels.length === 0)
|
|
626
|
+
return false;
|
|
627
|
+
const runnerStatuses = new Map();
|
|
628
|
+
for (const validation of validations) {
|
|
629
|
+
if (validation.source !== "runner" || typeof validation.id !== "string")
|
|
630
|
+
continue;
|
|
631
|
+
const label = recordedParentValidationLabel(validation);
|
|
632
|
+
runnerStatuses.set(label, [...(runnerStatuses.get(label) ?? []), validation.status]);
|
|
633
|
+
}
|
|
634
|
+
return labels.every((label) => {
|
|
635
|
+
const statuses = runnerStatuses.get(label);
|
|
636
|
+
return (statuses !== undefined &&
|
|
637
|
+
statuses.length > 0 &&
|
|
638
|
+
statuses.every((status) => status === "passed" || status === "not_applicable"));
|
|
639
|
+
});
|
|
640
|
+
}
|
|
447
641
|
/**
|
|
448
642
|
* Replaces stale runner-owned validation results while preserving executor-owned evidence.
|
|
449
643
|
* The caller must supply results produced from the fixed parent-validation allowlist.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { runEvidencePath, taskEvidencePaths } from "./run-records.js";
|
|
4
|
+
import { ensureDir } from "./shared.js";
|
|
4
5
|
function emptyStage(actor) {
|
|
5
6
|
return {
|
|
6
7
|
status: "pending",
|
|
@@ -33,7 +34,7 @@ function executionRelative(repoRoot, executionPath) {
|
|
|
33
34
|
return rel;
|
|
34
35
|
}
|
|
35
36
|
export function pipelineStateLocation(input) {
|
|
36
|
-
const path = join(input.worktreePath, executionRelative(input.repoRoot, input.executionPath),
|
|
37
|
+
const path = taskEvidencePaths(join(input.worktreePath, executionRelative(input.repoRoot, input.executionPath)), input.taskId, input.runId).state;
|
|
37
38
|
return { path, ref: relative(input.worktreePath, path).split(sep).join("/") };
|
|
38
39
|
}
|
|
39
40
|
function isStageState(value) {
|
|
@@ -196,6 +197,29 @@ function resolveArtifactRef(worktreePath, ref) {
|
|
|
196
197
|
return null;
|
|
197
198
|
return path;
|
|
198
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Validations recorded in the executor evidence of a run (PJR-T01P: the integration commit reads
|
|
202
|
+
* the parent-validation results). Returns an empty list when the state or evidence is unreadable.
|
|
203
|
+
*/
|
|
204
|
+
export function recordedRunValidations(worktreePath, statePath) {
|
|
205
|
+
if (!statePath || !existsSync(statePath))
|
|
206
|
+
return [];
|
|
207
|
+
try {
|
|
208
|
+
const state = readPipelineState(statePath);
|
|
209
|
+
const ref = state.stages.executor.artifact_ref;
|
|
210
|
+
const evidencePath = ref ? resolveArtifactRef(worktreePath, ref) : null;
|
|
211
|
+
if (!evidencePath || !existsSync(evidencePath))
|
|
212
|
+
return [];
|
|
213
|
+
const evidence = JSON.parse(readFileSync(evidencePath, "utf8"));
|
|
214
|
+
if (!isExecutorEvidence(evidence, state.task_id, state.run_id))
|
|
215
|
+
return [];
|
|
216
|
+
return Array.isArray(evidence.validations) ? evidence.validations : [];
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
// 読めない場合は hook を外さない(すべて流す)側へ倒す。
|
|
220
|
+
return [];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
199
223
|
function isExecutorEvidence(value, taskId, runId) {
|
|
200
224
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
201
225
|
return false;
|
|
@@ -226,9 +250,7 @@ export function loadPipelineResumeCheckpoint(input) {
|
|
|
226
250
|
const recordedEvidenceRef = state.stages.executor.artifact_ref;
|
|
227
251
|
const evidenceRef = recordedEvidenceRef ??
|
|
228
252
|
(state.stages.executor.status === "running"
|
|
229
|
-
? relative(input.worktreePath,
|
|
230
|
-
.split(sep)
|
|
231
|
-
.join("/")
|
|
253
|
+
? relative(input.worktreePath, runEvidencePath(statePath)).split(sep).join("/")
|
|
232
254
|
: null);
|
|
233
255
|
if (!evidenceRef)
|
|
234
256
|
return { state, statePath };
|