pi-spine 1.8.0 → 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.
- package/bin/spine-doctor.mjs +4 -0
- package/extensions/spine/slash-commands.ts +1 -1
- package/package.json +1 -1
- package/skills/create-spine-tasks/SKILL.md +42 -0
- package/skills/create-spine-tasks/references/contract-template.md +30 -2
- package/skills/create-spine-tasks/references/prompt-template.md +3 -1
- package/skills/spine-autonomous-operator/SKILL.md +7 -2
- package/skills/spine-autonomous-operator/references/agent-shell-batch-policy.md +91 -0
- package/skills/spine-orchestrate-waves/SKILL.md +10 -6
- package/skills/spine-orchestrate-waves/references/outer-loop.md +22 -5
- package/skills/spine-release-operator/SKILL.md +12 -3
- package/skills/spine-release-operator/references/pi-async-orchestration.md +2 -2
- package/src/batch/attached-runner.mjs +99 -2
- package/src/batch/contract-prelanded.mjs +83 -0
- package/src/batch/contract-verify.mjs +19 -5
- package/src/batch/diagnosis-tail-state.mjs +5 -0
- package/src/batch/diagnosis.mjs +3 -2
- package/src/batch/journal-rebuild.mjs +117 -0
- package/src/batch/lifecycle.mjs +2 -0
- package/src/batch/macro-phase.mjs +40 -2
- package/src/batch/orphan-detect.mjs +105 -2
- package/src/batch/reconcile.mjs +152 -10
- package/src/config/preflight/integrate-plan.mjs +31 -7
- package/src/config/spine-preflight-lib.mjs +1 -0
- package/src/dashboard/cache-invalidate.mjs +91 -0
- package/src/dashboard/server.mjs +7 -0
- package/src/dashboard/snapshot-waves.mjs +32 -5
- package/src/dashboard/snapshot.mjs +6 -1
- package/src/doctor/attached-orphan-risk.mjs +114 -0
- package/src/doctor/run-doctor-checks.mjs +2 -0
- package/src/planner/format-plan.mjs +5 -1
- package/src/planner/index.mjs +3 -1
- package/src/planner/waves.mjs +41 -0
- package/src/tasks/packet/validate-contract.mjs +8 -1
- package/src/tasks/packet/validate-prompt.mjs +1 -0
- package/src/tasks/validate-contract-warn.mjs +87 -0
package/bin/spine-doctor.mjs
CHANGED
|
@@ -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() {
|
|
@@ -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
|
|
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
|
@@ -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
|
|
@@ -501,6 +542,7 @@ Hydration commits (STATUS.md expansions) may happen mid-step for crash recovery.
|
|
|
501
542
|
|
|
502
543
|
- **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
544
|
- **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.
|
|
545
|
+
- **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
546
|
- **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
547
|
- **Documentation in every task** — "Must Update" / "Check If Affected" prevent doc drift.
|
|
506
548
|
- **Concrete deliverables** — name files to create/modify; avoid shortcuttable vague steps.
|
|
@@ -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 `
|
|
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 | `` `
|
|
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
|
-
>
|
|
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,8 @@ 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)
|
|
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.
|
|
35
37
|
|
|
36
38
|
## Phase 0 — Baseline
|
|
37
39
|
|
|
@@ -128,13 +130,15 @@ For each wave `N` until `spine plan pending` shows 0 tasks:
|
|
|
128
130
|
|
|
129
131
|
```text
|
|
130
132
|
MonitorCreate:
|
|
131
|
-
command: spine batch start pending --wave N --attached
|
|
133
|
+
command: spine batch start pending --wave N # detached — omit --attached (#163)
|
|
132
134
|
description: Pending wave N
|
|
133
135
|
timeout: 0
|
|
134
136
|
onDone: spine status --diagnose → land loop (§3.3) or recovery (§4)
|
|
135
137
|
```
|
|
136
138
|
|
|
137
|
-
|
|
139
|
+
After detached start, monitor with `spine wait --until completed,needs_integrate,failed,aborted --timeout 4h` or `spine status --diagnose`.
|
|
140
|
+
|
|
141
|
+
**Foreground fallback** (interactive terminal only — keep shell in foreground for full batch):
|
|
138
142
|
|
|
139
143
|
```bash
|
|
140
144
|
spine batch start pending --wave N --attached
|
|
@@ -251,6 +255,7 @@ In pi sessions, `MonitorCreate` for `npm run release:check` is allowed (see pi-a
|
|
|
251
255
|
- **Tasks root:** `spine-tasks/`
|
|
252
256
|
- **Config:** `.spine/spine-config.json`
|
|
253
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)
|
|
254
259
|
- **Known upstream issues:** #114 (integrate hang, fixed), #118 (trailing-slash contracts), #130 (`coverage/` restore), #163 (`engine_orphaned`)
|
|
255
260
|
|
|
256
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
|
|
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 `
|
|
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 `
|
|
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
|
|
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
|
|
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 `
|
|
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"
|
|
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
|
-
**
|
|
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
|
|
@@ -304,7 +313,7 @@ Always: `spine status --diagnose`
|
|
|
304
313
|
| `needs_retry` | Fix packet; `spine batch retry <taskId>` |
|
|
305
314
|
| `worker_orphaned` | abort → dismiss → prune worktree → retry |
|
|
306
315
|
| `needs_integrate` | Land loop |
|
|
307
|
-
| `state_drift` | `spine batch retry <taskId>`
|
|
316
|
+
| `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) |
|
|
308
317
|
| `failed` / `aborted` | Inspect journal; fix packet; dismiss; retry |
|
|
309
318
|
| Contract fail | Fix PROMPT on main, commit, abort, dismiss, retry |
|
|
310
319
|
|
|
@@ -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
|
|
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
|
|
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
|
|
|
@@ -13,11 +13,25 @@ import { detectPostMergeLimboForResume } from "./resume-multi-validate.mjs";
|
|
|
13
13
|
import { isProcessAlive } from "../process/liveness.mjs";
|
|
14
14
|
import { terminateStaleDetachedEngine } from "./resume-engine.mjs";
|
|
15
15
|
import { reconcileBatch } from "./reconcile.mjs";
|
|
16
|
-
import { readJournalEventsCached } from "./journal.mjs";
|
|
16
|
+
import { readJournalEventsCached, readJournalEvents, appendJournalEvent } from "./journal.mjs";
|
|
17
17
|
import { enforceOperatorPauseOnDisk } from "./pause.mjs";
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
loadSpineBatchState,
|
|
20
|
+
readBatchEnginePid,
|
|
21
|
+
saveSpineBatchState,
|
|
22
|
+
updateSegmentForTask,
|
|
23
|
+
recomputeTaskCounters,
|
|
24
|
+
clearBatchEnginePid,
|
|
25
|
+
} from "./state.mjs";
|
|
19
26
|
import { loadSpineConfig } from "../config/spine-config-load.mjs";
|
|
20
27
|
import { resolveAttachedMilestonePollMs } from "../config/spine-config-schema.mjs";
|
|
28
|
+
import {
|
|
29
|
+
journalHasContractVerified,
|
|
30
|
+
journalIndicatesPausedForceResume,
|
|
31
|
+
} from "./orphan-detect.mjs";
|
|
32
|
+
import { classifyTaskDoneSemantics } from "./diagnosis-task-done.mjs";
|
|
33
|
+
import { resolveTasksRoot } from "../config/spine-preflight-lib.mjs";
|
|
34
|
+
import { journalHasTaskCompleted } from "./resume-common.mjs";
|
|
21
35
|
|
|
22
36
|
export { DEFAULT_ATTACHED_MILESTONE_POLL_MS } from "../config/spine-config-schema.mjs";
|
|
23
37
|
|
|
@@ -215,6 +229,81 @@ export function enforceAttachedEngineSingleOwner({ projectRoot, force = false, o
|
|
|
215
229
|
};
|
|
216
230
|
}
|
|
217
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Promote running cache tasks with lane `.DONE` and contract verify after paused force resume (SP-513 / #184).
|
|
234
|
+
*
|
|
235
|
+
* @param {object} params
|
|
236
|
+
* @param {string} params.projectRoot
|
|
237
|
+
* @param {object} params.state
|
|
238
|
+
* @param {string} params.batchId
|
|
239
|
+
* @returns {{ reconciled: boolean, taskIds?: string[] }}
|
|
240
|
+
*/
|
|
241
|
+
export function reconcilePausedResumeDoneInLane({ projectRoot, state, batchId }) {
|
|
242
|
+
if (!state || typeof state !== "object" || !batchId) {
|
|
243
|
+
return { reconciled: false };
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const journalEvents = readJournalEvents(projectRoot, batchId);
|
|
247
|
+
if (!journalIndicatesPausedForceResume(journalEvents)) {
|
|
248
|
+
return { reconciled: false };
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const configResult = loadSpineConfig(projectRoot);
|
|
252
|
+
const tasksRoot = resolveTasksRoot(projectRoot, configResult);
|
|
253
|
+
const lanes = state.lanes ?? [];
|
|
254
|
+
/** @type {string[]} */
|
|
255
|
+
const promotedTaskIds = [];
|
|
256
|
+
let changed = false;
|
|
257
|
+
|
|
258
|
+
for (const task of state.tasks ?? []) {
|
|
259
|
+
const status = String(task?.status ?? "").toLowerCase();
|
|
260
|
+
if (status !== "running" && status !== "pending") continue;
|
|
261
|
+
|
|
262
|
+
const classified = classifyTaskDoneSemantics(task, {
|
|
263
|
+
tasksRoot,
|
|
264
|
+
projectRoot,
|
|
265
|
+
batchId,
|
|
266
|
+
lanes,
|
|
267
|
+
});
|
|
268
|
+
if (classified.doneInLane !== true) continue;
|
|
269
|
+
if (!journalHasContractVerified(journalEvents, task.taskId)) continue;
|
|
270
|
+
|
|
271
|
+
task.status = "succeeded";
|
|
272
|
+
task.doneFileFound = true;
|
|
273
|
+
task.exitReason = task.exitReason ?? "done";
|
|
274
|
+
if (!task.endedAt) task.endedAt = Date.now();
|
|
275
|
+
updateSegmentForTask(state, task.taskId, "succeeded");
|
|
276
|
+
promotedTaskIds.push(task.taskId);
|
|
277
|
+
changed = true;
|
|
278
|
+
|
|
279
|
+
if (!journalHasTaskCompleted(journalEvents, task.taskId)) {
|
|
280
|
+
const laneNumber = Number(task.laneNumber ?? 1);
|
|
281
|
+
const lane = lanes.find((entry) => Number(entry?.laneNumber) === laneNumber);
|
|
282
|
+
appendJournalEvent(projectRoot, batchId, "task.completed", {
|
|
283
|
+
taskId: task.taskId,
|
|
284
|
+
laneNumber,
|
|
285
|
+
laneId: lane?.laneId ?? `lane-${laneNumber}`,
|
|
286
|
+
resumed: true,
|
|
287
|
+
skippedDoneOnDisk: true,
|
|
288
|
+
reconciled: true,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (!changed) {
|
|
294
|
+
return { reconciled: false };
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const enginePid = readBatchEnginePid(state);
|
|
298
|
+
if (enginePid != null && !isProcessAlive(enginePid)) {
|
|
299
|
+
clearBatchEnginePid(state);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
recomputeTaskCounters(state);
|
|
303
|
+
saveSpineBatchState(projectRoot, state);
|
|
304
|
+
return { reconciled: true, taskIds: promotedTaskIds };
|
|
305
|
+
}
|
|
306
|
+
|
|
218
307
|
/**
|
|
219
308
|
* Run an attached foreground engine while streaming land-loop journal milestones to stdout.
|
|
220
309
|
*
|
|
@@ -279,6 +368,14 @@ function resolveAttachedBatchExitCode(result, reconciliation) {
|
|
|
279
368
|
* @param {boolean} [params.json]
|
|
280
369
|
*/
|
|
281
370
|
export function formatAttachedBatchCliResult({ projectRoot, operation, result, json = false }) {
|
|
371
|
+
const loaded = loadSpineBatchState(projectRoot);
|
|
372
|
+
if (loaded.raw?.batchId) {
|
|
373
|
+
reconcilePausedResumeDoneInLane({
|
|
374
|
+
projectRoot,
|
|
375
|
+
state: loaded.raw,
|
|
376
|
+
batchId: String(loaded.raw.batchId),
|
|
377
|
+
});
|
|
378
|
+
}
|
|
282
379
|
const reconciliation = reconcileBatch({ projectRoot });
|
|
283
380
|
const mergeBlocked = reconciliation.phase === "merge_blocked";
|
|
284
381
|
|