pi-spine 1.0.2 → 1.1.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/README.md +61 -489
- package/bin/get-version.mjs +1 -13
- package/bin/spine-batch.mjs +5 -1
- package/bin/spine-config.mjs +1 -212
- package/bin/spine-doctor.mjs +2 -418
- package/bin/spine-init.mjs +1 -398
- package/bin/spine-preflight.mjs +1 -700
- package/bin/spine-review-step.mjs +6 -4
- package/bin/spine-tasks.mjs +96 -11
- package/bin/spine-worker-runner.mjs +14 -4
- package/bin/spine.mjs +3 -1
- package/extensions/spine/worker-tools.ts +14 -12
- package/package.json +5 -2
- package/skills/create-spine-tasks/SKILL.md +135 -6
- package/skills/create-spine-tasks/references/clarify-template.md +73 -0
- package/skills/create-spine-tasks/references/prompt-template.md +2 -0
- package/skills/create-spine-tasks/references/requirements-checklist-template.md +94 -0
- package/src/batch/abort.mjs +1 -1
- package/src/batch/detached-start.mjs +41 -7
- package/src/batch/diagnosis.mjs +51 -6
- package/src/batch/engine-lanes/merge.mjs +70 -7
- package/src/batch/engine-lanes/review.mjs +32 -74
- package/src/batch/engine-scope.mjs +31 -4
- package/src/batch/engine.mjs +40 -48
- package/src/batch/evidence.mjs +3 -2
- package/src/batch/gate.mjs +3 -3
- package/src/batch/integrate.mjs +1 -1
- package/src/batch/journal.mjs +22 -0
- package/src/batch/lifecycle.mjs +1 -1
- package/src/batch/merge/adoption-doc-merge.mjs +160 -0
- package/src/batch/merge/wave-merge-state.mjs +105 -0
- package/src/batch/post-merge-limbo.mjs +87 -15
- package/src/batch/reconcile.mjs +50 -2
- package/src/batch/resume-common.mjs +1 -1
- package/src/batch/resume-engine.mjs +58 -1
- package/src/batch/resume-multi-validate.mjs +82 -3
- package/src/batch/resume-multi.mjs +36 -40
- package/src/batch/resume.mjs +20 -10
- package/src/batch/review-shared.mjs +196 -0
- package/src/batch/review-spawn.mjs +320 -0
- package/src/batch/review.mjs +178 -212
- package/src/batch/task-stall-budget.mjs +72 -0
- package/src/batch/worker-host.mjs +94 -34
- package/src/batch/worktree.mjs +10 -0
- package/src/cli/handoff.mjs +1 -1
- package/src/cli/rules.mjs +1 -1
- package/src/cli/settings-set.mjs +1 -1
- package/src/cli/settings-slash.mjs +27 -5
- package/src/config/spine-config-load.mjs +221 -0
- package/src/config/spine-init-constants.mjs +423 -0
- package/src/config/spine-preflight-lib.mjs +725 -0
- package/src/dashboard/public/dashboard.js +4 -25
- package/src/dashboard/public/index.html +1 -7
- package/src/dashboard/snapshot.mjs +172 -5
- package/src/dashboard/view.mjs +2 -0
- package/src/doctor/run-doctor-checks.mjs +458 -0
- package/src/doctor/stale-path.mjs +22 -0
- package/src/migrate/taskplane-config.mjs +1 -1
- package/src/planner/pending.mjs +92 -1
- package/src/tasks/analyze/index.mjs +453 -0
- package/src/util/command-exists.mjs +19 -0
- package/templates/docs/constitution.md +61 -0
- package/templates/spine-config.json +1 -1
|
@@ -18,78 +18,28 @@ import { runWorker } from "../worker-host.mjs";
|
|
|
18
18
|
import {
|
|
19
19
|
buildFinalReviewArtifactPath,
|
|
20
20
|
buildReviewArtifactPath,
|
|
21
|
+
normalizeCodeVerdict,
|
|
22
|
+
normalizeFinalVerdict,
|
|
23
|
+
parseFinalReviewVerdict,
|
|
24
|
+
shouldRunCodeReview,
|
|
25
|
+
shouldRunFinalReview,
|
|
26
|
+
} from "../review-shared.mjs";
|
|
27
|
+
import {
|
|
21
28
|
findCodeReviewStepNumber,
|
|
22
29
|
findCompletedCodeReview,
|
|
23
30
|
findCompletedFinalReview,
|
|
24
31
|
findFinalReviewStepNumber,
|
|
25
32
|
readReviewLevel,
|
|
33
|
+
REVIEW_TIMEOUT_REASON,
|
|
26
34
|
runStepReview,
|
|
27
35
|
} from "../review.mjs";
|
|
28
36
|
|
|
29
|
-
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const parsed = JSON.parse(jsonMatch[1]);
|
|
36
|
-
const verdict = normalizeFinalVerdict(parsed.verdict);
|
|
37
|
-
if (verdict) {
|
|
38
|
-
return {
|
|
39
|
-
verdict,
|
|
40
|
-
feedback: typeof parsed.feedback === "string" ? parsed.feedback : "",
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
} catch {
|
|
44
|
-
/* fall through */
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const headingMatch = reviewContent.match(/###?\s*Verdict[:\s]*(PASS|REVISE|REPLAN)/i);
|
|
49
|
-
if (headingMatch) {
|
|
50
|
-
return {
|
|
51
|
-
verdict: normalizeFinalVerdict(headingMatch[1]),
|
|
52
|
-
feedback: "",
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return { verdict: null, feedback: "" };
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @param {unknown} value
|
|
61
|
-
* @returns {"PASS"|"REVISE"|"REPLAN"|null}
|
|
62
|
-
*/
|
|
63
|
-
function normalizeFinalVerdict(value) {
|
|
64
|
-
if (typeof value !== "string") return null;
|
|
65
|
-
const upper = value.trim().toUpperCase();
|
|
66
|
-
return upper === "PASS" || upper === "REVISE" || upper === "REPLAN" ? upper : null;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @param {unknown} value
|
|
71
|
-
* @returns {"APPROVE"|"REVISE"|null}
|
|
72
|
-
*/
|
|
73
|
-
function normalizeCodeVerdict(value) {
|
|
74
|
-
if (typeof value !== "string") return null;
|
|
75
|
-
const upper = value.trim().toUpperCase();
|
|
76
|
-
return upper === "APPROVE" || upper === "REVISE" ? upper : null;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @param {object} params
|
|
81
|
-
*/
|
|
82
|
-
export function shouldRunCodeReview({ reviewLevel }) {
|
|
83
|
-
return reviewLevel >= 2;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @param {object} params
|
|
88
|
-
*/
|
|
89
|
-
export function shouldRunFinalReview({ config, reviewLevel }) {
|
|
90
|
-
const requireFinal = config?.review?.requireFinalVerdict ?? REVIEW_DEFAULTS.requireFinalVerdict;
|
|
91
|
-
return requireFinal && reviewLevel >= 1;
|
|
92
|
-
}
|
|
37
|
+
export {
|
|
38
|
+
buildFinalReviewArtifactPath,
|
|
39
|
+
parseFinalReviewVerdict,
|
|
40
|
+
shouldRunCodeReview,
|
|
41
|
+
shouldRunFinalReview,
|
|
42
|
+
} from "../review-shared.mjs";
|
|
93
43
|
|
|
94
44
|
/**
|
|
95
45
|
* @returns {"PASS"|"REVISE"|"REPLAN"}
|
|
@@ -145,7 +95,7 @@ function writeFinalStubReviewArtifact({ artifactPath, verdict, feedback }) {
|
|
|
145
95
|
/**
|
|
146
96
|
* @param {object} params
|
|
147
97
|
*/
|
|
148
|
-
export function runEngineFinalReview({
|
|
98
|
+
export async function runEngineFinalReview({
|
|
149
99
|
taskFolder,
|
|
150
100
|
worktreePath,
|
|
151
101
|
config = {},
|
|
@@ -196,7 +146,7 @@ export function runEngineFinalReview({
|
|
|
196
146
|
}
|
|
197
147
|
|
|
198
148
|
const stepNumber = findFinalReviewStepNumber(taskFolder);
|
|
199
|
-
return runStepReview({
|
|
149
|
+
return await runStepReview({
|
|
200
150
|
taskFolder,
|
|
201
151
|
worktreePath,
|
|
202
152
|
stepNumber,
|
|
@@ -210,7 +160,7 @@ export function runEngineFinalReview({
|
|
|
210
160
|
/**
|
|
211
161
|
* @param {object} params
|
|
212
162
|
*/
|
|
213
|
-
export function runEngineCodeReview({
|
|
163
|
+
export async function runEngineCodeReview({
|
|
214
164
|
taskFolder,
|
|
215
165
|
worktreePath,
|
|
216
166
|
config = {},
|
|
@@ -294,7 +244,7 @@ export function runEngineCodeReview({
|
|
|
294
244
|
};
|
|
295
245
|
}
|
|
296
246
|
|
|
297
|
-
return runStepReview({
|
|
247
|
+
return await runStepReview({
|
|
298
248
|
taskFolder,
|
|
299
249
|
worktreePath,
|
|
300
250
|
stepNumber,
|
|
@@ -461,7 +411,7 @@ async function runCodeReviewPhase({
|
|
|
461
411
|
};
|
|
462
412
|
|
|
463
413
|
while (true) {
|
|
464
|
-
const reviewResult = runEngineCodeReview({
|
|
414
|
+
const reviewResult = await runEngineCodeReview({
|
|
465
415
|
taskFolder: taskFolderInWorktree,
|
|
466
416
|
worktreePath: wt,
|
|
467
417
|
config,
|
|
@@ -470,6 +420,10 @@ async function runCodeReviewPhase({
|
|
|
470
420
|
});
|
|
471
421
|
|
|
472
422
|
if (reviewResult.spawnFailed) {
|
|
423
|
+
const spawnExitReason =
|
|
424
|
+
reviewResult.reason === REVIEW_TIMEOUT_REASON
|
|
425
|
+
? "code_review_timeout"
|
|
426
|
+
: "code_review_spawn_failed";
|
|
473
427
|
recordCodeReviewTaskFailure({
|
|
474
428
|
projectRoot,
|
|
475
429
|
state,
|
|
@@ -477,7 +431,7 @@ async function runCodeReviewPhase({
|
|
|
477
431
|
task,
|
|
478
432
|
lane,
|
|
479
433
|
laneCorrelationId,
|
|
480
|
-
exitReason:
|
|
434
|
+
exitReason: spawnExitReason,
|
|
481
435
|
verdict: null,
|
|
482
436
|
codeReviewAttempt,
|
|
483
437
|
config,
|
|
@@ -485,7 +439,7 @@ async function runCodeReviewPhase({
|
|
|
485
439
|
});
|
|
486
440
|
return {
|
|
487
441
|
ok: false,
|
|
488
|
-
error:
|
|
442
|
+
error: spawnExitReason,
|
|
489
443
|
output: reviewResult.error ?? "code review spawn failed",
|
|
490
444
|
};
|
|
491
445
|
}
|
|
@@ -793,7 +747,7 @@ async function runFinalReviewPhase({
|
|
|
793
747
|
}
|
|
794
748
|
}
|
|
795
749
|
|
|
796
|
-
const reviewResult = runEngineFinalReview({
|
|
750
|
+
const reviewResult = await runEngineFinalReview({
|
|
797
751
|
taskFolder: taskFolderInWorktree,
|
|
798
752
|
worktreePath: wt,
|
|
799
753
|
config,
|
|
@@ -803,6 +757,10 @@ async function runFinalReviewPhase({
|
|
|
803
757
|
});
|
|
804
758
|
|
|
805
759
|
if (reviewResult.spawnFailed) {
|
|
760
|
+
const spawnExitReason =
|
|
761
|
+
reviewResult.reason === REVIEW_TIMEOUT_REASON
|
|
762
|
+
? "final_review_timeout"
|
|
763
|
+
: "final_review_spawn_failed";
|
|
806
764
|
recordFinalReviewTaskFailure({
|
|
807
765
|
projectRoot,
|
|
808
766
|
state,
|
|
@@ -810,7 +768,7 @@ async function runFinalReviewPhase({
|
|
|
810
768
|
task,
|
|
811
769
|
lane,
|
|
812
770
|
laneCorrelationId,
|
|
813
|
-
exitReason:
|
|
771
|
+
exitReason: spawnExitReason,
|
|
814
772
|
verdict: null,
|
|
815
773
|
finalAttempt,
|
|
816
774
|
config,
|
|
@@ -818,7 +776,7 @@ async function runFinalReviewPhase({
|
|
|
818
776
|
});
|
|
819
777
|
return {
|
|
820
778
|
ok: false,
|
|
821
|
-
error:
|
|
779
|
+
error: spawnExitReason,
|
|
822
780
|
output: reviewResult.error ?? "final review spawn failed",
|
|
823
781
|
};
|
|
824
782
|
}
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { discoverTasks } from "../tasks/packet/discover.mjs";
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
assertBatchStartTasksNotSuperseded,
|
|
8
|
+
filterPendingTaskIds,
|
|
9
|
+
} from "../planner/pending.mjs";
|
|
10
|
+
import { NO_PENDING_TASKS_ERROR, parseScope } from "../planner/scope.mjs";
|
|
8
11
|
import { appendJournalEvent } from "./journal.mjs";
|
|
9
12
|
import {
|
|
10
13
|
loadSpineBatchState,
|
|
@@ -51,13 +54,14 @@ export function isExplicitBatchScope(scope) {
|
|
|
51
54
|
*
|
|
52
55
|
* @param {string} scope
|
|
53
56
|
* @param {string} tasksRoot
|
|
57
|
+
* @param {{ forceSuperseded?: boolean }} [options]
|
|
54
58
|
*/
|
|
55
|
-
export function resolveBatchStartScope(scope, tasksRoot) {
|
|
59
|
+
export function resolveBatchStartScope(scope, tasksRoot, options = {}) {
|
|
56
60
|
const trimmed = String(scope ?? "").trim();
|
|
57
61
|
const normalized = trimmed.toLowerCase();
|
|
62
|
+
const discovered = discoverTasks(tasksRoot);
|
|
58
63
|
|
|
59
64
|
if (!trimmed || normalized === "all") {
|
|
60
|
-
const discovered = discoverTasks(tasksRoot);
|
|
61
65
|
const pendingIds = filterPendingTaskIds(discovered, tasksRoot);
|
|
62
66
|
if (pendingIds.length === 0) {
|
|
63
67
|
return {
|
|
@@ -77,6 +81,29 @@ export function resolveBatchStartScope(scope, tasksRoot) {
|
|
|
77
81
|
return { ok: true, scope: "pending", policyScope: "pending" };
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
let resolvedTaskIds = [];
|
|
85
|
+
try {
|
|
86
|
+
const scopeResult = parseScope(trimmed, { tasksRoot, discoveredTasks: discovered });
|
|
87
|
+
resolvedTaskIds = scopeResult.taskIds;
|
|
88
|
+
} catch {
|
|
89
|
+
// Scope parsing errors surface again during buildPlan; still guard bare task ID tokens.
|
|
90
|
+
resolvedTaskIds = trimmed.split(/\s+/).filter((token) => /^[A-Z][A-Z0-9]*-\d{3,}$/.test(token));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const supersededGuard = assertBatchStartTasksNotSuperseded(
|
|
94
|
+
resolvedTaskIds,
|
|
95
|
+
tasksRoot,
|
|
96
|
+
discovered,
|
|
97
|
+
options,
|
|
98
|
+
);
|
|
99
|
+
if (!supersededGuard.ok) {
|
|
100
|
+
return {
|
|
101
|
+
ok: false,
|
|
102
|
+
error: supersededGuard.error,
|
|
103
|
+
output: supersededGuard.output,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
80
107
|
return { ok: true, scope: trimmed, policyScope: trimmed };
|
|
81
108
|
}
|
|
82
109
|
|
package/src/batch/engine.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* pi-spine batch engine (Phase 2 single-lane, Phase 3 multi-lane + §17.4 merge policy).
|
|
3
4
|
*/
|
|
@@ -7,10 +8,10 @@ import path from "node:path";
|
|
|
7
8
|
import crypto from "node:crypto";
|
|
8
9
|
import { discoverTasks } from "../tasks/packet/discover.mjs";
|
|
9
10
|
import { buildPlan } from "../planner/index.mjs";
|
|
10
|
-
import { runBatchPreflight, resolveTasksRoot } from "
|
|
11
|
-
import { loadSpineConfig } from "
|
|
12
|
-
import { openIntegrateGateAfterBatchComplete } from "./gate.mjs";
|
|
11
|
+
import { runBatchPreflight, resolveTasksRoot } from "../config/spine-preflight-lib.mjs";
|
|
12
|
+
import { loadSpineConfig } from "../config/spine-config-load.mjs";
|
|
13
13
|
import { integrateOrchToBase } from "./integrate.mjs";
|
|
14
|
+
import { finalizeBatchForIntegrate } from "./post-merge-limbo.mjs";
|
|
14
15
|
import { appendJournalEvent } from "./journal.mjs";
|
|
15
16
|
import {
|
|
16
17
|
assertNoActiveBatch,
|
|
@@ -61,12 +62,14 @@ export { loadTaskFileScopePaths, mergeLaneToOrch } from "./engine-lanes.mjs";
|
|
|
61
62
|
* @param {string} [options.scope]
|
|
62
63
|
* @param {boolean} [options.dryRun]
|
|
63
64
|
* @param {boolean} [options.skipPreflight]
|
|
65
|
+
* @param {boolean} [options.forceSuperseded]
|
|
64
66
|
*/
|
|
65
67
|
export async function startBatch({
|
|
66
68
|
projectRoot,
|
|
67
69
|
scope = "all",
|
|
68
70
|
dryRun = false,
|
|
69
71
|
skipPreflight = false,
|
|
72
|
+
forceSuperseded = false,
|
|
70
73
|
}) {
|
|
71
74
|
if (!skipPreflight) {
|
|
72
75
|
const preflight = runBatchPreflight({ projectRoot, skipDoctor: false });
|
|
@@ -75,7 +78,7 @@ export async function startBatch({
|
|
|
75
78
|
ok: false,
|
|
76
79
|
exitCode: preflight.exitCode ?? 1,
|
|
77
80
|
error: "preflight_failed",
|
|
78
|
-
output: preflight.output,
|
|
81
|
+
output: /** @type {string | undefined} */ (/** @type {any} */ (preflight).output),
|
|
79
82
|
};
|
|
80
83
|
}
|
|
81
84
|
}
|
|
@@ -83,13 +86,14 @@ export async function startBatch({
|
|
|
83
86
|
assertNoActiveBatch(projectRoot);
|
|
84
87
|
|
|
85
88
|
const configResult = loadSpineConfig(projectRoot);
|
|
89
|
+
/** @type {Record<string, any>} */
|
|
86
90
|
const config = configResult.config ?? {};
|
|
87
91
|
const tasksRoot = resolveTasksRoot(projectRoot, configResult);
|
|
88
92
|
if (!tasksRoot) {
|
|
89
93
|
return { ok: false, exitCode: 1, error: "tasks_root_missing" };
|
|
90
94
|
}
|
|
91
95
|
|
|
92
|
-
const scopeResolution = resolveBatchStartScope(scope, tasksRoot);
|
|
96
|
+
const scopeResolution = resolveBatchStartScope(scope, tasksRoot, { forceSuperseded });
|
|
93
97
|
if (!scopeResolution.ok) {
|
|
94
98
|
return {
|
|
95
99
|
ok: false,
|
|
@@ -99,11 +103,11 @@ export async function startBatch({
|
|
|
99
103
|
};
|
|
100
104
|
}
|
|
101
105
|
|
|
102
|
-
const effectiveScope = scopeResolution.scope;
|
|
106
|
+
const effectiveScope = /** @type {string} */ (scopeResolution.scope);
|
|
103
107
|
const policyScope = scopeResolution.policyScope ?? effectiveScope;
|
|
104
108
|
|
|
105
|
-
const plan = buildPlan({ scope: effectiveScope, config, tasksRoot });
|
|
106
|
-
const batchPolicy = canStartMultiTaskBatch(plan, policyScope);
|
|
109
|
+
const plan = buildPlan({ scope: effectiveScope, config, tasksRoot: /** @type {string} */ (tasksRoot) });
|
|
110
|
+
const batchPolicy = canStartMultiTaskBatch(plan, policyScope ?? effectiveScope);
|
|
107
111
|
if (!batchPolicy.ok) {
|
|
108
112
|
return {
|
|
109
113
|
ok: false,
|
|
@@ -148,6 +152,7 @@ export async function startBatch({
|
|
|
148
152
|
maxLaneNumber,
|
|
149
153
|
});
|
|
150
154
|
|
|
155
|
+
/** @type {ReturnType<typeof createInitialBatchState>} */
|
|
151
156
|
let state = createInitialBatchState({
|
|
152
157
|
batchId,
|
|
153
158
|
baseBranch,
|
|
@@ -237,7 +242,7 @@ export async function startBatch({
|
|
|
237
242
|
if (tickTaskIds.length === 0) continue;
|
|
238
243
|
|
|
239
244
|
const laneNumber = laneInTick + 1;
|
|
240
|
-
const lane = state.lanes.find((entry) => entry.laneNumber === laneNumber);
|
|
245
|
+
const lane = state.lanes.find((/** @type {{ laneNumber: number }} */ entry) => entry.laneNumber === laneNumber);
|
|
241
246
|
if (!lane) continue;
|
|
242
247
|
|
|
243
248
|
if (!runsByLane.has(laneNumber)) {
|
|
@@ -246,8 +251,8 @@ export async function startBatch({
|
|
|
246
251
|
const laneQueue = runsByLane.get(laneNumber);
|
|
247
252
|
|
|
248
253
|
for (const taskId of tickTaskIds) {
|
|
249
|
-
const task = state.tasks.find((entry) => entry.taskId === taskId);
|
|
250
|
-
const entry = discovered.find((item) => item.taskId === taskId);
|
|
254
|
+
const task = state.tasks.find((/** @type {{ taskId: string }} */ entry) => entry.taskId === taskId);
|
|
255
|
+
const entry = discovered.find((/** @type {{ taskId: string }} */ item) => item.taskId === taskId);
|
|
251
256
|
if (!task || !entry) continue;
|
|
252
257
|
|
|
253
258
|
const taskFolderRel = path.relative(projectRoot, entry.folderPath);
|
|
@@ -277,23 +282,26 @@ export async function startBatch({
|
|
|
277
282
|
taskFolderRel,
|
|
278
283
|
laneCorrelationId,
|
|
279
284
|
}).then((result) => {
|
|
280
|
-
if (result.aborted) batchAborted = true;
|
|
285
|
+
if ("aborted" in result && result.aborted) batchAborted = true;
|
|
281
286
|
return result;
|
|
282
287
|
});
|
|
283
288
|
|
|
284
|
-
laneQueue
|
|
289
|
+
if (laneQueue) {
|
|
290
|
+
laneQueue.runs.push({ taskId, run });
|
|
291
|
+
}
|
|
285
292
|
}
|
|
286
293
|
}
|
|
287
294
|
|
|
288
295
|
const laneExecutions = [...runsByLane.entries()].map(async ([laneNumber, { lane, runs }]) => {
|
|
296
|
+
const laneMeta = /** @type {{ laneId?: string; correlationId?: string }} */ (lane);
|
|
289
297
|
if (runs.length > 1) {
|
|
290
298
|
appendJournalEvent(projectRoot, batchId, "lane.tasks_serialized", {
|
|
291
299
|
laneNumber,
|
|
292
|
-
laneId:
|
|
300
|
+
laneId: laneMeta.laneId,
|
|
293
301
|
waveIndex: wave.index,
|
|
294
302
|
tickIndex: tick.index,
|
|
295
303
|
taskIds: runs.map((entry) => entry.taskId),
|
|
296
|
-
correlationId:
|
|
304
|
+
correlationId: laneMeta.correlationId ?? null,
|
|
297
305
|
});
|
|
298
306
|
}
|
|
299
307
|
|
|
@@ -311,9 +319,9 @@ export async function startBatch({
|
|
|
311
319
|
}
|
|
312
320
|
|
|
313
321
|
if (batchAborted) {
|
|
314
|
-
const abortedTask = state.tasks.find((task) => task.status === "aborted");
|
|
315
|
-
state.endedAt = Date.now();
|
|
316
|
-
state.lastError = "batch aborted";
|
|
322
|
+
const abortedTask = state.tasks.find((/** @type {{ status: string }} */ task) => task.status === "aborted");
|
|
323
|
+
/** @type {any} */ (state).endedAt = Date.now();
|
|
324
|
+
/** @type {any} */ (state).lastError = "batch aborted";
|
|
317
325
|
transitionPhase(state, "aborted", {
|
|
318
326
|
projectRoot,
|
|
319
327
|
batchId,
|
|
@@ -331,8 +339,8 @@ export async function startBatch({
|
|
|
331
339
|
|
|
332
340
|
const mergeEligibility = assessWaveMergeEligibility(state, wave.index);
|
|
333
341
|
if (!mergeEligibility.ok) {
|
|
334
|
-
state.endedAt = Date.now();
|
|
335
|
-
state.lastError = mergeEligibility.message?.slice(0, 500) ?? "mixed_outcome";
|
|
342
|
+
/** @type {any} */ (state).endedAt = Date.now();
|
|
343
|
+
/** @type {any} */ (state).lastError = mergeEligibility.message?.slice(0, 500) ?? "mixed_outcome";
|
|
336
344
|
transitionPhase(state, "failed", {
|
|
337
345
|
projectRoot,
|
|
338
346
|
batchId,
|
|
@@ -368,8 +376,8 @@ export async function startBatch({
|
|
|
368
376
|
waveIndex: wave.index,
|
|
369
377
|
});
|
|
370
378
|
if (!mergeResult.ok) {
|
|
371
|
-
state.endedAt = Date.now();
|
|
372
|
-
state.lastError = mergeResult.error ?? "merge failed";
|
|
379
|
+
/** @type {any} */ (state).endedAt = Date.now();
|
|
380
|
+
/** @type {any} */ (state).lastError = mergeResult.error ?? "merge failed";
|
|
373
381
|
transitionPhase(state, "failed", {
|
|
374
382
|
projectRoot,
|
|
375
383
|
batchId,
|
|
@@ -385,6 +393,10 @@ export async function startBatch({
|
|
|
385
393
|
};
|
|
386
394
|
}
|
|
387
395
|
|
|
396
|
+
if (mergeResult.finalized && mergeResult.finalizeResult) {
|
|
397
|
+
return mergeResult.finalizeResult;
|
|
398
|
+
}
|
|
399
|
+
|
|
388
400
|
if (
|
|
389
401
|
shouldAutoIntegrateAfterWave({
|
|
390
402
|
config,
|
|
@@ -401,37 +413,17 @@ export async function startBatch({
|
|
|
401
413
|
}
|
|
402
414
|
}
|
|
403
415
|
|
|
404
|
-
|
|
405
|
-
openIntegrateGateAfterBatchComplete({
|
|
416
|
+
return finalizeBatchForIntegrate({
|
|
406
417
|
projectRoot,
|
|
418
|
+
state,
|
|
407
419
|
batchId,
|
|
408
|
-
batchState: { ...state, phase: "completed" },
|
|
409
|
-
});
|
|
410
|
-
transitionPhase(state, "completed", {
|
|
411
|
-
projectRoot,
|
|
412
|
-
batchId,
|
|
413
|
-
extra: { taskIds, mergeCommit: state.mergeResults.at(-1)?.mergeCommit },
|
|
414
|
-
});
|
|
415
|
-
saveSpineBatchState(projectRoot, state);
|
|
416
|
-
|
|
417
|
-
const summaryTask =
|
|
418
|
-
taskIds.length === 1 ? taskIds[0] : `${taskIds.length} tasks (${taskIds.join(", ")})`;
|
|
419
|
-
return {
|
|
420
|
-
ok: true,
|
|
421
|
-
exitCode: 0,
|
|
422
|
-
batchId,
|
|
423
|
-
taskId: taskIds.length === 1 ? taskIds[0] : undefined,
|
|
424
|
-
taskIds,
|
|
425
420
|
orchBranch,
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
`Batch ${batchId} completed: ${summaryTask} succeeded; merged to ${orchBranch}.\n` +
|
|
429
|
-
` → spine gate status\n → spine gate approve\n → spine integrate\n → spine batch complete\n`,
|
|
430
|
-
};
|
|
421
|
+
resumed: false,
|
|
422
|
+
});
|
|
431
423
|
} catch (err) {
|
|
432
424
|
const message = err instanceof Error ? err.message : String(err);
|
|
433
|
-
state.endedAt = Date.now();
|
|
434
|
-
state.lastError = message;
|
|
425
|
+
/** @type {any} */ (state).endedAt = Date.now();
|
|
426
|
+
/** @type {any} */ (state).lastError = message;
|
|
435
427
|
transitionPhase(state, "failed", {
|
|
436
428
|
projectRoot,
|
|
437
429
|
batchId,
|
package/src/batch/evidence.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { runEvidenceCommand } from "./evidence-command.mjs";
|
|
|
9
9
|
import { readJournalEvents, readJournalTail } from "./journal.mjs";
|
|
10
10
|
import { generateBatchPostMortem } from "./postmortem.mjs";
|
|
11
11
|
import { reconcileBatch } from "./reconcile.mjs";
|
|
12
|
+
import { loadSpineConfig } from "../config/spine-config-load.mjs";
|
|
12
13
|
|
|
13
14
|
const TASKPLANE_CONFIG_PATH = ".pi/taskplane-config.json";
|
|
14
15
|
|
|
@@ -36,7 +37,7 @@ function readTaskplaneTestingCommands(projectRoot) {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
|
-
* @param {
|
|
40
|
+
* @param {ReturnType<typeof loadSpineConfig>["config"]} config
|
|
40
41
|
* @param {string} projectRoot
|
|
41
42
|
*/
|
|
42
43
|
export function resolveTestingCommands(config, projectRoot) {
|
|
@@ -121,7 +122,7 @@ export function buildTaskScorecard(batchState) {
|
|
|
121
122
|
* @param {string} ctx.projectRoot
|
|
122
123
|
* @param {string} ctx.batchId
|
|
123
124
|
* @param {object|null} [ctx.batchState]
|
|
124
|
-
* @param {
|
|
125
|
+
* @param {ReturnType<typeof loadSpineConfig>["config"]} [ctx.config]
|
|
125
126
|
*/
|
|
126
127
|
export function collectEvidenceBundle(ctx) {
|
|
127
128
|
const { projectRoot, batchId, batchState = null, config = null } = ctx;
|
package/src/batch/gate.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import crypto from "node:crypto";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import path from "node:path";
|
|
8
|
-
import { loadSpineConfig } from "
|
|
8
|
+
import { loadSpineConfig } from "../config/spine-config-load.mjs";
|
|
9
9
|
import { collectEvidenceBundle } from "./evidence.mjs";
|
|
10
10
|
import { appendJournalEvent } from "./journal.mjs";
|
|
11
11
|
|
|
@@ -65,7 +65,7 @@ export function formatGateSummary(gate) {
|
|
|
65
65
|
* @param {string} ctx.projectRoot
|
|
66
66
|
* @param {string} ctx.batchId
|
|
67
67
|
* @param {object|null} [ctx.batchState]
|
|
68
|
-
* @param {
|
|
68
|
+
* @param {ReturnType<typeof loadSpineConfig>["config"]} [ctx.config]
|
|
69
69
|
*/
|
|
70
70
|
export function openIntegrateGate(ctx) {
|
|
71
71
|
const { projectRoot, batchId, batchState = null, config = null } = ctx;
|
|
@@ -277,7 +277,7 @@ export function getIntegrateGateStatus(ctx) {
|
|
|
277
277
|
* @param {object} ctx
|
|
278
278
|
* @param {string} ctx.projectRoot
|
|
279
279
|
* @param {string} ctx.batchId
|
|
280
|
-
* @param {
|
|
280
|
+
* @param {ReturnType<typeof loadSpineConfig>["config"]} [ctx.config]
|
|
281
281
|
* @param {boolean} [ctx.forceIntegrate]
|
|
282
282
|
* @param {boolean} [ctx.dryRun]
|
|
283
283
|
*/
|
package/src/batch/integrate.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { execFileSync } from "node:child_process";
|
|
6
6
|
import { gitExec } from "./git-exec.mjs";
|
|
7
|
-
import { loadSpineConfig } from "
|
|
7
|
+
import { loadSpineConfig } from "../config/spine-config-load.mjs";
|
|
8
8
|
import {
|
|
9
9
|
resolveRulesManifestIntegrateDrift,
|
|
10
10
|
tryAutoResolveRulesManifestMergeConflict,
|
package/src/batch/journal.mjs
CHANGED
|
@@ -371,3 +371,25 @@ export function extractJournalDiagnosisHints(events) {
|
|
|
371
371
|
|
|
372
372
|
return hints;
|
|
373
373
|
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* True when journal shows plan `review.failed` with `nested_spawn_blocked` for a task.
|
|
377
|
+
* Stale PATH spine pre-SP-278 behavior (batch 20260619T020951 / issue #12).
|
|
378
|
+
*
|
|
379
|
+
* @param {object[]} journalEvents
|
|
380
|
+
* @param {string|null} [taskId]
|
|
381
|
+
*/
|
|
382
|
+
export function findPlanReviewNestedSpawnBlockedFailure(journalEvents, taskId) {
|
|
383
|
+
if (!Array.isArray(journalEvents) || journalEvents.length === 0) return false;
|
|
384
|
+
for (let index = journalEvents.length - 1; index >= 0; index -= 1) {
|
|
385
|
+
const event = journalEvents[index];
|
|
386
|
+
if (event.type !== "review.failed") continue;
|
|
387
|
+
const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
|
|
388
|
+
if (payload.reason !== "nested_spawn_blocked") continue;
|
|
389
|
+
if (payload.reviewType !== "plan") continue;
|
|
390
|
+
const eventTaskId = event.taskId ?? payload.taskId;
|
|
391
|
+
if (taskId && eventTaskId && eventTaskId !== taskId) continue;
|
|
392
|
+
return true;
|
|
393
|
+
}
|
|
394
|
+
return false;
|
|
395
|
+
}
|
package/src/batch/lifecycle.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import fs from "node:fs";
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { buildDiagnosisOutput } from "./diagnosis.mjs";
|
|
8
8
|
import { assertOrchIntegratable } from "./integrate.mjs";
|
|
9
|
-
import { loadSpineConfig } from "
|
|
9
|
+
import { loadSpineConfig } from "../config/spine-config-load.mjs";
|
|
10
10
|
import { appendJournalEvent } from "./journal.mjs";
|
|
11
11
|
import { recordBatchTerminalMetric } from "./metrics.mjs";
|
|
12
12
|
import { writeBatchPostMortem } from "./postmortem.mjs";
|