pi-spine 2.23.0 → 2.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +1 -1
  2. package/bin/spine-worker-runner.mjs +2 -1
  3. package/package.json +5 -5
  4. package/src/batch/attached-runner-promote.mjs +14 -0
  5. package/src/batch/batch-state-io.mjs +120 -45
  6. package/src/batch/engine-crash-guard.mjs +143 -0
  7. package/src/batch/engine-lanes/matrix-run.mjs +28 -2
  8. package/src/batch/engine-lanes/matrix.mjs +143 -8
  9. package/src/batch/integrate-dirty-overlap.mjs +35 -0
  10. package/src/batch/integrate-worktree.mjs +106 -13
  11. package/src/batch/integrate.mjs +34 -93
  12. package/src/batch/journal-checksum.mjs +26 -0
  13. package/src/batch/journal.mjs +32 -13
  14. package/src/batch/lifecycle-archive.mjs +8 -2
  15. package/src/batch/lifecycle.mjs +2 -2
  16. package/src/batch/reconcile-batch.mjs +26 -19
  17. package/src/batch/reconcile-classify.mjs +21 -11
  18. package/src/batch/reconcile-diagnosis-context.mjs +1 -2
  19. package/src/batch/reconcile-diagnosis.mjs +18 -19
  20. package/src/batch/reconcile-light-cache.mjs +0 -1
  21. package/src/batch/reconcile-orphan.mjs +9 -8
  22. package/src/batch/reconcile.mjs +0 -1
  23. package/src/batch/salvage-batch-integrate.mjs +13 -17
  24. package/src/batch/state.mjs +22 -1
  25. package/src/batch/worker-heartbeat.mjs +29 -8
  26. package/src/batch/worker-host.mjs +29 -4
  27. package/src/batch/worker-output.mjs +9 -6
  28. package/src/batch/worker-prompt.mjs +4 -2
  29. package/src/batch/worker-spawn.mjs +99 -12
  30. package/src/config/preflight/discovery.mjs +20 -12
  31. package/src/doctor/run-doctor-checks.mjs +41 -3
  32. package/src/planner/scope.mjs +3 -1
  33. package/src/tasks/packet/discover.mjs +59 -3
@@ -1,12 +1,68 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
 
4
+ /**
5
+ * Canonical task-ID discovery patterns (single source of truth).
6
+ * Closes #300: every discovery site (planner, preflight, worker runner)
7
+ * derives its patterns from here so SP-1000+ is found, sorted numerically,
8
+ * and non-task folders (`_explore`, `_authoring`, `_archive`) are excluded.
9
+ */
10
+
11
+ /** Source pattern for a task ID (PREFIX-###, three or more digits), for embedding in larger regexes. */
12
+ export const TASK_ID_PATTERN_SOURCE = "[A-Z][A-Z0-9]*-\\d{3,}";
13
+
14
+ /** Task ID: PREFIX-### (e.g. TP-007, SP-1000). Keeps the planner's existing prefix rule. */
15
+ export const TASK_ID_RE = new RegExp(`^${TASK_ID_PATTERN_SOURCE}$`);
16
+
4
17
  /** Folder name: PREFIX-###-slug (e.g. TP-007-taskplane-parsers). */
5
- export const TASK_FOLDER_RE = /^([A-Z][A-Z0-9]*-\d{3})-([a-z0-9][a-z0-9-]*)$/;
18
+ export const TASK_FOLDER_RE = new RegExp(
19
+ `^(${TASK_ID_PATTERN_SOURCE})-([a-z0-9][a-z0-9-]*)$`,
20
+ );
21
+
22
+ /** Prefix + digits of a conforming task ID, for numeric comparison. */
23
+ const TASK_ID_PARTS_RE = /^([A-Z][A-Z0-9]*)-(\d{3,})$/;
24
+
25
+ /**
26
+ * Extract the task ID from a folder name (PREFIX-###-slug or bare PREFIX-###).
27
+ * Returns null when the name is not a task folder (e.g. `_explore`).
28
+ *
29
+ * @param {string} name Folder name or path segment
30
+ * @returns {string | null}
31
+ */
32
+ export function taskIdFromFolderName(name) {
33
+ const base = String(name ?? "").split("/").pop() ?? "";
34
+ const folder = TASK_FOLDER_RE.exec(base);
35
+ if (folder) return folder[1];
36
+ const bare = TASK_ID_RE.exec(base);
37
+ return bare ? bare[0] : null;
38
+ }
39
+
40
+ /**
41
+ * Compare two task IDs: prefix first, then digits numerically.
42
+ * Non-conforming IDs sort after conforming ones, by string.
43
+ *
44
+ * @param {string} a
45
+ * @param {string} b
46
+ * @returns {number}
47
+ */
48
+ export function compareTaskIds(a, b) {
49
+ const pa = TASK_ID_PARTS_RE.exec(String(a ?? ""));
50
+ const pb = TASK_ID_PARTS_RE.exec(String(b ?? ""));
51
+ if (pa && pb) {
52
+ if (pa[1] !== pb[1]) return pa[1].localeCompare(pb[1]);
53
+ const da = Number(pa[2]);
54
+ const db = Number(pb[2]);
55
+ if (da !== db) return da - db;
56
+ return 0;
57
+ }
58
+ if (pa) return -1;
59
+ if (pb) return 1;
60
+ return String(a ?? "").localeCompare(String(b ?? ""));
61
+ }
6
62
 
7
63
  /**
8
64
  * Discover Taskplane task packets under `{tasksRoot}/{PREFIX-###-slug}/PROMPT.md`.
9
- * FR-TASK-01.
65
+ * FR-TASK-01. Results sort numerically: SP-099 < SP-999 < SP-1000.
10
66
  *
11
67
  * @param {string} tasksRoot Absolute or relative path to tasks root (e.g. spine-tasks)
12
68
  * @returns {Array<{ taskId: string, slug: string, folderName: string, folderPath: string, promptPath: string }>}
@@ -35,6 +91,6 @@ export function discoverTasks(tasksRoot) {
35
91
  });
36
92
  }
37
93
 
38
- tasks.sort((a, b) => a.taskId.localeCompare(b.taskId));
94
+ tasks.sort((a, b) => compareTaskIds(a.taskId, b.taskId));
39
95
  return tasks;
40
96
  }