pi-spine 2.30.0 → 2.31.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 +3 -3
- package/src/batch/attached-runner-reconcile.mjs +43 -0
- package/src/batch/integrate-assert.mjs +11 -1
- package/src/batch/lifecycle-archive.mjs +21 -0
- package/src/batch/lifecycle.mjs +16 -18
- package/src/batch/salvage-batch-integrate-heal.mjs +44 -0
- package/src/batch/state-guards.mjs +10 -1
- package/src/cli/spine-wait.mjs +67 -5
- package/src/cli/wait.mjs +7 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-spine",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.31.0",
|
|
4
4
|
"description": "Orchestration spine for long-running pi development",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@earendil-works/pi-coding-agent": "^1.
|
|
75
|
+
"@earendil-works/pi-coding-agent": "^1.5.2",
|
|
76
76
|
"@types/node": "^22.20.4",
|
|
77
|
-
"eslint": "^10.
|
|
77
|
+
"eslint": "^10.15.0",
|
|
78
78
|
"globals": "^17.14.0",
|
|
79
79
|
"typebox": "1.3.34",
|
|
80
80
|
"typescript": "6.0.3"
|
|
@@ -143,10 +143,37 @@ export function releaseResumeHandoffLock(projectRoot, batchId) {
|
|
|
143
143
|
*/
|
|
144
144
|
const LIVE_RESUME_OWNER_PHASES = new Set(["running", "gating"]);
|
|
145
145
|
|
|
146
|
+
/**
|
|
147
|
+
* True when the engine acknowledged the current pause episode: an
|
|
148
|
+
* `engine.pause_observed` journal event exists after the latest `batch.resumed`
|
|
149
|
+
* (SP-861 / #376). `pauseBatch` journals `batch.paused` only after the engine
|
|
150
|
+
* persisted phase: paused, and that engine-side persist also journals
|
|
151
|
+
* `engine.pause_observed` right before the engine loop stops — so after a
|
|
152
|
+
* confirmed pause the recorded enginePid belongs to a winding-down process that
|
|
153
|
+
* no longer drives the batch, i.e. a stale attached-child bookkeeping bit, not
|
|
154
|
+
* a live owner.
|
|
155
|
+
*
|
|
156
|
+
* @param {string} projectRoot
|
|
157
|
+
* @param {string} batchId
|
|
158
|
+
*/
|
|
159
|
+
function hasEngineAcknowledgedPause(projectRoot, batchId) {
|
|
160
|
+
const events = readJournalEvents(projectRoot, batchId);
|
|
161
|
+
let lastResumedIdx = -1;
|
|
162
|
+
let lastObservedIdx = -1;
|
|
163
|
+
for (let i = 0; i < events.length; i++) {
|
|
164
|
+
const type = String(events[i].type ?? "");
|
|
165
|
+
if (type === "batch.resumed") lastResumedIdx = i;
|
|
166
|
+
if (type === "engine.pause_observed") lastObservedIdx = i;
|
|
167
|
+
}
|
|
168
|
+
return lastObservedIdx >= 0 && lastObservedIdx > lastResumedIdx;
|
|
169
|
+
}
|
|
170
|
+
|
|
146
171
|
/**
|
|
147
172
|
* Reject a second attached engine when resilience.enginePid is alive (SP-434, GitHub #89).
|
|
148
173
|
* Serialized forced resume handoff when another resume --force is in flight (SP-533, #167).
|
|
149
174
|
* Fail-fast while a live engine already owns a running batch (SP-660, #207).
|
|
175
|
+
* A paused batch whose engine acknowledged the pause hands recovery to the
|
|
176
|
+
* operator instead of refusing (SP-861, #376).
|
|
150
177
|
*
|
|
151
178
|
* @param {object} params
|
|
152
179
|
* @param {string} params.projectRoot
|
|
@@ -239,6 +266,22 @@ export function enforceAttachedEngineSingleOwner({ projectRoot, force = false, o
|
|
|
239
266
|
};
|
|
240
267
|
}
|
|
241
268
|
|
|
269
|
+
// A paused batch whose engine acknowledged the pause has no live owner
|
|
270
|
+
// (SP-861 / #376): the recorded pid is a stale attached-child bookkeeping bit
|
|
271
|
+
// left behind by the pause handoff. Detached recovery must not be refused
|
|
272
|
+
// with a false "Attached batch engine already running" — clear the stale
|
|
273
|
+
// ownership instead so the resuming engine takes over cleanly. A live pid on
|
|
274
|
+
// a non-paused batch (engine still driving) keeps the refuse below.
|
|
275
|
+
if (fromPhase === "paused" && hasEngineAcknowledgedPause(projectRoot, batchId)) {
|
|
276
|
+
clearBatchEnginePid(state);
|
|
277
|
+
saveSpineBatchState(projectRoot, state, { bypassOwnerCheck: true });
|
|
278
|
+
appendJournalEvent(projectRoot, batchId, "engine.stale_ownership_cleared", {
|
|
279
|
+
stalePid: enginePid,
|
|
280
|
+
fromPhase,
|
|
281
|
+
});
|
|
282
|
+
return releaseResumeLock ? { ok: true, releaseResumeLock } : { ok: true };
|
|
283
|
+
}
|
|
284
|
+
|
|
242
285
|
const operationLabel = operation === "start" ? "start" : "resume";
|
|
243
286
|
const output =
|
|
244
287
|
`Attached batch engine already running (PID ${enginePid}, batch ${batchId}).\n` +
|
|
@@ -13,14 +13,24 @@ import { countCommitsAhead } from "./lane-commit.mjs";
|
|
|
13
13
|
* @param {string|null} ctx.orchBranch
|
|
14
14
|
* @param {boolean} ctx.mergeResultsEmpty
|
|
15
15
|
* @param {boolean} ctx.orchMergedToBase
|
|
16
|
+
* @param {boolean} [ctx.salvageLanded] salvage integrate landed every task's work on base (SP-862 / #374)
|
|
16
17
|
*/
|
|
17
18
|
export function assertOrchIntegratable(projectRoot, ctx) {
|
|
18
|
-
const { baseBranch, orchBranch, mergeResultsEmpty, orchMergedToBase } = ctx;
|
|
19
|
+
const { baseBranch, orchBranch, mergeResultsEmpty, orchMergedToBase, salvageLanded } = ctx;
|
|
19
20
|
|
|
20
21
|
if (orchMergedToBase) {
|
|
21
22
|
return { ok: true, reason: "orch_merged_to_base" };
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
// SP-862 / #374: salvage integrate merged the lane task branches onto base —
|
|
26
|
+
// the work complete's merge gate cares about is on base even though the
|
|
27
|
+
// batch orch branch never merged. Only set when the salvage heal left zero
|
|
28
|
+
// unresolved tasks (fail-closed). Lifecycle complete is the only caller that
|
|
29
|
+
// passes this.
|
|
30
|
+
if (salvageLanded) {
|
|
31
|
+
return { ok: true, reason: "salvage_landed_to_base" };
|
|
32
|
+
}
|
|
33
|
+
|
|
24
34
|
if (mergeResultsEmpty) {
|
|
25
35
|
return { ok: true, reason: "no_merge_claimed" };
|
|
26
36
|
}
|
|
@@ -170,6 +170,27 @@ export function clearCompletedBatchState(projectRoot, batchStatePath, batchId) {
|
|
|
170
170
|
clearActiveBatchStateIfMatches(batchStatePath, batchId, projectRoot);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
/**
|
|
174
|
+
* True when reconcile signals show live lane activity (running/pending tasks,
|
|
175
|
+
* or a lane whose status is running/active) — dismiss treats this as a live
|
|
176
|
+
* batch and requires --force.
|
|
177
|
+
*
|
|
178
|
+
* @param {object} signals
|
|
179
|
+
* @returns {boolean}
|
|
180
|
+
*/
|
|
181
|
+
export function hasLiveLanes(signals) {
|
|
182
|
+
if (!signals) return false;
|
|
183
|
+
if (signals.hasRunningTasks || signals.hasPendingTasks) return true;
|
|
184
|
+
const lanes = signals.lanes;
|
|
185
|
+
return (
|
|
186
|
+
Array.isArray(lanes) &&
|
|
187
|
+
lanes.some((lane) => {
|
|
188
|
+
const status = String(lane?.status ?? "").toLowerCase();
|
|
189
|
+
return status === "running" || status === "active";
|
|
190
|
+
})
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
173
194
|
/**
|
|
174
195
|
* @param {object|null|undefined} config
|
|
175
196
|
*/
|
package/src/batch/lifecycle.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
archiveBatchState,
|
|
14
14
|
clearCompletedBatchState,
|
|
15
|
+
hasLiveLanes,
|
|
15
16
|
reloadStateForTerminalWrite,
|
|
16
17
|
} from "./lifecycle-archive.mjs";
|
|
17
18
|
export { archiveBatchStatePath } from "./lifecycle-archive.mjs";
|
|
@@ -86,22 +87,6 @@ export function recordMergeBlocked({
|
|
|
86
87
|
};
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
/**
|
|
90
|
-
* @param {object} signals
|
|
91
|
-
*/
|
|
92
|
-
function hasLiveLanes(signals) {
|
|
93
|
-
if (!signals) return false;
|
|
94
|
-
if (signals.hasRunningTasks || signals.hasPendingTasks) return true;
|
|
95
|
-
const lanes = signals.lanes;
|
|
96
|
-
return (
|
|
97
|
-
Array.isArray(lanes) &&
|
|
98
|
-
lanes.some((lane) => {
|
|
99
|
-
const status = String(lane?.status ?? "").toLowerCase();
|
|
100
|
-
return status === "running" || status === "active";
|
|
101
|
-
})
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
90
|
/**
|
|
106
91
|
* @param {object} ctx
|
|
107
92
|
* @param {string} ctx.projectRoot
|
|
@@ -177,7 +162,13 @@ export function dismissBatch(ctx) {
|
|
|
177
162
|
};
|
|
178
163
|
}
|
|
179
164
|
|
|
180
|
-
|
|
165
|
+
// SP-862 / #374: needs_merge/needs_integrate after a full salvage heal is the
|
|
166
|
+
// empty batch shell (orch land loop never ran) — dismiss without --force.
|
|
167
|
+
const salvageCompleted =
|
|
168
|
+
Boolean(reconciliation.signals?.raw?.salvageLandedAllTasks) &&
|
|
169
|
+
Boolean(reconciliation.signals?.allTasksTerminalSuccess);
|
|
170
|
+
|
|
171
|
+
if (diagnosis && !DISMISS_ALLOWED.has(diagnosis) && !force && !salvageCompleted) {
|
|
181
172
|
const output = buildDiagnosisOutput(diagnosis, {
|
|
182
173
|
batchId,
|
|
183
174
|
phase: reconciliation.phase,
|
|
@@ -323,7 +314,13 @@ export function completeBatch(ctx) {
|
|
|
323
314
|
const diagnosis = reconciliation.diagnosis;
|
|
324
315
|
const batchId = reconciliation.batchId ?? String(loaded.raw.batchId ?? loaded.raw.id ?? "");
|
|
325
316
|
const signals = reconciliation.signals ?? {};
|
|
326
|
-
|
|
317
|
+
// SP-862 / #374: salvage merges lane branches onto base (not orch) — after a
|
|
318
|
+
// full heal the salvage land is the merge evidence (fail-closed: evidence is
|
|
319
|
+
// only written when the heal left zero unresolved tasks, and allSuccess below
|
|
320
|
+
// still applies).
|
|
321
|
+
const salvageSatisfied = Boolean(signals.raw?.salvageLandedAllTasks);
|
|
322
|
+
const mergeSatisfied =
|
|
323
|
+
!signals.mergeResultsEmpty || Boolean(signals.git?.orchMergedToBase) || salvageSatisfied;
|
|
327
324
|
const manualMergeOk =
|
|
328
325
|
detectManualMerge &&
|
|
329
326
|
(diagnosis === "completed_manual" || Boolean(signals.git?.orchMergedToBase));
|
|
@@ -372,6 +369,7 @@ export function completeBatch(ctx) {
|
|
|
372
369
|
orchBranch: batch?.orchBranch ?? loaded.raw.orchBranch ?? null,
|
|
373
370
|
mergeResultsEmpty: signals.mergeResultsEmpty,
|
|
374
371
|
orchMergedToBase: Boolean(signals.git?.orchMergedToBase),
|
|
372
|
+
salvageLanded: salvageSatisfied,
|
|
375
373
|
});
|
|
376
374
|
|
|
377
375
|
if (!integratable.ok && !manualMergeOk) {
|
|
@@ -16,6 +16,17 @@
|
|
|
16
16
|
* Tasks outside the salvage set are never touched: non-salvageable failures
|
|
17
17
|
* (contract/review failures) and evidence-less worker deaths remain failed and
|
|
18
18
|
* keep blocking complete (SP-763 completion criteria).
|
|
19
|
+
*
|
|
20
|
+
* SP-862 / #374: when the heal leaves zero non-terminal tasks, the batch has no
|
|
21
|
+
* unresolved failure left, so the state also records `salvageLandedAllTasks`
|
|
22
|
+
* evidence (+ a `batch.salvage_landed_all_tasks` journal event). `complete` and
|
|
23
|
+
* `dismiss` use it to accept the salvage land as the batch's merge evidence —
|
|
24
|
+
* salvage merges lane task branches onto base, not the batch orch branch, so
|
|
25
|
+
* the orch-based merge gates (`mergeSatisfied`, needs_merge dismiss gate) would
|
|
26
|
+
* otherwise keep refusing and force `dismiss --force`. Fail-closed: the
|
|
27
|
+
* evidence alone never opens a gate — complete/dismiss still require every
|
|
28
|
+
* task terminal-success at gate time, so a later retry that re-opens tasks
|
|
29
|
+
* re-arms the refusal.
|
|
19
30
|
*/
|
|
20
31
|
|
|
21
32
|
import { loadBatchStateFile } from "./batch-state-io.mjs";
|
|
@@ -107,6 +118,21 @@ export function healSalvagedTasksAfterIntegrate(projectRoot, batchId, options =
|
|
|
107
118
|
return { ok: true, healedTaskIds, reason: "nothing_to_heal", error: null };
|
|
108
119
|
}
|
|
109
120
|
|
|
121
|
+
// SP-862 / #374: no unresolved task remains after this heal — record the
|
|
122
|
+
// salvage land as batch-level merge evidence so complete/dismiss can accept
|
|
123
|
+
// it without --force (see module docstring for the fail-closed contract).
|
|
124
|
+
if (allTasksTerminalSuccess(loaded.raw)) {
|
|
125
|
+
loaded.raw.salvageLandedAllTasks = {
|
|
126
|
+
at: Date.now(),
|
|
127
|
+
mergeCommit: mergeCommit ?? null,
|
|
128
|
+
tasks: [...healedTaskIds],
|
|
129
|
+
};
|
|
130
|
+
appendJournalEvent(projectRoot, batchId, "batch.salvage_landed_all_tasks", {
|
|
131
|
+
mergeCommit: mergeCommit ?? null,
|
|
132
|
+
healedTaskIds: [...healedTaskIds],
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
110
136
|
saveSpineBatchState(projectRoot, loaded.raw);
|
|
111
137
|
return { ok: true, healedTaskIds, reason: null, error: null };
|
|
112
138
|
} catch (err) {
|
|
@@ -114,3 +140,21 @@ export function healSalvagedTasksAfterIntegrate(projectRoot, batchId, options =
|
|
|
114
140
|
return { ok: false, healedTaskIds: [], reason: "heal_threw", error: message };
|
|
115
141
|
}
|
|
116
142
|
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* True when every task in the raw batch state is terminal-success
|
|
146
|
+
* (`succeeded` / `skipped`) — i.e. no unresolved failure is left after the
|
|
147
|
+
* salvage heal. Unknown/missing statuses fail closed.
|
|
148
|
+
*
|
|
149
|
+
* @param {object} raw
|
|
150
|
+
* @returns {boolean}
|
|
151
|
+
*/
|
|
152
|
+
function allTasksTerminalSuccess(raw) {
|
|
153
|
+
const tasks = Array.isArray(raw?.tasks) ? raw.tasks : [];
|
|
154
|
+
if (tasks.length === 0) return false;
|
|
155
|
+
return tasks.every((task) => {
|
|
156
|
+
if (!task || typeof task !== "object") return false;
|
|
157
|
+
const status = String(task.status ?? "").toLowerCase();
|
|
158
|
+
return status === "succeeded" || status === "skipped";
|
|
159
|
+
});
|
|
160
|
+
}
|
|
@@ -62,6 +62,14 @@ export function isBatchArchived(projectRoot, batchId) {
|
|
|
62
62
|
* engine writers cannot be blocked by their own recorded PID; resurrection
|
|
63
63
|
* protection always runs.
|
|
64
64
|
*
|
|
65
|
+
* A live recorded PID does not reject writes to a **paused** batch (SP-861 / #376):
|
|
66
|
+
* a confirmed operator pause is an ownership handoff — the engine acknowledged the
|
|
67
|
+
* pause (persisted phase: paused + journaled `engine.pause_observed`) and stopped
|
|
68
|
+
* driving the batch, so its lingering process is not a writer owner. Refusing
|
|
69
|
+
* operator retry/skip recovery writes there dead-ends pause → retry → resume
|
|
70
|
+
* recovery. Engine-driven phases (`running`/`planning`) still refuse for any
|
|
71
|
+
* live foreign PID.
|
|
72
|
+
*
|
|
65
73
|
* @param {string} projectRoot
|
|
66
74
|
* @param {Record<string, any>} state
|
|
67
75
|
* @param {{ skipOwnerCheck?: boolean, allowArchivedResurrection?: boolean }} [options]
|
|
@@ -92,7 +100,8 @@ export function evaluateBatchStateWriteGuard(projectRoot, state, options = {}) {
|
|
|
92
100
|
!options.skipOwnerCheck &&
|
|
93
101
|
ownerPid &&
|
|
94
102
|
ownerPid !== process.pid &&
|
|
95
|
-
isEngineProcessAlive(ownerPid, ownerStartedAt)
|
|
103
|
+
isEngineProcessAlive(ownerPid, ownerStartedAt) &&
|
|
104
|
+
onDiskPhase !== "paused"
|
|
96
105
|
) {
|
|
97
106
|
return { allowed: false, reason: "stale_engine_pid" };
|
|
98
107
|
}
|
package/src/cli/spine-wait.mjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { DIAGNOSIS_TAXONOMY } from "../batch/diagnosis.mjs";
|
|
6
|
+
import { RUNNING_PHASES } from "../batch/reconcile-light-cache.mjs";
|
|
6
7
|
|
|
7
8
|
/** Operator-facing wait targets not in reconcile diagnosis taxonomy. */
|
|
8
9
|
export const WAIT_UNTIL_PSEUDO_DIAGNOSES = [
|
|
@@ -96,12 +97,52 @@ export function diagnosisMatchesUntil(diagnosis, untilDiagnoses) {
|
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
/**
|
|
100
|
+
* Partial-failure diagnoses that reconcile can report while sibling lane
|
|
101
|
+
* workers are still running (#375). All three derive from reconcile's
|
|
102
|
+
* `hasFailedTasks` branch, which fires on the first terminal-failure task —
|
|
103
|
+
* even mid-batch — so waking a land loop on them while a sibling lane is
|
|
104
|
+
* still live would pause/salvage/kill healthy lanes.
|
|
105
|
+
*
|
|
106
|
+
* @type {ReadonlySet<string>}
|
|
107
|
+
*/
|
|
108
|
+
export const WAIT_LIVE_SIBLING_GATED_DIAGNOSES = new Set([
|
|
109
|
+
"needs_retry",
|
|
110
|
+
"worker_done_missing",
|
|
111
|
+
"needs_replan",
|
|
112
|
+
]);
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Whether any in-scope lane task is still live (#375). Prefers
|
|
116
|
+
* `signals.hasRunningTasks` — the per-task running classification reconcile
|
|
117
|
+
* itself derives — and only falls back to the batch phase when the result
|
|
118
|
+
* carries no signals block (injected reconcile fns, non-verbose results):
|
|
119
|
+
* the engine holds the phase in a live run state while lane workers are
|
|
120
|
+
* active and transitions to failed/completed only after lanes settle.
|
|
121
|
+
*
|
|
122
|
+
* @param {import("../batch/reconcile.mjs").ReconciliationResult & Record<string, unknown>} result
|
|
123
|
+
* @returns {boolean}
|
|
124
|
+
*/
|
|
125
|
+
export function hasLiveSiblingLaneWorker(result) {
|
|
126
|
+
const signals = /** @type {Record<string, unknown> | null | undefined} */ (result?.signals);
|
|
127
|
+
if (signals != null && typeof signals === "object") {
|
|
128
|
+
return signals.hasRunningTasks === true;
|
|
129
|
+
}
|
|
130
|
+
return RUNNING_PHASES.has(String(result?.phase ?? ""));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Resolve which `--until` entry (taxonomy diagnosis, `failed` phase alias, or
|
|
135
|
+
* land-loop pseudo) a reconcile result matches; null when nothing matches.
|
|
136
|
+
* Single source of truth for match order — `describeMatchedDiagnosis` in the
|
|
137
|
+
* wait poll names the matched token through this helper.
|
|
138
|
+
*
|
|
99
139
|
* @param {import("../batch/reconcile.mjs").ReconciliationResult & Record<string, unknown>} result
|
|
100
140
|
* @param {Set<string>} untilDiagnoses
|
|
141
|
+
* @returns {string | null}
|
|
101
142
|
*/
|
|
102
|
-
export function
|
|
143
|
+
export function matchReconciliationUntil(result, untilDiagnoses) {
|
|
103
144
|
if (diagnosisMatchesUntil(result.diagnosis ?? null, untilDiagnoses)) {
|
|
104
|
-
return
|
|
145
|
+
return result.diagnosis;
|
|
105
146
|
}
|
|
106
147
|
|
|
107
148
|
// `--until failed` must wake on terminal batch failure even when reconcile
|
|
@@ -109,14 +150,35 @@ export function reconciliationMatchesUntil(result, untilDiagnoses) {
|
|
|
109
150
|
// engine_orphaned) instead of the literal "failed" token (#252). Explicit
|
|
110
151
|
// diagnosis tokens still match directly via the check above.
|
|
111
152
|
if (untilDiagnoses.has("failed") && result.phase === "failed") {
|
|
112
|
-
return
|
|
153
|
+
return "failed";
|
|
113
154
|
}
|
|
114
155
|
|
|
115
156
|
for (const pseudo of deriveWaitPseudoDiagnoses(result)) {
|
|
116
157
|
if (untilDiagnoses.has(pseudo)) {
|
|
117
|
-
return
|
|
158
|
+
return pseudo;
|
|
118
159
|
}
|
|
119
160
|
}
|
|
120
161
|
|
|
121
|
-
return
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @param {import("../batch/reconcile.mjs").ReconciliationResult & Record<string, unknown>} result
|
|
167
|
+
* @param {Set<string>} untilDiagnoses
|
|
168
|
+
*/
|
|
169
|
+
export function reconciliationMatchesUntil(result, untilDiagnoses) {
|
|
170
|
+
const matched = matchReconciliationUntil(result, untilDiagnoses);
|
|
171
|
+
if (matched == null) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
// Partial-failure hold (#375): needs_retry / worker_done_missing /
|
|
175
|
+
// needs_replan fire on the first failed task even while sibling lane
|
|
176
|
+
// workers are still running. Hold the match until the live siblings
|
|
177
|
+
// settle; terminal aliases (`failed`), success/integrate diagnoses, and
|
|
178
|
+
// gate pseudos keep their current behavior so a fully terminal batch
|
|
179
|
+
// never waits on imaginary siblings.
|
|
180
|
+
if (WAIT_LIVE_SIBLING_GATED_DIAGNOSES.has(matched) && hasLiveSiblingLaneWorker(result)) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
return true;
|
|
122
184
|
}
|
package/src/cli/wait.mjs
CHANGED
|
@@ -12,9 +12,8 @@ import path from "node:path";
|
|
|
12
12
|
|
|
13
13
|
import { reconcileBatch } from "../batch/reconcile.mjs";
|
|
14
14
|
import {
|
|
15
|
-
deriveWaitPseudoDiagnoses,
|
|
16
|
-
diagnosisMatchesUntil,
|
|
17
15
|
parseUntilDiagnoses,
|
|
16
|
+
matchReconciliationUntil,
|
|
18
17
|
reconciliationMatchesUntil,
|
|
19
18
|
} from "./spine-wait.mjs";
|
|
20
19
|
import {
|
|
@@ -132,19 +131,7 @@ function formatWaitElapsed(ms) {
|
|
|
132
131
|
* @returns {string}
|
|
133
132
|
*/
|
|
134
133
|
function describeMatchedDiagnosis(result, untilDiagnoses) {
|
|
135
|
-
|
|
136
|
-
if (diagnosisMatchesUntil(diagnosis, untilDiagnoses)) {
|
|
137
|
-
return diagnosis;
|
|
138
|
-
}
|
|
139
|
-
if (untilDiagnoses.has("failed") && result.phase === "failed") {
|
|
140
|
-
return "failed";
|
|
141
|
-
}
|
|
142
|
-
for (const pseudo of deriveWaitPseudoDiagnoses(result)) {
|
|
143
|
-
if (untilDiagnoses.has(pseudo)) {
|
|
144
|
-
return pseudo;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return diagnosis ?? "matched";
|
|
134
|
+
return matchReconciliationUntil(result, untilDiagnoses) ?? result.diagnosis ?? "matched";
|
|
148
135
|
}
|
|
149
136
|
|
|
150
137
|
/**
|
|
@@ -341,7 +328,11 @@ export async function runSpineWait(options) {
|
|
|
341
328
|
|
|
342
329
|
try {
|
|
343
330
|
while (running) {
|
|
344
|
-
|
|
331
|
+
// verbose: true (#375) — exposes signals.hasRunningTasks so the
|
|
332
|
+
// partial-failure match gate uses reconcile's own live-task
|
|
333
|
+
// classification instead of the phase fallback. buildWatchSnapshot
|
|
334
|
+
// picks explicit fields, so signals never leak into --json output.
|
|
335
|
+
const result = reconcileFn({ projectRoot, verbose: true });
|
|
345
336
|
if (!scopedBatchIdCaptured) {
|
|
346
337
|
const candidate = result.batchId ?? null;
|
|
347
338
|
if (candidate != null) {
|