pi-spine 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/bin/spine-cli/verify.mjs +6 -0
- package/bin/spine-deps.mjs +0 -2
- package/bin/spine-plan.mjs +49 -1
- package/bin/spine-rules.mjs +0 -2
- package/bin/spine-settings.mjs +0 -2
- package/bin/spine-worker-runner.mjs +136 -4
- package/bin/spine.mjs +2 -5
- package/package.json +2 -2
- package/skills/create-spine-tasks/SKILL.md +7 -2
- package/skills/create-spine-tasks/references/contract-template.md +95 -3
- package/src/batch/attached-engine-handoff.mjs +0 -1
- 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 +160 -16
- 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-retry-limbo.mjs +1 -1
- package/src/batch/diagnosis-tail-state.mjs +57 -0
- package/src/batch/diagnosis.mjs +22 -114
- package/src/batch/engine-lanes/commit.mjs +145 -0
- package/src/batch/engine-lanes/merge.mjs +1 -2
- package/src/batch/engine-lanes/review.mjs +124 -121
- package/src/batch/engine-lanes.mjs +21 -81
- package/src/batch/engine.mjs +46 -1
- package/src/batch/evidence.mjs +1 -2
- package/src/batch/git-exec.mjs +5 -2
- 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 +158 -3
- package/src/batch/journal.mjs +63 -0
- package/src/batch/lane-commit.mjs +6 -5
- package/src/batch/lane-dirty-check.mjs +513 -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 -10
- package/src/batch/resume-common.mjs +27 -0
- package/src/batch/resume-multi-lanes.mjs +11 -0
- package/src/batch/resume-multi.mjs +3 -1
- package/src/batch/resume.mjs +8 -4
- package/src/batch/retry.mjs +41 -10
- package/src/batch/review-spawn.mjs +1 -1
- package/src/batch/review.mjs +0 -4
- 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 +14 -5
- package/src/cli/deps.mjs +0 -2
- package/src/cli/sequence.mjs +14 -1
- package/src/cli/settings-set.mjs +33 -3
- package/src/config/contract.mjs +10 -0
- 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.css +8 -0
- package/src/dashboard/public/dashboard.js +36 -9
- package/src/dashboard/running-tail-state.mjs +31 -0
- package/src/dashboard/server.mjs +4 -0
- package/src/dashboard/snapshot.mjs +260 -29
- 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
- package/src/tasks/packet/validate-prompt.mjs +0 -1
|
@@ -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";
|
|
@@ -21,7 +22,6 @@ import { resolveStallConfig } from "../batch/heartbeat.mjs";
|
|
|
21
22
|
import { loadSpineConfig } from "../config/spine-config-load.mjs";
|
|
22
23
|
import {
|
|
23
24
|
deriveLanesThroughput,
|
|
24
|
-
deriveLaneThroughputStats,
|
|
25
25
|
emptyLaneThroughputStats,
|
|
26
26
|
summarizeLaneThroughput,
|
|
27
27
|
} from "./lane-throughput.mjs";
|
|
@@ -71,7 +71,7 @@ export function heartbeatAgeSeconds(lastHeartbeatAt, now = Date.now()) {
|
|
|
71
71
|
* @param {ReturnType<typeof resolveStallConfig>} params.stallConfig
|
|
72
72
|
* @param {number} [params.now]
|
|
73
73
|
*/
|
|
74
|
-
export function classifyLaneStatus({ lane, classifiedTasks, stallConfig, now = Date.now() }) {
|
|
74
|
+
export function classifyLaneStatus({ lane, classifiedTasks, stallConfig, now = Date.now(), diagnosis = null }) {
|
|
75
75
|
const taskIds = lane.taskIds ?? [];
|
|
76
76
|
const tasks = classifiedTasks.filter((task) => taskIds.includes(task.taskId));
|
|
77
77
|
|
|
@@ -79,8 +79,20 @@ export function classifyLaneStatus({ lane, classifiedTasks, stallConfig, now = D
|
|
|
79
79
|
return "completed";
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
if (diagnosis === "engine_orphaned" || diagnosis === "state_drift" || diagnosis === "needs_retry") {
|
|
83
|
+
const hasOpenWork = tasks.some((task) => {
|
|
84
|
+
const status = String(task.status ?? "").toLowerCase();
|
|
85
|
+
return status === "pending" || status === "running" || status === "failed" || task.doneInLane === true;
|
|
86
|
+
});
|
|
87
|
+
if (hasOpenWork) return diagnosis === "engine_orphaned" ? "stale" : "running";
|
|
88
|
+
}
|
|
89
|
+
|
|
82
90
|
const allDone =
|
|
83
|
-
tasks.length > 0 &&
|
|
91
|
+
tasks.length > 0 &&
|
|
92
|
+
tasks.every((task) => {
|
|
93
|
+
const status = String(task.status ?? "").toLowerCase();
|
|
94
|
+
return status === "succeeded" || status === "skipped";
|
|
95
|
+
});
|
|
84
96
|
if (allDone) return "completed";
|
|
85
97
|
|
|
86
98
|
const hasActive = tasks.some(
|
|
@@ -123,19 +135,63 @@ export function classifyLaneStatus({ lane, classifiedTasks, stallConfig, now = D
|
|
|
123
135
|
* @param {string[]} [params.currentWaveTaskIds]
|
|
124
136
|
*/
|
|
125
137
|
export function computeActiveTaskIdsForLane({ lane, classifiedTasks, currentWaveTaskIds }) {
|
|
138
|
+
const runningTaskId = computeRunningTaskIdForLane({ lane, classifiedTasks, currentWaveTaskIds });
|
|
139
|
+
const queuedTaskIds = computeQueuedTaskIdsForLane({ lane, classifiedTasks, currentWaveTaskIds });
|
|
140
|
+
if (runningTaskId) return [runningTaskId, ...queuedTaskIds];
|
|
141
|
+
return [...queuedTaskIds];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Single running task in the current wave on this physical lane (engine: ≤1 per lane).
|
|
146
|
+
*
|
|
147
|
+
* @param {object} params
|
|
148
|
+
* @param {object} params.lane
|
|
149
|
+
* @param {import("../batch/reconcile.mjs").NormalizedTask[]} params.classifiedTasks
|
|
150
|
+
* @param {string[]} [params.currentWaveTaskIds]
|
|
151
|
+
*/
|
|
152
|
+
export function computeRunningTaskIdForLane({ lane, classifiedTasks, currentWaveTaskIds }) {
|
|
153
|
+
if (!currentWaveTaskIds?.length) return null;
|
|
154
|
+
const waveSet = new Set(currentWaveTaskIds.map(String));
|
|
155
|
+
const running = classifiedTasks.find(
|
|
156
|
+
(task) =>
|
|
157
|
+
task.laneNumber === lane.laneNumber &&
|
|
158
|
+
waveSet.has(task.taskId) &&
|
|
159
|
+
(task.classification === "running" || task.status === "running"),
|
|
160
|
+
);
|
|
161
|
+
return running?.taskId ?? null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Pending tasks in the current wave on this lane, ordered by lane assignment queue.
|
|
166
|
+
*
|
|
167
|
+
* @param {object} params
|
|
168
|
+
* @param {object} params.lane
|
|
169
|
+
* @param {import("../batch/reconcile.mjs").NormalizedTask[]} params.classifiedTasks
|
|
170
|
+
* @param {string[]} [params.currentWaveTaskIds]
|
|
171
|
+
* @param {string[]} [params.laneTaskIds]
|
|
172
|
+
*/
|
|
173
|
+
export function computeQueuedTaskIdsForLane({
|
|
174
|
+
lane,
|
|
175
|
+
classifiedTasks,
|
|
176
|
+
currentWaveTaskIds,
|
|
177
|
+
laneTaskIds,
|
|
178
|
+
}) {
|
|
126
179
|
if (!currentWaveTaskIds?.length) return [];
|
|
127
180
|
const waveSet = new Set(currentWaveTaskIds.map(String));
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
(
|
|
133
|
-
task
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
181
|
+
const assignmentOrder = laneTaskIds ?? lane.taskIds ?? [];
|
|
182
|
+
|
|
183
|
+
const pendingIds = new Set(
|
|
184
|
+
classifiedTasks
|
|
185
|
+
.filter(
|
|
186
|
+
(task) =>
|
|
187
|
+
task.laneNumber === lane.laneNumber &&
|
|
188
|
+
waveSet.has(task.taskId) &&
|
|
189
|
+
(task.classification === "pending" || task.status === "pending"),
|
|
190
|
+
)
|
|
191
|
+
.map((task) => String(task.taskId)),
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
return assignmentOrder.filter((taskId) => pendingIds.has(String(taskId))).map(String);
|
|
139
195
|
}
|
|
140
196
|
|
|
141
197
|
/**
|
|
@@ -379,6 +435,7 @@ export function buildLaneRows({
|
|
|
379
435
|
projectRoot = null,
|
|
380
436
|
batchId = null,
|
|
381
437
|
now = Date.now(),
|
|
438
|
+
diagnosis = null,
|
|
382
439
|
}) {
|
|
383
440
|
const throughputByLane = deriveLanesThroughput({
|
|
384
441
|
lanes,
|
|
@@ -390,6 +447,13 @@ export function buildLaneRows({
|
|
|
390
447
|
return (lanes ?? []).map((lane) => {
|
|
391
448
|
const heartbeatMeta = resolveLaneHeartbeatMeta(lane.laneNumber, journalEvents);
|
|
392
449
|
const heartbeatAgeSecondsValue = heartbeatAgeSeconds(lane.lastHeartbeatAt, now);
|
|
450
|
+
const runningTaskId = computeRunningTaskIdForLane({ lane, classifiedTasks, currentWaveTaskIds });
|
|
451
|
+
const queuedTaskIds = computeQueuedTaskIdsForLane({
|
|
452
|
+
lane,
|
|
453
|
+
classifiedTasks,
|
|
454
|
+
currentWaveTaskIds,
|
|
455
|
+
laneTaskIds: lane.taskIds ?? [],
|
|
456
|
+
});
|
|
393
457
|
const activeTaskIds = computeActiveTaskIdsForLane({ lane, classifiedTasks, currentWaveTaskIds });
|
|
394
458
|
const activity = resolveLaneActivityPhase({
|
|
395
459
|
laneNumber: lane.laneNumber,
|
|
@@ -413,8 +477,10 @@ export function buildLaneRows({
|
|
|
413
477
|
return {
|
|
414
478
|
laneId: lane.laneId ?? `lane-${lane.laneNumber}`,
|
|
415
479
|
laneNumber: lane.laneNumber,
|
|
416
|
-
status: classifyLaneStatus({ lane, classifiedTasks, stallConfig, now }),
|
|
480
|
+
status: classifyLaneStatus({ lane, classifiedTasks, stallConfig, now, diagnosis }),
|
|
417
481
|
activeTaskIds,
|
|
482
|
+
runningTaskId,
|
|
483
|
+
queuedTaskIds,
|
|
418
484
|
activityPhase: activity.activityPhase,
|
|
419
485
|
activityPhaseLabel: activity.activityPhaseLabel,
|
|
420
486
|
taskIds: lane.taskIds ?? [],
|
|
@@ -435,10 +501,36 @@ export function buildLaneRows({
|
|
|
435
501
|
});
|
|
436
502
|
}
|
|
437
503
|
|
|
504
|
+
/**
|
|
505
|
+
* @param {string[]} taskIds
|
|
506
|
+
* @param {import("../batch/reconcile.mjs").NormalizedTask[]} classifiedTasks
|
|
507
|
+
*/
|
|
508
|
+
function waveTasksAllTerminalSuccess(taskIds, classifiedTasks) {
|
|
509
|
+
if (!taskIds.length) return false;
|
|
510
|
+
const byId = new Map((classifiedTasks ?? []).map((task) => [String(task.taskId), task]));
|
|
511
|
+
return taskIds.every((taskId) => byId.get(String(taskId))?.classification === "terminal-success");
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* @param {number} index
|
|
516
|
+
* @param {number} currentWaveIndex
|
|
517
|
+
* @param {string[]} taskIds
|
|
518
|
+
* @param {import("../batch/reconcile.mjs").NormalizedTask[]} [classifiedTasks]
|
|
519
|
+
*/
|
|
520
|
+
function resolveWaveStatus(index, currentWaveIndex, taskIds, classifiedTasks) {
|
|
521
|
+
if (classifiedTasks?.length && waveTasksAllTerminalSuccess(taskIds, classifiedTasks)) {
|
|
522
|
+
return "completed";
|
|
523
|
+
}
|
|
524
|
+
if (index < currentWaveIndex) return "completed";
|
|
525
|
+
if (index === currentWaveIndex) return "active";
|
|
526
|
+
return "pending";
|
|
527
|
+
}
|
|
528
|
+
|
|
438
529
|
/**
|
|
439
530
|
* @param {import("../batch/reconcile.mjs").NormalizedBatchState | Record<string, unknown> | null} batchState
|
|
531
|
+
* @param {import("../batch/reconcile.mjs").NormalizedTask[]} [classifiedTasks]
|
|
440
532
|
*/
|
|
441
|
-
export function buildWaveProgress(batchState) {
|
|
533
|
+
export function buildWaveProgress(batchState, classifiedTasks) {
|
|
442
534
|
const raw =
|
|
443
535
|
batchState && typeof batchState === "object" && "raw" in batchState
|
|
444
536
|
? /** @type {Record<string, unknown>} */ (batchState.raw)
|
|
@@ -451,12 +543,14 @@ export function buildWaveProgress(batchState) {
|
|
|
451
543
|
return {
|
|
452
544
|
currentWaveIndex,
|
|
453
545
|
totalWaves,
|
|
454
|
-
waves: wavePlan.map((entry, index) =>
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
546
|
+
waves: wavePlan.map((entry, index) => {
|
|
547
|
+
const taskIds = Array.isArray(entry) ? entry.map(String) : [];
|
|
548
|
+
return {
|
|
549
|
+
index,
|
|
550
|
+
taskIds,
|
|
551
|
+
status: resolveWaveStatus(index, currentWaveIndex, taskIds, classifiedTasks),
|
|
552
|
+
};
|
|
553
|
+
}),
|
|
460
554
|
};
|
|
461
555
|
}
|
|
462
556
|
|
|
@@ -596,15 +690,140 @@ export function buildLaneLogTail(projectRoot, batchId, laneNumber, activeTaskIds
|
|
|
596
690
|
};
|
|
597
691
|
}
|
|
598
692
|
|
|
693
|
+
const TERMINAL_DIAGNOSES = new Set([
|
|
694
|
+
"completed",
|
|
695
|
+
"completed_manual",
|
|
696
|
+
"limbo_stale",
|
|
697
|
+
"failed",
|
|
698
|
+
"aborted",
|
|
699
|
+
]);
|
|
700
|
+
|
|
701
|
+
/** @type {Record<string, string>} */
|
|
702
|
+
const TAIL_JOURNAL_ACTIVITY_LABELS = {
|
|
703
|
+
"batch.merge_started": "Merging lane branches…",
|
|
704
|
+
"batch.merge_completed": "Merge completed — finalizing batch…",
|
|
705
|
+
"batch.merge_blocked": "Merge blocked — retry or resume",
|
|
706
|
+
"gate.opened": "Integrate gate opened — awaiting approval",
|
|
707
|
+
"gate.evidence_collecting": "Collecting gate evidence…",
|
|
708
|
+
"engine.attached_post_merge_handoff": "Finalizing land loop…",
|
|
709
|
+
"integrate.started": "Integrating to main…",
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
/** @type {Record<string, string>} */
|
|
713
|
+
const TAIL_MACRO_ACTIVITY_LABELS = {
|
|
714
|
+
merging: "Merging lane branches…",
|
|
715
|
+
gating: "Opening integrate gate…",
|
|
716
|
+
integrating: "Integrating to main…",
|
|
717
|
+
reviewing: "Running reviews — no workers scheduled",
|
|
718
|
+
planning: "Planning — no workers scheduled",
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* @param {object[]} [lanes]
|
|
723
|
+
* @returns {boolean}
|
|
724
|
+
*/
|
|
725
|
+
export function lanesHaveActiveTasks(lanes) {
|
|
726
|
+
for (const lane of lanes ?? []) {
|
|
727
|
+
if (lane.runningTaskId) return true;
|
|
728
|
+
if (Array.isArray(lane.queuedTaskIds) && lane.queuedTaskIds.length > 0) return true;
|
|
729
|
+
}
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* @param {object} params
|
|
735
|
+
* @param {string|null|undefined} params.diagnosis
|
|
736
|
+
* @param {object|null|undefined} params.batch
|
|
737
|
+
* @returns {boolean}
|
|
738
|
+
*/
|
|
739
|
+
function isBatchNonTerminal({ diagnosis, batch }) {
|
|
740
|
+
if (!diagnosis) return false;
|
|
741
|
+
if (TERMINAL_DIAGNOSES.has(diagnosis)) return false;
|
|
742
|
+
if (batch?.endedAt) return false;
|
|
743
|
+
return true;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* @param {object[]} [journalEvents]
|
|
748
|
+
* @returns {string|null}
|
|
749
|
+
*/
|
|
750
|
+
export function resolveTailActivityFromJournal(journalEvents) {
|
|
751
|
+
const events = journalEvents ?? [];
|
|
752
|
+
for (let i = events.length - 1; i >= 0; i -= 1) {
|
|
753
|
+
const label = TAIL_JOURNAL_ACTIVITY_LABELS[events[i].type];
|
|
754
|
+
if (label) return label;
|
|
755
|
+
}
|
|
756
|
+
return null;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Lane-agnostic activity subline when Running/Queued are empty but batch is still open (GitHub #68 Tier 3).
|
|
761
|
+
*
|
|
762
|
+
* @param {object} params
|
|
763
|
+
* @param {object|null|undefined} params.reconciliation
|
|
764
|
+
* @param {object|null|undefined} params.batch
|
|
765
|
+
* @param {object[]} [params.lanes]
|
|
766
|
+
* @param {import("../batch/macro-phase.mjs").MacroPhase|null|undefined} [params.macroPhase]
|
|
767
|
+
* @param {string|null|undefined} [params.macroPhaseLabel]
|
|
768
|
+
* @param {object[]} [params.journalEvents]
|
|
769
|
+
* @returns {string|null}
|
|
770
|
+
*/
|
|
771
|
+
export function resolveTailActivityLabel({
|
|
772
|
+
reconciliation,
|
|
773
|
+
batch,
|
|
774
|
+
lanes = [],
|
|
775
|
+
macroPhase = null,
|
|
776
|
+
macroPhaseLabel: phaseLabel = null,
|
|
777
|
+
journalEvents = [],
|
|
778
|
+
}) {
|
|
779
|
+
if (lanesHaveActiveTasks(lanes)) return null;
|
|
780
|
+
|
|
781
|
+
const diagnosis = reconciliation?.diagnosis ?? null;
|
|
782
|
+
if (!isBatchNonTerminal({ diagnosis, batch })) return null;
|
|
783
|
+
|
|
784
|
+
const signals = reconciliation?.signals ?? {};
|
|
785
|
+
const tailCtx = {
|
|
786
|
+
phase: batch?.phase ?? reconciliation?.phase ?? signals.phase ?? null,
|
|
787
|
+
hasRunningTasks: signals.hasRunningTasks === true,
|
|
788
|
+
hasPendingTasks: signals.hasPendingTasks === true,
|
|
789
|
+
pendingTaskCount:
|
|
790
|
+
reconciliation?.pendingTasks ?? signals.pendingTasks ?? signals.pendingTaskCount ?? 0,
|
|
791
|
+
succeededTasks: batch?.succeededTasks ?? reconciliation?.succeededTasks ?? 0,
|
|
792
|
+
failedTasks: batch?.failedTasks ?? reconciliation?.failedTasks ?? 0,
|
|
793
|
+
totalTasks: batch?.totalTasks ?? reconciliation?.totalTasks ?? 0,
|
|
794
|
+
macroPhase,
|
|
795
|
+
postMergeLimbo: signals.postMergeLimbo === true,
|
|
796
|
+
integrateGateOpen: signals.integrateGateOpen === true,
|
|
797
|
+
allTasksTerminalSuccess: signals.allTasksTerminalSuccess === true,
|
|
798
|
+
};
|
|
799
|
+
|
|
800
|
+
const inRunningTail = isRunningWithoutActiveWorkers(tailCtx);
|
|
801
|
+
const inActionableTail =
|
|
802
|
+
diagnosis === "needs_merge" || diagnosis === "needs_integrate" || diagnosis === "running";
|
|
803
|
+
if (!inRunningTail && !inActionableTail) return null;
|
|
804
|
+
|
|
805
|
+
const fromJournal = resolveTailActivityFromJournal(journalEvents);
|
|
806
|
+
if (fromJournal) return fromJournal;
|
|
807
|
+
|
|
808
|
+
if (macroPhase && TAIL_MACRO_ACTIVITY_LABELS[macroPhase]) {
|
|
809
|
+
return TAIL_MACRO_ACTIVITY_LABELS[macroPhase];
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
if (phaseLabel) return phaseLabel;
|
|
813
|
+
|
|
814
|
+
return null;
|
|
815
|
+
}
|
|
816
|
+
|
|
599
817
|
/**
|
|
600
818
|
* @param {import("../batch/reconcile.mjs").NormalizedBatchState | null} batch
|
|
601
819
|
*/
|
|
602
|
-
function summarizeBatch(batch) {
|
|
820
|
+
function summarizeBatch(batch, reconciliation = null) {
|
|
603
821
|
if (!batch) return null;
|
|
604
822
|
|
|
605
823
|
return {
|
|
606
824
|
batchId: batch.batchId,
|
|
607
825
|
phase: batch.phase,
|
|
826
|
+
diagnosis: reconciliation?.diagnosis ?? null,
|
|
608
827
|
baseBranch: batch.baseBranch,
|
|
609
828
|
orchBranch: batch.orchBranch,
|
|
610
829
|
startedAt: batch.startedAt,
|
|
@@ -709,7 +928,7 @@ export function buildDashboardSnapshot(projectRoot) {
|
|
|
709
928
|
let journalTail = [];
|
|
710
929
|
let journalEvents = [];
|
|
711
930
|
if (reconciliation.batchId) {
|
|
712
|
-
journalEvents =
|
|
931
|
+
journalEvents = readJournalEventsCached(projectRoot, reconciliation.batchId);
|
|
713
932
|
journalTail = readJournalTail(journalEvents, 20).map(formatJournalTailEntry);
|
|
714
933
|
}
|
|
715
934
|
|
|
@@ -744,6 +963,7 @@ export function buildDashboardSnapshot(projectRoot) {
|
|
|
744
963
|
projectRoot,
|
|
745
964
|
batchId: reconciliation.batchId,
|
|
746
965
|
now,
|
|
966
|
+
diagnosis: reconciliation.diagnosis,
|
|
747
967
|
});
|
|
748
968
|
const laneThroughputSummary = summarizeLaneThroughput(
|
|
749
969
|
deriveLanesThroughput({
|
|
@@ -754,7 +974,7 @@ export function buildDashboardSnapshot(projectRoot) {
|
|
|
754
974
|
now,
|
|
755
975
|
}),
|
|
756
976
|
);
|
|
757
|
-
const waves = buildWaveProgress(batch);
|
|
977
|
+
const waves = buildWaveProgress(batch, classifiedTasks);
|
|
758
978
|
const defaultView = buildDefaultViewStatus(reconciliation, gate);
|
|
759
979
|
|
|
760
980
|
const macroPhase = deriveMacroPhase({
|
|
@@ -766,12 +986,22 @@ export function buildDashboardSnapshot(projectRoot) {
|
|
|
766
986
|
postMergeLimbo: reconciliation.signals?.postMergeLimbo === true,
|
|
767
987
|
journalEvents,
|
|
768
988
|
});
|
|
769
|
-
const
|
|
989
|
+
const resolvedMacroPhaseLabel = macroPhaseLabel(macroPhase);
|
|
990
|
+
const batchSummary = summarizeBatch(batch, reconciliation);
|
|
770
991
|
if (batchSummary) {
|
|
771
992
|
batchSummary.macroPhase = macroPhase;
|
|
772
|
-
batchSummary.macroPhaseLabel =
|
|
993
|
+
batchSummary.macroPhaseLabel = resolvedMacroPhaseLabel;
|
|
773
994
|
}
|
|
774
995
|
|
|
996
|
+
const tailActivityLabel = resolveTailActivityLabel({
|
|
997
|
+
reconciliation,
|
|
998
|
+
batch: batchSummary,
|
|
999
|
+
lanes,
|
|
1000
|
+
macroPhase,
|
|
1001
|
+
macroPhaseLabel: resolvedMacroPhaseLabel,
|
|
1002
|
+
journalEvents,
|
|
1003
|
+
});
|
|
1004
|
+
|
|
775
1005
|
return {
|
|
776
1006
|
generatedAt: new Date(now).toISOString(),
|
|
777
1007
|
defaultView,
|
|
@@ -785,7 +1015,8 @@ export function buildDashboardSnapshot(projectRoot) {
|
|
|
785
1015
|
reconciliation,
|
|
786
1016
|
batch: batchSummary,
|
|
787
1017
|
macroPhase,
|
|
788
|
-
macroPhaseLabel:
|
|
1018
|
+
macroPhaseLabel: resolvedMacroPhaseLabel,
|
|
1019
|
+
tailActivityLabel,
|
|
789
1020
|
lanes,
|
|
790
1021
|
laneThroughputSummary,
|
|
791
1022
|
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
|
+
}
|