pi-spine 1.1.0 → 1.2.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 (102) hide show
  1. package/bin/spine-batch.mjs +160 -53
  2. package/bin/spine-cli/batch.mjs +3 -3
  3. package/bin/spine-cli/lane-logs.mjs +24 -0
  4. package/bin/spine-cli/scenarios.mjs +298 -0
  5. package/bin/spine-cli/wait.mjs +30 -0
  6. package/bin/spine-cli/watch.mjs +27 -0
  7. package/bin/spine-issue.mjs +196 -0
  8. package/bin/spine-journal.mjs +1 -0
  9. package/bin/spine-run.mjs +30 -0
  10. package/bin/spine-status.mjs +19 -1
  11. package/bin/spine-tasks.mjs +16 -2
  12. package/bin/spine-worker-runner.mjs +10 -10
  13. package/bin/spine.mjs +49 -1
  14. package/package.json +1 -1
  15. package/skills/create-spine-tasks/references/contract-template.md +19 -0
  16. package/src/batch/abort.mjs +2 -11
  17. package/src/batch/agent-session-worker.mjs +45 -5
  18. package/src/batch/attached-engine-handoff.mjs +188 -0
  19. package/src/batch/attached-runner.mjs +312 -0
  20. package/src/batch/contract-prelanded.mjs +180 -0
  21. package/src/batch/contract-verify.mjs +140 -2
  22. package/src/batch/detached-start.mjs +66 -2
  23. package/src/batch/diagnosis-alternatives.mjs +46 -0
  24. package/src/batch/diagnosis-merge-failure.mjs +79 -0
  25. package/src/batch/diagnosis-retry-limbo.mjs +34 -0
  26. package/src/batch/diagnosis-stub.mjs +109 -0
  27. package/src/batch/diagnosis-task-done.mjs +110 -0
  28. package/src/batch/diagnosis-worker-done-missing.mjs +96 -0
  29. package/src/batch/diagnosis.mjs +135 -68
  30. package/src/batch/engine-lanes/merge.mjs +110 -82
  31. package/src/batch/engine-lanes/queue.mjs +4 -1
  32. package/src/batch/engine-lanes/watch.mjs +29 -0
  33. package/src/batch/engine-lanes.mjs +1 -0
  34. package/src/batch/engine-scope.mjs +11 -1
  35. package/src/batch/engine.mjs +79 -24
  36. package/src/batch/evidence.mjs +78 -15
  37. package/src/batch/gate.mjs +43 -14
  38. package/src/batch/git-helpers.mjs +96 -0
  39. package/src/batch/heartbeat.mjs +73 -7
  40. package/src/batch/integrate.mjs +2 -4
  41. package/src/batch/journal.mjs +3 -0
  42. package/src/batch/lane-commit.mjs +90 -5
  43. package/src/batch/lifecycle.mjs +130 -3
  44. package/src/batch/macro-phase.mjs +226 -0
  45. package/src/batch/merge/adoption-doc-merge.mjs +93 -10
  46. package/src/batch/merge/wave-merge-state.mjs +3 -0
  47. package/src/batch/metrics.mjs +74 -5
  48. package/src/batch/orphan-detect.mjs +74 -0
  49. package/src/batch/pause.mjs +223 -0
  50. package/src/batch/post-merge-limbo.mjs +264 -8
  51. package/src/batch/reconcile.mjs +429 -54
  52. package/src/batch/resume-common.mjs +5 -1
  53. package/src/batch/resume-lane-reviews.mjs +16 -0
  54. package/src/batch/resume-multi-lanes.mjs +56 -1
  55. package/src/batch/resume-multi-validate.mjs +67 -6
  56. package/src/batch/resume-multi.mjs +9 -4
  57. package/src/batch/resume.mjs +52 -45
  58. package/src/batch/retry.mjs +56 -5
  59. package/src/batch/review-spawn.mjs +8 -2
  60. package/src/batch/rules-manifest-drift.mjs +157 -0
  61. package/src/batch/salvage.mjs +2 -1
  62. package/src/batch/sequence.mjs +454 -0
  63. package/src/batch/state.mjs +18 -3
  64. package/src/batch/status-json.mjs +67 -0
  65. package/src/batch/task-stall-budget.mjs +22 -10
  66. package/src/batch/worker-host.mjs +95 -7
  67. package/src/batch/worker-output.mjs +196 -3
  68. package/src/cli/issue-draft.mjs +180 -0
  69. package/src/cli/journal-follow.mjs +239 -0
  70. package/src/cli/lane-logs.mjs +291 -0
  71. package/src/cli/sequence.mjs +108 -0
  72. package/src/cli/settings-set.mjs +2 -21
  73. package/src/cli/wait.mjs +187 -0
  74. package/src/cli/watch.mjs +160 -0
  75. package/src/config/agent-model-resolve.mjs +48 -0
  76. package/src/config/cursor-rules/discover.mjs +3 -21
  77. package/src/config/defaults.mjs +7 -1
  78. package/src/config/settings-fields.mjs +48 -0
  79. package/src/config/spine-init-constants.mjs +1 -0
  80. package/src/config/spine-preflight-lib.mjs +471 -16
  81. package/src/dashboard/lane-throughput.mjs +351 -0
  82. package/src/dashboard/public/dashboard.css +25 -1
  83. package/src/dashboard/public/dashboard.js +223 -18
  84. package/src/dashboard/public/index.html +14 -2
  85. package/src/dashboard/server.mjs +4 -0
  86. package/src/dashboard/snapshot.mjs +215 -1
  87. package/src/dashboard/view.mjs +170 -17
  88. package/src/doctor/agent-model-inherit.mjs +61 -6
  89. package/src/doctor/run-doctor-checks.mjs +26 -1
  90. package/src/doctor/sequence-safety.mjs +57 -0
  91. package/src/doctor/stale-worktrees.mjs +102 -0
  92. package/src/fixtures/scenario-registry.mjs +194 -0
  93. package/src/fs/atomic-write.mjs +49 -0
  94. package/src/planner/file-scope.mjs +246 -0
  95. package/src/planner/format-plan.mjs +9 -7
  96. package/src/planner/index.mjs +6 -2
  97. package/src/planner/wave-scope.mjs +136 -0
  98. package/src/planner/waves.mjs +133 -0
  99. package/src/tasks/packet/index.mjs +1 -0
  100. package/src/tasks/packet/parse-prompt.mjs +42 -1
  101. package/src/tasks/packet/validate-prompt.mjs +124 -0
  102. package/templates/spine-config.json +8 -1
