pi-spine 1.3.0 → 1.4.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.
@@ -23,6 +23,9 @@ export const PHASE23_GRANDFATHERED_OVER_500 = [
23
23
  "src/batch/resume-multi-lanes.mjs",
24
24
  "src/batch/resume.mjs",
25
25
  "src/batch/sequence.mjs",
26
+ "src/batch/contract-verify.mjs",
27
+ "src/batch/journal-rebuild.mjs",
28
+ "src/batch/lane-dirty-check.mjs",
26
29
  ];
27
30
 
28
31
  const PHASE23_ENGINE_LANES_MAX = 500;
@@ -5,8 +5,6 @@
5
5
  * Inspect task dependency graph without running a full batch plan.
6
6
  */
7
7
 
8
- import path from 'node:path';
9
-
10
8
  import { isCliEntrypoint } from './spine-cli/shared.mjs';
11
9
  import { loadSpineConfig } from './spine-config.mjs';
12
10
  import { buildDepsReport, formatDepsHuman } from '../src/cli/deps.mjs';
@@ -8,8 +8,6 @@
8
8
  * spine rules sync [--json]
9
9
  */
10
10
 
11
- import path from "node:path";
12
-
13
11
  import { isCliEntrypoint } from "./spine-cli/shared.mjs";
14
12
  import { printRulesHelp, runSpineRules } from "../src/cli/rules.mjs";
15
13
 
@@ -8,8 +8,6 @@
8
8
  * spine settings set <path> <value> [--dry-run] [--json]
9
9
  */
10
10
 
11
- import path from "node:path";
12
-
13
11
  import { isCliEntrypoint } from "./spine-cli/shared.mjs";
14
12
  import { loadSpineConfig, loadSpineConfigFile } from "./spine-config.mjs";
15
13
  import { formatSettingsShow } from "../src/cli/settings-show.mjs";
package/bin/spine.mjs CHANGED
@@ -25,12 +25,9 @@ import { handlePlan } from "./spine-cli/plan.mjs";
25
25
  import {
26
26
  c,
27
27
  die,
28
- FAIL,
29
28
  getPackageVersion,
30
29
  isCliEntrypoint,
31
- OK,
32
30
  PACKAGE_ROOT,
33
- WARN,
34
31
  } from "./spine-cli/shared.mjs";
35
32
  import { handleStatus } from "./spine-cli/status.mjs";
36
33
  import { handleLane } from "./spine-cli/lane-logs.mjs";
@@ -38,9 +35,9 @@ import { handleWatch } from "./spine-cli/watch.mjs";
38
35
  import { handleWait } from "./spine-cli/wait.mjs";
39
36
  import { handleScenarios } from "./spine-cli/scenarios.mjs";
40
37
  import { loadSpineConfig } from "./spine-config.mjs";
41
- import { cmdInit, SPINE_GITIGNORE_ENTRIES } from "./spine-init.mjs";
38
+ import { cmdInit } from "./spine-init.mjs";
42
39
  import { cmdMigrateFromTaskplane } from "./spine-migrate-from-taskplane.mjs";
43
- import { runDoctorChecks, cmdDoctor } from "./spine-doctor.mjs";
40
+ import { cmdDoctor } from "./spine-doctor.mjs";
44
41
 
45
42
  export { runDoctorChecks } from "./spine-doctor.mjs";
