pi-spine 1.2.0 → 1.3.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/README.md +4 -4
- package/bin/spine-cli/verify.mjs +3 -0
- package/bin/spine-plan.mjs +49 -1
- package/bin/spine-worker-runner.mjs +136 -4
- package/package.json +1 -1
- package/skills/create-spine-tasks/SKILL.md +7 -2
- package/skills/create-spine-tasks/references/contract-template.md +95 -3
- package/src/batch/attached-runner.mjs +81 -5
- package/src/batch/contract-stub-delivery.mjs +110 -0
- package/src/batch/contract-task-start.mjs +204 -0
- package/src/batch/contract-verify.mjs +55 -8
- package/src/batch/detached-start.mjs +72 -2
- package/src/batch/diagnosis-launch-failure.mjs +114 -0
- package/src/batch/diagnosis-primary-failure.mjs +89 -0
- package/src/batch/diagnosis-tail-state.mjs +57 -0
- package/src/batch/diagnosis.mjs +22 -113
- package/src/batch/engine-lanes/commit.mjs +145 -0
- package/src/batch/engine-lanes/review.mjs +67 -87
- package/src/batch/engine-lanes.mjs +21 -79
- package/src/batch/engine.mjs +46 -0
- package/src/batch/heartbeat.mjs +2 -2
- package/src/batch/integrate-assert.mjs +69 -0
- package/src/batch/integrate-worktree.mjs +354 -0
- package/src/batch/integrate.mjs +195 -102
- package/src/batch/journal-rebuild.mjs +48 -2
- package/src/batch/journal.mjs +63 -0
- package/src/batch/lane-dirty-check.mjs +437 -0
- package/src/batch/limbo-detect.mjs +34 -0
- package/src/batch/macro-phase.mjs +76 -0
- package/src/batch/metrics.mjs +2 -0
- package/src/batch/pause.mjs +18 -7
- package/src/batch/post-merge-limbo.mjs +3 -28
- package/src/batch/reconcile.mjs +79 -9
- package/src/batch/resume-common.mjs +27 -0
- package/src/batch/resume-multi-lanes.mjs +11 -0
- package/src/batch/resume-multi.mjs +2 -0
- package/src/batch/resume.mjs +8 -1
- package/src/batch/retry.mjs +41 -10
- package/src/batch/rules-manifest-drift.mjs +43 -2
- package/src/batch/sequence-state.mjs +290 -0
- package/src/batch/sequence.mjs +113 -51
- package/src/batch/state.mjs +16 -0
- package/src/batch/worker-host.mjs +1 -0
- package/src/cli/sequence.mjs +14 -1
- package/src/cli/settings-set.mjs +33 -3
- package/src/config/model-id.mjs +103 -0
- package/src/config/spine-init-constants.mjs +1 -0
- package/src/config/spine-preflight-lib.mjs +23 -1
- package/src/dashboard/public/dashboard.js +14 -3
- package/src/dashboard/running-tail-state.mjs +31 -0
- package/src/dashboard/server.mjs +4 -0
- package/src/dashboard/snapshot.mjs +260 -28
- package/src/dashboard/view.mjs +112 -2
- package/src/doctor/agent-models.mjs +53 -0
- package/src/doctor/batch-size-guidance.mjs +30 -2
- package/src/doctor/pi-extension-conflict.mjs +169 -0
- package/src/doctor/run-doctor-checks.mjs +6 -0
- package/src/planner/scope.mjs +5 -1
- package/src/tasks/packet/parse-prompt.mjs +31 -1
- package/src/tasks/packet/validate-contract.mjs +108 -0
package/README.md
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
**Orchestration spine for long-running pi development.**
|
|
6
6
|
|
|
7
|
-
pi-spine is a [pi](https://pi.dev) package for parallel, multi-day agent batches on real codebases. It combines Taskplane-style task packets, Babysitter-grade audit history, and pi-conductor
|
|
7
|
+
pi-spine is a [pi](https://pi.dev) package for parallel, multi-day agent batches on real codebases. It combines Taskplane-style task packets, Babysitter-grade audit history, and ~~pi-conductor~~-inspired human gates in one pi-native flow — **compose, don't merge** the best patterns into a single pi-native spine.
|
|
8
8
|
|
|
9
9
|
| pi-spine is | pi-spine is not |
|
|
10
10
|
|-------------|-----------------|
|
|
11
11
|
| A pi extension + CLI (`spine`) for batch orchestration | A replacement for pi itself |
|
|
12
12
|
| Compatible with Taskplane `PROMPT.md` / `STATUS.md` packets | A fork of Taskplane |
|
|
13
13
|
| An append-only **orchestration journal** for control-plane events | A full Babysitter process-definition engine |
|
|
14
|
-
| **Human gates** before integrate/merge | A clone of pi-conductor's external control-plane DB |
|
|
14
|
+
| **Human gates** before integrate/merge | A clone of ~~pi-conductor's~~ external control-plane DB (archived upstream) |
|
|
15
15
|
| Worktree-isolated parallel lanes | Cross-harness routing (Cursor, Codex, etc.) in v1 |
|
|
16
16
|
|
|
17
17
|
## Feature summary
|
|
@@ -28,7 +28,7 @@ pi-spine is a [pi](https://pi.dev) package for parallel, multi-day agent batches
|
|
|
28
28
|
|
|
29
29
|
## Inspired by
|
|
30
30
|
|
|
31
|
-
pi-spine builds on ideas from [Taskplane](https://pi.dev/packages/taskplane), [Babysitter](https://github.com/a5c-ai/babysitter), and [pi-conductor](https://www.npmjs.com/package/@feniix/pi-conductor). For comparisons, trade-offs, and when to use each tool alone, see **[Why pi-spine?](docs/adoption/why-pi-spine.md)**.
|
|
31
|
+
pi-spine builds on ideas from [Taskplane](https://pi.dev/packages/taskplane), [Babysitter](https://github.com/a5c-ai/babysitter), and [pi-conductor](https://www.npmjs.com/package/@feniix/pi-conductor) (archived). For comparisons, trade-offs, and when to use each tool alone, see **[Why pi-spine?](docs/adoption/why-pi-spine.md)**.
|
|
32
32
|
|
|
33
33
|
## Honest limits
|
|
34
34
|
|
|
@@ -138,7 +138,7 @@ CI runs on every push and PR: typecheck, tests, coverage, and CLI smoke checks
|
|
|
138
138
|
| [docs/PRD.md](docs/PRD.md) | Product requirements and implementation contract |
|
|
139
139
|
| [docs/QUICK-REFERENCE.md](docs/QUICK-REFERENCE.md) | Operator command reference |
|
|
140
140
|
| [docs/EXECUTION-FLOW.md](docs/EXECUTION-FLOW.md) | Batch lifecycle and scheduling |
|
|
141
|
-
| [docs/adoption/why-pi-spine.md](docs/adoption/why-pi-spine.md) | Positioning vs Taskplane, Babysitter, pi-conductor |
|
|
141
|
+
| [docs/adoption/why-pi-spine.md](docs/adoption/why-pi-spine.md) | Positioning vs Taskplane, Babysitter, pi-conductor (archived) |
|
|
142
142
|
| [docs/adoption/operator-runbook.md](docs/adoption/operator-runbook.md) | Daily operator procedures |
|
|
143
143
|
| [docs/adoption/bootstrap-checklist.md](docs/adoption/bootstrap-checklist.md) | First-time setup |
|
|
144
144
|
|
package/bin/spine-cli/verify.mjs
CHANGED
|
@@ -13,6 +13,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
13
13
|
|
|
14
14
|
/** Modules >500 LOC grandfathered until v2.3 split (FR-SHIP-02 partial — engine-lanes split done). */
|
|
15
15
|
export const PHASE23_GRANDFATHERED_OVER_500 = [
|
|
16
|
+
"src/batch/engine.mjs",
|
|
17
|
+
"src/batch/integrate.mjs",
|
|
16
18
|
"src/batch/state.mjs",
|
|
17
19
|
"src/batch/worker-host.mjs",
|
|
18
20
|
"src/batch/reconcile.mjs",
|
|
@@ -20,6 +22,7 @@ export const PHASE23_GRANDFATHERED_OVER_500 = [
|
|
|
20
22
|
"src/batch/review.mjs",
|
|
21
23
|
"src/batch/resume-multi-lanes.mjs",
|
|
22
24
|
"src/batch/resume.mjs",
|
|
25
|
+
"src/batch/sequence.mjs",
|
|
23
26
|
];
|
|
24
27
|
|
|
25
28
|
const PHASE23_ENGINE_LANES_MAX = 500;
|
package/bin/spine-plan.mjs
CHANGED
|
@@ -30,6 +30,39 @@ function writePlanArtifact({ projectRoot, plan }) {
|
|
|
30
30
|
return artifactPath;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Format a friendly informational message when pending scope has zero tasks.
|
|
35
|
+
*
|
|
36
|
+
* @param {{ excludedCount?: number, discoveredCount?: number }} meta
|
|
37
|
+
* @param {{ maxParallel?: number }} laneConfig
|
|
38
|
+
* @param {{ json?: boolean }} options
|
|
39
|
+
*/
|
|
40
|
+
function formatEmptyPendingResult({ excludedCount = 0, discoveredCount = 0 }, laneConfig, { json = false } = {}) {
|
|
41
|
+
if (json) {
|
|
42
|
+
const syntheticPlan = {
|
|
43
|
+
generatedAt: new Date().toISOString(),
|
|
44
|
+
scope: { mode: 'pending', taskIds: [] },
|
|
45
|
+
laneConfig,
|
|
46
|
+
waves: [],
|
|
47
|
+
tasks: {},
|
|
48
|
+
metadata: { tasksDiscovered: discoveredCount, tasksSelected: 0, tasksExcluded: excludedCount },
|
|
49
|
+
};
|
|
50
|
+
return { plan: syntheticPlan, artifactPath: null, output: JSON.stringify(syntheticPlan, null, 2) };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const lines = [
|
|
54
|
+
'Spine plan — pending',
|
|
55
|
+
`0 task(s) · 0 wave(s) · maxParallel ${laneConfig.maxParallel ?? 1}`,
|
|
56
|
+
`${excludedCount} excluded (.DONE on disk)`,
|
|
57
|
+
'',
|
|
58
|
+
'No pending tasks — all discovered tasks have .DONE on disk.',
|
|
59
|
+
'',
|
|
60
|
+
'\u2192 spine plan all',
|
|
61
|
+
'',
|
|
62
|
+
];
|
|
63
|
+
return { plan: null, artifactPath: null, output: lines.join('\n') };
|
|
64
|
+
}
|
|
65
|
+
|
|
33
66
|
export async function runSpinePlan({
|
|
34
67
|
projectRoot = process.cwd(),
|
|
35
68
|
scope = 'all',
|
|
@@ -49,7 +82,22 @@ export async function runSpinePlan({
|
|
|
49
82
|
err.suggestedCommand = 'spine init';
|
|
50
83
|
throw err;
|
|
51
84
|
}
|
|
52
|
-
|
|
85
|
+
|
|
86
|
+
let plan;
|
|
87
|
+
try {
|
|
88
|
+
plan = buildPlan({ scope, config, tasksRoot });
|
|
89
|
+
} catch (err) {
|
|
90
|
+
if (err?.code === 'NO_PENDING_TASKS') {
|
|
91
|
+
const laneConfig = { maxParallel: config.lanes?.maxParallel ?? 1 };
|
|
92
|
+
return formatEmptyPendingResult(
|
|
93
|
+
{ excludedCount: err.excludedCount, discoveredCount: err.discoveredCount },
|
|
94
|
+
laneConfig,
|
|
95
|
+
{ json },
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
throw err;
|
|
99
|
+
}
|
|
100
|
+
|
|
53
101
|
const artifactPath = writePlanArtifact({ projectRoot, plan });
|
|
54
102
|
|
|
55
103
|
if (json) {
|
|
@@ -29,9 +29,31 @@ import {
|
|
|
29
29
|
import { reportTaskProgress } from "../src/worker-tools/report-progress.mjs";
|
|
30
30
|
import { isCliEntrypoint } from "./spine-cli/shared.mjs";
|
|
31
31
|
import { loadSpineConfig } from "./spine-config.mjs";
|
|
32
|
+
import { isStubDeliveryOnlyScope } from "../src/batch/contract-stub-delivery.mjs";
|
|
32
33
|
import { writeWorkerDoneMarker } from "../src/batch/worker-output.mjs";
|
|
33
34
|
import { buildWorkerTailPrompt, taskIdFromFolder } from "../src/batch/worker-prompt.mjs";
|
|
34
|
-
import {
|
|
35
|
+
import { DEFAULT_TASKS_ROOT } from "../src/config/spine-init-constants.mjs";
|
|
36
|
+
import {
|
|
37
|
+
isPiExtensionConflictOutput,
|
|
38
|
+
shouldWorkerUsePiNoExtensions,
|
|
39
|
+
} from "../src/doctor/pi-extension-conflict.mjs";
|
|
40
|
+
import { parseContract, parsePrompt } from "../src/tasks/packet/parse-prompt.mjs";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Actionable hint when pi worker spawn fails on duplicate extension tool registration.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} output
|
|
46
|
+
* @returns {string|null}
|
|
47
|
+
*/
|
|
48
|
+
export function formatPiExtensionConflictHint(output) {
|
|
49
|
+
if (!isPiExtensionConflictOutput(output)) return null;
|
|
50
|
+
return [
|
|
51
|
+
"pi extension tool conflict detected (often duplicate pi-web-access npm + local checkout).",
|
|
52
|
+
"Batch workers pass pi -ne only when spine doctor detects duplicate pi-web-access sources.",
|
|
53
|
+
"Fix pi settings with `pi remove npm:pi-web-access -l` or remove the local path from",
|
|
54
|
+
"~/.pi/agent/settings.json, then retry the task.",
|
|
55
|
+
].join(" ");
|
|
56
|
+
}
|
|
35
57
|
|
|
36
58
|
function buildReviewJournal() {
|
|
37
59
|
return resolveBatchJournalContext();
|
|
@@ -77,7 +99,13 @@ export async function buildWorkerPiArgs({
|
|
|
77
99
|
? path.join(worktreePath, ".spine", "agents", "worker.md")
|
|
78
100
|
: null;
|
|
79
101
|
|
|
80
|
-
const
|
|
102
|
+
const projectRoot =
|
|
103
|
+
process.env.SPINE_RULES_PROJECT_ROOT || worktreePath || process.env.SPINE_PROJECT_ROOT || process.cwd();
|
|
104
|
+
const piArgs = [];
|
|
105
|
+
if (shouldWorkerUsePiNoExtensions({ projectRoot })) {
|
|
106
|
+
piArgs.push("-ne");
|
|
107
|
+
}
|
|
108
|
+
piArgs.push("-p", "--no-session");
|
|
81
109
|
if (workerAgentPath && fs.existsSync(workerAgentPath)) {
|
|
82
110
|
piArgs.push("--append-system-prompt", workerAgentPath);
|
|
83
111
|
}
|
|
@@ -85,8 +113,6 @@ export async function buildWorkerPiArgs({
|
|
|
85
113
|
piArgs.push(`@${promptPath}`);
|
|
86
114
|
}
|
|
87
115
|
appendWorkerAgentModelArgs(piArgs, spineConfig);
|
|
88
|
-
const projectRoot =
|
|
89
|
-
process.env.SPINE_RULES_PROJECT_ROOT || worktreePath || process.env.SPINE_PROJECT_ROOT || process.cwd();
|
|
90
116
|
const taskFileScope = resolveTaskFileScope(taskFolder);
|
|
91
117
|
const tailPrompt = await buildWorkerTailPrompt({
|
|
92
118
|
worktreePath,
|
|
@@ -108,6 +134,105 @@ export async function buildWorkerPiArgs({
|
|
|
108
134
|
* @param {string} taskFolder
|
|
109
135
|
* @returns {string[]}
|
|
110
136
|
*/
|
|
137
|
+
const STUB_DELIVERY_CURRENT_STEP = "Complete";
|
|
138
|
+
const STUB_DELIVERY_STATUS = "✅ Complete";
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Update STATUS.md header lines or append a minimal stub delivery block.
|
|
142
|
+
*
|
|
143
|
+
* @param {string} [existingContent]
|
|
144
|
+
* @returns {string}
|
|
145
|
+
*/
|
|
146
|
+
export function applyStubDeliveryStatusBlock(existingContent = "") {
|
|
147
|
+
const lines = String(existingContent ?? "").split("\n");
|
|
148
|
+
let foundCurrentStep = false;
|
|
149
|
+
let foundStatus = false;
|
|
150
|
+
const updated = lines.map((line) => {
|
|
151
|
+
if (/^\*\*Current Step:\*\*/.test(line)) {
|
|
152
|
+
foundCurrentStep = true;
|
|
153
|
+
return `**Current Step:** ${STUB_DELIVERY_CURRENT_STEP}`;
|
|
154
|
+
}
|
|
155
|
+
if (/^\*\*Status:\*\*/.test(line)) {
|
|
156
|
+
foundStatus = true;
|
|
157
|
+
return `**Status:** ${STUB_DELIVERY_STATUS}`;
|
|
158
|
+
}
|
|
159
|
+
return line;
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const additions = [];
|
|
163
|
+
if (!foundCurrentStep) {
|
|
164
|
+
additions.push(`**Current Step:** ${STUB_DELIVERY_CURRENT_STEP}`);
|
|
165
|
+
}
|
|
166
|
+
if (!foundStatus) {
|
|
167
|
+
additions.push(`**Status:** ${STUB_DELIVERY_STATUS}`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (additions.length === 0) {
|
|
171
|
+
return updated.join("\n");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const titleIdx = updated.findIndex((line) => /^#\s/.test(line));
|
|
175
|
+
if (titleIdx >= 0) {
|
|
176
|
+
let insertAt = titleIdx + 1;
|
|
177
|
+
if (insertAt < updated.length && updated[insertAt].trim() === "") {
|
|
178
|
+
insertAt += 1;
|
|
179
|
+
}
|
|
180
|
+
updated.splice(insertAt, 0, ...additions, "");
|
|
181
|
+
return updated.join("\n");
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (updated.length > 0 && updated[updated.length - 1].trim() !== "") {
|
|
185
|
+
updated.push("");
|
|
186
|
+
}
|
|
187
|
+
updated.push(...additions, "");
|
|
188
|
+
return updated.join("\n");
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @param {string[]} patterns
|
|
193
|
+
*/
|
|
194
|
+
function stubDeliveryRequiresStatusTouch(patterns) {
|
|
195
|
+
return patterns.some((pattern) => {
|
|
196
|
+
const normalized = String(pattern ?? "").replace(/\\/g, "/").trim();
|
|
197
|
+
if (normalized.includes("STATUS.md")) {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
if (normalized.endsWith("/**")) {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* When stub mode has delivery-only fileScopeMustChange, write STATUS.md before .DONE.
|
|
209
|
+
*
|
|
210
|
+
* @param {object} options
|
|
211
|
+
* @param {string} options.taskFolder
|
|
212
|
+
* @param {string} [options.tasksRoot]
|
|
213
|
+
* @returns {boolean} Whether STATUS.md was updated
|
|
214
|
+
*/
|
|
215
|
+
export function writeStubDeliveryStatusIfNeeded({ taskFolder, tasksRoot = DEFAULT_TASKS_ROOT }) {
|
|
216
|
+
const promptPath = path.join(taskFolder, "PROMPT.md");
|
|
217
|
+
if (!fs.existsSync(promptPath)) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const parsed = parseContract(fs.readFileSync(promptPath, "utf-8"));
|
|
222
|
+
const patterns = parsed.fileScopeMustChange ?? [];
|
|
223
|
+
if (!isStubDeliveryOnlyScope(patterns, tasksRoot)) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
if (!stubDeliveryRequiresStatusTouch(patterns)) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const statusPath = path.join(taskFolder, "STATUS.md");
|
|
231
|
+
const existing = fs.existsSync(statusPath) ? fs.readFileSync(statusPath, "utf-8") : "";
|
|
232
|
+
fs.writeFileSync(statusPath, applyStubDeliveryStatusBlock(existing), "utf-8");
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
|
|
111
236
|
function resolveTaskFileScope(taskFolder) {
|
|
112
237
|
const envScope = process.env.SPINE_TASK_FILE_SCOPE;
|
|
113
238
|
if (envScope) {
|
|
@@ -259,6 +384,8 @@ async function runWorkerRunner() {
|
|
|
259
384
|
|
|
260
385
|
await enforceStubReviewIfConfigured(taskFolder, worktreePath);
|
|
261
386
|
|
|
387
|
+
writeStubDeliveryStatusIfNeeded({ taskFolder });
|
|
388
|
+
|
|
262
389
|
const donePath = path.join(taskFolder, ".DONE");
|
|
263
390
|
const stubTaskId = process.env.SPINE_TASK_ID || taskIdFromFolder(taskFolder) || "stub";
|
|
264
391
|
writeWorkerDoneMarker(donePath, { taskId: stubTaskId });
|
|
@@ -306,6 +433,11 @@ async function runWorkerRunner() {
|
|
|
306
433
|
}
|
|
307
434
|
|
|
308
435
|
if (result.status !== 0) {
|
|
436
|
+
const combined = `${result.stderr ?? ""}${result.stdout ?? ""}`;
|
|
437
|
+
const conflictHint = formatPiExtensionConflictHint(combined);
|
|
438
|
+
if (conflictHint) {
|
|
439
|
+
console.error(conflictHint);
|
|
440
|
+
}
|
|
309
441
|
process.stderr.write(result.stderr ?? "");
|
|
310
442
|
process.stdout.write(result.stdout ?? "");
|
|
311
443
|
process.exit(result.status ?? 1);
|
package/package.json
CHANGED
|
@@ -285,7 +285,7 @@ Use [references/prompt-template.md](references/prompt-template.md). Spine-specif
|
|
|
285
285
|
- **Worker tools** — when Review Level > 0, steps must note `spine_review_step` after each step
|
|
286
286
|
- **Testing step (required for all tasks)** — every packet MUST include `### Step N: Testing & Verification` inside `## Steps`, placed **before** `## Completion Criteria`. This applies to **docs-only Review Level 0 tasks** as well — omitting the step causes `prompt_parse_failed` at batch launch (SP-075). Docs-only tasks still run the full test suite; they may omit the coverage-gate checkbox when no application code changes.
|
|
287
287
|
- **Coverage gate** — when the task changes application code, add a coverage verification checkbox in the Testing step using `testing.testWithCoverage` (≥77% line coverage policy)
|
|
288
|
-
- **Contract (required for new SP-\* tasks)** — add `## Contract` after `## File Scope` using [references/contract-template.md](references/contract-template.md). Include `testCommand` for code tasks; use `` `true` `` for docs-only S tasks. Legacy `TP-*` packets may omit Contract when `contract.legacyTaskIdPrefixes` includes `TP-`.
|
|
288
|
+
- **Contract (required for new SP-\* tasks)** — add `## Contract` after `## File Scope` using [references/contract-template.md](references/contract-template.md). Include `testCommand` for code tasks; use `` `true` `` for docs-only S tasks. When using `fileScopeMustNotChange`, follow parallel-only semantics and never ban `spine-tasks/**` (see contract template and [File Scope and parallel batches](#file-scope-and-parallel-batches)). Legacy `TP-*` packets may omit Contract when `contract.legacyTaskIdPrefixes` includes `TP-`.
|
|
289
289
|
- **Completion** — worker creates `{task-folder}/.DONE`; batch engine may auto-commit remaining work
|
|
290
290
|
|
|
291
291
|
### Step 5: Create STATUS.md
|
|
@@ -438,6 +438,10 @@ Task IDs in JSON use the **folder slug** (full `SP-011-api-handlers`) or bare ID
|
|
|
438
438
|
|
|
439
439
|
When decomposing a PRD, assign non-overlapping file scopes to tasks that should run in parallel.
|
|
440
440
|
|
|
441
|
+
**`fileScopeMustNotChange` (parallel lanes only):** When a packet includes `fileScopeMustNotChange` in `## Contract`, use it only to guard **product paths that concurrent tasks on different lanes** must not edit in the same wave — not to isolate paths touched by **prior serialized tasks** on the same lane. When `spine plan` reports `File scope overlaps (tasks serialized to the same lane)`, those tasks run sequentially on one lane; use disjoint `fileScopeMustChange` paths instead of relying on must-not-change. Full semantics and examples: [references/contract-template.md](references/contract-template.md#filescopemustnotchange-semantics).
|
|
442
|
+
|
|
443
|
+
**Never ban `spine-tasks/**`:** Do **not** list `spine-tasks/**` or the **current task folder** in `fileScopeMustNotChange`. Workers must update `STATUS.md`, create `.DONE`, and may write `.reviews/` — banning those paths causes `contract.verified` failures even when implementation is correct.
|
|
444
|
+
|
|
441
445
|
**Worker rules:** File Scope also drives **glob-matched Cursor rules** injected into batch workers (FR-WORK-05). Tasks touching `**/*.{js,mjs}` activate JS standards; Swift/Python tasks need scope paths that match those rule globs. Keep scope precise — wide scope pulls more rules and increases prompt byte usage.
|
|
442
446
|
|
|
443
447
|
**Reviewer rules (FR-REV-08):** Plan reviews use the same File Scope for glob matching; code reviews use changed paths from `git diff`. Final reviews load always-on rules only. Worker-only packs (`taskplane-worker-cursor.mdc`) are excluded from reviewer context by default.
|
|
@@ -483,7 +487,8 @@ Hydration commits (STATUS.md expansions) may happen mid-step for crash recovery.
|
|
|
483
487
|
|
|
484
488
|
## Key Principles
|
|
485
489
|
|
|
486
|
-
- **Self-contained PROMPT.md** — the worker has no memory of this conversation.
|
|
490
|
+
- **Self-contained PROMPT.md** — the worker has no memory of this conversation. Cross-model reviewers receive a **fresh spawn** (FR-REV-04) with only the review request, diff, and Contract — not `referenceDocs` or worker rules. Place acceptance criteria and spec references in PROMPT `## Mission`, `## Contract`, and step checkboxes.
|
|
491
|
+
- **Scoped `testCommand` for cross-model batches** — lane worktrees differ from dev checkouts; broad `flutter test` / `npm test` can fail in lanes even when targeted tests pass. See [cross-model authoring guidance](references/contract-template.md#cross-model-authoring-worker--reviewer) for the `testCommand` decision table.
|
|
487
492
|
- **Testing step required (never omit)** — every task packet needs `### Step N: Testing & Verification` inside `## Steps`, before `## Completion Criteria`. **Do not skip this for docs-only or Review Level 0 tasks** — the worker rejects packets without a Testing step. Use `testing.test` from spine config; for **code deliverables**, also include `testing.testWithCoverage` and a **≥77% line coverage** checkbox (see prompt template). Docs-only tasks may omit the coverage checkbox.
|
|
488
493
|
- **Documentation in every task** — "Must Update" / "Check If Affected" prevent doc drift.
|
|
489
494
|
- **Concrete deliverables** — name files to create/modify; avoid shortcuttable vague steps.
|
|
@@ -22,6 +22,14 @@ Normative schema: [PRD v2.0 implementation handoff §4](../../docs/PRD-v2.0-impl
|
|
|
22
22
|
| artifactsMustExist | `tests/batch/final-verdict.test.mjs` |
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
**Path list formatting:** wrap each path in its own backticks. Do **not** put multiple comma-separated paths inside one pair:
|
|
26
|
+
|
|
27
|
+
```markdown
|
|
28
|
+
| fileScopeMustChange | `bin/a.mjs`, `bin/b.mjs` |
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Avoid `` `bin/a.mjs,bin/b.mjs` `` — `tasks validate` warns (or errors in required mode) and the parser must recover for legacy packets.
|
|
32
|
+
|
|
25
33
|
---
|
|
26
34
|
|
|
27
35
|
## Field guidance
|
|
@@ -29,10 +37,10 @@ Normative schema: [PRD v2.0 implementation handoff §4](../../docs/PRD-v2.0-impl
|
|
|
29
37
|
| Field | When to include | Value format |
|
|
30
38
|
|-------|-----------------|--------------|
|
|
31
39
|
| `testCommand` | **Required** for code tasks (Review Level ≥ 1, Size M/L, or implementation steps) | Shell command in backticks; max 500 chars; no newlines. Use `` `true` `` for docs-only S tasks with no code changes. |
|
|
32
|
-
| `fileScopeMustChange` | When you need proof specific paths were touched | Comma-separated paths/globs relative to repo root |
|
|
33
|
-
| `fileScopeMustNotChange` | When parallel
|
|
40
|
+
| `fileScopeMustChange` | When you need proof specific paths were touched | Comma-separated paths/globs relative to repo root; **one backtick per path** (not `` `a.mjs,b.mjs` ``) |
|
|
41
|
+
| `fileScopeMustNotChange` | When **parallel lanes** must not collide on product paths (see semantics below) | Comma-separated paths/globs relative to repo root; **one backtick per path** |
|
|
34
42
|
| `minLineCoverage` | When task changes application code | Integer 0–100 (pi-spine policy: **77**) |
|
|
35
|
-
| `artifactsMustExist` | When deliverables must exist on disk | Comma-separated file paths |
|
|
43
|
+
| `artifactsMustExist` | When deliverables must exist on disk | Comma-separated file paths; **one backtick per path** |
|
|
36
44
|
| `stallTimeoutMinutes` | Long external jobs (operator matrix, CI arms) exceeding global/size stall budget | Positive integer minutes; engine uses `max(global, size floor, contract)` |
|
|
37
45
|
| `extendGraceOnFileScope` | STATUS-only progress during long external work | `true` or `false`; when `true`, file-scope mtime extends stall grace for this task |
|
|
38
46
|
|
|
@@ -40,6 +48,50 @@ Unknown field names produce **warnings** at validate time (not errors). Duplicat
|
|
|
40
48
|
|
|
41
49
|
---
|
|
42
50
|
|
|
51
|
+
## `fileScopeMustNotChange` semantics
|
|
52
|
+
|
|
53
|
+
**Parallel lanes only.** Use this field to guard product paths that **concurrent tasks on different lanes** must not edit in the same wave. It is **not** for isolating paths touched by **prior serialized tasks** on the same lane.
|
|
54
|
+
|
|
55
|
+
**How verify works today:** Final contract verify compares changed files on the lane branch against each pattern (currently `main...HEAD` cumulative diff until per-task scoping lands in SP-416). On a serialized lane, commits from earlier tasks remain in that diff — so `fileScopeMustNotChange` can fail even when the current worker behaved correctly.
|
|
56
|
+
|
|
57
|
+
**Planner overlap warning:** When `spine plan` reports:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
File scope overlaps (tasks serialized to the same lane):
|
|
61
|
+
Wave N: SP-AAA ↔ SP-BBB
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
those tasks run **sequentially on one lane**, not in parallel. Do **not** rely on `fileScopeMustNotChange` to separate them; use distinct `fileScopeMustChange` paths or accept cumulative diff semantics until per-task verify ships. The overlap warning means **concurrency is already prevented** — `fileScopeMustNotChange` targets **different lanes** editing the same product path in the same wave.
|
|
65
|
+
|
|
66
|
+
### Never ban `spine-tasks/**`
|
|
67
|
+
|
|
68
|
+
Workers **must** update `STATUS.md`, create `.DONE`, and may write `.reviews/`. These orchestration artifacts are not product-code scope violations.
|
|
69
|
+
|
|
70
|
+
- **Never** list `spine-tasks/**` in `fileScopeMustNotChange`.
|
|
71
|
+
- **Never** list the **current task folder** (e.g. `spine-tasks/SP-410-*/**`) — it blocks required worker outputs.
|
|
72
|
+
|
|
73
|
+
**Good** (parallel collision guard on product paths):
|
|
74
|
+
|
|
75
|
+
```markdown
|
|
76
|
+
| fileScopeMustNotChange | `extension/**`, `.spine/**` |
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Bad** (blocks required worker artifacts — fails `contract.verified` even when implementation is correct):
|
|
80
|
+
|
|
81
|
+
```markdown
|
|
82
|
+
| fileScopeMustNotChange | `extension/**`, `.spine/**`, `spine-tasks/**` |
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Bad** (blocks current task's `STATUS.md` and `.DONE`):
|
|
86
|
+
|
|
87
|
+
```markdown
|
|
88
|
+
| fileScopeMustNotChange | `spine-tasks/SP-410-contract-template-parallel-semantics/**` |
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Symptom in journal: `testCommand` passes but `fileScopeMustNotChange` fails with messages like `forbidden change spine-tasks/SP-001/STATUS.md` or `.DONE`.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
43
95
|
## Examples
|
|
44
96
|
|
|
45
97
|
### Minimal S task (code change)
|
|
@@ -106,6 +158,46 @@ Recommended: **240** minutes for jobs expected to run 2+ hours. Size S floor (90
|
|
|
106
158
|
|
|
107
159
|
---
|
|
108
160
|
|
|
161
|
+
## Cross-model authoring (worker ≠ reviewer)
|
|
162
|
+
|
|
163
|
+
When the worker model differs from the reviewer model (e.g. worker `cursor/auto`, reviewer `google/gemini-3.1-pro-preview`), contract shape directly affects review outcomes. The most common cross-model failure is `review_exhausted` caused by broad `testCommand` or missing context — not reviewer rejection of code quality.
|
|
164
|
+
|
|
165
|
+
### Scoped `testCommand`
|
|
166
|
+
|
|
167
|
+
Lane worktrees are **not** identical to the developer checkout. Worktree setup hooks, missing assets, pre-existing test failures, and Flutter/monorepo full-suite pollution can cause a scoped worker to pass targeted tests while the unscoped `testCommand` in Contract fails at final verify.
|
|
168
|
+
|
|
169
|
+
| Avoid | Prefer |
|
|
170
|
+
|-------|--------|
|
|
171
|
+
| `` `flutter test` `` / `` `npm test` `` (full suite in lane worktree) | Targeted command matching the Testing step: `` `flutter test test/unit/services/foo_test.dart` `` |
|
|
172
|
+
| Same command in Contract and global `testing.test` without verifying lane compatibility | Document when to use `` `true` `` (docs-only) vs scoped shell proof |
|
|
173
|
+
| Unscoped command producing >10 MB stdout (SP-426 `maxBuffer`) | Narrow test scope; prefer `npm test -- tests/feature.test.mjs` |
|
|
174
|
+
|
|
175
|
+
**Engine-side lane fixes:** [#78](https://github.com/beettlle/pi-spine/issues/78), [#80](https://github.com/beettlle/pi-spine/issues/80) track worktree setup hook and analyzer hygiene — docs alone cannot fix lane environment drift.
|
|
176
|
+
|
|
177
|
+
### Self-contained PROMPT for independent reviewers
|
|
178
|
+
|
|
179
|
+
Reviewers spawn as **fresh sessions** with no memory of the worker session (FR-REV-04). Cross-model reviewers receive:
|
|
180
|
+
|
|
181
|
+
| Worker sees | Reviewer sees |
|
|
182
|
+
|-------------|---------------|
|
|
183
|
+
| `taskplane-worker-cursor.mdc`, glob-matched language standards | Bounded rule subset via `profile.reviewer.*` (FR-REV-08); worker/authoring rules excluded |
|
|
184
|
+
| `referenceDocs` (e.g. `docs/constitution.md`) | **Not** auto-loaded; 16 KiB rule cap |
|
|
185
|
+
| Full PROMPT + STATUS in session, accumulated context | Fresh spawn; review request + diff + Contract only |
|
|
186
|
+
|
|
187
|
+
**Authoring implication:** Place acceptance criteria, spec references, and "done means" in PROMPT `## Mission`, `## Contract`, and step checkboxes — do not assume the reviewer read `IMPLEMENTATION.md`, domain plans, or `referenceDocs` unless quoted verbatim in PROMPT.
|
|
188
|
+
|
|
189
|
+
### `testCommand` decision table
|
|
190
|
+
|
|
191
|
+
| Task type | Recommended `testCommand` |
|
|
192
|
+
|-----------|---------------------------|
|
|
193
|
+
| Docs-only, no code changes | `` `true` `` |
|
|
194
|
+
| Single module, targeted tests exist | `` `npm test -- tests/feature.test.mjs` `` or `` `flutter test test/unit/services/foo_test.dart` `` |
|
|
195
|
+
| Full-suite safe in lane worktree | `` `npm run typecheck && SPINE_WORKER_STUB=1 npm test` `` |
|
|
196
|
+
| Coverage gate required (pi-spine ≥77%) | `` `npm run coverage:check` `` |
|
|
197
|
+
| Long external job (>2h) | Scoped command + `stallTimeoutMinutes` and `extendGraceOnFileScope` in Contract (see SP-314 example above) |
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
109
201
|
## Validate before plan
|
|
110
202
|
|
|
111
203
|
After authoring packets, run:
|
|
@@ -9,11 +9,12 @@ import {
|
|
|
9
9
|
isPostMergeLimbo,
|
|
10
10
|
} from "./post-merge-limbo.mjs";
|
|
11
11
|
import { detectPostMergeLimboForResume } from "./resume-multi-validate.mjs";
|
|
12
|
+
import { isProcessAlive } from "../process/liveness.mjs";
|
|
12
13
|
import { terminateStaleDetachedEngine } from "./resume-engine.mjs";
|
|
13
14
|
import { reconcileBatch } from "./reconcile.mjs";
|
|
14
|
-
import {
|
|
15
|
+
import { readJournalEventsCached } from "./journal.mjs";
|
|
15
16
|
import { enforceOperatorPauseOnDisk } from "./pause.mjs";
|
|
16
|
-
import { loadSpineBatchState, saveSpineBatchState } from "./state.mjs";
|
|
17
|
+
import { loadSpineBatchState, readBatchEnginePid, saveSpineBatchState } from "./state.mjs";
|
|
17
18
|
|
|
18
19
|
/** Journal types surfaced on attached stdout during the land loop. */
|
|
19
20
|
export const ATTACHED_LAND_LOOP_MILESTONE_TYPES = new Set([
|
|
@@ -116,7 +117,7 @@ export async function startAttachedMilestoneReporter({ projectRoot, write = (lin
|
|
|
116
117
|
batchId = loaded.raw?.batchId ? String(loaded.raw.batchId) : null;
|
|
117
118
|
}
|
|
118
119
|
if (batchId) {
|
|
119
|
-
const events =
|
|
120
|
+
const events = readJournalEventsCached(projectRoot, batchId);
|
|
120
121
|
for (const event of events) {
|
|
121
122
|
const key = milestoneEventKey(event);
|
|
122
123
|
if (printed.has(key)) continue;
|
|
@@ -136,7 +137,7 @@ export async function startAttachedMilestoneReporter({ projectRoot, write = (lin
|
|
|
136
137
|
stopped = true;
|
|
137
138
|
await loopPromise;
|
|
138
139
|
if (batchId) {
|
|
139
|
-
const events =
|
|
140
|
+
const events = readJournalEventsCached(projectRoot, batchId);
|
|
140
141
|
for (const event of events) {
|
|
141
142
|
const key = milestoneEventKey(event);
|
|
142
143
|
if (printed.has(key)) continue;
|
|
@@ -149,6 +150,59 @@ export async function startAttachedMilestoneReporter({ projectRoot, write = (lin
|
|
|
149
150
|
};
|
|
150
151
|
}
|
|
151
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Reject a second attached engine when resilience.enginePid is alive (SP-434, GitHub #89).
|
|
155
|
+
*
|
|
156
|
+
* @param {object} params
|
|
157
|
+
* @param {string} params.projectRoot
|
|
158
|
+
* @param {boolean} [params.force] Orphan-terminate prior engine before handoff
|
|
159
|
+
* @param {"start"|"resume"} [params.operation]
|
|
160
|
+
*/
|
|
161
|
+
export function enforceAttachedEngineSingleOwner({ projectRoot, force = false, operation = "resume" }) {
|
|
162
|
+
const loaded = loadSpineBatchState(projectRoot);
|
|
163
|
+
const state = loaded.raw;
|
|
164
|
+
if (!state) {
|
|
165
|
+
return { ok: true };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const batchId = String(state.batchId ?? "");
|
|
169
|
+
const enginePid = readBatchEnginePid(state);
|
|
170
|
+
if (enginePid == null || enginePid === process.pid || !isProcessAlive(enginePid)) {
|
|
171
|
+
return { ok: true };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const fromPhase = String(state.phase ?? "");
|
|
175
|
+
if (force) {
|
|
176
|
+
const terminateResult = terminateStaleDetachedEngine({
|
|
177
|
+
projectRoot,
|
|
178
|
+
state,
|
|
179
|
+
batchId,
|
|
180
|
+
fromPhase,
|
|
181
|
+
allowRunningOrphanTerminate: true,
|
|
182
|
+
});
|
|
183
|
+
saveSpineBatchState(projectRoot, state, { bypassWriteGuard: true });
|
|
184
|
+
return {
|
|
185
|
+
ok: true,
|
|
186
|
+
handoff: true,
|
|
187
|
+
terminated: terminateResult.terminated,
|
|
188
|
+
stalePid: terminateResult.stalePid ?? enginePid,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const operationLabel = operation === "start" ? "start" : "resume";
|
|
193
|
+
const output =
|
|
194
|
+
`Attached batch engine already running (PID ${enginePid}, batch ${batchId}).\n` +
|
|
195
|
+
`Stop the existing engine or run spine batch ${operationLabel} --attached --force to orphan it first.\n`;
|
|
196
|
+
return {
|
|
197
|
+
ok: false,
|
|
198
|
+
exitCode: 1,
|
|
199
|
+
error: "attached_engine_already_running",
|
|
200
|
+
output,
|
|
201
|
+
batchId,
|
|
202
|
+
enginePid,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
152
206
|
/**
|
|
153
207
|
* Run an attached foreground engine while streaming land-loop journal milestones to stdout.
|
|
154
208
|
*
|
|
@@ -156,8 +210,30 @@ export async function startAttachedMilestoneReporter({ projectRoot, write = (lin
|
|
|
156
210
|
* @param {string} params.projectRoot
|
|
157
211
|
* @param {() => Promise<object>} params.runEngine
|
|
158
212
|
* @param {(line: string) => void} [params.write]
|
|
213
|
+
* @param {boolean} [params.force]
|
|
214
|
+
* @param {"start"|"resume"} [params.operation]
|
|
159
215
|
*/
|
|
160
|
-
export async function runAttachedBatchEngine({
|
|
216
|
+
export async function runAttachedBatchEngine({
|
|
217
|
+
projectRoot,
|
|
218
|
+
runEngine,
|
|
219
|
+
write,
|
|
220
|
+
spineBin,
|
|
221
|
+
force = false,
|
|
222
|
+
operation = "resume",
|
|
223
|
+
}) {
|
|
224
|
+
if (operation === "start") {
|
|
225
|
+
const lock = enforceAttachedEngineSingleOwner({ projectRoot, force: false, operation: "start" });
|
|
226
|
+
if (!lock.ok) {
|
|
227
|
+
return {
|
|
228
|
+
ok: false,
|
|
229
|
+
exitCode: lock.exitCode ?? 1,
|
|
230
|
+
error: lock.error,
|
|
231
|
+
output: lock.output,
|
|
232
|
+
batchId: lock.batchId,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
161
237
|
installAttachedExitFinalizeHandlers({ projectRoot, spineBin });
|
|
162
238
|
const reporter = await startAttachedMilestoneReporter({ projectRoot, write });
|
|
163
239
|
try {
|