pi-spine 2.21.0 → 2.23.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.
package/README.md CHANGED
@@ -49,7 +49,7 @@ Primary monitor surfaces: **`spine status --diagnose`**, **`spine dashboard`** /
49
49
  | [pi](https://pi.dev) coding agent | ≥ 0.80.0 (`pi.minPiVersion`) | Yes |
50
50
  | Git (worktree support) | — | Yes |
51
51
 
52
- These are the Wave A floors ([#285](https://github.com/beettlle/pi-spine/issues/285)). `spine doctor` **warns** when the installed pi is below `pi.minPiVersion` ("pi version supported"). The optional peer `@earendil-works/pi-coding-agent` is developed and tested against `^0.85.1` (pinned in `devDependencies`; the `peerDependencies` range stays `*`).
52
+ These are the Wave A floors ([#285](https://github.com/beettlle/pi-spine/issues/285)). `spine doctor` **warns** when the installed pi is below `pi.minPiVersion` ("pi version supported"). The optional peer `@earendil-works/pi-coding-agent` is developed and tested against `^0.87.0` (pinned in `devDependencies`; the `peerDependencies` range stays `*`).
53
53
 
54
54
  ## Install
55
55
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-spine",
3
- "version": "2.21.0",
3
+ "version": "2.23.0",
4
4
  "description": "Orchestration spine for long-running pi development",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -72,7 +72,7 @@
72
72
  }
73
73
  },
74
74
  "devDependencies": {
75
- "@earendil-works/pi-coding-agent": "^0.85.1",
75
+ "@earendil-works/pi-coding-agent": "^0.87.0",
76
76
  "@types/node": "^22.19.18",
77
77
  "eslint": "^10.10.0",
78
78
  "globals": "^17.12.0",
@@ -35,8 +35,9 @@ Invoke explicitly: `/skill:spine-release-operator` or "run a spine release cycle
35
35
  4. `spine preflight` green; **`npm run release:check` green (blocking gate)** on current `main`
36
36
  5. **CI workflow green on release commit** (release-safe profile — parity with `ci.yml`) before tag push
37
37
  6. Operator explicitly approved publish; version bumped and tag pushed (if approved)
38
- 7. Every release-scoped `Closes #NNN` / `Closes: #NNN` issue is **CLOSED** on GitHub once its fix is on `main` (close after each land — do not wait for publish)
39
- 8. Final report with composition table, issues closed/deferred, verification output
38
+ 7. **npm stage completed via GitHub Actions** — `release.yml` Stage step green; then maintainer **approves** with 2FA; `npm view pi-spine version` matches the tag (stage alone is not publish)
39
+ 8. Every release-scoped `Closes #NNN` / `Closes: #NNN` issue is **CLOSED** on GitHub once its fix is on `main` (close after each land — do not wait for publish)
40
+ 9. Final report with composition table, issues closed/deferred, verification output
40
41
 
41
42
  ## Hard rules
42
43
 
@@ -46,6 +47,9 @@ Invoke explicitly: `/skill:spine-release-operator` or "run a spine release cycle
46
47
  - **Never** run `npm version` or `git push --tags` without explicit operator approval
47
48
  - **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))
48
49
  - **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))
50
+ - **Never** claim the package is on npm until the staged package is **approved** with 2FA and `npm view pi-spine version` matches the release — tag push and green `release.yml` stage alone are not publish
51
+ - **Never** re-run `npm version` / retag when `release.yml` failed after a correct `v*` tag already exists — fix Trusted Publisher / OIDC config or re-dispatch Release on the existing tag (see Phase 6 § Publish failure recovery)
52
+ - **Never** use local `npm publish` for routine releases — CI stages via OIDC (`npm stage publish`); emergency manual only after explicit operator approval (see `docs/release/npm-publish.md`)
49
53
  - **Always** parse target version / bump type **before** task selection (Phase 2)
