pi-spine 1.8.0 → 1.9.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 (36) hide show
  1. package/bin/spine-doctor.mjs +4 -0
  2. package/extensions/spine/slash-commands.ts +1 -1
  3. package/package.json +1 -1
  4. package/skills/create-spine-tasks/SKILL.md +42 -0
  5. package/skills/create-spine-tasks/references/contract-template.md +30 -2
  6. package/skills/create-spine-tasks/references/prompt-template.md +3 -1
  7. package/skills/spine-autonomous-operator/SKILL.md +7 -2
  8. package/skills/spine-autonomous-operator/references/agent-shell-batch-policy.md +91 -0
  9. package/skills/spine-orchestrate-waves/SKILL.md +10 -6
  10. package/skills/spine-orchestrate-waves/references/outer-loop.md +22 -5
  11. package/skills/spine-release-operator/SKILL.md +12 -3
  12. package/skills/spine-release-operator/references/pi-async-orchestration.md +2 -2
  13. package/src/batch/attached-runner.mjs +99 -2
  14. package/src/batch/contract-prelanded.mjs +83 -0
  15. package/src/batch/contract-verify.mjs +19 -5
  16. package/src/batch/diagnosis-tail-state.mjs +5 -0
  17. package/src/batch/diagnosis.mjs +3 -2
  18. package/src/batch/journal-rebuild.mjs +117 -0
  19. package/src/batch/lifecycle.mjs +2 -0
  20. package/src/batch/macro-phase.mjs +40 -2
  21. package/src/batch/orphan-detect.mjs +105 -2
  22. package/src/batch/reconcile.mjs +152 -10
  23. package/src/config/preflight/integrate-plan.mjs +31 -7
  24. package/src/config/spine-preflight-lib.mjs +1 -0
  25. package/src/dashboard/cache-invalidate.mjs +91 -0
  26. package/src/dashboard/server.mjs +7 -0
  27. package/src/dashboard/snapshot-waves.mjs +32 -5
  28. package/src/dashboard/snapshot.mjs +6 -1
  29. package/src/doctor/attached-orphan-risk.mjs +114 -0
  30. package/src/doctor/run-doctor-checks.mjs +2 -0
  31. package/src/planner/format-plan.mjs +5 -1
  32. package/src/planner/index.mjs +3 -1
  33. package/src/planner/waves.mjs +41 -0
  34. package/src/tasks/packet/validate-contract.mjs +8 -1
  35. package/src/tasks/packet/validate-prompt.mjs +1 -0
  36. package/src/tasks/validate-contract-warn.mjs +87 -0
@@ -249,6 +249,89 @@ export function isBaseScopeSatisfied(worktreePath, pattern, changedFiles, baseBr
249
249
  return onBase.some((filePath) => matchesScopePattern(filePath, pattern));
250
250
  }
251
251
 
