pi-spine 1.8.1 → 1.9.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.
@@ -284,7 +284,7 @@ export function formatOrchestratePrompt(
284
284
  "## Outer loop (per wave — you decide gate/integrate)",
285
285
  "",
286
286
  "1. spine preflight",
287
- `2. spine batch start ${scope} --wave W --attached`,
287
+ `2. spine batch start ${scope} --wave W # detached — monitor with spine wait`,
288
288
  "3. spine wait --until completed,needs_integrate,failed,aborted,needs_retry --timeout 4h",
289
289
  "4. spine status --diagnose",
290
290
  "5. spine gate status # review .spine/runtime/<batchId>/evidence/",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-spine",
3
- "version": "1.8.1",
3
+ "version": "1.9.0",
4
4
  "description": "Orchestration spine for long-running pi development",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -457,6 +457,43 @@ When decomposing a PRD, assign non-overlapping file scopes to tasks that should
457
457
 
458
458
  **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.
459
459
 
460
+ **Documentation paths in File Scope ([#144](https://github.com/beettlle/pi-spine/issues/144)):** Every path under **Must Update** in `## Documentation Requirements` **must** also appear in `## File Scope`. If a doc is advisory only, move it to **Check If Affected** — do not require workers to edit paths outside File Scope. Mismatches (e.g. SP-435, SP-451) caused out-of-scope edits and merge dirty-file failures.
461
+
462
+ ---
463
+
464
+ ## Docs-only contract pattern (FR-STA-12)
465
+
466
+ Use when the task delivers **documentation only** — no application code changes. Pair with Review Level 0 and Size S when appropriate.
467
+
468
+ ### Required fields
469
+
470
+ | Field | Value |
471
+ |-------|-------|
472
+ | `testCommand` | `` `true` `` |
473
+ | `fileScopeMustChange` | At least one documentation deliverable path (same paths in `## File Scope`) |
474
+
475
+ Without `fileScopeMustChange`, workers can pass contract by creating only `.DONE` (SP-214 batch `20260612T204048`, SP-457 batch `20260703T022335`).
476
+
477
+ ### Recommended scope guard ([#142](https://github.com/beettlle/pi-spine/issues/142))
478
+
479
+ Add `fileScopeMustNotChange` on product-code directories so accidental edits fail contract verify before merge:
480
+
481
+ ```markdown
482
+ | fileScopeMustNotChange | `src/**`, `bin/**` |
483
+ ```
484
+
485
+ Never ban `spine-tasks/**` — workers must update `STATUS.md` and create `.DONE`. Full example: [references/contract-template.md](references/contract-template.md#docs-only-with-scope-guard-recommended).
486
+
487
+ ### Docs-only vs scoped `node --test`
488
+
489
+ | Use docs-only (`testCommand: true`) | Use scoped `node --test` instead |
490
+ |-------------------------------------|----------------------------------|
491
+ | Skill, runbook, or README edits only | Any `src/**`, `bin/**`, or test file change |
492
+ | Review Level 0, Size S, no code deliverable | Size S/M patch with an existing targeted test |
493
+ | Contract proof is doc mtime, not test output | Contract must prove code behavior |
494
+
495
+ Docs-only tasks still include `### Step N: Testing & Verification` (full suite in the Testing step) — Contract `` `true` `` only means final verify does not re-run tests. See [contract-template decision table](references/contract-template.md#docs-only-vs-scoped-node---test).
496
+
460
497
  ---
461
498
 
462
499
  ## Unsupported (spine v1)
@@ -476,6 +513,10 @@ Before reporting launch commands:
476
513
  - [ ] Size S/M/L — split if XL
477
514
  - [ ] PROMPT.md from template: Mission, Dependencies, Context, File Scope, Contract (SP-\*), Steps, Do NOT, Git Commit Convention, Amendments
478
515
  - [ ] If `testCommand` is `` `true` ``, `fileScopeMustChange` MUST list at least one deliverable path
516
+ - [ ] Every **Must Update** doc path also appears in `## File Scope` ([#144](https://github.com/beettlle/pi-spine/issues/144))
517
+ - [ ] Docs-only tasks: consider `fileScopeMustNotChange` on `src/**`, `bin/**` ([#142](https://github.com/beettlle/pi-spine/issues/142)); see [Docs-only contract pattern](#docs-only-contract-pattern-fr-sta-12)
518
+ - [ ] S/M patch Contract uses scoped `node --test` — not `npm test` or `npm test -- path` ([#141](https://github.com/beettlle/pi-spine/issues/141), SP-522)
519
+ - [ ] Plan waves ≤8 tasks when possible — `spine plan` warns when exceeded ([#143](https://github.com/beettlle/pi-spine/issues/143), SP-524)
479
520
  - [ ] `### Step N: Testing & Verification` present inside `## Steps` before `## Completion Criteria` (required even for docs-only Review Level 0)
480
521
  - [ ] STATUS.md with matching steps (hydration markers where needed)
481
522
  - [ ] `dependencies.json` updated when task has deps
@@ -120,6 +120,21 @@ Symptom in journal: `testCommand` passes but `fileScopeMustNotChange` fails with
120
120
 
121
121
  When `testCommand` is `` `true` ``, **always** include `fileScopeMustChange` listing at least one documentation file the task must modify. Without it, workers can pass contract by creating only `.DONE` — two batches were rejected for this reason (SP-214 batch `20260612T204048`, SP-457 batch `20260703T022335`).
122
122
 
123
+ Every path in `fileScopeMustChange` **must** also appear in PROMPT `## File Scope` ([#144](https://github.com/beettlle/pi-spine/issues/144)) — workers cannot edit out-of-scope deliverables without merge dirty-file failures.
124
+
125
+ ```markdown
126
+ ## Contract
127
+
128
+ | Field | Value |
129
+ |-------|-------|
130
+ | testCommand | `true` |
131
+ | fileScopeMustChange | `docs/adoption/operator-runbook.md` |
132
+ ```
133
+
134
+ ### Docs-only with scope guard (recommended)
135
+
136
+ For docs-only tasks, add `fileScopeMustNotChange` on product-code directories so accidental worker edits to `src/**` or `bin/**` fail contract verify before merge — SP-457 post-mortem `20260703T051629` landed docs in-worker but merge failed on dirty `src/batch/`, `bin/`, `.spine/` paths ([#142](https://github.com/beettlle/pi-spine/issues/142)). Do **not** list `spine-tasks/**` here (workers must update `STATUS.md` and `.DONE`).
137
+
123
138
  ```markdown
124
139
  ## Contract
125
140
 
@@ -127,8 +142,19 @@ When `testCommand` is `` `true` ``, **always** include `fileScopeMustChange` lis
127
142
  |-------|-------|
128
143
  | testCommand | `true` |
129
144
  | fileScopeMustChange | `docs/adoption/operator-runbook.md` |
145
+ | fileScopeMustNotChange | `src/**`, `bin/**` |
130
146
  ```
131
147
 
148
+ ### Docs-only vs scoped `node --test`
149
+
150
+ | Situation | Contract pattern |
151
+ |-----------|------------------|
152
+ | No application code changes; documentation or skill text only | `` `true` `` + `fileScopeMustChange` on deliverable doc paths (+ optional `fileScopeMustNotChange` on `src/**`, `bin/**`) |
153
+ | Small code change with an existing targeted test file | `` `node --test tests/feature.test.mjs` `` (see [scoped testCommand](#scoped-testcommand) below) |
154
+ | Code change but no narrow test yet; full suite unsafe in lane | Scoped command matching the Testing step, or split into a code task + docs task |
155
+
156
+ Use docs-only when the worker's only product deliverable is documentation. Use scoped `node --test` when the task changes application code — even Size S/M patches should not use bare `` `npm test` `` or `` `npm test -- path` `` in Contract ([#141](https://github.com/beettlle/pi-spine/issues/141)).
157
+
132
158
  ### Scope guard for parallel wave
133
159
 
134
160
  ```markdown
@@ -167,13 +193,15 @@ When the worker model differs from the reviewer model (e.g. worker `cursor/auto`
167
193
 
168
194
  ### Scoped `testCommand`
169
195
 
196
+ Prefer `` `node --test tests/feature.test.mjs` `` for targeted proof in Contract. `` `npm test -- path` `` runs the full npm test script in lane worktrees — `spine tasks validate` warns or errors (FR-STA-10 / SP-522).
197
+
170
198
  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.
171
199
 
172
200
  | Avoid | Prefer |
173
201
  |-------|--------|
174
202
  | `` `flutter test` `` / `` `npm test` `` (full suite in lane worktree) | Targeted command matching the Testing step: `` `flutter test test/unit/services/foo_test.dart` `` |
175
203
  | Same command in Contract and global `testing.test` without verifying lane compatibility | Document when to use `` `true` `` (docs-only) vs scoped shell proof |
176
- | Unscoped command producing >10 MB stdout (SP-426 `maxBuffer`) | Narrow test scope; prefer `npm test -- tests/feature.test.mjs` |
204
+ | Unscoped command producing >10 MB stdout (SP-426 `maxBuffer`) | Narrow test scope; prefer `` `node --test tests/feature.test.mjs` `` |
177
205
 
178
206
  **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.
179
207
 
@@ -194,7 +222,7 @@ Reviewers spawn as **fresh sessions** with no memory of the worker session (FR-R
194
222
  | Task type | Recommended `testCommand` |
195
223
  |-----------|---------------------------|
196
224
  | Docs-only, no code changes | `` `true` `` **and** `fileScopeMustChange` with at least one deliverable doc path |
197
- | Single module, targeted tests exist | `` `npm test -- tests/feature.test.mjs` `` or `` `flutter test test/unit/services/foo_test.dart` `` |
225
+ | Single module, targeted tests exist | `` `node --test tests/feature.test.mjs` `` or `` `flutter test test/unit/services/foo_test.dart` `` |
198
226
  | Full-suite safe in lane worktree | `` `npm run typecheck && SPINE_WORKER_STUB=1 npm test` `` |
199
227
  | Coverage gate required (pi-spine ≥77%) | `` `npm run coverage:check` `` |
200
228
  | Long external job (>2h) | Scoped command + `stallTimeoutMinutes` and `extendGraceOnFileScope` in Contract (see SP-314 example above) |
@@ -118,7 +118,9 @@ Review Level 0 is ONLY for trivial changes. Most M+ tasks need Level ≥1.
118
118
 
119
119
  > **Required for every task** — including docs-only and Review Level 0 packets.
120
120
  > ZERO test failures allowed. This step runs the FULL test suite as a quality gate.
121
- > (Earlier steps should use targeted tests for fast feedback — see worker prompt.)
121
+ > Earlier steps should use **targeted** tests for fast feedback — e.g.
122
+ > `node --experimental-strip-types --test tests/feature.test.mjs` (not `npm test -- path`,
123
+ > which runs the full suite in lane worktrees; see SP-522).
122
124
  >
123
125
  > **Docs-only tasks:** keep this step; run the full test suite. Omit the coverage-gate
124
126
  > checkbox below when the task does not change application code.
@@ -32,6 +32,7 @@ Invoke explicitly: `/skill:spine-autonomous-operator`
32
32
  - **Do not** use unattended `spine run sequence --auto-approve-gate --force` without monitoring
33
33
  - **Do not** start a second batch while another batch is **running** on the same repo
34
34
  - **Never** background `spine batch resume --attached` or `resume --attached --force` ([#163](https://github.com/beettlle/pi-spine/issues/163))
35
+ - **Cursor Agent shell (~120s background timeout):** use **detached** `spine batch start|resume` (omit `--attached`); monitor with `spine status --diagnose` and `spine wait` — see [references/agent-shell-batch-policy.md](references/agent-shell-batch-policy.md)
35
36
  - **Release and agent batches:** use **detached** `spine batch start|resume` (omit `--attached`) unless the operator shell blocks until batch completion; then `spine wait --until …` ([#163](https://github.com/beettlle/pi-spine/issues/163), [#185](https://github.com/beettlle/pi-spine/issues/185)). `spine doctor` warns in non-interactive and agent-harness contexts.
36
37
 
37
38
  ## Phase 0 — Baseline
@@ -254,6 +255,7 @@ In pi sessions, `MonitorCreate` for `npm run release:check` is allowed (see pi-a
254
255
  - **Tasks root:** `spine-tasks/`
255
256
  - **Config:** `.spine/spine-config.json`
256
257
  - **Test gate:** `npm run release:check` (typecheck → lint → tests → coverage)
258
+ - **Agent shell policy:** [references/agent-shell-batch-policy.md](references/agent-shell-batch-policy.md)
257
259
  - **Known upstream issues:** #114 (integrate hang, fixed), #118 (trailing-slash contracts), #130 (`coverage/` restore), #163 (`engine_orphaned`)
258
260
 
259
261
  ## Short prompt (resume mid-batch)
@@ -0,0 +1,91 @@
1
+ # Agent shell batch policy
2
+
3
+ When an **external agent** (Cursor Agent, pi MonitorCreate, CI script, OpenCode) drives spine batches, the parent shell may return or be killed before the batch engine finishes. Use **detached** start/resume and monitor separately.
4
+
5
+ **Related:** [#163](https://github.com/beettlle/pi-spine/issues/163) (attached orphan / exit 137), [#185](https://github.com/beettlle/pi-spine/issues/185) (detached default for release/agent batches), [operator-runbook §Attached-first](../../../docs/adoption/operator-runbook.md#attached-first-policy-phase-22).
6
+
7
+ ---
8
+
9
+ ## Default for agents
10
+
11
+ Omit `--attached`. Detached is the CLI default for `spine batch start` and `spine batch resume`.
12
+
13
+ ```bash
14
+ spine batch start pending --wave 0 # detached — engine survives parent shell exit
15
+ spine status --diagnose # always after detached start/resume return
16
+ spine wait --until completed,needs_integrate,failed,aborted --timeout 4h # optional block
17
+ ```
18
+
19
+ Detached start/resume returns when the engine **starts**, not when work completes.
20
+
21
+ ---
22
+
23
+ ## Cursor Agent shell
24
+
25
+ Cursor Agent shells may background long-running commands after **~120 seconds** even when started from the IDE terminal. An `--attached` engine is tied to that parent process — when the shell backgrounds or exits, the engine is orphaned (`engine_orphaned`, exit 137) and tasks stick in `running`.
26
+
27
+ **Do not** use `spine batch start … --attached` from Cursor Agent. Use detached start + monitor.
28
+
29
+ `spine doctor` detects Cursor agent shells (`CURSOR_TRACE_ID`, `CURSOR_SESSION_ID`) and warns with a detached `suggestedCommand`. Run `spine doctor` during Phase 0 baseline and heed the warning.
30
+
31
+ ---
32
+
33
+ ## Monitor pattern (per wave)
34
+
35
+ ```bash
36
+ spine preflight
37
+ spine batch start pending --wave N
38
+ spine status --diagnose
39
+ spine wait --until completed,needs_integrate,failed,aborted,needs_retry --timeout 4h
40
+ spine status --diagnose
41
+ # → land loop or recovery per diagnosis
42
+ ```
43
+
44
+ Optional: `spine watch --once`, `spine dashboard`, `spine journal follow`.
45
+
46
+ ---
47
+
48
+ ## When `--attached` is OK
49
+
50
+ Use `--attached` only when **all** of the following hold:
51
+
52
+ - Persistent **interactive** terminal (human operator: iTerm, Terminal.app, etc.)
53
+ - Shell stays in the **foreground** for the full batch duration (often 30+ minutes for real `pi` workers)
54
+ - Short smoke batches where total runtime is well under shell harness limits
55
+
56
+ ```bash
57
+ spine batch start SP-042 --attached # human terminal — blocks until engine finishes
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Recovery
63
+
64
+ | Situation | Rule |
65
+ |-----------|------|
66
+ | Default resume after retry | `spine batch resume` (detached) |
67
+ | Diagnose suggests `--attached --force` | Run in **foreground** only — never background |
68
+ | `resume --attached` or `resume --attached --force` | **Never** MonitorCreate or background ([#163](https://github.com/beettlle/pi-spine/issues/163)) |
69
+ | After detached start/resume | Always `spine status --diagnose` before leaving session |
70
+
71
+ Follow `suggestedCommand` from `spine status --diagnose` when unsure.
72
+
73
+ ---
74
+
75
+ ## Preflight
76
+
77
+ ```bash
78
+ spine doctor
79
+ ```
80
+
81
+ If `batch --attached orphan risk (#163)` shows a warning, use detached start/resume for this session.
82
+
83
+ ---
84
+
85
+ ## Skills that reference this doc
86
+
87
+ | Skill | Use |
88
+ |-------|-----|
89
+ | `spine-autonomous-operator` | Full pending backlog operator |
90
+ | `spine-orchestrate-waves` | Multi-wave outer loop |
91
+ | `spine-release-operator` | Curated release batches |
@@ -21,6 +21,7 @@ Invoke explicitly: `/skill:spine-orchestrate-waves`, `/spine-orchestrate pending
21
21
  |---------|-------------|
22
22
  | Task packet authoring | `create-spine-tasks` skill |
23
23
  | Curated release subset | `spine-release-operator` skill |
24
+ | Agent shell batch policy (detached vs attached) | [spine-autonomous-operator/references/agent-shell-batch-policy.md](../spine-autonomous-operator/references/agent-shell-batch-policy.md) |
24
25
  | Pi async batch/verify (MonitorCreate) | [spine-release-operator/references/pi-async-orchestration.md](../spine-release-operator/references/pi-async-orchestration.md) |
25
26
  | Canonical how-to prose | [references/outer-loop.md](references/outer-loop.md) (synced from `docs/adoption/agent-orchestrated-waves.md`) |
26
27
  | Slash entry (`/spine-orchestrate`) | pi-spine extension — wave plan + outer loop checklist |
@@ -50,7 +51,8 @@ START
50
51
  │
51
52
  └─ FOR each wave W (from --from-wave or 0):
52
53
  │
53
- ├─ spine batch start <scope> --wave W --attached
54
+ ├─ spine batch start <scope> --wave W # detached — omit --attached
55
+ ├─ spine status --diagnose
54
56
  ├─ spine wait --until completed,needs_integrate,failed,aborted,needs_retry --timeout 4h
55
57
  ├─ spine status --diagnose
56
58
  │
@@ -92,7 +94,8 @@ From consumer repo root:
92
94
  spine preflight
93
95
  WAVE=0 # or next index from plan
94
96
 
95
- spine batch start pending --wave $WAVE --attached
97
+ spine batch start pending --wave $WAVE # detached — omit --attached
98
+ spine status --diagnose
96
99
  spine wait --until completed,needs_integrate,failed,aborted,needs_retry --timeout 4h
97
100
 
98
101
  spine status --diagnose
@@ -133,17 +136,17 @@ Inspect `.spine/runtime/<batchId>/evidence/`:
133
136
  | Diagnosis | Agent action |
134
137
  |-----------|--------------|
135
138
  | `needs_integrate` | Evidence checklist → `spine gate approve` → `spine integrate` → `spine batch complete` → push |
136
- | `needs_retry` | `spine batch retry <taskId>` then `spine batch resume --attached`; amend PROMPT contract if scope wrong |
139
+ | `needs_retry` | `spine batch retry <taskId>` then `spine batch resume` (detached); amend PROMPT contract if scope wrong |
137
140
  | `needs_retry` + `review_exhausted` | Inspect `.reviews/` feedback; fix implementation or packet scope, then retry |
138
141
  | `needs_retry` + `contract_failed` | Edit `PROMPT.md` `testCommand` or file scope, then retry |
139
142
  | `failed` | Inspect journal (`spine journal follow`); fix contract/env before retry |
140
143
  | `needs_replan` | Read `{taskFolder}/.reviews/final-*.md`; edit PROMPT scope, then retry |
141
144
  | `merge_blocked` | Resolve conflicts on orch branch or lane worktree; `spine batch resume --force` |
142
- | `engine_orphaned` | Do **not** start a second attached engine; `spine batch retry <taskId>` or `spine batch resume --attached --force` after confirming dead PIDs |
145
+ | `engine_orphaned` | Do **not** start a second attached engine; `spine batch retry <taskId>` or follow `suggestedCommand` (`resume --attached --force` only in **foreground** after confirming dead PIDs) |
143
146
  | `worker_orphaned` | `spine batch retry <taskId>` (reconciles orphan running → failed) |
144
147
  | `worker_done_missing` | Read worker output log from headline; fix blocker, then `spine batch retry <taskId>` |
145
148
  | `completed` | Run `spine batch complete` if not archived, then push |
146
- | `state_drift` | `spine batch retry <taskId>`; then `spine batch resume --attached --force` |
149
+ | `state_drift` | `spine batch retry <taskId>`; then follow `suggestedCommand` (`resume --attached --force` in **foreground** if diagnose requires) |
147
150
 
148
151
  ---
149
152
 
@@ -151,6 +154,7 @@ Inspect `.spine/runtime/<batchId>/evidence/`:
151
154
 
152
155
  | Anti-pattern | Correct approach |
153
156
  |--------------|------------------|
157
+ | `spine batch start … --attached` from Cursor Agent or non-TTY shell | Detached start + `spine wait` / `spine status --diagnose` — see [agent-shell-batch-policy.md](../spine-autonomous-operator/references/agent-shell-batch-policy.md) |
154
158
  | `spine batch resume --attached` while `spine run sequence --attached` is active | One entry point; kill stale engines first (`spine status --diagnose`) |
155
159
  | Approving gate without reading evidence | Always inspect evidence directory before `spine gate approve` |
156
160
  | Expecting workers to call `spine_request_gate` for integrate | Agent drives gate approval from host shell |
@@ -195,7 +199,7 @@ When all waves finish, report:
195
199
 
196
200
  ```text
197
201
  Resume spine wave orchestration: spine plan pending --json → pick next wave W →
198
- spine batch start pending --wave W --attached → spine wait → spine status --diagnose →
202
+ spine batch start pending --wave W (detached) → spine status --diagnose → spine wait →
199
203
  branch on diagnosis (evidence checklist before gate approve) → integrate → batch complete → push →
200
204
  repeat until plan shows 0 waves. Post completion report.
201
205
  ```
@@ -16,6 +16,16 @@ Run all pending tasks across multiple dependency waves without manual interventi
16
16
 
17
17
  ---
18
18
 
19
+ ## Agent shell policy
20
+
21
+ For agent-driven batches (Cursor Agent, pi MonitorCreate, CI), use **detached** start/resume — omit `--attached`. The engine survives parent shell exit; monitor with `spine status --diagnose` and `spine wait`.
22
+
23
+ Cursor Agent shells may background long commands after **~120 seconds**; an attached engine dies with the parent shell (`engine_orphaned`, exit 137). Run `spine doctor` and heed the `batch --attached orphan risk (#163)` warning.
24
+
25
+ Full policy: [agent-shell-batch-policy.md](../../spine-autonomous-operator/references/agent-shell-batch-policy.md). Use `--attached` only from a persistent interactive terminal kept in foreground for the full batch.
26
+
27
+ ---
28
+
19
29
  ## Responsibility split
20
30
 
21
31
  | Layer | Owns |
@@ -35,7 +45,8 @@ Run this sequence once per wave from the consumer repo root:
35
45
  spine preflight
36
46
  WAVE=0 # agent picks the next wave index from plan output
37
47
 
38
- spine batch start pending --wave $WAVE --attached
48
+ spine batch start pending --wave $WAVE # detached — omit --attached
49
+ spine status --diagnose
39
50
  spine wait --until completed,needs_integrate,failed,aborted,needs_retry --timeout 4h
40
51
 
41
52
  spine status --diagnose
@@ -68,7 +79,7 @@ Increment `$WAVE` and repeat until `spine plan pending` shows no remaining waves
68
79
  spine run sequence pending --attached --dry-run
69
80
  ```
70
81
 
71
- The agent can execute each printed block manually with judgment between steps.
82
+ The agent can execute each printed block manually with judgment between steps. Use **detached** start for real execution (omit `--attached`).
72
83
 
73
84
  **Not recommended for real pi:** `spine run sequence pending --auto-approve-gate --force` bypasses evidence review and is restricted to stub/CI environments by safety gates.
74
85
 
@@ -81,16 +92,17 @@ After `spine wait` returns or `spine status --diagnose` reports a non-running st
81
92
  | Diagnosis | Agent action |
82
93
  |-----------|--------------|
83
94
  | `needs_integrate` | Review evidence under `.spine/runtime/<batchId>/evidence/` → `spine gate approve` → `spine integrate` → `spine batch complete` → push |
84
- | `needs_retry` | `spine batch retry <taskId>` then `spine batch resume --attached`; amend PROMPT contract if scope is wrong |
95
+ | `needs_retry` | `spine batch retry <taskId>` then `spine batch resume` (detached); amend PROMPT contract if scope is wrong |
85
96
  | `needs_retry` + `review_exhausted` | Inspect `.reviews/` feedback; fix implementation or packet scope, then retry |
86
97
  | `needs_retry` + `contract_failed` | Edit `PROMPT.md` `testCommand` or file scope, then retry |
87
98
  | `failed` | Inspect journal (`spine journal follow`); fix contract/env before retry |
88
99
  | `needs_replan` | Read reviewer feedback in `{taskFolder}/.reviews/final-*.md`; edit PROMPT scope, then retry |
89
100
  | `merge_blocked` | Resolve conflicts on orch branch or lane worktree; `spine batch resume --force` |
90
- | `engine_orphaned` | Do **not** start a second attached engine; `spine batch retry <taskId>` or `spine batch resume --attached --force` after confirming dead PIDs |
101
+ | `engine_orphaned` | Do **not** start a second attached engine; `spine batch retry <taskId>` or follow `suggestedCommand` (`resume --attached --force` only in **foreground** after confirming dead PIDs) |
91
102
  | `worker_orphaned` | `spine batch retry <taskId>` (reconciles orphan running → failed) |
92
103
  | `worker_done_missing` | Read worker output log from headline; fix blocker, then `spine batch retry <taskId>` |
93
104
  | `completed` | Already landed — run `spine batch complete` if not archived, then push |
105
+ | `state_drift` | `spine batch retry <taskId>`; then follow `suggestedCommand` (`resume --attached --force` in **foreground** if diagnose requires) |
94
106
 
95
107
  ---
96
108
 
@@ -98,6 +110,7 @@ After `spine wait` returns or `spine status --diagnose` reports a non-running st
98
110
 
99
111
  | Anti-pattern | Why it fails | Correct approach |
100
112
  |--------------|-------------|------------------|
113
+ | `spine batch start … --attached` from Cursor Agent or non-TTY shell | Parent shell backgrounds (~120s) or exits; engine orphaned | Detached start + `spine wait` / `spine status --diagnose` |
101
114
  | Running `spine batch resume --attached` while `spine run sequence --attached` is active | Two engines on the same batch causes state corruption | Use one entry point; kill stale engines first (`spine status --diagnose` to check PIDs) |
102
115
  | Approving gate without reading evidence | Merges untested or broken code to main | Always inspect `.spine/runtime/<batchId>/evidence/` before `spine gate approve` |
103
116
  | Expecting workers to call `spine_request_gate` for integrate | Workers always receive `not_supported` (FR-SHIP-13) | Agent drives gate approval from the host shell |
@@ -120,7 +133,8 @@ WAVES=$(spine plan pending --json | jq '.waveCount')
120
133
  for ((WAVE=0; WAVE<WAVES; WAVE++)); do
121
134
  echo "=== Wave $WAVE ==="
122
135
 
123
- spine batch start pending --wave "$WAVE" --attached
136
+ spine batch start pending --wave "$WAVE"
137
+ spine status --diagnose
124
138
  spine wait --until completed,needs_integrate,failed,aborted,needs_retry --timeout 4h
125
139
 
126
140
  DIAG=$(spine status --json | jq -r '.diagnosis')
@@ -150,6 +164,7 @@ Adapt for agent sessions: replace the bash loop with agent tool calls (`spine st
150
164
  | Doc | Relevance |
151
165
  |-----|-----------|
152
166
  | [operator-runbook.md §4](../../../docs/adoption/operator-runbook.md#4-land-loop) | Land loop copy-paste sequence |
167
+ | [agent-shell-batch-policy.md](../../spine-autonomous-operator/references/agent-shell-batch-policy.md) | Detached default for agent shells |
153
168
  | [bootstrap-checklist.md](../../../docs/adoption/bootstrap-checklist.md) | First batch setup |
154
169
  | [upstream-execution-workflow.md](../../../docs/adoption/upstream-execution-workflow.md) | PRD → task packets → batch |
155
170
  | [QUICK-REFERENCE.md](../../../docs/QUICK-REFERENCE.md) | Command reference |
@@ -163,3 +178,5 @@ Adapt for agent sessions: replace the bash loop with agent tool calls (`spine st
163
178
  - [#84](https://github.com/beettlle/pi-spine/issues/84) — PROMPT authoring for cross-model
164
179
  - [#71](https://github.com/beettlle/pi-spine/issues/71) — built-in supervisor (future; agent outer loop bridges gap)
165
180
  - [#54](https://github.com/beettlle/pi-spine/issues/54) — `spine run sequence` (complementary, not replacement)
181
+ - [#163](https://github.com/beettlle/pi-spine/issues/163) — attached orphan risk in short-lived shells
182
+ - [#185](https://github.com/beettlle/pi-spine/issues/185) — detached default for release/agent batches
@@ -18,6 +18,7 @@ Invoke explicitly: `/skill:spine-release-operator` or "run a spine release cycle
18
18
  |---------|-------------|
19
19
  | PROMPT/STATUS/Contract authoring | `create-spine-tasks` skill + templates |
20
20
  | Batch land loop / recovery | [`spine-autonomous-operator`](../spine-autonomous-operator/SKILL.md) Phase 3–4 + [pi-async-orchestration.md](references/pi-async-orchestration.md) |
21
+ | Agent shell batch policy (detached vs attached) | [spine-autonomous-operator/references/agent-shell-batch-policy.md](../spine-autonomous-operator/references/agent-shell-batch-policy.md) |
21
22
  | Wave evidence / diagnosis tree | [`spine-orchestrate-waves`](../spine-orchestrate-waves/SKILL.md) |
22
23
  | Semver scope budgets | [references/release-profiles.md](references/release-profiles.md) |
23
24
  | Issue intake queries | [references/issue-intake-checklist.md](references/issue-intake-checklist.md) |
@@ -253,13 +254,21 @@ See [references/pi-async-orchestration.md](references/pi-async-orchestration.md)
253
254
 
254
255
  ```text
255
256
  MonitorCreate:
256
- command: spine batch start <release-scope> --wave N --attached
257
+ command: spine batch start <release-scope> --wave N # detached — omit --attached (#163)
257
258
  description: Release wave N
258
259
  timeout: 0
259
260
  onDone: spine status --diagnose → §4.3 land loop or §4.4 recovery
260
261
  ```
261
262
 
262
- **Foreground fallback** (non-pi, or after #163 orphan on MonitorCreate):
263
+ **Blocking fallback** (Cursor Agent, non-pi, or after MonitorCreate orphan — see [agent-shell-batch-policy.md](../spine-autonomous-operator/references/agent-shell-batch-policy.md)):
264
+
265
+ ```bash
266
+ spine batch start <release-scope> --wave N
267
+ spine status --diagnose
268
+ spine wait --until completed,failed,needs_integrate,needs_retry,aborted --timeout 4h
269
+ ```
270
+
271
+ **Foreground `--attached`** (persistent interactive human terminal only):
263
272
 
264
273
  ```bash
265
274
  spine batch start <release-scope> --wave N --attached
@@ -2,7 +2,7 @@
2
2
 
3
3
  Use in **pi sessions** when long-running shell work would waste the agent context window. The operator session stays free for intake, manifest edits, issue filing, and recovery planning while batches and verification run in the background.
4
4
 
5
- **Fallback:** When pi bridge tools are unavailable (Cursor-only, no MonitorCreate), use blocking `spine wait` and foreground shell — see each skill's non-pi sections.
5
+ **Fallback:** When pi bridge tools are unavailable (Cursor-only, no MonitorCreate), use detached `spine batch start` + `spine wait` / `spine status --diagnose` — see [agent-shell-batch-policy.md](../../spine-autonomous-operator/references/agent-shell-batch-policy.md) and each skill's non-pi sections.
6
6
 
7
7
  ---
8
8
 
@@ -12,7 +12,7 @@ Use in **pi sessions** when long-running shell work would waste the agent contex
12
12
 
13
13
  | Command | timeout | Notes |
14
14
  |---------|---------|-------|
15
- | `spine batch start <scope> --wave N --attached` | `0` (none) | Wave batch; see safety rules below |
15
+ | `spine batch start <scope> --wave N` | `0` (none) | Detached wave batch; monitor via onDone + `spine wait` ([#163](https://github.com/beettlle/pi-spine/issues/163)) |
16
16
  | `npm run release:check 2>&1 \| tee /tmp/pi-spine-release-check.log` | `900000` (15m) | Default 5m is too short for full pi-spine suite |
17
17
  | `gh run watch --exit-status <run-id>` | `1800000` (30m) | After tag push; resolve run-id from `gh run list` |
18
18
 
@@ -249,6 +249,89 @@ export function isBaseScopeSatisfied(worktreePath, pattern, changedFiles, baseBr
249
249
  return onBase.some((filePath) => matchesScopePattern(filePath, pattern));
250
250
  }
251
251
 
252
+ /**
253
+ * When `sinceCommit` scopes verify to a resume baseline, paths matching `fileScopeMustChange`
254
+ * that are unchanged on the lane since task start are satisfied if they already exist on
255
+ * `baseBranch` at that baseline (issue #171, SP-526 / FR-STA-11).
256
+ *
257
+ * @param {string} worktreePath
258
+ * @param {string} pattern
259
+ * @param {string[]} changedFiles
260
+ * @param {string} sinceCommit
261
+ * @param {string} baseBranch
262
+ * @param {ReturnType<import("../tasks/packet/parse-prompt.mjs").parseContract>} parsedContract
263
+ * @param {{ testCommandOk: boolean }} delivery
264
+ * @param {(worktreePath: string, artifactPath: string) => boolean} artifactExists
265
+ */
266
+ export function isResumeBaselineFileScopeSatisfied(
267
+ worktreePath,
268
+ pattern,
269
+ changedFiles,
270
+ sinceCommit,
271
+ baseBranch,
272
+ parsedContract,
273
+ delivery,
274
+ artifactExists,
275
+ ) {
276
+ const scopedSince = String(sinceCommit ?? "").trim();
277
+ if (!scopedSince) {
278
+ return false;
279
+ }
280
+
281
+ if (changedFiles.some((file) => matchesScopePattern(file, pattern))) {
282
+ return false;
283
+ }
284
+
285
+ const laneChangesSinceStart = listPathsChangedBetweenRefs(
286
+ worktreePath,
287
+ scopedSince,
288
+ "HEAD",
289
+ pattern,
290
+ );
291
+ if (laneChangesSinceStart.some((filePath) => matchesScopePattern(filePath, pattern))) {
292
+ return false;
293
+ }
294
+
295
+ const changedInSinceCommit = listPathsChangedBetweenRefs(
296
+ worktreePath,
297
+ `${scopedSince}^`,
298
+ scopedSince,
299
+ pattern,
300
+ );
301
+ if (changedInSinceCommit.some((filePath) => matchesScopePattern(filePath, pattern))) {
302
+ return false;
303
+ }
304
+
305
+ const onBaseAtStart = listPathsOnRef(worktreePath, scopedSince, pattern);
306
+ if (onBaseAtStart.some((filePath) => matchesScopePattern(filePath, pattern))) {
307
+ // Pattern already present at task-start baseline on the lane tree.
308
+ } else {
309
+ const onBaseNow = listPathsOnRef(worktreePath, baseBranch, pattern);
310
+ if (!onBaseNow.some((filePath) => matchesScopePattern(filePath, pattern))) {
311
+ return false;
312
+ }
313
+ const mainChangesSinceStart = listPathsChangedBetweenRefs(
314
+ worktreePath,
315
+ scopedSince,
316
+ baseBranch,
317
+ pattern,
318
+ );
319
+ if (mainChangesSinceStart.some((filePath) => matchesScopePattern(filePath, pattern))) {
320
+ return false;
321
+ }
322
+ }
323
+
324
+ if (parsedContract.testCommand && !delivery.testCommandOk) {
325
+ return false;
326
+ }
327
+ for (const artifactPath of parsedContract.artifactsMustExist ?? []) {
328
+ if (!artifactExists(worktreePath, artifactPath)) {
329
+ return false;
330
+ }
331
+ }
332
+ return true;
333
+ }
334
+
252
335
  /**
253
336
  * @param {string} worktreePath
254
337
  * @param {string} pattern
@@ -13,6 +13,7 @@ import {
13
13
  isBaseFileScopeSatisfied,
14
14
  isBaseScopeSatisfied,
15
15
  isPrelandedFileScopeSatisfied,
16
+ isResumeBaselineFileScopeSatisfied,
16
17
  isStubPrelandedFileScopeSatisfied,
17
18
  } from "./contract-prelanded.mjs";
18
19
  import { appendJournalEvent } from "./journal.mjs";
@@ -579,7 +580,18 @@ export function verifyContract(worktreePath, parsedContract, config = {}) {
579
580
  { testCommandOk },
580
581
  (worktree, artifactPath) => findArtifactMatch(worktree, artifactPath).ok,
581
582
  );
582
- const baseSatisfied = !matched && !prelanded &&
583
+ const resumeBaseline = !matched && !prelanded && sinceCommit &&
584
+ isResumeBaselineFileScopeSatisfied(
585
+ worktreePath,
586
+ pattern,
587
+ changedFiles,
588
+ sinceCommit,
589
+ baseBranch,
590
+ parsedContract,
591
+ { testCommandOk },
592
+ (worktree, artifactPath) => findArtifactMatch(worktree, artifactPath).ok,
593
+ );
594
+ const baseSatisfied = !matched && !prelanded && !resumeBaseline &&
583
595
  isBaseFileScopeSatisfied(
584
596
  worktreePath,
585
597
  pattern,
@@ -590,7 +602,7 @@ export function verifyContract(worktreePath, parsedContract, config = {}) {
590
602
  (worktree, artifactPath) => findArtifactMatch(worktree, artifactPath).ok,
591
603
  config,
592
604
  );
593
- const ok = matched || prelanded || baseSatisfied;
605
+ const ok = matched || prelanded || resumeBaseline || baseSatisfied;
594
606
  checks.push({
595
607
  field: "fileScopeMustChange",
596
608
  ok,
@@ -598,9 +610,11 @@ export function verifyContract(worktreePath, parsedContract, config = {}) {
598
610
  ? `fileScopeMustChange matched: ${pattern}`
599
611
  : prelanded
600
612
  ? `fileScopeMustChange pre-landed on ${baseBranch}: ${pattern}`
601
- : baseSatisfied
602
- ? `fileScopeMustChange satisfied on ${baseBranch}: ${pattern}`
603
- : `Contract fileScopeMustChange: no matching changes for ${pattern}`,
613
+ : resumeBaseline
614
+ ? `fileScopeMustChange pre-landed at resume baseline: ${pattern}`
615
+ : baseSatisfied
616
+ ? `fileScopeMustChange satisfied on ${baseBranch}: ${pattern}`
617
+ : `Contract fileScopeMustChange: no matching changes for ${pattern}`,
604
618
  });
605
619
  }
606
620
 
@@ -19,6 +19,7 @@ import {
19
19
  import { terminateLaneWorkers } from "./worker-host.mjs";
20
20
  import { removeLaneWorktrees } from "./worktree.mjs";
21
21
  import { terminateSupervisorIfRunning } from "./supervisor-spawn.mjs";
22
+ import { bumpDashboardInvalidateSignal } from "../dashboard/cache-invalidate.mjs";
22
23
 
23
24
  const DISMISS_ALLOWED = new Set(["limbo_stale", "completed_manual", "aborted"]);
24
25
 
@@ -314,6 +315,7 @@ export function dismissBatch(ctx) {
314
315
  config,
315
316
  });
316
317
  clearCompletedBatchState(loaded.path, batchId);
318
+ bumpDashboardInvalidateSignal(projectRoot, "batch_dismiss", batchId);
317
319
 
318
320
  return {
319
321
  ok: true,
@@ -268,7 +268,7 @@ export function listPrelandedFileScopeStaleTasks(ctx) {
268
268
 
269
269
  const discovered = discoverTasks(tasksRootPath);
270
270
  const { pendingIds } = summarizePendingScope(discovered, tasksRootPath);
271
- /** @type {Array<{ taskId: string, warnings: string[] }>} */
271
+ /** @type {Array<{ taskId: string, warnings: string[], statusRelPath: string, promptRelPath: string }>} */
272
272
  const staleTasks = [];
273
273
  /** @type {Array<{ discoveredTask: (typeof discovered)[number], promptPath: string }>} */
274
274
  const pendingPrompts = [];
@@ -295,13 +295,36 @@ export function listPrelandedFileScopeStaleTasks(ctx) {
295
295
  promptRelPath,
296
296
  );
297
297
  if (warnings.length > 0) {
298
- staleTasks.push({ taskId: discoveredTask.taskId, warnings });
298
+ const taskFolderRel = path
299
+ .relative(ctx.projectRoot, discoveredTask.folderPath)
300
+ .replace(/\\/g, "/");
301
+ staleTasks.push({
302
+ taskId: discoveredTask.taskId,
303
+ warnings,
304
+ statusRelPath: `${taskFolderRel}/STATUS.md`,
305
+ promptRelPath: path.relative(ctx.projectRoot, promptPath).replace(/\\/g, "/"),
306
+ });
299
307
  }
300
308
  }
301
309
 
302
310
  return staleTasks;
303
311
  }
304
312
 
313
+ /**
314
+ * Actionable redirect hint for pre-landed fileScope (FR-STA-14 / issue #159).
315
+ * Distinct from SP-374 generic stale warn — points operators at STATUS.md + Amendments.
316
+ *
317
+ * @param {Array<{ taskId: string, statusRelPath: string, promptRelPath: string }>} staleTasks
318
+ */
319
+ export function formatPrelandedFileScopeRedirectSuggestion(staleTasks) {
320
+ return staleTasks
321
+ .map(
322
+ (entry) =>
323
+ `${entry.taskId}: amend ${entry.statusRelPath} and ${entry.promptRelPath} ## Amendments (redirect fileScopeMustChange to delivery artifacts)`,
324
+ )
325
+ .join("; ");
326
+ }
327
+
305
328
  /**
306
329
  * Warn when pending tasks have fileScopeMustChange paths already changed on main (issue #56).
307
330
  *
@@ -322,15 +345,15 @@ export function checkPrelandedFileScopeWarn(ctx) {
322
345
 
323
346
  const preview = staleTasks.map((entry) => entry.taskId).slice(0, 5).join(", ");
324
347
  const suffix = staleTasks.length > 5 ? ` (+${staleTasks.length - 5} more)` : "";
348
+ const redirectHint = formatPrelandedFileScopeRedirectSuggestion(staleTasks);
325
349
  return makeCheck(
326
350
  "prelanded-file-scope",
327
351
  true,
328
- `${staleTasks.length} pending task(s) with fileScopeMustChange already changed on main (${preview}${suffix})`,
352
+ `${staleTasks.length} pending task(s) with fileScopeMustChange already changed on main (${preview}${suffix}) — ${redirectHint}`,
329
353
  {
330
354
  warning: true,
331
- details: { staleTasks },
332
- suggestedCommand:
333
- "spine tasks validate pending --warnings-only; amend PROMPT ## Contract before batch start",
355
+ details: { staleTasks, redirectHint },
356
+ suggestedCommand: `spine tasks validate pending --warnings-only; ${redirectHint}`,
334
357
  },
335
358
  );
336
359
  } catch (err) {
@@ -345,10 +368,11 @@ export function checkPrelandedFileScopeWarn(ctx) {
345
368
 
346
369
  function formatPrelandedFileScopePlanWarning(staleTasks) {
347
370
  const preview = staleTasks.map((entry) => entry.taskId).slice(0, 5).join(", ");
371
+ const redirectHint = formatPrelandedFileScopeRedirectSuggestion(staleTasks);
348
372
  return [
349
373
  "⚠️ Pre-landed contract risk: pending task(s)",
350
374
  `(${preview}) have fileScopeMustChange paths already changed on main.`,
351
- "Amend PROMPT ## Contract before batch start or expect contract rework loops.",
375
+ `Redirect: ${redirectHint}`,
352
376
  ].join(" ");
353
377
  }
354
378
 
@@ -55,6 +55,7 @@ export {
55
55
  export {
56
56
  checkOrchMergeConflictWarn,
57
57
  checkPrelandedFileScopeWarn,
58
+ formatPrelandedFileScopeRedirectSuggestion,
58
59
  isMergeOriginMainTask,
59
60
  listDivergentOrchMergeRiskPaths,
60
61
  listPrelandedFileScopeStaleTasks,
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Cross-process dashboard cache invalidation (batch dismiss / complete).
3
+ * CLI lifecycle bumps a signal file; dashboard server consumes it on poll.
4
+ */
5
+
6
+ import fs from "node:fs";
7
+ import path from "node:path";
8
+ import { clearJournalCache } from "../batch/journal.mjs";
9
+ import { clearLightReconcileCache } from "../batch/reconcile.mjs";
10
+
11
+ const SIGNAL_FILE = "dashboard-invalidate.json";
12
+
13
+ /** @type {number} */
14
+ let lastConsumedSeq = 0;
15
+
16
+ /**
17
+ * @param {string} projectRoot
18
+ */
19
+ export function dashboardInvalidateSignalPath(projectRoot) {
20
+ return path.join(projectRoot, ".spine", "runtime", SIGNAL_FILE);
21
+ }
22
+
23
+ /**
24
+ * Clear in-process reconcile/journal caches used by dashboard snapshots.
25
+ */
26
+ export function clearDashboardProcessCaches() {
27
+ clearLightReconcileCache();
28
+ clearJournalCache();
29
+ }
30
+
31
+ /**
32
+ * Bump invalidation signal after batch lifecycle clears active state.
33
+ *
34
+ * @param {string} projectRoot
35
+ * @param {string} reason
36
+ * @param {string|null} [batchId]
37
+ */
38
+ export function bumpDashboardInvalidateSignal(projectRoot, reason, batchId = null) {
39
+ const filePath = dashboardInvalidateSignalPath(projectRoot);
40
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
41
+ let seq = 1;
42
+ if (fs.existsSync(filePath)) {
43
+ try {
44
+ const previous = JSON.parse(fs.readFileSync(filePath, "utf-8"));
45
+ seq = Number(previous.seq ?? 0) + 1;
46
+ } catch {
47
+ seq = 1;
48
+ }
49
+ }
50
+ const payload = {
51
+ at: Date.now(),
52
+ seq,
53
+ reason,
54
+ batchId: batchId ?? null,
55
+ };
56
+ fs.writeFileSync(filePath, `${JSON.stringify(payload)}\n`, "utf-8");
57
+ clearDashboardProcessCaches();
58
+ return filePath;
59
+ }
60
+
61
+ /**
62
+ * Consume invalidation signal if newer than last consume in this process.
63
+ *
64
+ * @param {string} projectRoot
65
+ * @returns {boolean} true when caches were cleared for a new signal
66
+ */
67
+ export function consumeDashboardInvalidateSignal(projectRoot) {
68
+ const filePath = dashboardInvalidateSignalPath(projectRoot);
69
+ if (!fs.existsSync(filePath)) {
70
+ return false;
71
+ }
72
+
73
+ try {
74
+ const raw = fs.readFileSync(filePath, "utf-8");
75
+ const payload = JSON.parse(raw);
76
+ const seq = Number(payload.seq ?? 0);
77
+ if (!Number.isFinite(seq) || seq <= lastConsumedSeq) {
78
+ return false;
79
+ }
80
+ lastConsumedSeq = seq;
81
+ clearDashboardProcessCaches();
82
+ return true;
83
+ } catch {
84
+ return false;
85
+ }
86
+ }
87
+
88
+ /** Reset consume cursor (test isolation). */
89
+ export function resetDashboardInvalidateConsumeCursor() {
90
+ lastConsumedSeq = 0;
91
+ }
@@ -8,6 +8,7 @@ import path from "node:path";
8
8
  import { fileURLToPath } from "node:url";
9
9
  import { loadSpineConfig } from "../config/spine-config-load.mjs";
10
10
  import { resolveDashboardPollMs } from "../config/spine-config-schema.mjs";
11
+ import { consumeDashboardInvalidateSignal } from "./cache-invalidate.mjs";
11
12
  import { buildDashboardSnapshot } from "./snapshot.mjs";
12
13
  import { formatSseDataFrame, writeSseHeaders } from "./sse.mjs";
13
14
 
@@ -125,6 +126,12 @@ export function createSharedSnapshotPollHub({
125
126
  };
126
127
 
127
128
  const refreshSharedSnapshot = () => {
129
+ const invalidated = consumeDashboardInvalidateSignal(projectRoot);
130
+ if (invalidated) {
131
+ for (const client of sseClients) {
132
+ client.lastSerialized = "";
133
+ }
134
+ }
128
135
  snapshotGeneration += 1;
129
136
  const snapshot = {
130
137
  ...buildSnapshot(projectRoot),
@@ -26,6 +26,7 @@ import {
26
26
  metricsFilePath,
27
27
  readMetricsLines,
28
28
  } from "../batch/metrics.mjs";
29
+ import { consumeDashboardInvalidateSignal } from "./cache-invalidate.mjs";
29
30
  import { buildLaneRows } from "./snapshot-lanes.mjs";
30
31
  import {
31
32
  buildDefaultViewStatus,
@@ -42,6 +43,7 @@ export const DASHBOARD_JOURNAL_TAIL_LIMIT = 20;
42
43
  * @param {string} projectRoot
43
44
  */
44
45
  export function buildDashboardSnapshot(projectRoot) {
46
+ consumeDashboardInvalidateSignal(projectRoot);
45
47
  const configResult = loadSpineConfig(projectRoot);
46
48
  const stallConfig = resolveStallConfig(configResult.config ?? {});
47
49
  const reconciliation = reconcileBatch({ projectRoot, verbose: true });
@@ -131,5 +131,9 @@ export function formatPlanHuman(plan) {
131
131
  lines.push(`Start: spine batch start ${firstWave.taskIds.join(" ")}`);
132
132
  }
133
133
 
134
- return appendBatchSizeGuidanceToPlanOutput(`${lines.join("\n").trimEnd()}\n`, plan);
134
+ let output = `${lines.join("\n").trimEnd()}\n`;
135
+ if (Array.isArray(plan.waveSizeWarnings) && plan.waveSizeWarnings.length > 0) {
136
+ output = `${output.trimEnd()}\n\n${plan.waveSizeWarnings.join("\n")}\n`;
137
+ }
138
+ return appendBatchSizeGuidanceToPlanOutput(output, plan);
135
139
  }
@@ -16,7 +16,7 @@ import {
16
16
  import { buildGraph, topoWaves } from './graph.mjs';
17
17
  import { findCyclePath } from './cycles.mjs';
18
18
  import { parseScope } from './scope.mjs';
19
- import { formatFileScopeOverlapWarnings, planWaves } from './waves.mjs';
19
+ import { collectWaveSizeWarnings, formatFileScopeOverlapWarnings, planWaves } from './waves.mjs';
20
20
 
21
21
  /**
22
22
  * @param {{ scope?: any, config: { lanes?: { maxParallel?: number, queueExcess?: boolean } }, tasksRoot: string }} args
@@ -95,6 +95,7 @@ export function buildPlan({ scope, config, tasksRoot }) {
95
95
  });
96
96
 
97
97
  const overlapWarnings = formatFileScopeOverlapWarnings(fileScopeOverlaps);
98
+ const waveSizeWarnings = collectWaveSizeWarnings(waves);
98
99
 
99
100
  return {
100
101
  generatedAt: new Date().toISOString(),
@@ -125,5 +126,6 @@ export function buildPlan({ scope, config, tasksRoot }) {
125
126
  ...(fileScopeOverlaps.length > 0 ? { fileScopeOverlaps } : {}),
126
127
  },
127
128
  ...(overlapWarnings.length > 0 ? { overlapWarnings } : {}),
129
+ ...(waveSizeWarnings.length > 0 ? { waveSizeWarnings } : {}),
128
130
  };
129
131
  }
@@ -132,3 +132,44 @@ export function formatFileScopeOverlapWarnings(overlaps) {
132
132
  }
133
133
  return lines;
134
134
  }
135
+
136
+ /** Topological waves with more than this many tasks trigger a planner warning (FR-STA-12 / issue #143). */
137
+ export const WAVE_SIZE_WARN_THRESHOLD = 8;
138
+
139
+ /**
140
+ * Collect warning lines when any wave exceeds the task limit.
141
+ * Mega-waves stall pi workers (Phase 15 / SP-086–088).
142
+ *
143
+ * @param {string[][]} waves
144
+ * @returns {string[]}
145
+ */
146
+ export function collectWaveSizeWarnings(waves) {
147
+ if (!Array.isArray(waves) || waves.length === 0) {
148
+ return [];
149
+ }
150
+
151
+ /** @type {Array<{ waveIndex: number, taskCount: number }>} */
152
+ const oversized = [];
153
+ for (let waveIndex = 0; waveIndex < waves.length; waveIndex++) {
154
+ const taskIds = waves[waveIndex];
155
+ const taskCount = Array.isArray(taskIds) ? taskIds.length : 0;
156
+ if (taskCount > WAVE_SIZE_WARN_THRESHOLD) {
157
+ oversized.push({ waveIndex, taskCount });
158
+ }
159
+ }
160
+
161
+ if (oversized.length === 0) {
162
+ return [];
163
+ }
164
+
165
+ const lines = [
166
+ `Wave size warning: ${oversized.length} wave(s) exceed ${WAVE_SIZE_WARN_THRESHOLD} tasks (mega-waves stall pi workers):`,
167
+ ];
168
+ for (const { waveIndex, taskCount } of oversized) {
169
+ lines.push(` Wave ${waveIndex}: ${taskCount} tasks`);
170
+ }
171
+ lines.push(
172
+ ' Split waves per create-spine-tasks guidance (prefer ≤4 M-sized tasks per wave; see skills/create-spine-tasks/SKILL.md).',
173
+ );
174
+ return lines;
175
+ }
@@ -11,8 +11,42 @@ export const TEST_COMMAND_COVERAGE_FIX_HINT =
11
11
  export const TEST_COMMAND_NPM_TEST_FIX_HINT =
12
12
  "Use scoped node --test path/to.test.mjs instead of npm test on S/M patch tasks.";
13
13
 
14
+ /** npm test -- <path> does not scope; npm forwards args to the script, which still runs the full suite (issue #187). */
15
+ export const TEST_COMMAND_NPM_TEST_DASH_DASH_FIX_HINT =
16
+ "npm test -- <path> runs the full suite, not the path argument. Use scoped node --test path/to.test.mjs instead.";
17
+
14
18
  const PATCH_TASK_SIZES = new Set(["S", "M"]);
15
19
 
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+/;
22
+
23
+ /**
24
+ * Warn when S/M task contracts use npm test -- <path> false scoping (issues #187, #141).
25
+ *
26
+ * @param {ReturnType<import("./packet/parse-prompt.mjs").parseContract>} parsed
27
+ * @param {{ taskSize?: "S"|"M"|"L"|"XL"|null }} [options]
28
+ * @returns {string[]}
29
+ */
30
+ export function collectNpmTestDashDashWarnings(parsed, options = {}) {
31
+ const taskSize = options.taskSize ?? null;
32
+ if (!PATCH_TASK_SIZES.has(taskSize)) {
33
+ return [];
34
+ }
35
+
36
+ const testCommand = parsed?.testCommand;
37
+ if (!testCommand || testCommand === "true") {
38
+ return [];
39
+ }
40
+
41
+ if (!NPM_TEST_DASH_DASH_RE.test(testCommand)) {
42
+ return [];
43
+ }
44
+
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
+ ];
48
+ }
49
+
16
50
  /**
17
51
  * Warn when S/M task contracts chain full-suite gates in testCommand.
18
52
  *
@@ -40,7 +74,10 @@ export function collectTestCommandScopeWarnings(parsed, options = {}) {
40
74
  );
41
75
  }
42
76
 
43
- if (/\bnpm test\b/.test(testCommand)) {
77
+ const npmTestDashDashWarnings = collectNpmTestDashDashWarnings(parsed, options);
78
+ if (npmTestDashDashWarnings.length > 0) {
79
+ warnings.push(...npmTestDashDashWarnings);
80
+ } else if (/\bnpm test\b/.test(testCommand)) {
44
81
  warnings.push(
45
82
  `Contract testCommand uses npm test on Size ${taskSize} patch task. ${TEST_COMMAND_NPM_TEST_FIX_HINT}`,
46
83
  );