pi-spine 2.17.0 → 2.19.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-gate.mjs +8 -2
- package/bin/spine-status.mjs +18 -2
- package/package.json +1 -1
- package/skills/create-spine-tasks/references/prompt-template.md +16 -1
- package/src/batch/diagnosis-handoff-packet.mjs +148 -0
- package/src/batch/diagnosis-suggested-command.mjs +177 -0
- package/src/batch/diagnosis-worker-done-missing.mjs +12 -1
- package/src/batch/diagnosis.mjs +12 -168
- package/src/batch/engine-lanes/matrix-run.mjs +122 -26
- package/src/batch/gate.mjs +153 -6
- package/src/batch/heartbeat.mjs +18 -0
- package/src/batch/resume-gate-reopen.mjs +50 -0
- package/src/batch/resume-multi-validate.mjs +43 -0
- package/src/batch/resume-prompt-parse-fail.mjs +75 -0
- package/src/batch/resume.mjs +20 -39
- package/src/batch/salvage-batch-integrate-gate.mjs +180 -0
- package/src/batch/salvage-batch-integrate.mjs +66 -4
- package/src/batch/worker-heartbeat.mjs +31 -6
- package/src/batch/worker-host.mjs +27 -1
- package/src/batch/worker-output.mjs +56 -0
- package/src/cli/handoff.mjs +124 -10
- package/src/cli/issue-draft.mjs +59 -7
- package/src/planner/matrix.mjs +24 -0
- package/templates/agents/supervisor.md +1 -1
- package/templates/tasks/CONTEXT.md +4 -0
package/bin/spine-gate.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* Integrate gate inspection and resolution (PRD §12, FR-GATE).
|
|
4
|
-
* Usage: spine gate [approve|reject|status] [--batch ID] [--reason text] [--json]
|
|
4
|
+
* Usage: spine gate [approve|reject|status|reopen] [--batch ID] [--reason text] [--json]
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { isCliEntrypoint } from "./spine-cli/shared.mjs";
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
approveIntegrateGate,
|
|
11
11
|
getIntegrateGateStatus,
|
|
12
12
|
rejectIntegrateGate,
|
|
13
|
+
reopenIntegrateGateForCompletedBatch,
|
|
13
14
|
} from "../src/batch/gate.mjs";
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -113,13 +114,18 @@ export function runSpineGate(options) {
|
|
|
113
114
|
case "status":
|
|
114
115
|
result = getIntegrateGateStatus({ projectRoot, batchId });
|
|
115
116
|
break;
|
|
117
|
+
case "reopen":
|
|
118
|
+
// SP-740 / #275: re-open + re-approve path for completed batches after
|
|
119
|
+
// stale_revision or a removed gate record.
|
|
120
|
+
result = reopenIntegrateGateForCompletedBatch({ projectRoot, batchId });
|
|
121
|
+
break;
|
|
116
122
|
default:
|
|
117
123
|
result = {
|
|
118
124
|
ok: false,
|
|
119
125
|
exitCode: 1,
|
|
120
126
|
headline: `Unknown gate action: ${action}`,
|
|
121
127
|
suggestedCommand: "spine gate status",
|
|
122
|
-
error: "Use approve, reject, or
|
|
128
|
+
error: "Use approve, reject, status, or reopen",
|
|
123
129
|
};
|
|
124
130
|
}
|
|
125
131
|
|
package/bin/spine-status.mjs
CHANGED
|
@@ -37,8 +37,24 @@ export function runSpineStatus(options) {
|
|
|
37
37
|
lines.push(` Macro phase: ${result.macroPhaseLabel ?? result.macroPhase}`);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
if (diagnose && result.headline != null) {
|
|
41
|
+
// SBAR handoff layout (#278 / SP-745): Situation → Background → Assessment → Recommendation.
|
|
42
|
+
lines.push("", ` Situation: ${result.headline}`);
|
|
43
|
+
if (result.background?.length) {
|
|
44
|
+
lines.push("", " Background:");
|
|
45
|
+
for (const fact of result.background) {
|
|
46
|
+
lines.push(` • ${fact}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (result.assessmentReason) {
|
|
50
|
+
lines.push("", ` Assessment: ${result.diagnosis} — ${result.assessmentReason}`);
|
|
51
|
+
}
|
|
52
|
+
lines.push("");
|
|
53
|
+
lines.push(` Recommendation: ${result.suggestedCommand}`);
|
|
54
|
+
} else {
|
|
55
|
+
lines.push("", ` ${result.headline}`, "");
|
|
56
|
+
lines.push(` → ${result.suggestedCommand}`);
|
|
57
|
+
}
|
|
42
58
|
|
|
43
59
|
if (diagnose && result.mergeFailed) {
|
|
44
60
|
lines.push("");
|
package/package.json
CHANGED
|
@@ -15,8 +15,11 @@ Review Level 0 is ONLY for trivial changes. Most M+ tasks need Level ≥1.
|
|
|
15
15
|
|
|
16
16
|
## Review Level: [0-3] ([None | Plan Only | Plan and Code | Full])
|
|
17
17
|
|
|
18
|
-
**
|
|
18
|
+
**Risk:** [1-2 sentences: severity/blast radius — what breaks and how far the change reaches]
|
|
19
19
|
**Score:** [N]/8 — Blast radius: [N], Pattern novelty: [N], Security: [N], Reversibility: [N]
|
|
20
|
+
**Problem theory:** [Optional, bug-fix tasks — working diagnosis: why the fault occurs and why this change resolves it]
|
|
21
|
+
|
|
22
|
+
> **Assessment disambiguation ([#281](https://github.com/beettlle/pi-spine/issues/281)):** Use `**Risk:**` for severity/blast (pairs with **Score**) and `**Problem theory:**` for the working diagnosis. Legacy `**Assessment:**` alone remains accepted by tooling and validators — do not mass-rewrite historical packets.
|
|
20
23
|
|
|
21
24
|
> **Real-pi batches (SP-195/SP-278):** Do **not** add per-step "Call `spine_review_step`" checkboxes for Review Level ≥ 1. The batch engine runs plan, code, and final reviews after worker `.DONE`. Stub batches (`SPINE_WORKER_STUB=1`) may still use in-worker stub plan review via the tool when a checkpoint marker requires it.
|
|
22
25
|
|
|
@@ -180,6 +183,18 @@ for this task MUST include the task ID for traceability:
|
|
|
180
183
|
|
|
181
184
|
---
|
|
182
185
|
|
|
186
|
+
## Example — Review Level block fields ([#281](https://github.com/beettlle/pi-spine/issues/281))
|
|
187
|
+
|
|
188
|
+
Use unambiguous field names: `**Risk:**` for severity/blast (pairs with **Score**), `**Problem theory:**` for the working diagnosis. Legacy `**Assessment:**` alone remains valid — do not mass-rewrite historical packets.
|
|
189
|
+
|
|
190
|
+
```markdown
|
|
191
|
+
**Risk:** Docs and templates only; no runtime code paths touched.
|
|
192
|
+
**Score:** 1/8 — Blast radius: 1, Pattern novelty: 0, Security: 0, Reversibility: 0
|
|
193
|
+
**Problem theory:** The `Assessment` field was overloaded — packets used it for score blurbs and fault theories interchangeably, so workers could not tell severity from diagnosis.
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
183
198
|
# STATUS.md Template
|
|
184
199
|
|
|
185
200
|
Create alongside PROMPT.md. If omitted, the execution engine may auto-generate
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* Diagnose handoff packet fields (#278 / SP-745) — SBAR Background + Assessment rationale.
|
|
4
|
+
* Kept out of diagnosis.mjs so the parent stays under the phase23 LOC cap.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* SBAR Background — short decision-relevant facts that explain the state the
|
|
9
|
+
* assessment was derived from. Facts are additive; consumers that ignore
|
|
10
|
+
* unknown fields keep working.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} diagnosis
|
|
13
|
+
* @param {object} ctx
|
|
14
|
+
* @returns {string[]}
|
|
15
|
+
*/
|
|
16
|
+
export function buildBackground(diagnosis, ctx = {}) {
|
|
17
|
+
const facts = [];
|
|
18
|
+
if (ctx.batchId) {
|
|
19
|
+
facts.push(`Batch: ${ctx.batchId}`);
|
|
20
|
+
}
|
|
21
|
+
if (ctx.phase || ctx.macroPhase) {
|
|
22
|
+
facts.push(`Phase: ${ctx.phase ?? "unknown"}${ctx.macroPhase ? ` (macro: ${ctx.macroPhase})` : ""}`);
|
|
23
|
+
}
|
|
24
|
+
if (ctx.totalTasks != null) {
|
|
25
|
+
const progressBits = [`${ctx.succeededTasks ?? 0}/${ctx.totalTasks} tasks succeeded`];
|
|
26
|
+
if (ctx.failedTasks) progressBits.push(`${ctx.failedTasks} failed`);
|
|
27
|
+
if (ctx.pendingTaskCount) progressBits.push(`${ctx.pendingTaskCount} pending`);
|
|
28
|
+
facts.push(`Progress: ${progressBits.join(", ")}`);
|
|
29
|
+
}
|
|
30
|
+
if (ctx.failedTaskId) {
|
|
31
|
+
facts.push(
|
|
32
|
+
`Failed task: ${ctx.failedTaskId}${ctx.exitReason ? ` (exit: ${ctx.exitReason})` : ""}`,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
if (ctx.launchFailureKind) {
|
|
36
|
+
facts.push(`Launch failure kind: ${ctx.launchFailureKind}`);
|
|
37
|
+
}
|
|
38
|
+
if (ctx.engineStillRunning === true && ctx.enginePid != null) {
|
|
39
|
+
facts.push(`Engine PID ${ctx.enginePid} is still running`);
|
|
40
|
+
}
|
|
41
|
+
if (ctx.staleEnginePid === true && ctx.enginePid != null) {
|
|
42
|
+
facts.push(`Engine PID ${ctx.enginePid} is stale (process not alive)`);
|
|
43
|
+
}
|
|
44
|
+
if (ctx.engineOrphanCause) {
|
|
45
|
+
facts.push(`Engine orphan cause: ${ctx.engineOrphanCause}`);
|
|
46
|
+
}
|
|
47
|
+
if (ctx.mergeFailed) {
|
|
48
|
+
facts.push(
|
|
49
|
+
`Lane merge failed${ctx.failedWaveIndex != null ? ` (wave index ${ctx.failedWaveIndex})` : ""}`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
if (ctx.gitMerged === true) {
|
|
53
|
+
facts.push(`Orch branch already merged to ${ctx.baseBranch ?? "base"}`);
|
|
54
|
+
}
|
|
55
|
+
if (ctx.integrateGateOpen === true) {
|
|
56
|
+
facts.push("Integrate gate is open");
|
|
57
|
+
}
|
|
58
|
+
if (ctx.salvageRetryCommand) {
|
|
59
|
+
facts.push(`Tried: ${ctx.salvageRetryCommand}`);
|
|
60
|
+
}
|
|
61
|
+
if (Array.isArray(ctx.journalHints)) {
|
|
62
|
+
for (const hint of ctx.journalHints) {
|
|
63
|
+
if (typeof hint === "string") {
|
|
64
|
+
facts.push(`Journal: ${hint}`);
|
|
65
|
+
} else if (hint && typeof hint === "object" && (hint.summary || hint.type)) {
|
|
66
|
+
facts.push(`Journal: ${hint.type ?? "event"}${hint.summary ? ` — ${hint.summary}` : ""}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return facts;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* SBAR Assessment rationale — why this diagnosis enum was selected from
|
|
75
|
+
* reconcile signals, not just its label.
|
|
76
|
+
*
|
|
77
|
+
* @param {string} diagnosis
|
|
78
|
+
* @param {object} ctx
|
|
79
|
+
* @returns {string}
|
|
80
|
+
*/
|
|
81
|
+
export function buildAssessmentReason(diagnosis, ctx = {}) {
|
|
82
|
+
switch (diagnosis) {
|
|
83
|
+
case "engine_still_running":
|
|
84
|
+
return `Engine PID ${ctx.enginePid ?? "?"} is alive, so completion was refused to avoid clobbering an active run`;
|
|
85
|
+
case "limbo_stale":
|
|
86
|
+
return "Batch ended but state is stale and no engine or worker is active — only a dismiss can clear it";
|
|
87
|
+
case "completed_manual":
|
|
88
|
+
return "Work is already on the base branch while the batch record is still active — operator completed it manually";
|
|
89
|
+
case "needs_retry":
|
|
90
|
+
if (ctx.failedTaskId && ctx.exitReason) {
|
|
91
|
+
return `Task ${ctx.failedTaskId} exited "${ctx.exitReason}" without completing its contract, so the batch cannot proceed until it is retried`;
|
|
92
|
+
}
|
|
93
|
+
if (ctx.failedTaskId) {
|
|
94
|
+
return `Worker for task ${ctx.failedTaskId} died before writing .DONE, so the batch cannot proceed until it is retried`;
|
|
95
|
+
}
|
|
96
|
+
return "Failed phase left only pending tasks with no live workers — retry limbo resolves as a retry";
|
|
97
|
+
case "state_drift":
|
|
98
|
+
return ctx.failedTaskId
|
|
99
|
+
? `Journal history for task ${ctx.failedTaskId} disagrees with the batch-state cache — no single source of truth`
|
|
100
|
+
: "Journal history disagrees with the batch-state cache — no single source of truth";
|
|
101
|
+
case "worker_orphaned":
|
|
102
|
+
if (ctx.engineDead) {
|
|
103
|
+
return `Engine and lane worker both died while task ${ctx.failedTaskId ?? "?"} was still running`;
|
|
104
|
+
}
|
|
105
|
+
if (ctx.ghostRunningCluster) {
|
|
106
|
+
return `Lane worker died but multiple tasks are still marked running (ghost running cluster)${ctx.failedTaskId ? `, e.g. ${ctx.failedTaskId}` : ""}`;
|
|
107
|
+
}
|
|
108
|
+
return `Lane worker stopped while task ${ctx.failedTaskId ?? "?"} was still marked running — heartbeats ended without a terminal journal event`;
|
|
109
|
+
case "worker_done_missing":
|
|
110
|
+
return `Task ${ctx.failedTaskId ?? "?"} reported progress in the journal but no .DONE file was found in the lane or batch tasks root`;
|
|
111
|
+
case "engine_orphaned":
|
|
112
|
+
if (ctx.engineOrphanCause) {
|
|
113
|
+
return `Engine process is gone (${ctx.engineOrphanCause}) while tasks were still running`;
|
|
114
|
+
}
|
|
115
|
+
return `Engine process died mid-run${ctx.failedTaskId ? ` with task ${ctx.failedTaskId} still running` : ""} — journal has no engine shutdown event`;
|
|
116
|
+
case "needs_merge":
|
|
117
|
+
return "All assigned tasks finished in their lanes, but lane merges into the orch branch are still pending";
|
|
118
|
+
case "needs_integrate":
|
|
119
|
+
if (ctx.integrateGateOpen) {
|
|
120
|
+
return "Land loop is paused at the integrate gate with the gate open — approval continues the land";
|
|
121
|
+
}
|
|
122
|
+
return `Tasks are terminal-success and merged to the orch branch, which is not yet integrated into ${ctx.baseBranch ?? "base"}`;
|
|
123
|
+
case "needs_replan":
|
|
124
|
+
return ctx.failedTaskId
|
|
125
|
+
? `Task ${ctx.failedTaskId} failed in a way that requires a contract (PROMPT.md) change, not just a retry`
|
|
126
|
+
: "Failed tasks require a contract (PROMPT.md) change, not just a retry";
|
|
127
|
+
case "running":
|
|
128
|
+
return "Engine and workers are alive with no failure, drift, or orphan signals observed";
|
|
129
|
+
case "paused":
|
|
130
|
+
return `Batch was paused by an operator or gate with ${ctx.pendingTaskCount ?? 0} task(s) pending — resume continues from journal state`;
|
|
131
|
+
case "failed":
|
|
132
|
+
return `Batch recorded failure in phase ${ctx.phase ?? "unknown"} (${ctx.failedTasks ?? 0} failed task(s)) with no recoverable retry path`;
|
|
133
|
+
case "aborted":
|
|
134
|
+
return "Batch was aborted by an operator; state remains for audit";
|
|
135
|
+
case "completed":
|
|
136
|
+
return `All tasks succeeded and the orch branch landed on ${ctx.baseBranch ?? "base"}`;
|
|
137
|
+
case "human_base_diverged": {
|
|
138
|
+
const overlapCount = Array.isArray(ctx.overlapPaths) ? ctx.overlapPaths.length : 0;
|
|
139
|
+
return `Human commits on ${ctx.baseBranch ?? "base"} overlap orch land${overlapCount > 0 ? ` (${overlapCount} path(s))` : ""} — reconciliation needs a human sync decision`;
|
|
140
|
+
}
|
|
141
|
+
case "integrate_isolated_ok":
|
|
142
|
+
return "Isolated integrate landed cleanly; the human checkout only needs a sync with base";
|
|
143
|
+
case "pending_lane_land":
|
|
144
|
+
return "Done-in-lane work is sitting in lane worktrees waiting to be landed";
|
|
145
|
+
default:
|
|
146
|
+
return `Reconcile signals selected "${diagnosis}" for phase ${ctx.phase ?? "unknown"}`;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* Operator suggestedCommand builders — extracted from diagnosis.mjs for phase23 LOC.
|
|
4
|
+
*/
|
|
5
|
+
import { buildWorkerDoneMissingSuggestedCommand } from "./diagnosis-worker-done-missing.mjs";
|
|
6
|
+
import {
|
|
7
|
+
buildFailedPhasePendingOnlySuggestedCommand,
|
|
8
|
+
isFailedPhasePendingOnlyLimbo,
|
|
9
|
+
} from "./diagnosis-retry-limbo.mjs";
|
|
10
|
+
import {
|
|
11
|
+
buildGitignoredMergeRepairCommand,
|
|
12
|
+
shouldPreferPrimaryOverGitignoredHeadline,
|
|
13
|
+
} from "./diagnosis-merge-failure.mjs";
|
|
14
|
+
import {
|
|
15
|
+
buildStubFailureSuggestedCommand,
|
|
16
|
+
STUB_EXIT_REASONS,
|
|
17
|
+
} from "./diagnosis-stub.mjs";
|
|
18
|
+
import { buildPrimaryFailureSuggestedCommand } from "./diagnosis-primary-failure.mjs";
|
|
19
|
+
import { buildEngineOrphanParentExitSuggestedCommand } from "./diagnosis-parent-exit.mjs";
|
|
20
|
+
import { sanitizeRetrySuggestedCommand } from "./diagnosis-retry-command.mjs";
|
|
21
|
+
import { buildPendingLaneLandSuggestedCommand } from "./diagnosis-pending-lane.mjs";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} diagnosis
|
|
25
|
+
* @param {object} [ctx]
|
|
26
|
+
* @param {string|null} [ctx.failedTaskId]
|
|
27
|
+
* @param {string|null} [ctx.batchId]
|
|
28
|
+
* @param {string|null} [ctx.salvageRetryCommand]
|
|
29
|
+
* @param {string|null} [ctx.exitReason]
|
|
30
|
+
* @param {string|null} [ctx.launchFailureKind]
|
|
31
|
+
* @param {boolean} [ctx.mergeGitignoredFailure]
|
|
32
|
+
* @param {boolean} [ctx.mergeFailed]
|
|
33
|
+
* @param {string|null} [ctx.taskBranch]
|
|
34
|
+
* @param {string[]|null} [ctx.gitignoredPaths]
|
|
35
|
+
* @param {object[]} [ctx.pendingLaneLandTasks]
|
|
36
|
+
*/
|
|
37
|
+
export function buildSuggestedCommand(diagnosis, ctx = {}) {
|
|
38
|
+
const preferPrimaryOverGitignored = shouldPreferPrimaryOverGitignoredHeadline(diagnosis, ctx);
|
|
39
|
+
// Prefer gate-approve / orphan primary over recovered merge/gitignored repair (#195 / #205).
|
|
40
|
+
if (ctx.mergeGitignoredFailure && !preferPrimaryOverGitignored) {
|
|
41
|
+
return buildGitignoredMergeRepairCommand(ctx.taskBranch, ctx.gitignoredPaths);
|
|
42
|
+
}
|
|
43
|
+
if (
|
|
44
|
+
ctx.mergeFailed &&
|
|
45
|
+
!preferPrimaryOverGitignored &&
|
|
46
|
+
(diagnosis === "failed" || diagnosis === "needs_retry")
|
|
47
|
+
) {
|
|
48
|
+
return "spine batch resume --force";
|
|
49
|
+
}
|
|
50
|
+
if (ctx.phase === "merge_blocked") {
|
|
51
|
+
return "spine batch resume --force";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
switch (diagnosis) {
|
|
55
|
+
case "engine_still_running":
|
|
56
|
+
return "spine wait --until completed,failed,needs_integrate --timeout 2h";
|
|
57
|
+
case "limbo_stale":
|
|
58
|
+
case "completed_manual":
|
|
59
|
+
return "spine batch dismiss";
|
|
60
|
+
case "state_drift":
|
|
61
|
+
// Agent-safe detached recovery (#196 / SP-613) — never suggest --attached.
|
|
62
|
+
if (
|
|
63
|
+
ctx.phase === "running" ||
|
|
64
|
+
ctx.staleEnginePid === true ||
|
|
65
|
+
ctx.engineDead === true ||
|
|
66
|
+
ctx.allTasksTerminalSuccess === true
|
|
67
|
+
) {
|
|
68
|
+
return "spine batch resume --force";
|
|
69
|
+
}
|
|
70
|
+
if (ctx.failedTaskId) {
|
|
71
|
+
const driftStatus = String(ctx.driftTaskStatus ?? "").toLowerCase();
|
|
72
|
+
if (driftStatus === "running") {
|
|
73
|
+
return "spine batch resume --force";
|
|
74
|
+
}
|
|
75
|
+
return `spine batch retry ${ctx.failedTaskId}`;
|
|
76
|
+
}
|
|
77
|
+
return "spine status --diagnose";
|
|
78
|
+
case "needs_retry":
|
|
79
|
+
if (STUB_EXIT_REASONS.has(ctx.exitReason ?? "")) {
|
|
80
|
+
return buildStubFailureSuggestedCommand(ctx);
|
|
81
|
+
}
|
|
82
|
+
const primaryCommand = buildPrimaryFailureSuggestedCommand(ctx);
|
|
83
|
+
if (primaryCommand) return primaryCommand;
|
|
84
|
+
if (ctx.launchFailureKind === "pi_spine_root" || ctx.launchFailureKind === "launch_failed") {
|
|
85
|
+
return "spine doctor";
|
|
86
|
+
}
|
|
87
|
+
if (ctx.launchFailureKind === "worktree_unhealthy") {
|
|
88
|
+
return "spine doctor";
|
|
89
|
+
}
|
|
90
|
+
if (ctx.salvageRetryCommand) {
|
|
91
|
+
return sanitizeRetrySuggestedCommand(ctx.salvageRetryCommand, ctx.failedTaskId);
|
|
92
|
+
}
|
|
93
|
+
if (isFailedPhasePendingOnlyLimbo(ctx)) {
|
|
94
|
+
return buildFailedPhasePendingOnlySuggestedCommand(ctx);
|
|
95
|
+
}
|
|
96
|
+
return ctx.failedTaskId
|
|
97
|
+
? `spine batch retry ${ctx.failedTaskId}`
|
|
98
|
+
: "spine status --diagnose";
|
|
99
|
+
case "worker_orphaned":
|
|
100
|
+
if (ctx.planReviewNestedSpawnBlocked) {
|
|
101
|
+
if (ctx.stalePathSpine) {
|
|
102
|
+
return ctx.failedTaskId
|
|
103
|
+
? `node bin/spine.mjs batch retry ${ctx.failedTaskId}`
|
|
104
|
+
: "npm link && spine batch resume --attached";
|
|
105
|
+
}
|
|
106
|
+
if (ctx.failedTaskId) {
|
|
107
|
+
return `spine batch retry ${ctx.failedTaskId}`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (ctx.engineDead) {
|
|
111
|
+
return "spine batch resume --attached --force";
|
|
112
|
+
}
|
|
113
|
+
if (ctx.ghostRunningCluster) return "spine batch abort";
|
|
114
|
+
if (ctx.launchFailureKind === "pi_spine_root" || ctx.launchFailureKind === "launch_failed") {
|
|
115
|
+
return "spine doctor";
|
|
116
|
+
}
|
|
117
|
+
if (ctx.launchFailureKind === "worktree_unhealthy") {
|
|
118
|
+
return "spine doctor";
|
|
119
|
+
}
|
|
120
|
+
if (ctx.salvageRetryCommand) {
|
|
121
|
+
return sanitizeRetrySuggestedCommand(ctx.salvageRetryCommand, ctx.failedTaskId);
|
|
122
|
+
}
|
|
123
|
+
return ctx.failedTaskId
|
|
124
|
+
? `spine batch retry ${ctx.failedTaskId}`
|
|
125
|
+
: "spine batch abort";
|
|
126
|
+
case "worker_done_missing":
|
|
127
|
+
return buildWorkerDoneMissingSuggestedCommand(ctx);
|
|
128
|
+
case "engine_orphaned": {
|
|
129
|
+
const parentExitCommand = buildEngineOrphanParentExitSuggestedCommand(ctx);
|
|
130
|
+
if (parentExitCommand) return parentExitCommand;
|
|
131
|
+
// Terminal-success / doneInLane heal with dead engine — detached resume (#196 / #163).
|
|
132
|
+
if (ctx.allTasksTerminalSuccess === true) {
|
|
133
|
+
return "spine batch resume --force";
|
|
134
|
+
}
|
|
135
|
+
return ctx.failedTaskId
|
|
136
|
+
? `spine batch retry ${ctx.failedTaskId}`
|
|
137
|
+
: "spine batch resume --attached";
|
|
138
|
+
}
|
|
139
|
+
case "needs_merge":
|
|
140
|
+
return "spine batch resume --force";
|
|
141
|
+
case "needs_integrate":
|
|
142
|
+
if (ctx.integrateGateOpen) {
|
|
143
|
+
return "spine gate approve";
|
|
144
|
+
}
|
|
145
|
+
if (ctx.postMergeLimbo && ctx.phase === "running") {
|
|
146
|
+
if (ctx.stalePathSpine) {
|
|
147
|
+
return "node bin/spine.mjs batch resume --attached";
|
|
148
|
+
}
|
|
149
|
+
return "spine batch resume --force";
|
|
150
|
+
}
|
|
151
|
+
return "spine integrate";
|
|
152
|
+
case "needs_replan": {
|
|
153
|
+
const tasksRoot = ctx.tasksRoot ?? "spine-tasks";
|
|
154
|
+
return ctx.failedTaskId
|
|
155
|
+
? `edit ${tasksRoot}/${ctx.failedTaskId}/PROMPT.md then spine batch retry ${ctx.failedTaskId}`
|
|
156
|
+
: "spine status --diagnose";
|
|
157
|
+
}
|
|
158
|
+
case "running":
|
|
159
|
+
return "/spine-status --diagnose";
|
|
160
|
+
case "paused":
|
|
161
|
+
return "spine batch resume";
|
|
162
|
+
case "failed":
|
|
163
|
+
return "spine status --diagnose";
|
|
164
|
+
case "aborted":
|
|
165
|
+
return "spine batch dismiss";
|
|
166
|
+
case "completed":
|
|
167
|
+
return "spine preflight";
|
|
168
|
+
case "human_base_diverged":
|
|
169
|
+
return "spine sync-base";
|
|
170
|
+
case "integrate_isolated_ok":
|
|
171
|
+
return "spine sync-base";
|
|
172
|
+
case "pending_lane_land":
|
|
173
|
+
return buildPendingLaneLandSuggestedCommand(ctx.batchId, ctx.pendingLaneLandTasks ?? []);
|
|
174
|
+
default:
|
|
175
|
+
return "spine status --diagnose";
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
* Worker exited without `.DONE` diagnosis helpers (SP-313 / issue #18).
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import {
|
|
7
|
+
BACKGROUND_VERIFICATION_HINT,
|
|
8
|
+
detectBackgroundedVerification,
|
|
9
|
+
} from "./worker-output.mjs";
|
|
10
|
+
|
|
6
11
|
/** Worker exited cleanly but never wrote `.DONE`. */
|
|
7
12
|
export const WORKER_DONE_MISSING_OUTPUT_MARKERS = [
|
|
8
13
|
"pi exited but .DONE was not created",
|
|
@@ -81,7 +86,13 @@ export function buildWorkerDoneMissingHeadline(batchLabel, ctx = {}) {
|
|
|
81
86
|
: ctx.workerOutputSnippet
|
|
82
87
|
? `: ${ctx.workerOutputSnippet}`
|
|
83
88
|
: "";
|
|
84
|
-
|
|
89
|
+
// SP-741 (#276): point operators at the backgrounded-verification cause when
|
|
90
|
+
// the captured output shows the worker exited mid-verification.
|
|
91
|
+
const hintInput = [tail, ctx.workerOutputSnippet, ctx.output].filter(Boolean).join("\n");
|
|
92
|
+
const backgroundHint = detectBackgroundedVerification(hintInput)
|
|
93
|
+
? ` — ${BACKGROUND_VERIFICATION_HINT}`
|
|
94
|
+
: "";
|
|
95
|
+
return `${batchLabel} ${taskLabel} exited without .DONE${fileHint}${logHint}${tailHint}${backgroundHint}`;
|
|
85
96
|
}
|
|
86
97
|
|
|
87
98
|
/** @param {object} ctx */
|