@@ -20,9 +20,19 @@ import {
20
20
  import { discoverTasks } from "../tasks/packet/discover.mjs";
21
21
  import { NO_PENDING_TASKS_ERROR } from "../planner/scope.mjs";
22
22
  import { summarizePendingScope } from "../planner/pending.mjs";
23
- import { validatePrompt } from "../tasks/packet/validate-prompt.mjs";
23
+ import { validatePrompt, collectStaleFileScopeMustChangeWarnings } from "../tasks/packet/validate-prompt.mjs";
24
+ import { isRunMetricsAppendOnlyDrift } from "../batch/metrics.mjs";
25
+ import { METRICS_DEFAULTS } from "./defaults.mjs";
26
+ import { parseContract, parsePrompt } from "../tasks/packet/parse-prompt.mjs";
27
+ import { hasReleaseCriticalContract, isStubWorkerMode } from "../batch/contract-verify.mjs";
24
28
 
25
29
  const HEALTHY_ACTIVE_PHASES = new Set(["planning", "running", "paused"]);
30
+ /** High-risk paths that together block lane→orch auto-resolution (issue #37). */
31
+ export const PRD_REL_PATH = "docs/PRD.md";
32
+ export const ORCH_MULTI_FILE_MERGE_RISK_PATHS = Object.freeze([
33
+ PRD_REL_PATH,
34
+ RULES_MANIFEST_REL_PATH,
35
+ ]);
26
36
  const LIMBO_DIAGNOSES = new Set(["limbo_stale", "completed_manual"]);
27
37
  const DEPENDENCIES_SCHEMA_VERSION = 1;
28
38
  const TASK_ID_PATTERN = /^[A-Z]{2,}-\d{3,}$/;
@@ -191,6 +201,23 @@ export function checkGitClean(ctx) {
191
201
  );
192
202
  }
