pi-spine 1.10.0 → 1.10.1

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.
@@ -20,6 +20,7 @@ import {
20
20
  formatAttachedBatchCliResult,
21
21
  runAttachedBatchEngine,
22
22
  } from "../src/batch/attached-runner.mjs";
23
+ import { enforceAttachedOrphanRiskGuard } from "../src/doctor/attached-orphan-risk.mjs";
23
24
 
24
25
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
25
26
 
@@ -355,6 +356,17 @@ export async function runSpineBatch(options) {
355
356
  }
356
357
 
357
358
  if (parsed.subcommand === "resume") {
359
+ if (parsed.attached) {
360
+ const orphanGuard = enforceAttachedOrphanRiskGuard();
361
+ if (!orphanGuard.ok) {
362
+ return {
363
+ exitCode: orphanGuard.exitCode ?? 1,
364
+ output: orphanGuard.output ?? "",
365
+ result: orphanGuard,
366
+ };
367
+ }
368
+ }
369
+
358
370
  if (!parsed.attached) {
359
371
  const waitTerminal = resolveDefaultResumeWaitTerminal(
360
372
  projectRoot,
@@ -398,6 +410,17 @@ export async function runSpineBatch(options) {
398
410
  }
399
411
 
400
412
  const useAttached = parsed.attached || parsed.dryRun;
413
+ if (parsed.attached && !parsed.dryRun) {
414
+ const orphanGuard = enforceAttachedOrphanRiskGuard();
415
+ if (!orphanGuard.ok) {
416
+ return {
417
+ exitCode: orphanGuard.exitCode ?? 1,
418
+ output: orphanGuard.output ?? "",
419
+ result: orphanGuard,
420
+ };
421
+ }
422
+ }
423
+
401
424
  if (!useAttached) {
402
425
  const detached = await startBatchDetached({
403
426
  projectRoot,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-spine",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "description": "Orchestration spine for long-running pi development",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -34,6 +34,7 @@ import {
34
34
  import { classifyTaskDoneSemantics } from "./diagnosis-task-done.mjs";
35
35
  import { resolveTasksRoot } from "../config/spine-preflight-lib.mjs";
36
36
  import { journalHasTaskCompleted } from "./resume-common.mjs";
37
+ import { startParentSessionMonitor } from "./parent-session-monitor.mjs";
37
38
 
38
39
  export { DEFAULT_ATTACHED_MILESTONE_POLL_MS } from "../config/spine-config-schema.mjs";
39
40
 
@@ -464,6 +465,16 @@ export async function runAttachedBatchEngine({
464
465
 
465
466
  installAttachedExitFinalizeHandlers({ projectRoot, spineBin });
466
467
  const reporter = await startAttachedMilestoneReporter({ projectRoot, write });
468
+ /** @type {{ stop: () => Promise<void> }} */
469
+ let parentMonitor = { stop: async () => {} };
470
+ if (process.env.SPINE_ALLOW_ATTACHED_HARNESS !== "1") {
471
+ parentMonitor = await startParentSessionMonitor({
472
+ projectRoot,
473
+ onParentDied: () => {
474
+ process.exit(1);
475
+ },
476
+ });
477
+ }
467
478
  try {
468
479
  const result = await runEngine();
469
480
  const handoff = finalizeAttachedLandLoopBeforeExit({ projectRoot, spineBin, signal: "exit" });
@@ -472,6 +483,7 @@ export async function runAttachedBatchEngine({
472
483
  }
473
484
  return result;
474
485
  } finally {
486
+ await parentMonitor.stop();
475
487
  await reporter.stop();
476
488
  }
477
489
  }
@@ -21,6 +21,10 @@ import {
21
21
  sanitizeFlutterBuildBeforeAnalyze,
22
22
  shouldCleanFlutterBuildBeforeAnalyze,
23
23
  } from "./lane-dirty-check.mjs";
24
+ import {
25
+ NPM_TEST_DASH_DASH_RE,
26
+ TEST_COMMAND_NPM_TEST_DASH_DASH_FIX_HINT,
27
+ } from "../tasks/validate-contract-warn.mjs";
24
28
 
25
29
  export { resolvePromptRelPath, isFileScopePatternPrelanded, hasSpineTaskDeliveryChanges } from "./contract-prelanded.mjs";
26
30
 
@@ -346,6 +350,28 @@ export function writeContractFailureLog(taskFolder, command, result, attempt, to
346
350
  return logPath;
347
351
  }
348
352
 
353
+ /**
354
+ * Defense in depth: block `npm test -- <path>` before subprocess spawn (issue #187, SP-541).
355
+ *
356
+ * @param {string} command
357
+ * @returns {boolean}
358
+ */
359
+ export function isRefusedNpmTestDashDashCommand(command) {
360
+ const trimmed = String(command ?? "").trim();
361
+ if (!trimmed || trimmed === "true") {
362
+ return false;
363
+ }
364
+ return NPM_TEST_DASH_DASH_RE.test(trimmed);
365
+ }
366
+
367
+ /**
368
+ * @param {string} command
369
+ * @returns {string}
370
+ */
371
+ function formatRefusedNpmTestDashDashMessage(command) {
372
+ return `Contract testCommand refused before spawn: npm test -- <path> is blocked at runtime (command: ${command}). ${TEST_COMMAND_NPM_TEST_DASH_DASH_FIX_HINT}`;
373
+ }
374
+
349
375
  /**
350
376
  * @param {string} worktreePath
351
377
  * @param {string} command
@@ -357,6 +383,17 @@ export function runContractTestCommand(worktreePath, command, options = {}) {
357
383
  return { ok: true, exitCode: 0, output: "" };
358
384
  }
359
385
 
386
+ if (isRefusedNpmTestDashDashCommand(trimmed)) {
387
+ const summary = formatRefusedNpmTestDashDashMessage(trimmed);
388
+ return {
389
+ ok: false,
390
+ exitCode: 1,
391
+ output: summary,
392
+ summary,
393
+ refusedBeforeSpawn: true,
394
+ };
395
+ }
396
+
360
397
  const maxBuffer = options.maxBuffer ?? CONTRACT_TEST_COMMAND_MAX_BUFFER;
361
398
  const shell = process.env.SHELL || (process.platform === "win32" ? "cmd.exe" : "/bin/sh");
362
399
  const shellFlag = process.platform === "win32" ? "/c" : "-c";
@@ -69,7 +69,11 @@ export function spawnDetachedBatchEngine({ projectRoot, spineBin, argv }) {
69
69
  cwd: projectRoot,
70
70
  detached: true,
71
71
  stdio: ["ignore", logFd, logFd],
72
- env: process.env,
72
+ env: {
73
+ ...process.env,
74
+ // Detached parent intentionally spawns an attached engine subprocess (#163 / SP-539).
75
+ SPINE_ALLOW_ATTACHED_HARNESS: "1",
76
+ },
73
77
  });
74
78
  child.unref();
75
79
  fs.closeSync(logFd);
@@ -0,0 +1,201 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * Attached engine parent session monitor (FR-STAB-01, GitHub #163, SP-539).
4
+ *
5
+ * Detects parent shell/session loss while an attached batch engine runs and
6
+ * reconciles orphan running tasks before the operator resumes detached.
7
+ */
8
+
9
+ import { isProcessAlive } from "../process/liveness.mjs";
10
+ import { loadSpineConfig } from "../config/spine-config-load.mjs";
11
+ import { resolveAttachedMilestonePollMs } from "../config/spine-config-schema.mjs";
12
+ import { appendJournalEvent } from "./journal.mjs";
13
+ import {
14
+ clearBatchEnginePid,
15
+ loadSpineBatchState,
16
+ readBatchEnginePid,
17
+ recomputeTaskCounters,
18
+ saveSpineBatchState,
19
+ updateSegmentForTask,
20
+ } from "./state.mjs";
21
+
22
+ /**
23
+ * @param {number} ms
24
+ */
25
+ function sleep(ms) {
26
+ return new Promise((resolve) => setTimeout(resolve, ms));
27
+ }
28
+
29
+ /**
30
+ * Parent session is lost when the process reparented or the recorded parent PID died.
31
+ *
32
+ * @param {object} params
33
+ * @param {number} params.initialParentPid
34
+ * @param {number} [params.currentParentPid]
35
+ * @param {(pid: number) => boolean} [params.isAlive]
36
+ */
37
+ export function isParentSessionLost({
38
+ initialParentPid,
39
+ currentParentPid = process.ppid,
40
+ isAlive = isProcessAlive,
41
+ }) {
42
+ const initial = Number(initialParentPid);
43
+ const current = Number(currentParentPid);
44
+ if (!Number.isFinite(initial) || initial <= 0) {
45
+ return false;
46
+ }
47
+ if (!Number.isFinite(current) || current <= 0) {
48
+ return true;
49
+ }
50
+ if (current !== initial) {
51
+ return true;
52
+ }
53
+ return !isAlive(current);
54
+ }
55
+
56
+ /**
57
+ * Fail-closed reconcile when the attached engine parent session is gone.
58
+ *
59
+ * @param {object} params
60
+ * @param {string} params.projectRoot
61
+ * @param {number} params.parentPid
62
+ * @param {number} [params.enginePid]
63
+ * @returns {{ handled: boolean, batchId?: string, taskIds?: string[] }}
64
+ */
65
+ export function reconcileParentSessionLost({ projectRoot, parentPid, enginePid = process.pid }) {
66
+ const loaded = loadSpineBatchState(projectRoot);
67
+ const state = loaded.raw;
68
+ if (!state || typeof state !== "object") {
69
+ return { handled: false };
70
+ }
71
+
72
+ const batchId = String(state.batchId ?? "");
73
+ if (!batchId) {
74
+ return { handled: false };
75
+ }
76
+
77
+ const phase = String(state.phase ?? "");
78
+ if (phase === "completed" || phase === "aborted" || phase === "failed") {
79
+ return { handled: false, batchId };
80
+ }
81
+
82
+ appendJournalEvent(projectRoot, batchId, "engine.parent_died", {
83
+ parentPid,
84
+ enginePid,
85
+ signal: "parent_exit",
86
+ });
87
+
88
+ const now = Date.now();
89
+ /** @type {string[]} */
90
+ const failedTaskIds = [];
91
+ let changed = false;
92
+
93
+ for (const task of state.tasks ?? []) {
94
+ if (!task || typeof task !== "object") continue;
95
+ if (String(task.status ?? "").toLowerCase() !== "running") continue;
96
+
97
+ const taskId = String(task.taskId ?? "");
98
+ if (!taskId) continue;
99
+
100
+ task.status = "failed";
101
+ task.endedAt = now;
102
+ task.exitReason = "parent_exit";
103
+ updateSegmentForTask(state, taskId, "failed");
104
+ failedTaskIds.push(taskId);
105
+ changed = true;
106
+
107
+ const laneNumber = Number(task.laneNumber ?? 1);
108
+ const lane = (state.lanes ?? []).find((entry) => Number(entry?.laneNumber) === laneNumber);
109
+ appendJournalEvent(projectRoot, batchId, "task.failed", {
110
+ taskId,
111
+ laneNumber,
112
+ laneId: lane?.laneId ?? `lane-${laneNumber}`,
113
+ reason: "parent_exit",
114
+ reconciled: true,
115
+ });
116
+ }
117
+
118
+ for (const lane of state.lanes ?? []) {
119
+ if (!lane || typeof lane !== "object") continue;
120
+ const workerPid = Number(/** @type {{ workerPid?: number }} */ (lane).workerPid);
121
+ if (Number.isFinite(workerPid) && workerPid > 0 && !isProcessAlive(workerPid)) {
122
+ delete lane.workerPid;
123
+ changed = true;
124
+ }
125
+ }
126
+
127
+ const recordedEnginePid = readBatchEnginePid(state);
128
+ if (recordedEnginePid != null) {
129
+ clearBatchEnginePid(state);
130
+ changed = true;
131
+ }
132
+
133
+ if (phase !== "paused") {
134
+ state.phase = "paused";
135
+ changed = true;
136
+ }
137
+
138
+ if (!changed) {
139
+ return { handled: true, batchId, taskIds: failedTaskIds };
140
+ }
141
+
142
+ recomputeTaskCounters(state);
143
+ saveSpineBatchState(projectRoot, state, { bypassWriteGuard: true });
144
+ return { handled: true, batchId, taskIds: failedTaskIds };
145
+ }
146
+
147
+ /**
148
+ * @param {object} params
149
+ * @param {string} params.projectRoot
150
+ * @param {number} [params.pollIntervalMs]
151
+ * @param {(pid: number) => boolean} [params.isAlive]
152
+ * @param {() => number} [params.readParentPid]
153
+ * @param {(result: ReturnType<typeof reconcileParentSessionLost>) => void} [params.onParentDied]
154
+ * @returns {Promise<{ stop: () => Promise<void> }>}
155
+ */
156
+ export async function startParentSessionMonitor({
157
+ projectRoot,
158
+ pollIntervalMs,
159
+ isAlive = isProcessAlive,
160
+ readParentPid = () => process.ppid,
161
+ onParentDied,
162
+ }) {
163
+ const configResult = loadSpineConfig(projectRoot);
164
+ const resolvedPollMs =
165
+ pollIntervalMs ??
166
+ resolveAttachedMilestonePollMs({ config: configResult.config ?? {} });
167
+ const initialParentPid = readParentPid();
168
+ let stopped = false;
169
+ let handled = false;
170
+
171
+ const loop = async () => {
172
+ while (!stopped) {
173
+ if (
174
+ !handled &&
175
+ isParentSessionLost({
176
+ initialParentPid,
177
+ currentParentPid: readParentPid(),
178
+ isAlive,
179
+ })
180
+ ) {
181
+ handled = true;
182
+ const result = reconcileParentSessionLost({
183
+ projectRoot,
184
+ parentPid: initialParentPid,
185
+ enginePid: process.pid,
186
+ });
187
+ onParentDied?.(result);
188
+ }
189
+ await sleep(resolvedPollMs);
190
+ }
191
+ };
192
+
193
+ const loopPromise = loop();
194
+
195
+ return {
196
+ stop: async () => {
197
+ stopped = true;
198
+ await loopPromise;
199
+ },
200
+ };
201
+ }
@@ -190,7 +190,18 @@ export function checkDoctor(ctx) {
190
190
  * @param {object} [_ctx]
191
191
  * @param {{ stalePathCheckArgs?: object }} [options]
192
192
  */
193
- export function checkStalePathSpine(_ctx = {}, options = {}) {
193
+ export function checkStalePathSpine(ctx = {}, options = {}) {
194
+ if (
195
+ ctx.projectRoot &&
196
+ path.resolve(ctx.projectRoot) !== path.resolve(PACKAGE_ROOT)
197
+ ) {
198
+ return makeCheck(
199
+ "stale-path-spine",
200
+ true,
201
+ "stale PATH spine check skipped (isolated project fixture)",
202
+ );
203
+ }
204
+
194
205
  const check = buildStalePathDoctorCheck({
195
206
  packageRoot: PACKAGE_ROOT,
196
207
  runningSpinePath: path.join(PACKAGE_ROOT, "bin", "spine.mjs"),
@@ -35,7 +35,7 @@ const AUTOMATION_ENV_PATTERNS = [
35
35
  { env: "CURSOR_SESSION_ID", id: "cursor_agent_shell", label: "Cursor agent shell" },
36
36
  ];
37
37
 
38
- const DETACHED_RESUME_SUGGESTED =
38
+ export const DETACHED_RESUME_SUGGESTED =
39
39
  "spine batch start|resume (omit --attached); spine wait --until completed,needs_integrate,failed,aborted --timeout 2h";
40
40
 
41
41
  /**
@@ -82,6 +82,40 @@ export function detectAttachedOrphanRiskPatterns({
82
82
  };
83
83
  }
84
84
 
85
+ /**
86
+ * Fail-fast guard for `batch start|resume --attached` in risky shell contexts (SP-539 / #163).
87
+ *
88
+ * @param {object} [options]
89
+ * @param {boolean} [options.stdinIsTTY]
90
+ * @param {NodeJS.ProcessEnv} [options.env]
91
+ */
92
+ export function enforceAttachedOrphanRiskGuard({
93
+ stdinIsTTY = process.stdin.isTTY === true,
94
+ env = process.env,
95
+ } = {}) {
96
+ if (env.SPINE_ALLOW_ATTACHED_HARNESS === "1") {
97
+ return { ok: true };
98
+ }
99
+
100
+ const { risky, patterns } = detectAttachedOrphanRiskPatterns({ stdinIsTTY, env });
101
+ if (!risky) {
102
+ return { ok: true };
103
+ }
104
+
105
+ const summary = patterns.map((pattern) => pattern.label).join("; ");
106
+ return {
107
+ ok: false,
108
+ exitCode: 1,
109
+ error: "attached_orphan_risk",
110
+ output:
111
+ `Refusing batch --attached in a risky shell context (#163).\n` +
112
+ `${summary}\n\n` +
113
+ `Parent shell exit orphans attached engines (exit 137). Use detached start instead:\n` +
114
+ ` ${DETACHED_RESUME_SUGGESTED}\n`,
115
+ patterns,
116
+ };
117
+ }
118
+
85
119
  /**
86
120
  * Doctor advisory for attached orphan risk (#163 partial mitigation).
87
121
  *
@@ -6,7 +6,10 @@
6
6
  import micromatch from "micromatch";
7
7
 
8
8
  import { matchesContractPattern } from "../../batch/contract-verify.mjs";
9
- import { collectTestCommandScopeWarnings } from "../validate-contract-warn.mjs";
9
+ import {
10
+ collectNpmTestDashDashErrors,
11
+ collectTestCommandScopeWarnings,
12
+ } from "../validate-contract-warn.mjs";
10
13
  import { detectCommaInSingleBacktickPathLists } from "./parse-prompt.mjs";
11
14
 
12
15
  /** Operator-facing hint when must-not-change blocks worker orchestration artifacts. */
@@ -116,9 +119,18 @@ export function validateContract(parsed, options = {}) {
116
119
  }),
117
120
  );
118
121
 
122
+ if (mode === "required") {
123
+ errors.push(
124
+ ...collectNpmTestDashDashErrors(parsed, {
125
+ taskSize: options.taskSize ?? null,
126
+ }),
127
+ );
128
+ }
129
+
119
130
  warnings.push(
120
131
  ...collectTestCommandScopeWarnings(parsed, {
121
132
  taskSize: options.taskSize ?? null,
133
+ mode,
122
134
  }),
123
135
  );
124
136
 
@@ -18,47 +18,92 @@ export const TEST_COMMAND_NPM_TEST_DASH_DASH_FIX_HINT =
18
18
  const PATCH_TASK_SIZES = new Set(["S", "M"]);
19
19
 
20
20
  /** Matches `npm test --` followed by at least one path/token argument. */
21
- const NPM_TEST_DASH_DASH_RE = /\bnpm\s+test\s+--\s+\S+/;
21
+ export const NPM_TEST_DASH_DASH_RE = /\bnpm\s+test\s+--\s+\S+/;
22
22
 
23
23
  /**
24
- * Warn when S/M task contracts use npm test -- <path> false scoping (issues #187, #141).
24
+ * @param {ReturnType<import("./packet/parse-prompt.mjs").parseContract>} parsed
25
+ * @returns {boolean}
26
+ */
27
+ function matchesNpmTestDashDashPattern(parsed) {
28
+ const testCommand = parsed?.testCommand;
29
+ if (!testCommand || testCommand === "true") {
30
+ return false;
31
+ }
32
+ return NPM_TEST_DASH_DASH_RE.test(testCommand);
33
+ }
34
+
35
+ /**
36
+ * @param {"S"|"M"|"L"} taskSize
37
+ * @returns {string}
38
+ */
39
+ function formatNpmTestDashDashIssue(taskSize) {
40
+ return `Contract testCommand uses npm test -- <path> on Size ${taskSize} patch task; npm runs the full suite, not the path. ${TEST_COMMAND_NPM_TEST_DASH_DASH_FIX_HINT}`;
41
+ }
42
+
43
+ /**
44
+ * Error when required-mode S/M contracts use npm test -- <path> false scoping (issue #187).
25
45
  *
26
46
  * @param {ReturnType<import("./packet/parse-prompt.mjs").parseContract>} parsed
27
47
  * @param {{ taskSize?: "S"|"M"|"L"|"XL"|null }} [options]
28
48
  * @returns {string[]}
29
49
  */
50
+ export function collectNpmTestDashDashErrors(parsed, options = {}) {
51
+ const taskSize = options.taskSize ?? null;
52
+ if (!PATCH_TASK_SIZES.has(taskSize)) {
53
+ return [];
54
+ }
55
+
56
+ if (!matchesNpmTestDashDashPattern(parsed)) {
57
+ return [];
58
+ }
59
+
60
+ return [formatNpmTestDashDashIssue(taskSize)];
61
+ }
62
+
63
+ /**
64
+ * Warn when S/M optional-mode or L task contracts use npm test -- <path> false scoping (issues #187, #141).
65
+ *
66
+ * @param {ReturnType<import("./packet/parse-prompt.mjs").parseContract>} parsed
67
+ * @param {{ taskSize?: "S"|"M"|"L"|"XL"|null, mode?: "required" | "optional" | "legacy" }} [options]
68
+ * @returns {string[]}
69
+ */
30
70
  export function collectNpmTestDashDashWarnings(parsed, options = {}) {
31
71
  const taskSize = options.taskSize ?? null;
72
+ const mode = options.mode ?? "optional";
73
+
74
+ if (taskSize === "L") {
75
+ if (!matchesNpmTestDashDashPattern(parsed)) {
76
+ return [];
77
+ }
78
+ return [formatNpmTestDashDashIssue(taskSize)];
79
+ }
80
+
32
81
  if (!PATCH_TASK_SIZES.has(taskSize)) {
33
82
  return [];
34
83
  }
35
84
 
36
- const testCommand = parsed?.testCommand;
37
- if (!testCommand || testCommand === "true") {
85
+ // Required S/M promotes to validation errors in validateContract.
86
+ if (mode === "required") {
38
87
  return [];
39
88
  }
40
89
 
41
- if (!NPM_TEST_DASH_DASH_RE.test(testCommand)) {
90
+ if (!matchesNpmTestDashDashPattern(parsed)) {
42
91
  return [];
43
92
  }
44
93
 
45
- return [
46
- `Contract testCommand uses npm test -- <path> on Size ${taskSize} patch task; npm runs the full suite, not the path. ${TEST_COMMAND_NPM_TEST_DASH_DASH_FIX_HINT}`,
47
- ];
94
+ return [formatNpmTestDashDashIssue(taskSize)];
48
95
  }
49
96
 
50
97
  /**
51
98
  * Warn when S/M task contracts chain full-suite gates in testCommand.
52
99
  *
53
100
  * @param {ReturnType<import("./packet/parse-prompt.mjs").parseContract>} parsed
54
- * @param {{ taskSize?: "S"|"M"|"L"|"XL"|null }} [options]
101
+ * @param {{ taskSize?: "S"|"M"|"L"|"XL"|null, mode?: "required" | "optional" | "legacy" }} [options]
55
102
  * @returns {string[]}
56
103
  */
57
104
  export function collectTestCommandScopeWarnings(parsed, options = {}) {
58
105
  const taskSize = options.taskSize ?? null;
59
- if (!PATCH_TASK_SIZES.has(taskSize)) {
60
- return [];
61
- }
106
+ const mode = options.mode ?? "optional";
62
107
 
63
108
  const testCommand = parsed?.testCommand;
64
109
  if (!testCommand || testCommand === "true") {
@@ -68,19 +113,27 @@ export function collectTestCommandScopeWarnings(parsed, options = {}) {
68
113
  /** @type {string[]} */
69
114
  const warnings = [];
70
115
 
71
- if (/\bcoverage:check\b/.test(testCommand)) {
72
- warnings.push(
73
- `Contract testCommand chains full coverage gate (coverage:check) on Size ${taskSize} patch task. ${TEST_COMMAND_COVERAGE_FIX_HINT}`,
74
- );
116
+ if (PATCH_TASK_SIZES.has(taskSize)) {
117
+ if (/\bcoverage:check\b/.test(testCommand)) {
118
+ warnings.push(
119
+ `Contract testCommand chains full coverage gate (coverage:check) on Size ${taskSize} patch task. ${TEST_COMMAND_COVERAGE_FIX_HINT}`,
120
+ );
121
+ }
122
+
123
+ const npmTestDashDashWarnings = collectNpmTestDashDashWarnings(parsed, { taskSize, mode });
124
+ if (npmTestDashDashWarnings.length > 0) {
125
+ warnings.push(...npmTestDashDashWarnings);
126
+ } else if (/\bnpm test\b/.test(testCommand)) {
127
+ warnings.push(
128
+ `Contract testCommand uses npm test on Size ${taskSize} patch task. ${TEST_COMMAND_NPM_TEST_FIX_HINT}`,
129
+ );
130
+ }
131
+
132
+ return warnings;
75
133
  }
76
134
 
77
- const npmTestDashDashWarnings = collectNpmTestDashDashWarnings(parsed, options);
78
- if (npmTestDashDashWarnings.length > 0) {
79
- warnings.push(...npmTestDashDashWarnings);
80
- } else if (/\bnpm test\b/.test(testCommand)) {
81
- warnings.push(
82
- `Contract testCommand uses npm test on Size ${taskSize} patch task. ${TEST_COMMAND_NPM_TEST_FIX_HINT}`,
83
- );
135
+ if (taskSize === "L") {
136
+ warnings.push(...collectNpmTestDashDashWarnings(parsed, { taskSize, mode }));
84
137
  }
85
138
 
86
139
  return warnings;