specdojo 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/README.md +77 -18
- package/dist/catalog/build-references.js +144 -0
- package/dist/catalog/build-render.js +32 -0
- package/dist/{catalog-build.js → catalog/build.js} +18 -295
- package/dist/{catalog.js → catalog/catalog.js} +11 -11
- package/dist/{catalog-generate.js → catalog/generate.js} +13 -16
- package/dist/catalog/paths.js +1 -0
- package/dist/{catalog-plan-generate.js → catalog/plan-generate.js} +5 -5
- package/dist/{catalog-plan.js → catalog/plan.js} +9 -9
- package/dist/{catalog-scaffold.js → catalog/scaffold.js} +6 -6
- package/dist/{agent.js → commands/agent.js} +11 -11
- package/dist/{build-command.js → commands/build.js} +2 -2
- package/dist/{init-command.js → commands/init.js} +103 -37
- package/dist/{orchestrator.js → commands/orchestrator.js} +2 -2
- package/dist/{watch.js → commands/watch.js} +3 -3
- package/dist/dashboard/dashboard-timeline.js +175 -0
- package/dist/{dashboard.js → dashboard/dashboard.js} +16 -549
- package/dist/dashboard/exec-records.js +105 -0
- package/dist/dashboard/routines.js +256 -0
- package/dist/dashboard/shared.js +14 -0
- package/dist/{timeline-build.js → dashboard/timeline-build.js} +2 -1
- package/dist/{timeline.js → dashboard/timeline.js} +1 -1
- package/dist/{deliverable.js → deliverable/deliverable.js} +5 -5
- package/dist/{deliverable-trash.js → deliverable/trash.js} +7 -7
- package/dist/{devcontainer-command.js → devcontainer/command.js} +5 -3
- package/dist/{devcontainer-scaffold.js → devcontainer/scaffold.js} +94 -2
- package/dist/{doc-index.js → docs/doc-index.js} +3 -3
- package/dist/{frontmatter-namespace.js → docs/frontmatter-namespace.js} +2 -2
- package/dist/{index-command.js → docs/index-command.js} +1 -1
- package/dist/docs/template-resolution.js +1 -0
- package/dist/{viewpoint-document-kinds-check.js → docs/viewpoint-document-kinds-check.js} +3 -3
- package/dist/{yaml-pages-command.js → docs/yaml-pages-command.js} +1 -1
- package/dist/{yaml-pages.js → docs/yaml-pages.js} +5 -5
- package/dist/{exec-agent-config.js → exec/agent-config.js} +33 -4
- package/dist/{exec-agent-git-state.js → exec/agent-git-state.js} +1 -1
- package/dist/{exec-agent-protected-config.js → exec/agent-protected-config.js} +1 -1
- package/dist/{exec.js → exec/commands.js} +22 -467
- package/dist/exec/core.js +457 -0
- package/dist/{exec-events.js → exec/events.js} +2 -2
- package/dist/{exec-evidence.js → exec/evidence.js} +11 -6
- package/dist/exec/exec.js +2 -0
- package/dist/exec/format.js +1 -0
- package/dist/{exec-handoff.js → exec/handoff.js} +13 -12
- package/dist/{exec-limit.js → exec/limit.js} +93 -12
- package/dist/{exec-parent-validation.js → exec/parent-validation.js} +4 -4
- package/dist/{exec-pipeline-state.js → exec/pipeline-state.js} +16 -2
- package/dist/{exec-plans.js → exec/plans-core.js} +97 -468
- package/dist/exec/plans-generation.js +249 -0
- package/dist/exec/plans-storage.js +131 -0
- package/dist/exec/plans.js +3 -0
- package/dist/{exec-project.js → exec/project.js} +1 -1
- package/dist/{exec-protection-handoff.js → exec/protection-handoff.js} +3 -3
- package/dist/{exec-register-resume.js → exec/register-resume.js} +2 -2
- package/dist/{exec-register.js → exec/register.js} +92 -9
- package/dist/exec/repo-integration-git.js +23 -0
- package/dist/exec/repo-integration-sync.js +264 -0
- package/dist/{exec-repo-integration.js → exec/repo-integration.js} +13 -287
- package/dist/{exec-repo-trace.js → exec/repo-trace.js} +3 -3
- package/dist/exec/reporter-output.js +206 -0
- package/dist/{exec-reporter.js → exec/reporter.js} +29 -216
- package/dist/{exec-results.js → exec/results.js} +277 -36
- package/dist/exec/run/agent-pipeline.js +276 -0
- package/dist/exec/run/agent.js +583 -0
- package/dist/exec/run/in-place.js +570 -0
- package/dist/exec/run/job.js +746 -0
- package/dist/exec/run/lifecycle-commands.js +530 -0
- package/dist/{exec-run-lock.js → exec/run/lock.js} +4 -3
- package/dist/exec/run/mode-shared.js +140 -0
- package/dist/exec/run/register-command.js +252 -0
- package/dist/exec/run/register-core.js +411 -0
- package/dist/exec/run/register-mode.js +210 -0
- package/dist/exec/run/register-resume.js +398 -0
- package/dist/exec/run/register-state.js +325 -0
- package/dist/exec/run/register-worktree.js +540 -0
- package/dist/exec/run/run.js +11 -0
- package/dist/exec/run/schedule-mode.js +294 -0
- package/dist/exec/run/schedule-prepare.js +366 -0
- package/dist/exec/run/schedule-task.js +599 -0
- package/dist/exec/run/shared.js +449 -0
- package/dist/{exec-schedule-calendar.js → exec/schedule/calendar.js} +1 -1
- package/dist/{exec-schedule-cpm.js → exec/schedule/cpm.js} +2 -2
- package/dist/{exec-schedule-gantt-chart-render.js → exec/schedule/gantt-chart-render.js} +2 -2
- package/dist/exec/schedule/gantt-chart.js +2 -0
- package/dist/{exec-schedule-hash.js → exec/schedule/hash.js} +2 -2
- package/dist/exec/schedule/index.js +1 -0
- package/dist/{exec-schedule-initial.js → exec/schedule/initial.js} +2 -2
- package/dist/{exec-schedule-progress.js → exec/schedule/progress.js} +2 -2
- package/dist/{exec-schedule-ready.js → exec/schedule/ready.js} +2 -2
- package/dist/{exec-schedule.js → exec/schedule/schedule.js} +11 -11
- package/dist/exec/shared.js +63 -0
- package/dist/exec/slot-lock.js +1 -0
- package/dist/{exec-strategy.js → exec/strategy.js} +2 -2
- package/dist/{exec-task-repos.js → exec/task-repos.js} +2 -2
- package/dist/{exec-task-view.js → exec/task-view.js} +4 -4
- package/dist/{exec-trial.js → exec/trial-commands.js} +23 -388
- package/dist/exec/trial-core.js +371 -0
- package/dist/exec/trial.js +2 -0
- package/dist/{exec-worktree-command.js → exec/worktree-command.js} +25 -23
- package/dist/exec/worktree-ops-commit.js +672 -0
- package/dist/exec/worktree-ops-lifecycle.js +297 -0
- package/dist/exec/worktree-ops-merge.js +344 -0
- package/dist/exec/worktree-ops.js +3 -0
- package/dist/exec/worktree.js +305 -0
- package/dist/grade/apply.js +734 -0
- package/dist/grade/command-apply.js +250 -0
- package/dist/grade/command-inspect.js +138 -0
- package/dist/grade/command-plan.js +101 -0
- package/dist/grade/command-shared.js +68 -0
- package/dist/grade/core.js +307 -0
- package/dist/grade/grade.js +19 -0
- package/dist/grade/markdown.js +274 -0
- package/dist/grade/pipeline-state.js +184 -0
- package/dist/grade/plan.js +507 -0
- package/dist/{grade-result.js → grade/result.js} +7 -96
- package/dist/grade/target-discovery.js +265 -0
- package/dist/grade/targets.js +435 -0
- package/dist/{job.js → job/definition.js} +32 -574
- package/dist/job/job.js +568 -0
- package/dist/{kata-command.js → kata/command.js} +4 -4
- package/dist/{kata.js → kata/kata.js} +5 -5
- package/dist/register/approach.js +134 -0
- package/dist/register/command-types.js +1 -0
- package/dist/register/core.js +369 -0
- package/dist/register/create-commands.js +352 -0
- package/dist/{register-date.js → register/date.js} +1 -1
- package/dist/register/derivation.js +163 -0
- package/dist/{register-event-merge.js → register/event-merge.js} +32 -3
- package/dist/{register-events.js → register/events.js} +12 -6
- package/dist/{register-history.js → register/history.js} +7 -6
- package/dist/{register-item.js → register/item.js} +28 -10
- package/dist/register/lifecycle-lock.js +5 -0
- package/dist/register/maintenance-commands.js +193 -0
- package/dist/{register-migrate-timestamps.js → register/migrate-timestamps.js} +3 -3
- package/dist/register/migration.js +268 -0
- package/dist/register/register.js +404 -0
- package/dist/register/renumber.js +341 -0
- package/dist/register/transition-commands.js +248 -0
- package/dist/register/update.js +230 -0
- package/dist/register/views.js +296 -0
- package/dist/{review-grade.js → review/grade.js} +2 -2
- package/dist/{review-plan.js → review/plan.js} +5 -5
- package/dist/routine/definition.js +401 -0
- package/dist/{routine.js → routine/routine.js} +50 -419
- package/dist/{schedule-approach.js → schedule/approach.js} +9 -9
- package/dist/{schedule-build.js → schedule/build.js} +7 -4
- package/dist/{schedule.js → schedule/schedule.js} +9 -9
- package/dist/schedule/strategy-generate-document.js +273 -0
- package/dist/schedule/strategy-generate-scope.js +199 -0
- package/dist/schedule/strategy-generate.js +348 -0
- package/dist/shared/agent-types.js +23 -0
- package/dist/shared/artifact-path.js +9 -0
- package/dist/{build-if-stale.js → shared/build-if-stale.js} +1 -1
- package/dist/shared/catalog-render.js +115 -0
- package/dist/{exec-slot-lock.js → shared/cross-process-lock.js} +3 -1
- package/dist/shared/fs.js +30 -0
- package/dist/shared/git.js +316 -0
- package/dist/shared/grade-result.js +94 -0
- package/dist/{package-paths.js → shared/package-paths.js} +3 -3
- package/dist/shared/plan-templates.js +114 -0
- package/dist/{exec-provider-scaffold.js → shared/provider-scaffold.js} +3 -1
- package/dist/shared/random.js +4 -0
- package/dist/{exec-schedule-index.js → shared/schedule-index.js} +3 -1
- package/dist/shared/schedule-paths.js +9 -0
- package/dist/{specdojo-config.js → shared/specdojo-config.js} +96 -9
- package/dist/{exec-shared.js → shared/text.js} +0 -134
- package/dist/shared/time.js +28 -0
- package/dist/shared/yaml.js +28 -0
- package/dist/specdojo.js +22 -22
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +29 -17
- package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +1 -2
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +1 -2
- package/docs/ja/specdojo/exec-templates/xer-template.md +1 -3
- package/docs/ja/specdojo/exec-templates/xrp-job-template.md +6 -4
- package/docs/ja/specdojo/guides/exec-config-guide.md +97 -22
- package/docs/ja/specdojo/guides/exec-operation-guide.md +145 -12
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +2 -0
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +51 -18
- package/docs/ja/specdojo/guides/quick-start-guide.md +81 -16
- package/docs/ja/specdojo/guides/register-operation-guide.md +2 -1
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +10 -1
- package/docs/ja/specdojo/guides/review-guide.md +1 -1
- package/docs/ja/specdojo/guides/routine-operation-guide.md +6 -6
- package/docs/ja/specdojo/guides/use-case-guide.md +1 -1
- package/docs/ja/specdojo/references/command-reference.md +52 -28
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +17 -11
- package/docs/ja/specdojo/standards/job-definition-standard.md +20 -18
- package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +2 -2
- package/docs/ja/specdojo/templates/pjr-derived-items-template.md +22 -0
- package/docs/ja/specdojo/templates/pjr-index-template.md +1 -0
- package/docs/specdojo/schemas/v1/agent-members.schema.yaml +29 -2
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +20 -0
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +23 -0
- package/docs/specdojo/schemas/v1/job-run.schema.yaml +2 -2
- package/docs/specdojo/schemas/v1/job.schema.yaml +7 -0
- package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +26 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +70 -7
- package/docs/specdojo/schemas/v1/routine-run.schema.yaml +1 -1
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +1 -1
- package/package.json +4 -5
- package/templates/antigravity/README.md +7 -3
- package/templates/antigravity/agent-members-snippet.yaml +108 -12
- package/templates/antigravity/exec-defaults-snippet.yaml +10 -13
- package/templates/claude/README.md +27 -3
- package/templates/claude/agents/claude-executor.md +0 -1
- package/templates/claude/agents/claude-reporter.md +2 -1
- package/templates/claude/agents/claude-review-executor.md +0 -1
- package/templates/codex/README.md +23 -4
- package/templates/devcontainer/devcontainer.json +2 -2
- package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +69 -0
- package/templates/devcontainer/remote-host/ssh-config.sample +16 -0
- package/templates/init-agent-members.yaml +75 -25
- package/templates/init-exec-defaults.yaml +26 -8
- package/templates/opencode/README.md +17 -3
- package/templates/opencode/agents/opencode-executor.md +0 -1
- package/templates/opencode/agents/opencode-reporter.md +2 -1
- package/templates/opencode/agents/opencode-review-executor.md +0 -1
- package/dist/exec-run.js +0 -6182
- package/dist/exec-schedule-gantt-chart.js +0 -2
- package/dist/exec-worktree-ops.js +0 -1292
- package/dist/exec-worktree.js +0 -446
- package/dist/grade.js +0 -3193
- package/dist/register.js +0 -2407
- package/dist/schedule-strategy-generate.js +0 -812
- package/templates/claude/agents/claude-expert-review-executor.md +0 -14
- /package/dist/{catalog-plan-prompt.js → catalog/plan-prompt.js} +0 -0
- /package/dist/{catalog-types.js → catalog/types.js} +0 -0
- /package/dist/{template-frontmatter.js → docs/template-frontmatter.js} +0 -0
- /package/dist/{role-types.js → exec/role-types.js} +0 -0
- /package/dist/{exec-schedule-gantt-chart-scope.js → exec/schedule/gantt-chart-scope.js} +0 -0
- /package/dist/{exec-types.js → exec/types.js} +0 -0
- /package/dist/{review-types.js → review/types.js} +0 -0
- /package/dist/{schedule-phase-sets.js → schedule/phase-sets.js} +0 -0
- /package/dist/{schedule-strategy-profiles.js → schedule/strategy-profiles.js} +0 -0
- /package/dist/{agent-response.js → shared/agent-response.js} +0 -0
- /package/dist/{catalog-paths.js → shared/catalog-paths.js} +0 -0
- /package/dist/{dist-freshness.js → shared/dist-freshness.js} +0 -0
- /package/dist/{git-environment.js → shared/git-environment.js} +0 -0
- /package/dist/{exec-format.js → shared/markdown-format.js} +0 -0
- /package/dist/{practice-id.js → shared/practice-id.js} +0 -0
- /package/dist/{spawn-self.js → shared/spawn-self.js} +0 -0
- /package/dist/{specdojo-gitignore.js → shared/specdojo-gitignore.js} +0 -0
- /package/dist/{template-resolution.js → shared/template-resolution.js} +0 -0
- /package/dist/{yaml-schema-modeline.js → shared/yaml-schema-modeline.js} +0 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { relative, sep } from "node:path";
|
|
2
|
+
import { recordExecutorEvidence, recordParentValidationFailureOutput, recordReporterFailureOutput, snapshotWorktreeChanges, writeExecutorEvidence, } from "../evidence.js";
|
|
3
|
+
import { failedParentValidationReason, hasRecordedParentValidations, parentValidationRoots, replaceParentValidationResults, } from "../parent-validation.js";
|
|
4
|
+
import { createPipelineState, pipelineStateLocation, updatePipelineStage, writePipelineState, } from "../pipeline-state.js";
|
|
5
|
+
import { deriveReporterFacts, evidenceForReporter, runReporterWithFormatRetry, } from "../reporter.js";
|
|
6
|
+
import { renderReporterResult } from "../results.js";
|
|
7
|
+
import { randomHex } from "../shared.js";
|
|
8
|
+
import { withProductRepoPrompt } from "../task-repos.js";
|
|
9
|
+
import { worktreeStatusPaths } from "../worktree-ops.js";
|
|
10
|
+
import { agentEnvironment, appendParentValidationsToExecutorEvidence, buildExecutorPrompt, extractBlockReason, resumedTargetCoverageFailure, runConfiguredParentValidationBatch, runWithRetry, } from "./agent.js";
|
|
11
|
+
export async function refreshParentValidationsForReporterResume(params) {
|
|
12
|
+
const configuredEntries = params.execDefaults.pipeline?.parent_validations;
|
|
13
|
+
const force = params.force === true && (configuredEntries?.length ?? 0) > 0;
|
|
14
|
+
if (!force &&
|
|
15
|
+
hasRecordedParentValidations(params.evidence.validations, configuredEntries) &&
|
|
16
|
+
!failedParentValidationReason(params.evidence.validations)) {
|
|
17
|
+
return params.evidence;
|
|
18
|
+
}
|
|
19
|
+
process.stdout.write(` Refreshing parent validations before ${params.stageLabel ?? "reporter"} resume` +
|
|
20
|
+
`${force ? " (integration targets were merged into the worktree)" : ""}.\n`);
|
|
21
|
+
const parentValidationBatch = await runConfiguredParentValidationBatch(params.execDefaults, parentValidationRoots(params.cwd, params.productWorktrees), { label: params.evidence.task_id });
|
|
22
|
+
const evidenceWithValidations = replaceParentValidationResults(params.evidence, parentValidationBatch.validations);
|
|
23
|
+
const evidence = recordParentValidationFailureOutput({
|
|
24
|
+
worktreePath: params.cwd,
|
|
25
|
+
evidencePath: params.evidencePath,
|
|
26
|
+
evidence: evidenceWithValidations,
|
|
27
|
+
failureOutputs: parentValidationBatch.failureOutputs,
|
|
28
|
+
});
|
|
29
|
+
if (parentValidationBatch.failureOutputs.length === 0) {
|
|
30
|
+
writeExecutorEvidence(params.evidencePath, evidence);
|
|
31
|
+
}
|
|
32
|
+
process.stdout.write(` Refreshed executor evidence: ${relative(params.cwd, params.evidencePath).split(sep).join("/")}\n`);
|
|
33
|
+
return evidence;
|
|
34
|
+
}
|
|
35
|
+
// register pipeline の reporter 段だけを実行する。executor 直後の通常経路と、executor が
|
|
36
|
+
// 成功したまま reporter だけが失敗した run の再開経路の双方から共有し、reporter 起動・
|
|
37
|
+
// result 描画・pipeline-state 更新のみを担う(register の状態遷移と commit は呼び出し側)。
|
|
38
|
+
export async function runReporterStage(params) {
|
|
39
|
+
const { repoRoot, cwd, schedulePath, executionPath, reporterCandidates, execDefaults } = params;
|
|
40
|
+
const env = agentEnvironment(repoRoot, cwd, schedulePath, executionPath, params.productWorktrees);
|
|
41
|
+
const reporterEvidence = evidenceForReporter(params.evidence, {
|
|
42
|
+
repoRoot,
|
|
43
|
+
worktreePath: cwd,
|
|
44
|
+
executionPath,
|
|
45
|
+
resultPath: params.resultPath,
|
|
46
|
+
...(params.registerPaths ? { registerPaths: params.registerPaths } : {}),
|
|
47
|
+
});
|
|
48
|
+
let state = params.state;
|
|
49
|
+
const reporterStartedAt = new Date().toISOString();
|
|
50
|
+
state = updatePipelineStage(state, "reporter", {
|
|
51
|
+
status: "running",
|
|
52
|
+
actor: reporterCandidates[0]?.actor ?? null,
|
|
53
|
+
started_at: reporterStartedAt,
|
|
54
|
+
completed_at: null,
|
|
55
|
+
}, reporterStartedAt);
|
|
56
|
+
writePipelineState(params.statePath, state);
|
|
57
|
+
process.stdout.write(` Running reporter: ${reporterCandidates[0]?.command ?? ""}\n`);
|
|
58
|
+
let reporterAttempts = 0;
|
|
59
|
+
let reporterActor = reporterCandidates[0]?.actor;
|
|
60
|
+
const rateLimitEvents = [];
|
|
61
|
+
const runReporter = () => runReporterWithFormatRetry({
|
|
62
|
+
plan: params.planPrompt,
|
|
63
|
+
evidence: reporterEvidence,
|
|
64
|
+
mode: params.mode ?? "edit",
|
|
65
|
+
invoke: async (reporterPrompt) => {
|
|
66
|
+
const reporterOutcome = await runWithRetry(reporterCandidates, reporterPrompt, execDefaults, cwd, env, params.resultPath, params.rateLimitOptions);
|
|
67
|
+
reporterAttempts += reporterOutcome.attempts;
|
|
68
|
+
reporterActor = reporterOutcome.actor ?? reporterActor;
|
|
69
|
+
rateLimitEvents.push(...reporterOutcome.rateLimitEvents);
|
|
70
|
+
return {
|
|
71
|
+
result: reporterOutcome.result,
|
|
72
|
+
stdout: reporterOutcome.stdout,
|
|
73
|
+
stderr: reporterOutcome.stderr,
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
const reporter = params.providerConcurrencyGate
|
|
78
|
+
? await params.providerConcurrencyGate.run(reporterCandidates[0]?.provider, runReporter, `${params.evidence.task_id} reporter`)
|
|
79
|
+
: await runReporter();
|
|
80
|
+
if (rateLimitEvents.length > 0) {
|
|
81
|
+
params.evidence.rate_limit_events = [
|
|
82
|
+
...(params.evidence.rate_limit_events ?? []),
|
|
83
|
+
...rateLimitEvents,
|
|
84
|
+
];
|
|
85
|
+
reporterEvidence.rate_limit_events = params.evidence.rate_limit_events;
|
|
86
|
+
writeExecutorEvidence(params.evidencePath, params.evidence);
|
|
87
|
+
}
|
|
88
|
+
let exitCode = 1;
|
|
89
|
+
let blockReason;
|
|
90
|
+
if (reporter.result === "success") {
|
|
91
|
+
try {
|
|
92
|
+
await renderReporterResult(params.resultPath, reporter.output, reporterEvidence);
|
|
93
|
+
const facts = deriveReporterFacts(reporterEvidence, { mode: params.mode ?? "edit" });
|
|
94
|
+
exitCode = facts.outcome === "complete" ? 0 : 1;
|
|
95
|
+
blockReason = facts.block_reason || undefined;
|
|
96
|
+
process.stdout.write(` Reporter complete: ${reporterCandidates[0]?.actor ?? "reporter"} (format attempts: ${reporter.formatAttempts})\n`);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
exitCode = 1;
|
|
100
|
+
blockReason =
|
|
101
|
+
error instanceof Error
|
|
102
|
+
? `reporter result rendering failed: ${error.message}`
|
|
103
|
+
: String(error);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
blockReason = reporter.reason;
|
|
108
|
+
recordReporterFailureOutput({
|
|
109
|
+
worktreePath: cwd,
|
|
110
|
+
evidencePath: params.evidencePath,
|
|
111
|
+
evidence: params.evidence,
|
|
112
|
+
invocationOutputs: reporter.invocationOutputs,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const reporterCompletedAt = new Date().toISOString();
|
|
116
|
+
state = updatePipelineStage(state, "reporter", {
|
|
117
|
+
status: exitCode === 0 ? "succeeded" : reporter.result === "rate_limit" ? "rate_limited" : "failed",
|
|
118
|
+
attempts: state.stages.reporter.attempts + reporterAttempts,
|
|
119
|
+
actor: reporterActor ?? null,
|
|
120
|
+
completed_at: reporterCompletedAt,
|
|
121
|
+
artifact_ref: reporter.result === "success"
|
|
122
|
+
? relative(cwd, params.resultPath).split(sep).join("/")
|
|
123
|
+
: state.stages.reporter.artifact_ref,
|
|
124
|
+
...(rateLimitEvents.length > 0 ? { rate_limit_events: rateLimitEvents } : {}),
|
|
125
|
+
}, reporterCompletedAt);
|
|
126
|
+
writePipelineState(params.statePath, state);
|
|
127
|
+
const runResult = exitCode === 0 ? "success" : reporter.result === "rate_limit" ? "rate_limit" : "failure";
|
|
128
|
+
return { exitCode, runResult, blockReason, state };
|
|
129
|
+
}
|
|
130
|
+
// 1件の plan/result を executor→reporter の2段階で実行する。register 項目と Job Run の
|
|
131
|
+
// 双方が使い、in-place(cwd: repoRoot)・worktree(cwd: worktree.path)から共有する。
|
|
132
|
+
// evidence・pipeline-state の記録先は
|
|
133
|
+
// Schedule タスクの pipeline と同じ形式(exec/evidence/<taskId>/<runId>/)にすることで、
|
|
134
|
+
// 監査証跡のフォーマットを実行経路によらず統一する。state には plan / result の参照も
|
|
135
|
+
// 記録し、reporter だけが失敗した場合に `--resume` が入力を復元できるようにする。
|
|
136
|
+
export async function runAgentPipeline(params) {
|
|
137
|
+
const { repoRoot, cwd, schedulePath, executionPath, taskId, executor, reporterCandidates, planPrompt, resultPath, execDefaults, } = params;
|
|
138
|
+
const startedAt = new Date().toISOString();
|
|
139
|
+
const runId = params.runId ?? `${new Date().toISOString().replace(/[-:.]/g, "")}-${randomHex(4)}`;
|
|
140
|
+
const stateLocation = pipelineStateLocation({
|
|
141
|
+
repoRoot,
|
|
142
|
+
worktreePath: cwd,
|
|
143
|
+
executionPath,
|
|
144
|
+
taskId,
|
|
145
|
+
runId,
|
|
146
|
+
});
|
|
147
|
+
let state = createPipelineState({
|
|
148
|
+
taskId,
|
|
149
|
+
runId,
|
|
150
|
+
updatedAt: startedAt,
|
|
151
|
+
executorActor: executor.actor,
|
|
152
|
+
reporterActor: reporterCandidates[0]?.actor,
|
|
153
|
+
// plan は root(統合ブランチ)で生成して checkpoint 済みのため、repo 相対パスが
|
|
154
|
+
// worktree 内の相対パスと一致する。result は cwd(in-place は root、worktree 実行は
|
|
155
|
+
// worktree)からの相対で、evidence の artifact_ref と同じ基準に揃える。
|
|
156
|
+
artifacts: {
|
|
157
|
+
plan_ref: relative(repoRoot, params.planPath).split(sep).join("/"),
|
|
158
|
+
result_ref: relative(cwd, resultPath).split(sep).join("/"),
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
state = updatePipelineStage(state, "executor", { status: "running", started_at: startedAt }, startedAt);
|
|
162
|
+
writePipelineState(stateLocation.path, state);
|
|
163
|
+
const env = agentEnvironment(repoRoot, cwd, schedulePath, executionPath, params.productWorktrees);
|
|
164
|
+
const executorPrompt = withProductRepoPrompt(buildExecutorPrompt(planPrompt, execDefaults.pipeline?.parent_validations, {
|
|
165
|
+
mode: params.mode ?? "edit",
|
|
166
|
+
resumed: params.resumedExecutor,
|
|
167
|
+
...(params.resumedExecutor ? { existingChanges: worktreeStatusPaths(cwd) } : {}),
|
|
168
|
+
...(params.resumedExecutor
|
|
169
|
+
? { initialChangeTargets: params.initialChangeTargets ?? [] }
|
|
170
|
+
: {}),
|
|
171
|
+
...(params.resumedExecutor ? { resumeHandoff: params.resumeHandoff ?? [] } : {}),
|
|
172
|
+
}), params.productWorktrees);
|
|
173
|
+
const changesBeforeAttempt = snapshotWorktreeChanges(cwd, params.productWorktrees);
|
|
174
|
+
const runExecutor = () => runWithRetry([executor], executorPrompt, execDefaults, cwd, env, resultPath, params.executorRateLimitOptions);
|
|
175
|
+
const outcome = params.providerConcurrencyGate
|
|
176
|
+
? await params.providerConcurrencyGate.run(executor.provider, runExecutor, `${taskId} executor`)
|
|
177
|
+
: await runExecutor();
|
|
178
|
+
const recorded = recordExecutorEvidence({
|
|
179
|
+
repoRoot,
|
|
180
|
+
worktreePath: cwd,
|
|
181
|
+
executionPath,
|
|
182
|
+
taskId,
|
|
183
|
+
runId,
|
|
184
|
+
actor: outcome.actor ?? executor.actor,
|
|
185
|
+
status: outcome.result === "success"
|
|
186
|
+
? "succeeded"
|
|
187
|
+
: outcome.result === "rate_limit"
|
|
188
|
+
? "rate_limited"
|
|
189
|
+
: "failed",
|
|
190
|
+
startedAt,
|
|
191
|
+
completedAt: new Date().toISOString(),
|
|
192
|
+
exitCode: outcome.exitCode,
|
|
193
|
+
attempts: outcome.attempts,
|
|
194
|
+
stdout: outcome.stdout,
|
|
195
|
+
stderr: outcome.stderr,
|
|
196
|
+
changesBeforeAttempt,
|
|
197
|
+
productWorktrees: params.productWorktrees,
|
|
198
|
+
rateLimitEvents: outcome.rateLimitEvents,
|
|
199
|
+
});
|
|
200
|
+
const coverageFailure = outcome.result === "success"
|
|
201
|
+
? resumedTargetCoverageFailure({
|
|
202
|
+
resumed: !!params.resumedExecutor,
|
|
203
|
+
plan: planPrompt,
|
|
204
|
+
evidence: recorded.evidence,
|
|
205
|
+
evidencePath: recorded.evidencePath,
|
|
206
|
+
initialChangeTargets: params.initialChangeTargets,
|
|
207
|
+
})
|
|
208
|
+
: undefined;
|
|
209
|
+
const executorResult = coverageFailure ? "failure" : outcome.result;
|
|
210
|
+
const evidenceRef = relative(cwd, recorded.evidencePath).split(sep).join("/");
|
|
211
|
+
const executorCompletedAt = new Date().toISOString();
|
|
212
|
+
state = updatePipelineStage(state, "executor", {
|
|
213
|
+
status: executorResult === "success"
|
|
214
|
+
? "succeeded"
|
|
215
|
+
: outcome.protectionBlock
|
|
216
|
+
? "blocked"
|
|
217
|
+
: executorResult === "rate_limit"
|
|
218
|
+
? "rate_limited"
|
|
219
|
+
: "failed",
|
|
220
|
+
attempts: outcome.attempts,
|
|
221
|
+
actor: outcome.actor ?? executor.actor,
|
|
222
|
+
completed_at: executorCompletedAt,
|
|
223
|
+
artifact_ref: evidenceRef,
|
|
224
|
+
...(outcome.rateLimitEvents.length > 0 ? { rate_limit_events: outcome.rateLimitEvents } : {}),
|
|
225
|
+
}, executorCompletedAt);
|
|
226
|
+
writePipelineState(stateLocation.path, state);
|
|
227
|
+
process.stdout.write(` Executor evidence: ${evidenceRef}\n`);
|
|
228
|
+
if (executorResult !== "success") {
|
|
229
|
+
const blockReason = coverageFailure ??
|
|
230
|
+
(executorResult === "rate_limit"
|
|
231
|
+
? "executor rate limit reached"
|
|
232
|
+
: extractBlockReason(outcome.stderr));
|
|
233
|
+
return {
|
|
234
|
+
exitCode: 1,
|
|
235
|
+
runResult: executorResult,
|
|
236
|
+
blockReason,
|
|
237
|
+
stateRef: stateLocation.ref,
|
|
238
|
+
evidenceRef,
|
|
239
|
+
rateLimitEvents: outcome.rateLimitEvents,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
recorded.evidence = await appendParentValidationsToExecutorEvidence({
|
|
243
|
+
execDefaults,
|
|
244
|
+
cwd,
|
|
245
|
+
productWorktrees: params.productWorktrees,
|
|
246
|
+
evidence: recorded.evidence,
|
|
247
|
+
evidencePath: recorded.evidencePath,
|
|
248
|
+
});
|
|
249
|
+
const reporterOutcome = await runReporterStage({
|
|
250
|
+
repoRoot,
|
|
251
|
+
cwd,
|
|
252
|
+
schedulePath,
|
|
253
|
+
executionPath,
|
|
254
|
+
reporterCandidates,
|
|
255
|
+
planPrompt,
|
|
256
|
+
resultPath,
|
|
257
|
+
registerPaths: params.registerPaths,
|
|
258
|
+
execDefaults,
|
|
259
|
+
evidence: recorded.evidence,
|
|
260
|
+
evidencePath: recorded.evidencePath,
|
|
261
|
+
state,
|
|
262
|
+
statePath: stateLocation.path,
|
|
263
|
+
providerConcurrencyGate: params.providerConcurrencyGate,
|
|
264
|
+
productWorktrees: params.productWorktrees,
|
|
265
|
+
mode: params.mode,
|
|
266
|
+
rateLimitOptions: params.reporterRateLimitOptions,
|
|
267
|
+
});
|
|
268
|
+
return {
|
|
269
|
+
exitCode: reporterOutcome.exitCode,
|
|
270
|
+
runResult: reporterOutcome.runResult,
|
|
271
|
+
blockReason: reporterOutcome.blockReason,
|
|
272
|
+
stateRef: stateLocation.ref,
|
|
273
|
+
evidenceRef,
|
|
274
|
+
rateLimitEvents: recorded.evidence.rate_limit_events ?? [],
|
|
275
|
+
};
|
|
276
|
+
}
|