50
54
  - **Always** record dependency drift in Phase 1 (`npm outdated` + `npm audit`) and apply include/defer thresholds — never auto-add a full “update all deps” task; see [issue-intake-checklist.md](references/issue-intake-checklist.md) § Dependency drift check
51
55
  - **Always** prioritize documentation issues over enhancements
@@ -519,15 +523,79 @@ npm version patch # or minor / major — must match Phase 2 profile
519
523
  git push && git push --tags
520
524
  ```
521
525
 
522
- Monitor Release workflow (tag publish):
526
+ ### CI stages to npm via OIDC (not the operator shell)
527
+
528
+ **Canonical publish path:** pushing `v*` triggers [`.github/workflows/release.yml`](../../.github/workflows/release.yml). That workflow:
529
+
530
+ 1. Checks out the tag
531
+ 2. Verifies CI green on the tagged commit (or runs the full gate if no green CI yet)
532
+ 3. Ensures npm ≥ 11.15 and runs `npm stage publish --access public --ignore-scripts --provenance` with **Trusted Publishing (OIDC)** — `permissions.id-token: write`; no `NPMSECRET`
533
+ 4. Creates the GitHub Release (`gh release create`)
534
+
535
+ **Not live yet:** Trusted Publisher is **stage-only**. A maintainer must approve with 2FA before the version is installable:
536
+
537
+ ```bash
538
+ npm stage list
539
+ npm stage view <stage-id>
540
+ npm stage approve <stage-id> # prompts for 2FA
541
+ # or: npmjs.com → package → Staged Packages → Approve
542
+ ```
543
+
544
+ Operator Phase 6 after approval is: **bump → push tag → watch `release.yml` (stage) → human approve → smoke**. Full mechanics: `docs/release/npm-publish.md`.
545
+
546
+ Monitor Release workflow until conclusion:
547
+
548
+ ```bash
549
+ gh run list --workflow release.yml --limit 3
550
+ # Prefer the run for this tag:
551
+ gh run list --workflow release.yml --branch v{VERSION} --limit 3
552
+ gh run watch --exit-status <run-id>
553
+ ```
554
+
555
+ **pi async:** `MonitorCreate` with `gh run watch --exit-status <run-id>`, `timeout: 1800000`, `onDone` to report conclusion; if green, remind operator to approve the staged package, then run smoke.
556
+
557
+ **Publish success criteria (all required):**
558
+
559
+ - `release.yml` conclusion `success` (stage + GitHub Release)
560
+ - Staged package **approved** (2FA) — `npm view pi-spine version` equals the released version
561
+ - GitHub Release exists for `v{VERSION}` (`gh release view v{VERSION}`)
562
+
563
+ Tag push + green **CI** (`ci.yml`) alone is **not** enough — `ci.yml` does not stage or publish. Green stage alone is **not** enough — approve is required.
564
+
565
+ ### Publish failure recovery (HARD STOP — do not retag)
566
+
567
+ When `release.yml` fails, diagnose with the failed job log before any recovery:
523
568
 
524
569
  ```bash
570
+ gh run view <run-id> --log-failed
571
+ ```
572
+
573
+ | Symptom | Meaning | Action |
574
+ |---------|---------|--------|
575
+ | OIDC / trusted publisher mismatch / `ENEEDAUTH` | Trusted Publisher config wrong (workflow name, Environment name set while job has none, stage permission missing) | Fix npm Trusted Publisher; re-dispatch same tag — do **not** `npm version` again |
576
+ | Legacy `E404` on PUT with `NPMSECRET` | Old token path still in use or secret bad | Prefer OIDC; emergency: rotate `NPMSECRET` only if workflow still uses token |
577
+ | Validation steps failed (typecheck / lint / coverage / CLI smoke) | Tagged commit not release-safe | Fix on `main`, create a **new** patch version + tag; do not force-publish a broken tag |
578
+ | CI gate failed for tagged commit | Pre-tag CI was red or missing | Fix `main` / re-run `ci.yml`; new tag if the old tag pointed at a bad commit |
579
+ | Stage green but install missing version | Not approved yet | Approve with 2FA; do not retag |
580
+ | GitHub Release step failed after stage succeeded | Notes/release page only | Create release manually; do not double-stage the same version without rejecting the prior stage first |
581
+
582
+ **Re-dispatch existing tag** (after Trusted Publisher / transient registry fix):
583
+
584
+ ```bash
585
+ # Tag must already exist; this re-runs checkout → gate → stage → gh release
586
+ # workflow_dispatch uses the workflow file from the branch you select (usually main)
587
+ gh workflow run release.yml -f tag=v{VERSION}
525
588
  gh run list --workflow release.yml --limit 3
