pi-spine 1.7.0 → 1.8.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.
Files changed (129) hide show
  1. package/bin/spine-doctor.mjs +4 -0
  2. package/package.json +2 -2
  3. package/skills/create-spine-tasks/SKILL.md +1 -0
  4. package/skills/spine-autonomous-operator/SKILL.md +267 -0
  5. package/skills/spine-autonomous-operator/references/issue-template.md +45 -0
  6. package/skills/spine-orchestrate-waves/SKILL.md +1 -0
  7. package/skills/spine-release-operator/SKILL.md +44 -8
  8. package/skills/spine-release-operator/references/pi-async-orchestration.md +88 -0
  9. package/skills/spine-release-operator/scripts/collect-release-intake.sh +71 -0
  10. package/src/batch/abort.mjs +1 -0
  11. package/src/batch/agent-session-worker.mjs +1 -0
  12. package/src/batch/attached-engine-handoff.mjs +1 -0
  13. package/src/batch/attached-runner.mjs +100 -2
  14. package/src/batch/contract-prelanded.mjs +1 -0
  15. package/src/batch/contract-task-start.mjs +1 -0
  16. package/src/batch/contract-verify.mjs +1 -0
  17. package/src/batch/detached-start.mjs +1 -0
  18. package/src/batch/diagnosis-launch-failure.mjs +1 -0
  19. package/src/batch/diagnosis-merge-failure.mjs +1 -0
  20. package/src/batch/diagnosis-retry-limbo.mjs +1 -0
  21. package/src/batch/diagnosis-tail-state.mjs +6 -0
  22. package/src/batch/diagnosis-task-done.mjs +1 -0
  23. package/src/batch/diagnosis-worker-done-missing.mjs +1 -0
  24. package/src/batch/diagnosis.mjs +4 -2
  25. package/src/batch/engine-lanes/commit.mjs +1 -0
  26. package/src/batch/engine-lanes/merge.mjs +1 -0
  27. package/src/batch/engine-lanes/queue.mjs +1 -0
  28. package/src/batch/engine-lanes/review.mjs +1 -0
  29. package/src/batch/engine-lanes.mjs +1 -0
  30. package/src/batch/engine-scope.mjs +1 -0
  31. package/src/batch/engine.mjs +19 -9
  32. package/src/batch/evidence.mjs +1 -0
  33. package/src/batch/gate-evidence-collect.mjs +1 -0
  34. package/src/batch/gate-evidence-read.mjs +1 -0
  35. package/src/batch/gate.mjs +1 -0
  36. package/src/batch/git-helpers.mjs +1 -1
  37. package/src/batch/heartbeat-git-debounce.mjs +83 -0
  38. package/src/batch/heartbeat.mjs +17 -20
  39. package/src/batch/integrate-worktree.mjs +1 -0
  40. package/src/batch/integrate.mjs +1 -0
  41. package/src/batch/journal-rebuild.mjs +118 -0
  42. package/src/batch/journal.mjs +2 -1
  43. package/src/batch/lane-commit.mjs +1 -0
  44. package/src/batch/lane-dirty-check.mjs +1 -0
  45. package/src/batch/lifecycle.mjs +1 -0
  46. package/src/batch/limbo-detect.mjs +1 -0
  47. package/src/batch/macro-phase.mjs +41 -2
  48. package/src/batch/merge/adoption-doc-merge.mjs +1 -0
  49. package/src/batch/merge/wave-merge-state.mjs +1 -0
  50. package/src/batch/metrics.mjs +1 -0
  51. package/src/batch/orphan-detect.mjs +106 -2
  52. package/src/batch/pause.mjs +1 -0
  53. package/src/batch/post-merge-limbo.mjs +1 -0
  54. package/src/batch/postmortem.mjs +1 -0
  55. package/src/batch/readers/spine-state.mjs +1 -0
  56. package/src/batch/readers/taskplane-state.mjs +1 -0
  57. package/src/batch/reconcile.mjs +236 -18
  58. package/src/batch/resume-common.mjs +1 -0
  59. package/src/batch/resume-engine.mjs +1 -0
  60. package/src/batch/resume-multi-lanes.mjs +1 -0
  61. package/src/batch/resume-multi-validate.mjs +1 -0
  62. package/src/batch/resume-multi.mjs +1 -0
  63. package/src/batch/resume-validation.mjs +1 -0
  64. package/src/batch/resume.mjs +1 -0
  65. package/src/batch/retry.mjs +1 -0
  66. package/src/batch/review-shared.mjs +1 -0
  67. package/src/batch/review-spawn.mjs +1 -0
  68. package/src/batch/review.mjs +1 -0
  69. package/src/batch/rules-manifest-drift.mjs +1 -0
  70. package/src/batch/salvage.mjs +1 -0
  71. package/src/batch/sequence.mjs +5 -2
  72. package/src/batch/state.mjs +1 -0
  73. package/src/batch/supervisor-spawn.mjs +1 -0
  74. package/src/batch/task-stall-budget.mjs +3 -4
  75. package/src/batch/worker-host.mjs +31 -25
  76. package/src/batch/worker-output.mjs +1 -0
  77. package/src/batch/worker-prompt.mjs +1 -0
  78. package/src/cli/journal-follow.mjs +1 -1
  79. package/src/config/agent-model-resolve.mjs +1 -0
  80. package/src/config/contract.mjs +1 -0
  81. package/src/config/cursor-rules/discover.mjs +1 -0
  82. package/src/config/cursor-rules/match-globs.mjs +1 -0
  83. package/src/config/cursor-rules/parse-frontmatter.mjs +1 -0
  84. package/src/config/cursor-rules/profile.mjs +1 -0
  85. package/src/config/cursor-rules/select.mjs +1 -0
  86. package/src/config/env-overrides.mjs +1 -0
  87. package/src/config/pi-spine-root.mjs +1 -0
  88. package/src/config/preflight/discovery.mjs +333 -0
  89. package/src/config/preflight/git-batch.mjs +320 -0
  90. package/src/config/preflight/integrate-plan.mjs +460 -0
  91. package/src/config/reviewer-context.mjs +1 -0
  92. package/src/config/settings-fields.mjs +1 -0
  93. package/src/config/spine-config-schema.mjs +1 -0
  94. package/src/config/spine-init-constants.mjs +1 -0
  95. package/src/config/spine-preflight-lib.mjs +54 -1013
  96. package/src/config/worker-backend.mjs +1 -0
  97. package/src/config/worker-context.mjs +1 -0
  98. package/src/config/worker-launch-script.mjs +1 -0
  99. package/src/config/worktree-setup-hook.mjs +1 -0
  100. package/src/dashboard/public/dashboard.js +6 -1
  101. package/src/dashboard/running-tail-state.mjs +1 -0
  102. package/src/dashboard/server.mjs +136 -16
  103. package/src/dashboard/snapshot-lanes.mjs +479 -0
  104. package/src/dashboard/snapshot-waves.mjs +299 -0
  105. package/src/dashboard/snapshot.mjs +45 -863
  106. package/src/doctor/agent-model-inherit.mjs +1 -0
  107. package/src/doctor/agent-models.mjs +1 -0
  108. package/src/doctor/attached-orphan-risk.mjs +114 -0
  109. package/src/doctor/coexistence.mjs +1 -0
  110. package/src/doctor/run-doctor-checks.mjs +3 -0
  111. package/src/doctor/stale-path.mjs +1 -0
  112. package/src/doctor/stall-config.mjs +1 -0
  113. package/src/doctor/suggest-max-parallel.mjs +1 -0
  114. package/src/doctor/task-packet-size.mjs +3 -10
  115. package/src/doctor/worktree-health.mjs +1 -0
  116. package/src/planner/cycles.mjs +1 -0
  117. package/src/planner/file-scope.mjs +1 -0
  118. package/src/planner/format-plan.mjs +1 -0
  119. package/src/planner/graph.mjs +1 -0
  120. package/src/planner/scope.mjs +1 -0
  121. package/src/planner/wave-scope.mjs +1 -0
  122. package/src/planner/waves.mjs +1 -0
  123. package/src/tasks/packet/merge-deps.mjs +1 -0
  124. package/src/tasks/packet/parse-prompt.mjs +4 -3
  125. package/src/tasks/packet/parse-status.mjs +1 -0
  126. package/src/tasks/packet/size-line.mjs +12 -0
  127. package/src/tasks/packet/validate-contract.mjs +9 -1
  128. package/src/tasks/packet/validate-prompt.mjs +2 -0
  129. package/src/tasks/validate-contract-warn.mjs +50 -0