193
203
 
204
+ const configResult = loadSpineConfig(ctx.projectRoot);
205
+ const metricsRelPath = configResult?.config?.metrics?.path ?? METRICS_DEFAULTS.path;
206
+ const metricsDrift = isRunMetricsAppendOnlyDrift(ctx.projectRoot, dirtyPaths, metricsRelPath);
207
+ if (metricsDrift.ok) {
208
+ return makeCheck(
209
+ "git-clean",
210
+ true,
211
+ `working tree clean (${metricsRelPath} append-only drift ignored)`,
212
+ {
213
+ details: {
214
+ metricsAppendOnlyDrift: true,
215
+ metricsPath: metricsDrift.metricsPath,
216
+ },
217
+ },
218
+ );
219
+ }
220
+
194
221
  const listed = dirtyPaths.slice(0, 20);
195
222
  const suffix =
196
223
  dirtyPaths.length > listed.length ? ` (+${dirtyPaths.length - listed.length} more)` : "";
@@ -582,6 +609,389 @@ export function checkTasksValidate(ctx) {
582
609
  }
583
610
  }
584
611
 
612
+ /**
613
+ * Warn when stub workers are about to run tasks with release-critical `fileScopeMustChange` contracts.
614
+ *
615
+ * @param {object} ctx
616
+ * @param {string} ctx.projectRoot
617
+ * @param {ReturnType<typeof loadSpineConfig>} [ctx.configResult]
618
+ */
619
+ export function checkStubReleaseCritical(ctx) {
620
+ if (!isStubWorkerMode()) {
621
+ return makeCheck("stub-release-critical", true, "stub worker mode not active");
622
+ }
623
+
624
+ const configResult = ctx.configResult ?? loadSpineConfig(ctx.projectRoot);
625
+ const tasksRootPath = resolveTasksRoot(ctx.projectRoot, configResult);
626
+ if (!tasksRootPath) {
627
+ return makeCheck("stub-release-critical", true, "stub release-critical check skipped (no tasks root)");
628
+ }
629
+
630
+ try {
631
+ const discovered = discoverTasks(tasksRootPath);
632
+ const { pendingIds } = summarizePendingScope(discovered, tasksRootPath);
633
+ /** @type {string[]} */
634
+ const criticalTaskIds = [];
635
+
636
+ for (const discoveredTask of discovered) {
637
+ if (!pendingIds.includes(discoveredTask.taskId)) continue;
638
+ const promptMarkdown = fs.readFileSync(
639
+ path.join(discoveredTask.folderPath, "PROMPT.md"),
640
+ "utf-8",
641
+ );
642
+ const parsedContract = parseContract(promptMarkdown);
643
+ if (hasReleaseCriticalContract(parsedContract)) {
644
+ criticalTaskIds.push(discoveredTask.taskId);
645
+ }
646
+ }
647
+
648
+ if (criticalTaskIds.length === 0) {
649
+ return makeCheck(
650
+ "stub-release-critical",
651
+ true,
652
+ "no pending tasks with fileScopeMustChange contracts",
653
+ );
654
+ }
655
+
656
+ const preview = criticalTaskIds.slice(0, 8).join(", ");
657
+ const suffix =
658
+ criticalTaskIds.length > 8 ? ` (+${criticalTaskIds.length - 8} more)` : "";
659
+ return makeCheck(
660
+ "stub-release-critical",
661
+ true,
662
+ `SPINE_WORKER_STUB=1 with ${criticalTaskIds.length} pending task(s) requiring file-scope changes (${preview}${suffix})`,
663
+ {
664
+ warning: true,
665
+ details: { taskIds: criticalTaskIds },
666
+ suggestedCommand: "unset SPINE_WORKER_STUB",
667
+ },
668
+ );
669
+ } catch (err) {
670
+ const message = err?.message ?? String(err);
671
+ return makeCheck(
672
+ "stub-release-critical",
673
+ true,
674
+ `stub release-critical check skipped: ${message}`,
675
+ );
676
+ }
677
+ }
678
+
679
+ /**
680
+ * @param {{ title?: string | null, missionText?: string, folderName?: string }} task
681
+ */
682
+ export function isMergeOriginMainTask(task) {
683
+ const haystack = `${task.title ?? ""}\n${task.missionText ?? ""}\n${task.folderName ?? ""}`.toLowerCase();
684
+ if (/merge[-_\s]+origin[-_\s]+main/.test(haystack)) {
685
+ return true;
686
+ }
687
+ return haystack.includes("origin/main") && /\bmerge\b/.test(haystack);
688
+ }
689
+
690
+ /**
691
+ * @param {string} projectRoot
692
+ * @param {string} ref
693
+ */
694
+ function gitRefExists(projectRoot, ref) {
695
+ try {
696
+ execFileSync("git", ["rev-parse", "--verify", ref], {
697
+ cwd: projectRoot,
698
+ stdio: ["ignore", "ignore", "pipe"],
699
+ timeout: 5000,
700
+ });
701
+ return true;
702
+ } catch {
703
+ return false;
704
+ }
705
+ }
706
+
707
+ /**
708
+ * @param {string} projectRoot
709
+ */
710
+ function resolveOriginMainRef(projectRoot) {
711
+ for (const ref of ["origin/main", "refs/remotes/origin/main"]) {
712
+ if (gitRefExists(projectRoot, ref)) {
713
+ return ref;
714
+ }
715
+ }
716
+ return null;
717
+ }
718
+
719
+ /**
720
+ * @param {string} projectRoot
721
+ * @param {string} ref
722
+ * @param {string} filePath
723
+ */
724
+ function pathExistsAtRef(projectRoot, ref, filePath) {
725
+ try {
726
+ execFileSync("git", ["cat-file", "-e", `${ref}:${filePath}`], {
727
+ cwd: projectRoot,
728
+ stdio: "ignore",
729
+ timeout: 5000,
730
+ });
731
+ return true;
732
+ } catch {
733
+ return false;
734
+ }
735
+ }
736
+
737
+ /**
738
+ * @param {string} projectRoot
739
+ * @param {string} refA
740
+ * @param {string} refB
741
+ * @param {string} filePath
742
+ */
743
+ function refsDifferOnPath(projectRoot, refA, refB, filePath) {
744
+ const aExists = pathExistsAtRef(projectRoot, refA, filePath);
745
+ const bExists = pathExistsAtRef(projectRoot, refB, filePath);
746
+ if (!aExists && !bExists) {
747
+ return false;
748
+ }
749
+ if (aExists !== bExists) {
750
+ return true;
751
+ }
752
+ try {
753
+ execFileSync("git", ["diff", "--quiet", refA, refB, "--", filePath], {
754
+ cwd: projectRoot,
755
+ stdio: "ignore",
756
+ timeout: 5000,
757
+ });
758
+ return false;
759
+ } catch {
760
+ return true;
761
+ }
762
+ }
763
+
764
+ /**
765
+ * @param {string} projectRoot
766
+ * @param {string} headRef
767
+ * @param {string} originMainRef
768
+ */
769
+ export function listDivergentOrchMergeRiskPaths(projectRoot, headRef, originMainRef) {
770
+ return ORCH_MULTI_FILE_MERGE_RISK_PATHS.filter((filePath) =>
771
+ refsDifferOnPath(projectRoot, headRef, originMainRef, filePath),
772
+ );
773
+ }
774
+
775
+ /**
776
+ * Predict multi-file lane→orch merge conflicts when a pending task merges origin/main.
777
+ *
778
+ * @param {object} ctx
779
+ * @param {string} ctx.projectRoot
780
+ * @param {ReturnType<typeof loadSpineConfig>} [ctx.configResult]
781
+ */
782
+ export function predictOrchMergeConflictRisk(ctx) {
783
+ const { projectRoot, configResult } = ctx;
784
+ const loaded = configResult ?? loadSpineConfig(projectRoot);
785
+ const tasksRootPath = resolveTasksRoot(projectRoot, loaded);
786
+ if (!tasksRootPath) {
787
+ return { risky: false, reason: "no_tasks_root" };
788
+ }
789
+
790
+ const originMainRef = resolveOriginMainRef(projectRoot);
791
+ if (!originMainRef) {
792
+ return { risky: false, reason: "no_origin_main" };
793
+ }
794
+
795
+ const headRef = "HEAD";
796
+ if (!gitRefExists(projectRoot, headRef)) {
797
+ return { risky: false, reason: "no_head" };
798
+ }
799
+
800
+ const divergentPaths = listDivergentOrchMergeRiskPaths(projectRoot, headRef, originMainRef);
801
+ const hasPrdDivergence = divergentPaths.includes(PRD_REL_PATH);
802
+ const hasManifestDivergence = divergentPaths.includes(RULES_MANIFEST_REL_PATH);
803
+ if (!hasPrdDivergence || !hasManifestDivergence) {
804
+ return {
805
+ risky: false,
806
+ reason: "paths_not_divergent",
807
+ divergentPaths,
808
+ originMainRef,
809
+ headRef,
810
+ };
811
+ }
812
+
813
+ try {
814
+ const discovered = discoverTasks(tasksRootPath);
815
+ const { pendingIds } = summarizePendingScope(discovered, tasksRootPath);
816
+ /** @type {string[]} */
817
+ const mergeOriginTaskIds = [];
818
+
819
+ for (const discoveredTask of discovered) {
820
+ if (!pendingIds.includes(discoveredTask.taskId)) continue;
821
+ const promptMarkdown = fs.readFileSync(
822
+ path.join(discoveredTask.folderPath, "PROMPT.md"),
823
+ "utf-8",
824
+ );
825
+ const parsed = parsePrompt(promptMarkdown);
826
+ if (
827
+ isMergeOriginMainTask({
828
+ title: parsed.title,
829
+ missionText: parsed.sections.Mission ?? "",
830
+ folderName: path.basename(discoveredTask.folderPath),
831
+ })
832
+ ) {
833
+ mergeOriginTaskIds.push(discoveredTask.taskId);
834
+ }
835
+ }
836
+
837
+ if (mergeOriginTaskIds.length === 0) {
838
+ return {
839
+ risky: false,
840
+ reason: "no_merge_origin_main_task",
841
+ divergentPaths,
842
+ originMainRef,
843
+ headRef,
844
+ };
845
+ }
846
+
847
+ return {
848
+ risky: true,
849
+ mergeOriginTaskIds,
850
+ divergentPaths,
851
+ originMainRef,
852
+ headRef,
853
+ };
854
+ } catch (err) {
855
+ return {
856
+ risky: false,
857
+ reason: "error",
858
+ message: err?.message ?? String(err),
859
+ };
860
+ }
861
+ }
862
+
863
+ /**
864
+ * Warn when pending merge-origin-main tasks predict PRD + rules-manifest orch merge conflicts.
865
+ *
866
+ * @param {object} ctx
867
+ * @param {string} ctx.projectRoot
868
+ * @param {ReturnType<typeof loadSpineConfig>} [ctx.configResult]
869
+ */
870
+ export function checkOrchMergeConflictWarn(ctx) {
871
+ const risk = predictOrchMergeConflictRisk(ctx);
872
+ if (!risk.risky) {
873
+ const skipMessage =
874
+ risk.reason === "no_merge_origin_main_task"
875
+ ? "no pending merge-origin-main tasks"
876
+ : risk.reason === "no_origin_main"
877
+ ? "orch merge conflict check skipped (origin/main unavailable)"
878
+ : "no predictable multi-file orch merge conflicts";
879
+ return makeCheck("orch-merge-conflict", true, skipMessage);
880
+ }
881
+
882
+ const taskPreview = risk.mergeOriginTaskIds.slice(0, 5).join(", ");
883
+ const pathList = risk.divergentPaths.join(", ");
884
+ return makeCheck(
885
+ "orch-merge-conflict",
886
+ true,
887
+ `pending merge-origin-main task(s) (${taskPreview}) with ${pathList} divergent between HEAD and ${risk.originMainRef} — wave merge may fail on multi-file conflicts`,
888
+ {
889
+ warning: true,
890
+ details: risk,
891
+ suggestedCommand:
892
+ "merge origin/main into main before batch or resolve docs/PRD.md + rules-manifest drift manually",
893
+ },
894
+ );
895
+ }
896
+
897
+ function formatOrchMergeConflictPlanWarning(risk) {
898
+ const taskPreview = risk.mergeOriginTaskIds.slice(0, 5).join(", ");
899
+ const pathList = risk.divergentPaths.join(", ");
900
+ return [
901
+ "⚠️ Orch merge risk: pending merge-origin-main task(s)",
902
+ `(${taskPreview}) with ${pathList} divergent between HEAD and ${risk.originMainRef}.`,
903
+ "Wave merge may fail when automatic resolution cannot handle PRD + manifest together.",
904
+ ].join(" ");
905
+ }
906
+
907
+ /**
908
+ * List pending tasks whose fileScopeMustChange paths already changed on main since PROMPT intro.
909
+ *
910
+ * @param {object} ctx
911
+ * @param {string} ctx.projectRoot
912
+ * @param {ReturnType<typeof loadSpineConfig>} [ctx.configResult]
913
+ */
914
+ export function listPrelandedFileScopeStaleTasks(ctx) {
915
+ const configResult = ctx.configResult ?? loadSpineConfig(ctx.projectRoot);
916
+ const tasksRootPath = resolveTasksRoot(ctx.projectRoot, configResult);
917
+ if (!tasksRootPath) {
918
+ return [];
919
+ }
920
+
921
+ const discovered = discoverTasks(tasksRootPath);
922
+ const { pendingIds } = summarizePendingScope(discovered, tasksRootPath);
923
+ /** @type {Array<{ taskId: string, warnings: string[] }>} */
924
+ const staleTasks = [];
925
+
926
+ for (const discoveredTask of discovered) {
927
+ if (!pendingIds.includes(discoveredTask.taskId)) continue;
928
+ const promptPath = path.join(discoveredTask.folderPath, "PROMPT.md");
929
+ const promptMarkdown = fs.readFileSync(promptPath, "utf-8");
930
+ const parsedContract = parseContract(promptMarkdown);
931
+ const promptRelPath = path.relative(ctx.projectRoot, promptPath);
932
+ const warnings = collectStaleFileScopeMustChangeWarnings(
933
+ ctx.projectRoot,
934
+ parsedContract,
935
+ promptRelPath,
936
+ );
937
+ if (warnings.length > 0) {
938
+ staleTasks.push({ taskId: discoveredTask.taskId, warnings });
939
+ }
940
+ }
941
+
942
+ return staleTasks;
943
+ }
944
+
945
+ /**
946
+ * Warn when pending tasks have fileScopeMustChange paths already changed on main (issue #56).
947
+ *
948
+ * @param {object} ctx
949
+ * @param {string} ctx.projectRoot
950
+ * @param {ReturnType<typeof loadSpineConfig>} [ctx.configResult]
951
+ */
952
+ export function checkPrelandedFileScopeWarn(ctx) {
953
+ try {
954
+ const staleTasks = listPrelandedFileScopeStaleTasks(ctx);
955
+ if (staleTasks.length === 0) {
956
+ return makeCheck(
957
+ "prelanded-file-scope",
958
+ true,
959
+ "no pending tasks with stale fileScopeMustChange vs main",
960
+ );
961
+ }
962
+
963
+ const preview = staleTasks.map((entry) => entry.taskId).slice(0, 5).join(", ");
964
+ const suffix = staleTasks.length > 5 ? ` (+${staleTasks.length - 5} more)` : "";
965
+ return makeCheck(
966
+ "prelanded-file-scope",
967
+ true,
968
+ `${staleTasks.length} pending task(s) with fileScopeMustChange already changed on main (${preview}${suffix})`,
969
+ {
970
+ warning: true,
971
+ details: { staleTasks },
972
+ suggestedCommand:
973
+ "spine tasks validate pending --warnings-only; amend PROMPT ## Contract before batch start",
974
+ },
975
+ );
976
+ } catch (err) {
977
+ const message = err?.message ?? String(err);
978
+ return makeCheck(
979
+ "prelanded-file-scope",
980
+ true,
981
+ `prelanded file-scope check skipped: ${message}`,
982
+ );
983
+ }
984
+ }
985
+
986
+ function formatPrelandedFileScopePlanWarning(staleTasks) {
987
+ const preview = staleTasks.map((entry) => entry.taskId).slice(0, 5).join(", ");
988
+ return [
989
+ "⚠️ Pre-landed contract risk: pending task(s)",
990
+ `(${preview}) have fileScopeMustChange paths already changed on main.`,
991
+ "Amend PROMPT ## Contract before batch start or expect contract rework loops.",
992
+ ].join(" ");
993
+ }
994
+
585
995
  /**
586
996
  * @param {object} ctx
587
997
  */
