pi-spine 2.15.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-spine",
3
- "version": "2.15.0",
3
+ "version": "2.16.0",
4
4
  "description": "Orchestration spine for long-running pi development",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -35,7 +35,8 @@ Invoke explicitly: `/skill:spine-release-operator` or "run a spine release cycle
35
35
  4. `spine preflight` green; **`npm run release:check` green (blocking gate)** on current `main`
36
36
  5. **CI workflow green on release commit** (release-safe profile — parity with `ci.yml`) before tag push
37
37
  6. Operator explicitly approved publish; version bumped and tag pushed (if approved)
38
- 7. Final report with composition table, issues closed/deferred, verification output
38
+ 7. Every release-scoped `Closes #NNN` / `Closes: #NNN` issue is **CLOSED** on GitHub once its fix is on `main` (close after each land — do not wait for publish)
39
+ 8. Final report with composition table, issues closed/deferred, verification output
39
40
 
40
41
  ## Hard rules
41
42
 
@@ -57,6 +58,7 @@ Invoke explicitly: `/skill:spine-release-operator` or "run a spine release cycle
57
58
  - **Never** mid-release-edit `.spine/spine-config.json` agent pins (`agents.worker.model` / `agents.reviewer.model`) while a batch is running or integrated work is still unpublished. Pin **one worker** per release; escalate models **only** on content/contract failure — never on quota/403 or launch storms, which make releases worse (F7, [#248](https://github.com/beettlle/pi-spine/issues/248)). To override mid-release, first record the reason and date in the release manifest
58
59
  - **Heed** the doctor/preflight **quota-risk advisory** ([#251](https://github.com/beettlle/pi-spine/issues/251)): `spine doctor` surfaces `ok: true, warning: true` when escalate/hard worker pins target quota-constrained pools without headroom evidence, or recent run-metrics show launch-storm / quota-abort patterns. It is advisory only — never fails preflight — and does not change the mid-release pin-thrash ban above
59
60
  - **Always** push/sync `main` to `origin` after each land loop once the post-integrate regression gate is green — do not let `main` drift far ahead of `origin` during a release (F8, [#249](https://github.com/beettlle/pi-spine/issues/249))
61
+ - **Always** close GitHub issues linked as `Closes #NNN` / `Closes: #NNN` **as soon as that task's work is on `main`** (after integrate + post-integrate `release:check` green) — do **not** defer closing until Phase 6 publish. Leave `Partial #NNN` / `Partial: #NNN` open. Phase 6 is only a final sweep for any still-open `Closes` links (v2.15.0 left #257–#261, #263 open after ship — avoid that)
60
62
  - **Do not** start a second batch while another batch is **running** on this repo
61
63
  - **Never** background `spine batch resume --attached` or `resume --attached --force` ([#163](https://github.com/beettlle/pi-spine/issues/163))
62
64
  - **Release and agent batches:** use **detached** `spine batch start|resume` (omit `--attached`); monitor with MonitorCreate, `spine wait`, or `spine status --diagnose` ([#163](https://github.com/beettlle/pi-spine/issues/163), [#185](https://github.com/beettlle/pi-spine/issues/185)) — see [agent-shell-batch-policy.md](../spine-autonomous-operator/references/agent-shell-batch-policy.md)
@@ -149,7 +151,7 @@ spine tasks analyze pending
149
151
  **Map issues to tasks:**
150
152
 
151
153
  ```bash
152
- rg 'Closes:|Partial:' spine-tasks/*/PROMPT.md
154
+ rg 'Closes #|Closes:|Partial #|Partial:' spine-tasks/*/PROMPT.md
153
155
  ```
154
156
 
155
157
  Read `spine-tasks/CONTEXT.md` for `Next Task ID`.
@@ -205,7 +207,7 @@ Require explicit **"approve release scope"** before Phase 3.
205
207
  For issues in manifest without SP-*:
206
208
 
207
209
  - Follow **`create-spine-tasks`** (lean mode default)
208
- - Mission: `Closes: #NNN` (or `Partial:` when scoped)
210
+ - Mission: `Closes #NNN` (or `Closes: #NNN`) — use `Partial #NNN` / `Partial: #NNN` when scoped
209
211
  - Size S/M; ≤4 impl steps; Contract + Testing step
210
212
  - Update `dependencies.json`, `CONTEXT.md`, increment `Next Task ID`
211
213
 
@@ -349,6 +351,42 @@ git push origin main
349
351
 
350
352
  Do not let `main` drift far ahead of `origin` between waves — v2.12.1 ran **24 commits ahead** of `origin` at Phase 5 (F8, [#249](https://github.com/beettlle/pi-spine/issues/249)). Local-only releases may defer this push; record the deferral in the manifest publish checklist.
351
353
 
354
+ ### 4.3c Close GitHub issues for landed tasks (blocking hygiene)
355
+
356
+ After §4.3a is green (and §4.3b push when remote publish is the goal), **close every open issue fully resolved by tasks that just landed** — same wave, same land loop. Do not wait for Phase 6 or npm publish.
357
+
358
+ ```bash
359
+ # Issues linked from the wave's newly-.DONE tasks:
360
+ rg -n 'Closes #|Closes: #' spine-tasks/SP-*/PROMPT.md
361
+
362
+ # For each Closes #NNN (not Partial) whose SP-* is .DONE on main and still OPEN:
363
+ gh issue view NNN --repo beettlle/pi-spine --json state,title
364
+ gh issue close NNN --repo beettlle/pi-spine --reason completed --comment "$(cat <<EOF
365
+ Fixed on \`main\` by **SP-XXX** (release v{TARGET}).
366
+
367
+ - Commit(s): \`<sha>\` — <subject>
368
+ - Batch: <batchId> (integrated)
369
+ EOF
370
+ )"
371
+ ```
372
+
373
+ | Link in PROMPT Mission | Action after land |
374
+ |------------------------|-------------------|
375
+ | `Closes #NNN` / `Closes: #NNN` | **Close** when that task's `.DONE` is on `main` and §4.3a passed |
376
+ | `Partial #NNN` / `Partial: #NNN` | **Leave open** — note progress in a comment if useful |
377
+ | Manifest-mapped issue with no `Closes` line | Close only if acceptance criteria are fully met; otherwise comment + leave open |
378
+
379
+ **Fail closed before next wave / Phase 5:** every release-scoped `Closes #NNN` for tasks already `.DONE` on `main` must show `state: CLOSED`. Re-check:
380
+
381
+ ```bash
382
+ # Example: verify still-open Closes targets for release-scoped DONE tasks
383
+ for n in $(rg -o 'Closes:? #([0-9]+)' -r '$1' spine-tasks/SP-*/PROMPT.md | sort -u); do
384
+ gh issue view "$n" --repo beettlle/pi-spine --json number,state -q '"\(.number) \(.state)"'
385
+ done
386
+ ```
387
+
388
+ Record closed issue numbers in the release manifest intake / composition notes.
389
+
352
390
  ### 4.4 Recovery
353
391
 
354
392
  Always: `spine status --diagnose`
@@ -489,20 +527,33 @@ If retries exhaust, **STOP** — treat it as a real missing-version failure and
489
527
 
490
528
  Update `spine-tasks/CONTEXT.md` release note (version + date).
491
529
 
492
- Close GitHub issues where tasks had `Closes: #NNN` and work shipped.
530
+ ### Close remaining GitHub issues (final sweep)
531
+
532
+ §4.3c should already have closed each `Closes #NNN` when its task landed. Before the final report, **sweep** any still-open issues that release-scoped DONE tasks fully resolve:
533
+
534
+ ```bash
535
+ rg -n 'Closes #|Closes: #' spine-tasks/SP-*/PROMPT.md
536
+ # For each still-OPEN Closes #NNN whose SP-* is .DONE on main:
537
+ gh issue close NNN --repo beettlle/pi-spine --reason completed --comment "…"
538
+ ```
539
+
540
+ Include the published version/tag in the close comment when closing at Phase 6 (e.g. `Shipped in **v{TARGET}**`). Leave `Partial #NNN` open.
541
+
542
+ **Fail closed:** do not mark the release cycle complete while any release-scoped `Closes #NNN` issue remains OPEN.
493
543
 
494
544
  ---
495
545
 
496
546
  ## Final report (required)
497
547
 
498
548
  1. **Release manifest** — path, target version, profile, composition table
499
- 2. **Tasks completed** — SP-IDs, waves, issues closed
500
- 3. **Deferred backlog** — count and top items for next release
549
+ 2. **Tasks completed** — SP-IDs, waves, issues closed (list `#NNN` CLOSED with close time or comment URL)
550
+ 3. **Deferred backlog** — count and top items for next release (issues left OPEN + rationale)
501
551
  4. **Authoring changes** — new SP-* created, splits/fixes in Phase 3
502
552
  5. **Issues filed** — pi-spine GitHub links or "none"
503
553
  6. **Recovery actions** — aborts, retries, contract fixes
504
554
  7. **Verification** — paste `spine preflight` tail, **`npm run release:check` output** (or log path), test/coverage output
505
555
  8. **Publish** — version bumped (Y/N), tag pushed (Y/N), workflow URL, or "awaiting operator approval"
556
+ 9. **Issue tracker hygiene** — confirm every release-scoped `Closes #NNN` is CLOSED (paste `gh issue view` states or list)
506
557
 
507
558
  ---
508
559
 
@@ -527,6 +578,8 @@ preflight → for each wave: MonitorCreate batch start (or foreground) → onDon
527
578
  gate approve → integrate → npm install → batch complete →
528
579
  post-integrate release:check (exit 0 required; no tail-only verification) →
529
580
  git push origin main when remote publish is the goal (F8) →
530
- MonitorCreate release:check → HARD STOP if non-zero (fix on main, re-run) → only if exit 0: verify ci.yml green on HEAD (gh run list/watch) → HARD STOP if not green → only then: STOP for publish approval.
581
+ close Closes #NNN issues for tasks that just landed (§4.3c; do not wait for publish) →
582
+ MonitorCreate release:check → HARD STOP if non-zero (fix on main, re-run) → only if exit 0: verify ci.yml green on HEAD (gh run list/watch) → HARD STOP if not green → only then: STOP for publish approval →
583
+ after publish: Phase 6 issue sweep for any still-open Closes links → final report must list CLOSED issue numbers.
531
584
  resume --attached --force stays foreground. Post final report with composition table.
532
585
  ```
@@ -71,7 +71,7 @@ Prefer when:
71
71
 
72
72
  Exclude when:
73
73
 
74
- - Fixed on `main` but issue not closed
74
+ - Fixed on `main` but issue not closed — **unless** this release will close it immediately (hygiene debt from a prior land; close in §4.3c / Phase 6 sweep before selecting new work for the same issue)
75
75
  - Requires external repo reproduction without minimal repro
76
76
  - Blocked by epic infrastructure not in this release
77
77
 
@@ -15,6 +15,7 @@ Run on current `main` after:
15
15
  3. **Before next wave** — do not start wave N+1 until gate passes on `main`
16
16
  4. **Before first `git push origin main`** during a release cycle
17
17
  5. **Before `npm version`** — Phase 5 `release:check` (same command; re-run if `main` moved)
18
+ 6. **After gate green** — close GitHub `Closes #NNN` issues for tasks that just landed (spine-release-operator §4.3c); do not defer until publish
18
19
 
19
20
  ---
20
21
 
@@ -6,10 +6,12 @@
6
6
  import fs from "node:fs";
7
7
  import path from "node:path";
8
8
  import { loadSpineConfig } from "../config/spine-config-load.mjs";
9
+ import { writeJsonAtomic } from "../fs/atomic-write.mjs";
9
10
  import { archiveBatchStatePath } from "./lifecycle.mjs";
10
11
  import { appendJournalEvent, journalPath, readJournalEvents, readJournalTail } from "./journal.mjs";
11
12
  import { loadBatchStateFile } from "./reconcile.mjs";
12
13
  import { appendBatchHistoryEntry } from "./state.mjs";
14
+ import { withBatchStateLock } from "./batch-state-lock.mjs";
13
15
  import { removeLaneWorktrees, maxLaneNumberFromBatchState } from "./worktree.mjs";
14
16
  import { terminateLaneWorkers } from "./worker-host.mjs";
15
17
 
@@ -36,15 +38,21 @@ export function readAbortSignal(projectRoot, batchId) {
36
38
  }
37
39
 
38
40
  /**
41
+ * Write the abort signal atomically under the global batch-state lock
42
+ * (SP-722 / #264) so a concurrent engine heartbeat never observes a
43
+ * half-written signal.
44
+ *
39
45
  * @param {string} projectRoot
40
46
  * @param {string} batchId
41
47
  * @param {object} payload
42
48
  */
43
49
  export function writeAbortSignal(projectRoot, batchId, payload) {
44
- const signalPath = abortSignalPath(projectRoot, batchId);
45
- fs.mkdirSync(path.dirname(signalPath), { recursive: true });
46
- fs.writeFileSync(signalPath, `${JSON.stringify(payload, null, 2)}\n`, "utf-8");
47
- return signalPath;
50
+ return withBatchStateLock(projectRoot, () => {
51
+ const signalPath = abortSignalPath(projectRoot, batchId);
52
+ fs.mkdirSync(path.dirname(signalPath), { recursive: true });
53
+ writeJsonAtomic(signalPath, payload);
54
+ return signalPath;
55
+ });
48
56
  }
49
57
 
50
58
  /**
@@ -211,77 +219,83 @@ export function abortBatch(ctx) {
211
219
  };
212
220
  }
213
221
 
214
- const snapshot = buildAbortedSnapshot(loaded.raw, reason);
215
- writeAbortSignal(projectRoot, batchId, {
216
- hard,
217
- reason: reason ?? null,
218
- requestedAt: new Date().toISOString(),
219
- });
222
+ // Terminal abort write section runs under the global batch-state lock
223
+ // (SP-722 / #264): abort signal, archive, history entry, and clearing the
224
+ // active state must not interleave with a concurrent engine save or a
225
+ // concurrent complete/resume writer.
226
+ return withBatchStateLock(projectRoot, () => {
227
+ const snapshot = buildAbortedSnapshot(loaded.raw, reason);
228
+ writeAbortSignal(projectRoot, batchId, {
229
+ hard,
230
+ reason: reason ?? null,
231
+ requestedAt: new Date().toISOString(),
232
+ });
220
233
 
221
- if (hard) {
222
- killLaneWorkers(snapshot.lanes, true);
223
- }
234
+ if (hard) {
235
+ killLaneWorkers(snapshot.lanes, true);
236
+ }
224
237
 
225
- const archivePath = writeBatchArchive(projectRoot, batchId, snapshot);
238
+ const archivePath = writeBatchArchive(projectRoot, batchId, snapshot);
226
239
 
227
- const eventsBefore = readJournalEvents(projectRoot, batchId);
228
- const journalTail = readJournalTail(eventsBefore);
229
- appendJournalEvent(projectRoot, batchId, "batch.aborted", {
230
- reason: reason ?? null,
231
- hard,
232
- archivePath: path.relative(projectRoot, archivePath),
233
- journalEventsBeforeAbort: eventsBefore.length,
234
- journalTailEventTypes: journalTail.map((event) => event.type),
235
- });
240
+ const eventsBefore = readJournalEvents(projectRoot, batchId);
241
+ const journalTail = readJournalTail(eventsBefore);
242
+ appendJournalEvent(projectRoot, batchId, "batch.aborted", {
243
+ reason: reason ?? null,
244
+ hard,
245
+ archivePath: path.relative(projectRoot, archivePath),
246
+ journalEventsBeforeAbort: eventsBefore.length,
247
+ journalTailEventTypes: journalTail.map((event) => event.type),
248
+ });
236
249
 
237
- const journalFile = journalPath(projectRoot, batchId);
238
- if (!fs.existsSync(journalFile)) {
239
- return {
240
- ok: false,
241
- exitCode: 1,
242
- error: "journal_missing_after_abort",
243
- headline: "Abort archived state but journal file is missing",
244
- suggestedCommand: "spine status --diagnose",
245
- batchId,
246
- };
247
- }
250
+ const journalFile = journalPath(projectRoot, batchId);
251
+ if (!fs.existsSync(journalFile)) {
252
+ return {
253
+ ok: false,
254
+ exitCode: 1,
255
+ error: "journal_missing_after_abort",
256
+ headline: "Abort archived state but journal file is missing",
257
+ suggestedCommand: "spine status --diagnose",
258
+ batchId,
259
+ };
260
+ }
248
261
 
249
- appendBatchHistoryEntry(projectRoot, {
250
- batchId,
251
- action: "aborted",
252
- endedAt: snapshot.endedAt,
253
- hard,
254
- reason: reason ?? null,
255
- archivePath: path.relative(projectRoot, archivePath),
256
- });
262
+ appendBatchHistoryEntry(projectRoot, {
263
+ batchId,
264
+ action: "aborted",
265
+ endedAt: snapshot.endedAt,
266
+ hard,
267
+ reason: reason ?? null,
268
+ archivePath: path.relative(projectRoot, archivePath),
269
+ });
257
270
 
258
- if (hard) {
259
- const configResult = loadSpineConfig(projectRoot);
260
- const config = configResult.config ?? {};
261
- if (shouldCleanupWorktreesOnHardAbort(config)) {
262
- const laneCount = maxLaneNumberFromBatchState(snapshot);
263
- removeLaneWorktrees(projectRoot, batchId, laneCount);
264
- appendJournalEvent(projectRoot, batchId, "batch.worktrees_cleaned", {
265
- batchId,
266
- laneCount,
267
- reason: "hard_abort",
268
- });
271
+ if (hard) {
272
+ const configResult = loadSpineConfig(projectRoot);
273
+ const config = configResult.config ?? {};
274
+ if (shouldCleanupWorktreesOnHardAbort(config)) {
275
+ const laneCount = maxLaneNumberFromBatchState(snapshot);
276
+ removeLaneWorktrees(projectRoot, batchId, laneCount);
277
+ appendJournalEvent(projectRoot, batchId, "batch.worktrees_cleaned", {
278
+ batchId,
279
+ laneCount,
280
+ reason: "hard_abort",
281
+ });
282
+ }
269
283
  }
270
- }
271
284
 
272
- clearActiveBatchState(loaded.path);
285
+ clearActiveBatchState(loaded.path);
273
286
 
274
- return {
275
- ok: true,
276
- exitCode: 0,
277
- batchId,
278
- diagnosis: "aborted",
279
- hard,
280
- headline: hard
281
- ? `Batch ${batchId} hard-aborted and archived`
282
- : `Batch ${batchId} aborted and archived`,
283
- suggestedCommand: "spine preflight",
284
- alternatives: ["spine batch dismiss", "spine status --diagnose"],
285
- archivePath,
286
- };
287
+ return {
288
+ ok: true,
289
+ exitCode: 0,
290
+ batchId,
291
+ diagnosis: "aborted",
292
+ hard,
293
+ headline: hard
294
+ ? `Batch ${batchId} hard-aborted and archived`
295
+ : `Batch ${batchId} aborted and archived`,
296
+ suggestedCommand: "spine preflight",
297
+ alternatives: ["spine batch dismiss", "spine status --diagnose"],
298
+ archivePath,
299
+ };
300
+ });
287
301
  }