pi-spine 2.22.0 → 2.24.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.
@@ -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 {object} [config]
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 {object[]} [stateTasks]
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 {object} params.state
40
+ * @param {Record<string, any>} params.state
42
41
  * @param {string} params.taskId
43
42
  * @param {string[]} params.fileScopePaths
44
- * @param {object} [params.config]
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
- const deps = loadDependenciesJson(tasksRoot).tasks?.[taskId] ?? [];
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 {object} params
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
- recordTaskTerminalMetric({
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
- * @param {object} params
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) => runEngineCodeReview({ ...params, stubVerdicts }),
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
- * @param {object} params
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) => runEngineFinalReview({ ...params, stubVerdicts }),
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 {object[]} [params.journalEvents]
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
- * @param {object} params
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) => runEnginePlanReview({ ...params, stubVerdicts }),
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,
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Shared review poll-loop mechanics for the engine lane review phases
4
3
  * (SP-727 / #262). Extracted from review.mjs so the plan, code, and final
@@ -38,12 +37,12 @@ export function removeDoneFile(taskFolder) {
38
37
  * @param {object} params
39
38
  * @param {string} params.projectRoot
40
39
  * @param {string} params.batchId
41
- * @param {object} params.task
42
- * @param {object} params.lane
40
+ * @param {Record<string, any>} params.task
41
+ * @param {Record<string, any>} params.lane
43
42
  * @param {string} params.laneCorrelationId
44
43
  * @param {"plan"|"code"|"final"} params.reviewType
45
44
  * @param {number} params.reviewAttempt
46
- * @param {object} params.honored
45
+ * @param {Record<string, any>} params.honored
47
46
  * @param {"review.crash_recovered"|"review.skipped_fresh_artifact"|null} params.honorJournalEvent
48
47
  */
49
48
  export function appendReviewHonorJournalEvents({
@@ -105,6 +104,15 @@ export function appendReviewHonorJournalEvents({
105
104
  * @param {string} params.attemptField Task state field, e.g. "codeReviewAttempts".
106
105
  * @param {string} params.attemptKey Journal payload key, e.g. "codeReviewAttempt".
107
106
  * @param {Function} params.findCompletedReview ({ taskFolder, journalEvents, taskId }) => honored|null
107
+ * @param {string} params.projectRoot
108
+ * @param {Record<string, any>} params.state
109
+ * @param {string} params.batchId
110
+ * @param {Record<string, any>} params.task
111
+ * @param {Record<string, any>} params.lane
112
+ * @param {string} params.laneCorrelationId
113
+ * @param {string} params.taskFolder
114
+ * @param {Array<Record<string, any>>} params.journalEvents
115
+ * @returns {{ ok: boolean, [key: string]: any } | null}
108
116
  */
109
117
  export function honorCompletedReview({
110
118
  reviewType,
@@ -130,7 +138,9 @@ export function honorCompletedReview({
130
138
  const honorJournalEvent = resolveReviewHonorJournalEvent({
131
139
  journalEvents,
132
140
  taskId,
133
- reviewType,
141
+ // review-artifacts.mjs predates the plan phase and still narrows the
142
+ // JSDoc to "code"|"final"; its body treats all three types alike.
143
+ reviewType: /** @type {"code"|"final"} */ (reviewType),
134
144
  honorSource: honored.source,
135
145
  reviewAttempt,
136
146
  });
@@ -178,12 +188,25 @@ export function honorCompletedReview({
178
188
  * @param {string} params.attemptField Task state field, e.g. "codeReviewAttempts".
179
189
  * @param {string} params.attemptKey Journal payload key, e.g. "codeReviewAttempt".
180
190
  * @param {number} params.maxAttempts
181
- * @param {Function} params.runEngineReview Async engine review fn (e.g. runEngineCodeReview).
191
+ * @param {(reviewParams: Record<string, any>) => any} params.runEngineReview Async engine review fn (e.g. runEngineCodeReview).
182
192
  * @param {Function} params.recordReviewTaskFailure Phase-specific failure recorder.
183
193
  * @param {string} params.invalidVerdictOutput Output message for the invalid-verdict failure.
184
194
  * @param {boolean} [params.allowReplan] Final phase only: handle REPLAN as needs_replan.
185
- * @param {Function} [params.beforeReview] Async hook per iteration; returns
195
+ * @param {((hookParams: { attempt: number }) => Promise<{ abort?: any, extraReviewParams?: Record<string, any> } | undefined>) | null} [params.beforeReview] Async hook per iteration; returns
186
196
  * { abort: result } to stop the loop or { extraReviewParams: object } to continue.
197
+ * @param {Array<Record<string, any>>} params.journalEvents
198
+ * @param {string} params.projectRoot
199
+ * @param {Record<string, any>} params.state
200
+ * @param {string} params.batchId
201
+ * @param {Record<string, any>} params.config
202
+ * @param {Record<string, any>} params.task
203
+ * @param {Record<string, any>} params.lane
204
+ * @param {string} params.taskFolderInWorktree
205
+ * @param {string} params.wt
206
+ * @param {string} params.taskBranch
207
+ * @param {string} params.laneCorrelationId
208
+ * @param {string[]} params.fileScopePaths
209
+ * @returns {Promise<{ ok: boolean, [key: string]: any }>}
187
210
  */
188
211
  export async function runReviewPollLoop({
189
212
  reviewType,
@@ -355,7 +378,7 @@ export async function runReviewPollLoop({
355
378
  }
356
379
 
357
380
  removeDoneFile(taskFolderInWorktree);
358
- const reworkResult = await runWorker({
381
+ const reworkResult = /** @type {any} */ (await runWorker({
359
382
  worktreePath: wt,
360
383
  taskFolder: taskFolderInWorktree,
361
384
  projectRoot,
@@ -376,7 +399,7 @@ export async function runReviewPollLoop({
376
399
  saveSpineBatchState(projectRoot, state);
377
400
  }
378
401
  },
379
- });
402
+ }));
380
403
  if (!reworkResult.ok) {
381
404
  const aborted = reworkResult.classification === "aborted";
382
405
  task.status = aborted ? "aborted" : "failed";
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Engine lane review stub verdict queues (SP-728 / #262).
4
3
  *
@@ -69,7 +68,7 @@ export function createStubVerdictQueue({ queueValue, singleValue, normalize, def
69
68
  * @param {string} params.singleEnv Env var holding the single-verdict fallback.
70
69
  * @param {(raw: string) => string|null} params.normalize Verdict normalizer.
71
70
  * @param {string} params.defaultVerdict Fallback when nothing else resolves.
72
- * @param {NodeJS.ProcessEnv} [env]
71
+ * @param {NodeJS.ProcessEnv} [params.env]
73
72
  */
74
73
  export function createStubVerdictQueueFromEnv({
75
74
  queueEnv,
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Engine lane review-phase coordinator — re-exports phase modules (SP-729/730 / #262).
4
3
  */
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Lane task execution facade — re-exports split modules and phase transitions.
4
3
  *
@@ -90,6 +89,22 @@ export { runMatrixTaskOnLane, runMatrixSubLane } from "./engine-lanes/matrix-run
90
89
 
91
90
  export { transitionPhase } from "./engine-lanes/phase.mjs";
92
91
 
92
+ /**
93
+ * Run one task on its lane: file-scope load, matrix fan-out, or the single
94
+ * worker path (SP-770 typing).
95
+ *
96
+ * @param {object} params
97
+ * @param {string} params.projectRoot
98
+ * @param {Record<string, any>} params.state
99
+ * @param {string} params.batchId
100
+ * @param {string} [params.baseBranch]
101
+ * @param {Record<string, any>} params.config
102
+ * @param {Record<string, any>} params.task
103
+ * @param {Record<string, any>} params.lane
104
+ * @param {string} params.taskFolderRel
105
+ * @param {string} params.laneCorrelationId
106
+ * @returns {Promise<{ ok: boolean, [key: string]: any }>}
107
+ */
93
108
  export async function runTaskOnLane({
94
109
  projectRoot,
95
110
  state,
@@ -125,7 +140,8 @@ export async function runTaskOnLane({
125
140
  // global in-flight workers never exceed `lanes.maxParallel`.
126
141
  const matrixRows = loadMatrixTaskRows(path.join(projectRoot, taskFolderRel));
127
142
  if (matrixRows) {
128
- return runMatrixTaskOnLane({
143
+ /** @type {{ maxParallel: number } & Record<string, any>} */
144
+ const matrixParams = {
129
145
  projectRoot,
130
146
  state,
131
147
  batchId,
@@ -138,7 +154,8 @@ export async function runTaskOnLane({
138
154
  fileScopePaths,
139
155
  matrix: matrixRows,
140
156
  maxParallel: config?.lanes?.maxParallel ?? 1,
141
- });
157
+ };
158
+ return runMatrixTaskOnLane(matrixParams);
142
159
  }
143
160
 
144
161
  const laneSlot = await acquireLaneSlot(state, config?.lanes?.maxParallel ?? 1);
@@ -165,6 +182,17 @@ export async function runTaskOnLane({
165
182
  * for the duration of this call.
166
183
  *
167
184
  * @param {object} params
185
+ * @param {string} params.projectRoot
186
+ * @param {Record<string, any>} params.state
187
+ * @param {string} params.batchId
188
+ * @param {string} [params.baseBranch]
189
+ * @param {Record<string, any>} params.config
190
+ * @param {Record<string, any>} params.task
191
+ * @param {Record<string, any>} params.lane
192
+ * @param {string} params.taskFolderRel
193
+ * @param {string} params.laneCorrelationId
194
+ * @param {string[]} params.fileScopePaths
195
+ * @returns {Promise<{ ok: boolean, [key: string]: any }>}
168
196
  */
169
197
  async function runNonMatrixTaskOnLane({
170
198
  projectRoot,
@@ -256,7 +284,7 @@ async function runNonMatrixTaskOnLane({
256
284
  correlationId: laneCorrelationId,
257
285
  });
258
286
 
259
- const workerResult = await runWorker({
287
+ const workerResult = /** @type {any} */ (await runWorker({
260
288
  worktreePath: wt,
261
289
  taskFolder: taskFolderInWorktree,
262
290
  projectRoot,
@@ -277,7 +305,7 @@ async function runNonMatrixTaskOnLane({
277
305
  saveEngineBatchState(projectRoot, state);
278
306
  }
279
307
  },
280
- });
308
+ }));
281
309
 
282
310
  if (!workerResult.ok) {
283
311
  const doneOnDisk = fs.existsSync(path.join(taskFolderInWorktree, ".DONE"));