pi-spine 1.10.1 → 2.1.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-cleanup.mjs +89 -0
- package/bin/spine-doctor.mjs +8 -0
- package/bin/spine.mjs +13 -0
- package/package.json +4 -1
- package/skills/create-spine-tasks/SKILL.md +29 -0
- package/skills/create-spine-tasks/references/contract-template.md +11 -0
- package/skills/create-spine-tasks/references/prompt-template.md +15 -20
- package/skills/spine-autonomous-operator/SKILL.md +19 -3
- package/skills/spine-autonomous-operator/references/agent-shell-batch-policy.md +18 -0
- package/skills/spine-orchestrate-waves/SKILL.md +9 -2
- package/skills/spine-orchestrate-waves/references/outer-loop.md +24 -2
- package/skills/spine-release-operator/SKILL.md +25 -2
- package/skills/spine-release-operator/references/post-integrate-regression-gate.md +96 -0
- package/skills/spine-release-operator/references/release-manifest-template.md +7 -3
- package/src/batch/abort.mjs +10 -14
- package/src/batch/diagnosis-merge-failure.mjs +66 -0
- package/src/batch/diagnosis-parent-exit.mjs +125 -0
- package/src/batch/diagnosis.mjs +26 -73
- package/src/batch/engine-lanes/watch.mjs +4 -2
- package/src/batch/heartbeat-subprocess.mjs +214 -0
- package/src/batch/heartbeat.mjs +38 -63
- package/src/batch/lane-dirty-check.mjs +10 -0
- package/src/batch/lifecycle.mjs +1 -18
- package/src/batch/reconcile.mjs +11 -0
- package/src/batch/review.mjs +20 -0
- package/src/batch/worktree.mjs +130 -1
- package/src/config/preflight/git-batch.mjs +14 -3
- package/src/dashboard/public/dashboard.js +6 -2
- package/src/dashboard/snapshot.mjs +85 -11
- package/src/doctor/duplicate-install.mjs +148 -0
- package/src/doctor/pi-cli-resolution.mjs +222 -0
- package/src/doctor/run-doctor-checks.mjs +4 -0
- package/src/doctor/stale-worktrees.mjs +1 -1
- package/src/tasks/packet/parse-prompt.mjs +29 -0
|
@@ -23,6 +23,7 @@ Invoke explicitly: `/skill:spine-release-operator` or "run a spine release cycle
|
|
|
23
23
|
| Semver scope budgets | [references/release-profiles.md](references/release-profiles.md) |
|
|
24
24
|
| Issue intake queries | [references/issue-intake-checklist.md](references/issue-intake-checklist.md) |
|
|
25
25
|
| Manifest format | [references/release-manifest-template.md](references/release-manifest-template.md) |
|
|
26
|
+
| Post-integrate regression gate | [references/post-integrate-regression-gate.md](references/post-integrate-regression-gate.md) |
|
|
26
27
|
| npm publish mechanics | `docs/release/npm-publish.md` |
|
|
27
28
|
| Upstream bug filing | [references/issue-template.md](references/issue-template.md) |
|
|
28
29
|
|
|
@@ -48,6 +49,9 @@ Invoke explicitly: `/skill:spine-release-operator` or "run a spine release cycle
|
|
|
48
49
|
- **Always** prioritize documentation issues over enhancements
|
|
49
50
|
- **Always** run `spine gate approve` before `spine integrate`
|
|
50
51
|
- **Always** run `npm install` on `main` after successful integrate
|
|
52
|
+
- **Always** run post-integrate `npm run release:check` on `main` after each wave land loop before starting the next wave or pushing — see [post-integrate-regression-gate.md](references/post-integrate-regression-gate.md)
|
|
53
|
+
- **Never** use `| tail` or `| head` alone to judge `release:check` pass/fail — verify exit code (`$?` or `${PIPESTATUS[0]}`)
|
|
54
|
+
- **Never** `git push origin main` during a release until post-integrate `release:check` exits 0 on current `HEAD`
|
|
51
55
|
- **Do not** execute tasks outside the approved manifest scope
|
|
52
56
|
- **Do not** start a second batch while another batch is **running** on this repo
|
|
53
57
|
- **Never** background `spine batch resume --attached` or `resume --attached --force` ([#163](https://github.com/beettlle/pi-spine/issues/163))
|
|
@@ -308,6 +312,21 @@ spine batch complete
|
|
|
308
312
|
|
|
309
313
|
Verify: `git status` clean, `.DONE` count increased.
|
|
310
314
|
|
|
315
|
+
### 4.3a Post-integrate regression gate (blocking)
|
|
316
|
+
|
|
317
|
+
After **every** land loop (including manual merge / conflict resolution), on current `main`:
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
npm run release:check 2>&1 | tee /tmp/pi-spine-post-integrate-wave-${N}.log
|
|
321
|
+
test "${PIPESTATUS[0]}" -eq 0
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Full reference: [post-integrate-regression-gate.md](references/post-integrate-regression-gate.md).
|
|
325
|
+
|
|
326
|
+
**If non-zero:** fix on `main`, commit, re-run gate. Do **not** start wave N+1, push, or proceed to Phase 5 until green.
|
|
327
|
+
|
|
328
|
+
**Do not** judge pass/fail from `tail` output — `tail` exits 0 even when `release:check` failed.
|
|
329
|
+
|
|
311
330
|
### 4.4 Recovery
|
|
312
331
|
|
|
313
332
|
Always: `spine status --diagnose`
|
|
@@ -335,14 +354,17 @@ spine preflight
|
|
|
335
354
|
git status
|
|
336
355
|
```
|
|
337
356
|
|
|
338
|
-
**pi async (preferred):** `MonitorCreate` with `npm run release:check 2>&1 | tee /tmp/pi-spine-release-check.log`, `timeout: 900000`, `onDone` to read log
|
|
357
|
+
**pi async (preferred):** `MonitorCreate` with `npm run release:check 2>&1 | tee /tmp/pi-spine-release-check.log`, `timeout: 900000`, `onDone` to read **full log** and verify exit 0 — not log tail alone.
|
|
339
358
|
|
|
340
359
|
**Foreground fallback:**
|
|
341
360
|
|
|
342
361
|
```bash
|
|
343
|
-
npm run release:check
|
|
362
|
+
npm run release:check 2>&1 | tee /tmp/pi-spine-release-check.log
|
|
363
|
+
test "${PIPESTATUS[0]}" -eq 0 # or: npm run release:check; echo $?
|
|
344
364
|
```
|
|
345
365
|
|
|
366
|
+
**Do not** use `npm run release:check 2>&1 | tail -20` for pass/fail — verify exit code explicitly.
|
|
367
|
+
|
|
346
368
|
### `release:check` gate (HARD STOP — blocking)
|
|
347
369
|
|
|
348
370
|
`npm run release:check` is **not advisory**. It is a **blocking gate** before any publish checklist or Phase 6.
|
|
@@ -461,6 +483,7 @@ check manifest at spine-tasks/_authoring/release-v{TARGET}/manifest.md →
|
|
|
461
483
|
spine status --diagnose (do not collide with running batch) →
|
|
462
484
|
preflight → for each wave: MonitorCreate batch start (or foreground) → onDone diagnose →
|
|
463
485
|
gate approve → integrate → npm install → batch complete →
|
|
486
|
+
post-integrate release:check (exit 0 required; no tail-only verification) →
|
|
464
487
|
MonitorCreate release:check → HARD STOP if non-zero (fix on main, re-run) → only if exit 0: verify ci.yml green on HEAD (gh run list/watch) → HARD STOP if not green → only then: STOP for publish approval.
|
|
465
488
|
resume --attached --force stays foreground. Post final report with composition table.
|
|
466
489
|
```
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Post-integrate regression gate
|
|
2
|
+
|
|
3
|
+
Operator-enforced full-suite check on `main` after each land loop. The spine CLI does **not** run this automatically — agents and humans must run it explicitly.
|
|
4
|
+
|
|
5
|
+
**Related:** manifest regression gate in [release-manifest-template.md](release-manifest-template.md); SP-560 / `detached-start-orphan-timeout.test.mjs` cross-file drift (v2.1.0).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## When required (blocking)
|
|
10
|
+
|
|
11
|
+
Run on current `main` after:
|
|
12
|
+
|
|
13
|
+
1. **Standard land loop** — `spine gate approve` → `spine integrate` → `npm install` → `spine batch complete`
|
|
14
|
+
2. **Manual integrate** — `git merge orch/*`, conflict resolution, `human_base_diverged` recovery, or `spine batch complete --detect-manual-merge`
|
|
15
|
+
3. **Before next wave** — do not start wave N+1 until gate passes on `main`
|
|
16
|
+
4. **Before first `git push origin main`** during a release cycle
|
|
17
|
+
5. **Before `npm version`** — Phase 5 `release:check` (same command; re-run if `main` moved)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Command
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
cd <repo-root>
|
|
25
|
+
npm run release:check 2>&1 | tee /tmp/pi-spine-post-integrate-wave-${WAVE:-main}.log
|
|
26
|
+
test "${PIPESTATUS[0]}" -eq 0
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Equivalent without `tee` (must capture exit code):
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm run release:check
|
|
33
|
+
echo "release:check exit: $?"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**If exit is non-zero:** STOP. Fix on `main`, commit, re-run gate. Do not start the next wave, push, or tag.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Verification discipline
|
|
41
|
+
|
|
42
|
+
| Do | Do not |
|
|
43
|
+
|----|--------|
|
|
44
|
+
| Run full `npm run release:check` | Pipe through `tail` or `head` for pass/fail decisions |
|
|
45
|
+
| Verify exit code explicitly (`$?` or `${PIPESTATUS[0]}`) | Claim "passed" from truncated log tail |
|
|
46
|
+
| Save log path in manifest publish checklist | Assume scoped task `testCommand` covered full CI suite |
|
|
47
|
+
|
|
48
|
+
**Anti-pattern:** `npm run release:check 2>&1 | tail -20` — `tail` exits 0 even when `release:check` failed.
|
|
49
|
+
|
|
50
|
+
**Preferred in bash scripts:**
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
set -o pipefail
|
|
54
|
+
npm run release:check 2>&1 | tee /tmp/pi-spine-release-check.log
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Manual merge checklist
|
|
60
|
+
|
|
61
|
+
When any of these occurred on the current wave:
|
|
62
|
+
|
|
63
|
+
- [ ] `git merge orch/spine-*` into `main` (not only `spine integrate`)
|
|
64
|
+
- [ ] Merge conflict resolution in production or test files
|
|
65
|
+
- [ ] `spine batch complete --detect-manual-merge`
|
|
66
|
+
- [ ] Diagnosis `human_base_diverged` before integrate
|
|
67
|
+
|
|
68
|
+
Then post-integrate regression gate is **mandatory** before next wave or push. Record log path in manifest.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Shared-module behavior changes
|
|
73
|
+
|
|
74
|
+
When production code changes user-visible strings, errors, or diagnosis headlines in modules consumed by multiple tests:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
rg -l 'old phrase|OldErrorClass' tests/ src/
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Every test file that asserts on the old behavior must either:
|
|
81
|
+
|
|
82
|
+
- Appear in the task's scoped `testCommand`, or
|
|
83
|
+
- Be covered by this post-integrate `release:check` on `main` before push
|
|
84
|
+
|
|
85
|
+
**Example (SP-560):** Changing orphan headlines in `src/batch/diagnosis*.mjs` required updating both `diagnosis-parent-exit.test.mjs` and `detached-start-orphan-timeout.test.mjs` — scoped contract on the new test alone was insufficient until full suite ran on `main`.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Skills that reference this doc
|
|
90
|
+
|
|
91
|
+
| Skill | Section |
|
|
92
|
+
|-------|---------|
|
|
93
|
+
| `spine-release-operator` | Phase 4.3a |
|
|
94
|
+
| `spine-autonomous-operator` | Phase 3.3a |
|
|
95
|
+
| `spine-orchestrate-waves` | Per-wave outer loop |
|
|
96
|
+
| `create-spine-tasks` | Shared-module contract rule |
|
|
@@ -51,12 +51,15 @@ spine status --diagnose
|
|
|
51
51
|
spine gate approve && spine integrate && npm install && spine batch complete
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
**Regression gate** (run after each integrate, before next wave):
|
|
54
|
+
**Regression gate** (run after each integrate, before next wave — full reference: [post-integrate-regression-gate.md](../../skills/spine-release-operator/references/post-integrate-regression-gate.md)):
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
|
-
npm run
|
|
57
|
+
npm run release:check 2>&1 | tee /tmp/pi-spine-post-integrate-wave-${WAVE:-main}.log
|
|
58
|
+
test "${PIPESTATUS[0]}" -eq 0
|
|
58
59
|
```
|
|
59
60
|
|
|
61
|
+
Do **not** use `| tail` alone for pass/fail — verify exit code.
|
|
62
|
+
|
|
60
63
|
**Operator gates** (human only — sequence does not auto-approve without explicit flags):
|
|
61
64
|
|
|
62
65
|
1. Approve this manifest (operator sign-off on scope)
|
|
@@ -104,8 +107,9 @@ Filled example: [`docs/release/manifest-v1.10.0-example.md`](../../../docs/relea
|
|
|
104
107
|
## Publish checklist (Phase 5–6)
|
|
105
108
|
|
|
106
109
|
- [ ] All release-scoped tasks `.DONE` on `main`
|
|
110
|
+
- [ ] Post-integrate `release:check` green after **each wave** (log paths recorded)
|
|
107
111
|
- [ ] `spine preflight` green
|
|
108
|
-
- [ ] `npm run release:check` green (typecheck, lint, tests, coverage — CI parity)
|
|
112
|
+
- [ ] `npm run release:check` green on final `HEAD` (typecheck, lint, tests, coverage — CI parity)
|
|
109
113
|
- [ ] `git status` clean
|
|
110
114
|
- [ ] Operator approved publish bump type: patch | minor | major
|
|
111
115
|
- [ ] `npm version <bump>` + `git push && git push --tags`
|
package/src/batch/abort.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { archiveBatchStatePath } from "./lifecycle.mjs";
|
|
|
10
10
|
import { appendJournalEvent, journalPath, readJournalEvents, readJournalTail } from "./journal.mjs";
|
|
11
11
|
import { loadBatchStateFile } from "./reconcile.mjs";
|
|
12
12
|
import { appendBatchHistoryEntry } from "./state.mjs";
|
|
13
|
-
import {
|
|
13
|
+
import { removeLaneWorktrees, maxLaneNumberFromBatchState } from "./worktree.mjs";
|
|
14
14
|
import { terminateLaneWorkers } from "./worker-host.mjs";
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -230,19 +230,15 @@ export function abortBatch(ctx) {
|
|
|
230
230
|
|
|
231
231
|
if (hard) {
|
|
232
232
|
const configResult = loadSpineConfig(projectRoot);
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
} catch {
|
|
243
|
-
// best-effort cleanup
|
|
244
|
-
}
|
|
245
|
-
}
|
|
233
|
+
const config = configResult.config ?? {};
|
|
234
|
+
if (shouldCleanupWorktreesOnHardAbort(config)) {
|
|
235
|
+
const laneCount = maxLaneNumberFromBatchState(snapshot);
|
|
236
|
+
removeLaneWorktrees(projectRoot, batchId, laneCount);
|
|
237
|
+
appendJournalEvent(projectRoot, batchId, "batch.worktrees_cleaned", {
|
|
238
|
+
batchId,
|
|
239
|
+
laneCount,
|
|
240
|
+
reason: "hard_abort",
|
|
241
|
+
});
|
|
246
242
|
}
|
|
247
243
|
}
|
|
248
244
|
|
|
@@ -3,6 +3,72 @@
|
|
|
3
3
|
* Wave merge failure diagnosis helpers (SP-338 / GitHub #29).
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import {
|
|
7
|
+
isGitignoredArtifactPath,
|
|
8
|
+
listGitignoredArtifactRoots,
|
|
9
|
+
} from "./lane-dirty-check.mjs";
|
|
10
|
+
|
|
11
|
+
const GITIGNORED_MERGE_FAILURE_CLASSES = new Set(["merge_failed_gitignored", "GitignoredDirtyWorktree"]);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {object} [ctx]
|
|
15
|
+
* @param {string|null} [ctx.exitReason]
|
|
16
|
+
* @param {string|null} [ctx.failureClass]
|
|
17
|
+
* @param {string|null} [ctx.lastError]
|
|
18
|
+
* @param {object[]} [ctx.journalEvents]
|
|
19
|
+
* @returns {boolean}
|
|
20
|
+
*/
|
|
21
|
+
export function inferMergeGitignoredFailure(ctx = {}) {
|
|
22
|
+
const { exitReason, failureClass, lastError, journalEvents } = ctx;
|
|
23
|
+
if (GITIGNORED_MERGE_FAILURE_CLASSES.has(exitReason ?? "")) return true;
|
|
24
|
+
if (GITIGNORED_MERGE_FAILURE_CLASSES.has(failureClass ?? "")) return true;
|
|
25
|
+
|
|
26
|
+
const haystackParts = [exitReason, failureClass, lastError];
|
|
27
|
+
if (Array.isArray(journalEvents)) {
|
|
28
|
+
for (const event of journalEvents) {
|
|
29
|
+
if (event.type !== "batch.merge_failed" && event.type !== "task.failed") continue;
|
|
30
|
+
const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
|
|
31
|
+
haystackParts.push(
|
|
32
|
+
payload.failureClass,
|
|
33
|
+
payload.classification,
|
|
34
|
+
payload.error,
|
|
35
|
+
payload.output,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const haystack = haystackParts.filter(Boolean).join("\n").toLowerCase();
|
|
40
|
+
return (
|
|
41
|
+
haystack.includes("gitignored dirty files only") ||
|
|
42
|
+
haystack.includes("merge_failed_gitignored") ||
|
|
43
|
+
haystack.includes("gitignoreddirtyworktree") ||
|
|
44
|
+
(haystack.includes("git add") && haystack.includes("ignored"))
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {string|null|undefined} taskBranch
|
|
50
|
+
* @param {string[]|null|undefined} gitignoredPaths
|
|
51
|
+
*/
|
|
52
|
+
export function buildGitignoredMergeRepairCommand(taskBranch, gitignoredPaths) {
|
|
53
|
+
const branchHint = taskBranch ? `git checkout ${taskBranch}` : "git checkout <task-branch>";
|
|
54
|
+
const stetRuntimeCleanRoots = new Set([".review", ".spine/runtime"]);
|
|
55
|
+
if (Array.isArray(gitignoredPaths) && gitignoredPaths.length > 0) {
|
|
56
|
+
const artifactRoots = listGitignoredArtifactRoots(gitignoredPaths);
|
|
57
|
+
const stetRuntimeOnly =
|
|
58
|
+
artifactRoots.length > 0 &&
|
|
59
|
+
artifactRoots.every((root) => stetRuntimeCleanRoots.has(root)) &&
|
|
60
|
+
gitignoredPaths.every((p) => isGitignoredArtifactPath(p));
|
|
61
|
+
if (stetRuntimeOnly) {
|
|
62
|
+
const cleanHint = `git clean -fdX -- ${artifactRoots.join(" ")}`;
|
|
63
|
+
return `${branchHint} && ${cleanHint} && spine batch resume --force`;
|
|
64
|
+
}
|
|
65
|
+
const pathHint = `git rm -r --cached -- ${gitignoredPaths.slice(0, 5).join(" ")}`;
|
|
66
|
+
return `${branchHint} && ${pathHint} && spine batch resume --force`;
|
|
67
|
+
}
|
|
68
|
+
const pathHint = "git rm -r --cached -- <gitignored-paths>";
|
|
69
|
+
return `${branchHint} && ${pathHint} && spine batch resume --force`;
|
|
70
|
+
}
|
|
71
|
+
|
|
6
72
|
/**
|
|
7
73
|
* @param {unknown[]} mergeResults
|
|
8
74
|
* @param {string|null|undefined} lastError
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* Parent-shell exit vs engine crash hints for engine_orphaned diagnosis (SP-560 / #185).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { DETACHED_ENGINE_LOG_REL } from "./detached-spawn.mjs";
|
|
7
|
+
|
|
8
|
+
/** Journal types that indicate an uncaught engine crash (not parent shell exit). */
|
|
9
|
+
const ENGINE_CRASH_JOURNAL_TYPES = new Set(["engine.crash", "engine.uncaught_exception"]);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {object[]} [journalEvents]
|
|
13
|
+
* @returns {boolean}
|
|
14
|
+
*/
|
|
15
|
+
export function journalHasEngineCrash(journalEvents) {
|
|
16
|
+
if (!Array.isArray(journalEvents) || journalEvents.length === 0) return false;
|
|
17
|
+
return journalEvents.some((event) => ENGINE_CRASH_JOURNAL_TYPES.has(event.type));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {object[]} [journalEvents]
|
|
22
|
+
* @returns {boolean}
|
|
23
|
+
*/
|
|
24
|
+
export function journalIndicatesParentExit(journalEvents) {
|
|
25
|
+
if (!Array.isArray(journalEvents) || journalEvents.length === 0) return false;
|
|
26
|
+
return journalEvents.some((event) => {
|
|
27
|
+
if (event.type !== "engine.parent_died") return false;
|
|
28
|
+
const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
|
|
29
|
+
return payload.signal === "parent_exit" || event.signal === "parent_exit";
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {object[]} [journalEvents]
|
|
35
|
+
* @returns {boolean}
|
|
36
|
+
*/
|
|
37
|
+
export function journalHasBatchResumed(journalEvents) {
|
|
38
|
+
if (!Array.isArray(journalEvents) || journalEvents.length === 0) return false;
|
|
39
|
+
return journalEvents.some((event) => event.type === "batch.resumed");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Infer whether engine_orphaned is likely parent shell exit vs engine crash.
|
|
44
|
+
*
|
|
45
|
+
* @param {object} [ctx]
|
|
46
|
+
* @param {object[]} [ctx.journalEvents]
|
|
47
|
+
* @param {boolean} [ctx.staleEnginePid]
|
|
48
|
+
* @returns {{ kind: "parent_exit" | "parent_exit_likely" | "crash" | "unknown", detachedEngineLogRef: string|null }}
|
|
49
|
+
*/
|
|
50
|
+
export function inferEngineOrphanCause(ctx = {}) {
|
|
51
|
+
const { journalEvents, staleEnginePid } = ctx;
|
|
52
|
+
const logRef = staleEnginePid === true ? DETACHED_ENGINE_LOG_REL : null;
|
|
53
|
+
|
|
54
|
+
if (journalHasEngineCrash(journalEvents)) {
|
|
55
|
+
return { kind: "crash", detachedEngineLogRef: logRef };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (journalIndicatesParentExit(journalEvents)) {
|
|
59
|
+
return { kind: "parent_exit", detachedEngineLogRef: logRef };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Detached resume stall (SP-297) — not parent shell exit from attached mode.
|
|
63
|
+
if (journalHasBatchResumed(journalEvents)) {
|
|
64
|
+
return { kind: "unknown", detachedEngineLogRef: logRef };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Attached start orphan without crash journal (#185).
|
|
68
|
+
if (
|
|
69
|
+
Array.isArray(journalEvents) &&
|
|
70
|
+
journalEvents.some((event) => event.type === "batch.started")
|
|
71
|
+
) {
|
|
72
|
+
return { kind: "parent_exit_likely", detachedEngineLogRef: logRef };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return { kind: "unknown", detachedEngineLogRef: logRef };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {string} batchLabel
|
|
80
|
+
* @param {object} ctx
|
|
81
|
+
* @param {string|null} [ctx.failedTaskId]
|
|
82
|
+
* @param {{ kind: string, detachedEngineLogRef?: string|null }} [ctx.engineOrphanCause]
|
|
83
|
+
* @returns {string|null}
|
|
84
|
+
*/
|
|
85
|
+
export function buildEngineOrphanParentExitHeadline(batchLabel, ctx = {}) {
|
|
86
|
+
const cause = ctx.engineOrphanCause;
|
|
87
|
+
if (!cause) return null;
|
|
88
|
+
|
|
89
|
+
const taskHint = ctx.failedTaskId ? ` (task ${ctx.failedTaskId} still running)` : "";
|
|
90
|
+
const logHint = cause.detachedEngineLogRef ? ` — see ${cause.detachedEngineLogRef}` : "";
|
|
91
|
+
|
|
92
|
+
if (cause.kind === "parent_exit") {
|
|
93
|
+
return `${batchLabel} attached engine parent shell exited${taskHint} — use detached resume, not a crash${logHint}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (cause.kind === "parent_exit_likely") {
|
|
97
|
+
return `${batchLabel} engine likely orphaned by parent shell exit${taskHint} — use detached resume (no engine.crash in journal)${logHint}`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (cause.kind === "crash") {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @param {object} ctx
|
|
109
|
+
* @param {string|null} [ctx.failedTaskId]
|
|
110
|
+
* @param {{ kind: string }} [ctx.engineOrphanCause]
|
|
111
|
+
* @returns {string|null}
|
|
112
|
+
*/
|
|
113
|
+
export function buildEngineOrphanParentExitSuggestedCommand(ctx = {}) {
|
|
114
|
+
const cause = ctx.engineOrphanCause;
|
|
115
|
+
if (!cause) return null;
|
|
116
|
+
|
|
117
|
+
if (cause.kind === "parent_exit" || cause.kind === "parent_exit_likely") {
|
|
118
|
+
if (ctx.failedTaskId) {
|
|
119
|
+
return `spine batch retry ${ctx.failedTaskId}`;
|
|
120
|
+
}
|
|
121
|
+
return "spine batch resume --force";
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return null;
|
|
125
|
+
}
|
package/src/batch/diagnosis.mjs
CHANGED
|
@@ -15,11 +15,17 @@ import { buildAlternatives } from "./diagnosis-alternatives.mjs";
|
|
|
15
15
|
export { buildAlternatives } from "./diagnosis-alternatives.mjs";
|
|
16
16
|
import {
|
|
17
17
|
buildMergeFailureHeadline,
|
|
18
|
+
buildGitignoredMergeRepairCommand,
|
|
19
|
+
} from "./diagnosis-merge-failure.mjs";
|
|
20
|
+
export {
|
|
21
|
+
buildMergeFailureHeadline,
|
|
22
|
+
buildGitignoredMergeRepairCommand,
|
|
23
|
+
inferMergeGitignoredFailure,
|
|
24
|
+
summarizeMergeFailures,
|
|
18
25
|
} from "./diagnosis-merge-failure.mjs";
|
|
19
|
-
export { buildMergeFailureHeadline, summarizeMergeFailures } from "./diagnosis-merge-failure.mjs";
|
|
20
26
|
import { buildRunningTailHeadline } from "./diagnosis-tail-state.mjs";
|
|
21
27
|
export { buildRunningTailHeadline, isRunningWithoutActiveWorkers } from "./diagnosis-tail-state.mjs";
|
|
22
|
-
export { findLatestReviewHonorSignal } from "./review.mjs";
|
|
28
|
+
export { buildReviewHonorHeadlineSuffix, findLatestReviewHonorSignal } from "./review.mjs";
|
|
23
29
|
import {
|
|
24
30
|
buildStubFailureHeadline,
|
|
25
31
|
buildStubFailureSuggestedCommand,
|
|
@@ -36,6 +42,16 @@ import {
|
|
|
36
42
|
buildPrimaryFailureHeadline,
|
|
37
43
|
buildPrimaryFailureSuggestedCommand,
|
|
38
44
|
} from "./diagnosis-primary-failure.mjs";
|
|
45
|
+
import {
|
|
46
|
+
buildEngineOrphanParentExitHeadline,
|
|
47
|
+
buildEngineOrphanParentExitSuggestedCommand,
|
|
48
|
+
} from "./diagnosis-parent-exit.mjs";
|
|
49
|
+
export {
|
|
50
|
+
inferEngineOrphanCause,
|
|
51
|
+
journalHasEngineCrash,
|
|
52
|
+
journalIndicatesParentExit,
|
|
53
|
+
} from "./diagnosis-parent-exit.mjs";
|
|
54
|
+
import { buildReviewHonorHeadlineSuffix } from "./review.mjs";
|
|
39
55
|
export { inferLaunchFailureFromWorkerOutputTail, inferLaunchFailureKind } from "./diagnosis-launch-failure.mjs";
|
|
40
56
|
|
|
41
57
|
const INVALID_BARE_RETRY_FORCE = /^spine batch retry --force$/;
|
|
@@ -84,7 +100,6 @@ const NO_PAUSE_DIAGNOSES = new Set([
|
|
|
84
100
|
"engine_orphaned",
|
|
85
101
|
"integrate_isolated_ok",
|
|
86
102
|
]);
|
|
87
|
-
const GITIGNORED_MERGE_FAILURE_CLASSES = new Set(["merge_failed_gitignored", "GitignoredDirtyWorktree"]);
|
|
88
103
|
const REVIEW_SPAWN_FAILURE_EXIT_REASONS = new Set([
|
|
89
104
|
"code_review_spawn_failed",
|
|
90
105
|
"code_review_timeout",
|
|
@@ -92,74 +107,6 @@ const REVIEW_SPAWN_FAILURE_EXIT_REASONS = new Set([
|
|
|
92
107
|
"final_review_timeout",
|
|
93
108
|
]);
|
|
94
109
|
|
|
95
|
-
/**
|
|
96
|
-
* @param {object|null|undefined} reviewHonorSignal
|
|
97
|
-
* @returns {string|null}
|
|
98
|
-
*/
|
|
99
|
-
export function buildReviewHonorHeadlineSuffix(reviewHonorSignal) {
|
|
100
|
-
if (!reviewHonorSignal?.kind) return null;
|
|
101
|
-
const reviewLabel =
|
|
102
|
-
reviewHonorSignal.reviewType === "final" ? "final review" : "code review";
|
|
103
|
-
if (reviewHonorSignal.kind === "review.crash_recovered") {
|
|
104
|
-
return `recovered ${reviewLabel} crash — prior verdict honored from ${reviewHonorSignal.honorSource ?? "artifact"}`;
|
|
105
|
-
}
|
|
106
|
-
if (reviewHonorSignal.kind === "review.skipped_fresh_artifact") {
|
|
107
|
-
return `skipped redundant ${reviewLabel} — fresh artifact honored`;
|
|
108
|
-
}
|
|
109
|
-
if (reviewHonorSignal.kind === "review.resumed") {
|
|
110
|
-
return `${reviewLabel} resumed after operator retry`;
|
|
111
|
-
}
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @param {object} [ctx]
|
|
117
|
-
* @param {string|null} [ctx.exitReason]
|
|
118
|
-
* @param {string|null} [ctx.failureClass]
|
|
119
|
-
* @param {string|null} [ctx.lastError]
|
|
120
|
-
* @param {object[]} [ctx.journalEvents]
|
|
121
|
-
* @returns {boolean}
|
|
122
|
-
*/
|
|
123
|
-
export function inferMergeGitignoredFailure(ctx = {}) {
|
|
124
|
-
const { exitReason, failureClass, lastError, journalEvents } = ctx;
|
|
125
|
-
if (GITIGNORED_MERGE_FAILURE_CLASSES.has(exitReason ?? "")) return true;
|
|
126
|
-
if (GITIGNORED_MERGE_FAILURE_CLASSES.has(failureClass ?? "")) return true;
|
|
127
|
-
|
|
128
|
-
const haystackParts = [exitReason, failureClass, lastError];
|
|
129
|
-
if (Array.isArray(journalEvents)) {
|
|
130
|
-
for (const event of journalEvents) {
|
|
131
|
-
if (event.type !== "batch.merge_failed" && event.type !== "task.failed") continue;
|
|
132
|
-
const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
|
|
133
|
-
haystackParts.push(
|
|
134
|
-
payload.failureClass,
|
|
135
|
-
payload.classification,
|
|
136
|
-
payload.error,
|
|
137
|
-
payload.output,
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
const haystack = haystackParts.filter(Boolean).join("\n").toLowerCase();
|
|
142
|
-
return (
|
|
143
|
-
haystack.includes("gitignored dirty files only") ||
|
|
144
|
-
haystack.includes("merge_failed_gitignored") ||
|
|
145
|
-
haystack.includes("gitignoreddirtyworktree") ||
|
|
146
|
-
(haystack.includes("git add") && haystack.includes("ignored"))
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* @param {string|null|undefined} taskBranch
|
|
152
|
-
* @param {string[]|null|undefined} gitignoredPaths
|
|
153
|
-
*/
|
|
154
|
-
export function buildGitignoredMergeRepairCommand(taskBranch, gitignoredPaths) {
|
|
155
|
-
const branchHint = taskBranch ? `git checkout ${taskBranch}` : "git checkout <task-branch>";
|
|
156
|
-
const pathHint =
|
|
157
|
-
Array.isArray(gitignoredPaths) && gitignoredPaths.length > 0
|
|
158
|
-
? `git rm -r --cached -- ${gitignoredPaths.slice(0, 5).join(" ")}`
|
|
159
|
-
: "git rm -r --cached -- <gitignored-paths>";
|
|
160
|
-
return `${branchHint} && ${pathHint} && spine batch resume --force`;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
110
|
/**
|
|
164
111
|
* @param {string} diagnosis
|
|
165
112
|
* @param {object} [ctx]
|
|
@@ -249,10 +196,13 @@ export function buildSuggestedCommand(diagnosis, ctx = {}) {
|
|
|
249
196
|
: "spine batch abort";
|
|
250
197
|
case "worker_done_missing":
|
|
251
198
|
return buildWorkerDoneMissingSuggestedCommand(ctx);
|
|
252
|
-
case "engine_orphaned":
|
|
199
|
+
case "engine_orphaned": {
|
|
200
|
+
const parentExitCommand = buildEngineOrphanParentExitSuggestedCommand(ctx);
|
|
201
|
+
if (parentExitCommand) return parentExitCommand;
|
|
253
202
|
return ctx.failedTaskId
|
|
254
203
|
? `spine batch retry ${ctx.failedTaskId}`
|
|
255
204
|
: "spine batch resume --attached";
|
|
205
|
+
}
|
|
256
206
|
case "needs_merge":
|
|
257
207
|
return "/spine-resume --force";
|
|
258
208
|
case "needs_integrate":
|
|
@@ -391,10 +341,13 @@ export function buildHeadline(diagnosis, ctx = {}) {
|
|
|
391
341
|
: `${batchLabel} lane worker orphaned — retry or abort`;
|
|
392
342
|
case "worker_done_missing":
|
|
393
343
|
return buildWorkerDoneMissingHeadline(batchLabel, ctx);
|
|
394
|
-
case "engine_orphaned":
|
|
344
|
+
case "engine_orphaned": {
|
|
345
|
+
const parentExitHeadline = buildEngineOrphanParentExitHeadline(batchLabel, ctx);
|
|
346
|
+
if (parentExitHeadline) return parentExitHeadline;
|
|
395
347
|
return ctx.failedTaskId
|
|
396
348
|
? `${batchLabel} engine died mid-run (task ${ctx.failedTaskId} still running) — retry or abort`
|
|
397
349
|
: `${batchLabel} batch engine died while running — retry or abort`;
|
|
350
|
+
}
|
|
398
351
|
case "needs_merge":
|
|
399
352
|
if (ctx.mergeGitignoredFailure) {
|
|
400
353
|
return `${batchLabel} merge blocked by gitignored paths committed on a lane branch`;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Lane worker watch helpers — stall anchor slides on worker_alive while running (SP-341 / #32).
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
/** @typedef {"launching" | "pi" | "verify" | "unknown"} WorkerPhase */
|
|
5
|
+
/** @typedef {"launching" | "pi" | "verify" | "subprocess" | "unknown"} WorkerPhase */
|
|
6
6
|
/** @typedef {"worker_alive" | "checkpoint" | "file_scope_activity"} HeartbeatKind */
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
* @param {HeartbeatKind} params.heartbeatKind
|
|
12
12
|
*/
|
|
13
13
|
export function shouldSlideStallAnchorOnHeartbeat({ workerPhase, heartbeatKind }) {
|
|
14
|
-
return
|
|
14
|
+
return (
|
|
15
|
+
(workerPhase === "pi" || workerPhase === "subprocess") && heartbeatKind === "worker_alive"
|
|
16
|
+
);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
/**
|