pi-spine 2.15.0 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/create-spine-tasks/SKILL.md +3 -1
- package/skills/create-spine-tasks/references/contract-template.md +12 -12
- package/skills/create-spine-tasks/references/prompt-template.md +8 -6
- package/skills/spine-autonomous-operator/SKILL.md +2 -0
- package/skills/spine-autonomous-operator/references/agent-shell-batch-policy.md +1 -1
- package/skills/spine-orchestrate-waves/SKILL.md +6 -4
- package/skills/spine-orchestrate-waves/references/outer-loop.md +16 -1
- package/skills/spine-release-operator/SKILL.md +63 -7
- package/skills/spine-release-operator/references/issue-intake-checklist.md +1 -1
- package/skills/spine-release-operator/references/pi-async-orchestration.md +2 -1
- package/skills/spine-release-operator/references/post-integrate-regression-gate.md +15 -0
- package/src/batch/abort.mjs +82 -68
- package/src/batch/batch-guards.mjs +14 -0
- package/src/batch/batch-meta-reconstruct.mjs +5 -2
- package/src/batch/batch-state-lock.mjs +357 -0
- package/src/batch/contract-exec.mjs +12 -8
- package/src/batch/engine-lanes/merge.mjs +16 -11
- package/src/batch/engine-lanes/phase.mjs +45 -0
- package/src/batch/engine-lanes/queue.mjs +1 -1
- package/src/batch/engine-lanes/review-code.mjs +224 -0
- package/src/batch/engine-lanes/review-final.mjs +318 -0
- package/src/batch/engine-lanes/review-plan.mjs +315 -0
- package/src/batch/engine-lanes/review-poll.mjs +427 -0
- package/src/batch/engine-lanes/review-stub.mjs +146 -0
- package/src/batch/engine-lanes/review.mjs +4 -1532
- package/src/batch/engine-lanes.mjs +9 -37
- package/src/batch/engine.mjs +8 -16
- package/src/batch/lifecycle.mjs +106 -95
- package/src/batch/post-merge-finalize.mjs +128 -0
- package/src/batch/post-merge-limbo.mjs +14 -85
- package/src/batch/readers/spine-state.mjs +22 -1
- package/src/batch/readers/taskplane-state.mjs +22 -1
- package/src/batch/reconcile-batch.mjs +1 -1
- package/src/batch/resume-common.mjs +1 -1
- package/src/batch/resume-multi.mjs +6 -2
- package/src/batch/resume.mjs +1 -1
- package/src/batch/review-spawn.mjs +4 -3
- package/src/batch/state-io.mjs +55 -41
- package/src/cli/journal-follow.mjs +3 -1
- package/src/cli/lane-logs.mjs +3 -1
- package/src/cli/settings-slash.mjs +2 -1
- package/src/config/cursor-rules/profile.mjs +5 -1
- package/src/config/defaults.mjs +10 -1
- package/src/config/settings-fields.mjs +14 -0
- package/src/config/worker-context.mjs +2 -1
- package/src/planner/file-scope.mjs +109 -7
- package/src/tasks/analyze/index.mjs +16 -28
- package/src/tasks/packet/parse-prompt.mjs +138 -3
- package/src/tasks/validate-contract-warn.mjs +45 -0
|
@@ -37,6 +37,112 @@ const CONTRACT_TABLE_HEADER_RE = /^\|\s*Field\s*\|\s*Value\s*\|$/i;
|
|
|
37
37
|
const CONTRACT_TABLE_SEPARATOR_RE = /^\|[\s\-:|]+\|$/;
|
|
38
38
|
const CONTRACT_TABLE_ROW_RE = /^\|\s*([^|]+?)\s*\|\s*([^|]+?)\s*\|$/;
|
|
39
39
|
const TEST_COMMAND_MAX_LENGTH = 500;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Quote-aware scan for shell metacharacters forbidden in contract commands (#268).
|
|
43
|
+
*
|
|
44
|
+
* Contract testCommand / runCommand execute through a shell, so expansion and
|
|
45
|
+
* sequencing operators are an injection surface. Mirrors the #254 gate-evidence
|
|
46
|
+
* grammar: `&&` stays the only allowed chain separator (house style is
|
|
47
|
+
* `npm run typecheck && node --test …`), while `$`, backticks, `;`, `|` (which
|
|
48
|
+
* covers `||`), a lone `&`, and unquoted newlines fail closed. Single-quoted
|
|
49
|
+
* text is literal data (`printf '%s' 'a | b'` stays valid); `$` and backticks
|
|
50
|
+
* are rejected even inside double quotes because they still expand there;
|
|
51
|
+
* unclosed quotes fail closed.
|
|
52
|
+
*
|
|
53
|
+
* @param {string} command
|
|
54
|
+
* @returns {string | null} rejection reason, or null when the command is safe
|
|
55
|
+
*/
|
|
56
|
+
export function findContractCommandMetacharIssue(command) {
|
|
57
|
+
const text = String(command ?? "");
|
|
58
|
+
/** @type {"'" | '"' | null} */
|
|
59
|
+
let quote = null;
|
|
60
|
+
|
|
61
|
+
for (let i = 0; i < text.length; i++) {
|
|
62
|
+
const ch = text[i];
|
|
63
|
+
|
|
64
|
+
if (quote === "'") {
|
|
65
|
+
// Single-quoted content is literal in POSIX shells; only the closing
|
|
66
|
+
// quote matters, so metacharacters there are data, not syntax.
|
|
67
|
+
if (ch === "'") quote = null;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (ch === "\\" && i + 1 < text.length) {
|
|
72
|
+
// Escaped characters are literal outside quotes and inside double
|
|
73
|
+
// quotes, so `\;` / `\$` cannot sequence or expand anything.
|
|
74
|
+
i += 1;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (quote === '"') {
|
|
79
|
+
if (ch === '"') {
|
|
80
|
+
quote = null;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
// `$` and backticks expand inside double quotes; other characters are
|
|
84
|
+
// literal there, so quoted `;` / `|` data is allowed.
|
|
85
|
+
if (ch === "$") return "shell variable expansion ($ in double quotes)";
|
|
86
|
+
if (ch === "`") return "shell command substitution (backticks in double quotes)";
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (ch === "'") {
|
|
91
|
+
quote = "'";
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (ch === '"') {
|
|
95
|
+
quote = '"';
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (ch === "$") return "shell variable expansion ($)";
|
|
99
|
+
if (ch === "`") return "shell command substitution (backticks)";
|
|
100
|
+
if (ch === ";") return "shell sequencing (;)";
|
|
101
|
+
if (ch === "|") return "shell pipe (| or ||)";
|
|
102
|
+
if (ch === "\n" || ch === "\r") return "shell sequencing (newline)";
|
|
103
|
+
if (ch === "&") {
|
|
104
|
+
if (text[i + 1] === "&") {
|
|
105
|
+
// `&&` is the documented chain separator (mirrors #254 Phase B).
|
|
106
|
+
i += 1;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
return "shell background operator (&)";
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (quote) return "unclosed quote";
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Defense in depth: reject shell metacharacters in contract testCommand before the
|
|
119
|
+
* shell spawns (#268). `&&` chains stay allowed (mirrors the #254 gate-evidence
|
|
120
|
+
* grammar); `$`, backticks, `;`, `|`, `||`, and lone `&` fail closed. The runtime
|
|
121
|
+
* guard is the enforcement boundary because matrix row substitution can reintroduce
|
|
122
|
+
* metacharacters after parse-time validation.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} command
|
|
125
|
+
* @returns {boolean}
|
|
126
|
+
*/
|
|
127
|
+
export function isRefusedContractMetacharCommand(command) {
|
|
128
|
+
const trimmed = String(command ?? "").trim();
|
|
129
|
+
if (!trimmed || trimmed === "true") {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
return findContractCommandMetacharIssue(trimmed) !== null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Refusal copy for the contract verify path — deliberately distinct from the #254
|
|
137
|
+
* gate-evidence messages ("evidence command contains …").
|
|
138
|
+
*
|
|
139
|
+
* @param {string} command
|
|
140
|
+
* @returns {string}
|
|
141
|
+
*/
|
|
142
|
+
export function formatRefusedContractMetacharMessage(command) {
|
|
143
|
+
const issue = findContractCommandMetacharIssue(String(command ?? "").trim());
|
|
144
|
+
return `Contract testCommand refused before spawn: ${issue ?? "shell metacharacters"} (command: ${command}). Contract testCommand runs through a shell; remove $, backticks, ;, |, || or lone & — && chains are allowed (#268).`;
|
|
145
|
+
}
|
|
40
146
|
export const SEE_FILE_SCOPE_RE = /^see\s+file\s+scope$/i;
|
|
41
147
|
const CONTRACT_EM_DASH_PLACEHOLDER_RE = /^[—\-]$/;
|
|
42
148
|
const CONTRACT_NONE_VALUES = new Set([
|
|
@@ -298,6 +404,9 @@ export function resolveContractFileScopeReferences(parsed, fileScopePaths) {
|
|
|
298
404
|
parsed.fileScopeMustChange = [...new Set(expanded)];
|
|
299
405
|
}
|
|
300
406
|
|
|
407
|
+
const CONTRACT_METACHAR_FIX_HINT =
|
|
408
|
+
"contract commands reject $, backticks, ;, |, || and lone & — && chains are allowed (#268)";
|
|
409
|
+
|
|
301
410
|
/**
|
|
302
411
|
* @param {ReturnType<typeof parseContract>} parsed
|
|
303
412
|
* @param {string} field
|
|
@@ -320,6 +429,13 @@ function applyContractField(parsed, field, rawValue) {
|
|
|
320
429
|
parsed.errors.push(`Contract testCommand exceeds ${TEST_COMMAND_MAX_LENGTH} characters`);
|
|
321
430
|
return;
|
|
322
431
|
}
|
|
432
|
+
const testCommandIssue = findContractCommandMetacharIssue(command);
|
|
433
|
+
if (testCommandIssue) {
|
|
434
|
+
parsed.errors.push(
|
|
435
|
+
`Contract testCommand contains forbidden shell metacharacters: ${testCommandIssue}; ${CONTRACT_METACHAR_FIX_HINT}`,
|
|
436
|
+
);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
323
439
|
parsed.testCommand = command;
|
|
324
440
|
return;
|
|
325
441
|
}
|
|
@@ -333,6 +449,13 @@ function applyContractField(parsed, field, rawValue) {
|
|
|
333
449
|
parsed.errors.push(`Contract runCommand exceeds ${TEST_COMMAND_MAX_LENGTH} characters`);
|
|
334
450
|
return;
|
|
335
451
|
}
|
|
452
|
+
const runCommandIssue = findContractCommandMetacharIssue(command);
|
|
453
|
+
if (runCommandIssue) {
|
|
454
|
+
parsed.errors.push(
|
|
455
|
+
`Contract runCommand contains forbidden shell metacharacters: ${runCommandIssue}; ${CONTRACT_METACHAR_FIX_HINT}`,
|
|
456
|
+
);
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
336
459
|
parsed.runCommand = command;
|
|
337
460
|
return;
|
|
338
461
|
}
|
|
@@ -511,19 +634,31 @@ export function parsePromptDependencies(depsSection) {
|
|
|
511
634
|
}
|
|
512
635
|
|
|
513
636
|
const ids = [];
|
|
637
|
+
// Set-backed membership so dedup is O(1) per line instead of O(N) (#271);
|
|
638
|
+
// `ids` keeps first-seen bullet order for the return value.
|
|
639
|
+
const seenIds = new Set();
|
|
514
640
|
for (const line of depsSection.split(/\r?\n/)) {
|
|
515
641
|
const bullet = line.match(/^-\s+\*{0,2}([A-Z][A-Z0-9]*-\d+)\*{0,2}/);
|
|
516
642
|
if (bullet) {
|
|
517
|
-
if (!
|
|
643
|
+
if (!seenIds.has(bullet[1])) {
|
|
644
|
+
seenIds.add(bullet[1]);
|
|
645
|
+
ids.push(bullet[1]);
|
|
646
|
+
}
|
|
518
647
|
continue;
|
|
519
648
|
}
|
|
520
649
|
const bare = line.match(/^-\s+([A-Z][A-Z0-9]*-\d+)\b/);
|
|
521
650
|
if (bare) {
|
|
522
|
-
if (!
|
|
651
|
+
if (!seenIds.has(bare[1])) {
|
|
652
|
+
seenIds.add(bare[1]);
|
|
653
|
+
ids.push(bare[1]);
|
|
654
|
+
}
|
|
523
655
|
continue;
|
|
524
656
|
}
|
|
525
657
|
const requires = line.match(/\*+Requires:\*+\s*(?:[a-z0-9-]+\/)?([A-Z][A-Z0-9]*-\d+)/i);
|
|
526
|
-
if (requires && !
|
|
658
|
+
if (requires && !seenIds.has(requires[1])) {
|
|
659
|
+
seenIds.add(requires[1]);
|
|
660
|
+
ids.push(requires[1]);
|
|
661
|
+
}
|
|
527
662
|
}
|
|
528
663
|
return ids;
|
|
529
664
|
}
|
|
@@ -15,7 +15,23 @@ export const TEST_COMMAND_NPM_TEST_FIX_HINT =
|
|
|
15
15
|
export const TEST_COMMAND_NPM_TEST_DASH_DASH_FIX_HINT =
|
|
16
16
|
"npm test -- <path> runs the full suite, not the path argument. Use scoped node --test path/to.test.mjs instead.";
|
|
17
17
|
|
|
18
|
+
/** Code tasks should chain project lint/analyze in Contract testCommand (post-mortem v2.15.0 F-C). */
|
|
19
|
+
export const TEST_COMMAND_LINT_MISSING_FIX_HINT =
|
|
20
|
+
"Prefix Contract testCommand with project lint/analyze (pi-spine: npm run lint &&). Docs-only testCommand: true is exempt.";
|
|
21
|
+
|
|
18
22
|
const PATCH_TASK_SIZES = new Set(["S", "M"]);
|
|
23
|
+
const LINT_IN_TEST_COMMAND_RE = /\b(?:lint|eslint|analyze)\b/;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {string | null | undefined} testCommand
|
|
27
|
+
* @returns {boolean}
|
|
28
|
+
*/
|
|
29
|
+
function testCommandIncludesLintOrAnalyze(testCommand) {
|
|
30
|
+
if (!testCommand || testCommand === "true") {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return LINT_IN_TEST_COMMAND_RE.test(testCommand);
|
|
34
|
+
}
|
|
19
35
|
|
|
20
36
|
/** Matches `npm test --` followed by at least one path/token argument. */
|
|
21
37
|
export const NPM_TEST_DASH_DASH_RE = /\bnpm\s+test\s+--\s+\S+/;
|
|
@@ -94,6 +110,33 @@ export function collectNpmTestDashDashWarnings(parsed, options = {}) {
|
|
|
94
110
|
return [formatNpmTestDashDashIssue(taskSize)];
|
|
95
111
|
}
|
|
96
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Warn when code-task contracts omit project lint/analyze from testCommand (post-mortem v2.15.0 F-C).
|
|
115
|
+
*
|
|
116
|
+
* @param {ReturnType<import("./packet/parse-prompt.mjs").parseContract>} parsed
|
|
117
|
+
* @param {{ taskSize?: "S"|"M"|"L"|"XL"|null }} [options]
|
|
118
|
+
* @returns {string[]}
|
|
119
|
+
*/
|
|
120
|
+
export function collectLintMissingWarnings(parsed, options = {}) {
|
|
121
|
+
const taskSize = options.taskSize ?? null;
|
|
122
|
+
if (taskSize !== "S" && taskSize !== "M" && taskSize !== "L") {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const testCommand = parsed?.testCommand;
|
|
127
|
+
if (!testCommand || testCommand === "true") {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (testCommandIncludesLintOrAnalyze(testCommand)) {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return [
|
|
136
|
+
`Contract testCommand omits project lint/analyze on Size ${taskSize} code task. ${TEST_COMMAND_LINT_MISSING_FIX_HINT}`,
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
|
|
97
140
|
/**
|
|
98
141
|
* Warn when S/M task contracts chain full-suite gates in testCommand.
|
|
99
142
|
*
|
|
@@ -129,11 +172,13 @@ export function collectTestCommandScopeWarnings(parsed, options = {}) {
|
|
|
129
172
|
);
|
|
130
173
|
}
|
|
131
174
|
|
|
175
|
+
warnings.push(...collectLintMissingWarnings(parsed, { taskSize }));
|
|
132
176
|
return warnings;
|
|
133
177
|
}
|
|
134
178
|
|
|
135
179
|
if (taskSize === "L") {
|
|
136
180
|
warnings.push(...collectNpmTestDashDashWarnings(parsed, { taskSize, mode }));
|
|
181
|
+
warnings.push(...collectLintMissingWarnings(parsed, { taskSize }));
|
|
137
182
|
}
|
|
138
183
|
|
|
139
184
|
return warnings;
|