589
+ gh run watch --exit-status <new-run-id>
526
590
  ```
527
591
 
528
- **pi async:** `MonitorCreate` with `gh run watch --exit-status <run-id>`, `timeout: 1800000`, `onDone` to report conclusion and run smoke tests if green.
592
+ UI equivalent: **Actions → Release → Run workflow** → enter `v{VERSION}`.
593
+
594
+ **Do not** delete/retag/`npm version` again when the only failure was auth/OIDC — package.json and the `v*` tag are already correct.
595
+
596
+ Distinguish **stage auth failures** (table above) from **post-approve install E404/ETARGET** (registry lag F9 — smoke section below) and from **pre-approve missing version** (approve pending).
529
597
 
530
- Post-publish smoke per `docs/release/npm-publish.md` — **retry on registry lag (F9, [#247](https://github.com/beettlle/pi-spine/issues/247)):** the first `npm install -g` right after a successful `release.yml` run can fail with `ETARGET` / "No matching version found" while the registry propagates, even when `npm view` already lists the version. Prefer the bounded wrapper:
598
+ Post-publish smoke per `docs/release/npm-publish.md` — **only after stage success and 2FA approve**. **Retry on registry lag (F9, [#247](https://github.com/beettlle/pi-spine/issues/247)):** the first `npm install -g` right after approve can fail with `ETARGET` / "No matching version found" while the registry propagates, even when `npm view` already lists the version. Prefer the bounded wrapper:
531
599
 
532
600
  ```bash
533
601
  scripts/post-publish-smoke.sh <version>
@@ -571,7 +639,7 @@ Include the published version/tag in the close comment when closing at Phase 6 (
571
639
  6. **Issues filed** — pi-spine GitHub links or "none"
572
640
  7. **Recovery actions** — aborts, retries, contract fixes
573
641
  8. **Verification** — paste `spine preflight` tail, **`npm run release:check` output** (or log path), test/coverage output
574
- 9. **Publish** — version bumped (Y/N), tag pushed (Y/N), workflow URL, or "awaiting operator approval"
642
+ 9. **Publish** — version bumped (Y/N), tag pushed (Y/N), `release.yml` URL + conclusion, stage approved (Y/N), `npm view pi-spine version`, or "awaiting operator approval" / "blocked on Trusted Publisher" / "awaiting stage approve"
575
643
  10. **Issue tracker hygiene** — confirm every release-scoped `Closes #NNN` is CLOSED (paste `gh issue view` states or list)
576
644
 
577
645
  ---
@@ -584,7 +652,8 @@ Include the published version/tag in the close comment when closing at Phase 6 (
584
652
  | Issues repo | `beettlle/pi-spine` |
585
653
  | Pre-publish gate | `npm run release:check` (typecheck → lint → tests → coverage; CI parity) |
586
654
  | 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)) |
587
- | Publish | Tag-triggered `.github/workflows/release.yml` |
655
+ | Publish | **CI-only OIDC stage** — `.github/workflows/release.yml` runs `npm stage publish` (`id-token: write`). Trusted Publisher: stage-only. Human 2FA approve before installable |
656
+ | Re-publish | `gh workflow run release.yml -f tag=vX.Y.Z` after Trusted Publisher fix — never retag for auth-only failures |
588
657
  | Pending backlog | Run `spine plan pending` — release executes **subset only** |
589
658
 
590
659
  ## Short prompt (resume mid-release)
