pi-spine 1.5.0 → 1.7.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 +3 -2
- package/bin/spine-wait.mjs +12 -0
- package/bin/spine.mjs +12 -0
- package/extensions/spine/slash-commands.ts +170 -1
- package/package.json +7 -4
- package/skills/spine-orchestrate-waves/SKILL.md +200 -0
- package/skills/spine-orchestrate-waves/references/outer-loop.md +165 -0
- package/skills/spine-release-operator/SKILL.md +371 -0
- package/skills/spine-release-operator/references/issue-intake-checklist.md +107 -0
- package/skills/spine-release-operator/references/issue-template.md +51 -0
- package/skills/spine-release-operator/references/release-manifest-template.md +76 -0
- package/skills/spine-release-operator/references/release-profiles.md +100 -0
- package/src/batch/attached-runner.mjs +18 -7
- package/src/batch/batch-state-io.mjs +137 -0
- package/src/batch/contract-prelanded.mjs +116 -14
- package/src/batch/contract-task-start.mjs +12 -7
- package/src/batch/contract-verify.mjs +51 -3
- package/src/batch/detached-spawn.mjs +78 -0
- package/src/batch/detached-start.mjs +25 -71
- package/src/batch/diagnosis-alternatives.mjs +8 -0
- package/src/batch/diagnosis.mjs +53 -4
- package/src/batch/engine.mjs +10 -1
- package/src/batch/evidence.mjs +30 -250
- package/src/batch/gate-evidence-collect.mjs +172 -0
- package/src/batch/gate-evidence-read.mjs +145 -0
- package/src/batch/gate.mjs +28 -38
- package/src/batch/integrate-worktree.mjs +65 -15
- package/src/batch/lane-dirty-check.mjs +108 -1
- package/src/batch/lifecycle.mjs +16 -11
- package/src/batch/post-merge-limbo.mjs +1 -1
- package/src/batch/postmortem.mjs +1 -2
- package/src/batch/reconcile.mjs +255 -1
- package/src/batch/resume-common.mjs +7 -1
- package/src/batch/resume-multi-validate.mjs +25 -101
- package/src/batch/resume-validation.mjs +120 -0
- package/src/batch/sequence.mjs +11 -2
- package/src/batch/state.mjs +18 -1
- package/src/batch/supervisor-spawn.mjs +379 -0
- package/src/cli/batch-complete.mjs +16 -0
- package/src/cli/spine-wait.mjs +114 -0
- package/src/cli/sync-base.mjs +354 -0
- package/src/cli/wait.mjs +7 -43
- package/src/config/defaults.mjs +11 -1
- package/src/config/settings-fields.mjs +23 -0
- package/src/config/spine-config-load.mjs +6 -0
- package/src/config/spine-config-schema.mjs +121 -0
- package/src/config/spine-init-constants.mjs +19 -1
- package/src/config/spine-preflight-lib.mjs +146 -2
- package/src/config/worktree-setup-hook.mjs +221 -0
- package/src/doctor/agent-models.mjs +1 -0
- package/src/doctor/agents-model-inherit.mjs +318 -0
- package/src/doctor/run-doctor-checks.mjs +28 -0
- package/src/doctor/supervisor.mjs +66 -0
- package/src/doctor/worktree-health.mjs +1 -1
- package/templates/agents/supervisor.md +27 -18
- package/templates/spine-config.json +20 -1
- package/templates/spine-worktree-setup-flutter.sh +44 -0
|
@@ -9,10 +9,16 @@ import micromatch from "micromatch";
|
|
|
9
9
|
import { parseAggregateLineCoverage } from "../../scripts/coverage-parse.mjs";
|
|
10
10
|
import { resolveContractMode } from "../tasks/packet/validate-contract.mjs";
|
|
11
11
|
import {
|
|
12
|
+
isBaseFileScopeSatisfied,
|
|
13
|
+
isBaseScopeSatisfied,
|
|
12
14
|
isPrelandedFileScopeSatisfied,
|
|
13
15
|
isStubPrelandedFileScopeSatisfied,
|
|
14
16
|
} from "./contract-prelanded.mjs";
|
|
15
17
|
import { appendJournalEvent } from "./journal.mjs";
|
|
18
|
+
import {
|
|
19
|
+
sanitizeFlutterBuildBeforeAnalyze,
|
|
20
|
+
shouldCleanFlutterBuildBeforeAnalyze,
|
|
21
|
+
} from "./lane-dirty-check.mjs";
|
|
16
22
|
|
|
17
23
|
export { resolvePromptRelPath, isFileScopePatternPrelanded, hasSpineTaskDeliveryChanges } from "./contract-prelanded.mjs";
|
|
18
24
|
|
|
@@ -34,6 +40,8 @@ export const CONTRACT_TEST_WORKER_ENV_KEYS = ["SPINE_IS_WORKER"];
|
|
|
34
40
|
/**
|
|
35
41
|
* Build env for contract testCommand subprocess — omits worker-only keys inherited from
|
|
36
42
|
* worker-host.mjs that would false-fail batch-spawn integration tests (SP-482 guard).
|
|
43
|
+
* Preserves parent batch id as SPINE_PARENT_BATCH_ID so nested-spawn guard can block
|
|
44
|
+
* live engines in lane worktrees while still allowing isolated fixture tests (#162).
|
|
37
45
|
*
|
|
38
46
|
* @param {NodeJS.ProcessEnv} [sourceEnv]
|
|
39
47
|
* @returns {NodeJS.ProcessEnv}
|
|
@@ -43,6 +51,10 @@ export function buildContractTestEnv(sourceEnv = process.env) {
|
|
|
43
51
|
for (const key of CONTRACT_TEST_WORKER_ENV_KEYS) {
|
|
44
52
|
delete env[key];
|
|
45
53
|
}
|
|
54
|
+
if (env.SPINE_BATCH_ID && !env.SPINE_PARENT_BATCH_ID) {
|
|
55
|
+
env.SPINE_PARENT_BATCH_ID = env.SPINE_BATCH_ID;
|
|
56
|
+
}
|
|
57
|
+
delete env.SPINE_BATCH_ID;
|
|
46
58
|
return env;
|
|
47
59
|
}
|
|
48
60
|
|
|
@@ -218,6 +230,9 @@ export function verifyStubFileScopeMustChange(
|
|
|
218
230
|
if (isStubPrelandedFileScopeSatisfied(worktreePath, pattern, changedFiles, config, baseBranch)) {
|
|
219
231
|
continue;
|
|
220
232
|
}
|
|
233
|
+
if (isBaseScopeSatisfied(worktreePath, pattern, changedFiles, baseBranch, config)) {
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
221
236
|
failures.push(`Contract fileScopeMustChange: no matching changes for ${pattern}`);
|
|
222
237
|
}
|
|
223
238
|
return { ok: failures.length === 0, failures };
|
|
@@ -450,13 +465,31 @@ function findArtifactMatch(worktreePath, artifactPattern) {
|
|
|
450
465
|
return { ok: false };
|
|
451
466
|
}
|
|
452
467
|
|
|
468
|
+
/**
|
|
469
|
+
* Prepare lane worktree before contract testCommand (Flutter analyzer hygiene #78).
|
|
470
|
+
*
|
|
471
|
+
* @param {string} worktreePath
|
|
472
|
+
* @param {ReturnType<import("../tasks/packet/parse-prompt.mjs").parseContract>} parsedContract
|
|
473
|
+
* @param {object} [config]
|
|
474
|
+
* @returns {{ hygieneApplied: boolean, cleaned?: boolean, buildDir?: string, reason?: string }}
|
|
475
|
+
*/
|
|
476
|
+
export function prepareContractVerifyEnvironment(worktreePath, parsedContract, config = {}) {
|
|
477
|
+
const testCommand = parsedContract?.testCommand;
|
|
478
|
+
if (!testCommand || !shouldCleanFlutterBuildBeforeAnalyze(testCommand, config)) {
|
|
479
|
+
return { hygieneApplied: false };
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
const result = sanitizeFlutterBuildBeforeAnalyze(worktreePath);
|
|
483
|
+
return { hygieneApplied: true, ...result };
|
|
484
|
+
}
|
|
485
|
+
|
|
453
486
|
/**
|
|
454
487
|
* @param {string} worktreePath
|
|
455
488
|
* @param {ReturnType<import("../tasks/packet/parse-prompt.mjs").parseContract>} parsedContract
|
|
456
489
|
* @param {object} [config]
|
|
457
490
|
* @param {string} [config.baseBranch]
|
|
458
491
|
* @param {string} [config.sinceCommit] When set, scope file-scope checks to `sinceCommit..HEAD` (serialized lanes).
|
|
459
|
-
* @param {string} [config.taskStartCommit] Alias for `sinceCommit` (SP-415 journal resolution).
|
|
492
|
+
* @param {string} [config.taskStartCommit] Alias for `sinceCommit` (SP-415 journal resolution; anchor stable across retry/resume per SP-478).
|
|
460
493
|
* @param {string} [config.projectRoot] Repo root for journal events (optional).
|
|
461
494
|
* @param {string} [config.batchId] Batch ID for journal events (optional).
|
|
462
495
|
* @param {string} [config.taskId] Task ID for journal events (optional).
|
|
@@ -470,6 +503,8 @@ export function verifyContract(worktreePath, parsedContract, config = {}) {
|
|
|
470
503
|
const sinceCommit = config?.sinceCommit ?? config?.taskStartCommit ?? undefined;
|
|
471
504
|
const changedFiles = listChangedFiles(worktreePath, baseBranch, sinceCommit);
|
|
472
505
|
|
|
506
|
+
prepareContractVerifyEnvironment(worktreePath, parsedContract, config);
|
|
507
|
+
|
|
473
508
|
let testCommandOutput = "";
|
|
474
509
|
let testCommandOk = true;
|
|
475
510
|
let retriedCount = 0;
|
|
@@ -543,7 +578,18 @@ export function verifyContract(worktreePath, parsedContract, config = {}) {
|
|
|
543
578
|
{ testCommandOk },
|
|
544
579
|
(worktree, artifactPath) => findArtifactMatch(worktree, artifactPath).ok,
|
|
545
580
|
);
|
|
546
|
-
const
|
|
581
|
+
const baseSatisfied = !matched && !prelanded &&
|
|
582
|
+
isBaseFileScopeSatisfied(
|
|
583
|
+
worktreePath,
|
|
584
|
+
pattern,
|
|
585
|
+
changedFiles,
|
|
586
|
+
parsedContract,
|
|
587
|
+
baseBranch,
|
|
588
|
+
{ testCommandOk },
|
|
589
|
+
(worktree, artifactPath) => findArtifactMatch(worktree, artifactPath).ok,
|
|
590
|
+
config,
|
|
591
|
+
);
|
|
592
|
+
const ok = matched || prelanded || baseSatisfied;
|
|
547
593
|
checks.push({
|
|
548
594
|
field: "fileScopeMustChange",
|
|
549
595
|
ok,
|
|
@@ -551,7 +597,9 @@ export function verifyContract(worktreePath, parsedContract, config = {}) {
|
|
|
551
597
|
? `fileScopeMustChange matched: ${pattern}`
|
|
552
598
|
: prelanded
|
|
553
599
|
? `fileScopeMustChange pre-landed on ${baseBranch}: ${pattern}`
|
|
554
|
-
:
|
|
600
|
+
: baseSatisfied
|
|
601
|
+
? `fileScopeMustChange satisfied on ${baseBranch}: ${pattern}`
|
|
602
|
+
: `Contract fileScopeMustChange: no matching changes for ${pattern}`,
|
|
555
603
|
});
|
|
556
604
|
}
|
|
557
605
|
|
|
@@ -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
|
+
}
|
|
@@ -4,8 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
|
-
import { spawn } from "node:child_process";
|
|
8
7
|
import { loadSpineConfig } from "../config/spine-config-load.mjs";
|
|
8
|
+
import {
|
|
9
|
+
buildAttachedBatchResumeArgv,
|
|
10
|
+
buildAttachedBatchStartArgv,
|
|
11
|
+
DETACHED_ENGINE_LOG_REL,
|
|
12
|
+
detachedEngineLogPath,
|
|
13
|
+
spawnDetachedBatchEngine,
|
|
14
|
+
} from "./detached-spawn.mjs";
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
buildAttachedBatchResumeArgv,
|
|
18
|
+
buildAttachedBatchStartArgv,
|
|
19
|
+
DETACHED_ENGINE_LOG_REL,
|
|
20
|
+
detachedEngineLogPath,
|
|
21
|
+
spawnDetachedBatchEngine,
|
|
22
|
+
} from "./detached-spawn.mjs";
|
|
23
|
+
import { maybeSpawnSupervisorOnDetachedStart } from "./supervisor-spawn.mjs";
|
|
9
24
|
import { runBatchPreflight } from "../config/spine-preflight-lib.mjs";
|
|
10
25
|
import { loadGateRecord } from "./gate.mjs";
|
|
11
26
|
import { reconcileBatch } from "./reconcile.mjs";
|
|
@@ -22,8 +37,6 @@ import {
|
|
|
22
37
|
TERMINAL_BATCH_PHASES,
|
|
23
38
|
} from "./state.mjs";
|
|
24
39
|
|
|
25
|
-
export const DETACHED_ENGINE_LOG_REL = path.join(".spine", "runtime", "detached-engine.log");
|
|
26
|
-
|
|
27
40
|
/** Diagnoses that benefit from blocking until resume engine reaches terminal phase. */
|
|
28
41
|
const RESUME_WAIT_TERMINAL_DIAGNOSES = new Set([
|
|
29
42
|
"engine_orphaned",
|
|
@@ -308,74 +321,6 @@ function evaluateDetachedResumeWait(raw, taskId, updatedAtBefore) {
|
|
|
308
321
|
return null;
|
|
309
322
|
}
|
|
310
323
|
|
|
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
324
|
/**
|
|
380
325
|
* @param {string} projectRoot
|
|
381
326
|
* @param {number|null} enginePid
|
|
@@ -762,6 +707,13 @@ export async function startBatchDetached({
|
|
|
762
707
|
};
|
|
763
708
|
}
|
|
764
709
|
|
|
710
|
+
const configResult = loadSpineConfig(projectRoot);
|
|
711
|
+
const supervisorSpawn = maybeSpawnSupervisorOnDetachedStart({
|
|
712
|
+
projectRoot,
|
|
713
|
+
batchId: wait.batchId,
|
|
714
|
+
config: configResult.config ?? {},
|
|
715
|
+
});
|
|
716
|
+
|
|
765
717
|
const payload = {
|
|
766
718
|
ok: true,
|
|
767
719
|
detached: true,
|
|
@@ -773,6 +725,8 @@ export async function startBatchDetached({
|
|
|
773
725
|
enginePid,
|
|
774
726
|
logPath,
|
|
775
727
|
suggestedCommand: "spine status --diagnose",
|
|
728
|
+
supervisorSpawned: supervisorSpawn.spawned === true,
|
|
729
|
+
supervisorPid: supervisorSpawn.supervisorPid ?? null,
|
|
776
730
|
};
|
|
777
731
|
return {
|
|
778
732
|
ok: true,
|
|
@@ -16,6 +16,14 @@ export function buildAlternatives(diagnosis, ctx = {}) {
|
|
|
16
16
|
return ["spine batch complete --detect-manual-merge", ...common];
|
|
17
17
|
case "completed_manual":
|
|
18
18
|
return ["spine batch complete --detect-manual-merge", "spine batch dismiss", ...common];
|
|
19
|
+
case "human_base_diverged":
|
|
20
|
+
return [
|
|
21
|
+
"See operator-runbook §4.1 orch-first recovery",
|
|
22
|
+
"git merge main",
|
|
23
|
+
...common,
|
|
24
|
+
];
|
|
25
|
+
case "integrate_isolated_ok":
|
|
26
|
+
return ["git pull", "spine batch complete", ...common];
|
|
19
27
|
case "needs_retry":
|
|
20
28
|
return ["spine batch abort", "/spine-skip-task", "/spine-resume --force", ...common];
|
|
21
29
|
case "worker_orphaned":
|
package/src/batch/diagnosis.mjs
CHANGED
|
@@ -36,6 +36,25 @@ import {
|
|
|
36
36
|
} from "./diagnosis-primary-failure.mjs";
|
|
37
37
|
export { inferLaunchFailureFromWorkerOutputTail, inferLaunchFailureKind } from "./diagnosis-launch-failure.mjs";
|
|
38
38
|
|
|
39
|
+
const INVALID_BARE_RETRY_FORCE = /^spine batch retry --force$/;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Retry suggestions must include a task id; journal salvage payloads may be stale.
|
|
43
|
+
*
|
|
44
|
+
* @param {string|null|undefined} command
|
|
45
|
+
* @param {string|null|undefined} taskId
|
|
46
|
+
* @returns {string|null}
|
|
47
|
+
*/
|
|
48
|
+
export function sanitizeRetrySuggestedCommand(command, taskId) {
|
|
49
|
+
if (typeof command !== "string" || command.length === 0) {
|
|
50
|
+
return command ?? null;
|
|
51
|
+
}
|
|
52
|
+
if (INVALID_BARE_RETRY_FORCE.test(command.trim())) {
|
|
53
|
+
return taskId ? `spine batch retry ${taskId}` : "spine status --diagnose";
|
|
54
|
+
}
|
|
55
|
+
return command;
|
|
56
|
+
}
|
|
57
|
+
|
|
39
58
|
export const DIAGNOSIS_TAXONOMY = [
|
|
40
59
|
"running",
|
|
41
60
|
"paused",
|
|
@@ -50,11 +69,19 @@ export const DIAGNOSIS_TAXONOMY = [
|
|
|
50
69
|
"completed",
|
|
51
70
|
"completed_manual",
|
|
52
71
|
"limbo_stale",
|
|
72
|
+
"human_base_diverged",
|
|
73
|
+
"integrate_isolated_ok",
|
|
53
74
|
"failed",
|
|
54
75
|
"aborted",
|
|
55
76
|
];
|
|
56
77
|
|
|
57
|
-
const NO_PAUSE_DIAGNOSES = new Set([
|
|
78
|
+
const NO_PAUSE_DIAGNOSES = new Set([
|
|
79
|
+
"limbo_stale",
|
|
80
|
+
"completed_manual",
|
|
81
|
+
"needs_integrate",
|
|
82
|
+
"engine_orphaned",
|
|
83
|
+
"integrate_isolated_ok",
|
|
84
|
+
]);
|
|
58
85
|
const GITIGNORED_MERGE_FAILURE_CLASSES = new Set(["merge_failed_gitignored", "GitignoredDirtyWorktree"]);
|
|
59
86
|
const REVIEW_SPAWN_FAILURE_EXIT_REASONS = new Set([
|
|
60
87
|
"code_review_spawn_failed",
|
|
@@ -140,7 +167,13 @@ export function buildSuggestedCommand(diagnosis, ctx = {}) {
|
|
|
140
167
|
case "completed_manual":
|
|
141
168
|
return "spine batch dismiss";
|
|
142
169
|
case "state_drift":
|
|
143
|
-
|
|
170
|
+
if (ctx.failedTaskId) {
|
|
171
|
+
if (ctx.phase === "running") {
|
|
172
|
+
return `spine batch pause && spine batch retry ${ctx.failedTaskId}`;
|
|
173
|
+
}
|
|
174
|
+
return `spine batch retry ${ctx.failedTaskId}`;
|
|
175
|
+
}
|
|
176
|
+
return "spine status --diagnose";
|
|
144
177
|
case "needs_retry":
|
|
145
178
|
if (STUB_EXIT_REASONS.has(ctx.exitReason ?? "")) {
|
|
146
179
|
return buildStubFailureSuggestedCommand(ctx);
|
|
@@ -155,7 +188,9 @@ export function buildSuggestedCommand(diagnosis, ctx = {}) {
|
|
|
155
188
|
if (ctx.launchFailureKind === "worktree_unhealthy") {
|
|
156
189
|
return "spine doctor";
|
|
157
190
|
}
|
|
158
|
-
if (ctx.salvageRetryCommand)
|
|
191
|
+
if (ctx.salvageRetryCommand) {
|
|
192
|
+
return sanitizeRetrySuggestedCommand(ctx.salvageRetryCommand, ctx.failedTaskId);
|
|
193
|
+
}
|
|
159
194
|
if (isFailedPhasePendingOnlyLimbo(ctx)) {
|
|
160
195
|
return buildFailedPhasePendingOnlySuggestedCommand(ctx);
|
|
161
196
|
}
|
|
@@ -183,7 +218,9 @@ export function buildSuggestedCommand(diagnosis, ctx = {}) {
|
|
|
183
218
|
if (ctx.launchFailureKind === "worktree_unhealthy") {
|
|
184
219
|
return "spine doctor";
|
|
185
220
|
}
|
|
186
|
-
if (ctx.salvageRetryCommand)
|
|
221
|
+
if (ctx.salvageRetryCommand) {
|
|
222
|
+
return sanitizeRetrySuggestedCommand(ctx.salvageRetryCommand, ctx.failedTaskId);
|
|
223
|
+
}
|
|
187
224
|
return ctx.failedTaskId
|
|
188
225
|
? `spine batch retry ${ctx.failedTaskId}`
|
|
189
226
|
: "spine batch abort";
|
|
@@ -222,6 +259,10 @@ export function buildSuggestedCommand(diagnosis, ctx = {}) {
|
|
|
222
259
|
return "spine batch dismiss";
|
|
223
260
|
case "completed":
|
|
224
261
|
return "spine preflight";
|
|
262
|
+
case "human_base_diverged":
|
|
263
|
+
return "spine sync-base";
|
|
264
|
+
case "integrate_isolated_ok":
|
|
265
|
+
return "spine sync-base";
|
|
225
266
|
default:
|
|
226
267
|
return "spine status --diagnose";
|
|
227
268
|
}
|
|
@@ -371,6 +412,14 @@ export function buildHeadline(diagnosis, ctx = {}) {
|
|
|
371
412
|
return `${batchLabel} was aborted`;
|
|
372
413
|
case "completed":
|
|
373
414
|
return `${batchLabel} completed successfully`;
|
|
415
|
+
case "human_base_diverged": {
|
|
416
|
+
const overlapCount = Array.isArray(ctx.overlapPaths) ? ctx.overlapPaths.length : 0;
|
|
417
|
+
return overlapCount > 0
|
|
418
|
+
? `${batchLabel} — human commits on base overlap orch land (${overlapCount} path(s))`
|
|
419
|
+
: `${batchLabel} — human commits on base overlap orch land`;
|
|
420
|
+
}
|
|
421
|
+
case "integrate_isolated_ok":
|
|
422
|
+
return `${batchLabel} — isolated integrate landed; sync human checkout with base`;
|
|
374
423
|
default:
|
|
375
424
|
return `${batchLabel} requires attention (phase: ${ctx.phase ?? "unknown"})`;
|
|
376
425
|
}
|
package/src/batch/engine.mjs
CHANGED
|
@@ -15,6 +15,7 @@ import { installAttachedEngineShutdownHandlers } from "./attached-engine-handoff
|
|
|
15
15
|
import { finalizeBatchForIntegrate, tryFinalizePostMergeLimbo } from "./post-merge-limbo.mjs";
|
|
16
16
|
import { detectPostMergeLimboForResume } from "./resume-multi-validate.mjs";
|
|
17
17
|
import { appendJournalEvent } from "./journal.mjs";
|
|
18
|
+
import { recordBatchBaseSnapshotOnStart } from "./lifecycle.mjs";
|
|
18
19
|
import { adoptPauseIfRequested, saveEngineBatchState } from "./pause.mjs";
|
|
19
20
|
import {
|
|
20
21
|
assertNoActiveBatch,
|
|
@@ -88,6 +89,13 @@ export function detectNestedWorkerContext(projectRoot) {
|
|
|
88
89
|
if (process.env.SPINE_IS_WORKER === "1") {
|
|
89
90
|
return "SPINE_IS_WORKER=1 is set (running inside a worker process)";
|
|
90
91
|
}
|
|
92
|
+
const parentBatchId = process.env.SPINE_PARENT_BATCH_ID ?? process.env.SPINE_BATCH_ID;
|
|
93
|
+
if (parentBatchId && WORKTREE_SPINE_PATTERN.test(projectRoot)) {
|
|
94
|
+
return (
|
|
95
|
+
`parent batch ${parentBatchId} is active and projectRoot is inside a ` +
|
|
96
|
+
`.worktrees/spine-* lane directory`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
91
99
|
if (WORKTREE_SPINE_PATTERN.test(projectRoot)) {
|
|
92
100
|
return "projectRoot is inside a .worktrees/spine-* lane directory";
|
|
93
101
|
}
|
|
@@ -113,7 +121,7 @@ export async function startBatch({
|
|
|
113
121
|
}) {
|
|
114
122
|
const nestedReason = detectNestedWorkerContext(projectRoot);
|
|
115
123
|
if (nestedReason) {
|
|
116
|
-
const parentBatchId = process.env.SPINE_BATCH_ID ?? "unknown";
|
|
124
|
+
const parentBatchId = process.env.SPINE_PARENT_BATCH_ID ?? process.env.SPINE_BATCH_ID ?? "unknown";
|
|
117
125
|
try {
|
|
118
126
|
appendJournalEvent(projectRoot, parentBatchId, "engine.nested_spawn_blocked", {
|
|
119
127
|
projectRoot,
|
|
@@ -243,6 +251,7 @@ export async function startBatch({
|
|
|
243
251
|
lanes,
|
|
244
252
|
});
|
|
245
253
|
|
|
254
|
+
recordBatchBaseSnapshotOnStart(projectRoot, state);
|
|
246
255
|
saveEngineBatchState(projectRoot, state);
|
|
247
256
|
|
|
248
257
|
try {
|