252
+ /**
253
+ * When `sinceCommit` scopes verify to a resume baseline, paths matching `fileScopeMustChange`
254
+ * that are unchanged on the lane since task start are satisfied if they already exist on
255
+ * `baseBranch` at that baseline (issue #171, SP-526 / FR-STA-11).
256
+ *
257
+ * @param {string} worktreePath
258
+ * @param {string} pattern
259
+ * @param {string[]} changedFiles
260
+ * @param {string} sinceCommit
261
+ * @param {string} baseBranch
262
+ * @param {ReturnType<import("../tasks/packet/parse-prompt.mjs").parseContract>} parsedContract
263
+ * @param {{ testCommandOk: boolean }} delivery
264
+ * @param {(worktreePath: string, artifactPath: string) => boolean} artifactExists
265
+ */
266
+ export function isResumeBaselineFileScopeSatisfied(
267
+ worktreePath,
268
+ pattern,
269
+ changedFiles,
270
+ sinceCommit,
271
+ baseBranch,
272
+ parsedContract,
273
+ delivery,
274
+ artifactExists,
275
+ ) {
276
+ const scopedSince = String(sinceCommit ?? "").trim();
277
+ if (!scopedSince) {
278
+ return false;
279
+ }
280
+
281
+ if (changedFiles.some((file) => matchesScopePattern(file, pattern))) {
282
+ return false;
283
+ }
284
+
285
+ const laneChangesSinceStart = listPathsChangedBetweenRefs(
286
+ worktreePath,
287
+ scopedSince,
288
+ "HEAD",
289
+ pattern,
290
+ );
291
+ if (laneChangesSinceStart.some((filePath) => matchesScopePattern(filePath, pattern))) {
292
+ return false;
293
+ }
294
+
295
+ const changedInSinceCommit = listPathsChangedBetweenRefs(
296
+ worktreePath,
297
+ `${scopedSince}^`,
298
+ scopedSince,
299
+ pattern,
300
+ );
301
+ if (changedInSinceCommit.some((filePath) => matchesScopePattern(filePath, pattern))) {
302
+ return false;
303
+ }
304
+
305
+ const onBaseAtStart = listPathsOnRef(worktreePath, scopedSince, pattern);
306
+ if (onBaseAtStart.some((filePath) => matchesScopePattern(filePath, pattern))) {
307
+ // Pattern already present at task-start baseline on the lane tree.
308
+ } else {
309
+ const onBaseNow = listPathsOnRef(worktreePath, baseBranch, pattern);
310
+ if (!onBaseNow.some((filePath) => matchesScopePattern(filePath, pattern))) {
311
+ return false;
312
+ }
313
+ const mainChangesSinceStart = listPathsChangedBetweenRefs(
314
+ worktreePath,
315
+ scopedSince,
316
+ baseBranch,
317
+ pattern,
318
+ );
319
+ if (mainChangesSinceStart.some((filePath) => matchesScopePattern(filePath, pattern))) {
320
+ return false;
321
+ }
322
+ }
323
+
324
+ if (parsedContract.testCommand && !delivery.testCommandOk) {
325
+ return false;
326
+ }
327
+ for (const artifactPath of parsedContract.artifactsMustExist ?? []) {
328
+ if (!artifactExists(worktreePath, artifactPath)) {
329
+ return false;
330
+ }
331
+ }
332
+ return true;
333
+ }
334
+
252
335
  /**
253
336
  * @param {string} worktreePath
254
337
  * @param {string} pattern
@@ -13,6 +13,7 @@ import {
13
13
  isBaseFileScopeSatisfied,
14
14
  isBaseScopeSatisfied,
15
15
  isPrelandedFileScopeSatisfied,
16
+ isResumeBaselineFileScopeSatisfied,
16
17
  isStubPrelandedFileScopeSatisfied,
17
18
  } from "./contract-prelanded.mjs";
18
19
  import { appendJournalEvent } from "./journal.mjs";
@@ -579,7 +580,18 @@ export function verifyContract(worktreePath, parsedContract, config = {}) {
579
580
  { testCommandOk },
580
581
  (worktree, artifactPath) => findArtifactMatch(worktree, artifactPath).ok,
581
582
  );
582
- const baseSatisfied = !matched && !prelanded &&
583
+ const resumeBaseline = !matched && !prelanded && sinceCommit &&
584
+ isResumeBaselineFileScopeSatisfied(
585
+ worktreePath,
586
+ pattern,
587
+ changedFiles,
588
+ sinceCommit,
589
+ baseBranch,
590
+ parsedContract,
591
+ { testCommandOk },
592
+ (worktree, artifactPath) => findArtifactMatch(worktree, artifactPath).ok,
593
+ );
594
+ const baseSatisfied = !matched && !prelanded && !resumeBaseline &&
583
595
  isBaseFileScopeSatisfied(
584
596
  worktreePath,
585
597
  pattern,
@@ -590,7 +602,7 @@ export function verifyContract(worktreePath, parsedContract, config = {}) {
590
602
  (worktree, artifactPath) => findArtifactMatch(worktree, artifactPath).ok,
591
603
  config,
592
604
  );
593
- const ok = matched || prelanded || baseSatisfied;
605
+ const ok = matched || prelanded || resumeBaseline || baseSatisfied;
594
606
  checks.push({
595
607
  field: "fileScopeMustChange",
596
608
  ok,
@@ -598,9 +610,11 @@ export function verifyContract(worktreePath, parsedContract, config = {}) {
598
610
  ? `fileScopeMustChange matched: ${pattern}`
599
611
  : prelanded
600
612
  ? `fileScopeMustChange pre-landed on ${baseBranch}: ${pattern}`
601
- : baseSatisfied
602
- ? `fileScopeMustChange satisfied on ${baseBranch}: ${pattern}`
603
- : `Contract fileScopeMustChange: no matching changes for ${pattern}`,
613
+ : resumeBaseline
614
+ ? `fileScopeMustChange pre-landed at resume baseline: ${pattern}`
615
+ : baseSatisfied
616
+ ? `fileScopeMustChange satisfied on ${baseBranch}: ${pattern}`
617
+ : `Contract fileScopeMustChange: no matching changes for ${pattern}`,
604
618
  });
605
619
  }
606
620
 
@@ -45,6 +45,11 @@ export function buildRunningTailHeadline(batchLabel, ctx = {}) {
45
45
  return `${batchLabel} planning — no workers scheduled`;
46
46
  }
47
47
 
48
+ // Macro Failed must not surface in running tail — drift/orphan may still be recoverable (#165).
49
+ if (macroPhase === "failed") {
50
+ return `${batchLabel} finalizing batch — no active workers`;
51
+ }
52
+
48
53
  if (macroPhase != null && macroPhase !== "executing") {
49
54
  const label = macroPhaseLabel(macroPhase);
50
55
  return `${batchLabel} ${label.toLowerCase()} — finalizing batch`;
@@ -169,8 +169,9 @@ export function buildSuggestedCommand(diagnosis, ctx = {}) {
169
169
  return "spine batch dismiss";
170
170
  case "state_drift":
171
171
  if (ctx.failedTaskId) {
172
- if (ctx.phase === "running") {
173
- return `spine batch pause && spine batch retry ${ctx.failedTaskId}`;
172
+ const driftStatus = String(ctx.driftTaskStatus ?? "").toLowerCase();
173
+ if (driftStatus === "running" || ctx.phase === "running") {
174
+ return "spine batch resume --force";
174
175
  }
175
176
  return `spine batch retry ${ctx.failedTaskId}`;
176
177
  }
@@ -6,10 +6,13 @@
6
6
  import fs from "node:fs";
7
7
  import { appendJournalEvent, readJournalEvents, STRUCTURAL_JOURNAL_EVENT_TYPES } from "./journal.mjs";
8
8
  import { parseReviewVerdict } from "./review-shared.mjs";
9
+ import { journalHasTaskCompleted } from "./resume-common.mjs";
9
10
  import {
10
11
  clearTaskFailureMetadata,
11
12
  createInitialBatchState,
13
+ recordTaskSucceeded,
12
14
  recomputeTaskCounters,
15
+ saveSpineBatchState,
13
16
  updateSegmentForTask,
14
17
  } from "./state.mjs";
15
18
 
@@ -542,3 +545,117 @@ export function detectBatchStateDrift(cachedState, rebuiltState, events = [], cl
542
545
 
543
546
  return { drifted: entries.length > 0, entries };
544
547
  }
548
+
549
+ /**
550
+ * Journal evidence that lane work finished and review/contract passed (FR-STA-01 / #170).
551
+ *
552
+ * @param {object[]} events
553
+ * @param {string} taskId
554
+ */
555
+ export function journalShowsDoneInLaneTerminalArtifacts(events, taskId) {
556
+ let hasApprovedReview = false;
557
+ let hasLaneCompleted = false;
558
+ let hasContractVerified = false;
559
+
560
+ for (const event of events ?? []) {
561
+ const type = String(event?.type ?? "");
562
+ const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
563
+ const eventTaskId = event.taskId ?? payload.taskId;
564
+ if (eventTaskId !== taskId) continue;
565
+
566
+ if (type === "review.completed" && APPROVED_VERDICTS.has(String(payload.verdict ?? ""))) {
567
+ hasApprovedReview = true;
568
+ }
569
+ if (type === "task.verdict_recorded" && APPROVED_VERDICTS.has(String(payload.verdict ?? ""))) {
570
+ hasApprovedReview = true;
571
+ }
572
+ if (type === "lane.completed") {
573
+ hasLaneCompleted = true;
574
+ }
575
+ if (type === "contract.verified" && payload.ok === true) {
576
+ hasContractVerified = true;
577
+ }
578
+ }
579
+
580
+ return hasLaneCompleted && (hasApprovedReview || hasContractVerified);
581
+ }
582
+
583
+ /**
584
+ * Promote batch-state tasks when lane on-disk truth and journal show terminal success
585
+ * but cache still shows pending/running (idempotent; FR-STA-01 / SP-512).
586
+ *
587
+ * @param {object} params
588
+ * @param {string} params.projectRoot
589
+ * @param {object} params.state
590
+ * @param {object[]} [params.classifiedTasks]
591
+ * @param {object[]} [params.journalEvents]
592
+ * @param {{ drifted?: boolean, entries?: Array<{ taskId: string, field: string, rebuilt?: unknown }> }} [params.drift]
593
+ * @returns {{ reconciled: boolean, taskIds: string[] }}
594
+ */
595
+ export function reconcileBatchStateDrift({
596
+ projectRoot,
597
+ state,
598
+ classifiedTasks = [],
599
+ journalEvents = [],
600
+ drift = null,
601
+ }) {
602
+ if (!state || typeof state !== "object" || !drift?.drifted || !Array.isArray(drift.entries)) {
603
+ return { reconciled: false, taskIds: [] };
604
+ }
605
+
606
+ const batchId = String(state.batchId ?? "");
607
+ if (!batchId) {
608
+ return { reconciled: false, taskIds: [] };
609
+ }
610
+
611
+ const classifiedById = new Map(
612
+ (classifiedTasks ?? []).map((task) => [String(task?.taskId ?? ""), task]),
613
+ );
614
+ /** @type {string[]} */
615
+ const reconciledTaskIds = [];
616
+ let changed = false;
617
+
618
+ for (const entry of drift.entries) {
619
+ const taskId = String(entry?.taskId ?? "");
620
+ if (!taskId || taskId === "*") continue;
621
+
622
+ const task = (state.tasks ?? []).find((row) => row?.taskId === taskId);
623
+ if (!task) continue;
624
+
625
+ if (entry.field === "status" && String(entry.rebuilt ?? "") === "succeeded") {
626
+ if (String(task.status ?? "") === "succeeded") continue;
627
+ if (!recordTaskSucceeded(state, taskId, { doneFileFound: true, exitReason: "done" })) continue;
628
+ reconciledTaskIds.push(taskId);
629
+ changed = true;
630
+ continue;
631
+ }
632
+
633
+ if (entry.field !== "doneInLane") continue;
634
+
635
+ const classified = classifiedById.get(taskId);
636
+ if (!classifiedShowsDoneInLaneDrift(classified)) continue;
637
+ if (classified?.doneInLane !== true) continue;
638
+ if (journalHasTaskCompleted(journalEvents, taskId)) continue;
639
+ if (!journalShowsDoneInLaneTerminalArtifacts(journalEvents, taskId)) continue;
640
+ if (String(task.status ?? "") === "succeeded") continue;
641
+
642
+ if (!recordTaskSucceeded(state, taskId, { doneFileFound: true, exitReason: "done" })) continue;
643
+
644
+ appendJournalEvent(projectRoot, batchId, "task.completed", {
645
+ taskId,
646
+ laneNumber: task.laneNumber ?? null,
647
+ reconciled: true,
648
+ reconcileReason: "done_in_lane_terminal",
649
+ skippedDoneOnDisk: true,
650
+ });
651
+
652
+ reconciledTaskIds.push(taskId);
653
+ changed = true;
654
+ }
655
+
656
+ if (changed) {
657
+ saveSpineBatchState(projectRoot, state);
658
+ }
659
+
660
+ return { reconciled: changed, taskIds: reconciledTaskIds };
661
+ }
@@ -19,6 +19,7 @@ import {
19
19
  import { terminateLaneWorkers } from "./worker-host.mjs";
20
20
  import { removeLaneWorktrees } from "./worktree.mjs";
21
21
  import { terminateSupervisorIfRunning } from "./supervisor-spawn.mjs";
22
+ import { bumpDashboardInvalidateSignal } from "../dashboard/cache-invalidate.mjs";
22
23
 
23
24
  const DISMISS_ALLOWED = new Set(["limbo_stale", "completed_manual", "aborted"]);
24
25
 
@@ -314,6 +315,7 @@ export function dismissBatch(ctx) {
314
315
  config,
315
316
  });
