pi-spine 1.9.0 → 1.10.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.
@@ -26,6 +26,8 @@ export const PHASE23_GRANDFATHERED_OVER_500 = [
26
26
  "src/batch/contract-verify.mjs",
27
27
  "src/batch/journal-rebuild.mjs",
28
28
  "src/batch/lane-dirty-check.mjs",
29
+ "src/batch/attached-runner.mjs",
30
+ "src/batch/lifecycle.mjs",
29
31
  ];
30
32
 
31
33
  const PHASE23_ENGINE_LANES_MAX = 500;
package/bin/spine-run.mjs CHANGED
@@ -6,6 +6,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
6
  /**
7
7
  * Route `spine run` subcommands.
8
8
  * - `spine run sequence <scope>` — planner wave sequence (GitHub #54 Tier 2)
9
+ * Release scope: comma-separated SP-IDs or `--profile release` (FR-STA-25 / SP-536).
10
+ * Dry-run: `spine run sequence <scope> --dry-run` — see docs/release/manifest-v1.10.0-example.md
9
11
  * - `spine run <scope>` — alias for `spine batch start <scope>` (TP-024)
10
12
  *
11
13
  * @param {object} options
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-spine",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Orchestration spine for long-running pi development",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -124,7 +124,9 @@ spine run sequence pending --dry-run
124
124
 
125
125
  For each wave `N` until `spine plan pending` shows 0 tasks:
126
126
 
127
- ### 3.1 Start
127
+ ### 3.1 Start (detached default)
128
+
129
+ See [references/agent-shell-batch-policy.md](references/agent-shell-batch-policy.md). **Omit `--attached`** unless you are in a persistent interactive human terminal that stays foreground for the full batch.
128
130
 
129
131
  **pi async (preferred in pi sessions)** — see [pi-async-orchestration.md](../spine-release-operator/references/pi-async-orchestration.md):
130
132
 
@@ -138,7 +140,15 @@ MonitorCreate:
138
140
 
139
141
  After detached start, monitor with `spine wait --until completed,needs_integrate,failed,aborted --timeout 4h` or `spine status --diagnose`.
140
142
 
141
- **Foreground fallback** (interactive terminal only — keep shell in foreground for full batch):
143
+ **Detached shell fallback** (Cursor Agent, non-pi, CI — parent may return before batch finishes):
144
+
145
+ ```bash
146
+ spine batch start pending --wave N
147
+ spine status --diagnose
148
+ spine wait --until completed,needs_integrate,failed,aborted --timeout 4h
149
+ ```
150
+
151
+ **`--attached`** (persistent interactive human terminal only — shell stays foreground for full batch duration):
142
152
 
143
153
  ```bash
144
154
  spine batch start pending --wave N --attached
@@ -2,7 +2,7 @@
2
2
 
3
3
  When an **external agent** (Cursor Agent, pi MonitorCreate, CI script, OpenCode) drives spine batches, the parent shell may return or be killed before the batch engine finishes. Use **detached** start/resume and monitor separately.
4
4
 
5
- **Related:** [#163](https://github.com/beettlle/pi-spine/issues/163) (attached orphan / exit 137), [#185](https://github.com/beettlle/pi-spine/issues/185) (detached default for release/agent batches), [operator-runbook §Attached-first](../../../docs/adoption/operator-runbook.md#attached-first-policy-phase-22).
5
+ **Related:** [#163](https://github.com/beettlle/pi-spine/issues/163) (attached orphan / exit 137), [#185](https://github.com/beettlle/pi-spine/issues/185) (detached default for release/agent batches), [operator-runbook §Detached-first](../../../docs/adoption/operator-runbook.md#detached-first-policy-default).
6
6
 
7
7
  ---
8
8
 
@@ -31,9 +31,10 @@ Invoke explicitly: `/skill:spine-release-operator` or "run a spine release cycle
31
31
  1. GitNexus index refreshed (`gitnexus status` up-to-date with HEAD)
32
32
  2. Release manifest written and operator-approved
33
33
  3. All **release-scoped** tasks `.DONE` and integrated on `main`
34
- 4. `spine preflight` green; local test/coverage gates pass
35
- 5. Operator explicitly approved publish; version bumped and tag pushed (if approved)
36
- 6. Final report with composition table, issues closed/deferred, verification output
34
+ 4. `spine preflight` green; **`npm run release:check` green (blocking gate)** on current `main`
35
+ 5. **CI workflow green on release commit** (release-safe profile — parity with `ci.yml`) before tag push
36
+ 6. Operator explicitly approved publish; version bumped and tag pushed (if approved)
37
+ 7. Final report with composition table, issues closed/deferred, verification output
37
38
 
38
39
  ## Hard rules
39
40
 
@@ -41,6 +42,8 @@ Invoke explicitly: `/skill:spine-release-operator` or "run a spine release cycle
41
42
  - **Never** implement product code in task folders while a batch owns that scope
42
43
  - **Never** claim batch/test/publish success without CLI output
43
44
  - **Never** run `npm version` or `git push --tags` without explicit operator approval
45
+ - **Never** run `npm version` or `git push --tags` when `npm run release:check` exits non-zero on current `main` ([#175](https://github.com/beettlle/pi-spine/issues/175))
46
+ - **Never** run `npm version` or `git push --tags` when the **CI** workflow is not green on current `HEAD` — release-safe profile: typecheck + lint + tests + coverage (parity with `ci.yml`) ([#156](https://github.com/beettlle/pi-spine/issues/156))
44
47
  - **Always** parse target version / bump type **before** task selection (Phase 2)
45
48
  - **Always** prioritize documentation issues over enhancements
46
49
  - **Always** run `spine gate approve` before `spine integrate`
@@ -48,6 +51,7 @@ Invoke explicitly: `/skill:spine-release-operator` or "run a spine release cycle
48
51
  - **Do not** execute tasks outside the approved manifest scope
49
52
  - **Do not** start a second batch while another batch is **running** on this repo
50
53
  - **Never** background `spine batch resume --attached` or `resume --attached --force` ([#163](https://github.com/beettlle/pi-spine/issues/163))
54
+ - **Release and agent batches:** use **detached** `spine batch start|resume` (omit `--attached`); monitor with MonitorCreate, `spine wait`, or `spine status --diagnose` ([#163](https://github.com/beettlle/pi-spine/issues/163), [#185](https://github.com/beettlle/pi-spine/issues/185)) — see [agent-shell-batch-policy.md](../spine-autonomous-operator/references/agent-shell-batch-policy.md)
51
55
  - **Always** run `/gitnexus analyze` (Pre-work) before Phase 0 — do not start intake, authoring, or batches on a stale index
52
56
 
53
57
  ---
@@ -237,6 +241,8 @@ git commit -m "chore(spine): release v{TARGET} task packets"
237
241
 
238
242
  ## Phase 4 — Execute release scope
239
243
 
244
+ **Detached-first:** See [agent-shell-batch-policy.md](../spine-autonomous-operator/references/agent-shell-batch-policy.md). Omit `--attached` for release waves unless the operator shell is a persistent interactive terminal that blocks until batch completion.
245
+
240
246
  **Scope:** manifest tasks only — build a comma-separated release scope ID list.
241
247
 
242
248
  ```bash
@@ -337,28 +343,71 @@ git status
337
343
  npm run release:check # typecheck → lint → tests → coverage (CI parity)
338
344
  ```
339
345
 
346
+ ### `release:check` gate (HARD STOP — blocking)
347
+
348
+ `npm run release:check` is **not advisory**. It is a **blocking gate** before any publish checklist or Phase 6.
349
+
350
+ **If `npm run release:check` exits non-zero:**
351
+
352
+ 1. **STOP immediately.** Do not present the pre-publish checklist as passable.
353
+ 2. Do not ask for publish approval. Do not run `npm version` or `git push --tags`.
354
+ 3. Record the failure output in the release manifest publish checklist (paste log tail or path to `/tmp/pi-spine-release-check.log`).
355
+ 4. **Recovery:** fix failures on `main` (commit fixes), re-run `npm run release:check` until green, then **re-attempt Phase 5** from the top.
356
+
357
+ Only after `npm run release:check` exits **0** may you present the checklist below.
358
+
340
359
  Present checklist from `docs/release/npm-publish.md`:
341
360
 
342
361
  - [ ] All release-scoped tasks done
343
362
  - [ ] Preflight green
344
- - [ ] `npm run release:check` green (includes lint; ≥77% coverage)
363
+ - [ ] `npm run release:check` green (includes lint; ≥77% coverage) — **verified exit 0**
364
+ - [ ] CI workflow green on `HEAD` (release-safe profile — parity with `ci.yml`) — **verified via `gh run list`**
345
365
  - [ ] Clean git tree
346
366
  - [ ] Bump type matches profile: patch | minor | major
367
+ - [ ] `release:check` output recorded in manifest publish checklist
347
368
 
348
- **Human gate (required):** **STOP HERE.** Do not bump or push until operator explicitly approves publish and confirms bump type.
369
+ **Human gate (required):** **STOP HERE.** Do not bump or push until operator explicitly approves publish, confirms bump type, **and** Phase 5 `release:check` passed on current `main`.
349
370
 
350
371
  ---
351
372
 
352
373
  ## Phase 6 — Publish (after approval only)
353
374
 
354
- Only after operator says "approve publish" / "bump and push":
375
+ **Prerequisites (all required — no bypass):**
376
+
377
+ - Phase 5 `npm run release:check` exited **0** on current `main` (re-run if `main` moved since Phase 5)
378
+ - **CI workflow green on current `HEAD`** (pre-tag gate — see below)
379
+ - Operator explicitly said "approve publish" / "bump and push"
380
+ - Operator confirmed bump type matches Phase 2 profile
381
+
382
+ **Do not skip the release:check gate.** Operator approval alone does not authorize `npm version` or tag push when `release:check` would fail. If unsure, re-run `npm run release:check` before bumping.
383
+
384
+ ### Pre-tag CI gate (HARD STOP — blocking)
385
+
386
+ Before `npm version` or `git push --tags`, verify the **CI** workflow succeeded on current `HEAD` (the commit you are about to tag). **Release-safe CI profile** matches `ci.yml`: typecheck → lint → tests with coverage (≥77% line minimum) → CLI smoke checks. Local parity: `npm run release:check` (Phase 5).
387
+
388
+ **If CI is not green on `HEAD`, STOP.** Push to `main` and wait for CI before tagging — do not retag after a failed release.
389
+
390
+ ```bash
391
+ COMMIT=$(git rev-parse HEAD)
392
+ gh run list --workflow ci.yml --commit "$COMMIT" --json databaseId,conclusion,status --limit 5
393
+ ```
394
+
395
+ **Fail closed** when no run has `conclusion: success`. If the latest run is `in_progress` or `queued`, wait:
396
+
397
+ ```bash
398
+ gh run watch --exit-status <run-id>
399
+ ```
400
+
401
+ If CI **failed** or **no CI run** exists for `HEAD`, **STOP** — fix CI on `main`, re-run Phase 5, then re-attempt this gate. Do not `npm version` or `git push --tags`.
402
+
403
+ Only after Phase 5 **and** pre-tag CI gate pass:
355
404
 
356
405
  ```bash
357
406
  npm version patch # or minor / major — must match Phase 2 profile
358
407
  git push && git push --tags
359
408
  ```
360
409
 
361
- Monitor CI:
410
+ Monitor Release workflow (tag publish):
362
411
 
363
412
  ```bash
364
413
  gh run list --workflow release.yml --limit 3
@@ -388,7 +437,7 @@ Close GitHub issues where tasks had `Closes: #NNN` and work shipped.
388
437
  4. **Authoring changes** — new SP-* created, splits/fixes in Phase 3
389
438
  5. **Issues filed** — pi-spine GitHub links or "none"
390
439
  6. **Recovery actions** — aborts, retries, contract fixes
391
- 7. **Verification** — paste `spine preflight` tail, test/coverage output
440
+ 7. **Verification** — paste `spine preflight` tail, **`npm run release:check` output** (or log path), test/coverage output
392
441
  8. **Publish** — version bumped (Y/N), tag pushed (Y/N), workflow URL, or "awaiting operator approval"
393
442
 
394
443
  ---
@@ -400,6 +449,7 @@ Close GitHub issues where tasks had `Closes: #NNN` and work shipped.
400
449
  | Tasks root | `spine-tasks/` |
401
450
  | Issues repo | `beettlle/pi-spine` |
402
451
  | Pre-publish gate | `npm run release:check` (typecheck → lint → tests → coverage; CI parity) |
452
+ | Pre-tag CI gate | `ci.yml` green on `HEAD` via `gh run list` / `gh run watch` before `npm version` ([#156](https://github.com/beettlle/pi-spine/issues/156)) |
403
453
  | Publish | Tag-triggered `.github/workflows/release.yml` |
404
454
  | Pending backlog | Run `spine plan pending` — release executes **subset only** |
405
455
 
@@ -411,6 +461,6 @@ check manifest at spine-tasks/_authoring/release-v{TARGET}/manifest.md →
411
461
  spine status --diagnose (do not collide with running batch) →
412
462
  preflight → for each wave: MonitorCreate batch start (or foreground) → onDone diagnose →
413
463
  gate approve → integrate → npm install → batch complete →
414
- MonitorCreate release:check → STOP for publish approval.
464
+ MonitorCreate release:check → HARD STOP if non-zero (fix on main, re-run) → only if exit 0: verify ci.yml green on HEAD (gh run list/watch) → HARD STOP if not green → only then: STOP for publish approval.
415
465
  resume --attached --force stays foreground. Post final report with composition table.
416
466
  ```
@@ -28,7 +28,44 @@
28
28
  |-------|-------|--------|------|-------|-------|
29
29
  | SP-### | #NNN | doc / bug / enh | S/M | … | Closes / Partial |
30
30
 
31
- **Release scope ID:** comma-separated SP-IDs for `spine plan` / `spine batch start` (e.g. `SP-483,SP-460,SP-438`)
31
+ **Release scope ID:** comma-separated SP-IDs for `spine plan`, `spine batch start`, and `spine run sequence` (e.g. `SP-483,SP-460,SP-438`). No spaces.
32
+
33
+ ---
34
+
35
+ ## Sequence runner (Phase 4)
36
+
37
+ The manifest is the operator contract; the CLI takes the **scope ID string**, not the manifest file path.
38
+
39
+ ```bash
40
+ spine tasks validate <SP-IDs...>
41
+ spine plan <release-scope-id>
42
+ spine run sequence <release-scope-id> --dry-run
43
+ spine run sequence <release-scope-id> # detached — omit --attached (#163)
44
+ ```
45
+
46
+ Per-wave manual loop (alternative to full sequence):
47
+
48
+ ```bash
49
+ spine batch start <release-scope-id> --wave N
50
+ spine status --diagnose
51
+ spine gate approve && spine integrate && npm install && spine batch complete
52
+ ```
53
+
54
+ **Regression gate** (run after each integrate, before next wave):
55
+
56
+ ```bash
57
+ npm run typecheck && SPINE_WORKER_STUB=1 npm test && npm run release:check
58
+ ```
59
+
60
+ **Operator gates** (human only — sequence does not auto-approve without explicit flags):
61
+
62
+ 1. Approve this manifest (operator sign-off on scope)
63
+ 2. `spine gate approve` per integrate wave
64
+ 3. Publish approval before `npm version <bump>`
65
+
66
+ **Proof gate:** optional pre-publish dry-run (e.g. patch scope with operator touching only gate approve + publish approval; no `npm publish` during proof).
67
+
68
+ Filled example: [`docs/release/manifest-v1.10.0-example.md`](../../../docs/release/manifest-v1.10.0-example.md)
32
69
 
33
70
  ---
34
71
 
@@ -4,6 +4,8 @@
4
4
  * Post-merge limbo resume fast path (SP-348, GitHub #39).
5
5
  */