@@ -599,6 +668,7 @@ post-integrate release:check (exit 0 required; no tail-only verification) →
599
668
  git push origin main when remote publish is the goal (F8) →
600
669
  close Closes #NNN issues for tasks that just landed (§4.3c; do not wait for publish) →
601
670
  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 →
602
- after publish: Phase 6 issue sweep for any still-open Closes links → final report must list CLOSED issue numbers.
671
+ after approve: npm version + push tags → watch release.yml (OIDC `npm stage publish`) → on OIDC/auth failure fix Trusted Publisher and gh workflow run release.yml -f tag=v{TARGET} (do not retag) →
672
+ human 2FA approve staged package (npmjs.com or `npm stage approve`) → confirm npm view + gh release view → post-publish smoke → Phase 6 issue sweep → final report must list CLOSED issue numbers.
603
673
  resume --attached --force stays foreground. Post final report with composition table.
604
674
  ```
@@ -57,6 +57,39 @@ export function buildPrimaryFailureHeadline(batchLabel, ctx = {}) {
57
57
  return null;
58
58
  }
59
59
 
60
+ // Keep the hint readable; the gitignored merge repair command uses the same cap (#288).
61
+ const DIRTY_WORKTREE_PATH_HINT_LIMIT = 5;
62
+
63
+ /**
64
+ * DirtyWorktree remediation hint built from the actual dirty set (#288).
65
+ * Prefers concrete dirty paths from the failure payload / lane dirty-check;
66
+ * falls back to a generic status inspection plus retry when paths are unknown.
67
+ * Never hardcodes coverage paths — they appear only when present in the dirty set.
68
+ *
69
+ * @param {object} ctx
70
+ * @param {string|null} [ctx.failedTaskId]
71
+ * @param {string[]|null} [ctx.dirtyPaths]
72
+ * @param {string|null} [ctx.laneWorktree]
73
+ * @returns {string}
74
+ */
75
+ export function buildDirtyWorktreeSuggestedCommand(ctx = {}) {
76
+ const dirtyPaths = (Array.isArray(ctx.dirtyPaths) ? ctx.dirtyPaths : []).filter(
77
+ (entry) => typeof entry === "string" && entry.trim().length > 0,
78
+ );
79
+ const retryHint = ctx.failedTaskId
80
+ ? `spine batch retry ${ctx.failedTaskId}`
81
+ : "spine batch retry";
82
+ if (dirtyPaths.length > 0) {
83
+ const pathHint = dirtyPaths.slice(0, DIRTY_WORKTREE_PATH_HINT_LIMIT).join(" ");
84
+ return `git checkout -- ${pathHint} && ${retryHint}`;
85
+ }
86
+ const worktreeHint =
87
+ typeof ctx.laneWorktree === "string" && ctx.laneWorktree.trim().length > 0
88
+ ? ctx.laneWorktree
89
+ : "<laneWorktree>";
90
+ return `git -C ${worktreeHint} status --porcelain && ${retryHint}`;
91
+ }
92
+
60
93
  /**
61
94
  * @param {object} ctx
62
95
  * @param {string|null} [ctx.exitReason]
@@ -66,9 +99,7 @@ export function buildPrimaryFailureHeadline(batchLabel, ctx = {}) {
66
99
  export function buildPrimaryFailureSuggestedCommand(ctx = {}) {
67
100
  if (LANE_COMMIT_EXIT_REASONS.has(ctx.exitReason ?? "")) {
68
101
  if (ctx.exitReason === "DirtyWorktree") {
69
- return ctx.failedTaskId
70
- ? `git checkout -- extension/coverage && spine batch retry ${ctx.failedTaskId}`
71
- : "git checkout -- extension/coverage && spine batch retry";
102
+ return buildDirtyWorktreeSuggestedCommand(ctx);
72
103
  }
73
104
  return ctx.failedTaskId
74
105
  ? `spine batch retry ${ctx.failedTaskId}`
@@ -32,6 +32,8 @@ import { buildPendingLaneLandSuggestedCommand } from "./diagnosis-pending-lane.m
32
32
  * @param {boolean} [ctx.mergeFailed]
33
33
  * @param {string|null} [ctx.taskBranch]
34
34
  * @param {string[]|null} [ctx.gitignoredPaths]
35
+ * @param {string[]|null} [ctx.dirtyPaths]
36
+ * @param {string|null} [ctx.laneWorktree]
35
37
  * @param {object[]} [ctx.pendingLaneLandTasks]
36
38
  */
37
39
  export function buildSuggestedCommand(diagnosis, ctx = {}) {
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Lane commit and post-commit dirty validation (SP-427 / #73).
4
3
  */
@@ -27,15 +26,15 @@ const DIRTY_AFTER_COMMIT_MESSAGE =
27
26
  * @param {string} params.taskId
28
27
  * @param {string} params.batchId
29
28
  * @param {string} params.taskFolder
30
- * @param {string} [params.projectRoot]
29
+ * @param {string} params.projectRoot
31
30
  * @param {string[]} [params.fileScopePaths]
32
31
  * @param {string[]} [params.ignorePatterns]
33
- * @param {object} params.task
34
- * @param {object} params.lane
32
+ * @param {Record<string, any>} params.task
33
+ * @param {Record<string, any>} params.lane
35
34
  * @param {number} params.laneNumber
36
35
  * @param {string} params.laneCorrelationId
37
- * @param {object} params.state
38
- * @param {object} params.config
36
+ * @param {Record<string, any>} params.state
37
+ * @param {Record<string, any>} params.config
39
38
  * @returns {{ ok: true, laneCommit: object } | { ok: false, error: string, output?: string }}
40
39
  */
41
40
  export function commitLaneAndValidateWorktree({
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Matrix task / sub-lane runners (SP-671 / #217).
4
3
  *
@@ -43,7 +42,7 @@ import { gitExec } from "../git-exec.mjs";
43
42
  * Read the `## Contract` table from a parent task folder (un-substituted).
