pi-spine 2.1.0 → 2.3.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.
Files changed (49) hide show
  1. package/bin/spine-batch.mjs +74 -5
  2. package/bin/spine-cli/verify.mjs +2 -18
  3. package/package.json +1 -1
  4. package/src/batch/attached-runner-promote.mjs +370 -0
  5. package/src/batch/attached-runner-reconcile.mjs +291 -0
  6. package/src/batch/attached-runner.mjs +24 -634
  7. package/src/batch/batch-guards.mjs +69 -0
  8. package/src/batch/contract-exec.mjs +483 -0
  9. package/src/batch/contract-parse.mjs +243 -0
  10. package/src/batch/contract-verify.mjs +32 -707
  11. package/src/batch/detached-diagnostics.mjs +255 -0
  12. package/src/batch/detached-run.mjs +326 -0
  13. package/src/batch/detached-start.mjs +18 -894
  14. package/src/batch/detached-wait.mjs +346 -0
  15. package/src/batch/engine-lanes/merge.mjs +25 -0
  16. package/src/batch/engine.mjs +8 -67
  17. package/src/batch/integrate-git.mjs +21 -0
  18. package/src/batch/integrate.mjs +5 -15
  19. package/src/batch/journal-rebuild-structural.mjs +352 -0
  20. package/src/batch/journal-rebuild.mjs +94 -347
  21. package/src/batch/lane-dirty-check-commit.mjs +361 -0
  22. package/src/batch/lane-dirty-check-git.mjs +298 -0
  23. package/src/batch/lane-dirty-check.mjs +31 -297
  24. package/src/batch/reconcile-batch.mjs +483 -0
  25. package/src/batch/reconcile-classify.mjs +433 -0
  26. package/src/batch/reconcile-diagnosis.mjs +459 -0
  27. package/src/batch/reconcile-light-cache.mjs +61 -0
  28. package/src/batch/reconcile-orphan.mjs +198 -0
  29. package/src/batch/reconcile.mjs +19 -1693
  30. package/src/batch/resume-multi-lanes.mjs +44 -149
  31. package/src/batch/resume-multi-queue.mjs +159 -0
  32. package/src/batch/resume-single-validate.mjs +25 -0
  33. package/src/batch/resume.mjs +3 -20
  34. package/src/batch/review-artifacts.mjs +419 -0
  35. package/src/batch/review-step-run.mjs +383 -0
  36. package/src/batch/review-step.mjs +451 -0
  37. package/src/batch/review.mjs +32 -1199
  38. package/src/batch/salvage-batch-list.mjs +291 -0
  39. package/src/batch/salvage-batch.mjs +417 -0
  40. package/src/batch/sequence-plan.mjs +234 -0
  41. package/src/batch/sequence-run.mjs +418 -0
  42. package/src/batch/sequence-wait.mjs +167 -0
  43. package/src/batch/sequence.mjs +22 -783
  44. package/src/batch/state-guards.mjs +284 -0
  45. package/src/batch/state-io.mjs +135 -0
  46. package/src/batch/state.mjs +27 -396
  47. package/src/batch/worker-heartbeat.mjs +375 -0
  48. package/src/batch/worker-host.mjs +50 -541
  49. package/src/batch/worker-spawn.mjs +315 -0
@@ -1,33 +1,26 @@
1
1
  // @ts-nocheck
2
2
  /**
3
- * Step review spawn + verdict parsing (FR-REV, GAP-REV-01).
3
+ * Review module facade — re-exports artifact, spawn, step, and shared APIs.
4
+ * SP-579/SP-597 strangler split; keep imports on ./review.mjs stable.
4
5
  */
5
6
 
6
- import fs from "node:fs";
7
- import path from "node:path";
8
- import { fileURLToPath } from "node:url";
9
- import { detectOrphanedReviewStarted } from "./journal-rebuild.mjs";
10
- import { appendJournalEvent, readJournalEvents } from "./journal.mjs";
11
- import { loadSpineBatchState } from "./state.mjs";
12
- import { buildReviewerContext } from "../config/reviewer-context.mjs";
13
- import { resolveReviewScopePaths } from "./review-scope.mjs";
14
- import { commandExists as pathCommandExists } from "../util/command-exists.mjs";
15
- import {
16
- ARTIFACT_READY_HONOR_REASON,
17
- NESTED_REVIEW_SPAWN_BLOCKED,
18
- NESTED_REVIEW_SPAWN_REASON,
19
- REVIEW_SPAWN_TIMEOUT_EXIT_CODE,
20
- shouldBlockNestedReviewerSpawn,
21
- spawnReviewerPi,
22
- } from "./review-spawn.mjs";
23
- import {
24
- buildFinalReviewArtifactPath,
25
- buildReviewArtifactPath,
26
- isReviewTypeRequired,
27
- normalizeVerdict,
28
- parseReviewLevel,
29
- parseReviewVerdict,
30
- } from "./review-shared.mjs";
7
+ export {
8
+ buildReviewHonorHeadlineSuffix,
9
+ findCodeReviewStepNumber,
10
+ findCompletedCodeReview,
11
+ findCompletedFinalReview,
12
+ findFinalReviewStepNumber,
13
+ findLatestFinalReviewArtifact,
14
+ findLatestReviewHonorSignal,
15
+ findLatestStepReviewArtifact,
16
+ hasReviewSpawnFailureForHonor,
17
+ isRetryReconcileFreshReview,
18
+ readReviewLevel,
19
+ resolveReviewHonorJournalEvent,
20
+ resolveReviewPassKind,
21
+ REVIEW_HONOR_JOURNAL_EVENTS,
22
+ shouldEmitReviewResumed,
23
+ } from "./review-artifacts.mjs";
31
24
 