46
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-spine",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Orchestration spine for long-running pi development",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "scripts": {
30
30
  "doctor": "node bin/spine.mjs doctor",
31
- "lint": "eslint src bin tests scripts",
31
+ "lint": "eslint --max-warnings 0 src bin tests scripts",
32
32
  "typecheck": "tsc --project tsconfig.json --noEmit && tsc --project tsconfig.batch.json --noEmit",
33
33
  "test": "SPINE_SUPPRESS_JOURNAL_ATTACH=1 node --experimental-strip-types --test tests/*.test.mjs tests/cli/*.test.mjs tests/compat/*.test.mjs tests/tasks/*.test.mjs tests/config/*.test.mjs tests/config/cursor-rules/*.test.mjs tests/planner/*.test.mjs tests/batch/*.test.mjs tests/agents/*.test.mjs tests/adoption/*.test.mjs tests/dashboard/*.test.mjs tests/doctor/*.test.mjs tests/migrate/*.test.mjs tests/worker-tools/*.test.mjs tests/coverage/*.test.mjs tests/extensions/*.test.mjs",
34
34
  "test:batch": "SPINE_SUPPRESS_JOURNAL_ATTACH=1 node --experimental-strip-types --test tests/batch/*.test.mjs",
@@ -37,7 +37,7 @@ Avoid `` `bin/a.mjs,bin/b.mjs` `` — `tasks validate` warns (or errors in requi
37
37
  | Field | When to include | Value format |
38
38
  |-------|-----------------|--------------|
39
39
  | `testCommand` | **Required** for code tasks (Review Level ≥ 1, Size M/L, or implementation steps) | Shell command in backticks; max 500 chars; no newlines. Use `` `true` `` for docs-only S tasks with no code changes. |
40
- | `fileScopeMustChange` | When you need proof specific paths were touched | Comma-separated paths/globs relative to repo root; **one backtick per path** (not `` `a.mjs,b.mjs` ``) |
40
+ | `fileScopeMustChange` | When you need proof specific paths were touched | Comma-separated paths/globs relative to repo root; **one backtick per path** (not `` `a.mjs,b.mjs` ``). Trailing `/` means directory prefix match (e.g. `src/domain/types/` matches any file under that directory). |
41
41
  | `fileScopeMustNotChange` | When **parallel lanes** must not collide on product paths (see semantics below) | Comma-separated paths/globs relative to repo root; **one backtick per path** |
42
42
  | `minLineCoverage` | When task changes application code | Integer 0–100 (pi-spine policy: **77**) |
43
43
  | `artifactsMustExist` | When deliverables must exist on disk | Comma-separated file paths; **one backtick per path** |
@@ -14,7 +14,6 @@ import {
14
14
  import { loadGateRecord } from "./gate.mjs";
15
15
  import { appendJournalEvent } from "./journal.mjs";
16
16
  import {
17
- finalizeBatchForIntegrate,
18
17
  isPostMergeLimbo,
19
18
  tryFinalizePostMergeLimbo,
20
19
  } from "./post-merge-limbo.mjs";
@@ -218,7 +218,7 @@ export async function runAttachedBatchEngine({
218
218
  runEngine,
219
219
  write,
220
220
  spineBin,
221
- force = false,
221
+ _force = false,
222
222
  operation = "resume",
223
223
  }) {
224
224
  if (operation === "start") {
@@ -12,12 +12,19 @@ import {
12
12
  isPrelandedFileScopeSatisfied,
13
13
  isStubPrelandedFileScopeSatisfied,
14
14
  } from "./contract-prelanded.mjs";
15
+ import { appendJournalEvent } from "./journal.mjs";
15
16
 
16
17
  export { resolvePromptRelPath, isFileScopePatternPrelanded, hasSpineTaskDeliveryChanges } from "./contract-prelanded.mjs";
17
18
 
18
19
  /** Default stdout/stderr capture limit for contract testCommand (issue #86). */
19
20
  export const CONTRACT_TEST_COMMAND_MAX_BUFFER = 10 * 1024 * 1024;
20
21
 
22
+ /** Default number of retries for failed testCommand (SP-485, issue #136). */
23
+ export const CONTRACT_TEST_DEFAULT_RETRIES = 1;
24
+
25
+ /** Default delay in ms between testCommand retry attempts. */
26
+ export const CONTRACT_TEST_RETRY_DELAY_MS = 5000;
27
+
21
28
  /**
22
29
  * @param {string} taskId
23
30
  * @param {ReturnType<import("../tasks/packet/parse-prompt.mjs").parseContract>} parsedContract
@@ -181,7 +188,9 @@ export function verifyStubFileScopeMustChange(
181
188
  /** @type {string[]} */
182
189
  const failures = [];
183
190
  for (const pattern of patterns) {
184
- const matched = changedFiles.some((file) => matchesContractPattern(file, pattern));
191
+ const matched = changedFiles.some((file) =>
192
+ pattern.endsWith("/") ? file.startsWith(pattern) : matchesContractPattern(file, pattern),
193
+ );
185
194
  if (matched) {
186
195
  continue;
187
196
  }
@@ -257,6 +266,48 @@ function formatMaxBufferLabel(byteCount) {
257
266
  return `${byteCount}B`;
258
267
  }
259
268
 
269
+ /**
270
+ * Block the current thread for the given duration without busy-waiting.
271
+ * Safe for CLI/batch tools; not suitable for servers.
272
+ *
273
+ * @param {number} ms
274
+ */
275
+ function sleepSync(ms) {
276
+ if (ms <= 0) return;
277
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
278
+ }
279
+
280
+ /**
281
+ * Write a failure log for a contract testCommand attempt to the task's .reviews/ directory.
282
+ * Returns the written path, or null if taskFolder is not provided.
283
+ *
284
+ * @param {string | undefined} taskFolder
285
+ * @param {string} command
286
+ * @param {{ exitCode: number, output: string, bufferOverflow?: boolean }} result
287
+ * @param {number} attempt
288
+ * @param {number} totalAttempts
289
+ * @returns {string | null}
290
+ */
291
+ export function writeContractFailureLog(taskFolder, command, result, attempt, totalAttempts) {
292
+ if (!taskFolder) return null;
293
+ const reviewsDir = path.join(taskFolder, ".reviews");
294
+ fs.mkdirSync(reviewsDir, { recursive: true });
295
+ const ts = new Date().toISOString().replace(/[:.]/g, "-");
296
+ const logPath = path.join(reviewsDir, `contract-fail-${ts}.log`);
297
+ const header = [
298
+ "Contract testCommand failure log",
299
+ `Command: ${command}`,
300
+ `Exit code: ${result.exitCode}`,
301
+ `Attempt: ${attempt} of ${totalAttempts}`,
302
+ `Timestamp: ${new Date().toISOString()}`,
303
+ `Buffer overflow: ${result.bufferOverflow ? "yes" : "no"}`,
304
+ "---",
305
+ "",
306
+ ].join("\n");
307
+ fs.writeFileSync(logPath, header + (result.output ?? ""), "utf-8");
308
+ return logPath;
309
+ }
310
+
260
311
  /**
261
312
  * @param {string} worktreePath
262
313
  * @param {string} command
@@ -384,7 +435,11 @@ function findArtifactMatch(worktreePath, artifactPattern) {
384
435
  * @param {string} [config.baseBranch]
385
436
  * @param {string} [config.sinceCommit] When set, scope file-scope checks to `sinceCommit..HEAD` (serialized lanes).
386
437
  * @param {string} [config.taskStartCommit] Alias for `sinceCommit` (SP-415 journal resolution).
387
- * @returns {{ ok: boolean, checks: Array<{ field: string, ok: boolean, message: string }> }}
438
+ * @param {string} [config.projectRoot] Repo root for journal events (optional).
439
+ * @param {string} [config.batchId] Batch ID for journal events (optional).
440
+ * @param {string} [config.taskId] Task ID for journal events (optional).
441
+ * @param {string} [config.taskFolder] Task folder path for writing failure logs to .reviews/ (optional).
442
+ * @returns {{ ok: boolean, checks: Array<{ field: string, ok: boolean, message: string }>, retries?: number }}
388
443
  */
389
444
  export function verifyContract(worktreePath, parsedContract, config = {}) {
390
445
  /** @type {Array<{ field: string, ok: boolean, message: string }>} */
@@ -395,25 +450,66 @@ export function verifyContract(worktreePath, parsedContract, config = {}) {
395
450
 
396
451
  let testCommandOutput = "";
397
452
  let testCommandOk = true;
453
+ let retriedCount = 0;
398
454
  if (parsedContract.testCommand) {
399
- const result = runContractTestCommand(worktreePath, parsedContract.testCommand, {
400
- maxBuffer: config?.contractTestMaxBuffer,
401
- });
402
- testCommandOutput = result.output;
403
- testCommandOk = result.ok;
455
+ const maxRetries = config?.contract?.testRetries ?? CONTRACT_TEST_DEFAULT_RETRIES;
456
+ const retryDelayMs = config?.contract?.testRetryDelayMs ?? CONTRACT_TEST_RETRY_DELAY_MS;
457
+ const totalAttempts = maxRetries + 1;
458
+ let lastResult = null;
459
+ let successAttempt = 0;
460
+
461
+ for (let attempt = 1; attempt <= totalAttempts; attempt++) {
462
+ lastResult = runContractTestCommand(worktreePath, parsedContract.testCommand, {
463
+ maxBuffer: config?.contractTestMaxBuffer,
464
+ });
465
+
466
+ if (lastResult.ok) {
467
+ successAttempt = attempt;
468
+ break;
469
+ }
470
+
471
+ writeContractFailureLog(
472
+ config?.taskFolder,
473
+ parsedContract.testCommand,
474
+ lastResult,
475
+ attempt,
476
+ totalAttempts,
477
+ );
478
+
479
+ if (attempt < totalAttempts) {
480
+ retriedCount++;
481
+ if (config?.projectRoot && config?.batchId) {
482
+ appendJournalEvent(config.projectRoot, config.batchId, "contract.test_retry", {
483
+ taskId: config?.taskId,
484
+ attempt,
485
+ exitCode: lastResult.exitCode,
486
+ totalAttempts,
487
+ });
488
+ }
489
+ sleepSync(retryDelayMs);
490
+ }
491
+ }
492
+
493
+ testCommandOutput = lastResult.output;
494
+ testCommandOk = lastResult.ok;
495
+ const attemptLabel = successAttempt > 1
496
+ ? ` (passed on attempt ${successAttempt} of ${totalAttempts})`
497
+ : "";
404
498
  checks.push({
405
499
  field: "testCommand",
406
- ok: result.ok,
407
- message: result.ok
408
- ? "testCommand passed"
409
- : result.bufferOverflow
410
- ? `Contract ${result.summary}`
411
- : `Contract testCommand failed (exit ${result.exitCode}): ${result.summary || "(no output)"}`,
500
+ ok: lastResult.ok,
501
+ message: lastResult.ok
502
+ ? `testCommand passed${attemptLabel}`
503
+ : lastResult.bufferOverflow
504
+ ? `Contract ${lastResult.summary}`
505
+ : `Contract testCommand failed after ${totalAttempts} attempt(s) (exit ${lastResult.exitCode}): ${lastResult.summary || "(no output)"}`,
412
506
  });
413
507
  }
414
508
 
415
509
  for (const pattern of parsedContract.fileScopeMustChange ?? []) {
416
- const matched = changedFiles.some((file) => matchesContractPattern(file, pattern));
510
+ const matched = changedFiles.some((file) =>
511
+ pattern.endsWith("/") ? file.startsWith(pattern) : matchesContractPattern(file, pattern),
512
+ );
417
513
  const prelanded = !matched &&
418
514
  isPrelandedFileScopeSatisfied(
419
515
  worktreePath,
@@ -491,5 +587,6 @@ export function verifyContract(worktreePath, parsedContract, config = {}) {
491
587
  return {
492
588
  ok: checks.length === 0 || checks.every((check) => check.ok),
493
589
  checks,
590
+ ...(retriedCount > 0 ? { retries: retriedCount } : {}),
494
591
  };
495
592
  }
@@ -22,7 +22,7 @@ export function isFailedPhasePendingOnlyLimbo(ctx = {}) {
22
22
  * @param {string} batchLabel
23
23
  * @param {object} ctx
24
24
  */
25
- export function buildFailedPhasePendingOnlyHeadline(batchLabel, ctx = {}) {
25
+ export function buildFailedPhasePendingOnlyHeadline(batchLabel, _ctx = {}) {
26
26
  return `${batchLabel} failed with pending task(s) and no failed tasks — resume to continue`;
27
27
  }
28
28
 
@@ -14,7 +14,6 @@ import { buildAlternatives } from "./diagnosis-alternatives.mjs";
14
14
  export { buildAlternatives } from "./diagnosis-alternatives.mjs";
15
15
  import {
16
16
  buildMergeFailureHeadline,
17
- summarizeMergeFailures,
18
17
  } from "./diagnosis-merge-failure.mjs";
19
18
  export { buildMergeFailureHeadline, summarizeMergeFailures } from "./diagnosis-merge-failure.mjs";
20
19
  import { buildRunningTailHeadline } from "./diagnosis-tail-state.mjs";
@@ -13,7 +13,6 @@ import {
13
13
  loadRulesManifest,
14
14
  fingerprintRulesManifest,
15
15
  } from "../../config/cursor-rules/discover.mjs";
16
- import { resolveRulesManifestIntegrateDrift } from "../rules-manifest-drift.mjs";
17
16
  import { matchesContractPattern } from "../contract-verify.mjs";
18
17
  import {
19
18
  formatAdoptionDocMergeFailure,
@@ -196,7 +195,7 @@ function tryAutoResolveOutOfScopeMergeConflict({
196
195
  projectRoot,
197
196
  filePath,
198
197
  laneFileScopePaths,
199
- laneChangedFiles,
198
+ _laneChangedFiles,
200
199
  }) {
201
200
  if (pathInLaneFileScope(filePath, laneFileScopePaths)) {
202
201
  return { ok: false, reason: "in_lane_file_scope" };
@@ -8,7 +8,7 @@ import { recordLaneTaskMetric } from "./queue.mjs";
8
8
  import { REVIEW_DEFAULTS } from "../../config/defaults.mjs";
9
9
  import { parseContract } from "../../tasks/packet/parse-prompt.mjs";
10
10
  import { resolveTaskStartCommit } from "../contract-task-start.mjs";
11
- import { shouldRunContractVerify, shouldRunContractVerifyForWorker, verifyContract } from "../contract-verify.mjs";
11
+ import { shouldRunContractVerifyForWorker, verifyContract } from "../contract-verify.mjs";
12
12
  import { appendJournalEvent, readJournalEvents } from "../journal.mjs";
13
13
  import {
14
14
  recomputeTaskCounters,
@@ -21,7 +21,6 @@ import {
21
21
  buildReviewArtifactPath,
22
22
  normalizeCodeVerdict,
23
23
  normalizeFinalVerdict,
24
- parseFinalReviewVerdict,
25
24
  shouldRunCodeReview,
26
25
  shouldRunFinalReview,
27
26
  } from "../review-shared.mjs";
@@ -427,30 +426,40 @@ async function runCodeReviewPhase({
427
426
  const maxCodeReviewAttempts = config?.review?.maxFinalAttempts ?? REVIEW_DEFAULTS.maxFinalAttempts;
428
427
  let codeReviewAttempt = task.codeReviewAttempts ?? 0;
429
428
 
430
- if (codeReviewAttempt === 0) {
431
- const honored = findCompletedCodeReview({
432
- taskFolder: taskFolderInWorktree,
433
- journalEvents: readJournalEvents(projectRoot, batchId),
434
- taskId,
435
- });
436
- if (honored?.verdict === "APPROVE") {
437
- appendJournalEvent(projectRoot, batchId, "task.verdict_recorded", {
429
+ const honored = findCompletedCodeReview({
430
+ taskFolder: taskFolderInWorktree,
431
+ journalEvents: readJournalEvents(projectRoot, batchId),
432
+ taskId,
433
+ });
434
+ if (honored?.verdict === "APPROVE") {
435
+ if (codeReviewAttempt > 0) {
436
+ appendJournalEvent(projectRoot, batchId, "review.crash_recovered", {
438
437
  taskId,
439
438
  laneNumber,
440
439
  laneId: lane.laneId,
441
440
  correlationId: laneCorrelationId,
442
441
  reviewType: "code",
443
- verdict: "APPROVE",
444
- feedback: honored.feedback,
442
+ codeReviewAttempt,
445
443
  artifactPath: honored.artifactPath,
446
- codeReviewAttempt: 1,
447
- honored: true,
448
444
  honorSource: honored.source,
449
445
  });
450
- task.codeReviewAttempts = 1;
451
- saveSpineBatchState(projectRoot, state);
452
- return { ok: true, verdict: "APPROVE", codeReviewAttempt: 1, honored: true };
453
446
  }
447
+ appendJournalEvent(projectRoot, batchId, "task.verdict_recorded", {
448
+ taskId,
449
+ laneNumber,
450
+ laneId: lane.laneId,
451
+ correlationId: laneCorrelationId,
452
+ reviewType: "code",
453
+ verdict: "APPROVE",
454
+ feedback: honored.feedback,
455
+ artifactPath: honored.artifactPath,
456
+ codeReviewAttempt: codeReviewAttempt + 1,
457
+ honored: true,
458
+ honorSource: honored.source,
459
+ });
460
+ task.codeReviewAttempts = codeReviewAttempt + 1;
461
+ saveSpineBatchState(projectRoot, state);
462
+ return { ok: true, verdict: "APPROVE", codeReviewAttempt: codeReviewAttempt + 1, honored: true };
454
463
  }
455
464
 
456
465
  const journal = {
@@ -648,30 +657,40 @@ async function runFinalReviewPhase({
648
657
  const maxFinalAttempts = config?.review?.maxFinalAttempts ?? REVIEW_DEFAULTS.maxFinalAttempts;
649
658
  let finalAttempt = task.finalAttempts ?? 0;
650
659
 
651
- if (finalAttempt === 0) {
652
- const honored = findCompletedFinalReview({
653
- taskFolder: taskFolderInWorktree,
654
- journalEvents: readJournalEvents(projectRoot, batchId),
655
- taskId,
656
- });
657
- if (honored?.verdict === "PASS") {
658
- appendJournalEvent(projectRoot, batchId, "task.verdict_recorded", {
660
+ const honoredFinal = findCompletedFinalReview({
661
+ taskFolder: taskFolderInWorktree,
662
+ journalEvents: readJournalEvents(projectRoot, batchId),
663
+ taskId,
664
+ });
665
+ if (honoredFinal?.verdict === "PASS") {
666
+ if (finalAttempt > 0) {
667
+ appendJournalEvent(projectRoot, batchId, "review.crash_recovered", {
659
668
  taskId,
660
669
  laneNumber,
661
670
  laneId: lane.laneId,
662
671
  correlationId: laneCorrelationId,
663
672
  reviewType: "final",
664
- verdict: "PASS",
665
- feedback: honored.feedback,
666
- artifactPath: honored.artifactPath,
667
- finalAttempt: 1,
668
- honored: true,
669
- honorSource: honored.source,
673
+ finalAttempt,
674
+ artifactPath: honoredFinal.artifactPath,
675
+ honorSource: honoredFinal.source,
670
676
  });
671
- task.finalAttempts = 1;
672
- saveSpineBatchState(projectRoot, state);
673
- return { ok: true, verdict: "PASS", finalAttempt: 1, honored: true };
674
677
  }
678
+ appendJournalEvent(projectRoot, batchId, "task.verdict_recorded", {
679
+ taskId,
680
+ laneNumber,
681
+ laneId: lane.laneId,
682
+ correlationId: laneCorrelationId,
683
+ reviewType: "final",
684
+ verdict: "PASS",
685
+ feedback: honoredFinal.feedback,
686
+ artifactPath: honoredFinal.artifactPath,
687
+ finalAttempt: finalAttempt + 1,
688
+ honored: true,
689
+ honorSource: honoredFinal.source,
690
+ });
691
+ task.finalAttempts = finalAttempt + 1;
692
+ saveSpineBatchState(projectRoot, state);
693
+ return { ok: true, verdict: "PASS", finalAttempt: finalAttempt + 1, honored: true };
675
694
  }
676
695
 
677
696
  const journal = {
@@ -699,6 +718,10 @@ async function runFinalReviewPhase({
699
718
  ...config,
700
719
  baseBranch,
701
720
  sinceCommit: sinceCommit ?? undefined,
721
+ projectRoot,
722
+ batchId,
723
+ taskId,
724
+ taskFolder: taskFolderInWorktree,
702
725
  });
703
726
  task.contractOk = contractVerifyResult.ok;
704
727
  saveSpineBatchState(projectRoot, state);
@@ -5,11 +5,9 @@
5
5
  import fs from "node:fs";
6
6
  import path from "node:path";
7
7
  import {
8
- buildTasksAndLanesFromPlan,
9
8
  loadTaskFileScopePaths,
10
9
  recordLaneTaskMetric,
11
10
  recordPromptParseFailure,
12
- skipTaskDoneOnDisk,
13
11
  } from "./engine-lanes/queue.mjs";
14
12
  import { appendJournalEvent } from "./journal.mjs";
15
13
  import { commitLaneAndValidateWorktree } from "./engine-lanes/commit.mjs";
@@ -32,7 +32,6 @@ import { resolveWorktreeSetupHook } from "../config/worktree-setup-hook.mjs";
32
32
  import {
33
33
  assessWaveMergeEligibility,
34
34
  canStartMultiTaskBatch,
35
- countPlanTasks,
36
35
  maxLaneNumberForPlan,
37
36
  resolveBatchStartScope,
38
37
  shouldAutoIntegrateAfterWave,
@@ -10,7 +10,6 @@ import { runEvidenceCommand } from "./evidence-command.mjs";
10
10
  import { readJournalEvents, readJournalTail } from "./journal.mjs";
11
11
  import { generateBatchPostMortem } from "./postmortem.mjs";
12
12
  import { reconcileBatch } from "./reconcile.mjs";
13
- import { loadSpineConfig } from "../config/spine-config-load.mjs";
14
13
 
15
14
  const TASKPLANE_CONFIG_PATH = ".pi/taskplane-config.json";
16
15
 
@@ -185,7 +184,7 @@ export function collectCoreEvidenceBundle(ctx) {
185
184
  * @param {string[]} [ctx.evidenceRefs]
186
185
  */
187
186
  export function collectExtendedEvidenceBundle(ctx) {
188
- const { projectRoot, batchId, batchState = null, config = null } = ctx;
187
+ const { projectRoot, batchId, config = null } = ctx;
189
188
  const dir = evidenceDir(projectRoot, batchId);
190
189
  fs.mkdirSync(dir, { recursive: true });
191
190
 
@@ -5,18 +5,21 @@
5
5
  import { execFileSync } from "node:child_process";
6
6
  import { resolveGitCommitEnv } from "./git-commit-env.mjs";
7
7
 
8
+ const GIT_EXEC_MAX_BUFFER = 10 * 1024 * 1024;
9
+
8
10
  /**
9
11
  * @param {string} cwd
10
12
  * @param {string[]} args
11
- * @param {{ throwOnError?: boolean; projectRoot?: string }} [options]
13
+ * @param {{ throwOnError?: boolean; projectRoot?: string; maxBuffer?: number }} [options]
12
14
  */
13
- export function gitExec(cwd, args, { throwOnError = true, projectRoot } = {}) {
15
+ export function gitExec(cwd, args, { throwOnError = true, projectRoot, maxBuffer = GIT_EXEC_MAX_BUFFER } = {}) {
14
16
  const identityRoot = projectRoot ?? cwd;
15
17
  try {
16
18
  return execFileSync("git", args, {
17
19
  cwd,
18
20
  encoding: "utf-8",
19
21
  stdio: ["ignore", "pipe", "pipe"],
22
+ maxBuffer,
20
23
  env: { ...process.env, ...resolveGitCommitEnv(identityRoot) },
21
24
  }).trim();
22
25
  } catch (err) {
@@ -2,7 +2,9 @@
2
2
  * Rebuild batch task/segment status from append-only journal (FR-REL-01/02, PRD §11.4).
3
3
  */
4
4
 
5
- import { readJournalEvents, STRUCTURAL_JOURNAL_EVENT_TYPES } from "./journal.mjs";
5
+ import fs from "node:fs";
6
+ import { appendJournalEvent, readJournalEvents, STRUCTURAL_JOURNAL_EVENT_TYPES } from "./journal.mjs";
7
+ import { parseReviewVerdict } from "./review-shared.mjs";
6
8
  import {
7
9
  clearTaskFailureMetadata,
8
10
  createInitialBatchState,
@@ -384,6 +386,113 @@ function classifiedShowsDoneInLaneDrift(classified) {
384
386
  );
385
387
  }
386
388
 
389
+ /**
390
+ * Detect review.started events that have no matching review.completed for the same
391
+ * taskId + reviewType. These represent engine crashes mid-review where the artifact
392
+ * may exist on disk but the completion was never journaled.
393
+ *
394
+ * @param {object[]} events
395
+ * @returns {object[]} orphaned review.started events
396
+ */
397
+ export function detectOrphanedReviewStarted(events) {
398
+ /** @type {Map<string, object>} keyed by "taskId:reviewType" */
399
+ const latestStarted = new Map();
400
+ /** @type {Set<string>} */
401
+ const completedKeys = new Set();
402
+
403
+ for (const event of events) {
404
+ const type = String(event?.type ?? "");
405
+ const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
406
+ const taskId = event.taskId ?? payload.taskId;
407
+ if (!taskId) continue;
408
+ const reviewType = payload.reviewType;
409
+ if (!reviewType) continue;
410
+ const key = `${taskId}:${reviewType}`;
411
+
412
+ if (type === "review.started") {
413
+ latestStarted.set(key, event);
414
+ } else if (type === "review.completed") {
415
+ completedKeys.add(key);
416
+ latestStarted.delete(key);
417
+ }
418
+ }
419
+
420
+ const orphaned = [];
421
+ for (const [key, event] of latestStarted) {
422
+ if (!completedKeys.has(key)) {
423
+ orphaned.push(event);
424
+ }
425
+ }
426
+ return orphaned;
427
+ }
428
+
429
+ /** @type {ReadonlySet<string>} Verdicts that indicate a successful review outcome. */
430
+ const APPROVED_VERDICTS = new Set(["APPROVE", "PASS"]);
431
+
432
+ /**
433
+ * Reconcile orphaned review.started events by checking for on-disk artifacts with
434
+ * valid verdicts and synthesizing the missing review.completed + task.completed events.
435
+ * Called at resume time to self-heal after engine crashes mid-review (SP-484 / #131).
436
+ *
437
+ * @param {object} params
438
+ * @param {string} params.projectRoot
439
+ * @param {string} params.batchId
440
+ * @param {object[]} params.events - journal events
441
+ * @returns {{ synthesized: Array<{ taskId: string, reviewType: string, verdict: string, artifactPath: string }> }}
442
+ */
443
+ export function reconcileOrphanedReviewEvents({ projectRoot, batchId, events }) {
444
+ const orphaned = detectOrphanedReviewStarted(events);
445
+ /** @type {Array<{ taskId: string, reviewType: string, verdict: string, artifactPath: string }>} */
446
+ const synthesized = [];
447
+
448
+ for (const event of orphaned) {
449
+ const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
450
+ const artifactPath = typeof payload.artifactPath === "string" ? payload.artifactPath : "";
451
+ const taskId = event.taskId ?? payload.taskId;
452
+ if (!taskId || !artifactPath) continue;
453
+ if (!fs.existsSync(artifactPath)) continue;
454
+
455
+ let content;
456
+ try {
457
+ content = fs.readFileSync(artifactPath, "utf-8");
458
+ } catch {
459
+ continue;
460
+ }
461
+
462
+ const reviewType = payload.reviewType ?? "code";
463
+ const { verdict, feedback } = parseReviewVerdict(content, { reviewType });
464
+ if (!verdict || !APPROVED_VERDICTS.has(verdict)) continue;
465
+
466
+ appendJournalEvent(projectRoot, batchId, "review.completed", {
467
+ taskId,
468
+ laneNumber: payload.laneNumber ?? null,
469
+ correlationId: payload.correlationId ?? null,
470
+ stepNumber: payload.stepNumber ?? null,
471
+ reviewType,
472
+ reviewLevel: payload.reviewLevel ?? null,
473
+ verdict,
474
+ feedback: feedback ?? "",
475
+ artifactPath,
476
+ synthesized: true,
477
+ synthesizeReason: "orphaned_review_crash_recovery",
478
+ });
479
+
480
+ appendJournalEvent(projectRoot, batchId, "task.completed", {
481
+ taskId,
482
+ laneNumber: payload.laneNumber ?? null,
483
+ correlationId: payload.correlationId ?? null,
484
+ synthesized: true,
485
+ synthesizeReason: "orphaned_review_crash_recovery",
486
+ exitReason: "done",
487
+ doneFileFound: true,
488
+ });
489
+
490
+ synthesized.push({ taskId, reviewType, verdict, artifactPath });
491
+ }
492
+
493
+ return { synthesized };
494
+ }
495
+
387
496
  export function detectBatchStateDrift(cachedState, rebuiltState, events = [], classifiedTasks = null) {
388
497
  /** @type {DriftEntry[]} */
389
498
  const entries = [];
@@ -6,6 +6,7 @@ import fs from "node:fs";
6
6
  import path from "node:path";
7
7
  import { execFileSync } from "node:child_process";
8
8
  import { filterGitignoredPaths, gitAddFilteredPaths } from "./git-helpers.mjs";
9
+ import { classifyGitignoredPaths, formatGitignoredRemediationMessage } from "./lane-dirty-check.mjs";
9
10
  import { gitExec } from "./git-exec.mjs";
10
11
  import { parseContract } from "../tasks/packet/parse-prompt.mjs";
11
12
  import {
@@ -39,6 +40,7 @@ export function gitPorcelain(worktreePath) {
39
40
  cwd: worktreePath,
40
41
  encoding: "utf-8",
41
42
  stdio: ["ignore", "pipe", "pipe"],
43
+ maxBuffer: 10 * 1024 * 1024,
42
44
  }).trim();
43
45
  }
44
46
 
@@ -107,6 +109,7 @@ export function countCommitsAhead(projectRoot, baseRef, headRef) {
107
109
  cwd: projectRoot,
108
110
  encoding: "utf-8",
109
111
  stdio: ["ignore", "pipe", "pipe"],
112
+ maxBuffer: 10 * 1024 * 1024,
110
113
  }).trim();
111
114
  return Number.parseInt(count, 10) || 0;
112
115
  }
@@ -119,6 +122,7 @@ function listIgnoredUntrackedPaths(worktreePath) {
119
122
  cwd: worktreePath,
120
123
  encoding: "utf-8",
121
124
  stdio: ["ignore", "pipe", "pipe"],
125
+ maxBuffer: 10 * 1024 * 1024,
122
126
  }).trim();
123
127
  if (!output) return [];
124
128
  return output.split("\n").map((line) => line.trim()).filter(Boolean);
@@ -201,13 +205,10 @@ export function commitLaneWorktree({
201
205
  const { stageable, skipped: gitignoredDirtyPaths } = filterGitignoredPaths(worktreePath, dirtyPaths);
202
206
  const gitignoredPaths = [...new Set([...gitignoredDirtyPaths, ...ignoredUntrackedPaths])];
203
207
  if (stageable.length === 0 && gitignoredPaths.length > 0) {
204
- const preview = gitignoredPaths.slice(0, 20).join(", ");
205
- const suffix = gitignoredPaths.length > 20 ? "…" : "";
208
+ const { indexTracked, worktreeOnly } = classifyGitignoredPaths(worktreePath, gitignoredPaths);
206
209
  return {
207
210
  ok: false,
208
- error:
209
- `Lane worktree has gitignored dirty files only (${preview}${suffix}) — ` +
210
- "remove from the index with git rm --cached on the task branch before resume",
211
+ error: formatGitignoredRemediationMessage(indexTracked, worktreeOnly),
211
212
  failureClass: "GitignoredDirtyWorktree",
212
213
  gitignoredPaths,
213
214
  };
@@ -3,7 +3,7 @@
3
3
  * Coverage artifacts regenerated by npm test are ephemeral when not in task file scope.
4
4
  */
5
5
 
6
- import path from "node:path";
6
+ import { execFileSync } from "node:child_process";
7
7
  import { loadSpineConfig } from "../config/spine-config-load.mjs";
8
8
  import { resolveWorktreeSetupHook } from "../config/worktree-setup-hook.mjs";
9
9
  import { filterPorcelain, gitPorcelain } from "./lane-commit.mjs";
@@ -351,6 +351,82 @@ export function resolveSetupHookSymlinkDriftPorcelain(
351
351
  return filterSetupHookSymlinkDriftPorcelain(porcelain);
352
352
  }
353
353
 
354
+ /**
355
+ * Split gitignored paths into index-tracked (removable with git rm --cached)
356
+ * and worktree-only (ephemeral artifacts not in the index).
357
+ *
358
+ * @param {string} worktreePath
359
+ * @param {string[]} gitignoredPaths
360
+ * @returns {{ indexTracked: string[], worktreeOnly: string[] }}
361
+ */
362
+ export function classifyGitignoredPaths(worktreePath, gitignoredPaths) {
363
+ if (!Array.isArray(gitignoredPaths) || gitignoredPaths.length === 0) {
364
+ return { indexTracked: [], worktreeOnly: [] };
365
+ }
366
+
367
+ let indexedOutput = "";
368
+ try {
369
+ indexedOutput = execFileSync(
370
+ "git",
371
+ ["ls-files", "--cached", "--", ...gitignoredPaths],
372
+ {
373
+ cwd: worktreePath,
374
+ encoding: "utf-8",
375
+ stdio: ["ignore", "pipe", "pipe"],
376
+ },
377
+ ).trim();
378
+ } catch {
379
+ // If ls-files fails, treat all as worktree-only (safe fallback).
380
+ return { indexTracked: [], worktreeOnly: [...gitignoredPaths] };
381
+ }
382
+
383
+ const indexedSet = new Set(
384
+ indexedOutput ? indexedOutput.split("\n").map((l) => l.trim()).filter(Boolean) : [],
385
+ );
386
+ const indexTracked = [];
387
+ const worktreeOnly = [];
388
+ for (const p of gitignoredPaths) {
389
+ if (indexedSet.has(p)) {
390
+ indexTracked.push(p);
391
+ } else {
392
+ worktreeOnly.push(p);
393
+ }
394
+ }
395
+ return { indexTracked, worktreeOnly };
396
+ }
397
+
398
+ /**
399
+ * Build a remediation message appropriate for the gitignored path classification.
400
+ *
401
+ * @param {string[]} indexTracked
402
+ * @param {string[]} worktreeOnly
403
+ * @returns {string}
404
+ */
405
+ export function formatGitignoredRemediationMessage(indexTracked, worktreeOnly) {
406
+ const allPaths = [...indexTracked, ...worktreeOnly];
407
+ const preview = allPaths.slice(0, 20).join(", ");
408
+ const suffix = allPaths.length > 20 ? "…" : "";
409
+ const prefix = `Lane worktree has gitignored dirty files only (${preview}${suffix})`;
410
+
411
+ if (indexTracked.length > 0 && worktreeOnly.length > 0) {
412
+ return (
413
+ `${prefix} — ` +
414
+ `remove index-tracked paths with git rm --cached on the task branch, ` +
415
+ `then git clean -fdX to remove worktree-only artifacts before resume`
416
+ );
417
+ }
418
+ if (indexTracked.length > 0) {
419
+ return (
420
+ `${prefix} — ` +
421
+ `remove from the index with git rm --cached on the task branch before resume`
422
+ );
423
+ }
424
+ return (
425
+ `${prefix} — ` +
426
+ `worktree-only artifacts (not in git index); clean with git clean -fdX before resume`
427
+ );
428
+ }
429
+
354
430
  export function filterOutOfScopeCoveragePorcelain(porcelain, fileScopePaths, ignorePatterns = []) {
355
431
  const afterIgnore = filterPorcelain(porcelain, ignorePatterns);
356
432
  if (!afterIgnore?.trim()) return "";
@@ -40,7 +40,6 @@ import { isProcessAlive } from "../process/liveness.mjs";
40
40
  import {
41
41
  loadBatchStateFile,
42
42
  parseBatchState,
43
- resolveBatchStatePath,
44
43
  } from "./batch-state-io.mjs";
45
44
  import {
46
45
  clearBatchEnginePid,
@@ -9,7 +9,7 @@ import { assessWaveMergeEligibility } from "./engine-scope.mjs";
9
9
  import { mergeWaveLanesToOrch } from "./engine-lanes.mjs";
10
10
  import { recordResumePhaseTransition } from "./resume-common.mjs";
11
11
  import { appendJournalEvent, readJournalEvents } from "./journal.mjs";
12
- import { finalizeResumedBatchForIntegrate, isPostMergeLimbo } from "./post-merge-limbo.mjs";
12
+ import { finalizeResumedBatchForIntegrate } from "./post-merge-limbo.mjs";
13
13
  import {
14
14
  succeededWaveMergeIndices,
15
15
  waveTasksAllTerminal,
@@ -2,12 +2,10 @@
2
2
  * Batch pause and resume for single-lane batches (TP-015, PRD §18.2).
3
3
  */
4
4
 
5
- import fs from "node:fs";
6
5
  import path from "node:path";
7
6
  import crypto from "node:crypto";
8
7
  import { loadSpineConfig } from "../config/spine-config-load.mjs";
9
8
  import { DEFAULT_TASKS_ROOT } from "../config/spine-init-constants.mjs";
10
- import { resolveTasksRoot } from "../config/spine-preflight-lib.mjs";
11
9
  import { installAttachedEngineShutdownHandlers } from "./attached-engine-handoff.mjs";
12
10
  import { enforceAttachedEngineSingleOwner, finalizeResumePostMergeLimbo } from "./attached-runner.mjs";
13
11
  import { openIntegrateGateAfterBatchComplete } from "./gate.mjs";
@@ -97,7 +95,6 @@ export async function resumeBatch({ projectRoot, force = false }) {
97
95
  const taskId = task.taskId;
98
96
  const taskBranch = lane.branch ?? laneTaskBranch(batchId, 1);
99
97
  const wt = lane.worktreePath ?? laneWorktreePath(projectRoot, batchId, 1);
100
- const tasksRoot = resolveTasksRoot(projectRoot, configResult);
101
98
  const taskFolderRel = resolveTaskFolderRel(task, projectRoot);
102
99
  const tasksRootRel = config.paths?.tasksRoot ?? DEFAULT_TASKS_ROOT;
103
100
  const taskFolderInWorktree = taskFolderRel
@@ -90,7 +90,7 @@ function reviewerPiCommandExists(cmd) {
90
90
  */
91
91
  export function buildReviewerPiArgs({
92
92
  worktreePath,
93
- taskFolder,
93
+ _taskFolder,
94
94
  reviewPrompt,
95
95
  systemPrompt,
96
96
  config = {},
@@ -11,18 +11,14 @@ import { buildReviewerContext } from "../config/reviewer-context.mjs";
11
11
  import { resolveReviewScopePaths } from "./review-scope.mjs";
12
12
  import { commandExists as pathCommandExists } from "../util/command-exists.mjs";
13
13
  import {
14
- DEFAULT_REVIEW_SPAWN_TIMEOUT_MS,
15
14
  ARTIFACT_READY_HONOR_REASON,
16
- isActiveWorkerSession,
17
15
  NESTED_REVIEW_SPAWN_BLOCKED,
18
16
  NESTED_REVIEW_SPAWN_REASON,
19
17
  REVIEW_SPAWN_TIMEOUT_EXIT_CODE,
20
- REVIEW_TIMEOUT_REASON,
21
18
  shouldBlockNestedReviewerSpawn,
22
19
  spawnReviewerPi,
23
20
  } from "./review-spawn.mjs";
24
21
  import {
25
- REVIEW_LEVEL_RE,
26
22
  buildFinalReviewArtifactPath,
27
23
  buildReviewArtifactPath,
28
24
  isReviewTypeRequired,
@@ -44,6 +44,7 @@ const PACKAGE_ROOT = path.resolve(__dirname, "../..");
44
44
 
45
45
  const DEFAULT_TIMEOUT_MS = 60 * 60 * 1000;
46
46
  const POST_DONE_KILL_BACKOFF_MS = 5_000;
47
+ const CHILD_DONE_TIMEOUT_MS = 15_000;
47
48
 
48
49
  /**
49
50
  * Force-terminate lane worker processes tracked in batch state.
@@ -182,7 +183,7 @@ function spawnWorkerChild({
182
183
  worktreePath,
183
184
  taskFolder,
184
185
  useStub,
185
- timeoutMs,
186
+ timeoutMs: _timeoutMs,
186
187
  projectRoot,
187
188
  batchId,
188
189
  laneNumber,
@@ -457,7 +458,7 @@ export async function runWorker({
457
458
  onHeartbeat,
458
459
  onWorkerPid,
459
460
  fileScopePaths = [],
460
- timeoutMs = DEFAULT_TIMEOUT_MS,
461
+ timeoutMs: _timeoutMs = DEFAULT_TIMEOUT_MS,
461
462
  workerBackendDeps = {},
462
463
  }) {
463
464
  const donePath = path.join(taskFolder, ".DONE");
@@ -744,8 +745,7 @@ export async function runWorker({
744
745
  });
745
746
  stallWarningSent = true;
746
747
  }
747
- workerChild.kill("SIGTERM");
748
- const { output } = await childDone;
748
+ const { output } = await terminateHungWorkerChild(workerChild, childDone);
749
749
  return buildWorkerFailureResult({
750
750
  rawOutput: output,
751
751
  classification: "stall_timeout",
@@ -770,7 +770,15 @@ export async function runWorker({
770
770
  await sleep(Math.min(stallConfig.pollIntervalMs, 5_000));
771
771
  }
772
772
 
773
- const { exitCode, output } = await childDone;
773
+ const childResult = await Promise.race([childDone, sleep(CHILD_DONE_TIMEOUT_MS).then(() => null)]);
774
+ let exitCode, output;
775
+ if (childResult) {
776
+ ({ exitCode, output } = childResult);
777
+ } else {
778
+ // close event didn't fire — sub-processes likely hold stdio pipes open.
779
+ const fallback = await terminateHungWorkerChild(workerChild, childDone);
780
+ ({ exitCode, output } = fallback);
781
+ }
774
782
  const doneFound = fs.existsSync(donePath);
775
783
  if (postDoneTerminated && !doneFound) {
776
784
  return buildWorkerFailureResult({
package/src/cli/deps.mjs CHANGED
@@ -2,8 +2,6 @@
2
2
  * spine deps — dependency graph inspection (FR-SCHED-01 subset).
3
3
  */
4
4
 
5
- import path from 'node:path';
6
-
7
5
  import { resolveTasksRootPath } from '../config/env-overrides.mjs';
8
6
  import {
9
7
  discoverTasks,
@@ -33,6 +33,16 @@ export function validateContractConfig(config) {
33
33
  }
34
34
  }
35
35
 
36
+ if (contract.testRetries != null) {
37
+ if (typeof contract.testRetries !== "number" || !Number.isInteger(contract.testRetries) || contract.testRetries < 0) {
38
+ return {
39
+ code: "CONFIG_CONTRACT_TEST_RETRIES_INVALID",
40
+ message: "contract.testRetries must be a non-negative integer when set",
41
+ suggestedCommand: "spine settings set contract.testRetries 1",
42
+ };
43
+ }
44
+ }
45
+
36
46
  if (contract.legacyTaskIdPrefixes != null) {
37
47
  if (!Array.isArray(contract.legacyTaskIdPrefixes)) {
38
48
  return {
@@ -92,6 +92,14 @@ body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
92
92
  .lane-status-running { color: var(--running); }
93
93
  .lane-status-stale { color: var(--warn); }
94
94
  .lane-status-completed { color: var(--muted); }
95
+ tr.task-failed { background: rgba(248, 81, 73, 0.1); }
96
+ tr.task-failed td { color: var(--error); }
97
+ tr.task-failed td.col-running,
98
+ tr.task-failed td.col-queued { color: var(--error); }
99
+ tr.task-succeeded { background: rgba(63, 185, 80, 0.08); }
100
+ tr.task-succeeded td.lane-status-completed { color: var(--running); }
101
+ tr.task-running { background: rgba(210, 153, 34, 0.08); }
102
+ tr.task-running td.lane-status-running { color: var(--paused); }
95
103
  .empty-hint { color: var(--muted); font-style: italic; }
96
104
  .gate-status { font-weight: 600; text-transform: uppercase; font-size: 0.75rem; }
97
105
  .gate-status-pending, .gate-status-missing { color: var(--warn); }
@@ -226,13 +226,29 @@ function renderLanes(lanes, laneTableSummary, tailActivity, expandedLaneId) {
226
226
  }
227
227
  tr.dataset.laneId = lane.laneId;
228
228
  tr.setAttribute("aria-expanded", lane.laneId === expandedLaneId ? "true" : "false");
229
- const statusLabel =
230
- lane.laneAlert === "checkpoint-warning"
231
- ? `${lane.status} · checkpoint warning`
232
- : lane.laneAlert === "stall-killed"
233
- ? `${lane.status} · stall killed`
234
- : lane.status;
235
229
  const throughput = lane.throughput ?? {};
230
+ const failedCount = throughput.failedCount ?? 0;
231
+ const isTaskFailed = failedCount > 0 || lane.activityPhase === "failed";
232
+ const isTaskSucceeded = lane.status === "completed" && !isTaskFailed;
233
+ const isTaskRunning = lane.status === "running" && !isTaskFailed;
234
+ if (isTaskFailed) tr.classList.add("task-failed");
235
+ else if (isTaskSucceeded) tr.classList.add("task-succeeded");
236
+ else if (isTaskRunning) tr.classList.add("task-running");
237
+ let statusLabel;
238
+ if (isTaskFailed) {
239
+ const failedEvent = (lane.detail?.recentEvents ?? []).find((e) => e.type === "task.failed");
240
+ const rawReason = failedEvent?.summary ?? "";
241
+ const exitReason = rawReason.split("→")[0].replace(/,\s*$/, "").trim();
242
+ statusLabel = exitReason ? `❌ FAILED — ${exitReason}` : "❌ FAILED";
243
+ } else if (isTaskSucceeded) {
244
+ statusLabel = "✅ Done";
245
+ } else if (lane.laneAlert === "checkpoint-warning") {
246
+ statusLabel = `${lane.status} · checkpoint warning`;
247
+ } else if (lane.laneAlert === "stall-killed") {
248
+ statusLabel = `${lane.status} · stall killed`;
249
+ } else {
250
+ statusLabel = lane.status;
251
+ }
236
252
  const runningText = formatRunningCell(lane.runningTaskId);
237
253
  const queuedText = formatQueuedCell(lane.queuedTaskIds ?? []);
238
254
  const cellSpecs = [
@@ -22,7 +22,6 @@ import { resolveStallConfig } from "../batch/heartbeat.mjs";
22
22
  import { loadSpineConfig } from "../config/spine-config-load.mjs";
23
23
  import {
24
24
  deriveLanesThroughput,
25
- deriveLaneThroughputStats,
26
25
  emptyLaneThroughputStats,
27
26
  summarizeLaneThroughput,
28
27
  } from "./lane-throughput.mjs";
@@ -8,7 +8,6 @@ import { matchesContractPattern } from "../../batch/contract-verify.mjs";
8
8
  import { CONTRACT_DEFAULTS } from "../../config/defaults.mjs";
9
9
  import {
10
10
  parseContract,
11
- parsePrompt,
12
11
  validatePrompt as validatePromptStructure,
13
12
  } from "./parse-prompt.mjs";
14
13
  import { validateContract } from "./validate-contract.mjs";