44
43
  *
45
44
  * @param {string} parentTaskFolderAbs
46
- * @returns {object|null}
45
+ * @returns {ReturnType<typeof parseContract> | null}
47
46
  */
48
47
  export function readParentContract(parentTaskFolderAbs) {
49
48
  const promptPath = path.join(parentTaskFolderAbs, "PROMPT.md");
@@ -130,6 +129,18 @@ export function resolveMatrixRowConcurrency({ matrixMaxParallel, maxParallel = 1
130
129
  * worker child env (`buildMatrixRowEnv`).
131
130
  *
132
131
  * @param {object} params
132
+ * @param {string} params.projectRoot
133
+ * @param {string} params.batchId
134
+ * @param {number} params.laneNumber
135
+ * @param {string} params.taskId
136
+ * @param {string} params.laneBranch Lane task branch the row worktree branches from.
137
+ * @param {string} params.laneCorrelationId
138
+ * @param {{ rowId: string, values: Record<string, string> }} params.row
139
+ * @param {"execute" | "llm"} params.matrixType
140
+ * @param {string} params.parentTaskFolderAbs
141
+ * @param {string} params.taskFolderRel
142
+ * @param {Record<string, any>} [params.config]
143
+ * @param {string} [params.baseBranch]
133
144
  * @param {number} [params.rowIndex] 0-based index of this row in the matrix.
134
145
  * @param {number} [params.rowCount] Total matrix row count.
135
146
  * @returns {Promise<{ rowId: string, ok: boolean, exitCode: number, output: string, worktreePath?: string, branch?: string, commitSha?: string, servedPrompt?: string }>}
@@ -223,7 +234,7 @@ export async function runMatrixSubLane({
223
234
  };
224
235
  }
225
236
 
226
- /** @type {{ rowId: string, ok: boolean, exitCode: number, output: string, worktreePath?: string, branch?: string }} */
237
+ /** @type {{ rowId: string, ok: boolean, exitCode: number, output: string, worktreePath?: string, branch?: string, commitSha?: string, servedPrompt?: string }} */
227
238
  let result;
228
239
 
229
240
  if (matrixType === "execute") {
@@ -333,7 +344,8 @@ export async function runMatrixSubLane({
333
344
  sha256,
334
345
  chars: servedPrompt.length,
335
346
  });
336
- const workerResult = await runWorker({
347
+ const workerResult = /** @type {{ ok?: boolean, exitCode?: number, output?: string, classification?: string }} */ (
348
+ await runWorker({
337
349
  worktreePath,
338
350
  taskFolder: path.join(worktreePath, taskFolderRel),
339
351
  projectRoot,
@@ -345,7 +357,7 @@ export async function runMatrixSubLane({
345
357
  fileScopePaths: [],
346
358
  config,
347
359
  ...(matrixEnv ? { extraEnv: matrixEnv } : {}),
348
- });
360
+ }));
349
361
  result = {
350
362
  rowId,
351
363
  ok: Boolean(workerResult.ok),
@@ -397,7 +409,7 @@ export async function runMatrixSubLane({
397
409
  { projectRoot },
398
410
  );
399
411
  }
400
- const sha = gitExec(worktreePath, ["rev-parse", "HEAD"], { projectRoot });
412
+ const sha = /** @type {string} */ (gitExec(worktreePath, ["rev-parse", "HEAD"], { projectRoot }));
401
413
  result.commitSha = sha;
402
414
  recordMatrixEvent(projectRoot, batchId, "matrix.sub_lane.completed", {
403
415
  taskId,
@@ -450,12 +462,12 @@ export async function runMatrixSubLane({
450
462
  *
451
463
  * @param {object} params
452
464
  * @param {string} params.projectRoot
453
- * @param {object} params.state Live batch state.
465
+ * @param {Record<string, any>} params.state Live batch state.
454
466
  * @param {string} params.batchId
455
467
  * @param {string} params.baseBranch
456
- * @param {object} params.config
457
- * @param {object} params.task
458
- * @param {object} params.lane
468
+ * @param {Record<string, any>} params.config
469
+ * @param {Record<string, any>} params.task
470
+ * @param {Record<string, any>} params.lane
459
471
  * @param {string} params.taskFolderRel
460
472
  * @param {string} params.laneCorrelationId
461
473
  * @param {string[]} params.fileScopePaths
@@ -536,8 +548,16 @@ export async function runMatrixTaskForResume({
536
548
  * branches (fresh and carried-over) are merged back into the lane worktree so
537
549
  * the normal lane-commit + wave-merge carry all rows' output.
538
550
  *
539
- * @param {object} params
540
- * @param {number} params.maxParallel Global `lanes.maxParallel` (pool size).
551
+ * Params bag keys: `projectRoot` (string), `state` (live batch state),
552
+ * `batchId` (string), `baseBranch` (string), `config` (spine config), `task`
553
+ * (parent matrix task, mutated in place), `lane` (lane identity with
554
+ * `laneNumber`/`branch`/`worktreePath`), `taskFolderRel` (string),
555
+ * `laneCorrelationId` (string), `fileScopePaths` (string[]), `matrix` (packet
556
+ * matrix rows from `loadMatrixTaskRows`), `maxParallel` (global
557
+ * `lanes.maxParallel`, pool size).
558
+ *
559
+ * @param {Record<string, any>} params
560
+ * @returns {Promise<{ ok: boolean, aborted?: boolean, error?: string, output?: string, laneCommit?: object, workerResult?: { ok: boolean, classification?: string, exitCode?: number, output?: string } }>}
541
561
  */
542
562
  export async function runMatrixTaskOnLane({
543
563
  projectRoot,
@@ -575,9 +595,9 @@ export async function runMatrixTaskOnLane({
575
595
  // rows keep their status + persisted worktree/branch for retry carry-over,
576
596
  // `canceled` rows stay excluded, and only failed/pending rows re-enter the
577
597
  // sweep. Fresh rows start `pending`.
578
- task.matrixRows = matrix.rows.map((row) => {
598
+ task.matrixRows = matrix.rows.map((/** @type {any} */ row) => {
579
599
  const existing = Array.isArray(task.matrixRows)
580
- ? task.matrixRows.find((entry) => entry && entry.rowId === row.rowId)
600
+ ? task.matrixRows.find((/** @type {any} */ entry) => entry && entry.rowId === row.rowId)
581
601
  : null;
582
602
  return existing ?? {
583
603
  rowId: row.rowId,
@@ -595,7 +615,7 @@ export async function runMatrixTaskOnLane({
595
615
  const runnableRows = [];
596
616
  const skippedRowIds = [];
597
617
  for (const row of matrix.rows) {
598
- const entry = task.matrixRows.find((m) => m.rowId === row.rowId);
618
+ const entry = task.matrixRows.find((/** @type {any} */ m) => m.rowId === row.rowId);
599
619
  if (entry.status === "succeeded") {
600
620
  const carryWorktree = typeof entry.worktreePath === "string" ? entry.worktreePath : null;
601
621
  const carryBranch = typeof entry.branch === "string" ? entry.branch : null;
@@ -641,13 +661,13 @@ export async function runMatrixTaskOnLane({
641
661
  laneNumber,
642
662
  laneId: lane.laneId,
643
663
  correlationId: laneCorrelationId,
644
- rowIds: matrix.rows.map((row) => row.rowId),
664
+ rowIds: matrix.rows.map((/** @type {any} */ row) => row.rowId),
645
665
  matrixType: matrix.type,
646
666
  maxParallel,
647
667
  matrixMaxParallel,
648
668
  rowConcurrency,
649
- runnableRowIds: runnableRows.map((row) => row.rowId),
650
- carriedOverRowIds: carryOverRows.map((carry) => carry.row.rowId),
669
+ runnableRowIds: runnableRows.map((/** @type {any} */ row) => row.rowId),
670
+ carriedOverRowIds: carryOverRows.map((/** @type {any} */ carry) => carry.row.rowId),
651
671
  skippedRowIds,
652
672
  });
653
673
 
@@ -659,7 +679,7 @@ export async function runMatrixTaskOnLane({
659
679
  const rowLaneNumber = await acquireLaneSlot(state, maxParallel);
660
680
  // Per-row live status (#230): flip to `running` only once the row actually
661
681
  // holds a slot, and persist so `spine status` sees it from another process.
662
- const runningEntry = task.matrixRows.find((m) => m.rowId === row.rowId);
682
+ const runningEntry = task.matrixRows.find((/** @type {any} */ m) => m.rowId === row.rowId);
663
683
  if (runningEntry) {
664
684
  runningEntry.status = "running";
665
685
  saveEngineBatchState(projectRoot, state);
@@ -697,6 +717,9 @@ export async function runMatrixTaskOnLane({
697
717
  ok: false,
698
718
  exitCode: 1,
699
719
  output: `sub-lane crashed: ${message}`,
720
+ worktreePath: undefined,
721
+ branch: undefined,
722
+ commitSha: undefined,
700
723
  };
701
724
  } finally {
702
725
  releaseLaneSlot(state, rowLaneNumber);
@@ -704,7 +727,7 @@ export async function runMatrixTaskOnLane({
704
727
  });
705
728
 
706
729
  for (const rowResult of results) {
707
- const entry = task.matrixRows.find((m) => m.rowId === rowResult.rowId);
730
+ const entry = task.matrixRows.find((/** @type {any} */ m) => m.rowId === rowResult.rowId);
708
731
  if (entry) {
709
732
  entry.status = rowResult.ok ? "succeeded" : "failed";
710
733
  entry.exitCode = rowResult.exitCode ?? null;
@@ -724,8 +747,8 @@ export async function runMatrixTaskOnLane({
724
747
  // scope).
725
748
  const { ok, failedRowIds } = aggregateMatrixOutcomes(
726
749
  task.matrixRows
727
- .filter((entry) => entry.status !== "canceled")
728
- .map((entry) => ({ rowId: entry.rowId, ok: entry.status === "succeeded" })),
750
+ .filter((/** @type {any} */ entry) => entry.status !== "canceled")
751
+ .map((/** @type {any} */ entry) => ({ rowId: entry.rowId, ok: entry.status === "succeeded" })),
729
752
  );
730
753
 
731
754
  if (!ok) {
@@ -735,7 +758,7 @@ export async function runMatrixTaskOnLane({
735
758
  // Failed rows' worktrees are cleaned up; succeeded rows keep theirs as
736
759
  // carry-over material for a row-scoped retry (#230).
737
760
  removeMatrixSubLaneWorktree(projectRoot, rowResult.worktreePath, rowResult.branch);
738
- const failedEntry = task.matrixRows.find((m) => m.rowId === rowResult.rowId);
761
+ const failedEntry = task.matrixRows.find((/** @type {any} */ m) => m.rowId === rowResult.rowId);
739
762
  if (failedEntry) {
740
763
  delete failedEntry.worktreePath;
741
764
  delete failedEntry.branch;
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Matrix sub-lane execution (SP-671 / #217).
4
3
  *
@@ -35,7 +34,7 @@ import { appendJournalEvent } from "../journal.mjs";
35
34
  * task is not a matrix task.
36
35
  *
37
36
  * @param {string} taskFolderPath Absolute path to the task folder (parent for matrix).
38
- * @returns {{ rows: Array<{ rowId: string, values: Record<string,string> }>, columns: string[], type: string } | null}
37
+ * @returns {{ rows: Array<{ rowId: string, values: Record<string,string> }>, columns: string[], type: "execute" | "llm" } | null}
39
38
  */
40
39
  export function loadMatrixTaskRows(taskFolderPath) {
41
40
  if (!taskFolderPath || !fs.existsSync(path.join(taskFolderPath, "PROMPT.md"))) {
@@ -48,7 +47,9 @@ export function loadMatrixTaskRows(taskFolderPath) {
48
47
  return null;
49
48
  }
50
49
  const prompt = packet?.prompt;
51
- const matrix = Array.isArray(prompt?.matrix) ? prompt.matrix : null;
50
+ const matrix = /** @type {Array<Record<string, string>> | null} */ (
51
+ Array.isArray(prompt?.matrix) ? prompt.matrix : null
52
+ );
52
53
  if (!matrix || matrix.length === 0) return null;
53
54
  const columns = Array.isArray(prompt.matrixColumns) ? prompt.matrixColumns : [];
54
55
  const rows = matrix.map((values) => ({
@@ -273,8 +274,8 @@ export function removeMatrixSubLaneWorktree(projectRoot, worktreePath, branch) {
273
274
  * @returns {Record<string, string> | null}
274
275
  */
275
276
  export function buildMatrixRowEnv({ taskId, rowId, rowIndex, rowCount }) {
276
- if (!Number.isInteger(rowIndex) || rowIndex < 0) return null;
277
- if (!Number.isInteger(rowCount) || rowCount < 0) return null;
277
+ if (typeof rowIndex !== "number" || !Number.isInteger(rowIndex) || rowIndex < 0) return null;
278
+ if (typeof rowCount !== "number" || !Number.isInteger(rowCount) || rowCount < 0) return null;
278
279
  return {
279
280
  SPINE_MATRIX_JOB_ID: String(taskId ?? ""),
280
281
  SPINE_MATRIX_TASK_ID: String(rowId ?? ""),
@@ -302,8 +303,9 @@ export function runShellInDir(cwd, command, extraEnv = null) {
302
303
  stdio: ["ignore", "pipe", "pipe"],
303
304
  });
304
305
  let output = "";
306
+ /** @type {(chunk: unknown) => void} */
305
307
  const append = (chunk) => {
306
- output += chunk.toString();
308
+ output += String(chunk);
307
309
  };
308
310
  child.stdout?.on("data", append);
309
311
  child.stderr?.on("data", append);