@@ -11,6 +11,10 @@ import {
11
11
  } from "./spine-cli/shared.mjs";
12
12
  import { runDoctorChecks } from "../src/doctor/run-doctor-checks.mjs";
13
13
 
14
+ export {
15
+ buildAttachedOrphanRiskDoctorCheck,
16
+ detectAttachedOrphanRiskPatterns,
17
+ } from "../src/doctor/attached-orphan-risk.mjs";
14
18
  export { buildTestingEvidenceDoctorChecks, runDoctorChecks } from "../src/doctor/run-doctor-checks.mjs";
15
19
 
16
20
  export function cmdDoctor() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-spine",
3
- "version": "1.7.0",
3
+ "version": "1.8.1",
4
4
  "description": "Orchestration spine for long-running pi development",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -69,7 +69,7 @@
69
69
  }
70
70
  },
71
71
  "devDependencies": {
72
- "@earendil-works/pi-coding-agent": "^0.78.0",
72
+ "@earendil-works/pi-coding-agent": "^0.80.3",
73
73
  "@types/node": "^22.19.18",
74
74
  "eslint": "^9.28.0",
75
75
  "globals": "^16.2.0",
@@ -501,6 +501,7 @@ Hydration commits (STATUS.md expansions) may happen mid-step for crash recovery.
501
501
 
502
502
  - **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.
503
503
  - **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.
504
+ - **S/M patch tasks: no coverage gate in Contract** — do not chain `npm run coverage:check` or bare `npm test` in `## Contract` `testCommand` on Size S/M tasks; integrate gate owns full coverage at merge. Use scoped `node --test path/to.test.mjs` (SP-521 / [#141](https://github.com/beettlle/pi-spine/issues/141)). `spine tasks validate` warns when violated.
504
505
  - **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.
505
506
  - **Documentation in every task** — "Must Update" / "Check If Affected" prevent doc drift.
506
507
  - **Concrete deliverables** — name files to create/modify; avoid shortcuttable vague steps.
@@ -0,0 +1,267 @@
1
+ ---
2
+ name: spine-autonomous-operator
3
+ description: Autonomous pi-spine batch operator for pending tasks. Audits task sizing and decomposition, maximizes safe parallelization, runs preflight, executes wave-by-wave batch start with gate/integrate/complete land loop, recovers from failures, and files upstream bugs at beettlle/pi-spine. Use when asked to run all pending spine tasks, execute a full spine batch, operate spine waves, or finish SP-* tasks with clean preflight.
4
+ disable-model-invocation: true
5
+ compatibility: Requires spine CLI, gh CLI (for issue filing), git, Node >= 22. Run from pi-spine repo root on main.
6
+ ---
7
+
8
+ # Spine Autonomous Operator
9
+
10
+ You are the **pi-spine batch operator** for this repository. Drive all **pending** spine tasks to completion with maximum **safe** parallelization. You operate batches; you do **not** implement product code unless recovery requires fixing task packets or repo hygiene.
11
+
12
+ For **curated semver releases** (subset scope, publish gates), use [`skills/spine-release-operator/SKILL.md`](../spine-release-operator/SKILL.md) instead.
13
+
14
+ Invoke explicitly: `/skill:spine-autonomous-operator`
15
+
16
+ ## Success criteria
17
+
18
+ 1. `spine plan pending` shows **0 pending tasks**
19
+ 2. `spine preflight` passes with a **clean** git tree
20
+ 3. All work is **integrated on `main`** (not stuck in worktrees)
21
+ 4. Repeatable pi-spine **engine** faults have GitHub issues filed
22
+ 5. Final report: waves completed, tasks done, issues filed, verification output
23
+
24
+ ## Hard rules
25
+
26
+ - **Never** hand-edit `.spine/batch-state.json` or journal files under `.spine/runtime/`
27
+ - **Never** implement product code in task folders while a batch owns that scope
28
+ - **Never** claim batch/test success without CLI output
29
+ - **Always** use `spine status --diagnose` for recovery; follow `suggestedCommand`
30
+ - **Always** run `spine gate approve` before `spine integrate`
31
+ - **Always** run `npm install` on `main` after successful integrate
32
+ - **Do not** use unattended `spine run sequence --auto-approve-gate --force` without monitoring
33
+ - **Do not** start a second batch while another batch is **running** on the same repo
34
+ - **Never** background `spine batch resume --attached` or `resume --attached --force` ([#163](https://github.com/beettlle/pi-spine/issues/163))
35
+ - **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
+ ## Phase 0 — Baseline
38
+
39
+ ```bash
40
+ cd <repo-root>
41
+ spine --version
42
+ spine doctor
43
+ git status
44
+ git branch --show-current # must be main
45
+ spine status --diagnose # readonly — do not collide with active batch
46
+ ```
47
+
48
+ If not on `main`, stop and ask the operator. If another operator's batch is **running**, stop unless explicitly asked to take over recovery.
49
+
50
+ ## Phase 1 — Audit pending tasks
51
+
52
+ ### 1.1 Inventory
53
+
54
+ ```bash
55
+ spine plan pending
56
+ spine tasks validate pending
57
+ spine tasks analyze pending
58
+ spine deps pending
59
+ ```
60
+
61
+ Read `spine-tasks/CONTEXT.md` for `Next Task ID` and phase notes.
62
+
63
+ ### 1.2 Size audit
64
+
65
+ For each pending `spine-tasks/{SP-###-slug}/PROMPT.md`:
66
+
67
+ | Size | Target | Action if exceeded |
68
+ |------|--------|-------------------|
69
+ | **S** | <2h, ≤4 impl steps | Keep |
70
+ | **M** | 2–4h | OK if file scope disjoint from parallel neighbors |
71
+ | **L** | 4–8h | **Split** into multiple S/M tasks |
72
+ | **XL** | >8h or >4 steps | **Must split** |
73
+
74
+ **Decompose** when:
75
+ - More than 4 implementation steps (excluding Testing + Completion Criteria)
76
+ - Multiple unrelated file areas in one task
77
+ - Same hot file in parallel tasks (serialize via `dependencies.json`)
78
+ - M/L tasks share overlapping `fileScopeMustChange` in the same wave
79
+
80
+ ### 1.3 Parallelization audit
81
+
82
+ - [ ] `dependencies.json` matches PROMPT `## Dependencies`
83
+ - [ ] Same-wave tasks have **disjoint** `fileScopeMustChange`
84
+ - [ ] Hot shared files are serial (e.g. `src/batch/heartbeat.mjs`, `bin/spine.mjs`)
85
+ - [ ] No directory paths with trailing `/` in contracts — use explicit files
86
+ - [ ] No parenthetical comments in contract paths (e.g. `file.ts (Step 2 only)`)
87
+ - [ ] Pre-landed code on `main` → point `fileScopeMustChange` at `spine-tasks/{task}/STATUS.md` + `## Amendments`
88
+
89
+ After changes:
90
+
91
+ ```bash
92
+ spine tasks validate pending
93
+ spine tasks analyze pending
94
+ spine plan pending
95
+ ```
96
+
97
+ ### 1.4 Commit packet changes
98
+
99
+ ```bash
100
+ git add spine-tasks/ .spine/spine-config.json # only if changed
101
+ git commit -m "chore(spine): refine pending task packets for safe parallel execution"
102
+ ```
103
+
104
+ Repo hygiene that breaks preflight:
105
+ - Add `coverage/`, `node_modules/`, `.pi/` to `.gitignore` if missing
106
+ - `git worktree prune` after abort
107
+
108
+ ## Phase 2 — Preflight gate
109
+
110
+ ```bash
111
+ spine preflight
112
+ ```
113
+
114
+ All checks must pass (`git-clean`, `no-active-batch`, `tasks-validate`, `prelanded-file-scope`, `plan`). Fix, commit, re-run until green. **Do not start a batch on failed preflight** or while another batch is running.
115
+
116
+ ## Phase 3 — Wave execution loop
117
+
118
+ Preview the plan:
119
+
120
+ ```bash
121
+ spine run sequence pending --dry-run
122
+ ```
123
+
124
+ For each wave `N` until `spine plan pending` shows 0 tasks:
125
+
126
+ ### 3.1 Start
127
+
128
+ **pi async (preferred in pi sessions)** — see [pi-async-orchestration.md](../spine-release-operator/references/pi-async-orchestration.md):
129
+
130
+ ```text
131
+ MonitorCreate:
132
+ command: spine batch start pending --wave N # detached — omit --attached (#163)
133
+ description: Pending wave N
134
+ timeout: 0
135
+ onDone: spine status --diagnose → land loop (§3.3) or recovery (§4)
136
+ ```
137
+
138
+ After detached start, monitor with `spine wait --until completed,needs_integrate,failed,aborted --timeout 4h` or `spine status --diagnose`.
139
+
140
+ **Foreground fallback** (interactive terminal only — keep shell in foreground for full batch):
141
+
142
+ ```bash
143
+ spine batch start pending --wave N --attached
144
+ ```
145
+
146
+ ### 3.2 Monitor
147
+
148
+ ```bash
149
+ spine status --diagnose
150
+ # or block:
151
+ spine wait --until completed,failed,needs_integrate,needs_retry,aborted --timeout 2h
152
+ ```
153
+
154
+ Optional: `spine watch --once`, `spine dashboard`
155
+
156
+ ### 3.2a Pi async watchdog (optional)
157
+
158
+ If MonitorCreate `onDone` did not fire but batch may still be running:
159
+
160
+ ```text
161
+ LoopCreate: trigger "2m", readOnly true, maxFires 50
162
+ prompt: check spine status --diagnose; LoopDelete self on terminal diagnosis
163
+ ```
164
+
165
+ **Do not** start the next wave until the current wave is fully landed on `main`.
166
+
167
+ ### 3.3 Land loop
168
+
169
+ When diagnosis is `needs_integrate` or gate is open:
170
+
171
+ ```bash
172
+ spine gate status
173
+ spine gate approve
174
+ spine integrate
175
+ npm install
176
+ spine batch complete
177
+ git add spine-tasks/*/.DONE 2>/dev/null; git commit -m "chore: track .DONE for wave N" || true
178
+ ```
179
+
180
+ Verify: `git status` clean, `.DONE` count increased.
181
+
182
+ ### 3.4 Advance
183
+
184
+ Increment `N` and repeat.
185
+
186
+ ## Phase 4 — Recovery
187
+
188
+ Always: `spine status --diagnose`
189
+
190
+ | Diagnosis | Action |
191
+ |-----------|--------|
192
+ | `running` | Wait; `spine watch` or async watchdog |
193
+ | `paused` | `spine batch resume` (foreground if `--attached`) |
194
+ | `needs_retry` | Fix packet if needed; `spine batch retry <taskId>` |
195
+ | `worker_orphaned` | `abort` → `dismiss` → prune worktree → retry wave |
196
+ | `needs_integrate` | Land loop (gate → integrate → npm install → complete) |
197
+ | `state_drift` | `spine batch retry <taskId>`; then **`spine batch resume --attached --force` in foreground** |
198
+ | `failed` / `aborted` | Inspect journal; fix packet; dismiss; retry |
199
+ | Contract fail | Fix PROMPT on **main**, commit, abort, dismiss, prune, retry |
200
+ | Integrate hang | Manual `spine integrate` + `spine batch complete`; file upstream issue |
201
+
202
+ **After abort:**
203
+
204
+ ```bash
205
+ spine batch abort --reason recovery
206
+ spine batch dismiss --reason recovery
207
+ rm -rf .worktrees/spine-* # if stale
208
+ git worktree prune
209
+ spine preflight
210
+ ```
211
+
212
+ ## Phase 5 — File upstream pi-spine issues
213
+
214
+ File at https://github.com/beettlle/pi-spine/issues when:
215
+ - Same diagnosis repeats after `suggestedCommand`
216
+ - Engine crash, orphan, gate bug, integrate hang, verifier false positive
217
+
218
+ **Not** for: misconfig, dirty git, bad packets, consumer code bugs.
219
+
220
+ ```bash
221
+ spine issue draft --type bug --json
222
+ spine issue draft --type bug --create
223
+ # or:
224
+ gh issue create --repo beettlle/pi-spine --title "..." --body-file .spine/issue-draft.md
225
+ ```
226
+
227
+ Search existing issues first. Include version, commands, diagnosis, journal excerpt, expected vs actual.
228
+
229
+ See [references/issue-template.md](references/issue-template.md) for a full template.
230
+
231
+ ## Phase 6 — Final verification
232
+
233
+ ```bash
234
+ spine plan pending
235
+ spine preflight
236
+ git status
237
+ npm run release:check
238
+ find spine-tasks -name '.DONE' | wc -l
239
+ ```
240
+
241
+ In pi sessions, `MonitorCreate` for `npm run release:check` is allowed (see pi-async-orchestration).
242
+
243
+ ## Final report (required)
244
+
245
+ 1. **Tasks completed** — SP-IDs and wave numbers
246
+ 2. **Decomposition changes** — splits/fixes in Phase 1
247
+ 3. **Issues filed** — pi-spine GitHub links or "none"
248
+ 4. **Recovery actions** — aborts, retries, contract fixes
249
+ 5. **Verification** — paste `spine preflight` tail and `spine plan pending`
250
+ 6. **Remaining blockers** — if any
251
+
252
+ ## Repo-specific notes (pi-spine)
253
+
254
+ - **Tasks root:** `spine-tasks/`
255
+ - **Config:** `.spine/spine-config.json`
256
+ - **Test gate:** `npm run release:check` (typecheck → lint → tests → coverage)
257
+ - **Known upstream issues:** #114 (integrate hang, fixed), #118 (trailing-slash contracts), #130 (`coverage/` restore), #163 (`engine_orphaned`)
258
+
259
+ ## Short prompt (resume mid-batch)
260
+
261
+ ```text
262
+ Run pending spine tasks: validate/analyze/plan → fix packets → preflight →
263
+ for each wave: MonitorCreate batch start (or foreground) → diagnose →
264
+ gate approve → integrate → npm install → batch complete.
265
+ Resume --attached --force stays foreground. File pi-spine bugs on engine faults.
266
+ Done when 0 pending, preflight green, release:check passes. Post final report.
267
+ ```
@@ -0,0 +1,45 @@
1
+ # pi-spine upstream issue template
2
+
3
+ Use when filing engine/orchestrator bugs at https://github.com/beettlle/pi-spine/issues
4
+
5
+ ## Environment
6
+
7
+ - pi-spine: `spine --version`
8
+ - pi: `pi --version`
9
+ - Node: `node --version`
10
+ - Repo: `pi-spine` @ `git rev-parse --short HEAD`
11
+
12
+ ## Commands run
13
+
14
+ ```text
15
+ (paste exact spine commands)
16
+ ```
17
+
18
+ ## Diagnosis
19
+
20
+ ```text
21
+ (paste output of: spine status --diagnose)
22
+ ```
23
+
24
+ ## Journal excerpt
25
+
26
+ ```bash
27
+ spine journal replay --batch <batchId>
28
+ ```
29
+
30
+ ```text
31
+ (paste last 20–40 lines relevant to failure)
32
+ ```
33
+
34
+ ## Expected vs actual
35
+
36
+ - **Expected:** ...
37
+ - **Actual:** ...
38
+
39
+ ## Minimal reproduction
40
+
41
+ Steps another operator can follow on pi-spine or a consumer repo.
42
+
43
+ ## Related issues
44
+
45
+ Search first: #114 integrate hang, #118 contract trailing-slash, #130 coverage restore, #163 engine_orphaned
@@ -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
+ | Pi async batch/verify (MonitorCreate) | [spine-release-operator/references/pi-async-orchestration.md](../spine-release-operator/references/pi-async-orchestration.md) |
24
25
  | Canonical how-to prose | [references/outer-loop.md](references/outer-loop.md) (synced from `docs/adoption/agent-orchestrated-waves.md`) |
25
26
  | Slash entry (`/spine-orchestrate`) | pi-spine extension — wave plan + outer loop checklist |
26
27
  | Single-task suggested command | `/spine-next` inside land loop |
@@ -17,7 +17,8 @@ Invoke explicitly: `/skill:spine-release-operator` or "run a spine release cycle
17
17
  | Concern | Delegate to |
18
18
  |---------|-------------|
19
19
  | PROMPT/STATUS/Contract authoring | `create-spine-tasks` skill + templates |
20
- | Batch land loop / recovery | Phases below (adapted from `spine-autonomous-operator`) |
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
+ | Wave evidence / diagnosis tree | [`spine-orchestrate-waves`](../spine-orchestrate-waves/SKILL.md) |
21
22
  | Semver scope budgets | [references/release-profiles.md](references/release-profiles.md) |
22
23
  | Issue intake queries | [references/issue-intake-checklist.md](references/issue-intake-checklist.md) |
23
24
  | Manifest format | [references/release-manifest-template.md](references/release-manifest-template.md) |
@@ -44,6 +45,8 @@ Invoke explicitly: `/skill:spine-release-operator` or "run a spine release cycle
44
45
  - **Always** run `spine gate approve` before `spine integrate`
45
46
  - **Always** run `npm install` on `main` after successful integrate
46
47
  - **Do not** execute tasks outside the approved manifest scope
48
+ - **Do not** start a second batch while another batch is **running** on this repo
49
+ - **Never** background `spine batch resume --attached` or `resume --attached --force` ([#163](https://github.com/beettlle/pi-spine/issues/163))
47
50
  - **Always** run `/gitnexus analyze` (Pre-work) before Phase 0 — do not start intake, authoring, or batches on a stale index
48
51
 
49
52
  ---
@@ -106,6 +109,13 @@ If not on `main`, stop. If git is dirty, commit or stash hygiene fixes before re
106
109
 
107
110
  Follow [references/issue-intake-checklist.md](references/issue-intake-checklist.md).
108
111
 
112
+ Optional snapshot (readonly):
113
+
114
+ ```bash
115
+ skills/spine-release-operator/scripts/collect-release-intake.sh {TARGET}
116
+ # optional: tee spine-tasks/_authoring/release-v{TARGET}/intake-snapshot-$(date -u +%Y%m%d).md
117
+ ```
118
+
109
119
  **GitHub issues:**
110
120
 
111
121
  ```bash
@@ -235,7 +245,21 @@ spine run sequence <release-scope> --dry-run
235
245
 
236
246
  For each wave `N` until all release-scoped tasks are `.DONE`:
237
247
 
238
- ### 4.1 Start
248
+ Check `spine status --diagnose` first — if a batch is already **running** for this release, do not start another; follow recovery or wait.
249
+
250
+ ### 4.1 Start (pi async — preferred in pi sessions)
251
+
252
+ See [references/pi-async-orchestration.md](references/pi-async-orchestration.md):
253
+
254
+ ```text
255
+ MonitorCreate:
256
+ command: spine batch start <release-scope> --wave N --attached
257
+ description: Release wave N
258
+ timeout: 0
259
+ onDone: spine status --diagnose → §4.3 land loop or §4.4 recovery
260
+ ```
261
+
262
+ **Foreground fallback** (non-pi, or after #163 orphan on MonitorCreate):
239
263
 
240
264
  ```bash
241
265
  spine batch start <release-scope> --wave N --attached
@@ -249,6 +273,8 @@ spine status --diagnose
249
273
  spine wait --until completed,failed,needs_integrate,needs_retry,aborted --timeout 2h
250
274
  ```
251
275
 
276
+ Optional pi watchdog: `LoopCreate` every 2m, `readOnly: true`, `maxFires: 50` — see pi-async-orchestration.
277
+
252
278
  **Do not** start wave N+1 until wave N is integrated on `main`.
253
279
 
254
280
  Wave sizing: prefer ≤4 M-sized tasks per wave; serialize hot shared files.
@@ -278,7 +304,7 @@ Always: `spine status --diagnose`
278
304
  | `needs_retry` | Fix packet; `spine batch retry <taskId>` |
279
305
  | `worker_orphaned` | abort → dismiss → prune worktree → retry |
280
306
  | `needs_integrate` | Land loop |
281
- | `state_drift` | `spine batch retry <taskId>` (pause first if task still `running`); then `spine batch resume --attached --force` |
307
+ | `state_drift` | Follow `suggestedCommand` from diagnose: `spine batch retry <taskId>` when drift task is not `running`; `spine batch resume --force` when still `running` (SP-512 — not `pause && retry`). Then **`spine batch resume --attached --force` in foreground** if engine remains detached (never MonitorCreate) |
282
308
  | `failed` / `aborted` | Inspect journal; fix packet; dismiss; retry |
283
309
  | Contract fail | Fix PROMPT on main, commit, abort, dismiss, retry |
284
310
 
@@ -291,10 +317,17 @@ Always: `spine status --diagnose`
291
317
  ```bash
292
318
  spine plan <release-scope> # should show 0 pending for scope
293
319
  spine preflight
294
- npm run release:check # typecheck → lint → tests → coverage (CI parity)
295
320
  git status
296
321
  ```
297
322
 
323
+ **pi async (preferred):** `MonitorCreate` with `npm run release:check 2>&1 | tee /tmp/pi-spine-release-check.log`, `timeout: 900000`, `onDone` to read log tail and present checklist.
324
+
325
+ **Foreground fallback:**
326
+
327
+ ```bash
328
+ npm run release:check # typecheck → lint → tests → coverage (CI parity)
329
+ ```
330
+
298
331
  Present checklist from `docs/release/npm-publish.md`:
299
332
 
300
333
  - [ ] All release-scoped tasks done
@@ -322,6 +355,8 @@ Monitor CI:
322
355
  gh run list --workflow release.yml --limit 3
323
356
  ```
324
357
 
358
+ **pi async:** `MonitorCreate` with `gh run watch --exit-status <run-id>`, `timeout: 1800000`, `onDone` to report conclusion and run smoke tests if green.
359
+
325
360
  Post-publish smoke per `docs/release/npm-publish.md`:
326
361
 
327
362
  ```bash
@@ -362,10 +397,11 @@ Close GitHub issues where tasks had `Closes: #NNN` and work shipped.
362
397
  ## Short prompt (resume mid-release)
363
398
 
364
399
  ```text
365
- Resume spine release v{TARGET}: /gitnexus analyze (or gitnexus analyze) → gitnexus status →
400
+ Resume spine release v{TARGET}: /gitnexus analyze → gitnexus status →
366
401
  check manifest at spine-tasks/_authoring/release-v{TARGET}/manifest.md →
367
- verify remaining scope → preflight → for each wave: batch start --attached → diagnose →
402
+ spine status --diagnose (do not collide with running batch) →
403
+ preflight → for each wave: MonitorCreate batch start (or foreground) → onDone diagnose →
368
404
  gate approve → integrate → npm install → batch complete →
369
- when scope done: tests + preflight → STOP for publish approval.
370
- Post final report with composition table.
405
+ MonitorCreate release:check → STOP for publish approval.
406
+ resume --attached --force stays foreground. Post final report with composition table.
371
407
  ```
@@ -0,0 +1,88 @@
1
+ # Pi async orchestration (MonitorCreate / LoopCreate)
2
+
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
+
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.
6
+
7
+ ---
8
+
9
+ ## When to use MonitorCreate (preferred)
10
+
11
+ `MonitorCreate` runs a shell command in the background and fires an `onDone` prompt when it exits. No polling loop required.
12
+
13
+ | Command | timeout | Notes |
14
+ |---------|---------|-------|
15
+ | `spine batch start <scope> --wave N --attached` | `0` (none) | Wave batch; see safety rules below |
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
+ | `gh run watch --exit-status <run-id>` | `1800000` (30m) | After tag push; resolve run-id from `gh run list` |
18
+
19
+ ### onDone prompt template (batch)
20
+
21
+ ```text
22
+ Monitor for wave N completed. Run spine status --diagnose.
23
+ - needs_integrate: inspect .spine/runtime/<batchId>/evidence/ → gate approve → integrate → npm install → batch complete.
24
+ - needs_retry / failed / aborted: follow recovery table; do not start next wave.
25
+ - running: optional LoopCreate watchdog (below) or spine watch.
26
+ Paste diagnosis headline and exit evidence. Do not claim success without CLI output.
27
+ ```
28
+
29
+ ### onDone prompt template (release:check)
30
+
31
+ ```text
32
+ release:check monitor completed. Read tail of /tmp/pi-spine-release-check.log.
33
+ If exit 0: present pre-publish checklist from docs/release/npm-publish.md.
34
+ If non-zero: STOP; summarize first failing step; do not bump version.
35
+ ```
36
+
37
+ ---
38
+
39
+ ## When to use LoopCreate (watchdog only)
40
+
41
+ Use when MonitorCreate's completion wake is insufficient or you need lightweight status polling without blocking the session.
42
+
43
+ ```text
44
+ LoopCreate:
45
+ trigger: "2m"
46
+ readOnly: true
47
+ maxFires: 50
48
+ prompt: |
49
+ Check spine status --diagnose for batch <batchId>.
50
+ If diagnosis is terminal (needs_integrate, failed, aborted, needs_retry): LoopDelete this loop and run onDone actions.
51
+ If still running: do nothing.
52
+ ```
53
+
54
+ Prefer Monitor's built-in completion wake over LoopCreate when MonitorCreate was used for the same command.
55
+
56
+ ---
57
+
58
+ ## When NOT to async
59
+
60
+ | Action | Rule | Why |
61
+ |--------|------|-----|
62
+ | `spine batch resume --attached` | **Foreground shell only** | [#163](https://github.com/beettlle/pi-spine/issues/163) engine_orphaned |
63
+ | `spine batch resume --attached --force` | **Foreground shell only** | Same; release recovery discipline |
64
+ | `spine gate approve` | Agent must read evidence first | FR-SHIP-13; no auto-approve |
65
+ | Land loop during active recovery | Stay on current wave | Avoid parallel engines |
66
+
67
+ If `engine_orphaned` recurs after MonitorCreate on `batch start`, fall back to blocking `spine wait` for that wave and comment on #163.
68
+
69
+ ---
70
+
71
+ ## Cleanup
72
+
73
+ Before starting the next wave or ending the release session:
74
+
75
+ ```text
76
+ LoopList → LoopDelete any release watchdog loops
77
+ MonitorList → note completed monitors; MonitorStop any stale runners
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Do not interfere with active batches
83
+
84
+ Before authoring skill-driven commands:
85
+
86
+ 1. Run `spine status --diagnose` (readonly).
87
+ 2. If a batch is **running** for the current release, do not start a second batch or edit `.spine/runtime/**`.
88
+ 3. Skill/doc updates on `main` are safe; batch execution is owned by the active operator session.
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env bash
2
+ # Collect GitHub issues and spine backlog for release intake.
3
+ # Usage: from repo root: skills/spine-release-operator/scripts/collect-release-intake.sh [TARGET_VERSION]
4
+
5
+ set -euo pipefail
6
+
7
+ REPO_ROOT="$(cd "$(dirname "$0")/../../.." && pwd)"
8
+ cd "$REPO_ROOT"
9
+
10
+ TARGET="${1:-unknown}"
11
+
12
+ echo "=== pi-spine release intake snapshot ==="
13
+ echo "Target: v${TARGET}"
14
+ echo "Date: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
15
+ echo "Repo: $REPO_ROOT"
16
+ echo "Branch: $(git branch --show-current 2>/dev/null || echo unknown)"
17
+ echo "Package version: $(node -p "require('./package.json').version" 2>/dev/null || echo unknown)"
18
+ echo ""
19
+
20
+ echo "=== GitNexus status ==="
21
+ if command -v gitnexus >/dev/null 2>&1; then
22
+ gitnexus status 2>/dev/null || echo "(gitnexus status failed)"
23
+ else
24
+ echo "(gitnexus not installed)"
25
+ fi
26
+ echo ""
27
+
28
+ echo "=== GitHub open issues (beettlle/pi-spine) ==="
29
+ if command -v gh >/dev/null 2>&1; then
30
+ gh issue list --repo beettlle/pi-spine --state open --limit 100 \
31
+ --json number,title,labels,url,createdAt \
32
+ 2>/dev/null || echo "(gh failed — check auth)"
33
+ else
34
+ echo "(gh not installed)"
35
+ fi
36
+ echo ""
37
+
38
+ echo "=== Documentation issues ==="
39
+ if command -v gh >/dev/null 2>&1; then
40
+ gh issue list --repo beettlle/pi-spine --state open --label documentation \
41
+ --json number,title,labels \
42
+ 2>/dev/null || true
43
+ fi
44
+ echo ""
45
+
46
+ echo "=== Bug issues ==="
47
+ if command -v gh >/dev/null 2>&1; then
48
+ gh issue list --repo beettlle/pi-spine --state open --label bug \
49
+ --json number,title,labels \
50
+ 2>/dev/null || true
51
+ fi
52
+ echo ""
53
+
54
+ echo "=== Spine plan pending ==="
55
+ if command -v spine >/dev/null 2>&1; then
56
+ spine plan pending 2>/dev/null || true
57
+ else
58
+ echo "(spine not installed)"
59
+ fi
60
+ echo ""
61
+
62
+ echo "=== Issue → task mapping (Closes:/Partial:) ==="
63
+ if command -v rg >/dev/null 2>&1; then
64
+ rg 'Closes:|Partial:' spine-tasks/*/PROMPT.md 2>/dev/null || echo "(no mappings found)"
65
+ else
66
+ grep -r 'Closes:\|Partial:' spine-tasks/*/PROMPT.md 2>/dev/null || echo "(no mappings found)"
67
+ fi
68
+ echo ""
69
+
70
+ echo "=== Next Task ID (from CONTEXT.md) ==="
71
+ grep -E '^\*\*Next Task ID:\*\*' spine-tasks/CONTEXT.md 2>/dev/null || echo "(CONTEXT.md not found)"
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  /**
2
3
  * Archive-first batch abort (FR-BATCH-06, §18.6).
3
4
  */
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  /**
2
3
  * In-process lane worker via pi-coding-agent createAgentSession (TP-050 spike).
3
4
  */
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  /**
2
3
  * Attached engine post-merge SIGTERM survival (SP-316, GitHub #21).
3
4
  *