32
25
  export {
33
26
  REVIEW_LEVEL_RE,
@@ -38,9 +31,6 @@ export {
38
31
  parseReviewVerdict,
39
32
  } from "./review-shared.mjs";
40
33
 
41
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
42
- const PACKAGE_ROOT = path.resolve(__dirname, "../..");
43
-
44
34
  export {
45
35
  DEFAULT_REVIEW_SPAWN_TIMEOUT_MS,
46
36
  ARTIFACT_READY_HONOR_REASON,
@@ -52,1173 +42,16 @@ export {
52
42
  shouldBlockNestedReviewerSpawn,
53
43
  } from "./review-spawn.mjs";
54
44
 
55
- /**
56
- * @param {string} taskFolder
57
- */
58
- export function readReviewLevel(taskFolder) {
59
- const promptPath = path.join(taskFolder, "PROMPT.md");
60
- if (!fs.existsSync(promptPath)) return 0;
61
- return parseReviewLevel(fs.readFileSync(promptPath, "utf-8"));
62
- }
63
-
64
- /**
65
- * Highest numbered ### Step N heading in PROMPT.md (defaults to 1).
66
- * @param {string} taskFolder
67
- */
68
- export function findFinalReviewStepNumber(taskFolder) {
69
- const promptPath = path.join(taskFolder, "PROMPT.md");
70
- if (!fs.existsSync(promptPath)) return 1;
71
- const content = fs.readFileSync(promptPath, "utf-8");
72
- const matches = [...content.matchAll(/###\s+Step\s+(\d+)/g)];
73
- if (matches.length === 0) return 1;
74
- return Math.max(...matches.map((match) => Number(match[1])));
75
- }
76
-
77
- /**
78
- * Step number containing a code review checkpoint blockquote, else highest step.
79
- * @param {string} taskFolder
80
- */
81
- export function findCodeReviewStepNumber(taskFolder) {
82
- const promptPath = path.join(taskFolder, "PROMPT.md");
83
- if (!fs.existsSync(promptPath)) return findFinalReviewStepNumber(taskFolder);
84
- const content = fs.readFileSync(promptPath, "utf-8");
85
- const stepBlocks = [...content.matchAll(/###\s+Step\s+(\d+)[:\s][\s\S]*?(?=###\s+Step\s+\d+|$)/g)];
86
- for (const match of stepBlocks) {
87
- if (/code\s+review\s+checkpoint/i.test(match[0])) {
88
- return Number(match[1]);
89
- }
90
- }
91
- return findFinalReviewStepNumber(taskFolder);
92
- }
93
-
94
- /**
95
- * Latest `.reviews/{stepNumber}-*.md` by mtime, if any.
96
- * @param {string} taskFolder
97
- * @param {number} stepNumber
98
- * @returns {{ artifactPath: string, mtimeMs: number }|null}
99
- */
100
- export function findLatestStepReviewArtifact(taskFolder, stepNumber) {
101
- const reviewsDir = path.join(taskFolder, ".reviews");
102
- if (!fs.existsSync(reviewsDir)) return null;
103
- const prefix = `${stepNumber}-`;
104
- const candidates = fs
105
- .readdirSync(reviewsDir)
106
- .filter((name) => name.startsWith(prefix) && name.endsWith(".md"))
107
- .map((name) => {
108
- const artifactPath = path.join(reviewsDir, name);
109
- return { artifactPath, mtimeMs: fs.statSync(artifactPath).mtimeMs };
110
- })
111
- .sort((left, right) => right.mtimeMs - left.mtimeMs);
112
- return candidates[0] ?? null;
113
- }
114
-
115
- /**
116
- * Resolve an existing worker or lane code review from journal and/or artifacts.
117
- *
118
- * @param {object} params
119
- * @param {string} params.taskFolder
120
- * @param {object[]} [params.journalEvents]
121
- * @param {string} [params.taskId]
122
- * @returns {{ verdict: "APPROVE"|"REVISE", feedback: string, artifactPath: string, source: "journal"|"artifact" }|null}
123
- */
124
- export function findCompletedCodeReview({ taskFolder, journalEvents = [], taskId }) {
125
- /** @type {{ verdict: "APPROVE"|"REVISE", feedback: string, artifactPath: string, source: "journal"|"artifact", seq: number }|null} */
126
- let journalMatch = null;
127
- for (let index = 0; index < journalEvents.length; index += 1) {
128
- const event = journalEvents[index];
129
- if (taskId && event.taskId !== taskId) continue;
130
- if (event.type !== "review.completed") continue;
131
- const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
132
- if (payload.reviewType !== "code") continue;
133
- const verdict = normalizeVerdict(payload.verdict, "code");
134
- if (!verdict) continue;
135
- journalMatch = {
136
- verdict,
137
- feedback: typeof payload.feedback === "string" ? payload.feedback : "",
138
- artifactPath: typeof payload.artifactPath === "string" ? payload.artifactPath : "",
139
- source: "journal",
140
- seq: index,
141
- };
142
- }
143
-
144
- if (journalMatch?.verdict === "APPROVE") {
145
- const { seq: _seq, ...result } = journalMatch;
146
- return result;
147
- }
148
-
149
- const stepNumber = findCodeReviewStepNumber(taskFolder);
150
- const latestArtifact = findLatestStepReviewArtifact(taskFolder, stepNumber);
151
- if (latestArtifact) {
152
- const reviewContent = fs.readFileSync(latestArtifact.artifactPath, "utf-8");
153
- const { verdict, feedback } = parseReviewVerdict(reviewContent, { reviewType: "code" });
154
- if (verdict) {
155
- const artifactMatch = {
156
- verdict,
157
- feedback,
158
- artifactPath: latestArtifact.artifactPath,
159
- source: /** @type {"artifact"} */ ("artifact"),
160
- };
161
- if (verdict === "APPROVE") return artifactMatch;
162
- if (!journalMatch) return artifactMatch;
163
- }
164
- }
165
-
166
- if (!journalMatch) return null;
167
- const { seq: _seq, ...result } = journalMatch;
168
- return result;
169
- }
170
-
171
- /** Journal honor events emitted when honoring a completed review artifact. */
172
- export const REVIEW_HONOR_JOURNAL_EVENTS = {
173
- crashRecovered: "review.crash_recovered",
174
- skippedFreshArtifact: "review.skipped_fresh_artifact",
175
- resumed: "review.resumed",
176
- };
177
-
178
- /**
179
- * True when operator retry or reconcile re-enters review with a still-valid prior verdict.
180
- *
181
- * @param {object} params
182
- * @param {object[]} params.journalEvents
183
- * @param {string} params.taskId
184
- * @param {"code"|"final"} params.reviewType
185
- * @param {"journal"|"artifact"} [params.honorSource]
186
- */
187
- export function isRetryReconcileFreshReview({
188
- journalEvents = [],
189
- taskId,
190
- reviewType,
191
- honorSource,
192
- }) {
193
- let lastReviewCompletedIndex = -1;
194
- let lastRetryIndex = -1;
195
- let lastReconciledCompleteIndex = -1;
196
-
197
- for (let index = 0; index < journalEvents.length; index += 1) {
198
- const event = journalEvents[index];
199
- const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
200
- const eventTaskId = event.taskId ?? payload.taskId;
201
- if (eventTaskId !== taskId) continue;
202
-
203
- if (event.type === "review.completed" && payload.reviewType === reviewType) {
204
- lastReviewCompletedIndex = index;
205
- }
206
- if (event.type === "task.retry_requested") {
207
- lastRetryIndex = index;
208
- }
209
- if (
210
- event.type === "task.completed" &&
211
- (payload.reconcileReason === "done_in_lane_terminal" || payload.reconciled === true)
212
- ) {
213
- lastReconciledCompleteIndex = index;
214
- }
215
- }
216
-
217
- if (lastReviewCompletedIndex < 0) {
218
- return false;
219
- }
220
- if (lastRetryIndex > lastReviewCompletedIndex) {
221
- return true;
222
- }
223
- if (honorSource === "journal" && lastReconciledCompleteIndex > lastReviewCompletedIndex) {
224
- return true;
225
- }
226
- return false;
227
- }
228
-
229
- /**
230
- * True when journal shows a review spawn crash/failure that warrants crash_recovered.
231
- *
232
- * @param {object} params
233
- * @param {object[]} params.journalEvents
234
- * @param {string} params.taskId
235
- * @param {"code"|"final"} params.reviewType
236
- */
237
- export function hasReviewSpawnFailureForHonor({ journalEvents = [], taskId, reviewType }) {
238
- const orphaned = detectOrphanedReviewStarted(journalEvents);
239
- for (const event of orphaned) {
240
- const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
241
- const eventTaskId = event.taskId ?? payload.taskId;
242
- if (eventTaskId === taskId && payload.reviewType === reviewType) {
243
- return true;
244
- }
245
- }
246
-
247
- for (let index = journalEvents.length - 1; index >= 0; index -= 1) {
248
- const event = journalEvents[index];
249
- const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
250
- const eventTaskId = event.taskId ?? payload.taskId;
251
- if (eventTaskId !== taskId) continue;
252
-
253
- if (event.type === "review.failed") {
254
- if (payload.reviewType !== reviewType) continue;
255
- if (payload.reason === NESTED_REVIEW_SPAWN_REASON) continue;
256
- return true;
257
- }
258
- if (event.type === "review.completed" && payload.reviewType === reviewType) {
259
- break;
260
- }
261
- }
262
- return false;
263
- }
264
-
265
- /**
266
- * Resolve explicit journal event for honoring a completed review artifact.
267
- *
268
- * @param {object} params
269
- * @param {object[]} params.journalEvents
270
- * @param {string} params.taskId
271
- * @param {"code"|"final"} params.reviewType
272
- * @param {"journal"|"artifact"} [params.honorSource]
273
- * @param {number} [params.reviewAttempt]
274
- * @returns {"review.crash_recovered"|"review.skipped_fresh_artifact"|null}
275
- */
276
- export function resolveReviewHonorJournalEvent({
277
- journalEvents = [],
278
- taskId,
279
- reviewType,
280
- honorSource,
281
- reviewAttempt = 0,
282
- }) {
283
- if (
284
- isRetryReconcileFreshReview({ journalEvents, taskId, reviewType, honorSource }) &&
285
- !hasReviewSpawnFailureForHonor({ journalEvents, taskId, reviewType })
286
- ) {
287
- return REVIEW_HONOR_JOURNAL_EVENTS.skippedFreshArtifact;
288
- }
289
- if (hasReviewSpawnFailureForHonor({ journalEvents, taskId, reviewType })) {
290
- return REVIEW_HONOR_JOURNAL_EVENTS.crashRecovered;
291
- }
292
- if (reviewAttempt > 0) {
293
- return REVIEW_HONOR_JOURNAL_EVENTS.crashRecovered;
294
- }
295
- return null;
296
- }
297
-
298
- /**
299
- * Map honor journal event to task.verdict_recorded reviewPassKind.
300
- *
301
- * @param {"review.crash_recovered"|"review.skipped_fresh_artifact"|null} honorJournalEvent
302
- * @returns {"recovered"|"fresh_skip"|"normal"}
303
- */
304
- export function resolveReviewPassKind(honorJournalEvent) {
305
- if (honorJournalEvent === REVIEW_HONOR_JOURNAL_EVENTS.crashRecovered) {
306
- return "recovered";
307
- }
308
- if (honorJournalEvent === REVIEW_HONOR_JOURNAL_EVENTS.skippedFreshArtifact) {
309
- return "fresh_skip";
310
- }
311
- return "normal";
312
- }
313
-
314
- /**
315
- * True when review should emit review.resumed before spawning after operator retry.
316
- *
317
- * @param {object} params
318
- * @param {object[]} params.journalEvents
319
- * @param {string} params.taskId
320
- */
321
- export function shouldEmitReviewResumed({ journalEvents = [], taskId }) {
322
- for (let index = journalEvents.length - 1; index >= 0; index -= 1) {
323
- const event = journalEvents[index];
324
- if (event.type !== "task.retry_requested") continue;
325
- const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
326
- const eventTaskId = event.taskId ?? payload.taskId;
327
- if (eventTaskId === taskId) {
328
- return true;
329
- }
330
- }
331
- return false;
332
- }
333
-
334
- /**
335
- * Latest review honor/resume signal for diagnose and dashboard surfaces.
336
- *
337
- * @param {object[]} journalEvents
338
- * @param {string|null} [activeTaskId]
339
- * @returns {{ taskId: string, reviewType: string, kind: string, honorSource?: string, reviewPassKind?: string }|null}
340
- */
341
- export function findLatestReviewHonorSignal(journalEvents, activeTaskId = null) {
342
- const honorTypes = new Set([
343
- REVIEW_HONOR_JOURNAL_EVENTS.crashRecovered,
344
- REVIEW_HONOR_JOURNAL_EVENTS.skippedFreshArtifact,
345
- REVIEW_HONOR_JOURNAL_EVENTS.resumed,
346
- ]);
347
-
348
- for (let index = journalEvents.length - 1; index >= 0; index -= 1) {
349
- const event = journalEvents[index];
350
- if (!honorTypes.has(event.type)) continue;
351
- const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
352
- const taskId = event.taskId ?? payload.taskId;
353
- if (!taskId) continue;
354
- if (activeTaskId && taskId !== activeTaskId) continue;
355
- return {
356
- taskId,
357
- reviewType: payload.reviewType,
358
- kind: event.type,
359
- honorSource: payload.honorSource,
360
- reviewPassKind: payload.reviewPassKind,
361
- };
362
- }
363
- return null;
364
- }
365
-
366
- /**
367
- * @param {object|null|undefined} reviewHonorSignal
368
- * @returns {string|null}
369
- */
370
- export function buildReviewHonorHeadlineSuffix(reviewHonorSignal) {
371
- if (!reviewHonorSignal?.kind) return null;
372
- const reviewLabel =
373
- reviewHonorSignal.reviewType === "final" ? "final review" : "code review";
374
- if (reviewHonorSignal.kind === "review.crash_recovered") {
375
- return `recovered ${reviewLabel} crash — prior verdict honored from ${reviewHonorSignal.honorSource ?? "artifact"}`;
376
- }
377
- if (reviewHonorSignal.kind === "review.skipped_fresh_artifact") {
378
- return `skipped redundant ${reviewLabel} — fresh artifact honored`;
379
- }
380
- if (reviewHonorSignal.kind === "review.resumed") {
381
- return `${reviewLabel} resumed after operator retry`;
382
- }
383
- return null;
384
- }
385
-
386
- /**
387
- * Latest `.reviews/final-*.md` by mtime, if any.
388
- * @param {string} taskFolder
389
- * @returns {{ artifactPath: string, mtimeMs: number }|null}
390
- */
391
- export function findLatestFinalReviewArtifact(taskFolder) {
392
- const reviewsDir = path.join(taskFolder, ".reviews");
393
- if (!fs.existsSync(reviewsDir)) return null;
394
-
395
- const candidates = fs
396
- .readdirSync(reviewsDir)
397
- .filter((name) => name.startsWith("final-") && name.endsWith(".md"))
398
- .map((name) => {
399
- const artifactPath = path.join(reviewsDir, name);
400
- return { artifactPath, mtimeMs: fs.statSync(artifactPath).mtimeMs };
401
- })
402
- .sort((left, right) => right.mtimeMs - left.mtimeMs);
403
-
404
- return candidates[0] ?? null;
405
- }
406
-
407
- /**
408
- * Resolve an existing worker or lane final review from journal and/or artifacts.
409
- * Honors PASS from journal `review.completed` or latest final artifact.
410
- *
411
- * @param {object} params
412
- * @param {string} params.taskFolder
413
- * @param {object[]} [params.journalEvents]
414
- * @param {string} [params.taskId]
415
- * @returns {{ verdict: "PASS"|"REVISE"|"REPLAN", feedback: string, artifactPath: string, source: "journal"|"artifact" }|null}
416
- */
417
- export function findCompletedFinalReview({ taskFolder, journalEvents = [], taskId }) {
418
- /** @type {{ verdict: "PASS"|"REVISE"|"REPLAN", feedback: string, artifactPath: string, source: "journal"|"artifact", seq: number }|null} */
419
- let journalMatch = null;
420
- for (let index = 0; index < journalEvents.length; index += 1) {
421
- const event = journalEvents[index];
422
- if (taskId && event.taskId !== taskId) continue;
423
- if (event.type !== "review.completed") continue;
424
- const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
425
- if (payload.reviewType !== "final") continue;
426
- const verdict = normalizeVerdict(payload.verdict, "final");
427
- if (!verdict) continue;
428
- journalMatch = {
429
- verdict,
430
- feedback: typeof payload.feedback === "string" ? payload.feedback : "",
431
- artifactPath: typeof payload.artifactPath === "string" ? payload.artifactPath : "",
432
- source: "journal",
433
- seq: index,
434
- };
435
- }
436
-
437
- if (journalMatch?.verdict === "PASS") {
438
- const { seq: _seq, ...result } = journalMatch;
439
- return result;
440
- }
441
-
442
- const latestArtifact = findLatestFinalReviewArtifact(taskFolder);
443
- if (latestArtifact) {
444
- const reviewContent = fs.readFileSync(latestArtifact.artifactPath, "utf-8");
445
- const { verdict, feedback } = parseReviewVerdict(reviewContent, { reviewType: "final" });
446
- if (verdict) {
447
- const artifactMatch = {
448
- verdict,
449
- feedback,
450
- artifactPath: latestArtifact.artifactPath,
451
- source: /** @type {"artifact"} */ ("artifact"),
452
- };
453
- if (verdict === "PASS") return artifactMatch;
454
- if (!journalMatch) return artifactMatch;
455
- }
456
- }
457
-
458
- if (!journalMatch) return null;
459
- const { seq: _seq, ...result } = journalMatch;
460
- return result;
461
- }
462
-
463
- /**
464
- * @param {string} worktreePath
465
- */
466
- export function loadReviewerPrompt(worktreePath) {
467
- const candidates = [
468
- path.join(worktreePath, ".spine", "agents", "reviewer.md"),
469
- path.join(PACKAGE_ROOT, "templates", "agents", "reviewer.md"),
470
- ];
471
- for (const candidate of candidates) {
472
- if (!fs.existsSync(candidate)) continue;
473
- const raw = fs.readFileSync(candidate, "utf-8");
474
- const fmEnd = raw.indexOf("---", 4);
475
- if (fmEnd > 0) return raw.slice(fmEnd + 3).trim();
476
- return raw.trim();
477
- }
478
- return "You are a code reviewer. Write your review to the specified output file.";
479
- }
480
-
481
- /**
482
- * Base reviewer agent prompt plus auto-selected Cursor rules (system prompt only).
483
- *
484
- * @param {object} params
485
- * @param {string} params.worktreePath
486
- * @param {string} params.taskFolder
487
- * @param {"plan"|"code"|"final"} params.reviewType
488
- * @param {string} [params.baseline]
489
- * @param {object} [params.config]
490
- * @param {object} [params.journal]
491
- */
492
- export function buildReviewerSystemPrompt({
493
- worktreePath,
494
- taskFolder,
495
- reviewType,
496
- baseline,
497
- config = {},
498
- journal,
499
- }) {
500
- let systemPrompt = loadReviewerPrompt(worktreePath);
501
- const { scopePaths } = resolveReviewScopePaths({
502
- worktreePath,
503
- baseline,
504
- reviewType,
505
- taskFolder,
506
- });
507
- const reviewerContext = buildReviewerContext({
508
- projectRoot: journal?.projectRoot ?? worktreePath ?? process.cwd(),
509
- config,
510
- reviewType,
511
- scopePaths,
512
- journal,
513
- });
514
- if (reviewerContext.text) {
515
- systemPrompt = `${systemPrompt}${reviewerContext.text}`;
516
- }
517
- return systemPrompt;
518
- }
519
-
520
- /**
521
- * @param {string} cmd
522
- */
523
- export function commandExists(cmd) {
524
- if (process.env.SPINE_REVIEW_TEST_NO_PI === "1") return false;
525
- return pathCommandExists(cmd);
526
- }
527
-
528
- /**
529
- * @param {object} params
530
- */
531
- export function buildReviewRequest({
532
- reviewType,
533
- stepNumber,
534
- stepName,
535
- taskFolder,
536
- worktreePath,
537
- outputPath,
538
- baseline,
539
- projectName = "project",
540
- contractVerifyResult = null,
541
- }) {
542
- const promptPath = path.join(taskFolder, "PROMPT.md");
543
- const statusPath = path.join(taskFolder, "STATUS.md");
544
- if (reviewType === "final") {
545
- const contractLines =
546
- contractVerifyResult && Array.isArray(contractVerifyResult.checks)
547
- ? [
548
- "",
549
- "## Contract verification",
550
- `Machine verifier: ${contractVerifyResult.ok ? "PASS" : "FAIL"}`,
551
- ...contractVerifyResult.checks.map(
552
- (check) =>
553
- `- ${check.ok ? "OK" : "FAIL"} ${check.field}: ${check.message}`,
554
- ),
555
- ]
556
- : [];
557
-
558
- return [
559
- "# Review Request: Final Verdict",
560
- "",
561
- `You are performing a final verdict review for a ${projectName} task.`,
562
- "",
563
- "## Task Context",
564
- `- **Task PROMPT:** ${promptPath}`,
565
- `- **Task STATUS:** ${statusPath}`,
566
- `- **Step completed:** Step ${stepNumber}: ${stepName}`,
567
- `- **Worktree:** ${worktreePath}`,
568
- "",
569
- "## Instructions",
570
- "Verify completion criteria and contract checks before returning a final verdict.",
571
- ...contractLines,
572
- "",
573
- "## Output",
574
- `Write your review to: \`${outputPath}\``,
575
- "Include `### Verdict: PASS`, `### Verdict: REVISE`, or `### Verdict: REPLAN` and a JSON block.",
576
- ].join("\n");
577
- }
578
- if (reviewType === "plan") {
579
- return [
580
- "# Review Request: Plan Review",
581
- "",
582
- `You are reviewing an implementation plan for a ${projectName} task.`,
583
- "",
584
- "## Task Context",
585
- `- **Task PROMPT:** ${promptPath}`,
586
- `- **Task STATUS:** ${statusPath}`,
587
- `- **Step being planned:** Step ${stepNumber}: ${stepName}`,
588
- `- **Worktree:** ${worktreePath}`,
589
- "",
590
- "## Output",
591
- `Write your review to: \`${outputPath}\``,
592
- "Include `### Verdict: APPROVE` or `### Verdict: REVISE` and a JSON block.",
593
- ].join("\n");
594
- }
595
-
596
- const diffNamesCmd = baseline ? `git diff ${baseline}..HEAD --name-only` : "git diff --name-only";
597
- const diffCmd = baseline ? `git diff ${baseline}..HEAD` : "git diff";
598
-
599
- return [
600
- "# Review Request: Code Review",
601
- "",
602
- `You are reviewing code changes for a ${projectName} task.`,
603
- "",
604
- "## Task Context",
605
- `- **Task PROMPT:** ${promptPath}`,
606
- `- **Step reviewed:** Step ${stepNumber}: ${stepName}`,
607
- `- **Worktree:** ${worktreePath}`,
608
- ...(baseline ? [`- **Baseline commit:** ${baseline}`] : []),
609
- "",
610
- "## Instructions",
611
- `1. Run \`${diffNamesCmd}\` to see changed files`,
612
- `2. Run \`${diffCmd}\` for the full diff`,
613
- "",
614
- "## Output",
615
- `Write your review to: \`${outputPath}\``,
616
- "Include `### Verdict: APPROVE` or `### Verdict: REVISE` and a JSON block.",
617
- ].join("\n");
618
- }
619
-
620
- /**
621
- * @param {string} taskFolder
622
- * @param {number} stepNumber
623
- */
624
- export function findStepName(taskFolder, stepNumber) {
625
- const promptPath = path.join(taskFolder, "PROMPT.md");
626
- if (!fs.existsSync(promptPath)) return `Step ${stepNumber}`;
627
- const content = fs.readFileSync(promptPath, "utf-8");
628
- const re = new RegExp(`###\\s+Step\\s+${stepNumber}[:\\s]+(.+)`);
629
- const match = content.match(re);
630
- return match ? match[1].trim() : `Step ${stepNumber}`;
631
- }
632
-
633
- /**
634
- * @param {object} params
635
- */
636
- function writeStubReviewArtifact({ artifactPath, reviewType, stepNumber, stepName, verdict, feedback }) {
637
- fs.mkdirSync(path.dirname(artifactPath), { recursive: true });
638
- const reviewLabel =
639
- reviewType === "final" ? "Final" : reviewType === "plan" ? "Plan" : "Code";
640
- const body = [
641
- `## ${reviewLabel} Review: ${stepName}`,
642
- "",
643
- `### Verdict: ${verdict}`,
644
- "",
645
- "### Summary",
646
- feedback || `Stub ${reviewType} review for step ${stepNumber}.`,
647
- "",
648
- "```json",
649
- JSON.stringify({ verdict, feedback: feedback || "" }, null, 2),
650
- "```",
651
- "",
652
- ].join("\n");
653
- fs.writeFileSync(artifactPath, body, "utf-8");
654
- }
655
-
656
- /**
657
- * @param {object} params
658
- */
659
- /**
660
- * @param {object} journal
661
- */
662
- function isBatchJournalFrozen(journal) {
663
- const loaded = loadSpineBatchState(journal.projectRoot);
664
- if (!loaded.raw || loaded.raw.batchId !== journal.batchId) return false;
665
- const phase = String(loaded.raw.phase ?? "");
666
- return phase === "completed" || phase === "dismissed";
667
- }
668
-
669
- function journalReviewEvent(type, journal, payload) {
670
- if (!journal?.projectRoot || !journal?.batchId) return;
671
- if (type === "review.failed" && isBatchJournalFrozen(journal)) {
672
- return;
673
- }
674
- appendJournalEvent(journal.projectRoot, journal.batchId, type, {
675
- taskId: journal.taskId,
676
- laneNumber: journal.laneNumber,
677
- correlationId: journal.correlationId,
678
- ...payload,
679
- });
680
- }
681
-
682
- /**
683
- * In-worker plan/code checkpoints must journal `review.skipped` (SP-278/SP-308), never
684
- * `review.failed`, when nested reviewer spawn is blocked inside a pi worker session.
685
- *
686
- * @param {object} params
687
- */
688
- function completeNestedReviewSpawnSkipped({
689
- stepNumber,
690
- reviewType,
691
- reviewLevel,
692
- journal,
693
- artifactPath,
694
- feedback,
695
- }) {
696
- const message = feedback ?? NESTED_REVIEW_SPAWN_BLOCKED;
697
- journalReviewEvent("review.skipped", journal, {
698
- stepNumber,
699
- reviewType,
700
- reviewLevel,
701
- reason: NESTED_REVIEW_SPAWN_REASON,
702
- message,
703
- });
704
- return {
705
- ok: true,
706
- skipped: true,
707
- reviewLevel,
708
- verdict: null,
709
- feedback: message,
710
- artifactPath,
711
- spawnFailed: false,
712
- exitCode: 0,
713
- };
714
- }
715
-
716
- /**
717
- * True when inherited worker batch env must not write to the live journal
718
- * (e.g. npm test subprocess with SPINE_JOURNAL_ATTACH=1).
719
- */
720
- export function isJournalAttachBlocked() {
721
- return process.env.SPINE_SUPPRESS_JOURNAL_ATTACH === "1";
722
- }
723
-
724
- /**
725
- * Resolve batch journal target from env only when the batch engine opts in.
726
- * Prevents `npm test` (and other child processes) from polluting a live batch
727
- * journal via inherited SPINE_BATCH_ID / SPINE_PROJECT_ROOT.
728
- */
729
- export function resolveBatchJournalContext() {
730
- if (process.env.SPINE_JOURNAL_ATTACH !== "1") return undefined;
731
- if (isJournalAttachBlocked()) return undefined;
732
- const projectRoot = process.env.SPINE_PROJECT_ROOT;
733
- const batchId = process.env.SPINE_BATCH_ID;
734
- if (!projectRoot || !batchId) return undefined;
735
-
736
- return {
737
- projectRoot,
738
- batchId,
739
- taskId: process.env.SPINE_TASK_ID,
740
- laneNumber: process.env.SPINE_LANE_NUMBER
741
- ? Number(process.env.SPINE_LANE_NUMBER)
742
- : undefined,
743
- correlationId: process.env.SPINE_LANE_CORRELATION_ID,
744
- };
745
- }
746
-
747
- /**
748
- * When reviewer `pi` times out but the worker already left `.DONE` (and contract
749
- * passed for final review), honor the verdict instead of failing the task.
750
- *
751
- * @param {object} params
752
- * @returns {ReturnType<typeof runStepReview> | null}
753
- */
754
- export function honorReviewSpawnFailureWhenEligible({
755
- spawnResult,
756
- reviewType,
757
- taskFolder,
758
- contractVerifyResult,
759
- journal,
760
- stepNumber,
761
- reviewLevel,
762
- }) {
763
- if (!spawnResult?.spawnFailed) return null;
764
- if (spawnResult.exitCode !== REVIEW_SPAWN_TIMEOUT_EXIT_CODE) return null;
765
- if (!fs.existsSync(path.join(taskFolder, ".DONE"))) return null;
766
-
767
- if (reviewType === "final" && contractVerifyResult && !contractVerifyResult.ok) {
768
- return null;
769
- }
770
-
771
- const artifactPath =
772
- reviewType === "final"
773
- ? buildFinalReviewArtifactPath(taskFolder)
774
- : buildReviewArtifactPath(taskFolder, stepNumber);
775
- const verdict =
776
- reviewType === "final"
777
- ? contractVerifyResult?.ok === false
778
- ? "REVISE"
779
- : "PASS"
780
- : "APPROVE";
781
- const feedback =
782
- reviewType === "final"
783
- ? "Reviewer spawn timed out; honoring contract verification and worker .DONE."
784
- : "Reviewer spawn timed out; honoring worker .DONE and proceeding.";
785
-
786
- writeStubReviewArtifact({
787
- artifactPath,
788
- reviewType,
789
- verdict,
790
- feedback,
791
- });
792
-
793
- journalReviewEvent("review.completed", journal, {
794
- stepNumber,
795
- reviewType,
796
- reviewLevel,
797
- verdict,
798
- artifactPath,
799
- stub: true,
800
- honored: true,
801
- honorReason: "spawn_timeout_with_done",
802
- });
803
-
804
- const ok = reviewType === "final" ? verdict === "PASS" : verdict === "APPROVE";
805
- return {
806
- ok,
807
- skipped: false,
808
- honored: true,
809
- honorReason: "spawn_timeout_with_done",
810
- reviewLevel,
811
- verdict,
812
- feedback,
813
- artifactPath,
814
- spawnFailed: false,
815
- exitCode: ok ? 0 : 2,
816
- };
817
- }
818
-
819
- /**
820
- * Complete review from an on-disk artifact honored while reviewer pi is still running.
821
- *
822
- * @param {object} params
823
- * @returns {ReturnType<typeof runStepReview>}
824
- */
825
- export function completeReviewFromHonoredArtifact({
826
- artifactPath,
827
- reviewType,
828
- journal,
829
- stepNumber,
830
- reviewLevel,
831
- honorReason = ARTIFACT_READY_HONOR_REASON,
832
- }) {
833
- const reviewContent = fs.readFileSync(artifactPath, "utf-8");
834
- const { verdict, feedback } = parseReviewVerdict(reviewContent, { reviewType });
835
- if (!verdict) {
836
- const error = "honored review artifact missing structured verdict";
837
- journalReviewEvent("review.failed", journal, {
838
- stepNumber,
839
- reviewType,
840
- reviewLevel,
841
- error,
842
- artifactPath,
843
- spawnFailed: true,
844
- });
845
- return {
846
- ok: false,
847
- skipped: false,
848
- reviewLevel,
849
- verdict: null,
850
- feedback,
851
- artifactPath,
852
- spawnFailed: true,
853
- error,
854
- exitCode: 1,
855
- };
856
- }
857
-
858
- const ok = reviewType === "final" ? verdict === "PASS" : verdict === "APPROVE";
859
- journalReviewEvent("review.completed", journal, {
860
- stepNumber,
861
- reviewType,
862
- reviewLevel,
863
- verdict,
864
- artifactPath,
865
- feedback,
866
- honored: true,
867
- honorReason,
868
- });
869
-
870
- return {
871
- ok,
872
- skipped: false,
873
- honored: true,
874
- honorReason,
875
- reviewLevel,
876
- verdict,
877
- feedback,
878
- artifactPath,
879
- spawnFailed: false,
880
- exitCode: ok ? 0 : 2,
881
- };
882
- }
883
-
884
- /**
885
- * @param {object} params
886
- */
887
- export async function runStepReview({
888
- taskFolder,
889
- worktreePath,
890
- stepNumber,
891
- reviewType = "plan",
892
- baseline,
893
- config = {},
894
- journal,
895
- stub,
896
- stubVerdict = "APPROVE",
897
- stubFail = false,
898
- projectName,
899
- contractVerifyResult = null,
900
- }) {
901
- const reviewLevel = readReviewLevel(taskFolder);
902
- if (!isReviewTypeRequired(reviewLevel, reviewType)) {
903
- return {
904
- ok: true,
905
- skipped: true,
906
- reviewLevel,
907
- verdict: null,
908
- feedback: "",
909
- artifactPath: "",
910
- spawnFailed: false,
911
- exitCode: 0,
912
- };
913
- }
914
-
915
- if (reviewType === "final" && journal?.projectRoot && journal?.batchId) {
916
- const honored = findCompletedFinalReview({
917
- taskFolder,
918
- journalEvents: readJournalEvents(journal.projectRoot, journal.batchId),
919
- taskId: journal.taskId,
920
- });
921
- if (honored?.verdict === "PASS") {
922
- return {
923
- ok: true,
924
- skipped: true,
925
- honored: true,
926
- honorSource: honored.source,
927
- reviewLevel,
928
- verdict: "PASS",
929
- feedback: honored.feedback,
930
- artifactPath: honored.artifactPath,
931
- spawnFailed: false,
932
- exitCode: 0,
933
- };
934
- }
935
- }
936
-
937
- const stepName = findStepName(taskFolder, stepNumber);
938
- const artifactPath =
939
- reviewType === "final"
940
- ? buildFinalReviewArtifactPath(taskFolder)
941
- : buildReviewArtifactPath(taskFolder, stepNumber);
942
- const reviewPrompt = buildReviewRequest({
943
- reviewType,
944
- stepNumber,
945
- stepName,
946
- taskFolder,
947
- worktreePath,
948
- outputPath: artifactPath,
949
- baseline,
950
- projectName,
951
- contractVerifyResult,
952
- });
953
-
954
- journalReviewEvent("review.started", journal, {
955
- stepNumber,
956
- reviewType,
957
- reviewLevel,
958
- artifactPath,
959
- });
960
-
961
- const useStub =
962
- stub === true ||
963
- stubFail === true ||
964
- process.env.SPINE_REVIEW_STUB === "1" ||
965
- process.env.SPINE_REVIEW_STUB === "true";
966
-
967
- const stubFailRequested =
968
- stubFail === true ||
969
- (useStub &&
970
- (process.env.SPINE_REVIEW_STUB === "1" ||
971
- process.env.SPINE_REVIEW_STUB === "true") &&
972
- (process.env.SPINE_REVIEW_STUB_FAIL === "1" ||
973
- process.env.SPINE_REVIEW_STUB_FAIL === "true"));
974
-
975
- if (useStub) {
976
- if (stubFailRequested) {
977
- const error = "review spawn failed (stub)";
978
- journalReviewEvent("review.failed", journal, {
979
- stepNumber,
980
- reviewType,
981
- reviewLevel,
982
- error,
983
- spawnFailed: true,
984
- });
985
- return {
986
- ok: false,
987
- skipped: false,
988
- reviewLevel,
989
- verdict: null,
990
- feedback: "",
991
- artifactPath,
992
- spawnFailed: true,
993
- error,
994
- exitCode: 1,
995
- };
996
- }
997
-
998
- const defaultVerdict = reviewType === "final" ? "PASS" : "APPROVE";
999
- const verdict = normalizeVerdict(stubVerdict, reviewType) ?? defaultVerdict;
1000
- const feedback =
1001
- verdict === "REVISE"
1002
- ? "Stub reviewer requested changes."
1003
- : verdict === "REPLAN"
1004
- ? "Stub reviewer requested replan."
1005
- : reviewType === "final"
1006
- ? "Stub reviewer passed final verdict."
1007
- : "Stub reviewer approved.";
1008
- writeStubReviewArtifact({
1009
- artifactPath,
1010
- reviewType,
1011
- stepNumber,
1012
- stepName,
1013
- verdict,
1014
- feedback,
1015
- });
1016
-
1017
- const ok = reviewType === "final" ? verdict === "PASS" : verdict === "APPROVE";
1018
- journalReviewEvent("review.completed", journal, {
1019
- stepNumber,
1020
- reviewType,
1021
- reviewLevel,
1022
- verdict,
1023
- artifactPath,
1024
- stub: true,
1025
- });
1026
-
1027
- return {
1028
- ok,
1029
- skipped: false,
1030
- reviewLevel,
1031
- verdict,
1032
- feedback,
1033
- artifactPath,
1034
- spawnFailed: false,
1035
- exitCode: ok ? 0 : 2,
1036
- };
1037
- }
1038
-
1039
- const systemPrompt = buildReviewerSystemPrompt({
1040
- worktreePath,
1041
- taskFolder,
1042
- reviewType,
1043
- baseline,
1044
- config,
1045
- journal,
1046
- });
1047
-
1048
- if (shouldBlockNestedReviewerSpawn()) {
1049
- return completeNestedReviewSpawnSkipped({
1050
- stepNumber,
1051
- reviewType,
1052
- reviewLevel,
1053
- journal,
1054
- artifactPath,
1055
- });
1056
- }
1057
-
1058
- const spawnResult = await spawnReviewerPi({
1059
- worktreePath,
1060
- taskFolder,
1061
- reviewPrompt,
1062
- systemPrompt,
1063
- config,
1064
- artifactPath,
1065
- reviewType,
1066
- contractVerifyResult,
1067
- });
1068
-
1069
- if (spawnResult.honored && spawnResult.honorReason === ARTIFACT_READY_HONOR_REASON) {
1070
- return completeReviewFromHonoredArtifact({
1071
- artifactPath: spawnResult.artifactPath ?? artifactPath,
1072
- reviewType,
1073
- journal,
1074
- stepNumber,
1075
- reviewLevel,
1076
- });
1077
- }
1078
-
1079
- if (spawnResult.spawnFailed) {
1080
- if (spawnResult.reason === NESTED_REVIEW_SPAWN_REASON) {
1081
- return completeNestedReviewSpawnSkipped({
1082
- stepNumber,
1083
- reviewType,
1084
- reviewLevel,
1085
- journal,
1086
- artifactPath,
1087
- feedback: spawnResult.error,
1088
- });
1089
- }
1090
-
1091
- const honored = honorReviewSpawnFailureWhenEligible({
1092
- spawnResult,
1093
- reviewType,
1094
- taskFolder,
1095
- contractVerifyResult,
1096
- journal,
1097
- stepNumber,
1098
- reviewLevel,
1099
- });
1100
- if (honored) {
1101
- return honored;
1102
- }
1103
-
1104
- journalReviewEvent("review.failed", journal, {
1105
- stepNumber,
1106
- reviewType,
1107
- reviewLevel,
1108
- error: spawnResult.error,
1109
- spawnFailed: true,
1110
- exitCode: spawnResult.exitCode,
1111
- ...(spawnResult.reason ? { reason: spawnResult.reason } : {}),
1112
- });
1113
- return {
1114
- ok: false,
1115
- skipped: false,
1116
- reviewLevel,
1117
- verdict: null,
1118
- feedback: "",
1119
- artifactPath,
1120
- spawnFailed: true,
1121
- error: spawnResult.error,
1122
- exitCode: spawnResult.exitCode ?? 1,
1123
- reason: spawnResult.reason,
1124
- };
1125
- }
1126
-
1127
- if (!fs.existsSync(artifactPath)) {
1128
- const error = "reviewer exited but produced no artifact";
1129
- journalReviewEvent("review.failed", journal, {
1130
- stepNumber,
1131
- reviewType,
1132
- reviewLevel,
1133
- error,
1134
- spawnFailed: true,
1135
- });
1136
- return {
1137
- ok: false,
1138
- skipped: false,
1139
- reviewLevel,
1140
- verdict: null,
1141
- feedback: "",
1142
- artifactPath,
1143
- spawnFailed: true,
1144
- error,
1145
- exitCode: 1,
1146
- };
1147
- }
1148
-
1149
- const reviewContent = fs.readFileSync(artifactPath, "utf-8");
1150
- const { verdict, feedback } = parseReviewVerdict(reviewContent, { reviewType });
1151
- if (!verdict) {
1152
- const error = "review artifact missing structured verdict";
1153
- journalReviewEvent("review.failed", journal, {
1154
- stepNumber,
1155
- reviewType,
1156
- reviewLevel,
1157
- error,
1158
- artifactPath,
1159
- });
1160
- return {
1161
- ok: false,
1162
- skipped: false,
1163
- reviewLevel,
1164
- verdict: null,
1165
- feedback,
1166
- artifactPath,
1167
- spawnFailed: false,
1168
- error,
1169
- exitCode: 1,
1170
- };
1171
- }
1172
-
1173
- const ok = reviewType === "final" ? verdict === "PASS" : verdict === "APPROVE";
1174
- journalReviewEvent("review.completed", journal, {
1175
- stepNumber,
1176
- reviewType,
1177
- reviewLevel,
1178
- verdict,
1179
- artifactPath,
1180
- feedback,
1181
- });
1182
-
1183
- return {
1184
- ok,
1185
- skipped: false,
1186
- reviewLevel,
1187
- verdict,
1188
- feedback,
1189
- artifactPath,
1190
- spawnFailed: false,
1191
- exitCode: ok ? 0 : 2,
1192
- };
1193
- }
1194
-
1195
- /**
1196
- * @param {object} params
1197
- */
1198
- export function assertReviewToolAvailable({ taskFolder }) {
1199
- const reviewLevel = readReviewLevel(taskFolder);
1200
- if (reviewLevel <= 0) {
1201
- return { ok: true, reviewLevel };
1202
- }
1203
-
1204
- const reviewScript = path.join(PACKAGE_ROOT, "bin", "spine-review-step.mjs");
1205
- if (!fs.existsSync(reviewScript)) {
1206
- return {
1207
- ok: false,
1208
- reviewLevel,
1209
- error: `Review level ${reviewLevel} requires spine-review-step but ${reviewScript} is missing`,
1210
- };
1211
- }
1212
-
1213
- const useStub =
1214
- process.env.SPINE_REVIEW_STUB === "1" || process.env.SPINE_REVIEW_STUB === "true";
1215
- if (!useStub && !commandExists("pi")) {
1216
- return {
1217
- ok: false,
1218
- reviewLevel,
1219
- error: `Review level ${reviewLevel} requires pi for reviewer spawn (fail closed, FR-REV-06)`,
1220
- };
1221
- }
1222
-
1223
- return { ok: true, reviewLevel };
1224
- }
45
+ export {
46
+ assertReviewToolAvailable,
47
+ buildReviewRequest,
48
+ buildReviewerSystemPrompt,
49
+ commandExists,
50
+ completeReviewFromHonoredArtifact,
51
+ findStepName,
52
+ honorReviewSpawnFailureWhenEligible,
53
+ isJournalAttachBlocked,
54
+ loadReviewerPrompt,
55
+ resolveBatchJournalContext,
56
+ runStepReview,
57
+ } from "./review-step.mjs";