pi-spine 1.1.0 → 1.2.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/bin/spine-batch.mjs +160 -53
- package/bin/spine-cli/batch.mjs +3 -3
- package/bin/spine-cli/lane-logs.mjs +24 -0
- package/bin/spine-cli/scenarios.mjs +298 -0
- package/bin/spine-cli/wait.mjs +30 -0
- package/bin/spine-cli/watch.mjs +27 -0
- package/bin/spine-issue.mjs +196 -0
- package/bin/spine-journal.mjs +1 -0
- package/bin/spine-run.mjs +30 -0
- package/bin/spine-status.mjs +19 -1
- package/bin/spine-tasks.mjs +16 -2
- package/bin/spine-worker-runner.mjs +10 -10
- package/bin/spine.mjs +49 -1
- package/package.json +1 -1
- package/skills/create-spine-tasks/references/contract-template.md +19 -0
- package/src/batch/abort.mjs +2 -11
- package/src/batch/agent-session-worker.mjs +45 -5
- package/src/batch/attached-engine-handoff.mjs +188 -0
- package/src/batch/attached-runner.mjs +312 -0
- package/src/batch/contract-prelanded.mjs +180 -0
- package/src/batch/contract-verify.mjs +140 -2
- package/src/batch/detached-start.mjs +66 -2
- package/src/batch/diagnosis-alternatives.mjs +46 -0
- package/src/batch/diagnosis-merge-failure.mjs +79 -0
- package/src/batch/diagnosis-retry-limbo.mjs +34 -0
- package/src/batch/diagnosis-stub.mjs +109 -0
- package/src/batch/diagnosis-task-done.mjs +110 -0
- package/src/batch/diagnosis-worker-done-missing.mjs +96 -0
- package/src/batch/diagnosis.mjs +135 -68
- package/src/batch/engine-lanes/merge.mjs +110 -82
- package/src/batch/engine-lanes/queue.mjs +4 -1
- package/src/batch/engine-lanes/watch.mjs +29 -0
- package/src/batch/engine-lanes.mjs +1 -0
- package/src/batch/engine-scope.mjs +11 -1
- package/src/batch/engine.mjs +79 -24
- package/src/batch/evidence.mjs +78 -15
- package/src/batch/gate.mjs +43 -14
- package/src/batch/git-helpers.mjs +96 -0
- package/src/batch/heartbeat.mjs +73 -7
- package/src/batch/integrate.mjs +2 -4
- package/src/batch/journal.mjs +3 -0
- package/src/batch/lane-commit.mjs +90 -5
- package/src/batch/lifecycle.mjs +130 -3
- package/src/batch/macro-phase.mjs +226 -0
- package/src/batch/merge/adoption-doc-merge.mjs +93 -10
- package/src/batch/merge/wave-merge-state.mjs +3 -0
- package/src/batch/metrics.mjs +74 -5
- package/src/batch/orphan-detect.mjs +74 -0
- package/src/batch/pause.mjs +223 -0
- package/src/batch/post-merge-limbo.mjs +264 -8
- package/src/batch/reconcile.mjs +429 -54
- package/src/batch/resume-common.mjs +5 -1
- package/src/batch/resume-lane-reviews.mjs +16 -0
- package/src/batch/resume-multi-lanes.mjs +56 -1
- package/src/batch/resume-multi-validate.mjs +67 -6
- package/src/batch/resume-multi.mjs +9 -4
- package/src/batch/resume.mjs +52 -45
- package/src/batch/retry.mjs +56 -5
- package/src/batch/review-spawn.mjs +8 -2
- package/src/batch/rules-manifest-drift.mjs +157 -0
- package/src/batch/salvage.mjs +2 -1
- package/src/batch/sequence.mjs +454 -0
- package/src/batch/state.mjs +18 -3
- package/src/batch/status-json.mjs +67 -0
- package/src/batch/task-stall-budget.mjs +22 -10
- package/src/batch/worker-host.mjs +95 -7
- package/src/batch/worker-output.mjs +196 -3
- package/src/cli/issue-draft.mjs +180 -0
- package/src/cli/journal-follow.mjs +239 -0
- package/src/cli/lane-logs.mjs +291 -0
- package/src/cli/sequence.mjs +108 -0
- package/src/cli/settings-set.mjs +2 -21
- package/src/cli/wait.mjs +187 -0
- package/src/cli/watch.mjs +160 -0
- package/src/config/agent-model-resolve.mjs +48 -0
- package/src/config/cursor-rules/discover.mjs +3 -21
- package/src/config/defaults.mjs +7 -1
- package/src/config/settings-fields.mjs +48 -0
- package/src/config/spine-init-constants.mjs +1 -0
- package/src/config/spine-preflight-lib.mjs +471 -16
- package/src/dashboard/lane-throughput.mjs +351 -0
- package/src/dashboard/public/dashboard.css +25 -1
- package/src/dashboard/public/dashboard.js +223 -18
- package/src/dashboard/public/index.html +14 -2
- package/src/dashboard/server.mjs +4 -0
- package/src/dashboard/snapshot.mjs +215 -1
- package/src/dashboard/view.mjs +170 -17
- package/src/doctor/agent-model-inherit.mjs +61 -6
- package/src/doctor/run-doctor-checks.mjs +26 -1
- package/src/doctor/sequence-safety.mjs +57 -0
- package/src/doctor/stale-worktrees.mjs +102 -0
- package/src/fixtures/scenario-registry.mjs +194 -0
- package/src/fs/atomic-write.mjs +49 -0
- package/src/planner/file-scope.mjs +246 -0
- package/src/planner/format-plan.mjs +9 -7
- package/src/planner/index.mjs +6 -2
- package/src/planner/wave-scope.mjs +136 -0
- package/src/planner/waves.mjs +133 -0
- package/src/tasks/packet/index.mjs +1 -0
- package/src/tasks/packet/parse-prompt.mjs +42 -1
- package/src/tasks/packet/validate-prompt.mjs +124 -0
- package/templates/spine-config.json +8 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker exited without `.DONE` diagnosis helpers (SP-313 / issue #18).
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** Worker exited cleanly but never wrote `.DONE`. */
|
|
6
|
+
export const WORKER_DONE_MISSING_OUTPUT_MARKERS = [
|
|
7
|
+
"pi exited but .DONE was not created",
|
|
8
|
+
"agent session finished but .DONE was not created",
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {string|null|undefined} outputText
|
|
13
|
+
* @returns {boolean}
|
|
14
|
+
*/
|
|
15
|
+
export function outputIndicatesWorkerDoneMissing(outputText) {
|
|
16
|
+
if (!outputText || !String(outputText).trim()) return false;
|
|
17
|
+
const normalized = String(outputText).toLowerCase();
|
|
18
|
+
return WORKER_DONE_MISSING_OUTPUT_MARKERS.some((marker) =>
|
|
19
|
+
normalized.includes(marker.toLowerCase()),
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {object} [ctx]
|
|
25
|
+
* @param {object[]} [ctx.journalEvents]
|
|
26
|
+
* @param {string|null} [ctx.failedTaskId]
|
|
27
|
+
* @returns {object|null}
|
|
28
|
+
*/
|
|
29
|
+
export function inferWorkerDoneMissingFailure(ctx = {}) {
|
|
30
|
+
const { journalEvents, failedTaskId } = ctx;
|
|
31
|
+
if (!Array.isArray(journalEvents) || journalEvents.length === 0) return null;
|
|
32
|
+
|
|
33
|
+
for (let index = journalEvents.length - 1; index >= 0; index -= 1) {
|
|
34
|
+
const event = journalEvents[index];
|
|
35
|
+
if (event.type !== "task.failed") continue;
|
|
36
|
+
const eventTaskId = event.taskId ?? event.payload?.taskId;
|
|
37
|
+
if (failedTaskId && eventTaskId && eventTaskId !== failedTaskId) continue;
|
|
38
|
+
|
|
39
|
+
const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
|
|
40
|
+
if (payload.doneFound === true) continue;
|
|
41
|
+
|
|
42
|
+
const outputText = [payload.output, payload.error].filter(Boolean).join("\n");
|
|
43
|
+
if (!outputIndicatesWorkerDoneMissing(outputText)) continue;
|
|
44
|
+
|
|
45
|
+
const changedFileCount = Number(payload.changedFileCount);
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
taskId: eventTaskId ?? failedTaskId ?? null,
|
|
49
|
+
output: outputText || null,
|
|
50
|
+
workerOutputLogRef:
|
|
51
|
+
typeof payload.workerOutputLogRef === "string" ? payload.workerOutputLogRef : null,
|
|
52
|
+
workerOutputLogPath:
|
|
53
|
+
typeof payload.workerOutputLogPath === "string" ? payload.workerOutputLogPath : null,
|
|
54
|
+
changedFileCount: Number.isFinite(changedFileCount) ? changedFileCount : null,
|
|
55
|
+
exitCode: payload.exitCode ?? null,
|
|
56
|
+
doneFound: payload.doneFound === false,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {string} batchLabel
|
|
65
|
+
* @param {object} ctx
|
|
66
|
+
*/
|
|
67
|
+
export function buildWorkerDoneMissingHeadline(batchLabel, ctx = {}) {
|
|
68
|
+
const taskLabel = ctx.failedTaskId ? `task ${ctx.failedTaskId}` : "worker";
|
|
69
|
+
const fileHint =
|
|
70
|
+
ctx.changedFileCount === 0
|
|
71
|
+
? " (0 scoped files)"
|
|
72
|
+
: ctx.changedFileCount != null
|
|
73
|
+
? ` (${ctx.changedFileCount} scoped file(s))`
|
|
74
|
+
: "";
|
|
75
|
+
const logRef = ctx.workerOutputLogRef ?? ctx.workerOutputLogPath ?? null;
|
|
76
|
+
const logHint = logRef ? ` — see ${logRef}` : "";
|
|
77
|
+
const tail = ctx.workerOutputTail?.trim();
|
|
78
|
+
const tailHint = tail
|
|
79
|
+
? `: ${tail.split("\n").filter(Boolean).slice(-3).join(" | ")}`
|
|
80
|
+
: ctx.workerOutputSnippet
|
|
81
|
+
? `: ${ctx.workerOutputSnippet}`
|
|
82
|
+
: "";
|
|
83
|
+
return `${batchLabel} ${taskLabel} exited without .DONE${fileHint}${logHint}${tailHint}`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** @param {object} ctx */
|
|
87
|
+
export function buildWorkerDoneMissingSuggestedCommand(ctx = {}) {
|
|
88
|
+
return ctx.failedTaskId ? `spine batch retry ${ctx.failedTaskId}` : "spine status --diagnose";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** @param {object} ctx @param {string[]} common */
|
|
92
|
+
export function buildWorkerDoneMissingAlternatives(ctx = {}, common = []) {
|
|
93
|
+
return ctx.failedTaskId
|
|
94
|
+
? [`spine batch retry ${ctx.failedTaskId}`, "spine status --diagnose", ...common]
|
|
95
|
+
: common;
|
|
96
|
+
}
|
package/src/batch/diagnosis.mjs
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* FR-BATCH-13 diagnosis taxonomy and operator messaging (§18.3).
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
import {
|
|
5
|
+
buildWorkerDoneMissingHeadline,
|
|
6
|
+
buildWorkerDoneMissingSuggestedCommand,
|
|
7
|
+
} from "./diagnosis-worker-done-missing.mjs";
|
|
8
|
+
import {
|
|
9
|
+
buildFailedPhasePendingOnlyHeadline,
|
|
10
|
+
buildFailedPhasePendingOnlySuggestedCommand,
|
|
11
|
+
isFailedPhasePendingOnlyLimbo,
|
|
12
|
+
} from "./diagnosis-retry-limbo.mjs";
|
|
13
|
+
import { buildAlternatives } from "./diagnosis-alternatives.mjs";
|
|
14
|
+
export { buildAlternatives } from "./diagnosis-alternatives.mjs";
|
|
15
|
+
import {
|
|
16
|
+
buildMergeFailureHeadline,
|
|
17
|
+
summarizeMergeFailures,
|
|
18
|
+
} from "./diagnosis-merge-failure.mjs";
|
|
19
|
+
export { buildMergeFailureHeadline, summarizeMergeFailures } from "./diagnosis-merge-failure.mjs";
|
|
20
|
+
import {
|
|
21
|
+
buildStubFailureHeadline,
|
|
22
|
+
buildStubFailureSuggestedCommand,
|
|
23
|
+
STUB_EXIT_REASONS,
|
|
24
|
+
} from "./diagnosis-stub.mjs";
|
|
25
|
+
export {
|
|
26
|
+
classifyTaskDoneSemantics,
|
|
27
|
+
resolveTaskFolderPath,
|
|
28
|
+
resolveTaskLaneWorktreePath,
|
|
29
|
+
TASK_DONE_FLAG_FIELD_NAMES,
|
|
30
|
+
} from "./diagnosis-task-done.mjs";
|
|
5
31
|
/** @typedef {import("./reconcile.mjs").ReconciliationResult} ReconciliationResult */
|
|
6
32
|
|
|
7
33
|
export const DIAGNOSIS_TAXONOMY = [
|
|
@@ -10,6 +36,7 @@ export const DIAGNOSIS_TAXONOMY = [
|
|
|
10
36
|
"needs_retry",
|
|
11
37
|
"state_drift",
|
|
12
38
|
"worker_orphaned",
|
|
39
|
+
"worker_done_missing",
|
|
13
40
|
"engine_orphaned",
|
|
14
41
|
"needs_merge",
|
|
15
42
|
"needs_integrate",
|
|
@@ -21,15 +48,9 @@ export const DIAGNOSIS_TAXONOMY = [
|
|
|
21
48
|
"aborted",
|
|
22
49
|
];
|
|
23
50
|
|
|
24
|
-
const NO_PAUSE_DIAGNOSES = new Set([
|
|
25
|
-
"limbo_stale",
|
|
26
|
-
"completed_manual",
|
|
27
|
-
"needs_integrate",
|
|
28
|
-
"engine_orphaned",
|
|
29
|
-
]);
|
|
30
|
-
|
|
51
|
+
const NO_PAUSE_DIAGNOSES = new Set(["limbo_stale", "completed_manual", "needs_integrate", "engine_orphaned"]);
|
|
31
52
|
const LANE_COMMIT_EXIT_REASONS = new Set(["DirtyWorktree", "lane_commit_failed"]);
|
|
32
|
-
|
|
53
|
+
const GITIGNORED_MERGE_FAILURE_CLASSES = new Set(["merge_failed_gitignored", "GitignoredDirtyWorktree"]);
|
|
33
54
|
const REVIEW_SPAWN_FAILURE_EXIT_REASONS = new Set([
|
|
34
55
|
"code_review_spawn_failed",
|
|
35
56
|
"code_review_timeout",
|
|
@@ -37,23 +58,6 @@ const REVIEW_SPAWN_FAILURE_EXIT_REASONS = new Set([
|
|
|
37
58
|
"final_review_timeout",
|
|
38
59
|
]);
|
|
39
60
|
|
|
40
|
-
/**
|
|
41
|
-
* @param {object[]} [journalEvents]
|
|
42
|
-
* @param {string|null} [taskId]
|
|
43
|
-
* @returns {object|null}
|
|
44
|
-
*/
|
|
45
|
-
function findLatestTaskFailedEvent(journalEvents, taskId) {
|
|
46
|
-
if (!Array.isArray(journalEvents) || journalEvents.length === 0) return null;
|
|
47
|
-
for (let index = journalEvents.length - 1; index >= 0; index -= 1) {
|
|
48
|
-
const event = journalEvents[index];
|
|
49
|
-
if (event.type !== "task.failed") continue;
|
|
50
|
-
const eventTaskId = event.taskId ?? event.payload?.taskId;
|
|
51
|
-
if (taskId && eventTaskId && eventTaskId !== taskId) continue;
|
|
52
|
-
return event;
|
|
53
|
-
}
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
61
|
/**
|
|
58
62
|
* @param {string} haystack
|
|
59
63
|
* @param {object} [hints]
|
|
@@ -114,6 +118,54 @@ export function inferLaunchFailureFromWorkerOutputTail(outputText) {
|
|
|
114
118
|
return classifyLaunchFailureHaystack(String(outputText));
|
|
115
119
|
}
|
|
116
120
|
|
|
121
|
+
/**
|
|
122
|
+
* @param {object} [ctx]
|
|
123
|
+
* @param {string|null} [ctx.exitReason]
|
|
124
|
+
* @param {string|null} [ctx.failureClass]
|
|
125
|
+
* @param {string|null} [ctx.lastError]
|
|
126
|
+
* @param {object[]} [ctx.journalEvents]
|
|
127
|
+
* @returns {boolean}
|
|
128
|
+
*/
|
|
129
|
+
export function inferMergeGitignoredFailure(ctx = {}) {
|
|
130
|
+
const { exitReason, failureClass, lastError, journalEvents } = ctx;
|
|
131
|
+
if (GITIGNORED_MERGE_FAILURE_CLASSES.has(exitReason ?? "")) return true;
|
|
132
|
+
if (GITIGNORED_MERGE_FAILURE_CLASSES.has(failureClass ?? "")) return true;
|
|
133
|
+
|
|
134
|
+
const haystackParts = [exitReason, failureClass, lastError];
|
|
135
|
+
if (Array.isArray(journalEvents)) {
|
|
136
|
+
for (const event of journalEvents) {
|
|
137
|
+
if (event.type !== "batch.merge_failed" && event.type !== "task.failed") continue;
|
|
138
|
+
const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
|
|
139
|
+
haystackParts.push(
|
|
140
|
+
payload.failureClass,
|
|
141
|
+
payload.classification,
|
|
142
|
+
payload.error,
|
|
143
|
+
payload.output,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const haystack = haystackParts.filter(Boolean).join("\n").toLowerCase();
|
|
148
|
+
return (
|
|
149
|
+
haystack.includes("gitignored dirty files only") ||
|
|
150
|
+
haystack.includes("merge_failed_gitignored") ||
|
|
151
|
+
haystack.includes("gitignoreddirtyworktree") ||
|
|
152
|
+
(haystack.includes("git add") && haystack.includes("ignored"))
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @param {string|null|undefined} taskBranch
|
|
158
|
+
* @param {string[]|null|undefined} gitignoredPaths
|
|
159
|
+
*/
|
|
160
|
+
export function buildGitignoredMergeRepairCommand(taskBranch, gitignoredPaths) {
|
|
161
|
+
const branchHint = taskBranch ? `git checkout ${taskBranch}` : "git checkout <task-branch>";
|
|
162
|
+
const pathHint =
|
|
163
|
+
Array.isArray(gitignoredPaths) && gitignoredPaths.length > 0
|
|
164
|
+
? `git rm -r --cached -- ${gitignoredPaths.slice(0, 5).join(" ")}`
|
|
165
|
+
: "git rm -r --cached -- <gitignored-paths>";
|
|
166
|
+
return `${branchHint} && ${pathHint} && spine batch resume --force`;
|
|
167
|
+
}
|
|
168
|
+
|
|
117
169
|
/**
|
|
118
170
|
* @param {object} ctx
|
|
119
171
|
* @param {string|null} [ctx.exitReason]
|
|
@@ -162,8 +214,22 @@ export function inferLaunchFailureKind(ctx = {}) {
|
|
|
162
214
|
* @param {string|null} [ctx.salvageRetryCommand]
|
|
163
215
|
* @param {string|null} [ctx.exitReason]
|
|
164
216
|
* @param {string|null} [ctx.launchFailureKind]
|
|
217
|
+
* @param {boolean} [ctx.mergeGitignoredFailure]
|
|
218
|
+
* @param {boolean} [ctx.mergeFailed]
|
|
219
|
+
* @param {string|null} [ctx.taskBranch]
|
|
220
|
+
* @param {string[]|null} [ctx.gitignoredPaths]
|
|
165
221
|
*/
|
|
166
222
|
export function buildSuggestedCommand(diagnosis, ctx = {}) {
|
|
223
|
+
if (ctx.mergeGitignoredFailure) {
|
|
224
|
+
return buildGitignoredMergeRepairCommand(ctx.taskBranch, ctx.gitignoredPaths);
|
|
225
|
+
}
|
|
226
|
+
if (ctx.mergeFailed && (diagnosis === "failed" || diagnosis === "needs_retry")) {
|
|
227
|
+
return "spine batch resume --force";
|
|
228
|
+
}
|
|
229
|
+
if (ctx.phase === "merge_blocked") {
|
|
230
|
+
return "spine batch resume --force";
|
|
231
|
+
}
|
|
232
|
+
|
|
167
233
|
switch (diagnosis) {
|
|
168
234
|
case "limbo_stale":
|
|
169
235
|
case "completed_manual":
|
|
@@ -171,6 +237,9 @@ export function buildSuggestedCommand(diagnosis, ctx = {}) {
|
|
|
171
237
|
case "state_drift":
|
|
172
238
|
return "spine batch retry --force";
|
|
173
239
|
case "needs_retry":
|
|
240
|
+
if (STUB_EXIT_REASONS.has(ctx.exitReason ?? "")) {
|
|
241
|
+
return buildStubFailureSuggestedCommand(ctx);
|
|
242
|
+
}
|
|
174
243
|
if (ctx.launchFailureKind === "pi_spine_root" || ctx.launchFailureKind === "launch_failed") {
|
|
175
244
|
return "spine doctor";
|
|
176
245
|
}
|
|
@@ -178,6 +247,9 @@ export function buildSuggestedCommand(diagnosis, ctx = {}) {
|
|
|
178
247
|
return "spine doctor";
|
|
179
248
|
}
|
|
180
249
|
if (ctx.salvageRetryCommand) return ctx.salvageRetryCommand;
|
|
250
|
+
if (isFailedPhasePendingOnlyLimbo(ctx)) {
|
|
251
|
+
return buildFailedPhasePendingOnlySuggestedCommand(ctx);
|
|
252
|
+
}
|
|
181
253
|
return ctx.failedTaskId
|
|
182
254
|
? `spine batch retry ${ctx.failedTaskId}`
|
|
183
255
|
: "spine status --diagnose";
|
|
@@ -206,8 +278,12 @@ export function buildSuggestedCommand(diagnosis, ctx = {}) {
|
|
|
206
278
|
return ctx.failedTaskId
|
|
207
279
|
? `spine batch retry ${ctx.failedTaskId}`
|
|
208
280
|
: "spine batch abort";
|
|
281
|
+
case "worker_done_missing":
|
|
282
|
+
return buildWorkerDoneMissingSuggestedCommand(ctx);
|
|
209
283
|
case "engine_orphaned":
|
|
210
|
-
return
|
|
284
|
+
return ctx.failedTaskId
|
|
285
|
+
? `spine batch retry ${ctx.failedTaskId}`
|
|
286
|
+
: "spine batch resume --attached";
|
|
211
287
|
case "needs_merge":
|
|
212
288
|
return "/spine-resume --force";
|
|
213
289
|
case "needs_integrate":
|
|
@@ -218,7 +294,7 @@ export function buildSuggestedCommand(diagnosis, ctx = {}) {
|
|
|
218
294
|
if (ctx.stalePathSpine) {
|
|
219
295
|
return "node bin/spine.mjs batch resume --attached";
|
|
220
296
|
}
|
|
221
|
-
return "spine batch resume";
|
|
297
|
+
return "spine batch resume --force";
|
|
222
298
|
}
|
|
223
299
|
return "spine integrate";
|
|
224
300
|
case "needs_replan": {
|
|
@@ -254,16 +330,34 @@ export function buildSuggestedCommand(diagnosis, ctx = {}) {
|
|
|
254
330
|
* @param {number} [ctx.salvageChangedFileCount]
|
|
255
331
|
* @param {string|null} [ctx.exitReason]
|
|
256
332
|
* @param {string|null} [ctx.launchFailureKind]
|
|
333
|
+
* @param {boolean} [ctx.mergeGitignoredFailure]
|
|
334
|
+
* @param {boolean} [ctx.mergeFailed]
|
|
335
|
+
* @param {number|null} [ctx.failedWaveIndex]
|
|
336
|
+
* @param {number|null} [ctx.failedLane]
|
|
337
|
+
* @param {string|null} [ctx.lastError]
|
|
338
|
+
* @param {number} [ctx.succeededTasks]
|
|
339
|
+
* @param {number} [ctx.totalTasks]
|
|
257
340
|
*/
|
|
258
341
|
export function buildHeadline(diagnosis, ctx = {}) {
|
|
259
342
|
const batchLabel = ctx.batchId ? `Batch ${ctx.batchId}` : "Batch";
|
|
260
343
|
|
|
344
|
+
if (ctx.mergeGitignoredFailure) {
|
|
345
|
+
return `${batchLabel} merge blocked by gitignored paths on a lane branch — drop cached ignored files, then resume`;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (ctx.mergeFailed && (diagnosis === "failed" || diagnosis === "needs_retry")) {
|
|
349
|
+
return buildMergeFailureHeadline(batchLabel, ctx);
|
|
350
|
+
}
|
|
351
|
+
|
|
261
352
|
switch (diagnosis) {
|
|
262
353
|
case "limbo_stale":
|
|
263
354
|
return `${batchLabel} finished but state is stale — dismiss to clear`;
|
|
264
355
|
case "completed_manual":
|
|
265
356
|
return `${batchLabel} work is on main but batch record is still active`;
|
|
266
357
|
case "needs_retry":
|
|
358
|
+
if (STUB_EXIT_REASONS.has(ctx.exitReason ?? "")) {
|
|
359
|
+
return buildStubFailureHeadline(batchLabel, ctx);
|
|
360
|
+
}
|
|
267
361
|
if (ctx.launchFailureKind === "pi_spine_root" || ctx.launchFailureKind === "launch_failed") {
|
|
268
362
|
return `${batchLabel} failed at worker launch — fix PI_SPINE_ROOT/devcontainer, then retry`;
|
|
269
363
|
}
|
|
@@ -271,6 +365,11 @@ export function buildHeadline(diagnosis, ctx = {}) {
|
|
|
271
365
|
return `${batchLabel} failed at worker launch — repair lane worktree git, then retry`;
|
|
272
366
|
}
|
|
273
367
|
if (LANE_COMMIT_EXIT_REASONS.has(ctx.exitReason ?? "")) {
|
|
368
|
+
if (ctx.exitReason === "GitignoredDirtyWorktree" || ctx.mergeGitignoredFailure) {
|
|
369
|
+
return ctx.failedTaskId
|
|
370
|
+
? `${batchLabel} task ${ctx.failedTaskId} left gitignored dirty files on the lane branch`
|
|
371
|
+
: `${batchLabel} lane commit refused gitignored-only dirty files`;
|
|
372
|
+
}
|
|
274
373
|
return ctx.failedTaskId
|
|
275
374
|
? `${batchLabel} task ${ctx.failedTaskId} completed but lane commit failed`
|
|
276
375
|
: `${batchLabel} completed but lane commit failed`;
|
|
@@ -288,6 +387,9 @@ export function buildHeadline(diagnosis, ctx = {}) {
|
|
|
288
387
|
if (ctx.salvageChangedFileCount > 0 && ctx.failedTaskId) {
|
|
289
388
|
return `${batchLabel} failed (${ctx.failedTaskId}): ${ctx.salvageChangedFileCount} uncommitted file(s) in scope`;
|
|
290
389
|
}
|
|
390
|
+
if (isFailedPhasePendingOnlyLimbo(ctx)) {
|
|
391
|
+
return buildFailedPhasePendingOnlyHeadline(batchLabel, ctx);
|
|
392
|
+
}
|
|
291
393
|
return ctx.failedTaskId
|
|
292
394
|
? `${batchLabel} worker died while task ${ctx.failedTaskId} was running — retry or abort`
|
|
293
395
|
: `${batchLabel} has failed tasks — retry before resume`;
|
|
@@ -320,11 +422,16 @@ export function buildHeadline(diagnosis, ctx = {}) {
|
|
|
320
422
|
return ctx.failedTaskId
|
|
321
423
|
? `${batchLabel} lane worker orphaned while task ${ctx.failedTaskId} was running — retry or abort`
|
|
322
424
|
: `${batchLabel} lane worker orphaned — retry or abort`;
|
|
425
|
+
case "worker_done_missing":
|
|
426
|
+
return buildWorkerDoneMissingHeadline(batchLabel, ctx);
|
|
323
427
|
case "engine_orphaned":
|
|
324
428
|
return ctx.failedTaskId
|
|
325
429
|
? `${batchLabel} engine died mid-run (task ${ctx.failedTaskId} still running) — retry or abort`
|
|
326
430
|
: `${batchLabel} batch engine died while running — retry or abort`;
|
|
327
431
|
case "needs_merge":
|
|
432
|
+
if (ctx.mergeGitignoredFailure) {
|
|
433
|
+
return `${batchLabel} merge blocked by gitignored paths committed on a lane branch`;
|
|
434
|
+
}
|
|
328
435
|
return `${batchLabel} tasks done — lane merges pending`;
|
|
329
436
|
case "needs_integrate":
|
|
330
437
|
if (ctx.postMergeLimbo && ctx.phase === "running") {
|
|
@@ -361,46 +468,6 @@ export function buildHeadline(diagnosis, ctx = {}) {
|
|
|
361
468
|
}
|
|
362
469
|
}
|
|
363
470
|
|
|
364
|
-
/**
|
|
365
|
-
* @param {string} diagnosis
|
|
366
|
-
* @param {object} [ctx]
|
|
367
|
-
* @param {string|null} [ctx.failedTaskId]
|
|
368
|
-
*/
|
|
369
|
-
export function buildAlternatives(diagnosis, ctx = {}) {
|
|
370
|
-
const common = ["spine status --diagnose"];
|
|
371
|
-
|
|
372
|
-
switch (diagnosis) {
|
|
373
|
-
case "limbo_stale":
|
|
374
|
-
return ["spine batch complete --detect-manual-merge", ...common];
|
|
375
|
-
case "completed_manual":
|
|
376
|
-
return ["spine batch complete --detect-manual-merge", "spine batch dismiss", ...common];
|
|
377
|
-
case "needs_retry":
|
|
378
|
-
return ["spine batch abort", "/spine-skip-task", "/spine-resume --force", ...common];
|
|
379
|
-
case "worker_orphaned":
|
|
380
|
-
return ["spine batch abort", "spine batch resume --force", ...common];
|
|
381
|
-
case "engine_orphaned":
|
|
382
|
-
return ctx.failedTaskId
|
|
383
|
-
? [`spine batch retry ${ctx.failedTaskId}`, "spine batch abort", ...common]
|
|
384
|
-
: ["spine batch abort", "spine batch resume --force", ...common];
|
|
385
|
-
case "needs_merge":
|
|
386
|
-
return ["/spine-status --diagnose", ...common];
|
|
387
|
-
case "needs_integrate":
|
|
388
|
-
return ["/spine-integrate", "/spine-gate", ...common];
|
|
389
|
-
case "needs_replan":
|
|
390
|
-
return ctx.failedTaskId
|
|
391
|
-
? [`spine batch skip ${ctx.failedTaskId}`, "spine handoff", ...common]
|
|
392
|
-
: ["spine handoff", ...common];
|
|
393
|
-
case "running":
|
|
394
|
-
return ["/spine-pause", "/spine-abort", ...common];
|
|
395
|
-
case "paused":
|
|
396
|
-
return ["spine batch resume --force", "spine status --diagnose", ...common];
|
|
397
|
-
case "failed":
|
|
398
|
-
return ["/spine-retry-task", ...common];
|
|
399
|
-
default:
|
|
400
|
-
return common;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
471
|
/**
|
|
405
472
|
* @param {string} diagnosis
|
|
406
473
|
*/
|