pi-spine 1.7.0 → 1.8.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/package.json +2 -2
- package/skills/spine-autonomous-operator/SKILL.md +264 -0
- package/skills/spine-autonomous-operator/references/issue-template.md +45 -0
- package/skills/spine-orchestrate-waves/SKILL.md +1 -0
- package/skills/spine-release-operator/SKILL.md +44 -8
- package/skills/spine-release-operator/references/pi-async-orchestration.md +88 -0
- package/skills/spine-release-operator/scripts/collect-release-intake.sh +71 -0
- package/src/batch/abort.mjs +1 -0
- package/src/batch/agent-session-worker.mjs +1 -0
- package/src/batch/attached-engine-handoff.mjs +1 -0
- package/src/batch/attached-runner.mjs +1 -0
- package/src/batch/contract-prelanded.mjs +1 -0
- package/src/batch/contract-task-start.mjs +1 -0
- package/src/batch/contract-verify.mjs +1 -0
- package/src/batch/detached-start.mjs +1 -0
- package/src/batch/diagnosis-launch-failure.mjs +1 -0
- package/src/batch/diagnosis-merge-failure.mjs +1 -0
- package/src/batch/diagnosis-retry-limbo.mjs +1 -0
- package/src/batch/diagnosis-tail-state.mjs +1 -0
- package/src/batch/diagnosis-task-done.mjs +1 -0
- package/src/batch/diagnosis-worker-done-missing.mjs +1 -0
- package/src/batch/diagnosis.mjs +1 -0
- package/src/batch/engine-lanes/commit.mjs +1 -0
- package/src/batch/engine-lanes/merge.mjs +1 -0
- package/src/batch/engine-lanes/queue.mjs +1 -0
- package/src/batch/engine-lanes/review.mjs +1 -0
- package/src/batch/engine-lanes.mjs +1 -0
- package/src/batch/engine-scope.mjs +1 -0
- package/src/batch/engine.mjs +19 -9
- package/src/batch/evidence.mjs +1 -0
- package/src/batch/gate-evidence-collect.mjs +1 -0
- package/src/batch/gate-evidence-read.mjs +1 -0
- package/src/batch/gate.mjs +1 -0
- package/src/batch/git-helpers.mjs +1 -1
- package/src/batch/heartbeat-git-debounce.mjs +83 -0
- package/src/batch/heartbeat.mjs +17 -20
- package/src/batch/integrate-worktree.mjs +1 -0
- package/src/batch/integrate.mjs +1 -0
- package/src/batch/journal-rebuild.mjs +1 -0
- package/src/batch/journal.mjs +2 -1
- package/src/batch/lane-commit.mjs +1 -0
- package/src/batch/lane-dirty-check.mjs +1 -0
- package/src/batch/lifecycle.mjs +1 -0
- package/src/batch/limbo-detect.mjs +1 -0
- package/src/batch/macro-phase.mjs +1 -0
- package/src/batch/merge/adoption-doc-merge.mjs +1 -0
- package/src/batch/merge/wave-merge-state.mjs +1 -0
- package/src/batch/metrics.mjs +1 -0
- package/src/batch/orphan-detect.mjs +1 -0
- package/src/batch/pause.mjs +1 -0
- package/src/batch/post-merge-limbo.mjs +1 -0
- package/src/batch/postmortem.mjs +1 -0
- package/src/batch/readers/spine-state.mjs +1 -0
- package/src/batch/readers/taskplane-state.mjs +1 -0
- package/src/batch/reconcile.mjs +84 -8
- package/src/batch/resume-common.mjs +1 -0
- package/src/batch/resume-engine.mjs +1 -0
- package/src/batch/resume-multi-lanes.mjs +1 -0
- package/src/batch/resume-multi-validate.mjs +1 -0
- package/src/batch/resume-multi.mjs +1 -0
- package/src/batch/resume-validation.mjs +1 -0
- package/src/batch/resume.mjs +1 -0
- package/src/batch/retry.mjs +1 -0
- package/src/batch/review-shared.mjs +1 -0
- package/src/batch/review-spawn.mjs +1 -0
- package/src/batch/review.mjs +1 -0
- package/src/batch/rules-manifest-drift.mjs +1 -0
- package/src/batch/salvage.mjs +1 -0
- package/src/batch/sequence.mjs +5 -2
- package/src/batch/state.mjs +1 -0
- package/src/batch/supervisor-spawn.mjs +1 -0
- package/src/batch/task-stall-budget.mjs +3 -4
- package/src/batch/worker-host.mjs +31 -25
- package/src/batch/worker-output.mjs +1 -0
- package/src/batch/worker-prompt.mjs +1 -0
- package/src/cli/journal-follow.mjs +1 -1
- package/src/config/agent-model-resolve.mjs +1 -0
- package/src/config/contract.mjs +1 -0
- package/src/config/cursor-rules/discover.mjs +1 -0
- package/src/config/cursor-rules/match-globs.mjs +1 -0
- package/src/config/cursor-rules/parse-frontmatter.mjs +1 -0
- package/src/config/cursor-rules/profile.mjs +1 -0
- package/src/config/cursor-rules/select.mjs +1 -0
- package/src/config/env-overrides.mjs +1 -0
- package/src/config/pi-spine-root.mjs +1 -0
- package/src/config/preflight/discovery.mjs +333 -0
- package/src/config/preflight/git-batch.mjs +320 -0
- package/src/config/preflight/integrate-plan.mjs +460 -0
- package/src/config/reviewer-context.mjs +1 -0
- package/src/config/settings-fields.mjs +1 -0
- package/src/config/spine-config-schema.mjs +1 -0
- package/src/config/spine-init-constants.mjs +1 -0
- package/src/config/spine-preflight-lib.mjs +54 -1013
- package/src/config/worker-backend.mjs +1 -0
- package/src/config/worker-context.mjs +1 -0
- package/src/config/worker-launch-script.mjs +1 -0
- package/src/config/worktree-setup-hook.mjs +1 -0
- package/src/dashboard/public/dashboard.js +6 -1
- package/src/dashboard/running-tail-state.mjs +1 -0
- package/src/dashboard/server.mjs +136 -16
- package/src/dashboard/snapshot-lanes.mjs +479 -0
- package/src/dashboard/snapshot-waves.mjs +272 -0
- package/src/dashboard/snapshot.mjs +41 -862
- package/src/doctor/agent-model-inherit.mjs +1 -0
- package/src/doctor/agent-models.mjs +1 -0
- package/src/doctor/coexistence.mjs +1 -0
- package/src/doctor/run-doctor-checks.mjs +1 -0
- package/src/doctor/stale-path.mjs +1 -0
- package/src/doctor/stall-config.mjs +1 -0
- package/src/doctor/suggest-max-parallel.mjs +1 -0
- package/src/doctor/task-packet-size.mjs +3 -10
- package/src/doctor/worktree-health.mjs +1 -0
- package/src/planner/cycles.mjs +1 -0
- package/src/planner/file-scope.mjs +1 -0
- package/src/planner/format-plan.mjs +1 -0
- package/src/planner/graph.mjs +1 -0
- package/src/planner/scope.mjs +1 -0
- package/src/planner/wave-scope.mjs +1 -0
- package/src/planner/waves.mjs +1 -0
- package/src/tasks/packet/merge-deps.mjs +1 -0
- package/src/tasks/packet/parse-prompt.mjs +4 -3
- package/src/tasks/packet/parse-status.mjs +1 -0
- package/src/tasks/packet/size-line.mjs +12 -0
- package/src/tasks/packet/validate-contract.mjs +1 -0
- package/src/tasks/packet/validate-prompt.mjs +1 -0
package/src/batch/diagnosis.mjs
CHANGED
package/src/batch/engine.mjs
CHANGED
|
@@ -72,6 +72,16 @@ export {
|
|
|
72
72
|
} from "./engine-scope.mjs";
|
|
73
73
|
export { loadTaskFileScopePaths, mergeLaneToOrch } from "./engine-lanes.mjs";
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Mutable batch-state fields are widened from createInitialBatchState literals so
|
|
77
|
+
* terminal transitions can assign endedAt/lastError without any casts.
|
|
78
|
+
*
|
|
79
|
+
* @typedef {Omit<ReturnType<typeof createInitialBatchState>, "endedAt" | "lastError"> & {
|
|
80
|
+
* endedAt: number | null;
|
|
81
|
+
* lastError: string | null;
|
|
82
|
+
* }} SpineBatchState
|
|
83
|
+
*/
|
|
84
|
+
|
|
75
85
|
const WORKTREE_SPINE_PATTERN = /[/\\]\.worktrees[/\\]spine-/;
|
|
76
86
|
|
|
77
87
|
/**
|
|
@@ -149,7 +159,7 @@ export async function startBatch({
|
|
|
149
159
|
ok: false,
|
|
150
160
|
exitCode: preflight.exitCode ?? 1,
|
|
151
161
|
error: "preflight_failed",
|
|
152
|
-
output: /** @type {
|
|
162
|
+
output: /** @type {{ output?: string }} */ (preflight).output,
|
|
153
163
|
};
|
|
154
164
|
}
|
|
155
165
|
}
|
|
@@ -241,8 +251,8 @@ export async function startBatch({
|
|
|
241
251
|
maxLaneNumber,
|
|
242
252
|
});
|
|
243
253
|
|
|
244
|
-
/** @type {
|
|
245
|
-
|
|
254
|
+
/** @type {SpineBatchState} */
|
|
255
|
+
const state = createInitialBatchState({
|
|
246
256
|
batchId,
|
|
247
257
|
baseBranch,
|
|
248
258
|
orchBranch,
|
|
@@ -425,8 +435,8 @@ export async function startBatch({
|
|
|
425
435
|
|
|
426
436
|
if (batchAborted) {
|
|
427
437
|
const abortedTask = state.tasks.find((/** @type {{ status: string }} */ task) => task.status === "aborted");
|
|
428
|
-
|
|
429
|
-
|
|
438
|
+
state.endedAt = Date.now();
|
|
439
|
+
state.lastError = "batch aborted";
|
|
430
440
|
transitionPhase(state, "aborted", {
|
|
431
441
|
projectRoot,
|
|
432
442
|
batchId,
|
|
@@ -444,8 +454,8 @@ export async function startBatch({
|
|
|
444
454
|
|
|
445
455
|
const mergeEligibility = assessWaveMergeEligibility(state, wave.index);
|
|
446
456
|
if (!mergeEligibility.ok) {
|
|
447
|
-
|
|
448
|
-
|
|
457
|
+
state.endedAt = Date.now();
|
|
458
|
+
state.lastError = mergeEligibility.message?.slice(0, 500) ?? "mixed_outcome";
|
|
449
459
|
transitionPhase(state, "failed", {
|
|
450
460
|
projectRoot,
|
|
451
461
|
batchId,
|
|
@@ -531,8 +541,8 @@ export async function startBatch({
|
|
|
531
541
|
});
|
|
532
542
|
} catch (err) {
|
|
533
543
|
const message = err instanceof Error ? err.message : String(err);
|
|
534
|
-
|
|
535
|
-
|
|
544
|
+
state.endedAt = Date.now();
|
|
545
|
+
state.lastError = message;
|
|
536
546
|
transitionPhase(state, "failed", {
|
|
537
547
|
projectRoot,
|
|
538
548
|
batchId,
|
package/src/batch/evidence.mjs
CHANGED
package/src/batch/gate.mjs
CHANGED
|
@@ -17,7 +17,7 @@ export function filterGitignoredPaths(projectRoot, paths) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/** @type {Set<string>} */
|
|
20
|
-
|
|
20
|
+
const ignoredSet = new Set();
|
|
21
21
|
try {
|
|
22
22
|
const output = execFileSync("git", ["check-ignore", "--no-index", "--stdin"], {
|
|
23
23
|
cwd: projectRoot,
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* Git porcelain debounce for lane heartbeat progress signals (issue #98 P1).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Per-lane file-scope mtime snapshot; reused when mtimes are unchanged.
|
|
11
|
+
* @type {Map<string, { fileScopeMtimeMs: number | null, dirtyPaths: string[] }>}
|
|
12
|
+
*/
|
|
13
|
+
const _gitPorcelainDebounceByLane = new Map();
|
|
14
|
+
|
|
15
|
+
let _gitPorcelainCallCount = 0;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} worktreePath
|
|
19
|
+
* @param {string[]} [fileScopePaths]
|
|
20
|
+
*/
|
|
21
|
+
function gitPorcelainDebounceKey(worktreePath, fileScopePaths) {
|
|
22
|
+
const scopeKey = Array.isArray(fileScopePaths) ? fileScopePaths.join("\0") : "";
|
|
23
|
+
return `${worktreePath}\0${scopeKey}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Clear git porcelain debounce cache. Useful for test isolation. */
|
|
27
|
+
export function clearGitPorcelainDebounceCache() {
|
|
28
|
+
_gitPorcelainDebounceByLane.clear();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Reset git porcelain invocation counter (tests only). */
|
|
32
|
+
export function resetGitPorcelainCallCount() {
|
|
33
|
+
_gitPorcelainCallCount = 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** @returns {number} git status --porcelain invocations since last reset. */
|
|
37
|
+
export function getGitPorcelainCallCount() {
|
|
38
|
+
return _gitPorcelainCallCount;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Max mtime among existing file-scope paths (FR-WORK-10 activity signal).
|
|
43
|
+
* @param {string} worktreePath
|
|
44
|
+
* @param {string[]} [fileScopePaths]
|
|
45
|
+
*/
|
|
46
|
+
export function resolveFileScopeMtimeMs(worktreePath, fileScopePaths) {
|
|
47
|
+
if (!Array.isArray(fileScopePaths) || fileScopePaths.length === 0) return null;
|
|
48
|
+
let max = null;
|
|
49
|
+
for (const rel of fileScopePaths) {
|
|
50
|
+
if (!rel || typeof rel !== "string") continue;
|
|
51
|
+
const target = path.join(worktreePath, rel);
|
|
52
|
+
if (!fs.existsSync(target)) continue;
|
|
53
|
+
const stat = fs.statSync(target);
|
|
54
|
+
if (!stat.isFile()) continue;
|
|
55
|
+
max = max === null ? stat.mtimeMs : Math.max(max, stat.mtimeMs);
|
|
56
|
+
}
|
|
57
|
+
return max;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Debounced wrapper around fresh scoped porcelain resolution.
|
|
62
|
+
* @param {string} worktreePath
|
|
63
|
+
* @param {string[]} [fileScopePaths]
|
|
64
|
+
* @param {string} [taskFolder]
|
|
65
|
+
* @param {(worktreePath: string, fileScopePaths?: string[], taskFolder?: string) => string[]} resolveFresh
|
|
66
|
+
*/
|
|
67
|
+
export function resolveDebouncedScopedDirtyPaths(
|
|
68
|
+
worktreePath,
|
|
69
|
+
fileScopePaths,
|
|
70
|
+
taskFolder,
|
|
71
|
+
resolveFresh,
|
|
72
|
+
) {
|
|
73
|
+
const fileScopeMtimeMs = resolveFileScopeMtimeMs(worktreePath, fileScopePaths);
|
|
74
|
+
const debounceKey = gitPorcelainDebounceKey(worktreePath, fileScopePaths);
|
|
75
|
+
const debounced = _gitPorcelainDebounceByLane.get(debounceKey);
|
|
76
|
+
if (debounced && debounced.fileScopeMtimeMs === fileScopeMtimeMs) {
|
|
77
|
+
return debounced.dirtyPaths;
|
|
78
|
+
}
|
|
79
|
+
_gitPorcelainCallCount += 1;
|
|
80
|
+
const dirtyPaths = resolveFresh(worktreePath, fileScopePaths, taskFolder);
|
|
81
|
+
_gitPorcelainDebounceByLane.set(debounceKey, { fileScopeMtimeMs, dirtyPaths });
|
|
82
|
+
return dirtyPaths;
|
|
83
|
+
}
|
package/src/batch/heartbeat.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/**
|
|
2
3
|
* Lane heartbeat and progress-aware stall helpers (FR-WORK-09, PRD §18.4, FR-STALL-02).
|
|
3
4
|
*/
|
|
@@ -6,6 +7,16 @@ import fs from "node:fs";
|
|
|
6
7
|
import path from "node:path";
|
|
7
8
|
import { execFileSync } from "node:child_process";
|
|
8
9
|
import { appendJournalEvent, readJournalEventsCached } from "./journal.mjs";
|
|
10
|
+
import {
|
|
11
|
+
resolveDebouncedScopedDirtyPaths,
|
|
12
|
+
resolveFileScopeMtimeMs,
|
|
13
|
+
} from "./heartbeat-git-debounce.mjs";
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
clearGitPorcelainDebounceCache,
|
|
17
|
+
getGitPorcelainCallCount,
|
|
18
|
+
resetGitPorcelainCallCount,
|
|
19
|
+
} from "./heartbeat-git-debounce.mjs";
|
|
9
20
|
|
|
10
21
|
const DEFAULT_STALL_TIMEOUT_MIN = 60;
|
|
11
22
|
const DEFAULT_GRACE_AFTER_PROGRESS_MIN = 15;
|
|
@@ -76,25 +87,6 @@ function git(worktreePath, args) {
|
|
|
76
87
|
}
|
|
77
88
|
}
|
|
78
89
|
|
|
79
|
-
/**
|
|
80
|
-
* Max mtime among existing file-scope paths (FR-WORK-10 activity signal; warning only by default).
|
|
81
|
-
* @param {string} worktreePath
|
|
82
|
-
* @param {string[]} [fileScopePaths]
|
|
83
|
-
*/
|
|
84
|
-
function resolveFileScopeMtimeMs(worktreePath, fileScopePaths) {
|
|
85
|
-
if (!Array.isArray(fileScopePaths) || fileScopePaths.length === 0) return null;
|
|
86
|
-
let max = null;
|
|
87
|
-
for (const rel of fileScopePaths) {
|
|
88
|
-
if (!rel || typeof rel !== "string") continue;
|
|
89
|
-
const target = path.join(worktreePath, rel);
|
|
90
|
-
if (!fs.existsSync(target)) continue;
|
|
91
|
-
const stat = fs.statSync(target);
|
|
92
|
-
if (!stat.isFile()) continue;
|
|
93
|
-
max = max === null ? stat.mtimeMs : Math.max(max, stat.mtimeMs);
|
|
94
|
-
}
|
|
95
|
-
return max;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
90
|
/**
|
|
99
91
|
* Scoped git porcelain paths under File Scope or the task folder (FR-STALL-02 activity).
|
|
100
92
|
* @param {string} worktreePath
|
|
@@ -196,7 +188,12 @@ export function collectProgressSignals({
|
|
|
196
188
|
}
|
|
197
189
|
|
|
198
190
|
const fileScopeMtimeMs = resolveFileScopeMtimeMs(worktreePath, fileScopePaths);
|
|
199
|
-
const dirtyPaths =
|
|
191
|
+
const dirtyPaths = resolveDebouncedScopedDirtyPaths(
|
|
192
|
+
worktreePath,
|
|
193
|
+
fileScopePaths,
|
|
194
|
+
taskFolder,
|
|
195
|
+
resolveScopedDirtyPaths,
|
|
196
|
+
);
|
|
200
197
|
|
|
201
198
|
let stepCompletedAtMs = null;
|
|
202
199
|
if (journalContext?.projectRoot && journalContext?.batchId) {
|
package/src/batch/integrate.mjs
CHANGED
package/src/batch/journal.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/**
|
|
2
3
|
* Append-only orchestration journal (FR-JRN, PRD §11).
|
|
3
4
|
*/
|
|
@@ -83,7 +84,7 @@ export function redactSecrets(value) {
|
|
|
83
84
|
* @param {Record<string, unknown>} payload
|
|
84
85
|
*/
|
|
85
86
|
export function capPayloadSize(payload) {
|
|
86
|
-
|
|
87
|
+
const serialized = JSON.stringify(payload);
|
|
87
88
|
if (Buffer.byteLength(serialized, "utf-8") <= MAX_PAYLOAD_BYTES) {
|
|
88
89
|
return payload;
|
|
89
90
|
}
|
package/src/batch/lifecycle.mjs
CHANGED
package/src/batch/metrics.mjs
CHANGED
package/src/batch/pause.mjs
CHANGED
package/src/batch/postmortem.mjs
CHANGED
package/src/batch/reconcile.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/**
|
|
2
3
|
* Batch reconciliation (FR-BATCH-12, §17.5).
|
|
3
4
|
*/
|
|
@@ -56,6 +57,53 @@ export { loadBatchStateFile, parseBatchState, resolveBatchStatePath } from "./ba
|
|
|
56
57
|
const LIMBO_PHASES = new Set(["stopped", "failed", "executing"]);
|
|
57
58
|
const RUNNING_PHASES = new Set(["planning", "running", "executing", "merging"]);
|
|
58
59
|
|
|
60
|
+
/** @type {{ projectRoot: string|null, batchId: string|null, phase: string|null, git: object|null, diagnosis: string|null }} */
|
|
61
|
+
let _lightReconcileCache = {
|
|
62
|
+
projectRoot: null,
|
|
63
|
+
batchId: null,
|
|
64
|
+
phase: null,
|
|
65
|
+
git: null,
|
|
66
|
+
diagnosis: null,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Clears light-reconcile git cache (test isolation).
|
|
71
|
+
*/
|
|
72
|
+
export function clearLightReconcileCache() {
|
|
73
|
+
_lightReconcileCache = {
|
|
74
|
+
projectRoot: null,
|
|
75
|
+
batchId: null,
|
|
76
|
+
phase: null,
|
|
77
|
+
git: null,
|
|
78
|
+
diagnosis: null,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @param {string} projectRoot
|
|
84
|
+
* @param {string} batchId
|
|
85
|
+
* @param {string} phase
|
|
86
|
+
*/
|
|
87
|
+
function lightReconcileCacheMatches(projectRoot, batchId, phase) {
|
|
88
|
+
return (
|
|
89
|
+
_lightReconcileCache.projectRoot === projectRoot &&
|
|
90
|
+
_lightReconcileCache.batchId === batchId &&
|
|
91
|
+
_lightReconcileCache.phase === phase &&
|
|
92
|
+
_lightReconcileCache.git != null
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @param {string} projectRoot
|
|
98
|
+
* @param {string} batchId
|
|
99
|
+
* @param {string} phase
|
|
100
|
+
* @param {object} git
|
|
101
|
+
* @param {string|null} diagnosis
|
|
102
|
+
*/
|
|
103
|
+
function updateLightReconcileCache(projectRoot, batchId, phase, git, diagnosis) {
|
|
104
|
+
_lightReconcileCache = { projectRoot, batchId, phase, git, diagnosis };
|
|
105
|
+
}
|
|
106
|
+
|
|
59
107
|
/**
|
|
60
108
|
* @typedef {object} NormalizedTask
|
|
61
109
|
* @property {string} taskId
|
|
@@ -975,8 +1023,10 @@ export function deriveDiagnosis(signals) {
|
|
|
975
1023
|
* @param {object|null} [ctx.batchState]
|
|
976
1024
|
* @param {string|null} [ctx.batchStatePath]
|
|
977
1025
|
* @param {boolean} [ctx.verbose]
|
|
1026
|
+
* @param {boolean} [ctx.light] Skip git branch scans when batch phase unchanged since last full reconcile.
|
|
1027
|
+
* @param {boolean} [ctx._lightRetry] Internal — full reconcile after light diagnosis transition.
|
|
978
1028
|
*/
|
|
979
|
-
export function reconcileBatch(ctx) {
|
|
1029
|
+
export function reconcileBatch(ctx, _lightRetry = false) {
|
|
980
1030
|
const { projectRoot } = ctx;
|
|
981
1031
|
const loaded = ctx.batchState
|
|
982
1032
|
? {
|
|
@@ -987,6 +1037,7 @@ export function reconcileBatch(ctx) {
|
|
|
987
1037
|
: loadBatchStateFile(projectRoot, ctx.batchStatePath ?? null);
|
|
988
1038
|
|
|
989
1039
|
if (!loaded.path && !loaded.raw) {
|
|
1040
|
+
clearLightReconcileCache();
|
|
990
1041
|
return {
|
|
991
1042
|
diagnosis: null,
|
|
992
1043
|
headline: "No active batch — ready to plan or start",
|
|
@@ -1033,12 +1084,18 @@ export function reconcileBatch(ctx) {
|
|
|
1033
1084
|
|
|
1034
1085
|
const tasksRoot = resolveTasksRoot(projectRoot);
|
|
1035
1086
|
const classifiedTasks = classifyTasks(batch, tasksRoot, projectRoot);
|
|
1036
|
-
const
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1087
|
+
const useLightGit =
|
|
1088
|
+
ctx.light === true &&
|
|
1089
|
+
!_lightRetry &&
|
|
1090
|
+
lightReconcileCacheMatches(projectRoot, batch.batchId, batch.phase);
|
|
1091
|
+
const git = useLightGit
|
|
1092
|
+
? /** @type {ReturnType<typeof inspectGitState>} */ (_lightReconcileCache.git)
|
|
1093
|
+
: inspectGitState({
|
|
1094
|
+
projectRoot,
|
|
1095
|
+
batchId: batch.batchId,
|
|
1096
|
+
baseBranch: batch.baseBranch,
|
|
1097
|
+
orchBranch: batch.orchBranch,
|
|
1098
|
+
});
|
|
1042
1099
|
|
|
1043
1100
|
const hasRunningTasks = classifiedTasks.some((task) => task.classification === "running");
|
|
1044
1101
|
const hasPendingTasks = classifiedTasks.some((task) => task.classification === "pending");
|
|
@@ -1110,7 +1167,9 @@ export function reconcileBatch(ctx) {
|
|
|
1110
1167
|
const pendingTaskCount = computePendingTasks(batch.raw ?? {}).length;
|
|
1111
1168
|
signals.pendingTaskCount = pendingTaskCount;
|
|
1112
1169
|
|
|
1113
|
-
|
|
1170
|
+
const derived = deriveDiagnosis(signals);
|
|
1171
|
+
let { diagnosis, failedTaskId, exitReason } = derived;
|
|
1172
|
+
const launchFailureKind = derived.launchFailureKind;
|
|
1114
1173
|
const stubSucceededTaskId = findStubMarkedSucceededTask(tasksRoot, classifiedTasks);
|
|
1115
1174
|
if (
|
|
1116
1175
|
stubSucceededTaskId &&
|
|
@@ -1191,6 +1250,7 @@ export function reconcileBatch(ctx) {
|
|
|
1191
1250
|
const resolvedMacroPhaseLabel = macroPhaseLabel(macroPhase);
|
|
1192
1251
|
if (ctx.verbose) {
|
|
1193
1252
|
signals.macroPhase = macroPhase;
|
|
1253
|
+
signals.reconcileMode = useLightGit ? "light" : "full";
|
|
1194
1254
|
}
|
|
1195
1255
|
|
|
1196
1256
|
const stalePathCheck = buildStalePathDoctorCheck({
|
|
@@ -1275,6 +1335,22 @@ export function reconcileBatch(ctx) {
|
|
|
1275
1335
|
pendingTasks: pendingTaskCount,
|
|
1276
1336
|
});
|
|
1277
1337
|
|
|
1338
|
+
if (
|
|
1339
|
+
ctx.light === true &&
|
|
1340
|
+
useLightGit &&
|
|
1341
|
+
!_lightRetry &&
|
|
1342
|
+
_lightReconcileCache.diagnosis != null &&
|
|
1343
|
+
_lightReconcileCache.diagnosis !== diagnosis
|
|
1344
|
+
) {
|
|
1345
|
+
return reconcileBatch({ ...ctx, light: false }, true);
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
if (!useLightGit) {
|
|
1349
|
+
updateLightReconcileCache(projectRoot, batch.batchId, batch.phase, git, diagnosis);
|
|
1350
|
+
} else {
|
|
1351
|
+
_lightReconcileCache.diagnosis = diagnosis;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1278
1354
|
return {
|
|
1279
1355
|
...output,
|
|
1280
1356
|
batchId: batch.batchId,
|
package/src/batch/resume.mjs
CHANGED
package/src/batch/retry.mjs
CHANGED
package/src/batch/review.mjs
CHANGED
package/src/batch/salvage.mjs
CHANGED