pi-spine 2.36.0 → 2.36.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.
package/package.json
CHANGED
|
@@ -202,6 +202,46 @@ export function buildTaskLaneAssignments(plan) {
|
|
|
202
202
|
* @property {string[]} boundTaskIds VL task ids present in batch state.
|
|
203
203
|
*/
|
|
204
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Move tasks onto a lane in memory, keeping `task.laneNumber` and every lane's
|
|
207
|
+
* `taskIds` in sync (#397). Batch-state validation rejects any lane that lists
|
|
208
|
+
* a task whose `laneNumber` differs, so every rebind path must go through here
|
|
209
|
+
* rather than assigning `task.laneNumber` alone.
|
|
210
|
+
*
|
|
211
|
+
* Does not check task status; callers decide whether a task may move.
|
|
212
|
+
*
|
|
213
|
+
* @param {object} params
|
|
214
|
+
* @param {Record<string, any>} params.state Batch state (tasks + lanes mutated in place).
|
|
215
|
+
* @param {string[]} params.taskIds Task ids to move onto `laneNumber`.
|
|
216
|
+
* @param {number} params.laneNumber Target physical lane number.
|
|
217
|
+
* @returns {string[]} Task ids whose laneNumber actually changed.
|
|
218
|
+
*/
|
|
219
|
+
export function rebindTasksToLane({ state, taskIds, laneNumber }) {
|
|
220
|
+
/** @type {string[]} */
|
|
221
|
+
const changed = [];
|
|
222
|
+
const lanes = Array.isArray(state.lanes) ? state.lanes : [];
|
|
223
|
+
const targetLane = lanes.find((/** @type {{ laneNumber: number }} */ entry) => entry?.laneNumber === laneNumber);
|
|
224
|
+
|
|
225
|
+
for (const taskId of taskIds) {
|
|
226
|
+
const task = (state.tasks ?? []).find((/** @type {{ taskId: string }} */ entry) => entry?.taskId === taskId);
|
|
227
|
+
if (!task || Number(task.laneNumber) === laneNumber) continue;
|
|
228
|
+
task.laneNumber = laneNumber;
|
|
229
|
+
changed.push(taskId);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (!targetLane || changed.length === 0) return changed;
|
|
233
|
+
if (!Array.isArray(targetLane.taskIds)) targetLane.taskIds = [];
|
|
234
|
+
for (const taskId of changed) {
|
|
235
|
+
for (const other of lanes) {
|
|
236
|
+
if (other === targetLane || !Array.isArray(other?.taskIds)) continue;
|
|
237
|
+
const index = other.taskIds.indexOf(taskId);
|
|
238
|
+
if (index >= 0) other.taskIds.splice(index, 1);
|
|
239
|
+
}
|
|
240
|
+
if (!targetLane.taskIds.includes(taskId)) targetLane.taskIds.push(taskId);
|
|
241
|
+
}
|
|
242
|
+
return changed;
|
|
243
|
+
}
|
|
244
|
+
|
|
205
245
|
/**
|
|
206
246
|
* Bind a VL's task queue to the physical slot it was dispatched onto
|
|
207
247
|
* (SP-898 / #358): `task.laneNumber`, the slot lane's `taskIds`, the journal,
|
|
@@ -251,7 +291,7 @@ export function applyVlSlotLaneBinding({
|
|
|
251
291
|
/** @type {string[]} */
|
|
252
292
|
const boundTaskIds = [];
|
|
253
293
|
/** @type {string[]} */
|
|
254
|
-
const
|
|
294
|
+
const rebindable = [];
|
|
255
295
|
|
|
256
296
|
for (const taskId of Array.isArray(taskIds) ? taskIds : []) {
|
|
257
297
|
const task = (state.tasks ?? []).find(
|
|
@@ -262,22 +302,10 @@ export function applyVlSlotLaneBinding({
|
|
|
262
302
|
// A running task is mid-flight on its current slot — never overwrite a
|
|
263
303
|
// live binding; plan-time values stay provisional until first bind.
|
|
264
304
|
if (task.status === "running") continue;
|
|
265
|
-
|
|
266
|
-
task.laneNumber = laneNumber;
|
|
267
|
-
changed.push(task.taskId);
|
|
305
|
+
rebindable.push(task.taskId);
|
|
268
306
|
}
|
|
269
307
|
|
|
270
|
-
|
|
271
|
-
if (!Array.isArray(lane.taskIds)) lane.taskIds = [];
|
|
272
|
-
for (const taskId of changed) {
|
|
273
|
-
for (const other of state.lanes ?? []) {
|
|
274
|
-
if (other === lane || other?.laneNumber === laneNumber) continue;
|
|
275
|
-
const index = Array.isArray(other.taskIds) ? other.taskIds.indexOf(taskId) : -1;
|
|
276
|
-
if (index >= 0) other.taskIds.splice(index, 1);
|
|
277
|
-
}
|
|
278
|
-
if (!lane.taskIds.includes(taskId)) lane.taskIds.push(taskId);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
308
|
+
const changed = rebindTasksToLane({ state, taskIds: rebindable, laneNumber });
|
|
281
309
|
|
|
282
310
|
const canPersist = Boolean(projectRoot && batchId);
|
|
283
311
|
if (canPersist && (changed.length > 0 || boundTaskIds.length > 1)) {
|
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
taskTerminalSuccessInBatch,
|
|
43
43
|
} from "./resume-common.mjs";
|
|
44
44
|
import { appendJournalEvent } from "./journal.mjs";
|
|
45
|
+
import { rebindTasksToLane } from "./engine-scope.mjs";
|
|
45
46
|
import { laneTaskBranch } from "./worktree.mjs";
|
|
46
47
|
import { isTaskResumable } from "./resume-multi-validate.mjs";
|
|
47
48
|
import {
|
|
@@ -283,12 +284,14 @@ export async function executeResumeWave({
|
|
|
283
284
|
// VL→slot bind (SP-903 pattern): merge (and downstream resume/
|
|
284
285
|
// dashboard consumers) key off `task.laneNumber`, so the runtime
|
|
285
286
|
// binding must replace the plan-time sticky value before any run
|
|
286
|
-
// persists state.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
287
|
+
// persists state. The helper also moves the task out of the sticky
|
|
288
|
+
// lane's `taskIds`; batch-state validation rejects the mismatch (#397).
|
|
289
|
+
// Already-complete tasks keep their sticky lane.
|
|
290
|
+
rebindTasksToLane({
|
|
291
|
+
state,
|
|
292
|
+
taskIds: vl.tasks.filter((queued) => queued.bindsSlot).map((queued) => queued.taskId),
|
|
293
|
+
laneNumber: slotLane.laneNumber,
|
|
294
|
+
});
|
|
292
295
|
const slotCorrelationId = slotLane.correlationId ?? crypto.randomUUID();
|
|
293
296
|
slotLane.correlationId = slotCorrelationId;
|
|
294
297
|
|