specdojo 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/agents/specdojo-orchestrator.md +61 -2
- package/CHANGELOG.md +43 -0
- package/README.md +8 -7
- package/dist/commands/init.js +72 -15
- package/dist/commands/night-orchestrator.js +287 -0
- package/dist/commands/orchestrator.js +10 -3
- package/dist/devcontainer/command.js +3 -1
- package/dist/devcontainer/scaffold.js +166 -5
- package/dist/exec/agent-config.js +60 -2
- package/dist/exec/parent-validation.js +14 -0
- package/dist/exec/pipeline-state.js +13 -0
- package/dist/exec/register.js +23 -1
- package/dist/exec/repo-integration.js +1 -1
- package/dist/exec/reporter.js +113 -13
- package/dist/exec/results.js +36 -14
- package/dist/exec/run/agent-pipeline.js +3 -0
- package/dist/exec/run/agent.js +40 -5
- package/dist/exec/run/job.js +2 -2
- package/dist/exec/run/lifecycle-commands.js +2 -2
- package/dist/exec/run/register-command.js +23 -4
- package/dist/exec/run/register-core.js +17 -0
- package/dist/exec/run/register-mode.js +39 -16
- package/dist/exec/run/register-post-review.js +420 -0
- package/dist/exec/run/register-resume.js +27 -11
- package/dist/exec/run/register-worktree.js +66 -2
- package/dist/exec/run/run.js +1 -1
- package/dist/exec/run/shared.js +22 -24
- package/dist/exec/task-repos.js +102 -15
- package/dist/register/core.js +14 -2
- package/dist/register/create-commands.js +62 -6
- package/dist/register/event-merge.js +13 -1
- package/dist/register/events.js +4 -0
- package/dist/register/item.js +9 -0
- package/dist/register/migration.js +1 -0
- package/dist/register/register.js +2 -2
- package/dist/shared/git.js +45 -15
- package/dist/shared/provider-scaffold.js +3 -2
- package/dist/shared/specdojo-config.js +69 -16
- package/dist/shared/text.js +4 -1
- package/dist/shared/workspace-scaffold.js +69 -0
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +2 -1
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +2 -0
- package/docs/ja/specdojo/exec-templates/xrp-register-post-run-template.md +46 -0
- package/docs/ja/specdojo/guides/branch-workflow-guide.md +34 -1
- package/docs/ja/specdojo/guides/docs-structure-guide.md +2 -0
- package/docs/ja/specdojo/guides/exec-config-guide.md +79 -11
- package/docs/ja/specdojo/guides/exec-operation-guide.md +39 -1
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +9 -3
- package/docs/ja/specdojo/guides/quick-start-guide.md +9 -6
- package/docs/ja/specdojo/guides/register-operation-guide.md +42 -0
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +52 -6
- package/docs/ja/specdojo/guides/specdojo-overview-guide.md +1 -1
- package/docs/ja/specdojo/guides/waza-guide.md +1 -1
- package/docs/ja/specdojo/references/command-reference.md +101 -56
- package/docs/ja/specdojo/references/specdojo-config-reference.md +33 -7
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +5 -2
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +92 -18
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +6 -1
- package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +12 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +2 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +21 -0
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +35 -0
- package/package.json +17 -17
- package/templates/antigravity/README.md +1 -1
- package/templates/antigravity/orchestrator.md +61 -2
- package/templates/claude/agents/specdojo-orchestrator.md +61 -2
- package/templates/codex/README.md +17 -0
- package/templates/codex/agents/specdojo-orchestrator.toml +61 -2
- package/templates/codex/orchestrator.md +61 -2
- package/templates/devcontainer/devcontainer.json +3 -0
- package/templates/devcontainer/post-create.sh +15 -7
- package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +38 -5
- package/templates/devcontainer/remote-host/ssh-config.sample +3 -0
- package/templates/devcontainer/vim/vimrc +37 -0
- package/templates/init-agent-members.yaml +3 -3
- package/templates/init-exec-defaults.yaml +20 -1
- package/templates/opencode/agents/specdojo-orchestrator.md +61 -2
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { resolveMemberCommand } from "../agent-config.js";
|
|
4
|
+
import { buildSpecdojoFrontmatter } from "../../docs/frontmatter-namespace.js";
|
|
5
|
+
import { formatMarkdownFile } from "../../shared/markdown-format.js";
|
|
6
|
+
import { expandTemplate } from "../../shared/text.js";
|
|
7
|
+
import { execTemplatePath } from "../plans.js";
|
|
8
|
+
import { scaffoldResult, stripLeadingListMarker, updateResultStatus } from "../results.js";
|
|
9
|
+
import { readPipelineState } from "../pipeline-state.js";
|
|
10
|
+
import { sanitizeRegisterConclusion } from "../register.js";
|
|
11
|
+
import { gitOutput } from "../worktree.js";
|
|
12
|
+
import { worktreeStatusPaths } from "../worktree-ops.js";
|
|
13
|
+
import { runAgentPipeline } from "./agent-pipeline.js";
|
|
14
|
+
import { expandPromptRefs } from "./agent.js";
|
|
15
|
+
import { registerReporterManagedPaths, spawnRegisterTransition, } from "./register-core.js";
|
|
16
|
+
import { commitRegisterState } from "./register-state.js";
|
|
17
|
+
import { resolveAgentOverride, resolvePinnedRateLimitRunOptions, selectCandidates, } from "./shared.js";
|
|
18
|
+
export const DEFAULT_REGISTER_POST_REVIEW_EXECUTOR = "claude-expert-review-executor";
|
|
19
|
+
const ACCEPTED_POST_REVIEW_VERDICTS = new Set(["complete", "complete-with-findings"]);
|
|
20
|
+
const POST_REVIEW_VERDICTS = new Set(["complete", "complete-with-findings", "incomplete"]);
|
|
21
|
+
const AUTO_CLOSE_REGISTER_TYPES = new Set(["todo", "issue"]);
|
|
22
|
+
export function registerPostReviewDisposition(params) {
|
|
23
|
+
const { itemType, verdict, runnerImplementationChanged = false } = params;
|
|
24
|
+
if (verdict === "incomplete" || !verdict) {
|
|
25
|
+
return {
|
|
26
|
+
transition: "waiting",
|
|
27
|
+
outcome: "failure",
|
|
28
|
+
explanation: verdict === "incomplete" ? "review verdict is incomplete" : "review failed",
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (!ACCEPTED_POST_REVIEW_VERDICTS.has(verdict)) {
|
|
32
|
+
return {
|
|
33
|
+
transition: "waiting",
|
|
34
|
+
outcome: "failure",
|
|
35
|
+
explanation: `review verdict is not accepted: ${verdict}`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (!AUTO_CLOSE_REGISTER_TYPES.has(itemType)) {
|
|
39
|
+
return {
|
|
40
|
+
transition: "review",
|
|
41
|
+
outcome: "success",
|
|
42
|
+
explanation: `register type ${itemType} is not eligible for automatic close`,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (runnerImplementationChanged) {
|
|
46
|
+
return {
|
|
47
|
+
transition: "review",
|
|
48
|
+
outcome: "success",
|
|
49
|
+
explanation: "the integrated change modifies the running SpecDojo implementation; a new process smoke test and human close are required",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
transition: "done",
|
|
54
|
+
outcome: "success",
|
|
55
|
+
explanation: `review verdict is ${verdict}`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export function registerPostReviewVerdict(resultPath) {
|
|
59
|
+
if (!existsSync(resultPath))
|
|
60
|
+
return undefined;
|
|
61
|
+
const match = readFileSync(resultPath, "utf8").match(/^- verdict:\s*(complete|complete-with-findings|incomplete|grade-stale|grade-unavailable|changed-during-review)\s*$/m);
|
|
62
|
+
return match?.[1];
|
|
63
|
+
}
|
|
64
|
+
export function changesModifyRunningSpecDojo(repoRoot, paths) {
|
|
65
|
+
const packagePath = join(repoRoot, "package.json");
|
|
66
|
+
if (!existsSync(packagePath))
|
|
67
|
+
return false;
|
|
68
|
+
try {
|
|
69
|
+
const manifest = JSON.parse(readFileSync(packagePath, "utf8"));
|
|
70
|
+
if (manifest.name !== "specdojo")
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
return paths.some((path) => {
|
|
77
|
+
const normalized = path.replaceAll("\\", "/").replace(/^\.\//u, "");
|
|
78
|
+
return (normalized.startsWith("src/") ||
|
|
79
|
+
normalized.startsWith("tools/") ||
|
|
80
|
+
normalized === "package.json" ||
|
|
81
|
+
normalized === "package-lock.json" ||
|
|
82
|
+
normalized === "npm-shrinkwrap.json" ||
|
|
83
|
+
normalized === "pnpm-lock.yaml" ||
|
|
84
|
+
normalized === "yarn.lock");
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function candidateForMember(member, execDefaults) {
|
|
88
|
+
const command = resolveMemberCommand(execDefaults, member);
|
|
89
|
+
return command ? { command, actor: member.nickname, provider: member.provider } : undefined;
|
|
90
|
+
}
|
|
91
|
+
export function resolveRegisterPostReviewAgents(roster, opts, execDefaults) {
|
|
92
|
+
const reviewNickname = opts.reviewBy?.trim() || DEFAULT_REGISTER_POST_REVIEW_EXECUTOR;
|
|
93
|
+
const executorResolution = resolveAgentOverride("review", reviewNickname, {}, roster, execDefaults, "executor");
|
|
94
|
+
if (executorResolution.kind !== "command") {
|
|
95
|
+
const detail = executorResolution.kind === "error"
|
|
96
|
+
? executorResolution.message
|
|
97
|
+
: `agent not found: ${reviewNickname}`;
|
|
98
|
+
throw new Error(`Register post-review executor is unavailable (${detail.replace(/^--by/u, "--review-by")}). ` +
|
|
99
|
+
"Specify --review-by <nickname>.");
|
|
100
|
+
}
|
|
101
|
+
const executor = {
|
|
102
|
+
command: executorResolution.command,
|
|
103
|
+
actor: executorResolution.actor ?? reviewNickname,
|
|
104
|
+
provider: executorResolution.provider,
|
|
105
|
+
};
|
|
106
|
+
const reporterNickname = opts.reporterBy?.trim();
|
|
107
|
+
if (reporterNickname) {
|
|
108
|
+
const reporterResolution = resolveAgentOverride("review", reporterNickname, {}, roster, execDefaults, "reporter");
|
|
109
|
+
if (reporterResolution.kind !== "command") {
|
|
110
|
+
const detail = reporterResolution.kind === "error"
|
|
111
|
+
? reporterResolution.message
|
|
112
|
+
: `agent not found: ${reporterNickname}`;
|
|
113
|
+
throw new Error(detail.replace(/^--by/u, "--reporter-by"));
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
executor,
|
|
117
|
+
reporterCandidates: [
|
|
118
|
+
{
|
|
119
|
+
command: reporterResolution.command,
|
|
120
|
+
actor: reporterResolution.actor ?? reporterNickname,
|
|
121
|
+
provider: reporterResolution.provider,
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const reporterCandidates = selectCandidates({ capabilities: [], stage_role: "reporter" }, roster, undefined, undefined, execDefaults).flatMap((member) => {
|
|
127
|
+
const candidate = candidateForMember(member, execDefaults);
|
|
128
|
+
return candidate ? [candidate] : [];
|
|
129
|
+
});
|
|
130
|
+
if (reporterCandidates.length === 0) {
|
|
131
|
+
throw new Error("No reporter is available for register post-review. Specify --reporter-by <nickname>.");
|
|
132
|
+
}
|
|
133
|
+
return { executor, reporterCandidates };
|
|
134
|
+
}
|
|
135
|
+
function repoRelative(repoRoot, path) {
|
|
136
|
+
return relative(repoRoot, path).split(sep).join("/");
|
|
137
|
+
}
|
|
138
|
+
export async function generateRegisterPostReviewPlan(params) {
|
|
139
|
+
const { context, item, stem } = params;
|
|
140
|
+
const taskId = `${item.id}-post-review`;
|
|
141
|
+
const reviewStem = `${stem}-post-review`;
|
|
142
|
+
const planPath = join(context.executionPath, "exec", "plans", `${reviewStem}-plan.md`);
|
|
143
|
+
const resultPath = join(context.executionPath, "exec", "results", `${reviewStem}-result.md`);
|
|
144
|
+
const templatePath = execTemplatePath("xrp-register-post-run-template.md");
|
|
145
|
+
const frontmatter = buildSpecdojoFrontmatter([
|
|
146
|
+
`id: ${context.projectId}:xrp-${reviewStem}`,
|
|
147
|
+
"type: exec-plan",
|
|
148
|
+
"rulebook: none",
|
|
149
|
+
`task_id: ${taskId}`,
|
|
150
|
+
`name: ${JSON.stringify(`${item.id} ${item.title} の統合後レビュー`)}`,
|
|
151
|
+
"mode: review",
|
|
152
|
+
"status: ready",
|
|
153
|
+
`project_id: ${context.projectId}`,
|
|
154
|
+
"origin: register",
|
|
155
|
+
]);
|
|
156
|
+
const values = {
|
|
157
|
+
_FRONTMATTER_: frontmatter,
|
|
158
|
+
_ITEM_ID_: item.id,
|
|
159
|
+
_ITEM_TITLE_: item.title,
|
|
160
|
+
_ITEM_PATH_: repoRelative(context.repoRoot, params.ticketPath),
|
|
161
|
+
_EDIT_PLAN_REF_: repoRelative(context.repoRoot, params.editPlanPath),
|
|
162
|
+
_EDIT_RESULT_REF_: repoRelative(context.repoRoot, params.editResultPath),
|
|
163
|
+
_EDIT_EVIDENCE_REF_: params.editEvidenceRef ?? "-",
|
|
164
|
+
_BASE_COMMIT_: params.baseCommit,
|
|
165
|
+
_OUTPUT_COMMIT_: params.outputCommit,
|
|
166
|
+
_RESULT_REF_: repoRelative(context.repoRoot, resultPath),
|
|
167
|
+
};
|
|
168
|
+
const content = expandTemplate(readFileSync(templatePath, "utf8"), values);
|
|
169
|
+
mkdirSync(dirname(planPath), { recursive: true });
|
|
170
|
+
writeFileSync(planPath, content, "utf8");
|
|
171
|
+
await formatMarkdownFile(planPath);
|
|
172
|
+
return { taskId, planPath, resultPath };
|
|
173
|
+
}
|
|
174
|
+
function reviewRationale(resultPath) {
|
|
175
|
+
if (!existsSync(resultPath))
|
|
176
|
+
return "review result is unavailable";
|
|
177
|
+
const content = readFileSync(resultPath, "utf8");
|
|
178
|
+
const section = content.match(/## 2\. 判断根拠\s*\n([\s\S]*?)(?=\n## 3\.)/u)?.[1] ?? "";
|
|
179
|
+
const rationale = section
|
|
180
|
+
.split("\n")
|
|
181
|
+
.map((line) => line.replace(/^\s*-\s*/u, "").trim())
|
|
182
|
+
.filter(Boolean)
|
|
183
|
+
.join(" ");
|
|
184
|
+
return rationale || "review result recorded no rationale";
|
|
185
|
+
}
|
|
186
|
+
async function fillFailedReviewResult(resultPath, reason) {
|
|
187
|
+
const safeReason = reason.replace(/\s+/gu, " ").trim();
|
|
188
|
+
let content = readFileSync(resultPath, "utf8");
|
|
189
|
+
content = content
|
|
190
|
+
.replace(/_TODO_: 評価結果サイドカー[^\n]*/u, `統合後 review を完了できなかった: ${safeReason}`)
|
|
191
|
+
.replace(/_TODO_: 変更内容[^\n]*/u, "- runner が統合後 review を完了できなかった。")
|
|
192
|
+
.replace(/_TODO_: 未充足事項[^\n]*/u, `- ${stripLeadingListMarker(safeReason) || "理由なし"}`)
|
|
193
|
+
.replace(/_TODO_: `approach`[^\n]*/u, "統合済みの出力は変更していない。")
|
|
194
|
+
.replace(/- verdict: _TODO_([^\n]*)/u, "- verdict: incomplete");
|
|
195
|
+
writeFileSync(resultPath, content, "utf8");
|
|
196
|
+
await formatMarkdownFile(resultPath);
|
|
197
|
+
}
|
|
198
|
+
async function forceIncompleteReviewResult(resultPath, reason) {
|
|
199
|
+
let content = readFileSync(resultPath, "utf8");
|
|
200
|
+
content = content.replace(/^- verdict:\s*(?:complete|complete-with-findings|incomplete|grade-stale|grade-unavailable|changed-during-review)\s*$/mu, "- verdict: incomplete");
|
|
201
|
+
const note = `- runner 判定: ${reason.replace(/\s+/gu, " ").trim()}`;
|
|
202
|
+
if (!content.includes(note)) {
|
|
203
|
+
content = content.replace("\n## 4. approach に応じた確認", `\n${note}\n\n## 4. approach に応じた確認`);
|
|
204
|
+
}
|
|
205
|
+
writeFileSync(resultPath, content, "utf8");
|
|
206
|
+
await formatMarkdownFile(resultPath);
|
|
207
|
+
}
|
|
208
|
+
function editEvidenceRefAtRoot(params) {
|
|
209
|
+
if (!params.pipelineStatePath)
|
|
210
|
+
return undefined;
|
|
211
|
+
const stateRel = relative(params.worktreePath, params.pipelineStatePath);
|
|
212
|
+
const rootStatePath = resolve(params.repoRoot, stateRel);
|
|
213
|
+
if (!existsSync(rootStatePath))
|
|
214
|
+
return undefined;
|
|
215
|
+
const state = readPipelineState(rootStatePath);
|
|
216
|
+
const evidenceRef = state.stages.executor.artifact_ref;
|
|
217
|
+
return evidenceRef && existsSync(resolve(params.repoRoot, evidenceRef)) ? evidenceRef : undefined;
|
|
218
|
+
}
|
|
219
|
+
function changedPathsBetween(repoRoot, baseCommit, outputCommit) {
|
|
220
|
+
return gitOutput(repoRoot, ["diff", "--name-only", `${baseCommit}..${outputCommit}`])
|
|
221
|
+
.split("\n")
|
|
222
|
+
.map((path) => path.trim())
|
|
223
|
+
.filter(Boolean);
|
|
224
|
+
}
|
|
225
|
+
// post-review の記帳(個票・イベント・review の plan と result)の commit が hook で失敗すると、
|
|
226
|
+
// 記帳は作業ツリーに残ったまま次の項目へ進む。人が確かめて手で commit できるよう、失敗した
|
|
227
|
+
// hook の名前と最初のエラーの行(commitRegisterState の要約)、残ったファイル、hook の全出力の
|
|
228
|
+
// 置き場所を runner のログへ出す。
|
|
229
|
+
export function postReviewCommitFailureLines(params) {
|
|
230
|
+
const summary = params.message.replace(/^git commit failed:\s*/u, "");
|
|
231
|
+
// summarizeGitHookFailure は失敗した step を `<step>: <最初のエラーの行>` の形で先頭に置く。
|
|
232
|
+
// git 自身の `fatal:` / `error:` は hook 名ではないため、hook 名として扱わない。
|
|
233
|
+
const match = summary.match(/^([\w.-]+): (.*)$/su);
|
|
234
|
+
const isHookName = match !== null && !/^(?:fatal|error|warning|hint)$/iu.test(match[1]);
|
|
235
|
+
const hook = isHookName ? match[1] : "unknown";
|
|
236
|
+
const firstError = isHookName ? match[2] : summary;
|
|
237
|
+
return [
|
|
238
|
+
`Error: post-review bookkeeping commit failed for ${params.itemId}`,
|
|
239
|
+
` failed hook: ${hook}`,
|
|
240
|
+
` first error: ${firstError || "unknown"}`,
|
|
241
|
+
` uncommitted bookkeeping files: ${params.leftFiles.length > 0 ? params.leftFiles.join(", ") : "none"}`,
|
|
242
|
+
` full hook output: ${params.failureLogPath}`,
|
|
243
|
+
];
|
|
244
|
+
}
|
|
245
|
+
function reportPostReviewCommitFailure(params) {
|
|
246
|
+
const message = params.error instanceof Error ? params.error.message : String(params.error);
|
|
247
|
+
const leftFiles = worktreeStatusPaths(params.repoRoot)
|
|
248
|
+
.filter((path) => !params.preexisting.includes(path))
|
|
249
|
+
.sort();
|
|
250
|
+
const lines = postReviewCommitFailureLines({
|
|
251
|
+
itemId: params.itemId,
|
|
252
|
+
message,
|
|
253
|
+
leftFiles,
|
|
254
|
+
failureLogPath: repoRelative(params.repoRoot, params.failureLogPath),
|
|
255
|
+
});
|
|
256
|
+
process.stderr.write(`${lines.join("\n")}\n`);
|
|
257
|
+
}
|
|
258
|
+
export async function runRegisterPostReview(params) {
|
|
259
|
+
const { context, opts, item, registerPaths } = params;
|
|
260
|
+
const agents = resolveRegisterPostReviewAgents(context.roster, opts, context.execDefaults);
|
|
261
|
+
const editEvidenceRef = editEvidenceRefAtRoot({
|
|
262
|
+
repoRoot: context.repoRoot,
|
|
263
|
+
worktreePath: params.worktreePath,
|
|
264
|
+
pipelineStatePath: params.editPipelineStatePath,
|
|
265
|
+
});
|
|
266
|
+
const preexisting = worktreeStatusPaths(context.repoRoot);
|
|
267
|
+
const generated = await generateRegisterPostReviewPlan({
|
|
268
|
+
context,
|
|
269
|
+
item,
|
|
270
|
+
ticketPath: params.ticketPath,
|
|
271
|
+
stem: params.stem,
|
|
272
|
+
editPlanPath: params.editPlanPath,
|
|
273
|
+
editResultPath: params.editResultPath,
|
|
274
|
+
...(editEvidenceRef ? { editEvidenceRef } : {}),
|
|
275
|
+
baseCommit: params.baseCommit,
|
|
276
|
+
outputCommit: params.outputCommit,
|
|
277
|
+
});
|
|
278
|
+
await scaffoldResult({
|
|
279
|
+
executionPath: context.executionPath,
|
|
280
|
+
taskId: generated.taskId,
|
|
281
|
+
mode: "review",
|
|
282
|
+
projectId: context.projectId,
|
|
283
|
+
origin: "register",
|
|
284
|
+
planRef: repoRelative(context.executionPath, generated.planPath),
|
|
285
|
+
agent: agents.executor.actor,
|
|
286
|
+
startedAt: new Date().toISOString(),
|
|
287
|
+
stem: `${params.stem}-post-review`,
|
|
288
|
+
});
|
|
289
|
+
process.stdout.write(`Running post-review for ${item.id}: ${agents.executor.actor} (executor), ${agents.reporterCandidates[0]?.actor ?? "reporter"} (reporter)\n`);
|
|
290
|
+
const reviewExecDefaults = {
|
|
291
|
+
...context.execDefaults,
|
|
292
|
+
pipeline: { ...context.execDefaults.pipeline, parent_validations: [] },
|
|
293
|
+
};
|
|
294
|
+
const outcome = await runAgentPipeline({
|
|
295
|
+
repoRoot: context.repoRoot,
|
|
296
|
+
cwd: context.repoRoot,
|
|
297
|
+
schedulePath: context.schedulePath,
|
|
298
|
+
executionPath: context.executionPath,
|
|
299
|
+
taskId: generated.taskId,
|
|
300
|
+
executor: agents.executor,
|
|
301
|
+
reporterCandidates: agents.reporterCandidates,
|
|
302
|
+
planPath: generated.planPath,
|
|
303
|
+
planPrompt: expandPromptRefs(readFileSync(generated.planPath, "utf8")),
|
|
304
|
+
resultPath: generated.resultPath,
|
|
305
|
+
registerPaths: registerReporterManagedPaths(registerPaths),
|
|
306
|
+
execDefaults: reviewExecDefaults,
|
|
307
|
+
providerConcurrencyGate: context.providerConcurrencyGate,
|
|
308
|
+
mode: "review",
|
|
309
|
+
executorRateLimitOptions: resolvePinnedRateLimitRunOptions(opts, context.execDefaults, context.roster, "executor", agents.executor),
|
|
310
|
+
...(opts.reporterBy
|
|
311
|
+
? {
|
|
312
|
+
reporterRateLimitOptions: resolvePinnedRateLimitRunOptions(opts, context.execDefaults, context.roster, "reporter", agents.reporterCandidates[0]),
|
|
313
|
+
}
|
|
314
|
+
: {}),
|
|
315
|
+
});
|
|
316
|
+
const reviewStatePath = resolve(context.repoRoot, outcome.stateRef);
|
|
317
|
+
const reviewState = readPipelineState(reviewStatePath);
|
|
318
|
+
const reviewActor = reviewState.stages.executor.actor ?? agents.executor.actor;
|
|
319
|
+
const reviewEvidencePath = reviewState.stages.executor.artifact_ref
|
|
320
|
+
? resolve(context.repoRoot, reviewState.stages.executor.artifact_ref)
|
|
321
|
+
: undefined;
|
|
322
|
+
let reviewFailure = outcome.blockReason;
|
|
323
|
+
if (reviewEvidencePath && existsSync(reviewEvidencePath)) {
|
|
324
|
+
const evidence = JSON.parse(readFileSync(reviewEvidencePath, "utf8"));
|
|
325
|
+
const unexpected = evidence.attempt_changes ?? [];
|
|
326
|
+
if (unexpected.length > 0) {
|
|
327
|
+
reviewFailure = `review executor changed files: ${unexpected.map((change) => change.path).join(", ")}`;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
let verdict = outcome.exitCode === 0 ? registerPostReviewVerdict(generated.resultPath) : undefined;
|
|
331
|
+
if (reviewFailure || !verdict) {
|
|
332
|
+
const reason = reviewFailure ?? "review result has no verdict";
|
|
333
|
+
if (registerPostReviewVerdict(generated.resultPath)) {
|
|
334
|
+
await forceIncompleteReviewResult(generated.resultPath, reason);
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
await fillFailedReviewResult(generated.resultPath, reason);
|
|
338
|
+
}
|
|
339
|
+
verdict = "incomplete";
|
|
340
|
+
await updateResultStatus(generated.resultPath, "blocked", new Date().toISOString(), reason);
|
|
341
|
+
}
|
|
342
|
+
else if (!POST_REVIEW_VERDICTS.has(verdict)) {
|
|
343
|
+
const reason = `register post-review returned unsupported verdict ${verdict}`;
|
|
344
|
+
await forceIncompleteReviewResult(generated.resultPath, reason);
|
|
345
|
+
verdict = "incomplete";
|
|
346
|
+
await updateResultStatus(generated.resultPath, "blocked", new Date().toISOString(), reason);
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
await updateResultStatus(generated.resultPath, "complete", new Date().toISOString());
|
|
350
|
+
}
|
|
351
|
+
const runnerImplementationChanged = changesModifyRunningSpecDojo(context.repoRoot, changedPathsBetween(context.repoRoot, params.baseCommit, params.outputCommit));
|
|
352
|
+
const disposition = registerPostReviewDisposition({
|
|
353
|
+
itemType: item.type,
|
|
354
|
+
verdict,
|
|
355
|
+
runnerImplementationChanged,
|
|
356
|
+
});
|
|
357
|
+
const rationale = sanitizeRegisterConclusion(`post-run review verdict ${verdict}: ${reviewRationale(generated.resultPath)}; ${disposition.explanation}`);
|
|
358
|
+
if (disposition.transition === "done") {
|
|
359
|
+
if (!spawnRegisterTransition(context.projectId, [
|
|
360
|
+
"close",
|
|
361
|
+
"--id",
|
|
362
|
+
item.id,
|
|
363
|
+
"--status",
|
|
364
|
+
"done",
|
|
365
|
+
"--by",
|
|
366
|
+
reviewActor,
|
|
367
|
+
"--reason",
|
|
368
|
+
rationale,
|
|
369
|
+
])) {
|
|
370
|
+
throw new Error(`register close transition failed after post-review: ${item.id}`);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
else if (disposition.transition === "waiting") {
|
|
374
|
+
if (!spawnRegisterTransition(context.projectId, [
|
|
375
|
+
"wait",
|
|
376
|
+
"--id",
|
|
377
|
+
item.id,
|
|
378
|
+
"--by",
|
|
379
|
+
reviewActor,
|
|
380
|
+
"--reason",
|
|
381
|
+
rationale,
|
|
382
|
+
])) {
|
|
383
|
+
throw new Error(`register wait transition failed after post-review: ${item.id}`);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
const evidencePrefix = `${repoRelative(context.repoRoot, dirname(reviewStatePath))}/`;
|
|
387
|
+
const managed = worktreeStatusPaths(context.repoRoot)
|
|
388
|
+
.filter((path) => {
|
|
389
|
+
const normalized = path.replaceAll("\\", "/");
|
|
390
|
+
return (normalized === repoRelative(context.repoRoot, generated.planPath) ||
|
|
391
|
+
normalized === repoRelative(context.repoRoot, generated.resultPath) ||
|
|
392
|
+
normalized.startsWith(evidencePrefix));
|
|
393
|
+
})
|
|
394
|
+
.map((path) => resolve(context.repoRoot, path));
|
|
395
|
+
const commitFailureLogPath = join(dirname(reviewStatePath), "post-review-commit.log");
|
|
396
|
+
try {
|
|
397
|
+
commitRegisterState(context.repoRoot, registerPaths, `exec(register ${item.id}): post-review ${verdict}`, params.ticketPath, managed, commitFailureLogPath);
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
reportPostReviewCommitFailure({
|
|
401
|
+
repoRoot: context.repoRoot,
|
|
402
|
+
itemId: item.id,
|
|
403
|
+
error,
|
|
404
|
+
preexisting,
|
|
405
|
+
failureLogPath: commitFailureLogPath,
|
|
406
|
+
});
|
|
407
|
+
throw error;
|
|
408
|
+
}
|
|
409
|
+
const commit = gitOutput(context.repoRoot, ["rev-parse", "--short", "HEAD"]).trim();
|
|
410
|
+
const introduced = worktreeStatusPaths(context.repoRoot).filter((path) => !preexisting.includes(path));
|
|
411
|
+
if (introduced.length > 0) {
|
|
412
|
+
process.stderr.write(`Warning: post-review left uncommitted files for ${item.id}: ${introduced.join(", ")}\n`);
|
|
413
|
+
}
|
|
414
|
+
return {
|
|
415
|
+
transition: disposition.transition,
|
|
416
|
+
outcome: disposition.outcome,
|
|
417
|
+
reason: rationale,
|
|
418
|
+
commit: `committed ${commit}`,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
@@ -4,7 +4,7 @@ import { qualifyTaskId } from "../shared.js";
|
|
|
4
4
|
import { requireRunnableRegisterItem, resolveRegisterRunTarget, sanitizeRegisterConclusion, ticketPathFromItem, } from "../register.js";
|
|
5
5
|
import { readResultFrontmatterSnapshot } from "../results.js";
|
|
6
6
|
import { findExecWorktree } from "../worktree.js";
|
|
7
|
-
import { configuredProductRepos, missingProductWorktrees, withProductWorktrees, } from "../task-repos.js";
|
|
7
|
+
import { configuredProductRepos, missingProductWorktrees, resumeIntegrationBranches, withProductWorktrees, } from "../task-repos.js";
|
|
8
8
|
import { currentBranch, isExecBranchMergedIntoCurrent } from "../worktree-ops.js";
|
|
9
9
|
import { syncTaskWorktreesWithIntegrationTargets, } from "../repo-integration.js";
|
|
10
10
|
import { failedParentValidationReason } from "../parent-validation.js";
|
|
@@ -119,6 +119,7 @@ export async function resumeRegisterIntegration(params) {
|
|
|
119
119
|
const resultScaffold = readResultFrontmatterSnapshot(worktreeResultPath);
|
|
120
120
|
const finalize = async () => finalizeRegisterWorktreeRun({
|
|
121
121
|
context: params.context,
|
|
122
|
+
opts: params.opts,
|
|
122
123
|
registerPaths: params.registerPaths,
|
|
123
124
|
item,
|
|
124
125
|
ticketPath: params.ticketPath,
|
|
@@ -165,18 +166,9 @@ export async function resumeSingleRegisterItemWorktree(context, opts, pjrId, lif
|
|
|
165
166
|
if (!foundWorktree) {
|
|
166
167
|
return refuse(`no exec worktree to resume for ${item.id}; run the item again instead`);
|
|
167
168
|
}
|
|
168
|
-
// PJR-98G4: プロダクトの worktree も揃っていることを再開の条件にする。欠けたまま再開すると、
|
|
169
|
-
// agent がプロダクト側の変更先を失う。
|
|
170
|
-
const products = configuredProductRepos(schedulePath);
|
|
171
|
-
const worktree = withProductWorktrees(foundWorktree, products, worktreeTaskId);
|
|
172
|
-
const missingProducts = missingProductWorktrees(products, worktree);
|
|
173
|
-
if (missingProducts.length > 0) {
|
|
174
|
-
return refuse(`product worktrees are missing for ${item.id}: ${missingProducts.join(", ")}; ` +
|
|
175
|
-
`run the item again instead`);
|
|
176
|
-
}
|
|
177
169
|
const lookup = findResumableRegisterRun({
|
|
178
170
|
repoRoot,
|
|
179
|
-
worktreePath:
|
|
171
|
+
worktreePath: foundWorktree.path,
|
|
180
172
|
executionPath,
|
|
181
173
|
taskId: item.id,
|
|
182
174
|
...(opts.resumeFrom === "executor" ? { resumeFrom: "executor" } : {}),
|
|
@@ -184,6 +176,26 @@ export async function resumeSingleRegisterItemWorktree(context, opts, pjrId, lif
|
|
|
184
176
|
if (lookup.kind !== "resumable")
|
|
185
177
|
return refuse(lookup.reason);
|
|
186
178
|
const target = lookup.target;
|
|
179
|
+
// PJR-XRAB: run 開始時の --integration-branch を checkpoint から引き継ぐ。再開時に別の統合先を
|
|
180
|
+
// 指定することは認めない(run の途中で統合先が変わると、開始点と統合先が食い違う)。
|
|
181
|
+
let products;
|
|
182
|
+
let integrationBranchOverrides;
|
|
183
|
+
try {
|
|
184
|
+
const overrides = resumeIntegrationBranches(target.state.integration_branches, opts.integrationBranch);
|
|
185
|
+
products = configuredProductRepos(schedulePath, overrides);
|
|
186
|
+
integrationBranchOverrides = overrides.size > 0 ? Object.fromEntries(overrides) : undefined;
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
return refuse(error instanceof Error ? error.message : String(error));
|
|
190
|
+
}
|
|
191
|
+
// PJR-98G4: プロダクトの worktree も揃っていることを再開の条件にする。欠けたまま再開すると、
|
|
192
|
+
// agent がプロダクト側の変更先を失う。
|
|
193
|
+
const worktree = withProductWorktrees(foundWorktree, products, worktreeTaskId);
|
|
194
|
+
const missingProducts = missingProductWorktrees(products, worktree);
|
|
195
|
+
if (missingProducts.length > 0) {
|
|
196
|
+
return refuse(`product worktrees are missing for ${item.id}: ${missingProducts.join(", ")}; ` +
|
|
197
|
+
`run the item again instead`);
|
|
198
|
+
}
|
|
187
199
|
const artifacts = resolveRegisterResumeArtifacts({
|
|
188
200
|
repoRoot,
|
|
189
201
|
worktreePath: worktree.path,
|
|
@@ -269,6 +281,7 @@ export async function resumeSingleRegisterItemWorktree(context, opts, pjrId, lif
|
|
|
269
281
|
}
|
|
270
282
|
return resumeRegisterIntegration({
|
|
271
283
|
context,
|
|
284
|
+
opts,
|
|
272
285
|
registerPaths,
|
|
273
286
|
item,
|
|
274
287
|
ticketPath,
|
|
@@ -321,11 +334,13 @@ export async function resumeSingleRegisterItemWorktree(context, opts, pjrId, lif
|
|
|
321
334
|
resumeHandoff: target.handoff,
|
|
322
335
|
providerConcurrencyGate: context.providerConcurrencyGate,
|
|
323
336
|
productWorktrees: worktree.repos,
|
|
337
|
+
...(integrationBranchOverrides ? { integrationBranchOverrides } : {}),
|
|
324
338
|
executorRateLimitOptions: resolvePinnedRateLimitRunOptions(opts, context.execDefaults, context.roster, "executor", executor.candidate),
|
|
325
339
|
reporterRateLimitOptions: resolvePinnedRateLimitRunOptions(opts, context.execDefaults, context.roster, "reporter", reporter.candidate),
|
|
326
340
|
});
|
|
327
341
|
const finalize = async () => finalizeRegisterWorktreeRun({
|
|
328
342
|
context,
|
|
343
|
+
opts,
|
|
329
344
|
registerPaths,
|
|
330
345
|
item,
|
|
331
346
|
ticketPath,
|
|
@@ -380,6 +395,7 @@ export async function resumeSingleRegisterItemWorktree(context, opts, pjrId, lif
|
|
|
380
395
|
});
|
|
381
396
|
const finalize = async () => finalizeRegisterWorktreeRun({
|
|
382
397
|
context,
|
|
398
|
+
opts,
|
|
383
399
|
registerPaths,
|
|
384
400
|
item,
|
|
385
401
|
ticketPath,
|
|
@@ -6,7 +6,7 @@ import { buildInPlaceStem } from "../plans.js";
|
|
|
6
6
|
import { generateRegisterPlan, requireRunnableRegisterItem, resolveRegisterRunTarget, sanitizeRegisterConclusion, ticketPathFromItem, } from "../register.js";
|
|
7
7
|
import { readResultFrontmatterSnapshot, scaffoldResult, updateResultStatus } from "../results.js";
|
|
8
8
|
import { findExecWorktree, gitOutput } from "../worktree.js";
|
|
9
|
-
import { configuredProductRepos, withProductRepoPrompt } from "../task-repos.js";
|
|
9
|
+
import { configuredProductRepos, integrationBranchOverrideRecord, withProductRepoPrompt, } from "../task-repos.js";
|
|
10
10
|
import { checkpointAndEnsureWorktree, commitTargetPaths, commitWorktreeChanges, discardStaleExecWorktree, isExecBranchMergedIntoCurrent, mergeWorktreeIntoCurrent, removeWorktree, taskTargetsAtHead, WorktreeRemovedBranchDeletionError, worktreeStatusPaths, } from "../worktree-ops.js";
|
|
11
11
|
import { commitProductWorktrees, integrateTaskRepositories, projectMergeBlockers, PROJECT_REPO_NAME, RepoIntegrationError, } from "../repo-integration.js";
|
|
12
12
|
import { productIntegrationTrace, recordResultTrace, refsTrailer, registerProjectMergeMessage, traceKey, withCommitTrailers, } from "../repo-trace.js";
|
|
@@ -19,6 +19,7 @@ import { downgradeUnfilledResult } from "./schedule-prepare.js";
|
|
|
19
19
|
import { commitSubject, integrateLogPath, recordIntegrateStage, recordRepoIntegration, repoRelativePath, } from "./mode-shared.js";
|
|
20
20
|
import { resolveRegisterCommand, isRegisterPipelineRequested, resolveRegisterPipelineCommand, spawnRegisterTransition, registerRunnerManagedPaths, registerReporterManagedPaths, } from "./register-core.js";
|
|
21
21
|
import { commitRegisterState, registerPathsInsideWorktree, rebuildRootRegisterViews, registerWaitSummary, } from "./register-state.js";
|
|
22
|
+
import { runRegisterPostReview } from "./register-post-review.js";
|
|
22
23
|
// 全体再実行が既存 run の未統合成果を破棄しないための保護。既存 worktree に再開可能な run
|
|
23
24
|
// (executor 成功済みで reporter か統合が未完了)が残っている場合だけ理由を返し、呼び出し側が
|
|
24
25
|
// 破壊的操作(discardStaleExecWorktree)の手前で中断できるようにする。--force-restart で無効化できる。
|
|
@@ -46,6 +47,26 @@ export function protectResumableRegisterWorktree(context, opts, taskId, worktree
|
|
|
46
47
|
`its changes are still unintegrated in ${worktree.path}. ` +
|
|
47
48
|
`Resume the ${stage} stage with --resume, or discard the worktree with --force-restart.`);
|
|
48
49
|
}
|
|
50
|
+
// cleanup の再開までに別項目の commit が積まれても、対象 exec branch を最初に取り込んだ
|
|
51
|
+
// first-parent commit(runner が作った merge commit)だけを post-review の差分範囲にする。
|
|
52
|
+
function integratedRegisterCommitRange(repoRoot, branch) {
|
|
53
|
+
const tip = gitOutput(repoRoot, ["rev-parse", "--verify", `${branch}^{commit}`]).trim();
|
|
54
|
+
const outputCommit = gitOutput(repoRoot, [
|
|
55
|
+
"rev-list",
|
|
56
|
+
"--first-parent",
|
|
57
|
+
"--ancestry-path",
|
|
58
|
+
`${tip}..HEAD`,
|
|
59
|
+
])
|
|
60
|
+
.split("\n")
|
|
61
|
+
.map((line) => line.trim())
|
|
62
|
+
.filter(Boolean)
|
|
63
|
+
.at(-1);
|
|
64
|
+
if (!outputCommit) {
|
|
65
|
+
throw new Error(`could not locate integrated commit for register branch: ${branch}`);
|
|
66
|
+
}
|
|
67
|
+
const baseCommit = gitOutput(repoRoot, ["rev-parse", `${outputCommit}^1`]).trim();
|
|
68
|
+
return { baseCommit, outputCommit };
|
|
69
|
+
}
|
|
49
70
|
// register worktree 実行の Phase 3(成果物統合と状態遷移)。成功なら worktree の成果物を
|
|
50
71
|
// commit → worktree 側で register review → 統合ブランチへ merge commit 1件 → worktree 撤去、
|
|
51
72
|
// 失敗なら worktree を保持したまま waiting へ戻す(wait commit 1件)。通常実行・reporter 再開・
|
|
@@ -70,6 +91,36 @@ export async function finalizeRegisterWorktreeRun(params) {
|
|
|
70
91
|
worktree,
|
|
71
92
|
bookkeepingPaths: params.bookkeepingPaths,
|
|
72
93
|
});
|
|
94
|
+
const postReview = async (baseCommit, outputCommit) => {
|
|
95
|
+
if (!context.postReview)
|
|
96
|
+
return undefined;
|
|
97
|
+
if (!ticketPath) {
|
|
98
|
+
throw new Error(`register post-review requires an item ticket: ${item.id}`);
|
|
99
|
+
}
|
|
100
|
+
const reviewed = await runRegisterPostReview({
|
|
101
|
+
context,
|
|
102
|
+
opts: params.opts,
|
|
103
|
+
registerPaths,
|
|
104
|
+
item,
|
|
105
|
+
ticketPath,
|
|
106
|
+
stem,
|
|
107
|
+
editPlanPath: resolve(context.executionPath, "exec", "plans", `${stem}-plan.md`),
|
|
108
|
+
editResultPath: resolve(repoRoot, repoRelativePath(worktree.path, params.worktreeResultPath)),
|
|
109
|
+
baseCommit,
|
|
110
|
+
outputCommit,
|
|
111
|
+
worktreePath: worktree.path,
|
|
112
|
+
editPipelineStatePath: params.pipelineStatePath,
|
|
113
|
+
});
|
|
114
|
+
process.stdout.write(`post-review done: ${item.id} (verdict transition: ${reviewed.transition})\n`);
|
|
115
|
+
return {
|
|
116
|
+
id: item.id,
|
|
117
|
+
title: item.title,
|
|
118
|
+
outcome: reviewed.outcome,
|
|
119
|
+
transition: reviewed.transition,
|
|
120
|
+
commit: reviewed.commit ?? `committed ${outputCommit.slice(0, 12)}`,
|
|
121
|
+
reason: reviewed.reason,
|
|
122
|
+
};
|
|
123
|
+
};
|
|
73
124
|
const completedAt = new Date().toISOString();
|
|
74
125
|
const worktreeResultPath = params.worktreeResultPath;
|
|
75
126
|
const { result: effectiveResult, unfilledBlock } = downgradeUnfilledResult(agentResult, worktreeResultPath, "edit", params.resultScaffold);
|
|
@@ -80,6 +131,7 @@ export async function finalizeRegisterWorktreeRun(params) {
|
|
|
80
131
|
// exec branch here would force a second merge commit for the same task.
|
|
81
132
|
if (params.resumedIntegration &&
|
|
82
133
|
isExecBranchMergedIntoCurrent({ context: wtContext, worktree })) {
|
|
134
|
+
const { baseCommit, outputCommit } = integratedRegisterCommitRange(repoRoot, worktree.branch);
|
|
83
135
|
try {
|
|
84
136
|
const lifecyclePaths = new Set([worktreeResultPath, params.pipelineStatePath]
|
|
85
137
|
.filter((path) => !!path)
|
|
@@ -125,6 +177,9 @@ export async function finalizeRegisterWorktreeRun(params) {
|
|
|
125
177
|
}
|
|
126
178
|
}
|
|
127
179
|
rebuildRootRegisterViews(projectId, item.id);
|
|
180
|
+
const reviewed = await postReview(baseCommit, outputCommit);
|
|
181
|
+
if (reviewed)
|
|
182
|
+
return reviewed;
|
|
128
183
|
const sha = gitOutput(repoRoot, ["rev-parse", "--short", "HEAD"]).trim();
|
|
129
184
|
process.stdout.write(`run done: ${item.id} (status: review — confirm and close with "register close")\n`);
|
|
130
185
|
return {
|
|
@@ -136,6 +191,7 @@ export async function finalizeRegisterWorktreeRun(params) {
|
|
|
136
191
|
};
|
|
137
192
|
}
|
|
138
193
|
await updateResultStatus(worktreeResultPath, "complete", completedAt);
|
|
194
|
+
const baseCommit = gitOutput(repoRoot, ["rev-parse", "HEAD"]).trim();
|
|
139
195
|
const subject = commitSubject(`exec(register ${item.id}): `, item.title);
|
|
140
196
|
// PJR-30SW: プロダクト側の commit と merge commit、プロジェクト側の merge commit に
|
|
141
197
|
// `Refs: <project-id>:<item-id>` を付ける(PJR-1SXK)。
|
|
@@ -301,6 +357,10 @@ export async function finalizeRegisterWorktreeRun(params) {
|
|
|
301
357
|
}
|
|
302
358
|
// review は merge で root の個票に入る。非追跡の派生ビューだけ root で作り直す。
|
|
303
359
|
rebuildRootRegisterViews(projectId, item.id);
|
|
360
|
+
const outputCommit = gitOutput(repoRoot, ["rev-parse", "HEAD"]).trim();
|
|
361
|
+
const reviewed = await postReview(baseCommit, outputCommit);
|
|
362
|
+
if (reviewed)
|
|
363
|
+
return reviewed;
|
|
304
364
|
const sha = gitOutput(repoRoot, ["rev-parse", "--short", "HEAD"]).trim();
|
|
305
365
|
process.stdout.write(`run done: ${item.id} (status: review — confirm and close with "register close")\n`);
|
|
306
366
|
return {
|
|
@@ -358,7 +418,9 @@ export async function runSingleRegisterItemWorktree(context, opts, pjrId, lifecy
|
|
|
358
418
|
? `${new Date().toISOString().replace(/[-:.]/g, "")}-${randomHex(4)}`
|
|
359
419
|
: undefined;
|
|
360
420
|
// PJR-98G4: repos を宣言した project では、プロダクトの worktree も同じタスクの下に作る。
|
|
361
|
-
|
|
421
|
+
// PJR-XRAB: --integration-branch は設定の integration_branch より優先する。
|
|
422
|
+
const products = configuredProductRepos(schedulePath, opts.integrationBranch);
|
|
423
|
+
const integrationBranchOverrides = integrationBranchOverrideRecord(opts.integrationBranch);
|
|
362
424
|
// Phase 1: plan/result 生成 → register start → checkpoint → worktree 作成(root で直列化)。
|
|
363
425
|
const setup = async () => {
|
|
364
426
|
// executor が成功した run の worktree を、全体再実行が破棄しないよう保護する。
|
|
@@ -494,6 +556,7 @@ export async function runSingleRegisterItemWorktree(context, opts, pjrId, lifecy
|
|
|
494
556
|
execDefaults: context.execDefaults,
|
|
495
557
|
providerConcurrencyGate: context.providerConcurrencyGate,
|
|
496
558
|
productWorktrees: worktree.repos,
|
|
559
|
+
...(integrationBranchOverrides ? { integrationBranchOverrides } : {}),
|
|
497
560
|
runId: pipelineRunId,
|
|
498
561
|
executorRateLimitOptions: opts.executorBy
|
|
499
562
|
? resolvePinnedRateLimitRunOptions(opts, context.execDefaults, context.roster, "executor", pipelineAgents.executor)
|
|
@@ -522,6 +585,7 @@ export async function runSingleRegisterItemWorktree(context, opts, pjrId, lifecy
|
|
|
522
585
|
// Phase 3: 成果物統合と状態遷移(root で直列化)。通常実行と再開経路で共通化する。
|
|
523
586
|
const finalize = async () => finalizeRegisterWorktreeRun({
|
|
524
587
|
context,
|
|
588
|
+
opts,
|
|
525
589
|
registerPaths,
|
|
526
590
|
item,
|
|
527
591
|
ticketPath,
|
package/dist/exec/run/run.js
CHANGED
|
@@ -4,7 +4,7 @@ export { checkCompletionBeforeIntegration, downgradeUnfilledResult } from "./sch
|
|
|
4
4
|
export { rebuildStaleGeneratedTracksForCycle, resolveClaimingActor } from "./schedule-mode.js";
|
|
5
5
|
export { resolveInPlaceAgentPipeline, resolveInPlaceCommand } from "./in-place.js";
|
|
6
6
|
export { commitSubject, pipelineRecoveryMeta } from "./mode-shared.js";
|
|
7
|
-
export { commitRegisterItemChanges, isRegisterPipelineRequested, parseRegisterExecutorSelection, resolveRegisterCommand, resolveRegisterPipelineCommand, } from "./register-core.js";
|
|
7
|
+
export { applyRegisterDifficultyRouting, commitRegisterItemChanges, isRegisterPipelineRequested, parseRegisterExecutorSelection, resolveRegisterCommand, resolveRegisterPipelineCommand, } from "./register-core.js";
|
|
8
8
|
export { registerStatePaths } from "./register-state.js";
|
|
9
9
|
export { resolveRegisterResumeExecutor, resolveRegisterResumeReporter } from "./register-resume.js";
|
|
10
10
|
export { registerRunCommand } from "./register-command.js";
|