pi-spine 2.21.0 → 2.23.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 +1 -1
- package/package.json +2 -2
- package/skills/spine-release-operator/SKILL.md +78 -8
- package/src/batch/diagnosis-primary-failure.mjs +34 -3
- package/src/batch/diagnosis-suggested-command.mjs +2 -0
- package/src/batch/engine-lanes/commit.mjs +5 -6
- package/src/batch/engine-lanes/matrix-run.mjs +46 -23
- package/src/batch/engine-lanes/matrix.mjs +8 -6
- package/src/batch/engine-lanes/merge.mjs +57 -25
- package/src/batch/engine-lanes/orch-sync.mjs +13 -6
- package/src/batch/engine-lanes/phase.mjs +8 -2
- package/src/batch/engine-lanes/queue.mjs +33 -3
- package/src/batch/engine-lanes/review-code.mjs +28 -3
- package/src/batch/engine-lanes/review-final.mjs +39 -3
- package/src/batch/engine-lanes/review-plan.mjs +32 -5
- package/src/batch/engine-lanes/review-poll.mjs +32 -9
- package/src/batch/engine-lanes/review-stub.mjs +1 -2
- package/src/batch/engine-lanes/review.mjs +0 -1
- package/src/batch/engine-lanes.mjs +33 -5
- package/src/batch/evidence-command.mjs +5 -2
- package/src/batch/journal-rebuild-structural.mjs +13 -2
- package/src/batch/reconcile-diagnosis-enrich.mjs +173 -0
- package/src/batch/reconcile-diagnosis.mjs +63 -135
- package/src/batch/salvage-batch-integrate-heal.mjs +116 -0
- package/src/batch/salvage-batch-integrate.mjs +18 -0
- package/src/config/preflight/tracked-gitignored.mjs +178 -0
- package/src/config/spine-preflight-lib.mjs +9 -0
- package/src/doctor/run-doctor-checks.mjs +5 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Engine lane merge-phase wiring — lane→orch merges and rules-manifest conflict resolution.
|
|
4
3
|
*/
|
|
@@ -69,6 +68,7 @@ function listUnmergedPaths(projectRoot) {
|
|
|
69
68
|
/**
|
|
70
69
|
* @param {string} projectRoot
|
|
71
70
|
* @param {string} ref
|
|
71
|
+
* @returns {{ ok: true, manifest: import("../../config/cursor-rules/discover.mjs").CursorRulesManifest } | { ok: false, error: string }}
|
|
72
72
|
*/
|
|
73
73
|
function readRulesManifestFromRef(projectRoot, ref) {
|
|
74
74
|
const output = git(projectRoot, ["show", `${ref}:${RULES_MANIFEST_REL_PATH}`], {
|
|
@@ -112,6 +112,7 @@ export { resolveRulesManifestIntegrateDrift } from "../rules-manifest-drift.mjs"
|
|
|
112
112
|
/**
|
|
113
113
|
* @param {string} projectRoot
|
|
114
114
|
* @param {2 | 3} stage
|
|
115
|
+
* @returns {{ ok: true, manifest: import("../../config/cursor-rules/discover.mjs").CursorRulesManifest } | { ok: false, error: string }}
|
|
115
116
|
*/
|
|
116
117
|
function readRulesManifestMergeStage(projectRoot, stage) {
|
|
117
118
|
const output = git(projectRoot, ["show", `:${stage}:${RULES_MANIFEST_REL_PATH}`], {
|
|
@@ -161,7 +162,7 @@ function resolveRulesManifestMergeConflict(projectRoot) {
|
|
|
161
162
|
const theirsResult = readRulesManifestMergeStage(projectRoot, 3);
|
|
162
163
|
if (!oursResult.ok || !theirsResult.ok) {
|
|
163
164
|
return {
|
|
164
|
-
ok: false,
|
|
165
|
+
ok: /** @type {const} */ (false),
|
|
165
166
|
error: "unable to read rules-manifest merge stages",
|
|
166
167
|
};
|
|
167
168
|
}
|
|
@@ -177,8 +178,8 @@ function resolveRulesManifestMergeConflict(projectRoot) {
|
|
|
177
178
|
writeRulesManifestAtomic(projectRoot, resolved.manifest);
|
|
178
179
|
gitAddFilteredPaths(projectRoot, [RULES_MANIFEST_REL_PATH], { projectRoot });
|
|
179
180
|
return {
|
|
180
|
-
ok: true,
|
|
181
|
-
autoResolved: true,
|
|
181
|
+
ok: /** @type {const} */ (true),
|
|
182
|
+
autoResolved: /** @type {const} */ (true),
|
|
182
183
|
generatedAt: resolved.manifest.generatedAt,
|
|
183
184
|
};
|
|
184
185
|
}
|
|
@@ -196,7 +197,7 @@ function tryAutoResolveOutOfScopeMergeConflict({
|
|
|
196
197
|
projectRoot,
|
|
197
198
|
filePath,
|
|
198
199
|
laneFileScopePaths,
|
|
199
|
-
_laneChangedFiles,
|
|
200
|
+
laneChangedFiles: _laneChangedFiles,
|
|
200
201
|
}) {
|
|
201
202
|
if (pathInLaneFileScope(filePath, laneFileScopePaths)) {
|
|
202
203
|
return { ok: false, reason: "in_lane_file_scope" };
|
|
@@ -220,7 +221,7 @@ function tryAutoResolveOutOfScopeMergeConflict({
|
|
|
220
221
|
}
|
|
221
222
|
|
|
222
223
|
/**
|
|
223
|
-
* @param {
|
|
224
|
+
* @param {Record<string, any>} state
|
|
224
225
|
* @param {number} laneNumber
|
|
225
226
|
* @param {string[]} waveTaskIds
|
|
226
227
|
*/
|
|
@@ -228,7 +229,7 @@ function collectLaneWaveFileScope(state, laneNumber, waveTaskIds) {
|
|
|
228
229
|
/** @type {Set<string>} */
|
|
229
230
|
const patterns = new Set();
|
|
230
231
|
for (const taskId of waveTaskIds) {
|
|
231
|
-
const task = (state.tasks ?? []).find((entry) => entry?.taskId === taskId);
|
|
232
|
+
const task = (state.tasks ?? []).find((/** @type {any} */ entry) => entry?.taskId === taskId);
|
|
232
233
|
if (!task || task.laneNumber !== laneNumber) continue;
|
|
233
234
|
const folder = task.taskFolder;
|
|
234
235
|
if (!folder) continue;
|
|
@@ -243,12 +244,15 @@ function collectLaneWaveFileScope(state, laneNumber, waveTaskIds) {
|
|
|
243
244
|
}
|
|
244
245
|
|
|
245
246
|
/**
|
|
247
|
+
* Auto-resolve lane→orch merge conflicts for known conflict classes.
|
|
248
|
+
*
|
|
246
249
|
* @param {string} projectRoot
|
|
247
250
|
* @param {object} [options]
|
|
248
251
|
* @param {string[]} [options.laneFileScopePaths]
|
|
249
252
|
* @param {string} [options.taskBranch]
|
|
250
253
|
* @param {string} [options.orchBranch]
|
|
251
254
|
* @param {number} [options.waveIndex]
|
|
255
|
+
* @returns {{ ok: true, autoResolved: true, generatedAt?: string, outOfScopePaths?: string[], adoptionDocPaths?: string[], skippedGitignoredPaths?: string[] } | { ok: false, error: string, failureClass?: string, outOfScopePaths?: string[], adoptionDocPaths?: string[], skippedGitignoredPaths?: string[] }}
|
|
252
256
|
*/
|
|
253
257
|
export function tryAutoResolveMergeConflicts(projectRoot, options = {}) {
|
|
254
258
|
const { laneFileScopePaths = [], taskBranch, orchBranch, waveIndex } = options;
|
|
@@ -274,11 +278,11 @@ export function tryAutoResolveMergeConflicts(projectRoot, options = {}) {
|
|
|
274
278
|
/** @type {Set<string>} */
|
|
275
279
|
let laneChangedFiles = new Set();
|
|
276
280
|
if (canResolveOutOfScope) {
|
|
277
|
-
const mergeBase = git(projectRoot, ["merge-base", orchBranch, taskBranch], {
|
|
281
|
+
const mergeBase = git(projectRoot, ["merge-base", /** @type {string} */ (orchBranch), /** @type {string} */ (taskBranch)], {
|
|
278
282
|
throwOnError: false,
|
|
279
283
|
});
|
|
280
284
|
if (mergeBase) {
|
|
281
|
-
laneChangedFiles = listBranchChangedFiles(projectRoot, mergeBase, taskBranch);
|
|
285
|
+
laneChangedFiles = listBranchChangedFiles(projectRoot, mergeBase, /** @type {string} */ (taskBranch));
|
|
282
286
|
}
|
|
283
287
|
}
|
|
284
288
|
|
|
@@ -411,7 +415,10 @@ export function tryAutoResolveMergeConflicts(projectRoot, options = {}) {
|
|
|
411
415
|
};
|
|
412
416
|
}
|
|
413
417
|
|
|
414
|
-
/**
|
|
418
|
+
/**
|
|
419
|
+
* @deprecated use tryAutoResolveMergeConflicts
|
|
420
|
+
* @param {string} projectRoot
|
|
421
|
+
*/
|
|
415
422
|
export function tryAutoResolveRulesManifestMergeConflict(projectRoot) {
|
|
416
423
|
return tryAutoResolveMergeConflicts(projectRoot, {});
|
|
417
424
|
}
|
|
@@ -424,15 +431,12 @@ function gitStrict(projectRoot, args) {
|
|
|
424
431
|
return git(projectRoot, args);
|
|
425
432
|
}
|
|
426
433
|
|
|
427
|
-
/**
|
|
428
|
-
* @param {object} params
|
|
429
|
-
* @param {boolean} [params.requireLaneCommits] When true, task branch must be ahead of orch before merge (post lane auto-commit).
|
|
430
|
-
*/
|
|
431
434
|
/**
|
|
432
435
|
* Clear generatedAt-only rules-manifest drift on the working tree before lane→orch merge.
|
|
433
436
|
* Workers refresh the manifest during pi sessions; an uncommitted copy blocks `git merge`.
|
|
434
437
|
*
|
|
435
438
|
* @param {string} projectRoot
|
|
439
|
+
* @returns {{ ok: true, resolved: boolean, action?: string } | { ok: false, failureClass: string, error: string }}
|
|
436
440
|
*/
|
|
437
441
|
function resolveRulesManifestPreMergeDrift(projectRoot) {
|
|
438
442
|
const dirtyPaths = listDirtyPaths(projectRoot);
|
|
@@ -443,7 +447,7 @@ function resolveRulesManifestPreMergeDrift(projectRoot) {
|
|
|
443
447
|
return { ok: true, resolved: false };
|
|
444
448
|
}
|
|
445
449
|
|
|
446
|
-
const headRef = gitStrict(projectRoot, ["rev-parse", "HEAD"]);
|
|
450
|
+
const headRef = /** @type {string} */ (gitStrict(projectRoot, ["rev-parse", "HEAD"]));
|
|
447
451
|
const headResult = readRulesManifestFromRef(projectRoot, headRef);
|
|
448
452
|
const working = loadRulesManifest(projectRoot);
|
|
449
453
|
if (!working) {
|
|
@@ -478,6 +482,22 @@ function resolveRulesManifestPreMergeDrift(projectRoot) {
|
|
|
478
482
|
return { ok: true, resolved: true, action: "restored_head_for_lane_merge" };
|
|
479
483
|
}
|
|
480
484
|
|
|
485
|
+
/**
|
|
486
|
+
* Merge a lane task branch into the orch branch, auto-resolving known conflict
|
|
487
|
+
* classes (rules-manifest, adoption/PRD docs, out-of-scope dependency drift).
|
|
488
|
+
*
|
|
489
|
+
* @param {object} params
|
|
490
|
+
* @param {string} params.projectRoot
|
|
491
|
+
* @param {string} params.baseBranch
|
|
492
|
+
* @param {string} params.orchBranch
|
|
493
|
+
* @param {string} params.taskBranch
|
|
494
|
+
* @param {string} params.batchId
|
|
495
|
+
* @param {boolean} [params.requireLaneCommits] When true, task branch must be ahead of orch before merge (post lane auto-commit).
|
|
496
|
+
* @param {string[]} [params.laneFileScopePaths]
|
|
497
|
+
* @param {string[]} [params.laneTaskFolders]
|
|
498
|
+
* @param {number} [params.waveIndex]
|
|
499
|
+
* @returns {{ ok: true, mergeCommit: string, commitsAhead: number } | { ok: false, failureClass?: string, error: string, outOfScopePaths?: string[], skippedGitignoredPaths?: string[] }}
|
|
500
|
+
*/
|
|
481
501
|
export function mergeLaneToOrch({
|
|
482
502
|
projectRoot,
|
|
483
503
|
baseBranch,
|
|
@@ -501,7 +521,7 @@ export function mergeLaneToOrch({
|
|
|
501
521
|
};
|
|
502
522
|
}
|
|
503
523
|
|
|
504
|
-
const orchHeadBefore = gitStrict(projectRoot, ["rev-parse", orchBranch]);
|
|
524
|
+
const orchHeadBefore = /** @type {string} */ (gitStrict(projectRoot, ["rev-parse", orchBranch]));
|
|
505
525
|
const commitsAhead = countCommitsAhead(projectRoot, orchBranch, taskBranch);
|
|
506
526
|
|
|
507
527
|
if (Array.isArray(laneTaskFolders) && laneTaskFolders.length > 0) {
|
|
@@ -567,7 +587,7 @@ export function mergeLaneToOrch({
|
|
|
567
587
|
gitStrict(projectRoot, ["commit", "--no-edit"]);
|
|
568
588
|
}
|
|
569
589
|
|
|
570
|
-
const mergeCommit = gitStrict(projectRoot, ["rev-parse", "HEAD"]);
|
|
590
|
+
const mergeCommit = /** @type {string} */ (gitStrict(projectRoot, ["rev-parse", "HEAD"]));
|
|
571
591
|
|
|
572
592
|
if (requireLaneCommits && mergeCommit === orchHeadBefore) {
|
|
573
593
|
return {
|
|
@@ -605,9 +625,21 @@ export function mergeLaneToOrch({
|
|
|
605
625
|
}
|
|
606
626
|
|
|
607
627
|
/**
|
|
608
|
-
*
|
|
609
|
-
*
|
|
610
|
-
*
|
|
628
|
+
* Merge every succeeded lane of a wave into the orch branch, then run the
|
|
629
|
+
* optional `finalizeAfterWaveMerge(hookParams)` hook injected by callers that
|
|
630
|
+
* own the limbo graph (`maybeFinalizeAfterWaveMerge` from post-merge-limbo.mjs,
|
|
631
|
+
* SP-734). Omitted → skip post-wave-merge finalize.
|
|
632
|
+
*
|
|
633
|
+
* @param {object} params
|
|
634
|
+
* @param {string} params.projectRoot
|
|
635
|
+
* @param {Record<string, any>} params.state
|
|
636
|
+
* @param {string} params.batchId
|
|
637
|
+
* @param {string} params.baseBranch
|
|
638
|
+
* @param {string} params.orchBranch
|
|
639
|
+
* @param {number} params.waveIndex
|
|
640
|
+
* @param {boolean} [params.resumed]
|
|
641
|
+
* @param {((params: object) => unknown) | null} [params.finalizeAfterWaveMerge]
|
|
642
|
+
* @returns {{ ok: true, mergeCommit: string | null, finalized: boolean, finalizeResult: unknown } | { ok: false, error: string, laneNumber?: number, failureClass?: string | null, blockedBy?: string, exitReason?: string }}
|
|
611
643
|
*/
|
|
612
644
|
export function mergeWaveLanesToOrch({
|
|
613
645
|
projectRoot,
|
|
@@ -621,7 +653,7 @@ export function mergeWaveLanesToOrch({
|
|
|
621
653
|
}) {
|
|
622
654
|
const waveTaskIds = state.wavePlan?.[waveIndex] ?? [];
|
|
623
655
|
const needsReplanTask = (state.tasks ?? []).find(
|
|
624
|
-
(entry) =>
|
|
656
|
+
(/** @type {any} */ entry) =>
|
|
625
657
|
waveTaskIds.includes(entry?.taskId) && entry?.exitReason === "needs_replan",
|
|
626
658
|
);
|
|
627
659
|
if (needsReplanTask) {
|
|
@@ -639,8 +671,8 @@ export function mergeWaveLanesToOrch({
|
|
|
639
671
|
for (const lane of lanes) {
|
|
640
672
|
const laneNumber = lane.laneNumber;
|
|
641
673
|
const waveTaskIds = state.wavePlan?.[waveIndex] ?? [];
|
|
642
|
-
const laneSucceeded = waveTaskIds.some((taskId) => {
|
|
643
|
-
const task = (state.tasks ?? []).find((entry) => entry?.taskId === taskId);
|
|
674
|
+
const laneSucceeded = waveTaskIds.some((/** @type {any} */ taskId) => {
|
|
675
|
+
const task = (state.tasks ?? []).find((/** @type {any} */ entry) => entry?.taskId === taskId);
|
|
644
676
|
return task && task.laneNumber === laneNumber && task.status === "succeeded";
|
|
645
677
|
});
|
|
646
678
|
if (!laneSucceeded) continue;
|
|
@@ -648,8 +680,8 @@ export function mergeWaveLanesToOrch({
|
|
|
648
680
|
const taskBranch = lane.branch ?? laneTaskBranch(batchId, laneNumber);
|
|
649
681
|
const laneFileScopePaths = collectLaneWaveFileScope(state, laneNumber, waveTaskIds);
|
|
650
682
|
const laneTaskFolders = waveTaskIds
|
|
651
|
-
.map((taskId) => {
|
|
652
|
-
const task = (state.tasks ?? []).find((entry) => entry?.taskId === taskId);
|
|
683
|
+
.map((/** @type {any} */ taskId) => {
|
|
684
|
+
const task = (state.tasks ?? []).find((/** @type {any} */ entry) => entry?.taskId === taskId);
|
|
653
685
|
if (!task || task.laneNumber !== laneNumber || !task.taskFolder) return null;
|
|
654
686
|
return task.taskFolder;
|
|
655
687
|
})
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Orch→lane sync when satisfied deps share File Scope (FR-REL231-03 / #191).
|
|
4
3
|
*/
|
|
@@ -12,7 +11,7 @@ import { syncLaneWorktreeFromOrch } from "../worktree.mjs";
|
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* @param {string} projectRoot
|
|
15
|
-
* @param {
|
|
14
|
+
* @param {Record<string, any>} config
|
|
16
15
|
*/
|
|
17
16
|
function resolveBatchTasksRoot(projectRoot, config) {
|
|
18
17
|
return resolveTasksRootPath(projectRoot, config) ?? path.join(projectRoot, "spine-tasks");
|
|
@@ -21,7 +20,7 @@ function resolveBatchTasksRoot(projectRoot, config) {
|
|
|
21
20
|
/**
|
|
22
21
|
* @param {string} tasksRoot
|
|
23
22
|
* @param {string} taskId
|
|
24
|
-
* @param {
|
|
23
|
+
* @param {Array<Record<string, any>>} [stateTasks]
|
|
25
24
|
*/
|
|
26
25
|
function resolveTaskFolderPath(tasksRoot, taskId, stateTasks = []) {
|
|
27
26
|
const fromState = stateTasks.find((entry) => entry?.taskId === taskId)?.taskFolder;
|
|
@@ -38,10 +37,10 @@ function resolveTaskFolderPath(tasksRoot, taskId, stateTasks = []) {
|
|
|
38
37
|
*
|
|
39
38
|
* @param {object} params
|
|
40
39
|
* @param {string} params.projectRoot
|
|
41
|
-
* @param {
|
|
40
|
+
* @param {Record<string, any>} params.state
|
|
42
41
|
* @param {string} params.taskId
|
|
43
42
|
* @param {string[]} params.fileScopePaths
|
|
44
|
-
* @param {
|
|
43
|
+
* @param {Record<string, any>} [params.config]
|
|
45
44
|
* @returns {Array<{ depId: string, overlap: string[] }>}
|
|
46
45
|
*/
|
|
47
46
|
export function collectSharedScopeSatisfiedDeps({
|
|
@@ -54,7 +53,9 @@ export function collectSharedScopeSatisfiedDeps({
|
|
|
54
53
|
if (!Array.isArray(fileScopePaths) || fileScopePaths.length === 0) return [];
|
|
55
54
|
|
|
56
55
|
const tasksRoot = resolveBatchTasksRoot(projectRoot, config);
|
|
57
|
-
|
|
56
|
+
/** @type {{ tasks?: Record<string, string[]> }} */
|
|
57
|
+
const depsIndex = loadDependenciesJson(tasksRoot);
|
|
58
|
+
const deps = depsIndex.tasks?.[taskId] ?? [];
|
|
58
59
|
if (!Array.isArray(deps) || deps.length === 0) return [];
|
|
59
60
|
|
|
60
61
|
const scopeSet = new Set(fileScopePaths);
|
|
@@ -85,6 +86,12 @@ export function collectSharedScopeSatisfiedDeps({
|
|
|
85
86
|
|
|
86
87
|
/**
|
|
87
88
|
* @param {object} params
|
|
89
|
+
* @param {string} params.projectRoot
|
|
90
|
+
* @param {Record<string, any>} params.state
|
|
91
|
+
* @param {string} params.taskId
|
|
92
|
+
* @param {string[]} params.fileScopePaths
|
|
93
|
+
* @param {string} params.worktreePath
|
|
94
|
+
* @param {Record<string, any>} [params.config]
|
|
88
95
|
* @returns {{ ok: true, synced: boolean, skipped?: boolean, sharedDeps: Array<{ depId: string, overlap: string[] }>, headSha?: string } | { ok: false, error: string, sharedDeps: Array<{ depId: string, overlap: string[] }> }}
|
|
89
96
|
*/
|
|
90
97
|
export function ensureLaneSyncedForSharedScopeDeps({
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Batch phase transition helpers for the engine-lanes facade.
|
|
4
3
|
* Leaf module: journals phase changes without importing resume/limbo/reconcile.
|
|
@@ -19,7 +18,7 @@ function phaseTransitionEventType(fromPhase, toPhase) {
|
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
|
-
* @param {
|
|
21
|
+
* @param {{ projectRoot: string, batchId: string, fromPhase: string, toPhase: string, extra?: Record<string, unknown> }} params
|
|
23
22
|
*/
|
|
24
23
|
function recordPhaseTransition({ projectRoot, batchId, fromPhase, toPhase, extra = {} }) {
|
|
25
24
|
const type = phaseTransitionEventType(fromPhase, toPhase);
|
|
@@ -31,6 +30,13 @@ function recordPhaseTransition({ projectRoot, batchId, fromPhase, toPhase, extra
|
|
|
31
30
|
});
|
|
32
31
|
}
|
|
33
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Mutate `state.phase` and journal the transition (SP-770).
|
|
35
|
+
*
|
|
36
|
+
* @param {Record<string, any>} state Batch state mutated in place.
|
|
37
|
+
* @param {string} newPhase
|
|
38
|
+
* @param {{ projectRoot: string, batchId: string, extra?: Record<string, unknown> }} ctx
|
|
39
|
+
*/
|
|
34
40
|
export function transitionPhase(state, newPhase, ctx) {
|
|
35
41
|
const fromPhase = state.phase;
|
|
36
42
|
if (fromPhase === newPhase) return;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Lane queue and provisioning — build lane/task state from plan and handle
|
|
4
3
|
* per-lane task prep (file scope) plus skip-when-done-on-disk queue behavior.
|
|
@@ -20,20 +19,28 @@ import { laneTaskBranch, laneWorktreePath } from "../worktree.mjs";
|
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* @param {object} params
|
|
22
|
+
* @param {string} params.projectRoot
|
|
23
|
+
* @param {string} params.batchId
|
|
24
|
+
* @param {Record<string, any>} params.task
|
|
25
|
+
* @param {Record<string, any>} [params.config]
|
|
26
|
+
* @param {string} [params.taskFolder]
|
|
27
|
+
* @param {{ laneNumber?: number }} [params.lane]
|
|
23
28
|
*/
|
|
24
29
|
export function recordLaneTaskMetric({ projectRoot, batchId, task, config, taskFolder, lane }) {
|
|
25
|
-
|
|
30
|
+
const metricParams = {
|
|
26
31
|
projectRoot,
|
|
27
32
|
batchId,
|
|
28
33
|
task,
|
|
29
34
|
config,
|
|
30
35
|
taskFolder,
|
|
31
36
|
laneNumber: lane?.laneNumber ?? task?.laneNumber,
|
|
32
|
-
}
|
|
37
|
+
};
|
|
38
|
+
recordTaskTerminalMetric(metricParams);
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
/**
|
|
36
42
|
* @param {string} taskFolderPath
|
|
43
|
+
* @returns {{ ok: true, fileScopePaths: string[] } | { ok: false, error: string, errors?: string[], promptPath: string }}
|
|
37
44
|
*/
|
|
38
45
|
export function loadTaskFileScopePaths(taskFolderPath) {
|
|
39
46
|
try {
|
|
@@ -58,6 +65,15 @@ export function loadTaskFileScopePaths(taskFolderPath) {
|
|
|
58
65
|
|
|
59
66
|
/**
|
|
60
67
|
* @param {object} params
|
|
68
|
+
* @param {string} params.projectRoot
|
|
69
|
+
* @param {Record<string, any>} params.state
|
|
70
|
+
* @param {string} params.batchId
|
|
71
|
+
* @param {Record<string, any>} params.task
|
|
72
|
+
* @param {{ laneNumber?: number, laneId?: string }} params.lane
|
|
73
|
+
* @param {string} [params.laneCorrelationId]
|
|
74
|
+
* @param {{ ok: false, error: string, errors?: string[], promptPath?: string }} params.scopeResult
|
|
75
|
+
* @param {Record<string, any>} [params.config]
|
|
76
|
+
* @param {string} [params.taskFolderPath]
|
|
61
77
|
*/
|
|
62
78
|
export function recordPromptParseFailure({
|
|
63
79
|
projectRoot,
|
|
@@ -122,9 +138,15 @@ export function recordPromptParseFailure({
|
|
|
122
138
|
|
|
123
139
|
/**
|
|
124
140
|
* @param {object} params
|
|
141
|
+
* @param {any} params.plan
|
|
142
|
+
* @param {Array<{ taskId: string, folderPath?: string }>} params.discovered
|
|
143
|
+
* @param {string} params.projectRoot
|
|
144
|
+
* @param {string} params.batchId
|
|
145
|
+
* @param {number} params.maxLaneNumber
|
|
125
146
|
*/
|
|
126
147
|
export function buildTasksAndLanesFromPlan({ plan, discovered, projectRoot, batchId, maxLaneNumber }) {
|
|
127
148
|
const assignments = buildTaskLaneAssignments(plan);
|
|
149
|
+
/** @type {string[]} */
|
|
128
150
|
const taskIds = countPlanTasks(plan);
|
|
129
151
|
|
|
130
152
|
/** @type {Record<number, string[]>} */
|
|
@@ -166,6 +188,14 @@ export function buildTasksAndLanesFromPlan({ plan, discovered, projectRoot, batc
|
|
|
166
188
|
|
|
167
189
|
/**
|
|
168
190
|
* @param {object} params
|
|
191
|
+
* @param {string} params.projectRoot
|
|
192
|
+
* @param {Record<string, any>} params.state
|
|
193
|
+
* @param {string} params.batchId
|
|
194
|
+
* @param {Record<string, any>} params.task
|
|
195
|
+
* @param {{ laneNumber?: number, laneId?: string }} params.lane
|
|
196
|
+
* @param {string} params.taskFolderPath
|
|
197
|
+
* @param {string} [params.laneCorrelationId]
|
|
198
|
+
* @param {Record<string, any>} [params.config]
|
|
169
199
|
*/
|
|
170
200
|
export function skipTaskDoneOnDisk({
|
|
171
201
|
projectRoot,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Engine lane code review phase (SP-729 / #262).
|
|
4
3
|
*/
|
|
@@ -30,6 +29,13 @@ import {
|
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
31
|
* @param {object} params
|
|
32
|
+
* @param {string} params.taskFolder
|
|
33
|
+
* @param {string} params.worktreePath
|
|
34
|
+
* @param {Record<string, any>} [params.config]
|
|
35
|
+
* @param {number} [params.attempt]
|
|
36
|
+
* @param {Record<string, any>} [params.journal]
|
|
37
|
+
* @param {{ next: () => string } | null} [params.stubVerdicts]
|
|
38
|
+
* @returns {Promise<{ ok: boolean, [key: string]: any }>}
|
|
33
39
|
*/
|
|
34
40
|
export async function runEngineCodeReview({
|
|
35
41
|
taskFolder,
|
|
@@ -112,6 +118,17 @@ export async function runEngineCodeReview({
|
|
|
112
118
|
|
|
113
119
|
/**
|
|
114
120
|
* @param {object} params
|
|
121
|
+
* @param {string} params.projectRoot
|
|
122
|
+
* @param {Record<string, any>} params.state
|
|
123
|
+
* @param {string} params.batchId
|
|
124
|
+
* @param {Record<string, any>} params.task
|
|
125
|
+
* @param {Record<string, any>} params.lane
|
|
126
|
+
* @param {string} params.laneCorrelationId
|
|
127
|
+
* @param {string} params.exitReason
|
|
128
|
+
* @param {string|null} params.verdict
|
|
129
|
+
* @param {number} params.codeReviewAttempt
|
|
130
|
+
* @param {Record<string, any>} params.config
|
|
131
|
+
* @param {string} params.taskFolder
|
|
115
132
|
*/
|
|
116
133
|
function recordCodeReviewTaskFailure({
|
|
117
134
|
projectRoot,
|
|
@@ -154,7 +171,14 @@ function recordCodeReviewTaskFailure({
|
|
|
154
171
|
}
|
|
155
172
|
|
|
156
173
|
/**
|
|
157
|
-
*
|
|
174
|
+
* Params: projectRoot, state, batchId, config, task, lane,
|
|
175
|
+
* taskFolderInWorktree, wt, taskBranch, laneCorrelationId, fileScopePaths.
|
|
176
|
+
* Loosely typed because callers may forward a shared params bag
|
|
177
|
+
* (resume-lane-reviews.mjs) — same `Record<string, any>` pattern as
|
|
178
|
+
* state-guards.mjs.
|
|
179
|
+
*
|
|
180
|
+
* @param {Record<string, any>} params
|
|
181
|
+
* @returns {Promise<{ ok: boolean, [key: string]: any }>}
|
|
158
182
|
*/
|
|
159
183
|
export async function runCodeReviewPhase({
|
|
160
184
|
projectRoot,
|
|
@@ -205,7 +229,8 @@ export async function runCodeReviewPhase({
|
|
|
205
229
|
attemptField: "codeReviewAttempts",
|
|
206
230
|
attemptKey: "codeReviewAttempt",
|
|
207
231
|
maxAttempts: maxCodeReviewAttempts,
|
|
208
|
-
runEngineReview: (params) =>
|
|
232
|
+
runEngineReview: (params) =>
|
|
233
|
+
runEngineCodeReview(/** @type {any} */ ({ ...params, stubVerdicts })),
|
|
209
234
|
recordReviewTaskFailure: recordCodeReviewTaskFailure,
|
|
210
235
|
invalidVerdictOutput: "code review artifact missing APPROVE or REVISE verdict",
|
|
211
236
|
journalEvents,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Engine lane final review phase (SP-729 / #262).
|
|
4
3
|
*/
|
|
@@ -39,6 +38,14 @@ import {
|
|
|
39
38
|
|
|
40
39
|
/**
|
|
41
40
|
* @param {object} params
|
|
41
|
+
* @param {string} params.taskFolder
|
|
42
|
+
* @param {string} params.worktreePath
|
|
43
|
+
* @param {Record<string, any>} [params.config]
|
|
44
|
+
* @param {number} [params.attempt]
|
|
45
|
+
* @param {any} [params.contractVerifyResult]
|
|
46
|
+
* @param {Record<string, any>} [params.journal]
|
|
47
|
+
* @param {{ next: () => string } | null} [params.stubVerdicts]
|
|
48
|
+
* @returns {Promise<{ ok: boolean, [key: string]: any }>}
|
|
42
49
|
*/
|
|
43
50
|
export async function runEngineFinalReview({
|
|
44
51
|
taskFolder,
|
|
@@ -103,6 +110,15 @@ export async function runEngineFinalReview({
|
|
|
103
110
|
|
|
104
111
|
/**
|
|
105
112
|
* @param {object} params
|
|
113
|
+
* @param {string} params.projectRoot
|
|
114
|
+
* @param {Record<string, any>} params.state
|
|
115
|
+
* @param {string} params.batchId
|
|
116
|
+
* @param {Record<string, any>} params.task
|
|
117
|
+
* @param {Record<string, any>} params.lane
|
|
118
|
+
* @param {string} params.laneCorrelationId
|
|
119
|
+
* @param {any} params.contractVerifyResult
|
|
120
|
+
* @param {Record<string, any>} params.config
|
|
121
|
+
* @param {string} params.taskFolder
|
|
106
122
|
*/
|
|
107
123
|
function recordContractVerifyTaskFailure({
|
|
108
124
|
projectRoot,
|
|
@@ -153,6 +169,17 @@ function recordContractVerifyTaskFailure({
|
|
|
153
169
|
|
|
154
170
|
/**
|
|
155
171
|
* @param {object} params
|
|
172
|
+
* @param {string} params.projectRoot
|
|
173
|
+
* @param {Record<string, any>} params.state
|
|
174
|
+
* @param {string} params.batchId
|
|
175
|
+
* @param {Record<string, any>} params.task
|
|
176
|
+
* @param {Record<string, any>} params.lane
|
|
177
|
+
* @param {string} params.laneCorrelationId
|
|
178
|
+
* @param {string} params.exitReason
|
|
179
|
+
* @param {string|null} params.verdict
|
|
180
|
+
* @param {number} params.finalAttempt
|
|
181
|
+
* @param {Record<string, any>} params.config
|
|
182
|
+
* @param {string} params.taskFolder
|
|
156
183
|
*/
|
|
157
184
|
function recordFinalReviewTaskFailure({
|
|
158
185
|
projectRoot,
|
|
@@ -195,7 +222,15 @@ function recordFinalReviewTaskFailure({
|
|
|
195
222
|
}
|
|
196
223
|
|
|
197
224
|
/**
|
|
198
|
-
*
|
|
225
|
+
* Params: projectRoot, state, batchId, config, task, lane,
|
|
226
|
+
* taskFolderInWorktree, wt, taskBranch, laneCorrelationId, fileScopePaths,
|
|
227
|
+
* baseBranch.
|
|
228
|
+
* Loosely typed because callers may forward a shared params bag
|
|
229
|
+
* (resume-lane-reviews.mjs) — same `Record<string, any>` pattern as
|
|
230
|
+
* state-guards.mjs.
|
|
231
|
+
*
|
|
232
|
+
* @param {Record<string, any>} params
|
|
233
|
+
* @returns {Promise<{ ok: boolean, [key: string]: any }>}
|
|
199
234
|
*/
|
|
200
235
|
export async function runFinalReviewPhase({
|
|
201
236
|
projectRoot,
|
|
@@ -248,7 +283,8 @@ export async function runFinalReviewPhase({
|
|
|
248
283
|
attemptField: "finalAttempts",
|
|
249
284
|
attemptKey: "finalAttempt",
|
|
250
285
|
maxAttempts: maxFinalAttempts,
|
|
251
|
-
runEngineReview: (params) =>
|
|
286
|
+
runEngineReview: (params) =>
|
|
287
|
+
runEngineFinalReview(/** @type {any} */ ({ ...params, stubVerdicts })),
|
|
252
288
|
recordReviewTaskFailure: recordFinalReviewTaskFailure,
|
|
253
289
|
invalidVerdictOutput: "final review artifact missing PASS, REVISE, or REPLAN verdict",
|
|
254
290
|
allowReplan: true,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Engine lane plan review phase (SP-730 / #262).
|
|
4
3
|
*/
|
|
@@ -57,7 +56,7 @@ function findPlanReviewStepNumber(taskFolder) {
|
|
|
57
56
|
*
|
|
58
57
|
* @param {object} params
|
|
59
58
|
* @param {string} params.taskFolder
|
|
60
|
-
* @param {
|
|
59
|
+
* @param {Array<Record<string, any>>} [params.journalEvents]
|
|
61
60
|
* @param {string} [params.taskId]
|
|
62
61
|
* @returns {{ verdict: "APPROVE"|"REVISE", feedback: string, artifactPath: string, source: "journal"|"artifact" }|null}
|
|
63
62
|
*/
|
|
@@ -93,7 +92,9 @@ function findCompletedPlanReview({ taskFolder, journalEvents = [], taskId }) {
|
|
|
93
92
|
const { verdict, feedback } = parseReviewVerdict(reviewContent, { reviewType: "plan" });
|
|
94
93
|
if (verdict) {
|
|
95
94
|
const artifactMatch = {
|
|
96
|
-
verdict
|
|
95
|
+
// Narrowed by the `if (verdict)` guard above; parseReviewVerdict's
|
|
96
|
+
// union spans code/final verdicts, so cast to the plan verdict set.
|
|
97
|
+
verdict: /** @type {"APPROVE"|"REVISE"} */ (verdict),
|
|
97
98
|
feedback,
|
|
98
99
|
artifactPath: latestArtifact.artifactPath,
|
|
99
100
|
source: /** @type {"artifact"} */ ("artifact"),
|
|
@@ -113,6 +114,13 @@ function findCompletedPlanReview({ taskFolder, journalEvents = [], taskId }) {
|
|
|
113
114
|
* Uses agents.reviewer.plan pins via runStepReview → buildReviewerPiArgs (SP-695 / #250).
|
|
114
115
|
*
|
|
115
116
|
* @param {object} params
|
|
117
|
+
* @param {string} params.taskFolder
|
|
118
|
+
* @param {string} params.worktreePath
|
|
119
|
+
* @param {Record<string, any>} [params.config]
|
|
120
|
+
* @param {number} [params.attempt]
|
|
121
|
+
* @param {Record<string, any>} [params.journal]
|
|
122
|
+
* @param {{ next: () => string } | null} [params.stubVerdicts]
|
|
123
|
+
* @returns {Promise<{ ok: boolean, [key: string]: any }>}
|
|
116
124
|
*/
|
|
117
125
|
export async function runEnginePlanReview({
|
|
118
126
|
taskFolder,
|
|
@@ -195,6 +203,17 @@ export async function runEnginePlanReview({
|
|
|
195
203
|
|
|
196
204
|
/**
|
|
197
205
|
* @param {object} params
|
|
206
|
+
* @param {string} params.projectRoot
|
|
207
|
+
* @param {Record<string, any>} params.state
|
|
208
|
+
* @param {string} params.batchId
|
|
209
|
+
* @param {Record<string, any>} params.task
|
|
210
|
+
* @param {Record<string, any>} params.lane
|
|
211
|
+
* @param {string} params.laneCorrelationId
|
|
212
|
+
* @param {string} params.exitReason
|
|
213
|
+
* @param {string|null} params.verdict
|
|
214
|
+
* @param {number} params.planReviewAttempt
|
|
215
|
+
* @param {Record<string, any>} params.config
|
|
216
|
+
* @param {string} params.taskFolder
|
|
198
217
|
*/
|
|
199
218
|
function recordPlanReviewTaskFailure({
|
|
200
219
|
projectRoot,
|
|
@@ -242,7 +261,14 @@ function recordPlanReviewTaskFailure({
|
|
|
242
261
|
* existing plan artifact/journal verdict, rework loop on REVISE, fail-closed
|
|
243
262
|
* on exhaustion or invalid verdict.
|
|
244
263
|
*
|
|
245
|
-
*
|
|
264
|
+
* Params: projectRoot, state, batchId, config, task, lane,
|
|
265
|
+
* taskFolderInWorktree, wt, taskBranch, laneCorrelationId, fileScopePaths.
|
|
266
|
+
* Loosely typed because callers may forward a shared params bag
|
|
267
|
+
* (resume-lane-reviews.mjs) — same `Record<string, any>` pattern as
|
|
268
|
+
* state-guards.mjs.
|
|
269
|
+
*
|
|
270
|
+
* @param {Record<string, any>} params
|
|
271
|
+
* @returns {Promise<{ ok: boolean, [key: string]: any }>}
|
|
246
272
|
*/
|
|
247
273
|
export async function runPlanReviewPhase({
|
|
248
274
|
projectRoot,
|
|
@@ -296,7 +322,8 @@ export async function runPlanReviewPhase({
|
|
|
296
322
|
attemptField: "planReviewAttempts",
|
|
297
323
|
attemptKey: "planReviewAttempt",
|
|
298
324
|
maxAttempts: maxPlanReviewAttempts,
|
|
299
|
-
runEngineReview: (params) =>
|
|
325
|
+
runEngineReview: (params) =>
|
|
326
|
+
runEnginePlanReview(/** @type {any} */ ({ ...params, stubVerdicts })),
|
|
300
327
|
recordReviewTaskFailure: recordPlanReviewTaskFailure,
|
|
301
328
|
invalidVerdictOutput: "plan review artifact missing APPROVE or REVISE verdict",
|
|
302
329
|
journalEvents,
|