316
317
  clearCompletedBatchState(loaded.path, batchId);
318
+ bumpDashboardInvalidateSignal(projectRoot, "batch_dismiss", batchId);
317
319
 
318
320
  return {
319
321
  ok: true,
@@ -11,7 +11,7 @@
11
11
  * |--------------|---------|
12
12
  * | idle | diagnosis null/undefined (no active batch) |
13
13
  * | aborted | batchPhase or diagnosis `aborted` |
14
- * | failed | batchPhase `failed`, or terminal-failure diagnoses (needs_retry, worker_orphaned, …) |
14
+ * | failed | batchPhase `failed`, or terminal-failure diagnoses when not recoverable drift/orphan (#165) |
15
15
  * | paused | batchPhase or diagnosis `paused` (when not failed) |
16
16
  * | gating | integrate gate record `pending`, or postMergeLimbo awaiting operator gate approval |
17
17
  * | integrating | open `integrate.started` journal event, or diagnosis `needs_integrate` |
@@ -66,6 +66,15 @@ const FAILED_DIAGNOSES = new Set([
66
66
  "git_unavailable",
67
67
  ]);
68
68
 
69
+ /** Drift/orphan diagnoses that may still be progressing while batch phase is active (#165). */
70
+ const RECOVERABLE_DRIFT_ORPHAN_DIAGNOSES = new Set([
71
+ "state_drift",
72
+ "engine_orphaned",
73
+ "worker_orphaned",
74
+ ]);
75
+
76
+ const ACTIVE_BATCH_PHASES = new Set(["running", "merging"]);
77
+
69
78
  const INTEGRATE_EVENT_TYPES = new Set(["integrate.started", "integrate.completed", "integrate.failed"]);
70
79
 
71
80
  /**
@@ -193,6 +202,31 @@ function isGatingState(gateRecord, postMergeLimbo, diagnosis) {
193
202
  return false;
194
203
  }
195
204
 
205
+ /**
206
+ * Drift/orphan under an active batch may still be executing, merging, or gating — not macro Failed.
207
+ *
208
+ * @param {DeriveMacroPhaseInput} input
209
+ * @returns {boolean}
210
+ */
211
+ function isRecoverableDriftOrphanWhileActive(input) {
212
+ const diagnosis = input.diagnosis ?? null;
213
+ const batchPhase = input.batchPhase ?? null;
214
+ if (diagnosis == null || !RECOVERABLE_DRIFT_ORPHAN_DIAGNOSES.has(diagnosis)) {
215
+ return false;
216
+ }
217
+ if (!ACTIVE_BATCH_PHASES.has(batchPhase ?? "")) {
218
+ return false;
219
+ }
220
+ if (input.hasActiveWorkerTasks === true) {
221
+ return true;
222
+ }
223
+ // All lanes terminal — defer to gating/integrating/merging tail derivation.
224
+ if (input.allTasksTerminalSuccess === true) {
225
+ return true;
226
+ }
227
+ return false;
228
+ }
229
+
196
230
  /**
197
231
  * @param {DeriveMacroPhaseInput} input
198
232
  * @returns {MacroPhase|null}
@@ -262,7 +296,11 @@ export function deriveMacroPhase(input) {
262
296
  return "aborted";
263
297
  }
264
298
 
265
- if (batchPhase === "failed" || batchPhase === "merge_blocked" || (diagnosis != null && FAILED_DIAGNOSES.has(diagnosis))) {
299
+ if (
300
+ batchPhase === "failed" ||
301
+ batchPhase === "merge_blocked" ||
302
+ (diagnosis != null && FAILED_DIAGNOSES.has(diagnosis) && !isRecoverableDriftOrphanWhileActive(input))
303
+ ) {
266
304
  return "failed";
267
305
  }
268
306
 
@@ -66,6 +66,99 @@ function readEngineStartedAt(raw) {
66
66
  return Number.isFinite(startedAt) && startedAt > 0 ? startedAt : null;
67
67
  }
68
68
 
69
+ /**
70
+ * @param {unknown} event
71
+ * @returns {string|null}
72
+ */
73
+ function eventFromPhase(event) {
74
+ if (!event || typeof event !== "object") return null;
75
+ const payload = /** @type {{ fromPhase?: unknown, payload?: { fromPhase?: unknown } }} */ (event);
76
+ const direct = payload.fromPhase ?? payload.payload?.fromPhase;
77
+ return typeof direct === "string" && direct ? direct : null;
78
+ }
79
+
80
+ /**
81
+ * Paused batch resumed with --force after intentional engine handoff (SP-513 / #184).
82
+ *
83
+ * @param {object[]} journalEvents
84
+ */
85
+ export function journalIndicatesPausedForceResume(journalEvents) {
86
+ if (!Array.isArray(journalEvents) || journalEvents.length === 0) return false;
87
+ return journalEvents.some((event) => {
88
+ if (String(event?.type ?? "") !== "batch.resumed") return false;
89
+ const payload =
90
+ event.payload && typeof event.payload === "object"
91
+ ? /** @type {Record<string, unknown>} */ (event.payload)
92
+ : {};
93
+ const resumeForced = payload.resumeForced === true || event.resumeForced === true;
94
+ const fromPhase = eventFromPhase(event);
95
+ return resumeForced && fromPhase === "paused";
96
+ });
97
+ }
98
+
99
+ /**
100
+ * @param {object[]} journalEvents
101
+ * @param {string} taskId
102
+ */
103
+ export function journalHasContractVerified(journalEvents, taskId) {
104
+ if (!Array.isArray(journalEvents) || !taskId) return false;
105
+ return journalEvents.some((event) => {
106
+ if (String(event?.type ?? "") !== "contract.verified") return false;
107
+ const matchedTaskId = eventTaskId(event) ?? event.payload?.taskId;
108
+ if (matchedTaskId !== taskId) return false;
109
+ const payload =
110
+ event.payload && typeof event.payload === "object"
111
+ ? /** @type {Record<string, unknown>} */ (event.payload)
112
+ : {};
113
+ if (payload.ok === false || event.ok === false) return false;
114
+ return true;
115
+ });
116
+ }
117
+
118
+ /**
119
+ * Running cache tasks with lane `.DONE` and contract verify should not surface engine_orphaned
120
+ * after a paused force-resume handoff (SP-513 / #184).
121
+ *
122
+ * @param {object} ctx
123
+ * @param {object[]} scopedJournalEvents
124
+ */
125
+ export function shouldSuppressPausedResumeEngineOrphan(ctx, scopedJournalEvents) {
126
+ if (!journalIndicatesPausedForceResume(scopedJournalEvents)) {
127
+ return false;
128
+ }
129
+
130
+ const cacheTasks = Array.isArray(ctx.raw?.tasks) ? ctx.raw.tasks : [];
131
+ const runningCacheTasks = cacheTasks.filter(
132
+ (task) => String(task?.status ?? "").toLowerCase() === "running",
133
+ );
134
+ if (runningCacheTasks.length === 0) {
135
+ return false;
136
+ }
137
+
138
+ const classifiedById = new Map(
139
+ (ctx.tasks ?? [])
140
+ .filter((task) => typeof task?.taskId === "string" && task.taskId)
141
+ .map((task) => [task.taskId, task]),
142
+ );
143
+ const journalEvents = Array.isArray(ctx.fullJournalEvents)
144
+ ? ctx.fullJournalEvents
145
+ : scopedJournalEvents;
146
+
147
+ for (const task of runningCacheTasks) {
148
+ const taskId = String(task.taskId ?? "");
149
+ if (!taskId) return false;
150
+ const classified = classifiedById.get(taskId);
151
+ if (classified?.doneInLane !== true) {
152
+ return false;
153
+ }
154
+ if (!journalHasContractVerified(journalEvents, taskId)) {
155
+ return false;
156
+ }
157
+ }
158
+
159
+ return true;
160
+ }
161
+
69
162
  /**
70
163
  * Journal events for the current detached engine session only.
71
164
  * Prefers the latest `batch.resumed`; otherwise filters from `engineStartedAt`.
@@ -255,7 +348,16 @@ export function detectOrphanRunning(ctx) {
255
348
  }
256
349
 
257
350
  const enginePid = readBatchEnginePid(ctx.raw);
258
- if (enginePid && !isProcessAlive(enginePid) && !journalHasTerminalBatchEvent(scopedJournalEvents)) {
351
+ const suppressPausedResumeEngineOrphan = shouldSuppressPausedResumeEngineOrphan(
352
+ ctx,
353
+ scopedJournalEvents,
354
+ );
355
+ if (
356
+ enginePid &&
357
+ !isProcessAlive(enginePid) &&
358
+ !journalHasTerminalBatchEvent(scopedJournalEvents) &&
359
+ !suppressPausedResumeEngineOrphan
360
+ ) {
259
361
  /** @type {OrphanRunningSignal} */
260
362
  return {
261
363
  kind: "engine",
@@ -271,7 +373,8 @@ export function detectOrphanRunning(ctx) {
271
373
  enginePid == null &&
272
374
  !hasFiniteWorkerPidForRunningTasks(ctx.lanes, runningTasks) &&
273
375
  engineStartedAt != null &&
274
- journalIndicatesStalledSession(scopedJournalEvents)
376
+ journalIndicatesStalledSession(scopedJournalEvents) &&
377
+ !suppressPausedResumeEngineOrphan
275
378
  ) {
276
379
  /** @type {OrphanRunningSignal} */
277
380
  return {