@@ -608,38 +1018,78 @@ export function runPreflightPlanCheck(ctx) {
608
1018
  try {
609
1019
  const discovered = discoverTasks(tasksRootPath);
610
1020
  const { pendingIds, excludedCount } = summarizePendingScope(discovered, tasksRootPath);
1021
+ const orchMergeRisk = predictOrchMergeConflictRisk(ctx);
1022
+ const prelandedFileScopeTasks = listPrelandedFileScopeStaleTasks(ctx);
611
1023
  if (pendingIds.length === 0) {
612
1024
  const maxParallel = config.lanes?.maxParallel ?? 1;
1025
+ const lines = [
1026
+ "Spine plan — pending",
1027
+ `0 task(s) · 0 wave(s) · maxParallel ${maxParallel}`,
1028
+ `${excludedCount} excluded (.DONE on disk)`,
1029
+ ];
1030
+ if (orchMergeRisk.risky) {
1031
+ lines.push(formatOrchMergeConflictPlanWarning(orchMergeRisk));
1032
+ }
1033
+ if (prelandedFileScopeTasks.length > 0) {
1034
+ lines.push(formatPrelandedFileScopePlanWarning(prelandedFileScopeTasks));
1035
+ }
613
1036
  return {
614
1037
  status: "ok",
615
- message: [
616
- "Spine plan — pending",
617
- `0 task(s) · 0 wave(s) · maxParallel ${maxParallel}`,
618
- `${excludedCount} excluded (.DONE on disk)`,
619
- ].join("\n"),
620
- details: { waves: 0, pendingCount: 0, excludedCount },
1038
+ message: lines.join("\n"),
1039
+ details: {
1040
+ waves: 0,
1041
+ pendingCount: 0,
1042
+ excludedCount,
1043
+ orchMergeConflictRisk: orchMergeRisk,
1044
+ prelandedFileScopeTasks,
1045
+ },
621
1046
  };
622
1047
  }
623
1048
 
624
1049
  const plan = buildPlan({ scope: "pending", config, tasksRoot: tasksRootPath });
625
1050
  const waveCount = plan.waves?.length ?? 0;
1051
+ const planText = formatPlanHuman(plan).trimEnd();
1052
+ const planWarnings = [];
1053
+ if (orchMergeRisk.risky) {
1054
+ planWarnings.push(formatOrchMergeConflictPlanWarning(orchMergeRisk));
1055
+ }
1056
+ if (prelandedFileScopeTasks.length > 0) {
1057
+ planWarnings.push(formatPrelandedFileScopePlanWarning(prelandedFileScopeTasks));
1058
+ }
626
1059
  return {
627
1060
  status: "ok",
628
- message: `${formatPlanHuman(plan).trimEnd()}`,
629
- details: { waves: waveCount },
1061
+ message:
1062
+ planWarnings.length > 0
1063
+ ? `${planText}\n\n${planWarnings.join("\n\n")}`
1064
+ : planText,
1065
+ details: { waves: waveCount, orchMergeConflictRisk: orchMergeRisk, prelandedFileScopeTasks },
630
1066
  };
631
1067
  } catch (err) {
632
1068
  const msg = err?.message ?? String(err);
633
1069
  if (msg === NO_PENDING_TASKS_ERROR) {
634
1070
  const maxParallel = config.lanes?.maxParallel ?? 1;
1071
+ const orchMergeRisk = predictOrchMergeConflictRisk(ctx);
1072
+ const prelandedFileScopeTasks = listPrelandedFileScopeStaleTasks(ctx);
1073
+ const lines = [
1074
+ "Spine plan — pending",
1075
+ `0 task(s) · 0 wave(s) · maxParallel ${maxParallel}`,
1076
+ "All discovered tasks have .DONE on disk",
1077
+ ];
1078
+ if (orchMergeRisk.risky) {
1079
+ lines.push(formatOrchMergeConflictPlanWarning(orchMergeRisk));
1080
+ }
1081
+ if (prelandedFileScopeTasks.length > 0) {
1082
+ lines.push(formatPrelandedFileScopePlanWarning(prelandedFileScopeTasks));
1083
+ }
635
1084
  return {
636
1085
  status: "ok",
637
- message: [
638
- "Spine plan — pending",
639
- `0 task(s) · 0 wave(s) · maxParallel ${maxParallel}`,
640
- "All discovered tasks have .DONE on disk",
641
- ].join("\n"),
642
- details: { waves: 0, pendingCount: 0 },
1086
+ message: lines.join("\n"),
1087
+ details: {
1088
+ waves: 0,
1089
+ pendingCount: 0,
1090
+ orchMergeConflictRisk: orchMergeRisk,
1091
+ prelandedFileScopeTasks,
1092
+ },
643
1093
  };
644
1094
  }
645
1095
  return {
@@ -690,6 +1140,9 @@ export function runBatchPreflight(options) {
690
1140
  checks.push(checkDependenciesJson(ctx));
691
1141
  checks.push(checkWorktreeSetupHook(ctx));
692
1142
  checks.push(checkTasksValidate(ctx));
1143
+ checks.push(checkStubReleaseCritical(ctx));
1144
+ checks.push(checkOrchMergeConflictWarn(ctx));
1145
+ checks.push(checkPrelandedFileScopeWarn(ctx));
693
1146
 
694
1147
  const plan = runPreflightPlanCheck(ctx);
695
1148
  checks.push(
@@ -709,10 +1162,12 @@ export function runBatchPreflight(options) {
709
1162
  export function formatPreflightHuman(result) {
710
1163
  const lines = ["\nBatch preflight\n"];
711
1164
  for (const check of result.checks) {
712
- const icon = check.ok ? "✅" : "❌";
1165
+ const icon = !check.ok ? "❌" : check.warning ? "⚠️" : "✅";
713
1166
  lines.push(` ${icon} ${check.id}: ${check.message}`);
714
1167
  if (!check.ok && check.suggestedCommand) {
715
1168
  lines.push(` → ${check.suggestedCommand}`);
1169
+ } else if (check.warning && check.suggestedCommand) {
1170
+ lines.push(` → ${check.suggestedCommand}`);
716
1171
  }
717
1172
  }
718
1173
  lines.push("");