6
6
 
7
+ import fs from "node:fs";
8
+ import path from "node:path";
7
9
  import {
8
10
  finalizeAttachedLandLoopBeforeExit,
9
11
  finalizeResumedBatchForIntegrate,
@@ -176,8 +178,104 @@ export async function startAttachedMilestoneReporter({
176
178
  };
177
179
  }
178
180
 
181
+ /**
182
+ * @param {string} projectRoot
183
+ * @param {string} batchId
184
+ */
185
+ export function resumeHandoffLockPath(projectRoot, batchId) {
186
+ return path.join(projectRoot, ".spine", "runtime", batchId, "resume-handoff.lock");
187
+ }
188
+
189
+ /**
190
+ * Exclusive lock for forced resume handoff (SP-533 / #167).
191
+ *
192
+ * @param {string} projectRoot
193
+ * @param {string} batchId
194
+ * @param {boolean} [allowRetry]
195
+ * @returns {{ ok: true, release: () => void } | { ok: false, holderPid?: number|null, startedAt?: number }}
196
+ */
197
+ export function tryAcquireResumeHandoffLock(projectRoot, batchId, allowRetry = true) {
198
+ const lockPath = resumeHandoffLockPath(projectRoot, batchId);
199
+ fs.mkdirSync(path.dirname(lockPath), { recursive: true });
200
+ const payload = JSON.stringify({ pid: process.pid, startedAt: Date.now() });
201
+
202
+ try {
203
+ fs.writeFileSync(lockPath, payload, { encoding: "utf-8", flag: "wx" });
204
+ return {
205
+ ok: true,
206
+ release: () => releaseResumeHandoffLock(projectRoot, batchId),
207
+ };
208
+ } catch (err) {
209
+ if (/** @type {NodeJS.ErrnoException} */ (err).code !== "EEXIST") {
210
+ throw err;
211
+ }
212
+ }
213
+
214
+ /** @type {{ pid?: number, startedAt?: number } | null} */
215
+ let holder = null;
216
+ try {
217
+ holder = JSON.parse(fs.readFileSync(lockPath, "utf-8"));
218
+ } catch {
219
+ try {
220
+ fs.unlinkSync(lockPath);
221
+ } catch {
222
+ /* ignore stale corrupt lock cleanup */
223
+ }
224
+ if (allowRetry) {
225
+ return tryAcquireResumeHandoffLock(projectRoot, batchId, false);
226
+ }
227
+ return { ok: false, holderPid: null };
228
+ }
229
+
230
+ const holderPid = Number(holder?.pid);
231
+ if (Number.isFinite(holderPid) && holderPid > 0 && isProcessAlive(holderPid)) {
232
+ return {
233
+ ok: false,
234
+ holderPid,
235
+ startedAt: Number(holder?.startedAt) || undefined,
236
+ };
237
+ }
238
+
239
+ try {
240
+ fs.unlinkSync(lockPath);
241
+ } catch {
242
+ /* ignore stale lock cleanup */
243
+ }
244
+
245
+ try {
246
+ fs.writeFileSync(lockPath, payload, { encoding: "utf-8", flag: "wx" });
247
+ return {
248
+ ok: true,
249
+ release: () => releaseResumeHandoffLock(projectRoot, batchId),
250
+ };
251
+ } catch (err) {
252
+ if (/** @type {NodeJS.ErrnoException} */ (err).code === "EEXIST") {
253
+ return { ok: false, holderPid: Number.isFinite(holderPid) ? holderPid : null };
254
+ }
255
+ throw err;
256
+ }
257
+ }
258
+
259
+ /**
260
+ * @param {string} projectRoot
261
+ * @param {string} batchId
262
+ */
263
+ export function releaseResumeHandoffLock(projectRoot, batchId) {
264
+ const lockPath = resumeHandoffLockPath(projectRoot, batchId);
265
+ try {
266
+ if (!fs.existsSync(lockPath)) return;
267
+ const holder = JSON.parse(fs.readFileSync(lockPath, "utf-8"));
268
+ if (Number(holder?.pid) === process.pid) {
269
+ fs.unlinkSync(lockPath);
270
+ }
271
+ } catch {
272
+ /* ignore release races */
273
+ }
274
+ }
275
+
179
276
  /**
180
277
  * Reject a second attached engine when resilience.enginePid is alive (SP-434, GitHub #89).
278
+ * Serialized forced resume handoff when another resume --force is in flight (SP-533, #167).
181
279
  *
182
280
  * @param {object} params
183
281
  * @param {string} params.projectRoot
@@ -192,9 +290,37 @@ export function enforceAttachedEngineSingleOwner({ projectRoot, force = false, o
192
290
  }
193
291
 
194
292
  const batchId = String(state.batchId ?? "");
293
+ /** @type {(() => void) | undefined} */
294
+ let releaseResumeLock;
295
+
296
+ if (force && operation === "resume") {
297
+ const lock = tryAcquireResumeHandoffLock(projectRoot, batchId);
298
+ if (!lock.ok) {
299
+ const enginePid = readBatchEnginePid(state);
300
+ const holderPid = lock.holderPid ?? null;
301
+ const output =
302
+ `Another batch resume --force is already in progress (batch ${batchId}` +
303
+ `${holderPid ? `, holder PID ${holderPid}` : ""}).\n` +
304
+ `Wait for the in-flight forced resume to finish before starting another.\n`;
305
+ return {
306
+ ok: false,
307
+ exitCode: 1,
308
+ error: "concurrent_resume_blocked",
309
+ output,
310
+ batchId,
311
+ enginePid,
312
+ holderPid,
313
+ };
314
+ }
315
+ releaseResumeLock = lock.release;
316
+ appendJournalEvent(projectRoot, batchId, "batch.resume_handoff_started", {
317
+ pid: process.pid,
318
+ });
319
+ }
320
+
195
321
  const enginePid = readBatchEnginePid(state);
196
322
  if (enginePid == null || enginePid === process.pid || !isProcessAlive(enginePid)) {
197
- return { ok: true };
323
+ return releaseResumeLock ? { ok: true, releaseResumeLock } : { ok: true };
198
324
  }
199
325
 
200
326
  const fromPhase = String(state.phase ?? "");
@@ -212,6 +338,7 @@ export function enforceAttachedEngineSingleOwner({ projectRoot, force = false, o
212
338
  handoff: true,
213
339
  terminated: terminateResult.terminated,
214
340
  stalePid: terminateResult.stalePid ?? enginePid,
341
+ releaseResumeLock,
215
342
  };
216
343
  }
217
344
 
@@ -114,6 +114,18 @@ export function readBatchStateEnginePid(raw) {
114
114
  return null;
115
115
  }
116
116
 
117
+ /**
118
+ * Returns the alive batch-engine PID when complete/archive must wait (FR-STA-22 / #173).
119
+ *
120
+ * @param {unknown} raw
121
+ * @returns {number|null}
122
+ */
123
+ export function readAliveBatchEnginePid(raw) {
124
+ const enginePid = readBatchStateEnginePid(raw);
125
+ if (enginePid == null || !isProcessAlive(enginePid)) return null;
126
+ return enginePid;
127
+ }
128
+
117
129
  /**
118
130
  * Remove active batch-state only when on-disk batch matches expected (SP-441 / #94).
119
131
  * Prevents complete/dismiss from clearing a newer batch after a concurrent start handoff.
@@ -762,7 +762,10 @@ export async function resumeBatchDetached({
762
762
  error: engineLock.error,
763
763
  output: engineLock.output,
764
764
  enginePid: engineLock.enginePid,
765
- suggestedCommand: "spine batch resume --attached --force",
765
+ suggestedCommand:
766
+ engineLock.error === "concurrent_resume_blocked"
767
+ ? "spine status --diagnose"
768
+ : "spine batch resume --attached --force",
766
769
  };
767
770
  return {
768
771
  ok: false,
@@ -771,9 +774,11 @@ export async function resumeBatchDetached({
771
774
  result: payload,
772
775
  };
773
776
  }
777
+ const releaseResumeLock = engineLock.releaseResumeLock;
774
778
 
775
779
  const resumeCheck = validateResumeBatch({ projectRoot, force });
776
780
  if (!resumeCheck.ok) {
781
+ releaseResumeLock?.();
777
782
  const payload = {
778
783
  ok: false,
779
784
  detached: true,
@@ -804,6 +809,7 @@ export async function resumeBatchDetached({
804
809
  fromPhase: String(state.phase ?? "running"),
805
810
  resumeForced: force,
806
811
  });
812
+ releaseResumeLock?.();
807
813
  if (!finalizeResult?.ok) {
808
814
  const payload = {
809
815
  ok: false,
@@ -843,6 +849,7 @@ export async function resumeBatchDetached({
843
849
  prepareDetachedResumeEngineHandoff(projectRoot);
844
850
  const argv = buildAttachedBatchResumeArgv({ force });
845
851
  const { enginePid, logPath } = spawnDetachedBatchEngine({ projectRoot, spineBin, argv });
852
+ releaseResumeLock?.();
846
853
  const waitTimeoutMs = resolveDetachedWaitTimeoutMs(waitTerminal);
847
854
  const wait = await waitForDetachedBatchResume({
848
855
  projectRoot,
@@ -19,6 +19,7 @@ import {
19
19
  export { buildMergeFailureHeadline, summarizeMergeFailures } from "./diagnosis-merge-failure.mjs";
20
20
  import { buildRunningTailHeadline } from "./diagnosis-tail-state.mjs";
21
21
  export { buildRunningTailHeadline, isRunningWithoutActiveWorkers } from "./diagnosis-tail-state.mjs";
22
+ export { findLatestReviewHonorSignal } from "./review.mjs";
22
23
  import {
23
24
  buildStubFailureHeadline,
24
25
  buildStubFailureSuggestedCommand,
@@ -91,6 +92,26 @@ const REVIEW_SPAWN_FAILURE_EXIT_REASONS = new Set([
91
92
  "final_review_timeout",
92
93
  ]);
93
94
 
95
+ /**
96
+ * @param {object|null|undefined} reviewHonorSignal
97
+ * @returns {string|null}
98
+ */
99
+ export function buildReviewHonorHeadlineSuffix(reviewHonorSignal) {
100
+ if (!reviewHonorSignal?.kind) return null;
101
+ const reviewLabel =
102
+ reviewHonorSignal.reviewType === "final" ? "final review" : "code review";
103
+ if (reviewHonorSignal.kind === "review.crash_recovered") {
104
+ return `recovered ${reviewLabel} crash — prior verdict honored from ${reviewHonorSignal.honorSource ?? "artifact"}`;
105
+ }
106
+ if (reviewHonorSignal.kind === "review.skipped_fresh_artifact") {
107
+ return `skipped redundant ${reviewLabel} — fresh artifact honored`;
108
+ }
109
+ if (reviewHonorSignal.kind === "review.resumed") {
110
+ return `${reviewLabel} resumed after operator retry`;
111
+ }
112
+ return null;
113
+ }
114
+
94
115
  /**
95
116
  * @param {object} [ctx]
96
117
  * @param {string|null} [ctx.exitReason]
@@ -395,6 +416,10 @@ export function buildHeadline(diagnosis, ctx = {}) {
395
416
  ? `Task ${ctx.failedTaskId} needs replan — edit PROMPT.md before retry`
396
417
  : `${batchLabel} has tasks needing replan — edit PROMPT.md before retry`;
397
418
  case "running": {
419
+ const reviewHonorSuffix = buildReviewHonorHeadlineSuffix(ctx.reviewHonorSignal);
420
+ if (reviewHonorSuffix && ctx.reviewHonorSignal?.taskId) {
421
+ return `${batchLabel} task ${ctx.reviewHonorSignal.taskId}: ${reviewHonorSuffix}`;
422
+ }
398
423
  const tailHeadline = buildRunningTailHeadline(batchLabel, ctx);
399
424
  if (tailHeadline) {
400
425
  return tailHeadline;