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.
- package/bin/spine-batch.mjs +160 -53
- package/bin/spine-cli/batch.mjs +3 -3
- package/bin/spine-cli/lane-logs.mjs +24 -0
- package/bin/spine-cli/scenarios.mjs +298 -0
- package/bin/spine-cli/wait.mjs +30 -0
- package/bin/spine-cli/watch.mjs +27 -0
- package/bin/spine-issue.mjs +196 -0
- package/bin/spine-journal.mjs +1 -0
- package/bin/spine-run.mjs +30 -0
- package/bin/spine-status.mjs +19 -1
- package/bin/spine-tasks.mjs +16 -2
- package/bin/spine-worker-runner.mjs +10 -10
- package/bin/spine.mjs +49 -1
- package/package.json +1 -1
- package/skills/create-spine-tasks/references/contract-template.md +19 -0
- package/src/batch/abort.mjs +2 -11
- package/src/batch/agent-session-worker.mjs +45 -5
- package/src/batch/attached-engine-handoff.mjs +188 -0
- package/src/batch/attached-runner.mjs +312 -0
- package/src/batch/contract-prelanded.mjs +180 -0
- package/src/batch/contract-verify.mjs +140 -2
- package/src/batch/detached-start.mjs +66 -2
- package/src/batch/diagnosis-alternatives.mjs +46 -0
- package/src/batch/diagnosis-merge-failure.mjs +79 -0
- package/src/batch/diagnosis-retry-limbo.mjs +34 -0
- package/src/batch/diagnosis-stub.mjs +109 -0
- package/src/batch/diagnosis-task-done.mjs +110 -0
- package/src/batch/diagnosis-worker-done-missing.mjs +96 -0
- package/src/batch/diagnosis.mjs +135 -68
- package/src/batch/engine-lanes/merge.mjs +110 -82
- package/src/batch/engine-lanes/queue.mjs +4 -1
- package/src/batch/engine-lanes/watch.mjs +29 -0
- package/src/batch/engine-lanes.mjs +1 -0
- package/src/batch/engine-scope.mjs +11 -1
- package/src/batch/engine.mjs +79 -24
- package/src/batch/evidence.mjs +78 -15
- package/src/batch/gate.mjs +43 -14
- package/src/batch/git-helpers.mjs +96 -0
- package/src/batch/heartbeat.mjs +73 -7
- package/src/batch/integrate.mjs +2 -4
- package/src/batch/journal.mjs +3 -0
- package/src/batch/lane-commit.mjs +90 -5
- package/src/batch/lifecycle.mjs +130 -3
- package/src/batch/macro-phase.mjs +226 -0
- package/src/batch/merge/adoption-doc-merge.mjs +93 -10
- package/src/batch/merge/wave-merge-state.mjs +3 -0
- package/src/batch/metrics.mjs +74 -5
- package/src/batch/orphan-detect.mjs +74 -0
- package/src/batch/pause.mjs +223 -0
- package/src/batch/post-merge-limbo.mjs +264 -8
- package/src/batch/reconcile.mjs +429 -54
- package/src/batch/resume-common.mjs +5 -1
- package/src/batch/resume-lane-reviews.mjs +16 -0
- package/src/batch/resume-multi-lanes.mjs +56 -1
- package/src/batch/resume-multi-validate.mjs +67 -6
- package/src/batch/resume-multi.mjs +9 -4
- package/src/batch/resume.mjs +52 -45
- package/src/batch/retry.mjs +56 -5
- package/src/batch/review-spawn.mjs +8 -2
- package/src/batch/rules-manifest-drift.mjs +157 -0
- package/src/batch/salvage.mjs +2 -1
- package/src/batch/sequence.mjs +454 -0
- package/src/batch/state.mjs +18 -3
- package/src/batch/status-json.mjs +67 -0
- package/src/batch/task-stall-budget.mjs +22 -10
- package/src/batch/worker-host.mjs +95 -7
- package/src/batch/worker-output.mjs +196 -3
- package/src/cli/issue-draft.mjs +180 -0
- package/src/cli/journal-follow.mjs +239 -0
- package/src/cli/lane-logs.mjs +291 -0
- package/src/cli/sequence.mjs +108 -0
- package/src/cli/settings-set.mjs +2 -21
- package/src/cli/wait.mjs +187 -0
- package/src/cli/watch.mjs +160 -0
- package/src/config/agent-model-resolve.mjs +48 -0
- package/src/config/cursor-rules/discover.mjs +3 -21
- package/src/config/defaults.mjs +7 -1
- package/src/config/settings-fields.mjs +48 -0
- package/src/config/spine-init-constants.mjs +1 -0
- package/src/config/spine-preflight-lib.mjs +471 -16
- package/src/dashboard/lane-throughput.mjs +351 -0
- package/src/dashboard/public/dashboard.css +25 -1
- package/src/dashboard/public/dashboard.js +223 -18
- package/src/dashboard/public/index.html +14 -2
- package/src/dashboard/server.mjs +4 -0
- package/src/dashboard/snapshot.mjs +215 -1
- package/src/dashboard/view.mjs +170 -17
- package/src/doctor/agent-model-inherit.mjs +61 -6
- package/src/doctor/run-doctor-checks.mjs +26 -1
- package/src/doctor/sequence-safety.mjs +57 -0
- package/src/doctor/stale-worktrees.mjs +102 -0
- package/src/fixtures/scenario-registry.mjs +194 -0
- package/src/fs/atomic-write.mjs +49 -0
- package/src/planner/file-scope.mjs +246 -0
- package/src/planner/format-plan.mjs +9 -7
- package/src/planner/index.mjs +6 -2
- package/src/planner/wave-scope.mjs +136 -0
- package/src/planner/waves.mjs +133 -0
- package/src/tasks/packet/index.mjs +1 -0
- package/src/tasks/packet/parse-prompt.mjs +42 -1
- package/src/tasks/packet/validate-prompt.mjs +124 -0
- package/templates/spine-config.json +8 -1
|
@@ -48,9 +48,13 @@
|
|
|
48
48
|
<th scope="col">Lane</th>
|
|
49
49
|
<th scope="col">Status</th>
|
|
50
50
|
<th scope="col">Phase</th>
|
|
51
|
-
<th scope="col">
|
|
51
|
+
<th scope="col" class="col-running">Running</th>
|
|
52
|
+
<th scope="col" class="col-queued" id="lane-queued-heading">Queued</th>
|
|
52
53
|
<th scope="col">Batch assignment</th>
|
|
53
54
|
<th scope="col">Heartbeat</th>
|
|
55
|
+
<th scope="col">Elapsed</th>
|
|
56
|
+
<th scope="col">Done</th>
|
|
57
|
+
<th scope="col">Rate</th>
|
|
54
58
|
<th scope="col">Worktree</th>
|
|
55
59
|
</tr>
|
|
56
60
|
</thead>
|
|
@@ -60,7 +64,15 @@
|
|
|
60
64
|
</section>
|
|
61
65
|
|
|
62
66
|
<section class="panel panel-wide" aria-labelledby="journal-heading">
|
|
63
|
-
<
|
|
67
|
+
<div class="journal-header">
|
|
68
|
+
<h3 id="journal-heading">Journal (last 20)</h3>
|
|
69
|
+
<label class="journal-filter-label" for="journal-lane-filter">
|
|
70
|
+
Lane
|
|
71
|
+
<select id="journal-lane-filter" class="journal-lane-filter" aria-label="Filter journal by lane">
|
|
72
|
+
<option value="">All lanes</option>
|
|
73
|
+
</select>
|
|
74
|
+
</label>
|
|
75
|
+
</div>
|
|
64
76
|
<ol id="journal-list" class="journal-list"></ol>
|
|
65
77
|
</section>
|
|
66
78
|
</main>
|
package/src/dashboard/server.mjs
CHANGED
|
@@ -21,6 +21,10 @@ const STATIC_ROUTES = {
|
|
|
21
21
|
"/dashboard.css": { file: "dashboard.css", contentType: "text/css; charset=utf-8" },
|
|
22
22
|
"/dashboard.js": { file: "dashboard.js", contentType: "text/javascript; charset=utf-8" },
|
|
23
23
|
"/view.mjs": { file: path.join("..", "view.mjs"), contentType: "text/javascript; charset=utf-8" },
|
|
24
|
+
"/lane-throughput.mjs": {
|
|
25
|
+
file: path.join("..", "lane-throughput.mjs"),
|
|
26
|
+
contentType: "text/javascript; charset=utf-8",
|
|
27
|
+
},
|
|
24
28
|
};
|
|
25
29
|
|
|
26
30
|
/**
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* Dashboard snapshot builder (PRD §16, NFR-OBS-04).
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { deriveMacroPhase, macroPhaseLabel } from "../batch/macro-phase.mjs";
|
|
5
8
|
import {
|
|
6
9
|
classifyTasks,
|
|
7
10
|
loadBatchStateFile,
|
|
@@ -16,6 +19,26 @@ import {
|
|
|
16
19
|
} from "../batch/journal.mjs";
|
|
17
20
|
import { resolveStallConfig } from "../batch/heartbeat.mjs";
|
|
18
21
|
import { loadSpineConfig } from "../config/spine-config-load.mjs";
|
|
22
|
+
import {
|
|
23
|
+
deriveLanesThroughput,
|
|
24
|
+
deriveLaneThroughputStats,
|
|
25
|
+
emptyLaneThroughputStats,
|
|
26
|
+
summarizeLaneThroughput,
|
|
27
|
+
} from "./lane-throughput.mjs";
|
|
28
|
+
import {
|
|
29
|
+
filterMetricsLines,
|
|
30
|
+
metricsFilePath,
|
|
31
|
+
readMetricsLines,
|
|
32
|
+
} from "../batch/metrics.mjs";
|
|
33
|
+
import {
|
|
34
|
+
workerLiveLogPath,
|
|
35
|
+
workerLiveLogRef,
|
|
36
|
+
workerOutputLogPath,
|
|
37
|
+
workerOutputLogRef,
|
|
38
|
+
} from "../batch/worker-output.mjs";
|
|
39
|
+
|
|
40
|
+
const LANE_RECENT_EVENTS_LIMIT = 5;
|
|
41
|
+
const LANE_LOG_TAIL_LINES = 10;
|
|
19
42
|
|
|
20
43
|
/**
|
|
21
44
|
* @param {string|null|undefined} worktreePath
|
|
@@ -341,6 +364,9 @@ export function formatLaneHeartbeatDisplay({ workerPhase, heartbeatAgeSeconds })
|
|
|
341
364
|
* @param {string[]} [params.currentWaveTaskIds]
|
|
342
365
|
* @param {number} [params.now]
|
|
343
366
|
* @param {object[]} [params.journalEvents]
|
|
367
|
+
* @param {object[]} [params.metricsLines]
|
|
368
|
+
* @param {string|null} [params.projectRoot]
|
|
369
|
+
* @param {string|null} [params.batchId]
|
|
344
370
|
*/
|
|
345
371
|
export function buildLaneRows({
|
|
346
372
|
lanes,
|
|
@@ -349,8 +375,18 @@ export function buildLaneRows({
|
|
|
349
375
|
currentWaveTaskIds = [],
|
|
350
376
|
journalTail = [],
|
|
351
377
|
journalEvents = [],
|
|
378
|
+
metricsLines = [],
|
|
379
|
+
projectRoot = null,
|
|
380
|
+
batchId = null,
|
|
352
381
|
now = Date.now(),
|
|
353
382
|
}) {
|
|
383
|
+
const throughputByLane = deriveLanesThroughput({
|
|
384
|
+
lanes,
|
|
385
|
+
journalEvents,
|
|
386
|
+
metricsLines,
|
|
387
|
+
now,
|
|
388
|
+
});
|
|
389
|
+
|
|
354
390
|
return (lanes ?? []).map((lane) => {
|
|
355
391
|
const heartbeatMeta = resolveLaneHeartbeatMeta(lane.laneNumber, journalEvents);
|
|
356
392
|
const heartbeatAgeSecondsValue = heartbeatAgeSeconds(lane.lastHeartbeatAt, now);
|
|
@@ -361,6 +397,19 @@ export function buildLaneRows({
|
|
|
361
397
|
classifiedTasks,
|
|
362
398
|
journalEvents,
|
|
363
399
|
});
|
|
400
|
+
const throughput =
|
|
401
|
+
throughputByLane.get(lane.laneNumber) ?? emptyLaneThroughputStats();
|
|
402
|
+
const recentEvents = buildLaneRecentEvents(lane.laneNumber, journalEvents);
|
|
403
|
+
const logDetail =
|
|
404
|
+
projectRoot && batchId
|
|
405
|
+
? buildLaneLogTail(
|
|
406
|
+
projectRoot,
|
|
407
|
+
batchId,
|
|
408
|
+
lane.laneNumber,
|
|
409
|
+
activeTaskIds,
|
|
410
|
+
lane.taskIds ?? [],
|
|
411
|
+
)
|
|
412
|
+
: { logTail: [], workerLogRef: null };
|
|
364
413
|
return {
|
|
365
414
|
laneId: lane.laneId ?? `lane-${lane.laneNumber}`,
|
|
366
415
|
laneNumber: lane.laneNumber,
|
|
@@ -378,6 +427,10 @@ export function buildLaneRows({
|
|
|
378
427
|
}),
|
|
379
428
|
worktree: truncateWorktreePath(lane.worktreePath),
|
|
380
429
|
laneAlert: resolveLaneAlert(lane.laneNumber, journalTail, now),
|
|
430
|
+
throughput,
|
|
431
|
+
recentEvents,
|
|
432
|
+
logTail: logDetail.logTail,
|
|
433
|
+
workerLogRef: logDetail.workerLogRef,
|
|
381
434
|
};
|
|
382
435
|
});
|
|
383
436
|
}
|
|
@@ -421,6 +474,128 @@ export function formatJournalTailEntry(event) {
|
|
|
421
474
|
};
|
|
422
475
|
}
|
|
423
476
|
|
|
477
|
+
/**
|
|
478
|
+
* @param {number} laneNumber
|
|
479
|
+
* @param {object} event
|
|
480
|
+
*/
|
|
481
|
+
function journalEventScopedToLane(laneNumber, event) {
|
|
482
|
+
const laneId = `lane-${laneNumber}`;
|
|
483
|
+
const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
|
|
484
|
+
if (event.laneId) return event.laneId === laneId;
|
|
485
|
+
if (payload.laneNumber != null) return payload.laneNumber === laneNumber;
|
|
486
|
+
return false;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Last N journal events scoped to a physical lane.
|
|
491
|
+
*
|
|
492
|
+
* @param {number} laneNumber
|
|
493
|
+
* @param {object[]} journalEvents
|
|
494
|
+
* @param {number} [limit]
|
|
495
|
+
*/
|
|
496
|
+
export function buildLaneRecentEvents(laneNumber, journalEvents, limit = LANE_RECENT_EVENTS_LIMIT) {
|
|
497
|
+
const matching = (journalEvents ?? []).filter(
|
|
498
|
+
(event) => journalEventScopedToLane(laneNumber, event) && laneEventMatches(laneNumber, event),
|
|
499
|
+
);
|
|
500
|
+
return readJournalTail(matching, limit).map(formatJournalTailEntry);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* @param {string|null|undefined} filePath
|
|
505
|
+
* @param {number} [lineCount]
|
|
506
|
+
* @returns {string[]}
|
|
507
|
+
*/
|
|
508
|
+
export function readLogFileTailLines(filePath, lineCount = LANE_LOG_TAIL_LINES) {
|
|
509
|
+
if (!filePath || !fs.existsSync(filePath)) return [];
|
|
510
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
511
|
+
const lines = content.split("\n");
|
|
512
|
+
if (lines.at(-1) === "") lines.pop();
|
|
513
|
+
if (lines.length === 0) return [];
|
|
514
|
+
return lines.slice(-lineCount);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Prefer live worker log for active tasks, then terminal output log, then newest in lane dir.
|
|
519
|
+
*
|
|
520
|
+
* @param {string} projectRoot
|
|
521
|
+
* @param {string} batchId
|
|
522
|
+
* @param {number} laneNumber
|
|
523
|
+
* @param {string[]} activeTaskIds
|
|
524
|
+
* @param {string[]} taskIds
|
|
525
|
+
* @returns {{ path: string, ref: string } | null}
|
|
526
|
+
*/
|
|
527
|
+
export function resolveLaneWorkerLog(projectRoot, batchId, laneNumber, activeTaskIds, taskIds) {
|
|
528
|
+
/** @type {string[]} */
|
|
529
|
+
const orderedTaskIds = [];
|
|
530
|
+
const seen = new Set();
|
|
531
|
+
for (const taskId of [...(activeTaskIds ?? []), ...(taskIds ?? [])]) {
|
|
532
|
+
if (!taskId || seen.has(taskId)) continue;
|
|
533
|
+
seen.add(taskId);
|
|
534
|
+
orderedTaskIds.push(String(taskId));
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
for (const taskId of orderedTaskIds) {
|
|
538
|
+
const livePath = workerLiveLogPath(projectRoot, batchId, laneNumber, taskId);
|
|
539
|
+
if (fs.existsSync(livePath)) {
|
|
540
|
+
return { path: livePath, ref: workerLiveLogRef(batchId, laneNumber, taskId) };
|
|
541
|
+
}
|
|
542
|
+
const outputPath = workerOutputLogPath(projectRoot, batchId, laneNumber, taskId);
|
|
543
|
+
if (fs.existsSync(outputPath)) {
|
|
544
|
+
return { path: outputPath, ref: workerOutputLogRef(batchId, laneNumber, taskId) };
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
const laneDir = path.join(
|
|
549
|
+
projectRoot,
|
|
550
|
+
".spine",
|
|
551
|
+
"runtime",
|
|
552
|
+
batchId,
|
|
553
|
+
"lanes",
|
|
554
|
+
`lane-${laneNumber}`,
|
|
555
|
+
);
|
|
556
|
+
if (!fs.existsSync(laneDir)) return null;
|
|
557
|
+
|
|
558
|
+
/** @type {{ path: string, ref: string, mtime: number } | null} */
|
|
559
|
+
let newest = null;
|
|
560
|
+
for (const name of fs.readdirSync(laneDir)) {
|
|
561
|
+
const isLive = name.startsWith("worker-live-") && name.endsWith(".log");
|
|
562
|
+
const isOutput = name.startsWith("worker-output-") && name.endsWith(".log");
|
|
563
|
+
if (!isLive && !isOutput) continue;
|
|
564
|
+
const candidate = path.join(laneDir, name);
|
|
565
|
+
const mtime = fs.statSync(candidate).mtimeMs;
|
|
566
|
+
if (!newest || mtime >= newest.mtime) {
|
|
567
|
+
const taskId = name.replace(/^worker-(?:live|output)-/, "").replace(/\.log$/, "");
|
|
568
|
+
newest = {
|
|
569
|
+
path: candidate,
|
|
570
|
+
ref: isLive
|
|
571
|
+
? workerLiveLogRef(batchId, laneNumber, taskId)
|
|
572
|
+
: workerOutputLogRef(batchId, laneNumber, taskId),
|
|
573
|
+
mtime,
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
return newest ? { path: newest.path, ref: newest.ref } : null;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* @param {string} projectRoot
|
|
583
|
+
* @param {string} batchId
|
|
584
|
+
* @param {number} laneNumber
|
|
585
|
+
* @param {string[]} activeTaskIds
|
|
586
|
+
* @param {string[]} taskIds
|
|
587
|
+
*/
|
|
588
|
+
export function buildLaneLogTail(projectRoot, batchId, laneNumber, activeTaskIds, taskIds) {
|
|
589
|
+
const resolved = resolveLaneWorkerLog(projectRoot, batchId, laneNumber, activeTaskIds, taskIds);
|
|
590
|
+
if (!resolved) {
|
|
591
|
+
return { logTail: [], workerLogRef: null };
|
|
592
|
+
}
|
|
593
|
+
return {
|
|
594
|
+
logTail: readLogFileTailLines(resolved.path, LANE_LOG_TAIL_LINES),
|
|
595
|
+
workerLogRef: resolved.ref,
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
|
|
424
599
|
/**
|
|
425
600
|
* @param {import("../batch/reconcile.mjs").NormalizedBatchState | null} batch
|
|
426
601
|
*/
|
|
@@ -549,6 +724,15 @@ export function buildDashboardSnapshot(projectRoot) {
|
|
|
549
724
|
? wavePlan[currentWaveIndex].map(String)
|
|
550
725
|
: [];
|
|
551
726
|
|
|
727
|
+
const config = configResult.config ?? {};
|
|
728
|
+
let metricsLines = [];
|
|
729
|
+
if (reconciliation.batchId) {
|
|
730
|
+
const metricsPath = metricsFilePath(projectRoot, config);
|
|
731
|
+
metricsLines = filterMetricsLines(readMetricsLines(metricsPath), {
|
|
732
|
+
batchId: reconciliation.batchId,
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
|
|
552
736
|
const lanes = buildLaneRows({
|
|
553
737
|
lanes: batch?.lanes ?? [],
|
|
554
738
|
classifiedTasks,
|
|
@@ -556,11 +740,38 @@ export function buildDashboardSnapshot(projectRoot) {
|
|
|
556
740
|
currentWaveTaskIds,
|
|
557
741
|
journalTail,
|
|
558
742
|
journalEvents,
|
|
743
|
+
metricsLines,
|
|
744
|
+
projectRoot,
|
|
745
|
+
batchId: reconciliation.batchId,
|
|
559
746
|
now,
|
|
560
747
|
});
|
|
748
|
+
const laneThroughputSummary = summarizeLaneThroughput(
|
|
749
|
+
deriveLanesThroughput({
|
|
750
|
+
lanes: batch?.lanes ?? [],
|
|
751
|
+
journalEvents,
|
|
752
|
+
metricsLines,
|
|
753
|
+
tasks: batch?.tasks,
|
|
754
|
+
now,
|
|
755
|
+
}),
|
|
756
|
+
);
|
|
561
757
|
const waves = buildWaveProgress(batch);
|
|
562
758
|
const defaultView = buildDefaultViewStatus(reconciliation, gate);
|
|
563
759
|
|
|
760
|
+
const macroPhase = deriveMacroPhase({
|
|
761
|
+
diagnosis: reconciliation.diagnosis,
|
|
762
|
+
batchPhase: batch?.phase ?? reconciliation.phase,
|
|
763
|
+
currentWaveIndex,
|
|
764
|
+
mergeResults: Array.isArray(rawBatch.mergeResults) ? rawBatch.mergeResults : [],
|
|
765
|
+
gateRecord: gate,
|
|
766
|
+
postMergeLimbo: reconciliation.signals?.postMergeLimbo === true,
|
|
767
|
+
journalEvents,
|
|
768
|
+
});
|
|
769
|
+
const batchSummary = summarizeBatch(batch);
|
|
770
|
+
if (batchSummary) {
|
|
771
|
+
batchSummary.macroPhase = macroPhase;
|
|
772
|
+
batchSummary.macroPhaseLabel = macroPhaseLabel(macroPhase);
|
|
773
|
+
}
|
|
774
|
+
|
|
564
775
|
return {
|
|
565
776
|
generatedAt: new Date(now).toISOString(),
|
|
566
777
|
defaultView,
|
|
@@ -572,8 +783,11 @@ export function buildDashboardSnapshot(projectRoot) {
|
|
|
572
783
|
phase: reconciliation.phase,
|
|
573
784
|
batchStatePath: reconciliation.batchStatePath,
|
|
574
785
|
reconciliation,
|
|
575
|
-
batch:
|
|
786
|
+
batch: batchSummary,
|
|
787
|
+
macroPhase,
|
|
788
|
+
macroPhaseLabel: macroPhaseLabel(macroPhase),
|
|
576
789
|
lanes,
|
|
790
|
+
laneThroughputSummary,
|
|
577
791
|
gate,
|
|
578
792
|
journalTail,
|
|
579
793
|
waves,
|
package/src/dashboard/view.mjs
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
* Dashboard view model (PRD §16.1) — pure functions for browser + tests.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
import {
|
|
6
|
+
computeThroughputTasksPerHour,
|
|
7
|
+
emptyLaneThroughputStats,
|
|
8
|
+
formatElapsedMs,
|
|
9
|
+
formatThroughputRate,
|
|
10
|
+
} from "./lane-throughput.mjs";
|
|
11
|
+
|
|
5
12
|
const DIAGNOSIS_BADGE_CLASS = {
|
|
6
13
|
running: "badge-running",
|
|
7
14
|
paused: "badge-paused",
|
|
@@ -129,6 +136,8 @@ export function buildBatchSummaryModel(batch) {
|
|
|
129
136
|
return {
|
|
130
137
|
batchId: batch.batchId,
|
|
131
138
|
phase: batch.phase,
|
|
139
|
+
macroPhase: batch.macroPhase ?? null,
|
|
140
|
+
macroPhaseLabel: batch.macroPhaseLabel ?? null,
|
|
132
141
|
baseBranch: batch.baseBranch,
|
|
133
142
|
orchBranch: batch.orchBranch,
|
|
134
143
|
startedAt: batch.startedAt,
|
|
@@ -149,6 +158,7 @@ export function buildWaveModel(snapshot) {
|
|
|
149
158
|
return {
|
|
150
159
|
currentWaveIndex: waves.currentWaveIndex ?? 0,
|
|
151
160
|
totalWaves: waves.totalWaves ?? 0,
|
|
161
|
+
macroPhaseLabel: snapshot?.macroPhaseLabel ?? snapshot?.batch?.macroPhaseLabel ?? null,
|
|
152
162
|
waves: (waves.waves ?? []).map((wave) => ({
|
|
153
163
|
index: wave.index,
|
|
154
164
|
taskIds: wave.taskIds ?? [],
|
|
@@ -166,23 +176,145 @@ export function formatLaneHeartbeatDisplay(lane) {
|
|
|
166
176
|
return `${lane.heartbeatAgeSeconds}s`;
|
|
167
177
|
}
|
|
168
178
|
|
|
179
|
+
/**
|
|
180
|
+
* @param {object} lane
|
|
181
|
+
*/
|
|
182
|
+
export function buildLaneThroughputModel(lane) {
|
|
183
|
+
const throughput = lane?.throughput ?? emptyLaneThroughputStats();
|
|
184
|
+
return {
|
|
185
|
+
activeElapsedMs: throughput.activeElapsedMs,
|
|
186
|
+
completedCount: throughput.completedCount,
|
|
187
|
+
failedCount: throughput.failedCount,
|
|
188
|
+
throughputTasksPerHour: throughput.throughputTasksPerHour,
|
|
189
|
+
elapsedDisplay: formatElapsedMs(throughput.activeElapsedMs),
|
|
190
|
+
doneDisplay: throughput.completedCount > 0 ? String(throughput.completedCount) : "—",
|
|
191
|
+
rateDisplay:
|
|
192
|
+
throughput.throughputTasksPerHour == null
|
|
193
|
+
? "—"
|
|
194
|
+
: `${formatThroughputRate(throughput.throughputTasksPerHour)} tasks/hr`,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @param {object|null|undefined} summary
|
|
200
|
+
*/
|
|
201
|
+
export function buildLaneThroughputSummaryModel(summary) {
|
|
202
|
+
const throughput = summary ?? emptyLaneThroughputStats();
|
|
203
|
+
return {
|
|
204
|
+
elapsedDisplay: formatElapsedMs(throughput.activeElapsedMs),
|
|
205
|
+
doneDisplay: throughput.completedCount > 0 ? String(throughput.completedCount) : "—",
|
|
206
|
+
rateDisplay:
|
|
207
|
+
throughput.throughputTasksPerHour == null
|
|
208
|
+
? "—"
|
|
209
|
+
: `${formatThroughputRate(throughput.throughputTasksPerHour)} tasks/hr`,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* @param {object} lane
|
|
215
|
+
*/
|
|
216
|
+
export function buildLaneDetailModel(lane) {
|
|
217
|
+
return {
|
|
218
|
+
recentEvents: (lane?.recentEvents ?? []).map((entry) => ({
|
|
219
|
+
eventId: entry.eventId,
|
|
220
|
+
type: entry.type,
|
|
221
|
+
timestamp: entry.timestamp,
|
|
222
|
+
summary: entry.summary,
|
|
223
|
+
})),
|
|
224
|
+
logTail: lane?.logTail ?? [],
|
|
225
|
+
workerLogRef: lane?.workerLogRef ?? null,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Resolve running vs queued task projection for the lane table.
|
|
231
|
+
* Prefers SP-379 snapshot fields; falls back to deprecated activeTaskIds.
|
|
232
|
+
*
|
|
233
|
+
* @param {object} lane
|
|
234
|
+
*/
|
|
235
|
+
export function resolveLaneQueueProjection(lane) {
|
|
236
|
+
const runningTaskId = lane?.runningTaskId ?? null;
|
|
237
|
+
const queuedTaskIds = lane?.queuedTaskIds ?? null;
|
|
238
|
+
|
|
239
|
+
if (runningTaskId != null || (queuedTaskIds != null && queuedTaskIds.length > 0)) {
|
|
240
|
+
return {
|
|
241
|
+
runningTaskId: runningTaskId ?? null,
|
|
242
|
+
queuedTaskIds: queuedTaskIds ?? [],
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const activeTaskIds = lane?.activeTaskIds ?? [];
|
|
247
|
+
if (activeTaskIds.length === 0) {
|
|
248
|
+
return { runningTaskId: null, queuedTaskIds: [] };
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Degraded fallback until snapshot exposes explicit queue fields (SP-379).
|
|
252
|
+
if (lane?.status === "running" && activeTaskIds.length >= 1) {
|
|
253
|
+
return {
|
|
254
|
+
runningTaskId: activeTaskIds[0] ?? null,
|
|
255
|
+
queuedTaskIds: activeTaskIds.slice(1),
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return { runningTaskId: null, queuedTaskIds: [...activeTaskIds] };
|
|
260
|
+
}
|
|
261
|
+
|
|
169
262
|
/**
|
|
170
263
|
* @param {object} snapshot
|
|
171
264
|
*/
|
|
172
265
|
export function buildLaneTableModel(snapshot) {
|
|
173
|
-
return (snapshot?.lanes ?? []).map((lane) =>
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
266
|
+
return (snapshot?.lanes ?? []).map((lane) => {
|
|
267
|
+
const queue = resolveLaneQueueProjection(lane);
|
|
268
|
+
return {
|
|
269
|
+
laneId: lane.laneId,
|
|
270
|
+
laneNumber: lane.laneNumber,
|
|
271
|
+
status: lane.status,
|
|
272
|
+
activeTaskIds: lane.activeTaskIds ?? [],
|
|
273
|
+
runningTaskId: queue.runningTaskId,
|
|
274
|
+
queuedTaskIds: queue.queuedTaskIds,
|
|
275
|
+
queuedCount: queue.queuedTaskIds.length,
|
|
276
|
+
taskIds: lane.taskIds ?? [],
|
|
277
|
+
heartbeatAgeSeconds: lane.heartbeatAgeSeconds,
|
|
278
|
+
heartbeatKind: lane.heartbeatKind ?? null,
|
|
279
|
+
workerPhase: lane.workerPhase ?? null,
|
|
280
|
+
heartbeatDisplay: lane.heartbeatDisplay ?? formatLaneHeartbeatDisplay(lane),
|
|
281
|
+
activityPhase: lane.activityPhase ?? "idle",
|
|
282
|
+
activityPhaseLabel: lane.activityPhaseLabel ?? "—",
|
|
283
|
+
worktree: lane.worktree,
|
|
284
|
+
laneAlert: lane.laneAlert ?? null,
|
|
285
|
+
throughput: buildLaneThroughputModel(lane),
|
|
286
|
+
detail: buildLaneDetailModel(lane),
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* @param {object} snapshot
|
|
293
|
+
*/
|
|
294
|
+
export function buildLaneTableSummaryModel(snapshot) {
|
|
295
|
+
const lanes = snapshot?.lanes ?? [];
|
|
296
|
+
if (lanes.length < 2) return null;
|
|
297
|
+
|
|
298
|
+
if (snapshot?.laneThroughputSummary) {
|
|
299
|
+
return buildLaneThroughputSummaryModel(snapshot.laneThroughputSummary);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
let activeElapsedMs = 0;
|
|
303
|
+
let completedCount = 0;
|
|
304
|
+
let failedCount = 0;
|
|
305
|
+
for (const lane of lanes) {
|
|
306
|
+
const throughput = lane.throughput ?? emptyLaneThroughputStats();
|
|
307
|
+
activeElapsedMs += throughput.activeElapsedMs;
|
|
308
|
+
completedCount += throughput.completedCount;
|
|
309
|
+
failedCount += throughput.failedCount;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return buildLaneThroughputSummaryModel({
|
|
313
|
+
activeElapsedMs,
|
|
314
|
+
completedCount,
|
|
315
|
+
failedCount,
|
|
316
|
+
throughputTasksPerHour: computeThroughputTasksPerHour(completedCount, activeElapsedMs),
|
|
317
|
+
});
|
|
186
318
|
}
|
|
187
319
|
|
|
188
320
|
/**
|
|
@@ -247,20 +379,39 @@ export function shouldShowGateAffordance(snapshot) {
|
|
|
247
379
|
|
|
248
380
|
/**
|
|
249
381
|
* @param {object} snapshot
|
|
382
|
+
* @param {{ laneFilter?: string|null }} [options]
|
|
250
383
|
*/
|
|
251
|
-
export function buildJournalModel(snapshot) {
|
|
252
|
-
|
|
384
|
+
export function buildJournalModel(snapshot, { laneFilter = null } = {}) {
|
|
385
|
+
let entries = snapshot?.journalTail ?? [];
|
|
386
|
+
if (laneFilter) {
|
|
387
|
+
entries = entries.filter((entry) => entry.laneId === laneFilter);
|
|
388
|
+
}
|
|
389
|
+
return entries.map((entry) => ({
|
|
253
390
|
eventId: entry.eventId,
|
|
254
391
|
type: entry.type,
|
|
255
392
|
timestamp: entry.timestamp,
|
|
393
|
+
laneId: entry.laneId ?? null,
|
|
256
394
|
summary: entry.summary,
|
|
257
395
|
}));
|
|
258
396
|
}
|
|
259
397
|
|
|
398
|
+
/**
|
|
399
|
+
* Lane ids for the optional journal panel filter.
|
|
400
|
+
*
|
|
401
|
+
* @param {object} snapshot
|
|
402
|
+
*/
|
|
403
|
+
export function buildJournalLaneFilterOptions(snapshot) {
|
|
404
|
+
return (snapshot?.lanes ?? []).map((lane) => ({
|
|
405
|
+
laneId: lane.laneId,
|
|
406
|
+
label: lane.laneId ?? `lane-${lane.laneNumber}`,
|
|
407
|
+
}));
|
|
408
|
+
}
|
|
409
|
+
|
|
260
410
|
/**
|
|
261
411
|
* @param {object} snapshot
|
|
412
|
+
* @param {{ journalLaneFilter?: string|null }} [options]
|
|
262
413
|
*/
|
|
263
|
-
export function buildDashboardViewModel(snapshot) {
|
|
414
|
+
export function buildDashboardViewModel(snapshot, { journalLaneFilter = null } = {}) {
|
|
264
415
|
return {
|
|
265
416
|
generatedAt: snapshot?.generatedAt ?? null,
|
|
266
417
|
idle: isIdleSnapshot(snapshot),
|
|
@@ -268,10 +419,12 @@ export function buildDashboardViewModel(snapshot) {
|
|
|
268
419
|
batch: buildBatchSummaryModel(snapshot?.batch),
|
|
269
420
|
waves: buildWaveModel(snapshot),
|
|
270
421
|
lanes: buildLaneTableModel(snapshot),
|
|
422
|
+
laneTableSummary: buildLaneTableSummaryModel(snapshot),
|
|
271
423
|
gate: buildGateModel(snapshot?.gate),
|
|
272
424
|
gateAffordance: buildGateAffordanceModel(snapshot),
|
|
273
425
|
showGateAffordance: shouldShowGateAffordance(snapshot),
|
|
274
|
-
journal: buildJournalModel(snapshot),
|
|
426
|
+
journal: buildJournalModel(snapshot, { laneFilter: journalLaneFilter }),
|
|
427
|
+
journalLaneFilterOptions: buildJournalLaneFilterOptions(snapshot),
|
|
275
428
|
};
|
|
276
429
|
}
|
|
277
430
|
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Doctor warning when spine agents inherit pi's global model and pi defaults to LM Studio (SP-238).
|
|
3
|
+
* Per-type reviewer effective pins (issue #53 / SP-371).
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
6
|
import fs from "node:fs";
|
|
6
7
|
import os from "node:os";
|
|
7
8
|
import path from "node:path";
|
|
8
9
|
|
|
10
|
+
import {
|
|
11
|
+
resolveReviewerModelPin,
|
|
12
|
+
resolveReviewerThinkingPin,
|
|
13
|
+
} from "../config/agent-model-resolve.mjs";
|
|
14
|
+
|
|
9
15
|
const LMSTUDIO_PROVIDER = "lmstudio";
|
|
10
16
|
|
|
17
|
+
/** @type {readonly ("plan"|"code"|"final")[]} */
|
|
18
|
+
const REVIEW_TYPES = ["plan", "code", "final"];
|
|
19
|
+
|
|
11
20
|
/**
|
|
12
21
|
* @param {string} settingsPath
|
|
13
22
|
* @returns {Record<string, unknown>|null}
|
|
@@ -48,15 +57,57 @@ export function resolvePiDefaultProvider(
|
|
|
48
57
|
return provider.trim().toLowerCase();
|
|
49
58
|
}
|
|
50
59
|
|
|
60
|
+
/**
|
|
61
|
+
* @param {unknown} model
|
|
62
|
+
* @returns {boolean}
|
|
63
|
+
*/
|
|
64
|
+
function modelUsesInherit(model) {
|
|
65
|
+
return !model || model === "inherit";
|
|
66
|
+
}
|
|
67
|
+
|
|
51
68
|
/**
|
|
52
69
|
* @param {object} [config]
|
|
53
70
|
* @returns {boolean}
|
|
54
71
|
*/
|
|
55
72
|
export function spineAgentsUseInherit(config = {}) {
|
|
56
73
|
const workerModel = config.agents?.worker?.model;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
74
|
+
if (modelUsesInherit(workerModel)) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
for (const reviewType of REVIEW_TYPES) {
|
|
79
|
+
if (resolveReviewerModelPin(config, reviewType) === null) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @param {object} [config]
|
|
89
|
+
* @returns {string}
|
|
90
|
+
*/
|
|
91
|
+
export function formatReviewerEffectivePins(config = {}) {
|
|
92
|
+
return REVIEW_TYPES.map((reviewType) => {
|
|
93
|
+
const modelPin = resolveReviewerModelPin(config, reviewType);
|
|
94
|
+
const thinkingPin = resolveReviewerThinkingPin(config, reviewType);
|
|
95
|
+
const modelLabel = modelPin ?? "inherit";
|
|
96
|
+
const thinkingLabel = thinkingPin ?? "inherit";
|
|
97
|
+
return `${reviewType}=${modelLabel}/${thinkingLabel}`;
|
|
98
|
+
}).join(", ");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @param {object} params
|
|
103
|
+
* @param {object} [params.config]
|
|
104
|
+
*/
|
|
105
|
+
export function buildReviewerPerTypePinsDoctorCheck({ config = {} } = {}) {
|
|
106
|
+
return {
|
|
107
|
+
label: "reviewer model pins (per-type)",
|
|
108
|
+
ok: true,
|
|
109
|
+
detail: formatReviewerEffectivePins(config),
|
|
110
|
+
};
|
|
60
111
|
}
|
|
61
112
|
|
|
62
113
|
/**
|
|
@@ -70,11 +121,13 @@ export function buildAgentModelInheritDoctorCheck({
|
|
|
70
121
|
projectRoot = process.cwd(),
|
|
71
122
|
resolveProvider,
|
|
72
123
|
} = {}) {
|
|
124
|
+
const perTypeDetail = formatReviewerEffectivePins(config);
|
|
125
|
+
|
|
73
126
|
if (!spineAgentsUseInherit(config)) {
|
|
74
127
|
return {
|
|
75
128
|
label: "agents model inherit (pi-lmstudio)",
|
|
76
129
|
ok: true,
|
|
77
|
-
detail:
|
|
130
|
+
detail: `pinned — ${perTypeDetail}`,
|
|
78
131
|
};
|
|
79
132
|
}
|
|
80
133
|
|
|
@@ -85,7 +138,9 @@ export function buildAgentModelInheritDoctorCheck({
|
|
|
85
138
|
return {
|
|
86
139
|
label: "agents model inherit (pi-lmstudio)",
|
|
87
140
|
ok: true,
|
|
88
|
-
detail: provider
|
|
141
|
+
detail: provider
|
|
142
|
+
? `pi default provider ${provider} — ${perTypeDetail}`
|
|
143
|
+
: `pi default provider unset — ${perTypeDetail}`,
|
|
89
144
|
};
|
|
90
145
|
}
|
|
91
146
|
|
|
@@ -94,7 +149,7 @@ export function buildAgentModelInheritDoctorCheck({
|
|
|
94
149
|
ok: true,
|
|
95
150
|
warning: true,
|
|
96
151
|
detail:
|
|
97
|
-
|
|
152
|
+
`inherit + pi defaultProvider lmstudio — batch workers/reviewers may use local LM Studio; pin cursor/auto in spine-config — ${perTypeDetail}`,
|
|
98
153
|
suggestedCommand:
|
|
99
154
|
"spine settings set agents.worker.model cursor/auto && spine settings set agents.reviewer.model cursor/auto",
|
|
100
155
|
};
|