pi-spine 1.2.0 → 1.3.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 +4 -4
- package/bin/spine-cli/verify.mjs +3 -0
- package/bin/spine-plan.mjs +49 -1
- package/bin/spine-worker-runner.mjs +136 -4
- package/package.json +1 -1
- package/skills/create-spine-tasks/SKILL.md +7 -2
- package/skills/create-spine-tasks/references/contract-template.md +95 -3
- package/src/batch/attached-runner.mjs +81 -5
- package/src/batch/contract-stub-delivery.mjs +110 -0
- package/src/batch/contract-task-start.mjs +204 -0
- package/src/batch/contract-verify.mjs +55 -8
- package/src/batch/detached-start.mjs +72 -2
- package/src/batch/diagnosis-launch-failure.mjs +114 -0
- package/src/batch/diagnosis-primary-failure.mjs +89 -0
- package/src/batch/diagnosis-tail-state.mjs +57 -0
- package/src/batch/diagnosis.mjs +22 -113
- package/src/batch/engine-lanes/commit.mjs +145 -0
- package/src/batch/engine-lanes/review.mjs +67 -87
- package/src/batch/engine-lanes.mjs +21 -79
- package/src/batch/engine.mjs +46 -0
- package/src/batch/heartbeat.mjs +2 -2
- package/src/batch/integrate-assert.mjs +69 -0
- package/src/batch/integrate-worktree.mjs +354 -0
- package/src/batch/integrate.mjs +195 -102
- package/src/batch/journal-rebuild.mjs +48 -2
- package/src/batch/journal.mjs +63 -0
- package/src/batch/lane-dirty-check.mjs +437 -0
- package/src/batch/limbo-detect.mjs +34 -0
- package/src/batch/macro-phase.mjs +76 -0
- package/src/batch/metrics.mjs +2 -0
- package/src/batch/pause.mjs +18 -7
- package/src/batch/post-merge-limbo.mjs +3 -28
- package/src/batch/reconcile.mjs +79 -9
- package/src/batch/resume-common.mjs +27 -0
- package/src/batch/resume-multi-lanes.mjs +11 -0
- package/src/batch/resume-multi.mjs +2 -0
- package/src/batch/resume.mjs +8 -1
- package/src/batch/retry.mjs +41 -10
- package/src/batch/rules-manifest-drift.mjs +43 -2
- package/src/batch/sequence-state.mjs +290 -0
- package/src/batch/sequence.mjs +113 -51
- package/src/batch/state.mjs +16 -0
- package/src/batch/worker-host.mjs +1 -0
- package/src/cli/sequence.mjs +14 -1
- package/src/cli/settings-set.mjs +33 -3
- package/src/config/model-id.mjs +103 -0
- package/src/config/spine-init-constants.mjs +1 -0
- package/src/config/spine-preflight-lib.mjs +23 -1
- package/src/dashboard/public/dashboard.js +14 -3
- package/src/dashboard/running-tail-state.mjs +31 -0
- package/src/dashboard/server.mjs +4 -0
- package/src/dashboard/snapshot.mjs +260 -28
- package/src/dashboard/view.mjs +112 -2
- package/src/doctor/agent-models.mjs +53 -0
- package/src/doctor/batch-size-guidance.mjs +30 -2
- package/src/doctor/pi-extension-conflict.mjs +169 -0
- package/src/doctor/run-doctor-checks.mjs +6 -0
- package/src/planner/scope.mjs +5 -1
- package/src/tasks/packet/parse-prompt.mjs +31 -1
- package/src/tasks/packet/validate-contract.mjs +108 -0
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
|
+
import { isRunningWithoutActiveWorkers } from "./running-tail-state.mjs";
|
|
7
8
|
import { deriveMacroPhase, macroPhaseLabel } from "../batch/macro-phase.mjs";
|
|
8
9
|
import {
|
|
9
10
|
classifyTasks,
|
|
@@ -13,7 +14,7 @@ import {
|
|
|
13
14
|
} from "../batch/reconcile.mjs";
|
|
14
15
|
import { loadGateRecord, formatGateSummary } from "../batch/gate.mjs";
|
|
15
16
|
import {
|
|
16
|
-
|
|
17
|
+
readJournalEventsCached,
|
|
17
18
|
readJournalTail,
|
|
18
19
|
summarizeJournalEvent,
|
|
19
20
|
} from "../batch/journal.mjs";
|
|
@@ -71,7 +72,7 @@ export function heartbeatAgeSeconds(lastHeartbeatAt, now = Date.now()) {
|
|
|
71
72
|
* @param {ReturnType<typeof resolveStallConfig>} params.stallConfig
|
|
72
73
|
* @param {number} [params.now]
|
|
73
74
|
*/
|
|
74
|
-
export function classifyLaneStatus({ lane, classifiedTasks, stallConfig, now = Date.now() }) {
|
|
75
|
+
export function classifyLaneStatus({ lane, classifiedTasks, stallConfig, now = Date.now(), diagnosis = null }) {
|
|
75
76
|
const taskIds = lane.taskIds ?? [];
|
|
76
77
|
const tasks = classifiedTasks.filter((task) => taskIds.includes(task.taskId));
|
|
77
78
|
|
|
@@ -79,8 +80,20 @@ export function classifyLaneStatus({ lane, classifiedTasks, stallConfig, now = D
|
|
|
79
80
|
return "completed";
|
|
80
81
|
}
|
|
81
82
|
|
|
83
|
+
if (diagnosis === "engine_orphaned" || diagnosis === "state_drift" || diagnosis === "needs_retry") {
|
|
84
|
+
const hasOpenWork = tasks.some((task) => {
|
|
85
|
+
const status = String(task.status ?? "").toLowerCase();
|
|
86
|
+
return status === "pending" || status === "running" || status === "failed" || task.doneInLane === true;
|
|
87
|
+
});
|
|
88
|
+
if (hasOpenWork) return diagnosis === "engine_orphaned" ? "stale" : "running";
|
|
89
|
+
}
|
|
90
|
+
|
|
82
91
|
const allDone =
|
|
83
|
-
tasks.length > 0 &&
|
|
92
|
+
tasks.length > 0 &&
|
|
93
|
+
tasks.every((task) => {
|
|
94
|
+
const status = String(task.status ?? "").toLowerCase();
|
|
95
|
+
return status === "succeeded" || status === "skipped";
|
|
96
|
+
});
|
|
84
97
|
if (allDone) return "completed";
|
|
85
98
|
|
|
86
99
|
const hasActive = tasks.some(
|
|
@@ -123,19 +136,63 @@ export function classifyLaneStatus({ lane, classifiedTasks, stallConfig, now = D
|
|
|
123
136
|
* @param {string[]} [params.currentWaveTaskIds]
|
|
124
137
|
*/
|
|
125
138
|
export function computeActiveTaskIdsForLane({ lane, classifiedTasks, currentWaveTaskIds }) {
|
|
139
|
+
const runningTaskId = computeRunningTaskIdForLane({ lane, classifiedTasks, currentWaveTaskIds });
|
|
140
|
+
const queuedTaskIds = computeQueuedTaskIdsForLane({ lane, classifiedTasks, currentWaveTaskIds });
|
|
141
|
+
if (runningTaskId) return [runningTaskId, ...queuedTaskIds];
|
|
142
|
+
return [...queuedTaskIds];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Single running task in the current wave on this physical lane (engine: ≤1 per lane).
|
|
147
|
+
*
|
|
148
|
+
* @param {object} params
|
|
149
|
+
* @param {object} params.lane
|
|
150
|
+
* @param {import("../batch/reconcile.mjs").NormalizedTask[]} params.classifiedTasks
|
|
151
|
+
* @param {string[]} [params.currentWaveTaskIds]
|
|
152
|
+
*/
|
|
153
|
+
export function computeRunningTaskIdForLane({ lane, classifiedTasks, currentWaveTaskIds }) {
|
|
154
|
+
if (!currentWaveTaskIds?.length) return null;
|
|
155
|
+
const waveSet = new Set(currentWaveTaskIds.map(String));
|
|
156
|
+
const running = classifiedTasks.find(
|
|
157
|
+
(task) =>
|
|
158
|
+
task.laneNumber === lane.laneNumber &&
|
|
159
|
+
waveSet.has(task.taskId) &&
|
|
160
|
+
(task.classification === "running" || task.status === "running"),
|
|
161
|
+
);
|
|
162
|
+
return running?.taskId ?? null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Pending tasks in the current wave on this lane, ordered by lane assignment queue.
|
|
167
|
+
*
|
|
168
|
+
* @param {object} params
|
|
169
|
+
* @param {object} params.lane
|
|
170
|
+
* @param {import("../batch/reconcile.mjs").NormalizedTask[]} params.classifiedTasks
|
|
171
|
+
* @param {string[]} [params.currentWaveTaskIds]
|
|
172
|
+
* @param {string[]} [params.laneTaskIds]
|
|
173
|
+
*/
|
|
174
|
+
export function computeQueuedTaskIdsForLane({
|
|
175
|
+
lane,
|
|
176
|
+
classifiedTasks,
|
|
177
|
+
currentWaveTaskIds,
|
|
178
|
+
laneTaskIds,
|
|
179
|
+
}) {
|
|
126
180
|
if (!currentWaveTaskIds?.length) return [];
|
|
127
181
|
const waveSet = new Set(currentWaveTaskIds.map(String));
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
(
|
|
133
|
-
task
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
182
|
+
const assignmentOrder = laneTaskIds ?? lane.taskIds ?? [];
|
|
183
|
+
|
|
184
|
+
const pendingIds = new Set(
|
|
185
|
+
classifiedTasks
|
|
186
|
+
.filter(
|
|
187
|
+
(task) =>
|
|
188
|
+
task.laneNumber === lane.laneNumber &&
|
|
189
|
+
waveSet.has(task.taskId) &&
|
|
190
|
+
(task.classification === "pending" || task.status === "pending"),
|
|
191
|
+
)
|
|
192
|
+
.map((task) => String(task.taskId)),
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
return assignmentOrder.filter((taskId) => pendingIds.has(String(taskId))).map(String);
|
|
139
196
|
}
|
|
140
197
|
|
|
141
198
|
/**
|
|
@@ -379,6 +436,7 @@ export function buildLaneRows({
|
|
|
379
436
|
projectRoot = null,
|
|
380
437
|
batchId = null,
|
|
381
438
|
now = Date.now(),
|
|
439
|
+
diagnosis = null,
|
|
382
440
|
}) {
|
|
383
441
|
const throughputByLane = deriveLanesThroughput({
|
|
384
442
|
lanes,
|
|
@@ -390,6 +448,13 @@ export function buildLaneRows({
|
|
|
390
448
|
return (lanes ?? []).map((lane) => {
|
|
391
449
|
const heartbeatMeta = resolveLaneHeartbeatMeta(lane.laneNumber, journalEvents);
|
|
392
450
|
const heartbeatAgeSecondsValue = heartbeatAgeSeconds(lane.lastHeartbeatAt, now);
|
|
451
|
+
const runningTaskId = computeRunningTaskIdForLane({ lane, classifiedTasks, currentWaveTaskIds });
|
|
452
|
+
const queuedTaskIds = computeQueuedTaskIdsForLane({
|
|
453
|
+
lane,
|
|
454
|
+
classifiedTasks,
|
|
455
|
+
currentWaveTaskIds,
|
|
456
|
+
laneTaskIds: lane.taskIds ?? [],
|
|
457
|
+
});
|
|
393
458
|
const activeTaskIds = computeActiveTaskIdsForLane({ lane, classifiedTasks, currentWaveTaskIds });
|
|
394
459
|
const activity = resolveLaneActivityPhase({
|
|
395
460
|
laneNumber: lane.laneNumber,
|
|
@@ -413,8 +478,10 @@ export function buildLaneRows({
|
|
|
413
478
|
return {
|
|
414
479
|
laneId: lane.laneId ?? `lane-${lane.laneNumber}`,
|
|
415
480
|
laneNumber: lane.laneNumber,
|
|
416
|
-
status: classifyLaneStatus({ lane, classifiedTasks, stallConfig, now }),
|
|
481
|
+
status: classifyLaneStatus({ lane, classifiedTasks, stallConfig, now, diagnosis }),
|
|
417
482
|
activeTaskIds,
|
|
483
|
+
runningTaskId,
|
|
484
|
+
queuedTaskIds,
|
|
418
485
|
activityPhase: activity.activityPhase,
|
|
419
486
|
activityPhaseLabel: activity.activityPhaseLabel,
|
|
420
487
|
taskIds: lane.taskIds ?? [],
|
|
@@ -435,10 +502,36 @@ export function buildLaneRows({
|
|
|
435
502
|
});
|
|
436
503
|
}
|
|
437
504
|
|
|
505
|
+
/**
|
|
506
|
+
* @param {string[]} taskIds
|
|
507
|
+
* @param {import("../batch/reconcile.mjs").NormalizedTask[]} classifiedTasks
|
|
508
|
+
*/
|
|
509
|
+
function waveTasksAllTerminalSuccess(taskIds, classifiedTasks) {
|
|
510
|
+
if (!taskIds.length) return false;
|
|
511
|
+
const byId = new Map((classifiedTasks ?? []).map((task) => [String(task.taskId), task]));
|
|
512
|
+
return taskIds.every((taskId) => byId.get(String(taskId))?.classification === "terminal-success");
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* @param {number} index
|
|
517
|
+
* @param {number} currentWaveIndex
|
|
518
|
+
* @param {string[]} taskIds
|
|
519
|
+
* @param {import("../batch/reconcile.mjs").NormalizedTask[]} [classifiedTasks]
|
|
520
|
+
*/
|
|
521
|
+
function resolveWaveStatus(index, currentWaveIndex, taskIds, classifiedTasks) {
|
|
522
|
+
if (classifiedTasks?.length && waveTasksAllTerminalSuccess(taskIds, classifiedTasks)) {
|
|
523
|
+
return "completed";
|
|
524
|
+
}
|
|
525
|
+
if (index < currentWaveIndex) return "completed";
|
|
526
|
+
if (index === currentWaveIndex) return "active";
|
|
527
|
+
return "pending";
|
|
528
|
+
}
|
|
529
|
+
|
|
438
530
|
/**
|
|
439
531
|
* @param {import("../batch/reconcile.mjs").NormalizedBatchState | Record<string, unknown> | null} batchState
|
|
532
|
+
* @param {import("../batch/reconcile.mjs").NormalizedTask[]} [classifiedTasks]
|
|
440
533
|
*/
|
|
441
|
-
export function buildWaveProgress(batchState) {
|
|
534
|
+
export function buildWaveProgress(batchState, classifiedTasks) {
|
|
442
535
|
const raw =
|
|
443
536
|
batchState && typeof batchState === "object" && "raw" in batchState
|
|
444
537
|
? /** @type {Record<string, unknown>} */ (batchState.raw)
|
|
@@ -451,12 +544,14 @@ export function buildWaveProgress(batchState) {
|
|
|
451
544
|
return {
|
|
452
545
|
currentWaveIndex,
|
|
453
546
|
totalWaves,
|
|
454
|
-
waves: wavePlan.map((entry, index) =>
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
547
|
+
waves: wavePlan.map((entry, index) => {
|
|
548
|
+
const taskIds = Array.isArray(entry) ? entry.map(String) : [];
|
|
549
|
+
return {
|
|
550
|
+
index,
|
|
551
|
+
taskIds,
|
|
552
|
+
status: resolveWaveStatus(index, currentWaveIndex, taskIds, classifiedTasks),
|
|
553
|
+
};
|
|
554
|
+
}),
|
|
460
555
|
};
|
|
461
556
|
}
|
|
462
557
|
|
|
@@ -596,15 +691,140 @@ export function buildLaneLogTail(projectRoot, batchId, laneNumber, activeTaskIds
|
|
|
596
691
|
};
|
|
597
692
|
}
|
|
598
693
|
|
|
694
|
+
const TERMINAL_DIAGNOSES = new Set([
|
|
695
|
+
"completed",
|
|
696
|
+
"completed_manual",
|
|
697
|
+
"limbo_stale",
|
|
698
|
+
"failed",
|
|
699
|
+
"aborted",
|
|
700
|
+
]);
|
|
701
|
+
|
|
702
|
+
/** @type {Record<string, string>} */
|
|
703
|
+
const TAIL_JOURNAL_ACTIVITY_LABELS = {
|
|
704
|
+
"batch.merge_started": "Merging lane branches…",
|
|
705
|
+
"batch.merge_completed": "Merge completed — finalizing batch…",
|
|
706
|
+
"batch.merge_blocked": "Merge blocked — retry or resume",
|
|
707
|
+
"gate.opened": "Integrate gate opened — awaiting approval",
|
|
708
|
+
"gate.evidence_collecting": "Collecting gate evidence…",
|
|
709
|
+
"engine.attached_post_merge_handoff": "Finalizing land loop…",
|
|
710
|
+
"integrate.started": "Integrating to main…",
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
/** @type {Record<string, string>} */
|
|
714
|
+
const TAIL_MACRO_ACTIVITY_LABELS = {
|
|
715
|
+
merging: "Merging lane branches…",
|
|
716
|
+
gating: "Opening integrate gate…",
|
|
717
|
+
integrating: "Integrating to main…",
|
|
718
|
+
reviewing: "Running reviews — no workers scheduled",
|
|
719
|
+
planning: "Planning — no workers scheduled",
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* @param {object[]} [lanes]
|
|
724
|
+
* @returns {boolean}
|
|
725
|
+
*/
|
|
726
|
+
export function lanesHaveActiveTasks(lanes) {
|
|
727
|
+
for (const lane of lanes ?? []) {
|
|
728
|
+
if (lane.runningTaskId) return true;
|
|
729
|
+
if (Array.isArray(lane.queuedTaskIds) && lane.queuedTaskIds.length > 0) return true;
|
|
730
|
+
}
|
|
731
|
+
return false;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* @param {object} params
|
|
736
|
+
* @param {string|null|undefined} params.diagnosis
|
|
737
|
+
* @param {object|null|undefined} params.batch
|
|
738
|
+
* @returns {boolean}
|
|
739
|
+
*/
|
|
740
|
+
function isBatchNonTerminal({ diagnosis, batch }) {
|
|
741
|
+
if (!diagnosis) return false;
|
|
742
|
+
if (TERMINAL_DIAGNOSES.has(diagnosis)) return false;
|
|
743
|
+
if (batch?.endedAt) return false;
|
|
744
|
+
return true;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* @param {object[]} [journalEvents]
|
|
749
|
+
* @returns {string|null}
|
|
750
|
+
*/
|
|
751
|
+
export function resolveTailActivityFromJournal(journalEvents) {
|
|
752
|
+
const events = journalEvents ?? [];
|
|
753
|
+
for (let i = events.length - 1; i >= 0; i -= 1) {
|
|
754
|
+
const label = TAIL_JOURNAL_ACTIVITY_LABELS[events[i].type];
|
|
755
|
+
if (label) return label;
|
|
756
|
+
}
|
|
757
|
+
return null;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* Lane-agnostic activity subline when Running/Queued are empty but batch is still open (GitHub #68 Tier 3).
|
|
762
|
+
*
|
|
763
|
+
* @param {object} params
|
|
764
|
+
* @param {object|null|undefined} params.reconciliation
|
|
765
|
+
* @param {object|null|undefined} params.batch
|
|
766
|
+
* @param {object[]} [params.lanes]
|
|
767
|
+
* @param {import("../batch/macro-phase.mjs").MacroPhase|null|undefined} [params.macroPhase]
|
|
768
|
+
* @param {string|null|undefined} [params.macroPhaseLabel]
|
|
769
|
+
* @param {object[]} [params.journalEvents]
|
|
770
|
+
* @returns {string|null}
|
|
771
|
+
*/
|
|
772
|
+
export function resolveTailActivityLabel({
|
|
773
|
+
reconciliation,
|
|
774
|
+
batch,
|
|
775
|
+
lanes = [],
|
|
776
|
+
macroPhase = null,
|
|
777
|
+
macroPhaseLabel: phaseLabel = null,
|
|
778
|
+
journalEvents = [],
|
|
779
|
+
}) {
|
|
780
|
+
if (lanesHaveActiveTasks(lanes)) return null;
|
|
781
|
+
|
|
782
|
+
const diagnosis = reconciliation?.diagnosis ?? null;
|
|
783
|
+
if (!isBatchNonTerminal({ diagnosis, batch })) return null;
|
|
784
|
+
|
|
785
|
+
const signals = reconciliation?.signals ?? {};
|
|
786
|
+
const tailCtx = {
|
|
787
|
+
phase: batch?.phase ?? reconciliation?.phase ?? signals.phase ?? null,
|
|
788
|
+
hasRunningTasks: signals.hasRunningTasks === true,
|
|
789
|
+
hasPendingTasks: signals.hasPendingTasks === true,
|
|
790
|
+
pendingTaskCount:
|
|
791
|
+
reconciliation?.pendingTasks ?? signals.pendingTasks ?? signals.pendingTaskCount ?? 0,
|
|
792
|
+
succeededTasks: batch?.succeededTasks ?? reconciliation?.succeededTasks ?? 0,
|
|
793
|
+
failedTasks: batch?.failedTasks ?? reconciliation?.failedTasks ?? 0,
|
|
794
|
+
totalTasks: batch?.totalTasks ?? reconciliation?.totalTasks ?? 0,
|
|
795
|
+
macroPhase,
|
|
796
|
+
postMergeLimbo: signals.postMergeLimbo === true,
|
|
797
|
+
integrateGateOpen: signals.integrateGateOpen === true,
|
|
798
|
+
allTasksTerminalSuccess: signals.allTasksTerminalSuccess === true,
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
const inRunningTail = isRunningWithoutActiveWorkers(tailCtx);
|
|
802
|
+
const inActionableTail =
|
|
803
|
+
diagnosis === "needs_merge" || diagnosis === "needs_integrate" || diagnosis === "running";
|
|
804
|
+
if (!inRunningTail && !inActionableTail) return null;
|
|
805
|
+
|
|
806
|
+
const fromJournal = resolveTailActivityFromJournal(journalEvents);
|
|
807
|
+
if (fromJournal) return fromJournal;
|
|
808
|
+
|
|
809
|
+
if (macroPhase && TAIL_MACRO_ACTIVITY_LABELS[macroPhase]) {
|
|
810
|
+
return TAIL_MACRO_ACTIVITY_LABELS[macroPhase];
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
if (phaseLabel) return phaseLabel;
|
|
814
|
+
|
|
815
|
+
return null;
|
|
816
|
+
}
|
|
817
|
+
|
|
599
818
|
/**
|
|
600
819
|
* @param {import("../batch/reconcile.mjs").NormalizedBatchState | null} batch
|
|
601
820
|
*/
|
|
602
|
-
function summarizeBatch(batch) {
|
|
821
|
+
function summarizeBatch(batch, reconciliation = null) {
|
|
603
822
|
if (!batch) return null;
|
|
604
823
|
|
|
605
824
|
return {
|
|
606
825
|
batchId: batch.batchId,
|
|
607
826
|
phase: batch.phase,
|
|
827
|
+
diagnosis: reconciliation?.diagnosis ?? null,
|
|
608
828
|
baseBranch: batch.baseBranch,
|
|
609
829
|
orchBranch: batch.orchBranch,
|
|
610
830
|
startedAt: batch.startedAt,
|
|
@@ -709,7 +929,7 @@ export function buildDashboardSnapshot(projectRoot) {
|
|
|
709
929
|
let journalTail = [];
|
|
710
930
|
let journalEvents = [];
|
|
711
931
|
if (reconciliation.batchId) {
|
|
712
|
-
journalEvents =
|
|
932
|
+
journalEvents = readJournalEventsCached(projectRoot, reconciliation.batchId);
|
|
713
933
|
journalTail = readJournalTail(journalEvents, 20).map(formatJournalTailEntry);
|
|
714
934
|
}
|
|
715
935
|
|
|
@@ -744,6 +964,7 @@ export function buildDashboardSnapshot(projectRoot) {
|
|
|
744
964
|
projectRoot,
|
|
745
965
|
batchId: reconciliation.batchId,
|
|
746
966
|
now,
|
|
967
|
+
diagnosis: reconciliation.diagnosis,
|
|
747
968
|
});
|
|
748
969
|
const laneThroughputSummary = summarizeLaneThroughput(
|
|
749
970
|
deriveLanesThroughput({
|
|
@@ -754,7 +975,7 @@ export function buildDashboardSnapshot(projectRoot) {
|
|
|
754
975
|
now,
|
|
755
976
|
}),
|
|
756
977
|
);
|
|
757
|
-
const waves = buildWaveProgress(batch);
|
|
978
|
+
const waves = buildWaveProgress(batch, classifiedTasks);
|
|
758
979
|
const defaultView = buildDefaultViewStatus(reconciliation, gate);
|
|
759
980
|
|
|
760
981
|
const macroPhase = deriveMacroPhase({
|
|
@@ -766,12 +987,22 @@ export function buildDashboardSnapshot(projectRoot) {
|
|
|
766
987
|
postMergeLimbo: reconciliation.signals?.postMergeLimbo === true,
|
|
767
988
|
journalEvents,
|
|
768
989
|
});
|
|
769
|
-
const
|
|
990
|
+
const resolvedMacroPhaseLabel = macroPhaseLabel(macroPhase);
|
|
991
|
+
const batchSummary = summarizeBatch(batch, reconciliation);
|
|
770
992
|
if (batchSummary) {
|
|
771
993
|
batchSummary.macroPhase = macroPhase;
|
|
772
|
-
batchSummary.macroPhaseLabel =
|
|
994
|
+
batchSummary.macroPhaseLabel = resolvedMacroPhaseLabel;
|
|
773
995
|
}
|
|
774
996
|
|
|
997
|
+
const tailActivityLabel = resolveTailActivityLabel({
|
|
998
|
+
reconciliation,
|
|
999
|
+
batch: batchSummary,
|
|
1000
|
+
lanes,
|
|
1001
|
+
macroPhase,
|
|
1002
|
+
macroPhaseLabel: resolvedMacroPhaseLabel,
|
|
1003
|
+
journalEvents,
|
|
1004
|
+
});
|
|
1005
|
+
|
|
775
1006
|
return {
|
|
776
1007
|
generatedAt: new Date(now).toISOString(),
|
|
777
1008
|
defaultView,
|
|
@@ -785,7 +1016,8 @@ export function buildDashboardSnapshot(projectRoot) {
|
|
|
785
1016
|
reconciliation,
|
|
786
1017
|
batch: batchSummary,
|
|
787
1018
|
macroPhase,
|
|
788
|
-
macroPhaseLabel:
|
|
1019
|
+
macroPhaseLabel: resolvedMacroPhaseLabel,
|
|
1020
|
+
tailActivityLabel,
|
|
789
1021
|
lanes,
|
|
790
1022
|
laneThroughputSummary,
|
|
791
1023
|
gate,
|
package/src/dashboard/view.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Dashboard view model (PRD §16.1) — pure functions for browser + tests.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import { isRunningWithoutActiveWorkers } from "./running-tail-state.mjs";
|
|
5
6
|
import {
|
|
6
7
|
computeThroughputTasksPerHour,
|
|
7
8
|
emptyLaneThroughputStats,
|
|
@@ -9,6 +10,8 @@ import {
|
|
|
9
10
|
formatThroughputRate,
|
|
10
11
|
} from "./lane-throughput.mjs";
|
|
11
12
|
|
|
13
|
+
const BADGE_FINALIZING = "badge-finalizing";
|
|
14
|
+
|
|
12
15
|
const DIAGNOSIS_BADGE_CLASS = {
|
|
13
16
|
running: "badge-running",
|
|
14
17
|
paused: "badge-paused",
|
|
@@ -111,17 +114,97 @@ export function buildActionChips(snapshot) {
|
|
|
111
114
|
return chips;
|
|
112
115
|
}
|
|
113
116
|
|
|
117
|
+
/**
|
|
118
|
+
* @param {object} snapshot
|
|
119
|
+
* @returns {boolean}
|
|
120
|
+
*/
|
|
121
|
+
function snapshotHasRunningLaneTasks(snapshot) {
|
|
122
|
+
for (const lane of snapshot?.lanes ?? []) {
|
|
123
|
+
if (lane?.runningTaskId) return true;
|
|
124
|
+
if (Array.isArray(lane?.queuedTaskIds) && lane.queuedTaskIds.length > 0) return true;
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @param {object} snapshot
|
|
131
|
+
*/
|
|
132
|
+
function buildBannerTailContext(snapshot) {
|
|
133
|
+
const signals = snapshot?.reconciliation?.signals ?? {};
|
|
134
|
+
const batch = snapshot?.batch ?? {};
|
|
135
|
+
return {
|
|
136
|
+
phase: snapshot?.phase ?? batch.phase ?? signals.phase ?? null,
|
|
137
|
+
hasRunningTasks:
|
|
138
|
+
signals.hasRunningTasks === true || snapshotHasRunningLaneTasks(snapshot),
|
|
139
|
+
hasPendingTasks: signals.hasPendingTasks === true,
|
|
140
|
+
pendingTaskCount:
|
|
141
|
+
snapshot?.reconciliation?.pendingTasks ??
|
|
142
|
+
signals.pendingTasks ??
|
|
143
|
+
signals.pendingTaskCount ??
|
|
144
|
+
0,
|
|
145
|
+
succeededTasks: batch.succeededTasks ?? snapshot?.reconciliation?.succeededTasks ?? 0,
|
|
146
|
+
failedTasks: batch.failedTasks ?? snapshot?.reconciliation?.failedTasks ?? 0,
|
|
147
|
+
totalTasks: batch.totalTasks ?? snapshot?.reconciliation?.totalTasks ?? 0,
|
|
148
|
+
macroPhase:
|
|
149
|
+
snapshot?.macroPhase ?? batch.macroPhase ?? snapshot?.reconciliation?.macroPhase ?? null,
|
|
150
|
+
postMergeLimbo: signals.postMergeLimbo === true,
|
|
151
|
+
integrateGateOpen: signals.integrateGateOpen === true,
|
|
152
|
+
stalePathSpine: signals.stalePathSpine === true,
|
|
153
|
+
gitMerged: signals.git?.orchMergedToBase,
|
|
154
|
+
allTasksTerminalSuccess: signals.allTasksTerminalSuccess === true,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @param {object} snapshot
|
|
160
|
+
* @param {string|null|undefined} diagnosis
|
|
161
|
+
*/
|
|
162
|
+
function resolveBannerBadge(snapshot, diagnosis) {
|
|
163
|
+
const baseClass = diagnosisBadgeClass(diagnosis);
|
|
164
|
+
const baseLabel = diagnosis ? String(diagnosis).replace(/_/g, " ") : "";
|
|
165
|
+
|
|
166
|
+
if (diagnosis !== "running") {
|
|
167
|
+
return { badgeClass: baseClass, badgeLabel: baseLabel, subline: null, tailState: false };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const tailCtx = buildBannerTailContext(snapshot);
|
|
171
|
+
if (tailCtx.hasRunningTasks || tailCtx.hasPendingTasks) {
|
|
172
|
+
return { badgeClass: "badge-running", badgeLabel: "running", subline: null, tailState: false };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (!isRunningWithoutActiveWorkers(tailCtx)) {
|
|
176
|
+
return { badgeClass: baseClass, badgeLabel: baseLabel, subline: null, tailState: false };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const phaseLabel =
|
|
180
|
+
snapshot?.macroPhaseLabel ??
|
|
181
|
+
snapshot?.batch?.macroPhaseLabel ??
|
|
182
|
+
snapshot?.reconciliation?.macroPhaseLabel ??
|
|
183
|
+
null;
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
badgeClass: BADGE_FINALIZING,
|
|
187
|
+
badgeLabel: phaseLabel ?? "finalizing",
|
|
188
|
+
subline: phaseLabel,
|
|
189
|
+
tailState: true,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
114
193
|
/**
|
|
115
194
|
* @param {object} snapshot
|
|
116
195
|
*/
|
|
117
196
|
export function buildBannerModel(snapshot) {
|
|
118
197
|
const diagnosis = snapshot?.diagnosis ?? null;
|
|
198
|
+
const badge = resolveBannerBadge(snapshot, diagnosis);
|
|
119
199
|
return {
|
|
120
200
|
headline: snapshot?.headline ?? "",
|
|
121
201
|
suggestedCommand: snapshot?.suggestedCommand ?? "",
|
|
122
202
|
alternatives: snapshot?.alternatives ?? [],
|
|
123
203
|
diagnosis,
|
|
124
|
-
badgeClass:
|
|
204
|
+
badgeClass: badge.badgeClass,
|
|
205
|
+
badgeLabel: badge.badgeLabel,
|
|
206
|
+
subline: badge.subline,
|
|
207
|
+
tailState: badge.tailState,
|
|
125
208
|
primaryAction: primaryActionLabel(diagnosis),
|
|
126
209
|
actionChips: buildActionChips(snapshot),
|
|
127
210
|
idle: isIdleSnapshot(snapshot),
|
|
@@ -288,6 +371,28 @@ export function buildLaneTableModel(snapshot) {
|
|
|
288
371
|
});
|
|
289
372
|
}
|
|
290
373
|
|
|
374
|
+
/**
|
|
375
|
+
* @param {object} snapshot
|
|
376
|
+
*/
|
|
377
|
+
export function buildTailActivityModel(snapshot) {
|
|
378
|
+
const label = snapshot?.tailActivityLabel ?? null;
|
|
379
|
+
if (!label) {
|
|
380
|
+
return { tailActivityLabel: null, visible: false };
|
|
381
|
+
}
|
|
382
|
+
for (const lane of snapshot?.lanes ?? []) {
|
|
383
|
+
if (lane.runningTaskId) {
|
|
384
|
+
return { tailActivityLabel: null, visible: false };
|
|
385
|
+
}
|
|
386
|
+
if (Array.isArray(lane.queuedTaskIds) && lane.queuedTaskIds.length > 0) {
|
|
387
|
+
return { tailActivityLabel: null, visible: false };
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return {
|
|
391
|
+
tailActivityLabel: label,
|
|
392
|
+
visible: true,
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
|
|
291
396
|
/**
|
|
292
397
|
* @param {object} snapshot
|
|
293
398
|
*/
|
|
@@ -420,6 +525,7 @@ export function buildDashboardViewModel(snapshot, { journalLaneFilter = null } =
|
|
|
420
525
|
waves: buildWaveModel(snapshot),
|
|
421
526
|
lanes: buildLaneTableModel(snapshot),
|
|
422
527
|
laneTableSummary: buildLaneTableSummaryModel(snapshot),
|
|
528
|
+
tailActivity: buildTailActivityModel(snapshot),
|
|
423
529
|
gate: buildGateModel(snapshot?.gate),
|
|
424
530
|
gateAffordance: buildGateAffordanceModel(snapshot),
|
|
425
531
|
showGateAffordance: shouldShowGateAffordance(snapshot),
|
|
@@ -441,7 +547,11 @@ export function bannerUsesDiagnosisNotPhase(snapshot) {
|
|
|
441
547
|
return diagnosisBadgeClass(diagnosis) === "badge-integrate";
|
|
442
548
|
}
|
|
443
549
|
if (diagnosis === "running") {
|
|
444
|
-
|
|
550
|
+
const badge = resolveBannerBadge(snapshot, diagnosis);
|
|
551
|
+
if (badge.tailState) {
|
|
552
|
+
return badge.badgeClass === BADGE_FINALIZING;
|
|
553
|
+
}
|
|
554
|
+
return badge.badgeClass === "badge-running";
|
|
445
555
|
}
|
|
446
556
|
return diagnosisBadgeClass(diagnosis) !== "badge-running" || diagnosis === "running";
|
|
447
557
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Doctor check: validate that all agent model pins use canonical provider/model format (SP-422 / #76).
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { validateModelIdFormat } from "../config/model-id.mjs";
|
|
6
|
+
|
|
7
|
+
/** @type {ReadonlyArray<{ path: string, get: (c: object) => unknown }>} */
|
|
8
|
+
const MODEL_PATHS = Object.freeze([
|
|
9
|
+
{ path: "agents.worker.model", get: (c) => c?.agents?.worker?.model },
|
|
10
|
+
{ path: "agents.reviewer.model", get: (c) => c?.agents?.reviewer?.model },
|
|
11
|
+
{ path: "agents.reviewer.plan.model", get: (c) => c?.agents?.reviewer?.plan?.model },
|
|
12
|
+
{ path: "agents.reviewer.code.model", get: (c) => c?.agents?.reviewer?.code?.model },
|
|
13
|
+
{ path: "agents.reviewer.final.model", get: (c) => c?.agents?.reviewer?.final?.model },
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {object} params
|
|
18
|
+
* @param {object} [params.config]
|
|
19
|
+
* @returns {{ label: string, ok: boolean, detail: string, suggestedCommand?: string }}
|
|
20
|
+
*/
|
|
21
|
+
export function buildAgentModelIdsDoctorCheck({ config = {} } = {}) {
|
|
22
|
+
/** @type {Array<{ path: string, error: string, suggestedCommand?: string }>} */
|
|
23
|
+
const failures = [];
|
|
24
|
+
|
|
25
|
+
for (const { path, get } of MODEL_PATHS) {
|
|
26
|
+
const value = get(config);
|
|
27
|
+
if (value == null || value === "" || value === "inherit") continue;
|
|
28
|
+
if (typeof value !== "string") continue;
|
|
29
|
+
|
|
30
|
+
const result = validateModelIdFormat(value);
|
|
31
|
+
if (!result.ok) {
|
|
32
|
+
const suggested = result.canonical
|
|
33
|
+
? `spine settings set ${path} ${result.canonical}`
|
|
34
|
+
: undefined;
|
|
35
|
+
failures.push({ path, error: result.error, suggestedCommand: suggested });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (failures.length === 0) {
|
|
40
|
+
return {
|
|
41
|
+
label: "agent model ids (canonical)",
|
|
42
|
+
ok: true,
|
|
43
|
+
detail: "all pins use provider/model format",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
label: "agent model ids (canonical)",
|
|
49
|
+
ok: false,
|
|
50
|
+
detail: failures.map((f) => `${f.path}: ${f.error}`).join("; "),
|
|
51
|
+
suggestedCommand: failures[0].suggestedCommand,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -20,21 +20,49 @@ export function countMediumLargeTasks({ tasksRoot, taskIds }) {
|
|
|
20
20
|
|
|
21
21
|
/** @type {string[]} */
|
|
22
22
|
const mediumLargeTaskIds = [];
|
|
23
|
+
let mCount = 0;
|
|
24
|
+
let lCount = 0;
|
|
23
25
|
for (const taskId of taskIds) {
|
|
24
26
|
const folderPath = folderById[taskId];
|
|
25
27
|
if (!folderPath) continue;
|
|
26
28
|
const size = parseTaskSizeFromFolder(folderPath);
|
|
27
29
|
if (size && MEDIUM_LARGE_SIZES.has(size)) {
|
|
28
30
|
mediumLargeTaskIds.push(taskId);
|
|
31
|
+
if (size === "M") mCount++;
|
|
32
|
+
else if (size === "L") lCount++;
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
return {
|
|
33
37
|
count: mediumLargeTaskIds.length,
|
|
34
38
|
taskIds: mediumLargeTaskIds,
|
|
39
|
+
mCount,
|
|
40
|
+
lCount,
|
|
35
41
|
};
|
|
36
42
|
}
|
|
37
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @param {object} params
|
|
46
|
+
* @param {string} params.tasksRoot
|
|
47
|
+
* @param {string[]} params.taskIds
|
|
48
|
+
* @returns {string|null}
|
|
49
|
+
*/
|
|
50
|
+
/**
|
|
51
|
+
* Format the size label portion of the guidance warning based on actual M/L composition.
|
|
52
|
+
* @param {number} mCount
|
|
53
|
+
* @param {number} lCount
|
|
54
|
+
* @returns {string}
|
|
55
|
+
*/
|
|
56
|
+
function formatSizeLabel(mCount, lCount) {
|
|
57
|
+
if (mCount > 0 && lCount > 0) {
|
|
58
|
+
return `${mCount} M and ${lCount} L task(s)`;
|
|
59
|
+
}
|
|
60
|
+
if (mCount > 0) {
|
|
61
|
+
return `${mCount} M task(s)`;
|
|
62
|
+
}
|
|
63
|
+
return `${lCount} L task(s)`;
|
|
64
|
+
}
|
|
65
|
+
|
|
38
66
|
/**
|
|
39
67
|
* @param {object} params
|
|
40
68
|
* @param {string} params.tasksRoot
|
|
@@ -44,14 +72,14 @@ export function countMediumLargeTasks({ tasksRoot, taskIds }) {
|
|
|
44
72
|
export function buildBatchSizeGuidanceWarning({ tasksRoot, taskIds }) {
|
|
45
73
|
if (isStubWorkerMode()) return null;
|
|
46
74
|
|
|
47
|
-
const { count, taskIds: mediumLargeTaskIds } = countMediumLargeTasks({ tasksRoot, taskIds });
|
|
75
|
+
const { count, taskIds: mediumLargeTaskIds, mCount, lCount } = countMediumLargeTasks({ tasksRoot, taskIds });
|
|
48
76
|
if (count < WARN_AT_MEDIUM_LARGE_COUNT) return null;
|
|
49
77
|
|
|
50
78
|
const preview = mediumLargeTaskIds.slice(0, 6).join(", ");
|
|
51
79
|
const suffix = mediumLargeTaskIds.length > 6 ? ", ..." : "";
|
|
52
80
|
|
|
53
81
|
return (
|
|
54
|
-
`⚠ Batch includes ${
|
|
82
|
+
`⚠ Batch includes ${formatSizeLabel(mCount, lCount)} (${preview}${suffix}) — ` +
|
|
55
83
|
"prefer smaller batches for real pi workers; set lanes.stallTimeoutMinutes ≥120"
|
|
56
84
|
);
|
|
57
85
|
}
|