@alpacachen/dsh-kanban 1.12.0 → 1.12.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpacachen/dsh-kanban",
3
- "version": "1.12.0",
3
+ "version": "1.12.1",
4
4
  "description": "Human-led Kanban and AI-run workflows for DeepSeek Harness, with native execution, human review and task artifacts.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -88,10 +88,12 @@ export function makeStagePrompt(task, previousStages, outputDirectory, artifacts
88
88
  ].join('\n\n')
89
89
  }
90
90
 
91
+ const MAX_CONCURRENT_STAGES = 2
92
+
91
93
  /** Host-owned scheduler. It never lives in a request or browser component. */
92
94
  export function createWorkflowRunner({ store, executor, attachments, workspaceRegistry, runtimeSnapshot = {}, onError = () => {}, onChange = () => {}, ownerInstanceId = randomUUID() }) {
93
95
  let stopped = false
94
- let active = null
96
+ const active = new Map()
95
97
  let pumping = null
96
98
  let pumpAgain = false
97
99
  let lastError = null
@@ -212,22 +214,21 @@ export function createWorkflowRunner({ store, executor, attachments, workspaceRe
212
214
  // Retry only the recorded result; storage failures never redispatch the Agent.
213
215
  settlements.set(attempt.id, { taskId: task.id, payload: settlement, prepare })
214
216
  await flushSettlements()
215
- active = null
217
+ active.delete(task.id)
216
218
  notify()
217
219
  if (!stopped) kick()
218
220
  }
219
221
  }
220
222
 
221
223
  async function pump() {
222
- // ponytail: one live Attempt globally; per-workspace parallelism can follow
223
- // measured demand without changing the durable per-workspace safety slots.
224
- if (stopped || !started || active) return
224
+ if (stopped || !started || active.size >= MAX_CONCURRENT_STAGES) return
225
225
  await flushSettlements()
226
226
  void cleanupDeletedTasks()
227
227
  if (stopped) return
228
228
  const summaries = store.listTaskSummaries ? store.listTaskSummaries() : store.listTasks()
229
229
  for (const queued of summaries.filter((task) => task.state === 'queued')) {
230
- if (stopped || active) return
230
+ if (stopped || active.size >= MAX_CONCURRENT_STAGES) return
231
+ if (active.has(queued.id)) continue
231
232
  const task = store.getTask(queued.id)
232
233
  const workspace = workspaceRegistry.get(task.workspaceId)
233
234
  let boundPath
@@ -278,10 +279,10 @@ export function createWorkflowRunner({ store, executor, attachments, workspaceRe
278
279
  continue
279
280
  }
280
281
  const controller = new AbortController()
281
- active = { attemptId: attempt.id, taskId: task.id, controller, done: null }
282
- active.done = execute(attempt, task, controller.signal)
282
+ const execution = { attemptId: attempt.id, controller, done: null }
283
+ active.set(task.id, execution)
284
+ execution.done = execute(attempt, task, controller.signal)
283
285
  notify()
284
- return
285
286
  }
286
287
  }
287
288
 
@@ -292,7 +293,7 @@ export function createWorkflowRunner({ store, executor, attachments, workspaceRe
292
293
  report(error); retryLater()
293
294
  }).finally(() => {
294
295
  pumping = null
295
- if (pumpAgain && !stopped && !active) kick()
296
+ if (pumpAgain && !stopped && active.size < MAX_CONCURRENT_STAGES) kick()
296
297
  })
297
298
  return pumping
298
299
  }
@@ -307,24 +308,24 @@ export function createWorkflowRunner({ store, executor, attachments, workspaceRe
307
308
  },
308
309
  kick,
309
310
  cleanupDeletedTasks,
310
- isExecutingTask: taskId => active?.taskId === taskId,
311
+ isExecutingTask: taskId => active.has(taskId),
311
312
  hasPendingSettlement: taskId => [...settlements.values()].some(item => item.taskId === taskId),
312
313
  settleTask: taskId => [...settlements.values()].some(item => item.taskId === taskId) ? flushSettlements() : Promise.resolve(),
313
314
  async cancelTask(taskId) {
314
- if (active?.taskId === taskId) {
315
- const current = active
315
+ const current = active.get(taskId)
316
+ if (current) {
316
317
  current.controller.abort()
317
318
  return executor.cancel(current.attemptId)
318
319
  }
319
320
  if ([...settlements.values()].some(item => item.taskId === taskId)) await flushSettlements()
320
321
  return { requested: false }
321
322
  },
322
- status: () => ({ policy: NATIVE_POLICY, running: active !== null, settling: settlements.size > 0, cleanupPending, stopped, lastError }),
323
+ status: () => ({ policy: NATIVE_POLICY, running: active.size > 0, settling: settlements.size > 0, cleanupPending, stopped, lastError }),
323
324
  async whenIdle() {
324
325
  // Deterministic test/shutdown barrier, never used as business success proof.
325
- while (pumping || active || flushing || cleaning) {
326
+ while (pumping || active.size || flushing || cleaning) {
326
327
  await pumping
327
- if (active) await active.done
328
+ await Promise.all([...active.values()].map(execution => execution.done))
328
329
  await flushing
329
330
  await cleaning
330
331
  }
@@ -332,14 +333,12 @@ export function createWorkflowRunner({ store, executor, attachments, workspaceRe
332
333
  async dispose() {
333
334
  stopped = true
334
335
  clearTimeout(retryTimer)
335
- active?.controller.abort()
336
+ for (const execution of active.values()) execution.controller.abort()
336
337
  await pumping
337
- if (active) {
338
- const current = active
339
- current.controller.abort()
340
- try { await executor.cancel(current.attemptId) } catch (error) { report(error) }
341
- await current.done
342
- }
338
+ await Promise.all([...active.values()].map(async execution => {
339
+ try { await executor.cancel(execution.attemptId) } catch (error) { report(error) }
340
+ await execution.done
341
+ }))
343
342
  await executor.dispose()
344
343
  await flushSettlements()
345
344
  await cleaning