pi-spine 1.3.0 → 1.5.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-cli/verify.mjs +3 -0
- package/bin/spine-deps.mjs +0 -2
- package/bin/spine-rules.mjs +0 -2
- package/bin/spine-settings.mjs +0 -2
- package/bin/spine.mjs +2 -5
- package/package.json +2 -2
- package/skills/create-spine-tasks/SKILL.md +13 -1
- package/skills/create-spine-tasks/references/contract-template.md +6 -3
- package/skills/create-spine-tasks/references/requirements-checklist-template.md +1 -0
- package/src/batch/attached-engine-handoff.mjs +0 -1
- package/src/batch/attached-runner.mjs +1 -1
- package/src/batch/contract-verify.mjs +133 -14
- package/src/batch/diagnosis-retry-limbo.mjs +1 -1
- package/src/batch/diagnosis.mjs +0 -1
- package/src/batch/engine-lanes/commit.mjs +6 -0
- package/src/batch/engine-lanes/merge.mjs +1 -2
- package/src/batch/engine-lanes/review.mjs +57 -34
- package/src/batch/engine-lanes.mjs +0 -2
- package/src/batch/engine.mjs +0 -1
- package/src/batch/evidence.mjs +1 -2
- package/src/batch/git-exec.mjs +5 -2
- package/src/batch/journal-rebuild.mjs +110 -1
- package/src/batch/lane-commit.mjs +6 -5
- package/src/batch/lane-dirty-check.mjs +196 -1
- package/src/batch/reconcile.mjs +0 -1
- package/src/batch/resume-multi.mjs +1 -1
- package/src/batch/resume.mjs +0 -3
- package/src/batch/review-spawn.mjs +1 -1
- package/src/batch/review.mjs +0 -4
- package/src/batch/sequence-waves.mjs +221 -0
- package/src/batch/sequence.mjs +117 -4
- package/src/batch/worker-host.mjs +13 -5
- package/src/cli/deps.mjs +0 -2
- package/src/config/contract.mjs +10 -0
- package/src/dashboard/public/dashboard.css +8 -0
- package/src/dashboard/public/dashboard.js +22 -6
- package/src/dashboard/snapshot.mjs +0 -1
- package/src/tasks/packet/validate-prompt.mjs +0 -1
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planner sequence wave policy after merge_blocked (GitHub #82, SP-437).
|
|
3
|
+
* Evaluates whether later waves can run per dependencies.json / plan.tasks deps.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {object|null|undefined} batchState
|
|
8
|
+
* @returns {{ succeeded: string[], failed: string[], skipped: string[], pending: string[] }}
|
|
9
|
+
*/
|
|
10
|
+
export function collectWaveTaskOutcomes(batchState) {
|
|
11
|
+
const tasks = batchState?.tasks ?? [];
|
|
12
|
+
/** @type {string[]} */
|
|
13
|
+
const succeeded = [];
|
|
14
|
+
/** @type {string[]} */
|
|
15
|
+
const failed = [];
|
|
16
|
+
/** @type {string[]} */
|
|
17
|
+
const skipped = [];
|
|
18
|
+
/** @type {string[]} */
|
|
19
|
+
const pending = [];
|
|
20
|
+
|
|
21
|
+
for (const task of tasks) {
|
|
22
|
+
const taskId = String(task?.taskId ?? "");
|
|
23
|
+
if (!taskId) continue;
|
|
24
|
+
const status = String(task?.status ?? "");
|
|
25
|
+
if (status === "succeeded") succeeded.push(taskId);
|
|
26
|
+
else if (status === "failed") failed.push(taskId);
|
|
27
|
+
else if (status === "skipped") skipped.push(taskId);
|
|
28
|
+
else if (status === "pending" || status === "running") pending.push(taskId);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return { succeeded, failed, skipped, pending };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {object} [params]
|
|
36
|
+
* @param {object|null} [params.startResult]
|
|
37
|
+
* @param {object|null} [params.reconciliation]
|
|
38
|
+
*/
|
|
39
|
+
export function isMergeBlockedBatchOutcome({ startResult = null, reconciliation = null } = {}) {
|
|
40
|
+
if (startResult?.error === "mixed_outcome_merge_blocked") return true;
|
|
41
|
+
const phase = reconciliation?.phase ?? reconciliation?.signals?.raw?.phase ?? null;
|
|
42
|
+
if (phase === "merge_blocked") return true;
|
|
43
|
+
const lastError = String(reconciliation?.signals?.raw?.lastError ?? "");
|
|
44
|
+
if (phase === "failed" && lastError.includes("§17.4")) return true;
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {Iterable<string>} doneOnMainTaskIds
|
|
50
|
+
* @param {Array<{ succeeded?: string[], skipped?: string[] }>} priorOutcomes
|
|
51
|
+
*/
|
|
52
|
+
export function buildSequenceSatisfiedTaskIds(doneOnMainTaskIds = [], priorOutcomes = []) {
|
|
53
|
+
const satisfied = new Set(doneOnMainTaskIds);
|
|
54
|
+
for (const outcome of priorOutcomes) {
|
|
55
|
+
for (const taskId of outcome.succeeded ?? []) satisfied.add(taskId);
|
|
56
|
+
for (const taskId of outcome.skipped ?? []) satisfied.add(taskId);
|
|
57
|
+
}
|
|
58
|
+
return satisfied;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {object} params
|
|
63
|
+
* @param {object} params.plan
|
|
64
|
+
* @param {string[]} params.waveTaskIds
|
|
65
|
+
* @param {Set<string>} params.satisfiedTaskIds
|
|
66
|
+
*/
|
|
67
|
+
export function evaluateWaveTaskDependencies({ plan, waveTaskIds, satisfiedTaskIds }) {
|
|
68
|
+
const tasks = plan?.tasks ?? {};
|
|
69
|
+
/** @type {string[]} */
|
|
70
|
+
const runnable = [];
|
|
71
|
+
/** @type {Array<{ taskId: string, unsatisfiedDeps: string[] }>} */
|
|
72
|
+
const blocked = [];
|
|
73
|
+
|
|
74
|
+
for (const taskId of waveTaskIds) {
|
|
75
|
+
const deps = tasks[taskId]?.dependencies ?? [];
|
|
76
|
+
const unsatisfiedDeps = deps.filter((depId) => !satisfiedTaskIds.has(depId));
|
|
77
|
+
if (unsatisfiedDeps.length === 0) {
|
|
78
|
+
runnable.push(taskId);
|
|
79
|
+
} else {
|
|
80
|
+
blocked.push({ taskId, unsatisfiedDeps });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return { runnable, blocked };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @param {object} params
|
|
89
|
+
* @param {number} params.waveIndex
|
|
90
|
+
* @param {Array<{ taskId: string, unsatisfiedDeps: string[] }>} params.blocked
|
|
91
|
+
* @param {number} params.mergeBlockedWaveIndex
|
|
92
|
+
* @param {string[]} [params.failedTaskIds]
|
|
93
|
+
* @param {string[]} [params.succeededTaskIds]
|
|
94
|
+
*/
|
|
95
|
+
export function formatSequenceWaveSkipMessage({
|
|
96
|
+
waveIndex,
|
|
97
|
+
blocked,
|
|
98
|
+
mergeBlockedWaveIndex,
|
|
99
|
+
failedTaskIds = [],
|
|
100
|
+
succeededTaskIds = [],
|
|
101
|
+
}) {
|
|
102
|
+
const lines = [
|
|
103
|
+
`Sequence wave ${waveIndex} skipped (§17.4 mixed-outcome policy — wave ${mergeBlockedWaveIndex} merge blocked).`,
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
if (succeededTaskIds.length > 0) {
|
|
107
|
+
lines.push(`Prior wave succeeded task(s): ${succeededTaskIds.join(", ")}.`);
|
|
108
|
+
}
|
|
109
|
+
if (failedTaskIds.length > 0) {
|
|
110
|
+
lines.push(`Prior wave failed task(s): ${failedTaskIds.join(", ")}.`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
for (const entry of blocked) {
|
|
114
|
+
lines.push(
|
|
115
|
+
` ${entry.taskId}: blocked by unsatisfied dependencies ${entry.unsatisfiedDeps.join(", ")}.`,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (blocked.length === 0) {
|
|
120
|
+
lines.push(` No runnable tasks in wave ${waveIndex}.`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
lines.push(
|
|
124
|
+
"Retry or skip failed tasks on the blocked wave, or land succeeded lanes before dependencies unblock.",
|
|
125
|
+
);
|
|
126
|
+
return lines.join("\n");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @param {object} params
|
|
131
|
+
* @param {object} params.plan
|
|
132
|
+
* @param {number} params.waveIndex
|
|
133
|
+
* @param {string[]} params.waveTaskIds
|
|
134
|
+
* @param {Set<string>} params.satisfiedTaskIds
|
|
135
|
+
* @param {number} params.mergeBlockedWaveIndex
|
|
136
|
+
* @param {string[]} [params.failedTaskIds]
|
|
137
|
+
* @param {string[]} [params.succeededTaskIds]
|
|
138
|
+
*/
|
|
139
|
+
export function resolveWaveAfterMergeBlocked({
|
|
140
|
+
plan,
|
|
141
|
+
waveIndex,
|
|
142
|
+
waveTaskIds,
|
|
143
|
+
satisfiedTaskIds,
|
|
144
|
+
mergeBlockedWaveIndex,
|
|
145
|
+
failedTaskIds = [],
|
|
146
|
+
succeededTaskIds = [],
|
|
147
|
+
}) {
|
|
148
|
+
const { runnable, blocked } = evaluateWaveTaskDependencies({
|
|
149
|
+
plan,
|
|
150
|
+
waveTaskIds,
|
|
151
|
+
satisfiedTaskIds,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (runnable.length === 0) {
|
|
155
|
+
return {
|
|
156
|
+
action: "skip",
|
|
157
|
+
runnableTaskIds: [],
|
|
158
|
+
blocked,
|
|
159
|
+
message: formatSequenceWaveSkipMessage({
|
|
160
|
+
waveIndex,
|
|
161
|
+
blocked,
|
|
162
|
+
mergeBlockedWaveIndex,
|
|
163
|
+
failedTaskIds,
|
|
164
|
+
succeededTaskIds,
|
|
165
|
+
}),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
action: "continue",
|
|
171
|
+
runnableTaskIds: runnable,
|
|
172
|
+
blocked,
|
|
173
|
+
skippedTaskIds: blocked.map((entry) => entry.taskId),
|
|
174
|
+
message:
|
|
175
|
+
blocked.length > 0
|
|
176
|
+
? formatSequenceWaveSkipMessage({
|
|
177
|
+
waveIndex,
|
|
178
|
+
blocked,
|
|
179
|
+
mergeBlockedWaveIndex,
|
|
180
|
+
failedTaskIds,
|
|
181
|
+
succeededTaskIds,
|
|
182
|
+
})
|
|
183
|
+
: null,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @param {object} params
|
|
189
|
+
* @param {object} params.plan
|
|
190
|
+
* @param {number} params.waveIndex
|
|
191
|
+
* @param {string[]} params.waveTaskIds
|
|
192
|
+
* @param {Set<string>} params.satisfiedTaskIds
|
|
193
|
+
*/
|
|
194
|
+
export function planSequenceWaveTasks({ plan, waveIndex, waveTaskIds, satisfiedTaskIds }) {
|
|
195
|
+
const { runnable, blocked } = evaluateWaveTaskDependencies({
|
|
196
|
+
plan,
|
|
197
|
+
waveTaskIds,
|
|
198
|
+
satisfiedTaskIds,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
if (runnable.length === 0) {
|
|
202
|
+
return {
|
|
203
|
+
action: "skip",
|
|
204
|
+
runnableTaskIds: [],
|
|
205
|
+
blocked,
|
|
206
|
+
message: `Sequence wave ${waveIndex} skipped — no tasks with satisfied dependencies.`,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return {
|
|
211
|
+
action: "continue",
|
|
212
|
+
runnableTaskIds: runnable,
|
|
213
|
+
blocked,
|
|
214
|
+
partialSkipMessage:
|
|
215
|
+
blocked.length > 0
|
|
216
|
+
? `Sequence wave ${waveIndex}: skipping tasks with unsatisfied dependencies: ${blocked
|
|
217
|
+
.map((entry) => entry.taskId)
|
|
218
|
+
.join(", ")}.`
|
|
219
|
+
: null,
|
|
220
|
+
};
|
|
221
|
+
}
|
package/src/batch/sequence.mjs
CHANGED
|
@@ -9,8 +9,10 @@ import {
|
|
|
9
9
|
runBatchPreflight,
|
|
10
10
|
resolveTasksRoot,
|
|
11
11
|
} from "../config/spine-preflight-lib.mjs";
|
|
12
|
+
import { filterPendingTaskIds } from "../planner/pending.mjs";
|
|
12
13
|
import { buildPlan } from "../planner/index.mjs";
|
|
13
14
|
import { resolveWaveTaskIds } from "../planner/wave-scope.mjs";
|
|
15
|
+
import { discoverTasks } from "../tasks/packet/discover.mjs";
|
|
14
16
|
|
|
15
17
|
export { resolveWaveTaskIds };
|
|
16
18
|
import { startBatch } from "./engine.mjs";
|
|
@@ -22,6 +24,13 @@ import { completeBatch } from "./lifecycle.mjs";
|
|
|
22
24
|
import { reconcileBatch } from "./reconcile.mjs";
|
|
23
25
|
import { loadSpineBatchState } from "./state.mjs";
|
|
24
26
|
import { validateSequenceAutoApproveGate } from "../doctor/sequence-safety.mjs";
|
|
27
|
+
import {
|
|
28
|
+
buildSequenceSatisfiedTaskIds,
|
|
29
|
+
collectWaveTaskOutcomes,
|
|
30
|
+
isMergeBlockedBatchOutcome,
|
|
31
|
+
planSequenceWaveTasks,
|
|
32
|
+
resolveWaveAfterMergeBlocked,
|
|
33
|
+
} from "./sequence-waves.mjs";
|
|
25
34
|
import {
|
|
26
35
|
buildSequenceStateSnapshot,
|
|
27
36
|
finalizeSequenceState,
|
|
@@ -379,8 +388,81 @@ export async function runSequence(ctx) {
|
|
|
379
388
|
/** @type {Array<{ waveIndex: number, batchId: string|null, diagnosis: string|null }>} */
|
|
380
389
|
const completedWaves = [...persistedCompletedWaves];
|
|
381
390
|
|
|
391
|
+
const tasksRoot = plan?.metadata?.tasksRoot ?? null;
|
|
392
|
+
const discoveredTasks = tasksRoot ? discoverTasks(tasksRoot) : [];
|
|
393
|
+
const pendingTaskIds = tasksRoot ? filterPendingTaskIds(discoveredTasks, tasksRoot) : [];
|
|
394
|
+
const doneOnMainTaskIds = discoveredTasks
|
|
395
|
+
.map((task) => task.taskId)
|
|
396
|
+
.filter((taskId) => !pendingTaskIds.includes(taskId));
|
|
397
|
+
/** @type {Array<{ succeeded?: string[], skipped?: string[], failed?: string[] }>} */
|
|
398
|
+
const priorMergeOutcomes = [];
|
|
399
|
+
let satisfiedTaskIds = buildSequenceSatisfiedTaskIds(doneOnMainTaskIds, priorMergeOutcomes);
|
|
400
|
+
let mergeBlockedWaveIndex = null;
|
|
401
|
+
let sequenceHadMergeBlocked = false;
|
|
402
|
+
/** @type {string[]} */
|
|
403
|
+
const sequenceOutputLines = [];
|
|
404
|
+
/** @type {Array<{ waveIndex: number, message: string }>} */
|
|
405
|
+
const skippedWaves = [];
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* @param {number} waveIndex
|
|
409
|
+
* @param {string[]} waveTaskIds
|
|
410
|
+
*/
|
|
411
|
+
function resolveRunnableWaveTasks(waveIndex, waveTaskIds) {
|
|
412
|
+
if (mergeBlockedWaveIndex != null && waveIndex > mergeBlockedWaveIndex) {
|
|
413
|
+
const lastOutcome = priorMergeOutcomes[priorMergeOutcomes.length - 1] ?? {};
|
|
414
|
+
return resolveWaveAfterMergeBlocked({
|
|
415
|
+
plan,
|
|
416
|
+
waveIndex,
|
|
417
|
+
waveTaskIds,
|
|
418
|
+
satisfiedTaskIds,
|
|
419
|
+
mergeBlockedWaveIndex,
|
|
420
|
+
failedTaskIds: lastOutcome.failed ?? [],
|
|
421
|
+
succeededTaskIds: lastOutcome.succeeded ?? [],
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
return planSequenceWaveTasks({ plan, waveIndex, waveTaskIds, satisfiedTaskIds });
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* @param {number} waveIndex
|
|
429
|
+
* @param {object|null} batchState
|
|
430
|
+
* @param {string} [fallbackMessage]
|
|
431
|
+
*/
|
|
432
|
+
function absorbMergeBlockedWave(waveIndex, batchState, fallbackMessage = "") {
|
|
433
|
+
const outcomes = collectWaveTaskOutcomes(batchState);
|
|
434
|
+
priorMergeOutcomes.push(outcomes);
|
|
435
|
+
satisfiedTaskIds = buildSequenceSatisfiedTaskIds(doneOnMainTaskIds, priorMergeOutcomes);
|
|
436
|
+
mergeBlockedWaveIndex = waveIndex;
|
|
437
|
+
sequenceHadMergeBlocked = true;
|
|
438
|
+
const message =
|
|
439
|
+
String(fallbackMessage ?? "").trim() ||
|
|
440
|
+
String(batchState?.lastError ?? "").trim() ||
|
|
441
|
+
`Wave merge blocked (§17.4 mixed-outcome policy) at wave ${waveIndex}.`;
|
|
442
|
+
sequenceOutputLines.push(message);
|
|
443
|
+
}
|
|
444
|
+
|
|
382
445
|
for (const wave of wavePlan.waves) {
|
|
383
|
-
const
|
|
446
|
+
const wavePlanResolution = resolveRunnableWaveTasks(wave.waveIndex, wave.taskIds);
|
|
447
|
+
if (wavePlanResolution.action === "skip") {
|
|
448
|
+
skippedWaves.push({
|
|
449
|
+
waveIndex: wave.waveIndex,
|
|
450
|
+
message: wavePlanResolution.message ?? `Sequence wave ${wave.waveIndex} skipped.`,
|
|
451
|
+
});
|
|
452
|
+
sequenceOutputLines.push(
|
|
453
|
+
wavePlanResolution.message ?? `Sequence wave ${wave.waveIndex} skipped.`,
|
|
454
|
+
);
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
if (wavePlanResolution.message) {
|
|
458
|
+
sequenceOutputLines.push(wavePlanResolution.message);
|
|
459
|
+
} else if (wavePlanResolution.partialSkipMessage) {
|
|
460
|
+
sequenceOutputLines.push(wavePlanResolution.partialSkipMessage);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
const taskScope = wavePlanResolution.runnableTaskIds.join(" ");
|
|
464
|
+
if (!taskScope) continue;
|
|
465
|
+
|
|
384
466
|
let batchId = null;
|
|
385
467
|
let detachedEnginePid = null;
|
|
386
468
|
|
|
@@ -391,6 +473,15 @@ export async function runSequence(ctx) {
|
|
|
391
473
|
skipPreflight: true,
|
|
392
474
|
});
|
|
393
475
|
if (!startResult.ok) {
|
|
476
|
+
const reconciliation = reconcileBatch({ projectRoot });
|
|
477
|
+
if (isMergeBlockedBatchOutcome({ startResult, reconciliation })) {
|
|
478
|
+
absorbMergeBlockedWave(
|
|
479
|
+
wave.waveIndex,
|
|
480
|
+
loadSpineBatchState(projectRoot).raw,
|
|
481
|
+
startResult.output ?? "",
|
|
482
|
+
);
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
394
485
|
if (!stopOnFailure) continue;
|
|
395
486
|
return haltSequenceAndPersist(
|
|
396
487
|
projectRoot,
|
|
@@ -457,6 +548,15 @@ export async function runSequence(ctx) {
|
|
|
457
548
|
: await waitForSequenceBatchTerminal({ projectRoot, pollIntervalMs, timeoutMs, enginePid: detachedEnginePid ?? null });
|
|
458
549
|
|
|
459
550
|
if (!wait.ok || isSequenceBatchFailure(wait.diagnosis)) {
|
|
551
|
+
const reconciliation = wait.reconciliation ?? reconcileBatch({ projectRoot });
|
|
552
|
+
if (isMergeBlockedBatchOutcome({ reconciliation })) {
|
|
553
|
+
absorbMergeBlockedWave(
|
|
554
|
+
wave.waveIndex,
|
|
555
|
+
reconciliation.signals?.raw ?? loadSpineBatchState(projectRoot).raw,
|
|
556
|
+
reconciliation.headline ?? "",
|
|
557
|
+
);
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
460
560
|
if (!stopOnFailure) continue;
|
|
461
561
|
return haltSequenceAndPersist(projectRoot, sequenceState, completedWaves, {
|
|
462
562
|
waveIndex: wave.waveIndex,
|
|
@@ -492,6 +592,10 @@ export async function runSequence(ctx) {
|
|
|
492
592
|
};
|
|
493
593
|
completedWaves.push(waveResult);
|
|
494
594
|
|
|
595
|
+
for (const taskId of wavePlanResolution.runnableTaskIds) {
|
|
596
|
+
satisfiedTaskIds.add(taskId);
|
|
597
|
+
}
|
|
598
|
+
|
|
495
599
|
if (sequenceState) {
|
|
496
600
|
const lastBatchId = waveResult.batchId ?? sequenceState.lastBatchId ?? null;
|
|
497
601
|
sequenceState = buildSequenceStateSnapshot(sequenceState, {
|
|
@@ -505,12 +609,21 @@ export async function runSequence(ctx) {
|
|
|
505
609
|
|
|
506
610
|
finalizeSequenceState(projectRoot, sequenceState, completedWaves, plan);
|
|
507
611
|
|
|
612
|
+
if (completedWaves.length > 0) {
|
|
613
|
+
sequenceOutputLines.push(`Sequence completed ${completedWaves.length} wave(s).`);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const partialMergeBlocked = sequenceHadMergeBlocked && completedWaves.length < wavePlan.waves.length;
|
|
617
|
+
|
|
508
618
|
return {
|
|
509
|
-
ok:
|
|
510
|
-
exitCode: 0,
|
|
619
|
+
ok: !sequenceHadMergeBlocked,
|
|
620
|
+
exitCode: sequenceHadMergeBlocked ? 1 : 0,
|
|
511
621
|
completedWaves,
|
|
622
|
+
skippedWaves,
|
|
623
|
+
mergeBlocked: sequenceHadMergeBlocked,
|
|
624
|
+
partial: partialMergeBlocked,
|
|
512
625
|
waveCount: wavePlan.waves.length,
|
|
513
626
|
resumed: resume,
|
|
514
|
-
output:
|
|
627
|
+
output: `${sequenceOutputLines.join("\n")}\n`,
|
|
515
628
|
};
|
|
516
629
|
}
|
|
@@ -44,6 +44,7 @@ const PACKAGE_ROOT = path.resolve(__dirname, "../..");
|
|
|
44
44
|
|
|
45
45
|
const DEFAULT_TIMEOUT_MS = 60 * 60 * 1000;
|
|
46
46
|
const POST_DONE_KILL_BACKOFF_MS = 5_000;
|
|
47
|
+
const CHILD_DONE_TIMEOUT_MS = 15_000;
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
50
|
* Force-terminate lane worker processes tracked in batch state.
|
|
@@ -182,7 +183,7 @@ function spawnWorkerChild({
|
|
|
182
183
|
worktreePath,
|
|
183
184
|
taskFolder,
|
|
184
185
|
useStub,
|
|
185
|
-
timeoutMs,
|
|
186
|
+
timeoutMs: _timeoutMs,
|
|
186
187
|
projectRoot,
|
|
187
188
|
batchId,
|
|
188
189
|
laneNumber,
|
|
@@ -457,7 +458,7 @@ export async function runWorker({
|
|
|
457
458
|
onHeartbeat,
|
|
458
459
|
onWorkerPid,
|
|
459
460
|
fileScopePaths = [],
|
|
460
|
-
timeoutMs = DEFAULT_TIMEOUT_MS,
|
|
461
|
+
timeoutMs: _timeoutMs = DEFAULT_TIMEOUT_MS,
|
|
461
462
|
workerBackendDeps = {},
|
|
462
463
|
}) {
|
|
463
464
|
const donePath = path.join(taskFolder, ".DONE");
|
|
@@ -744,8 +745,7 @@ export async function runWorker({
|
|
|
744
745
|
});
|
|
745
746
|
stallWarningSent = true;
|
|
746
747
|
}
|
|
747
|
-
workerChild
|
|
748
|
-
const { output } = await childDone;
|
|
748
|
+
const { output } = await terminateHungWorkerChild(workerChild, childDone);
|
|
749
749
|
return buildWorkerFailureResult({
|
|
750
750
|
rawOutput: output,
|
|
751
751
|
classification: "stall_timeout",
|
|
@@ -770,7 +770,15 @@ export async function runWorker({
|
|
|
770
770
|
await sleep(Math.min(stallConfig.pollIntervalMs, 5_000));
|
|
771
771
|
}
|
|
772
772
|
|
|
773
|
-
const
|
|
773
|
+
const childResult = await Promise.race([childDone, sleep(CHILD_DONE_TIMEOUT_MS).then(() => null)]);
|
|
774
|
+
let exitCode, output;
|
|
775
|
+
if (childResult) {
|
|
776
|
+
({ exitCode, output } = childResult);
|
|
777
|
+
} else {
|
|
778
|
+
// close event didn't fire — sub-processes likely hold stdio pipes open.
|
|
779
|
+
const fallback = await terminateHungWorkerChild(workerChild, childDone);
|
|
780
|
+
({ exitCode, output } = fallback);
|
|
781
|
+
}
|
|
774
782
|
const doneFound = fs.existsSync(donePath);
|
|
775
783
|
if (postDoneTerminated && !doneFound) {
|
|
776
784
|
return buildWorkerFailureResult({
|
package/src/cli/deps.mjs
CHANGED
package/src/config/contract.mjs
CHANGED
|
@@ -33,6 +33,16 @@ export function validateContractConfig(config) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
if (contract.testRetries != null) {
|
|
37
|
+
if (typeof contract.testRetries !== "number" || !Number.isInteger(contract.testRetries) || contract.testRetries < 0) {
|
|
38
|
+
return {
|
|
39
|
+
code: "CONFIG_CONTRACT_TEST_RETRIES_INVALID",
|
|
40
|
+
message: "contract.testRetries must be a non-negative integer when set",
|
|
41
|
+
suggestedCommand: "spine settings set contract.testRetries 1",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
36
46
|
if (contract.legacyTaskIdPrefixes != null) {
|
|
37
47
|
if (!Array.isArray(contract.legacyTaskIdPrefixes)) {
|
|
38
48
|
return {
|
|
@@ -92,6 +92,14 @@ body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
|
|
|
92
92
|
.lane-status-running { color: var(--running); }
|
|
93
93
|
.lane-status-stale { color: var(--warn); }
|
|
94
94
|
.lane-status-completed { color: var(--muted); }
|
|
95
|
+
tr.task-failed { background: rgba(248, 81, 73, 0.1); }
|
|
96
|
+
tr.task-failed td { color: var(--error); }
|
|
97
|
+
tr.task-failed td.col-running,
|
|
98
|
+
tr.task-failed td.col-queued { color: var(--error); }
|
|
99
|
+
tr.task-succeeded { background: rgba(63, 185, 80, 0.08); }
|
|
100
|
+
tr.task-succeeded td.lane-status-completed { color: var(--running); }
|
|
101
|
+
tr.task-running { background: rgba(210, 153, 34, 0.08); }
|
|
102
|
+
tr.task-running td.lane-status-running { color: var(--paused); }
|
|
95
103
|
.empty-hint { color: var(--muted); font-style: italic; }
|
|
96
104
|
.gate-status { font-weight: 600; text-transform: uppercase; font-size: 0.75rem; }
|
|
97
105
|
.gate-status-pending, .gate-status-missing { color: var(--warn); }
|
|
@@ -226,13 +226,29 @@ function renderLanes(lanes, laneTableSummary, tailActivity, expandedLaneId) {
|
|
|
226
226
|
}
|
|
227
227
|
tr.dataset.laneId = lane.laneId;
|
|
228
228
|
tr.setAttribute("aria-expanded", lane.laneId === expandedLaneId ? "true" : "false");
|
|
229
|
-
const statusLabel =
|
|
230
|
-
lane.laneAlert === "checkpoint-warning"
|
|
231
|
-
? `${lane.status} · checkpoint warning`
|
|
232
|
-
: lane.laneAlert === "stall-killed"
|
|
233
|
-
? `${lane.status} · stall killed`
|
|
234
|
-
: lane.status;
|
|
235
229
|
const throughput = lane.throughput ?? {};
|
|
230
|
+
const failedCount = throughput.failedCount ?? 0;
|
|
231
|
+
const isTaskFailed = failedCount > 0 || lane.activityPhase === "failed";
|
|
232
|
+
const isTaskSucceeded = lane.status === "completed" && !isTaskFailed;
|
|
233
|
+
const isTaskRunning = lane.status === "running" && !isTaskFailed;
|
|
234
|
+
if (isTaskFailed) tr.classList.add("task-failed");
|
|
235
|
+
else if (isTaskSucceeded) tr.classList.add("task-succeeded");
|
|
236
|
+
else if (isTaskRunning) tr.classList.add("task-running");
|
|
237
|
+
let statusLabel;
|
|
238
|
+
if (isTaskFailed) {
|
|
239
|
+
const failedEvent = (lane.detail?.recentEvents ?? []).find((e) => e.type === "task.failed");
|
|
240
|
+
const rawReason = failedEvent?.summary ?? "";
|
|
241
|
+
const exitReason = rawReason.split("→")[0].replace(/,\s*$/, "").trim();
|
|
242
|
+
statusLabel = exitReason ? `❌ FAILED — ${exitReason}` : "❌ FAILED";
|
|
243
|
+
} else if (isTaskSucceeded) {
|
|
244
|
+
statusLabel = "✅ Done";
|
|
245
|
+
} else if (lane.laneAlert === "checkpoint-warning") {
|
|
246
|
+
statusLabel = `${lane.status} · checkpoint warning`;
|
|
247
|
+
} else if (lane.laneAlert === "stall-killed") {
|
|
248
|
+
statusLabel = `${lane.status} · stall killed`;
|
|
249
|
+
} else {
|
|
250
|
+
statusLabel = lane.status;
|
|
251
|
+
}
|
|
236
252
|
const runningText = formatRunningCell(lane.runningTaskId);
|
|
237
253
|
const queuedText = formatQueuedCell(lane.queuedTaskIds ?? []);
|
|
238
254
|
const cellSpecs = [
|
|
@@ -22,7 +22,6 @@ import { resolveStallConfig } from "../batch/heartbeat.mjs";
|
|
|
22
22
|
import { loadSpineConfig } from "../config/spine-config-load.mjs";
|
|
23
23
|
import {
|
|
24
24
|
deriveLanesThroughput,
|
|
25
|
-
deriveLaneThroughputStats,
|
|
26
25
|
emptyLaneThroughputStats,
|
|
27
26
|
summarizeLaneThroughput,
|
|
28
27
|
} from "./lane-throughput.mjs";
|
|
@@ -8,7 +8,6 @@ import { matchesContractPattern } from "../../batch/contract-verify.mjs";
|
|
|
8
8
|
import { CONTRACT_DEFAULTS } from "../../config/defaults.mjs";
|
|
9
9
|
import {
|
|
10
10
|
parseContract,
|
|
11
|
-
parsePrompt,
|
|
12
11
|
validatePrompt as validatePromptStructure,
|
|
13
12
|
} from "./parse-prompt.mjs";
|
|
14
13
|
import { validateContract } from "./validate-contract.mjs";
|