pi-spine 1.6.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/bin/spine-wait.mjs +12 -0
- package/package.json +3 -3
- 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 +80 -14
- 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 +19 -7
- package/src/batch/contract-prelanded.mjs +1 -0
- package/src/batch/contract-task-start.mjs +13 -7
- package/src/batch/contract-verify.mjs +26 -1
- package/src/batch/detached-spawn.mjs +78 -0
- package/src/batch/detached-start.mjs +26 -71
- 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 +26 -2
- 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 +31 -250
- package/src/batch/gate-evidence-collect.mjs +173 -0
- package/src/batch/gate-evidence-read.mjs +146 -0
- package/src/batch/gate.mjs +29 -38
- 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 +103 -0
- package/src/batch/lifecycle.mjs +7 -5
- 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 +2 -1
- package/src/batch/postmortem.mjs +2 -2
- package/src/batch/readers/spine-state.mjs +1 -0
- package/src/batch/readers/taskplane-state.mjs +1 -0
- package/src/batch/reconcile.mjs +85 -9
- package/src/batch/resume-common.mjs +8 -1
- package/src/batch/resume-engine.mjs +1 -0
- package/src/batch/resume-multi-lanes.mjs +1 -0
- package/src/batch/resume-multi-validate.mjs +26 -101
- package/src/batch/resume-multi.mjs +1 -0
- package/src/batch/resume-validation.mjs +121 -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 +16 -4
- package/src/batch/state.mjs +1 -0
- package/src/batch/supervisor-spawn.mjs +380 -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/cli/spine-wait.mjs +114 -0
- package/src/cli/wait.mjs +7 -43
- 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/defaults.mjs +4 -1
- 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 +24 -0
- package/src/config/spine-config-load.mjs +6 -0
- package/src/config/spine-config-schema.mjs +122 -0
- package/src/config/spine-init-constants.mjs +20 -1
- 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 +222 -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 +2 -0
- package/src/doctor/coexistence.mjs +1 -0
- package/src/doctor/run-doctor-checks.mjs +15 -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/supervisor.mjs +66 -0
- package/src/doctor/task-packet-size.mjs +3 -10
- package/src/doctor/worktree-health.mjs +2 -1
- 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/templates/agents/supervisor.md +27 -18
- package/templates/spine-config.json +16 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Collect GitHub issues and spine backlog for release intake.
|
|
3
|
+
# Usage: from repo root: skills/spine-release-operator/scripts/collect-release-intake.sh [TARGET_VERSION]
|
|
4
|
+
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
REPO_ROOT="$(cd "$(dirname "$0")/../../.." && pwd)"
|
|
8
|
+
cd "$REPO_ROOT"
|
|
9
|
+
|
|
10
|
+
TARGET="${1:-unknown}"
|
|
11
|
+
|
|
12
|
+
echo "=== pi-spine release intake snapshot ==="
|
|
13
|
+
echo "Target: v${TARGET}"
|
|
14
|
+
echo "Date: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
15
|
+
echo "Repo: $REPO_ROOT"
|
|
16
|
+
echo "Branch: $(git branch --show-current 2>/dev/null || echo unknown)"
|
|
17
|
+
echo "Package version: $(node -p "require('./package.json').version" 2>/dev/null || echo unknown)"
|
|
18
|
+
echo ""
|
|
19
|
+
|
|
20
|
+
echo "=== GitNexus status ==="
|
|
21
|
+
if command -v gitnexus >/dev/null 2>&1; then
|
|
22
|
+
gitnexus status 2>/dev/null || echo "(gitnexus status failed)"
|
|
23
|
+
else
|
|
24
|
+
echo "(gitnexus not installed)"
|
|
25
|
+
fi
|
|
26
|
+
echo ""
|
|
27
|
+
|
|
28
|
+
echo "=== GitHub open issues (beettlle/pi-spine) ==="
|
|
29
|
+
if command -v gh >/dev/null 2>&1; then
|
|
30
|
+
gh issue list --repo beettlle/pi-spine --state open --limit 100 \
|
|
31
|
+
--json number,title,labels,url,createdAt \
|
|
32
|
+
2>/dev/null || echo "(gh failed — check auth)"
|
|
33
|
+
else
|
|
34
|
+
echo "(gh not installed)"
|
|
35
|
+
fi
|
|
36
|
+
echo ""
|
|
37
|
+
|
|
38
|
+
echo "=== Documentation issues ==="
|
|
39
|
+
if command -v gh >/dev/null 2>&1; then
|
|
40
|
+
gh issue list --repo beettlle/pi-spine --state open --label documentation \
|
|
41
|
+
--json number,title,labels \
|
|
42
|
+
2>/dev/null || true
|
|
43
|
+
fi
|
|
44
|
+
echo ""
|
|
45
|
+
|
|
46
|
+
echo "=== Bug issues ==="
|
|
47
|
+
if command -v gh >/dev/null 2>&1; then
|
|
48
|
+
gh issue list --repo beettlle/pi-spine --state open --label bug \
|
|
49
|
+
--json number,title,labels \
|
|
50
|
+
2>/dev/null || true
|
|
51
|
+
fi
|
|
52
|
+
echo ""
|
|
53
|
+
|
|
54
|
+
echo "=== Spine plan pending ==="
|
|
55
|
+
if command -v spine >/dev/null 2>&1; then
|
|
56
|
+
spine plan pending 2>/dev/null || true
|
|
57
|
+
else
|
|
58
|
+
echo "(spine not installed)"
|
|
59
|
+
fi
|
|
60
|
+
echo ""
|
|
61
|
+
|
|
62
|
+
echo "=== Issue → task mapping (Closes:/Partial:) ==="
|
|
63
|
+
if command -v rg >/dev/null 2>&1; then
|
|
64
|
+
rg 'Closes:|Partial:' spine-tasks/*/PROMPT.md 2>/dev/null || echo "(no mappings found)"
|
|
65
|
+
else
|
|
66
|
+
grep -r 'Closes:\|Partial:' spine-tasks/*/PROMPT.md 2>/dev/null || echo "(no mappings found)"
|
|
67
|
+
fi
|
|
68
|
+
echo ""
|
|
69
|
+
|
|
70
|
+
echo "=== Next Task ID (from CONTEXT.md) ==="
|
|
71
|
+
grep -E '^\*\*Next Task ID:\*\*' spine-tasks/CONTEXT.md 2>/dev/null || echo "(CONTEXT.md not found)"
|
package/src/batch/abort.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/**
|
|
2
3
|
* Attached batch foreground runner — milestones, integrate handoff, CLI exit (SP-343, GitHub #34).
|
|
3
4
|
* Post-merge limbo resume fast path (SP-348, GitHub #39).
|
|
@@ -15,6 +16,13 @@ import { reconcileBatch } from "./reconcile.mjs";
|
|
|
15
16
|
import { readJournalEventsCached } from "./journal.mjs";
|
|
16
17
|
import { enforceOperatorPauseOnDisk } from "./pause.mjs";
|
|
17
18
|
import { loadSpineBatchState, readBatchEnginePid, saveSpineBatchState } from "./state.mjs";
|
|
19
|
+
import { loadSpineConfig } from "../config/spine-config-load.mjs";
|
|
20
|
+
import { resolveAttachedMilestonePollMs } from "../config/spine-config-schema.mjs";
|
|
21
|
+
|
|
22
|
+
export { DEFAULT_ATTACHED_MILESTONE_POLL_MS } from "../config/spine-config-schema.mjs";
|
|
23
|
+
|
|
24
|
+
/** @type {boolean} */
|
|
25
|
+
let attachedExitHandlersInstalled = false;
|
|
18
26
|
|
|
19
27
|
/** Journal types surfaced on attached stdout during the land loop. */
|
|
20
28
|
export const ATTACHED_LAND_LOOP_MILESTONE_TYPES = new Set([
|
|
@@ -33,11 +41,6 @@ export const ATTACHED_LAND_LOOP_MILESTONE_TYPES = new Set([
|
|
|
33
41
|
"batch.completed",
|
|
34
42
|
]);
|
|
35
43
|
|
|
36
|
-
const ATTACHED_MILESTONE_POLL_MS = 200;
|
|
37
|
-
|
|
38
|
-
/** @type {boolean} */
|
|
39
|
-
let attachedExitHandlersInstalled = false;
|
|
40
|
-
|
|
41
44
|
/**
|
|
42
45
|
* Install journal-aware SIGTERM/SIGINT handlers before attached engine exit (SP-378).
|
|
43
46
|
*
|
|
@@ -101,9 +104,18 @@ export function formatAttachedMilestoneLine(event) {
|
|
|
101
104
|
* @param {object} params
|
|
102
105
|
* @param {string} params.projectRoot
|
|
103
106
|
* @param {(line: string) => void} [params.write]
|
|
107
|
+
* @param {number} [params.pollIntervalMs]
|
|
104
108
|
* @returns {Promise<{ stop: () => Promise<void> }>}
|
|
105
109
|
*/
|
|
106
|
-
export async function startAttachedMilestoneReporter({
|
|
110
|
+
export async function startAttachedMilestoneReporter({
|
|
111
|
+
projectRoot,
|
|
112
|
+
write = (line) => process.stdout.write(line),
|
|
113
|
+
pollIntervalMs,
|
|
114
|
+
}) {
|
|
115
|
+
const configResult = loadSpineConfig(projectRoot);
|
|
116
|
+
const resolvedPollMs =
|
|
117
|
+
pollIntervalMs ??
|
|
118
|
+
resolveAttachedMilestonePollMs({ config: configResult.config ?? {} });
|
|
107
119
|
/** @type {Set<string>} */
|
|
108
120
|
const printed = new Set();
|
|
109
121
|
let batchId = null;
|
|
@@ -126,7 +138,7 @@ export async function startAttachedMilestoneReporter({ projectRoot, write = (lin
|
|
|
126
138
|
write(formatAttachedMilestoneLine(event));
|
|
127
139
|
}
|
|
128
140
|
}
|
|
129
|
-
await sleep(
|
|
141
|
+
await sleep(resolvedPollMs);
|
|
130
142
|
}
|
|
131
143
|
};
|
|
132
144
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/**
|
|
2
3
|
* Resolve lane branch HEAD at task.started for scoped contract verify (issue #62, SP-415).
|
|
3
4
|
*/
|
|
@@ -98,9 +99,10 @@ function batchMatches(event, batchId) {
|
|
|
98
99
|
* @param {object[]} journal
|
|
99
100
|
* @param {string|null|undefined} laneId
|
|
100
101
|
* @param {number} beforeIndex
|
|
102
|
+
* @param {string|null|undefined} [excludeTaskId] Skip lane.committed for this task (SP-478 / issue #105).
|
|
101
103
|
* @returns {string|null}
|
|
102
104
|
*/
|
|
103
|
-
function resolvePriorLaneCommit(journal, laneId, beforeIndex) {
|
|
105
|
+
function resolvePriorLaneCommit(journal, laneId, beforeIndex, excludeTaskId) {
|
|
104
106
|
for (let index = beforeIndex - 1; index >= 0; index -= 1) {
|
|
105
107
|
const event = journal[index];
|
|
106
108
|
if (String(event?.type ?? "") !== "lane.committed") {
|
|
@@ -109,6 +111,9 @@ function resolvePriorLaneCommit(journal, laneId, beforeIndex) {
|
|
|
109
111
|
if (!lanesMatch(readEventLaneId(event), laneId)) {
|
|
110
112
|
continue;
|
|
111
113
|
}
|
|
114
|
+
if (excludeTaskId && readEventTaskId(event) === excludeTaskId) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
112
117
|
const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
|
|
113
118
|
const sha = payload.commitSha ?? payload.mergeCommit;
|
|
114
119
|
if (typeof sha === "string" && sha.trim()) {
|
|
@@ -138,14 +143,15 @@ function resolveHeadAtTimestamp(worktreePath, timestampIso) {
|
|
|
138
143
|
}
|
|
139
144
|
|
|
140
145
|
/**
|
|
146
|
+
* First task.started for a task — stable baseline across retry/resume (SP-478 / issue #105).
|
|
147
|
+
*
|
|
141
148
|
* @param {object[]} journal
|
|
142
149
|
* @param {string} taskId
|
|
143
150
|
* @param {string|null|undefined} laneId
|
|
144
151
|
* @param {string|null|undefined} batchId
|
|
145
152
|
* @returns {{ event: object, index: number } | null}
|
|
146
153
|
*/
|
|
147
|
-
function
|
|
148
|
-
let match = null;
|
|
154
|
+
function findFirstTaskStarted(journal, taskId, laneId, batchId) {
|
|
149
155
|
for (let index = 0; index < journal.length; index += 1) {
|
|
150
156
|
const event = journal[index];
|
|
151
157
|
if (String(event?.type ?? "") !== "task.started") {
|
|
@@ -160,9 +166,9 @@ function findLastTaskStarted(journal, taskId, laneId, batchId) {
|
|
|
160
166
|
if (!batchMatches(event, batchId)) {
|
|
161
167
|
continue;
|
|
162
168
|
}
|
|
163
|
-
|
|
169
|
+
return { event, index };
|
|
164
170
|
}
|
|
165
|
-
return
|
|
171
|
+
return null;
|
|
166
172
|
}
|
|
167
173
|
|
|
168
174
|
/**
|
|
@@ -177,7 +183,7 @@ export function resolveTaskStartCommit({ journal, taskId, laneId, batchId, workt
|
|
|
177
183
|
return null;
|
|
178
184
|
}
|
|
179
185
|
|
|
180
|
-
const started =
|
|
186
|
+
const started = findFirstTaskStarted(journal, taskId, laneId, batchId);
|
|
181
187
|
if (!started) {
|
|
182
188
|
return null;
|
|
183
189
|
}
|
|
@@ -188,7 +194,7 @@ export function resolveTaskStartCommit({ journal, taskId, laneId, batchId, workt
|
|
|
188
194
|
}
|
|
189
195
|
|
|
190
196
|
const eventLaneId = readEventLaneId(started.event);
|
|
191
|
-
const priorLaneCommit = resolvePriorLaneCommit(journal, eventLaneId, started.index);
|
|
197
|
+
const priorLaneCommit = resolvePriorLaneCommit(journal, eventLaneId, started.index, taskId);
|
|
192
198
|
if (priorLaneCommit) {
|
|
193
199
|
return priorLaneCommit;
|
|
194
200
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/**
|
|
2
3
|
* Machine contract verification in lane worktree (handoff §4.5, SP-154/SP-155).
|
|
3
4
|
*/
|
|
@@ -15,6 +16,10 @@ import {
|
|
|
15
16
|
isStubPrelandedFileScopeSatisfied,
|
|
16
17
|
} from "./contract-prelanded.mjs";
|
|
17
18
|
import { appendJournalEvent } from "./journal.mjs";
|
|
19
|
+
import {
|
|
20
|
+
sanitizeFlutterBuildBeforeAnalyze,
|
|
21
|
+
shouldCleanFlutterBuildBeforeAnalyze,
|
|
22
|
+
} from "./lane-dirty-check.mjs";
|
|
18
23
|
|
|
19
24
|
export { resolvePromptRelPath, isFileScopePatternPrelanded, hasSpineTaskDeliveryChanges } from "./contract-prelanded.mjs";
|
|
20
25
|
|
|
@@ -461,13 +466,31 @@ function findArtifactMatch(worktreePath, artifactPattern) {
|
|
|
461
466
|
return { ok: false };
|
|
462
467
|
}
|
|
463
468
|
|
|
469
|
+
/**
|
|
470
|
+
* Prepare lane worktree before contract testCommand (Flutter analyzer hygiene #78).
|
|
471
|
+
*
|
|
472
|
+
* @param {string} worktreePath
|
|
473
|
+
* @param {ReturnType<import("../tasks/packet/parse-prompt.mjs").parseContract>} parsedContract
|
|
474
|
+
* @param {object} [config]
|
|
475
|
+
* @returns {{ hygieneApplied: boolean, cleaned?: boolean, buildDir?: string, reason?: string }}
|
|
476
|
+
*/
|
|
477
|
+
export function prepareContractVerifyEnvironment(worktreePath, parsedContract, config = {}) {
|
|
478
|
+
const testCommand = parsedContract?.testCommand;
|
|
479
|
+
if (!testCommand || !shouldCleanFlutterBuildBeforeAnalyze(testCommand, config)) {
|
|
480
|
+
return { hygieneApplied: false };
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
const result = sanitizeFlutterBuildBeforeAnalyze(worktreePath);
|
|
484
|
+
return { hygieneApplied: true, ...result };
|
|
485
|
+
}
|
|
486
|
+
|
|
464
487
|
/**
|
|
465
488
|
* @param {string} worktreePath
|
|
466
489
|
* @param {ReturnType<import("../tasks/packet/parse-prompt.mjs").parseContract>} parsedContract
|
|
467
490
|
* @param {object} [config]
|
|
468
491
|
* @param {string} [config.baseBranch]
|
|
469
492
|
* @param {string} [config.sinceCommit] When set, scope file-scope checks to `sinceCommit..HEAD` (serialized lanes).
|
|
470
|
-
* @param {string} [config.taskStartCommit] Alias for `sinceCommit` (SP-415 journal resolution).
|
|
493
|
+
* @param {string} [config.taskStartCommit] Alias for `sinceCommit` (SP-415 journal resolution; anchor stable across retry/resume per SP-478).
|
|
471
494
|
* @param {string} [config.projectRoot] Repo root for journal events (optional).
|
|
472
495
|
* @param {string} [config.batchId] Batch ID for journal events (optional).
|
|
473
496
|
* @param {string} [config.taskId] Task ID for journal events (optional).
|
|
@@ -481,6 +504,8 @@ export function verifyContract(worktreePath, parsedContract, config = {}) {
|
|
|
481
504
|
const sinceCommit = config?.sinceCommit ?? config?.taskStartCommit ?? undefined;
|
|
482
505
|
const changedFiles = listChangedFiles(worktreePath, baseBranch, sinceCommit);
|
|
483
506
|
|
|
507
|
+
prepareContractVerifyEnvironment(worktreePath, parsedContract, config);
|
|
508
|
+
|
|
484
509
|
let testCommandOutput = "";
|
|
485
510
|
let testCommandOk = true;
|
|
486
511
|
let retriedCount = 0;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detached batch engine spawn argv builders — leaf module (SP-469 / #83-C).
|
|
3
|
+
* No imports from detached-start, reconcile, or post-merge-limbo.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { spawn } from "node:child_process";
|
|
9
|
+
|
|
10
|
+
export const DETACHED_ENGINE_LOG_REL = path.join(".spine", "runtime", "detached-engine.log");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} projectRoot
|
|
14
|
+
*/
|
|
15
|
+
export function detachedEngineLogPath(projectRoot) {
|
|
16
|
+
return path.join(projectRoot, DETACHED_ENGINE_LOG_REL);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @param {object} params
|
|
21
|
+
* @param {string} params.scope
|
|
22
|
+
* @param {boolean} [params.skipPreflight]
|
|
23
|
+
* @param {boolean} [params.forceSuperseded]
|
|
24
|
+
* @param {number|null} [params.waveFilter]
|
|
25
|
+
*/
|
|
26
|
+
export function buildAttachedBatchStartArgv({
|
|
27
|
+
scope,
|
|
28
|
+
skipPreflight = false,
|
|
29
|
+
forceSuperseded = false,
|
|
30
|
+
waveFilter = null,
|
|
31
|
+
}) {
|
|
32
|
+
const tokens = String(scope ?? "")
|
|
33
|
+
.trim()
|
|
34
|
+
.split(/\s+/)
|
|
35
|
+
.filter(Boolean);
|
|
36
|
+
const args = ["batch", "start", ...tokens, "--attached"];
|
|
37
|
+
if (skipPreflight) args.push("--skip-preflight");
|
|
38
|
+
if (forceSuperseded) args.push("--force-superseded");
|
|
39
|
+
if (waveFilter != null) args.push("--wave", String(waveFilter));
|
|
40
|
+
return args;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {object} params
|
|
45
|
+
* @param {boolean} [params.force]
|
|
46
|
+
*/
|
|
47
|
+
export function buildAttachedBatchResumeArgv({ force = false }) {
|
|
48
|
+
const args = ["batch", "resume", "--attached"];
|
|
49
|
+
if (force) args.push("--force");
|
|
50
|
+
return args;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {object} params
|
|
55
|
+
* @param {string} params.projectRoot
|
|
56
|
+
* @param {string} params.spineBin
|
|
57
|
+
* @param {string[]} params.argv
|
|
58
|
+
*/
|
|
59
|
+
export function spawnDetachedBatchEngine({ projectRoot, spineBin, argv }) {
|
|
60
|
+
const logPath = detachedEngineLogPath(projectRoot);
|
|
61
|
+
fs.mkdirSync(path.dirname(logPath), { recursive: true });
|
|
62
|
+
const logFd = fs.openSync(logPath, "a");
|
|
63
|
+
fs.writeFileSync(
|
|
64
|
+
logFd,
|
|
65
|
+
`\n--- detached batch engine ${new Date().toISOString()} argv=${argv.join(" ")} ---\n`,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const child = spawn(process.execPath, [spineBin, ...argv], {
|
|
69
|
+
cwd: projectRoot,
|
|
70
|
+
detached: true,
|
|
71
|
+
stdio: ["ignore", logFd, logFd],
|
|
72
|
+
env: process.env,
|
|
73
|
+
});
|
|
74
|
+
child.unref();
|
|
75
|
+
fs.closeSync(logFd);
|
|
76
|
+
|
|
77
|
+
return { enginePid: child.pid ?? null, logPath: DETACHED_ENGINE_LOG_REL };
|
|
78
|
+
}
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/**
|
|
2
3
|
* Detached batch engine spawn — default for `spine batch start` and `spine batch resume`.
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
6
|
import fs from "node:fs";
|
|
6
7
|
import path from "node:path";
|
|
7
|
-
import { spawn } from "node:child_process";
|
|
8
8
|
import { loadSpineConfig } from "../config/spine-config-load.mjs";
|
|
9
|
+
import {
|
|
10
|
+
buildAttachedBatchResumeArgv,
|
|
11
|
+
buildAttachedBatchStartArgv,
|
|
12
|
+
DETACHED_ENGINE_LOG_REL,
|
|
13
|
+
detachedEngineLogPath,
|
|
14
|
+
spawnDetachedBatchEngine,
|
|
15
|
+
} from "./detached-spawn.mjs";
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
buildAttachedBatchResumeArgv,
|
|
19
|
+
buildAttachedBatchStartArgv,
|
|
20
|
+
DETACHED_ENGINE_LOG_REL,
|
|
21
|
+
detachedEngineLogPath,
|
|
22
|
+
spawnDetachedBatchEngine,
|
|
23
|
+
} from "./detached-spawn.mjs";
|
|
24
|
+
import { maybeSpawnSupervisorOnDetachedStart } from "./supervisor-spawn.mjs";
|
|
9
25
|
import { runBatchPreflight } from "../config/spine-preflight-lib.mjs";
|
|
10
26
|
import { loadGateRecord } from "./gate.mjs";
|
|
11
27
|
import { reconcileBatch } from "./reconcile.mjs";
|
|
@@ -22,8 +38,6 @@ import {
|
|
|
22
38
|
TERMINAL_BATCH_PHASES,
|
|
23
39
|
} from "./state.mjs";
|
|
24
40
|
|
|
25
|
-
export const DETACHED_ENGINE_LOG_REL = path.join(".spine", "runtime", "detached-engine.log");
|
|
26
|
-
|
|
27
41
|
/** Diagnoses that benefit from blocking until resume engine reaches terminal phase. */
|
|
28
42
|
const RESUME_WAIT_TERMINAL_DIAGNOSES = new Set([
|
|
29
43
|
"engine_orphaned",
|
|
@@ -308,74 +322,6 @@ function evaluateDetachedResumeWait(raw, taskId, updatedAtBefore) {
|
|
|
308
322
|
return null;
|
|
309
323
|
}
|
|
310
324
|
|
|
311
|
-
/**
|
|
312
|
-
* @param {string} projectRoot
|
|
313
|
-
*/
|
|
314
|
-
export function detachedEngineLogPath(projectRoot) {
|
|
315
|
-
return path.join(projectRoot, DETACHED_ENGINE_LOG_REL);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* @param {object} params
|
|
320
|
-
* @param {string} params.scope
|
|
321
|
-
* @param {boolean} [params.skipPreflight]
|
|
322
|
-
* @param {boolean} [params.forceSuperseded]
|
|
323
|
-
* @param {number|null} [params.waveFilter]
|
|
324
|
-
*/
|
|
325
|
-
export function buildAttachedBatchStartArgv({
|
|
326
|
-
scope,
|
|
327
|
-
skipPreflight = false,
|
|
328
|
-
forceSuperseded = false,
|
|
329
|
-
waveFilter = null,
|
|
330
|
-
}) {
|
|
331
|
-
const tokens = String(scope ?? "")
|
|
332
|
-
.trim()
|
|
333
|
-
.split(/\s+/)
|
|
334
|
-
.filter(Boolean);
|
|
335
|
-
const args = ["batch", "start", ...tokens, "--attached"];
|
|
336
|
-
if (skipPreflight) args.push("--skip-preflight");
|
|
337
|
-
if (forceSuperseded) args.push("--force-superseded");
|
|
338
|
-
if (waveFilter != null) args.push("--wave", String(waveFilter));
|
|
339
|
-
return args;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* @param {object} params
|
|
344
|
-
* @param {boolean} [params.force]
|
|
345
|
-
*/
|
|
346
|
-
export function buildAttachedBatchResumeArgv({ force = false }) {
|
|
347
|
-
const args = ["batch", "resume", "--attached"];
|
|
348
|
-
if (force) args.push("--force");
|
|
349
|
-
return args;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* @param {object} params
|
|
354
|
-
* @param {string} params.projectRoot
|
|
355
|
-
* @param {string} params.spineBin
|
|
356
|
-
* @param {string[]} params.argv
|
|
357
|
-
*/
|
|
358
|
-
export function spawnDetachedBatchEngine({ projectRoot, spineBin, argv }) {
|
|
359
|
-
const logPath = detachedEngineLogPath(projectRoot);
|
|
360
|
-
fs.mkdirSync(path.dirname(logPath), { recursive: true });
|
|
361
|
-
const logFd = fs.openSync(logPath, "a");
|
|
362
|
-
fs.writeFileSync(
|
|
363
|
-
logFd,
|
|
364
|
-
`\n--- detached batch engine ${new Date().toISOString()} argv=${argv.join(" ")} ---\n`,
|
|
365
|
-
);
|
|
366
|
-
|
|
367
|
-
const child = spawn(process.execPath, [spineBin, ...argv], {
|
|
368
|
-
cwd: projectRoot,
|
|
369
|
-
detached: true,
|
|
370
|
-
stdio: ["ignore", logFd, logFd],
|
|
371
|
-
env: process.env,
|
|
372
|
-
});
|
|
373
|
-
child.unref();
|
|
374
|
-
fs.closeSync(logFd);
|
|
375
|
-
|
|
376
|
-
return { enginePid: child.pid ?? null, logPath: DETACHED_ENGINE_LOG_REL };
|
|
377
|
-
}
|
|
378
|
-
|
|
379
325
|
/**
|
|
380
326
|
* @param {string} projectRoot
|
|
381
327
|
* @param {number|null} enginePid
|
|
@@ -762,6 +708,13 @@ export async function startBatchDetached({
|
|
|
762
708
|
};
|
|
763
709
|
}
|
|
764
710
|
|
|
711
|
+
const configResult = loadSpineConfig(projectRoot);
|
|
712
|
+
const supervisorSpawn = maybeSpawnSupervisorOnDetachedStart({
|
|
713
|
+
projectRoot,
|
|
714
|
+
batchId: wait.batchId,
|
|
715
|
+
config: configResult.config ?? {},
|
|
716
|
+
});
|
|
717
|
+
|
|
765
718
|
const payload = {
|
|
766
719
|
ok: true,
|
|
767
720
|
detached: true,
|
|
@@ -773,6 +726,8 @@ export async function startBatchDetached({
|
|
|
773
726
|
enginePid,
|
|
774
727
|
logPath,
|
|
775
728
|
suggestedCommand: "spine status --diagnose",
|
|
729
|
+
supervisorSpawned: supervisorSpawn.spawned === true,
|
|
730
|
+
supervisorPid: supervisorSpawn.supervisorPid ?? null,
|
|
776
731
|
};
|
|
777
732
|
return {
|
|
778
733
|
ok: true,
|
package/src/batch/diagnosis.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/**
|
|
2
3
|
* FR-BATCH-13 diagnosis taxonomy and operator messaging (§18.3).
|
|
3
4
|
*/
|
|
@@ -36,6 +37,25 @@ import {
|
|
|
36
37
|
} from "./diagnosis-primary-failure.mjs";
|
|
37
38
|
export { inferLaunchFailureFromWorkerOutputTail, inferLaunchFailureKind } from "./diagnosis-launch-failure.mjs";
|
|
38
39
|
|
|
40
|
+
const INVALID_BARE_RETRY_FORCE = /^spine batch retry --force$/;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Retry suggestions must include a task id; journal salvage payloads may be stale.
|
|
44
|
+
*
|
|
45
|
+
* @param {string|null|undefined} command
|
|
46
|
+
* @param {string|null|undefined} taskId
|
|
47
|
+
* @returns {string|null}
|
|
48
|
+
*/
|
|
49
|
+
export function sanitizeRetrySuggestedCommand(command, taskId) {
|
|
50
|
+
if (typeof command !== "string" || command.length === 0) {
|
|
51
|
+
return command ?? null;
|
|
52
|
+
}
|
|
53
|
+
if (INVALID_BARE_RETRY_FORCE.test(command.trim())) {
|
|
54
|
+
return taskId ? `spine batch retry ${taskId}` : "spine status --diagnose";
|
|
55
|
+
}
|
|
56
|
+
return command;
|
|
57
|
+
}
|
|
58
|
+
|
|
39
59
|
export const DIAGNOSIS_TAXONOMY = [
|
|
40
60
|
"running",
|
|
41
61
|
"paused",
|
|
@@ -169,7 +189,9 @@ export function buildSuggestedCommand(diagnosis, ctx = {}) {
|
|
|
169
189
|
if (ctx.launchFailureKind === "worktree_unhealthy") {
|
|
170
190
|
return "spine doctor";
|
|
171
191
|
}
|
|
172
|
-
if (ctx.salvageRetryCommand)
|
|
192
|
+
if (ctx.salvageRetryCommand) {
|
|
193
|
+
return sanitizeRetrySuggestedCommand(ctx.salvageRetryCommand, ctx.failedTaskId);
|
|
194
|
+
}
|
|
173
195
|
if (isFailedPhasePendingOnlyLimbo(ctx)) {
|
|
174
196
|
return buildFailedPhasePendingOnlySuggestedCommand(ctx);
|
|
175
197
|
}
|
|
@@ -197,7 +219,9 @@ export function buildSuggestedCommand(diagnosis, ctx = {}) {
|
|
|
197
219
|
if (ctx.launchFailureKind === "worktree_unhealthy") {
|
|
198
220
|
return "spine doctor";
|
|
199
221
|
}
|
|
200
|
-
if (ctx.salvageRetryCommand)
|
|
222
|
+
if (ctx.salvageRetryCommand) {
|
|
223
|
+
return sanitizeRetrySuggestedCommand(ctx.salvageRetryCommand, ctx.failedTaskId);
|
|
224
|
+
}
|
|
201
225
|
return ctx.failedTaskId
|
|
202
226
|
? `spine batch retry ${ctx.failedTaskId}`
|
|
203
227
|
: "spine batch abort";
|