@wrongstack/sdd 0.284.1 → 0.285.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/dist/auto-executor.d.ts +89 -0
- package/dist/auto-executor.d.ts.map +1 -0
- package/dist/board-types.d.ts +144 -0
- package/dist/board-types.d.ts.map +1 -0
- package/dist/conflict-resolver.d.ts +45 -0
- package/dist/conflict-resolver.d.ts.map +1 -0
- package/dist/critical-path.d.ts +36 -0
- package/dist/critical-path.d.ts.map +1 -0
- package/dist/decompose-task.d.ts +20 -0
- package/dist/decompose-task.d.ts.map +1 -0
- package/dist/index.d.ts +26 -1864
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +192 -76
- package/dist/index.js.map +7 -1
- package/dist/sdd-board-projector.d.ts +83 -0
- package/dist/sdd-board-projector.d.ts.map +1 -0
- package/dist/sdd-board-store.d.ts +59 -0
- package/dist/sdd-board-store.d.ts.map +1 -0
- package/dist/sdd-interview-driver.d.ts +131 -0
- package/dist/sdd-interview-driver.d.ts.map +1 -0
- package/dist/sdd-lifecycle.d.ts +146 -0
- package/dist/sdd-lifecycle.d.ts.map +1 -0
- package/dist/sdd-parallel-run.d.ts +427 -0
- package/dist/sdd-parallel-run.d.ts.map +1 -0
- package/dist/sdd-run-registry.d.ts +68 -0
- package/dist/sdd-run-registry.d.ts.map +1 -0
- package/dist/sdd-supervisor.d.ts +52 -0
- package/dist/sdd-supervisor.d.ts.map +1 -0
- package/dist/sdd-task-decomposer.d.ts +89 -0
- package/dist/sdd-task-decomposer.d.ts.map +1 -0
- package/dist/spec-builder.d.ts +139 -0
- package/dist/spec-builder.d.ts.map +1 -0
- package/dist/spec-parser.d.ts +14 -0
- package/dist/spec-parser.d.ts.map +1 -0
- package/dist/spec-store.d.ts +36 -0
- package/dist/spec-store.d.ts.map +1 -0
- package/dist/spec-templates.d.ts +22 -0
- package/dist/spec-templates.d.ts.map +1 -0
- package/dist/spec-versioning.d.ts +49 -0
- package/dist/spec-versioning.d.ts.map +1 -0
- package/dist/start-sdd-run.d.ts +67 -0
- package/dist/start-sdd-run.d.ts.map +1 -0
- package/dist/task-flow.d.ts +99 -0
- package/dist/task-flow.d.ts.map +1 -0
- package/dist/task-generator.d.ts +39 -0
- package/dist/task-generator.d.ts.map +1 -0
- package/dist/task-graph-store.d.ts +33 -0
- package/dist/task-graph-store.d.ts.map +1 -0
- package/dist/task-tracker.d.ts +2 -0
- package/dist/task-tracker.d.ts.map +1 -0
- package/dist/task-visualizer.d.ts +26 -0
- package/dist/task-visualizer.d.ts.map +1 -0
- package/dist/verify-task.d.ts +23 -0
- package/dist/verify-task.d.ts.map +1 -0
- package/package.json +4 -5
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
import type { Agent } from '@wrongstack/core';
|
|
2
|
+
import type { TaskResult } from '@wrongstack/core/types';
|
|
3
|
+
import type { AgentFactory } from '@wrongstack/core';
|
|
4
|
+
import type { EventBus } from '@wrongstack/core/kernel';
|
|
5
|
+
import type { WorktreeManager } from '@wrongstack/core';
|
|
6
|
+
import type { TaskGraph, TaskNode, TaskProgress } from '@wrongstack/core/types';
|
|
7
|
+
import type { TaskTracker } from '@wrongstack/core/tasking';
|
|
8
|
+
import { type TaskBatch } from './sdd-task-decomposer.js';
|
|
9
|
+
/** A sub-task produced by splitting a parent task (see `splitTask`). */
|
|
10
|
+
export interface SddSubtaskSpec {
|
|
11
|
+
title: string;
|
|
12
|
+
description: string;
|
|
13
|
+
type?: TaskNode['type'] | undefined;
|
|
14
|
+
priority?: TaskNode['priority'] | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Verdict returned by the optional failure supervisor when a task is about to go
|
|
18
|
+
* terminal. `retry` re-queues with a fresh attempt budget; `reassign` swaps the
|
|
19
|
+
* worker model (+ optional provider) then re-queues; `split` breaks the task
|
|
20
|
+
* into sub-tasks; `fail` (or `undefined`) lets it terminal-fail.
|
|
21
|
+
*/
|
|
22
|
+
export type SddSupervisorVerdict = {
|
|
23
|
+
action: 'retry';
|
|
24
|
+
} | {
|
|
25
|
+
action: 'reassign';
|
|
26
|
+
model?: string | undefined;
|
|
27
|
+
provider?: string | undefined;
|
|
28
|
+
} | {
|
|
29
|
+
action: 'split';
|
|
30
|
+
subtasks: SddSubtaskSpec[];
|
|
31
|
+
} | {
|
|
32
|
+
action: 'fail';
|
|
33
|
+
};
|
|
34
|
+
export interface SddParallelRunOptions {
|
|
35
|
+
/** Pre-constructed TaskTracker (must already hold the graph's initial state). */
|
|
36
|
+
tracker: TaskTracker;
|
|
37
|
+
/** The TaskGraph produced by TaskGenerator from an approved spec. */
|
|
38
|
+
graph: TaskGraph;
|
|
39
|
+
/** The main agent — used as the subagent factory. */
|
|
40
|
+
agent: Agent;
|
|
41
|
+
/** Project root (used for coordinator id). */
|
|
42
|
+
projectRoot: string;
|
|
43
|
+
/**
|
|
44
|
+
* Override default parallel slots (1–16). Default: 2 — deliberately low so a
|
|
45
|
+
* run never juggles more git worktrees than a human can review. Independent
|
|
46
|
+
* tasks still run concurrently up to this cap; dependency chains run in order.
|
|
47
|
+
*/
|
|
48
|
+
parallelSlots?: number | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Hard wall-clock cap per task in ms. OPT-IN — `undefined` by default so a
|
|
51
|
+
* long-but-productive task is never killed merely for running long (the old
|
|
52
|
+
* 5-min default hard-killed real coding tasks with `budget_timeout`). When
|
|
53
|
+
* set, the coordinator watchdog enforces it. Prefer `taskIdleTimeoutMs`.
|
|
54
|
+
*/
|
|
55
|
+
taskTimeoutMs?: number | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Idle reaper per task in ms: reap a task only after this long with NO
|
|
58
|
+
* activity (iteration / tool call / streamed token / tool progress). Resets
|
|
59
|
+
* on every sign of forward motion, so an actively-working agent runs until
|
|
60
|
+
* its task naturally ends. Default: 600_000 (10 min of silence = genuinely
|
|
61
|
+
* stuck). This is the default guard — wall-clock (`taskTimeoutMs`) is opt-in.
|
|
62
|
+
*/
|
|
63
|
+
taskIdleTimeoutMs?: number | undefined;
|
|
64
|
+
/** Maximum in-run retry attempts for a failed task before it goes terminal. Default: 3. */
|
|
65
|
+
maxRetries?: number | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* After the graph settles with terminal-failed tasks, requeue ALL failed
|
|
68
|
+
* (non-cancelled) tasks to `pending` and run them again — up to this many
|
|
69
|
+
* sweeps. Each sweep gives every failed task a fresh `maxRetries` budget. The
|
|
70
|
+
* loop stops early once a sweep produces no new completions (no progress).
|
|
71
|
+
* 0 = off. Default: 2.
|
|
72
|
+
*/
|
|
73
|
+
maxFailedRetrySweeps?: number | undefined;
|
|
74
|
+
/** Override the default agent factory. */
|
|
75
|
+
subagentFactory?: AgentFactory | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Run-level default model for worker subagents. A task's own
|
|
78
|
+
* `metadata.model` (set per-task in the WebUI) takes precedence; this is the
|
|
79
|
+
* fallback for every task that has no explicit assignment. Undefined → the
|
|
80
|
+
* factory's own default (the leader's model).
|
|
81
|
+
*/
|
|
82
|
+
defaultModel?: string | undefined;
|
|
83
|
+
/** Run-level default provider id (same precedence rules as defaultModel). */
|
|
84
|
+
defaultProvider?: string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Run-level fallback model chain (entries: `model` / `provider/model`). A
|
|
87
|
+
* task's `metadata.fallbackModels` overrides this. The subagent factory wires
|
|
88
|
+
* these into a fallback extension so a 429/stream-hang rotates to the next.
|
|
89
|
+
*/
|
|
90
|
+
fallbackModels?: string[] | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Post-task verification gate. When set, a task whose worker reported success
|
|
93
|
+
* is NOT marked `completed` (and NOT merged) until this resolves `{ok:true}`.
|
|
94
|
+
* Runs in the task's worktree cwd (or the project root when no worktree). Core
|
|
95
|
+
* stays shell-agnostic — the caller injects a verifier that, e.g., runs the
|
|
96
|
+
* task's `metadata.verificationCommand` (tests / typecheck). A task with no
|
|
97
|
+
* command should return `{ok:true}`. An `{ok:false}` routes the task into the
|
|
98
|
+
* normal failure path (retry while attempts remain, else terminal-fail).
|
|
99
|
+
*/
|
|
100
|
+
verifyTask?: ((info: {
|
|
101
|
+
task: TaskNode;
|
|
102
|
+
result: TaskResult;
|
|
103
|
+
cwd: string;
|
|
104
|
+
}) => Promise<{
|
|
105
|
+
ok: boolean;
|
|
106
|
+
reason?: string;
|
|
107
|
+
}>) | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Optional merge-conflict resolver, forwarded to `WorktreeManager.merge`. Given
|
|
110
|
+
* the conflicted files + the base checkout cwd, return `true` once resolved (no
|
|
111
|
+
* markers left). When omitted or it returns `false`, the task is requeued (a
|
|
112
|
+
* re-run forks a fresh worktree off the advanced base) and, if retries are
|
|
113
|
+
* exhausted, terminally failed with its worktree kept for review.
|
|
114
|
+
*/
|
|
115
|
+
conflictResolver?: ((info: {
|
|
116
|
+
task: TaskNode;
|
|
117
|
+
conflictFiles: string[];
|
|
118
|
+
cwd: string;
|
|
119
|
+
}) => Promise<boolean>) | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* Failure supervisor: consulted ONLY when a task has exhausted its retries and
|
|
122
|
+
* is about to go terminal-failed. Returning a verdict lets a decision agent
|
|
123
|
+
* keep the run moving — `retry` / `reassign` (swap model) / `split` — instead
|
|
124
|
+
* of dead-ending. Returning `{action:'fail'}` / `undefined` lets it fail. Each
|
|
125
|
+
* task can be rescued at most `maxSupervisorEscalations` times (loop guard).
|
|
126
|
+
*/
|
|
127
|
+
superviseFailure?: ((info: {
|
|
128
|
+
task: TaskNode;
|
|
129
|
+
error: string;
|
|
130
|
+
attempts: number;
|
|
131
|
+
}) => Promise<SddSupervisorVerdict | undefined>) | undefined;
|
|
132
|
+
/** Max times the supervisor may rescue a single task before it must fail. Default 2. */
|
|
133
|
+
maxSupervisorEscalations?: number | undefined;
|
|
134
|
+
/** Called after each wave completes. */
|
|
135
|
+
onWave?: ((wave: WaveResult) => void) | undefined;
|
|
136
|
+
/** Called with progress stats every ~2s during execution. */
|
|
137
|
+
onProgress?: ((progress: SddProgress) => void) | undefined;
|
|
138
|
+
/** Shared EventBus — when set, the run emits `sdd.*` live-board events. */
|
|
139
|
+
events?: EventBus | undefined;
|
|
140
|
+
/** Parent session id for every emitted `sdd.*` event. */
|
|
141
|
+
sessionId?: string | (() => string | undefined) | undefined;
|
|
142
|
+
/** Stable id correlating all events of this run (default: random). */
|
|
143
|
+
runId?: string | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* Optional git-worktree manager. When set (and the project is a git repo),
|
|
146
|
+
* each task runs in its own isolated worktree and merges back into the base
|
|
147
|
+
* branch after success — so parallel agents never collide on the same files.
|
|
148
|
+
*/
|
|
149
|
+
worktrees?: WorktreeManager | undefined;
|
|
150
|
+
/** Run-level backstops (prevent an autonomous run from looping forever). */
|
|
151
|
+
maxTotalWaves?: number | undefined;
|
|
152
|
+
maxWallClockMs?: number | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* Deadlock auto-recovery rounds: when the graph deadlocks on failed blockers,
|
|
155
|
+
* requeue those failed blockers `pending` and try again, up to N times. 0 = off.
|
|
156
|
+
*/
|
|
157
|
+
maxRecoveryRounds?: number | undefined;
|
|
158
|
+
}
|
|
159
|
+
export interface SddProgress {
|
|
160
|
+
wave: number;
|
|
161
|
+
total: number;
|
|
162
|
+
completed: number;
|
|
163
|
+
inProgress: number;
|
|
164
|
+
failed: number;
|
|
165
|
+
blocked: number;
|
|
166
|
+
pending: number;
|
|
167
|
+
percent: number;
|
|
168
|
+
deadlocked: boolean;
|
|
169
|
+
}
|
|
170
|
+
export interface WaveResult {
|
|
171
|
+
wave: number;
|
|
172
|
+
batch: TaskBatch;
|
|
173
|
+
results: TaskResult[];
|
|
174
|
+
successCount: number;
|
|
175
|
+
failCount: number;
|
|
176
|
+
durationMs: number;
|
|
177
|
+
stopRequested: boolean;
|
|
178
|
+
}
|
|
179
|
+
/** Result of a single task's execution in the continuous scheduler. */
|
|
180
|
+
interface TaskOutcome {
|
|
181
|
+
taskId: string;
|
|
182
|
+
success: boolean;
|
|
183
|
+
result?: TaskResult | undefined;
|
|
184
|
+
}
|
|
185
|
+
export interface RunResult {
|
|
186
|
+
totalWaves: number;
|
|
187
|
+
totalCompleted: number;
|
|
188
|
+
totalFailed: number;
|
|
189
|
+
totalDurationMs: number;
|
|
190
|
+
deadlocked: boolean;
|
|
191
|
+
stopRequested: boolean;
|
|
192
|
+
finalProgress: TaskProgress;
|
|
193
|
+
}
|
|
194
|
+
export declare class SddParallelRun {
|
|
195
|
+
private readonly opts;
|
|
196
|
+
private readonly slots;
|
|
197
|
+
/** Opt-in hard wall-clock cap (undefined → no cap; idle reaper guards instead). */
|
|
198
|
+
private readonly timeoutMs;
|
|
199
|
+
/** Idle reaper window (ms) — resets on activity; reaps only a genuine stall. */
|
|
200
|
+
private readonly idleTimeoutMs;
|
|
201
|
+
private readonly maxRetries;
|
|
202
|
+
/** Max supervisor rescues per task before it must terminal-fail (loop guard). */
|
|
203
|
+
private readonly maxSupervisorEscalations;
|
|
204
|
+
/** Per-task count of supervisor rescues used (resets nothing — bounds the loop). */
|
|
205
|
+
private supervisorEscalations;
|
|
206
|
+
/** Max end-of-run failed-task sweeps (see `maxFailedRetrySweeps`). */
|
|
207
|
+
private readonly maxFailedSweeps;
|
|
208
|
+
/** How many failed-task sweeps have run this `run()` so far. */
|
|
209
|
+
private failedSweeps;
|
|
210
|
+
/** Completed-count snapshot at the last sweep, to detect a no-progress sweep. */
|
|
211
|
+
private lastSweepCompleted;
|
|
212
|
+
private decomposer;
|
|
213
|
+
private coordinator;
|
|
214
|
+
private stopRequested;
|
|
215
|
+
private retryMap;
|
|
216
|
+
readonly runId: string;
|
|
217
|
+
private readonly events?;
|
|
218
|
+
private readonly sessionIdSource;
|
|
219
|
+
private readonly maxTotalWaves;
|
|
220
|
+
private readonly maxWallClockMs?;
|
|
221
|
+
private readonly maxRecoveryRounds;
|
|
222
|
+
private recoveryRounds;
|
|
223
|
+
/** Per-run worker identities, so the board shows "who is on what". */
|
|
224
|
+
private usedNicknames;
|
|
225
|
+
/** Per-task git worktree cwd (Layer 2 worktree isolation; empty otherwise). */
|
|
226
|
+
private taskCwds;
|
|
227
|
+
/** Per-task git worktree branch, for board display. */
|
|
228
|
+
private taskBranches;
|
|
229
|
+
/** Live worktree handles keyed by task id (for commit/merge/release). */
|
|
230
|
+
private taskWorktrees;
|
|
231
|
+
/** Live subagent id per running task — lets cancelTask() abort exactly one. */
|
|
232
|
+
private taskSubagents;
|
|
233
|
+
/** Tasks the user cancelled mid-flight — skip retry, mark terminal-cancelled. */
|
|
234
|
+
private cancelledTasks;
|
|
235
|
+
/**
|
|
236
|
+
* Base branch the run's squash commits land on (captured once at start when
|
|
237
|
+
* worktrees are enabled). Anchors a later `rollback()`.
|
|
238
|
+
*/
|
|
239
|
+
private baseBranch;
|
|
240
|
+
/**
|
|
241
|
+
* Squash-merge commits this run landed on the base branch, in landing order.
|
|
242
|
+
* `rollback()` reverts these (newest → oldest). Persisted via the board
|
|
243
|
+
* snapshot so a post-run rollback can read them off disk.
|
|
244
|
+
*/
|
|
245
|
+
private mergedCommits;
|
|
246
|
+
/** Monotonic dispatch counter (unique subagent ids) + dispatch-round counter. */
|
|
247
|
+
private dispatchSeq;
|
|
248
|
+
private round;
|
|
249
|
+
constructor(opts: SddParallelRunOptions);
|
|
250
|
+
/** Type-safe emit on the optional EventBus (no-op when unwired). */
|
|
251
|
+
private emit;
|
|
252
|
+
private currentSessionId;
|
|
253
|
+
private paused;
|
|
254
|
+
/** Trigger stop — causes run() to abort after the current wave. */
|
|
255
|
+
stop(): void;
|
|
256
|
+
/** Pause: no new wave starts until resume() (the current wave finishes). */
|
|
257
|
+
pause(): void;
|
|
258
|
+
resume(): void;
|
|
259
|
+
isPaused(): boolean;
|
|
260
|
+
isRunning(): boolean;
|
|
261
|
+
/** Base branch the run's squash commits land on (undefined when worktrees off). */
|
|
262
|
+
getBaseBranch(): string | undefined;
|
|
263
|
+
/** Squash commits this run landed on the base branch, in landing order. */
|
|
264
|
+
getMergedCommits(): ReadonlyArray<{
|
|
265
|
+
taskId: string;
|
|
266
|
+
sha: string;
|
|
267
|
+
title: string;
|
|
268
|
+
}>;
|
|
269
|
+
/**
|
|
270
|
+
* Remove every git worktree + branch this run (and any prior run) created.
|
|
271
|
+
* Refuses while the run is still live — cleaning a checkout under an active
|
|
272
|
+
* worker would corrupt it. Stop first. Returns the number of worktrees removed
|
|
273
|
+
* (0 when worktrees are disabled). Idempotent.
|
|
274
|
+
*/
|
|
275
|
+
cleanupWorktrees(): Promise<number>;
|
|
276
|
+
/**
|
|
277
|
+
* Undo the run's merged commits by reverting each on the base branch (history
|
|
278
|
+
* preserving). Refuses while the run is still live (stop first). Returns the
|
|
279
|
+
* revert outcome; a dirty tree or revert conflict surfaces as `ok:false`.
|
|
280
|
+
*/
|
|
281
|
+
rollback(): Promise<{
|
|
282
|
+
ok: boolean;
|
|
283
|
+
reverted: number;
|
|
284
|
+
reason?: string;
|
|
285
|
+
}>;
|
|
286
|
+
/** Requeue a task to `pending` so the scheduler re-runs it (clears retries + cancel marker). */
|
|
287
|
+
retryTask(taskId: string): boolean;
|
|
288
|
+
/** Reassign a task to a specific agent name (reflected on the board). */
|
|
289
|
+
reassignTask(taskId: string, agentName: string): boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Set/override a task's worker model (and optionally provider) — applied on its
|
|
292
|
+
* NEXT dispatch (a running task must be cancelled + retried to take effect). The
|
|
293
|
+
* assignment lives on node metadata so it survives crash → resume.
|
|
294
|
+
*/
|
|
295
|
+
setTaskModel(taskId: string, model: string | undefined, provider?: string | undefined): boolean;
|
|
296
|
+
/** Set/override a task's fallback model chain (applied on its next dispatch). */
|
|
297
|
+
setTaskFallbacks(taskId: string, fallbackModels: string[] | undefined): boolean;
|
|
298
|
+
/**
|
|
299
|
+
* Set/override a task's verification command (the completion gate runs it in
|
|
300
|
+
* the task's cwd and only lets the task complete on exit 0). Empty/undefined
|
|
301
|
+
* clears it. Applied on the task's next verification — i.e. its next dispatch.
|
|
302
|
+
*/
|
|
303
|
+
setTaskVerification(taskId: string, verificationCommand: string | undefined): boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Cancel a task. If it is currently running, abort its subagent and mark the
|
|
306
|
+
* node terminally failed+cancelled (so the scheduler frees the slot and does
|
|
307
|
+
* NOT retry it). If it has not started, it is simply marked cancelled. Use
|
|
308
|
+
* `retryTask` to bring a cancelled task back. Returns false for an unknown task.
|
|
309
|
+
*/
|
|
310
|
+
cancelTask(taskId: string): Promise<boolean>;
|
|
311
|
+
/**
|
|
312
|
+
* Delete a not-yet-started task from the graph (pending/blocked/failed only —
|
|
313
|
+
* never a running task; cancel it first). Removes the node and every edge
|
|
314
|
+
* touching it; dependents lose this blocker. Returns false if missing or running.
|
|
315
|
+
*/
|
|
316
|
+
deleteTask(taskId: string): boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Split a task into sub-tasks and delegate them to separate workers. The new
|
|
319
|
+
* leaves inherit the parent's blockers (so they don't start before the
|
|
320
|
+
* parent's dependencies are met), every existing dependent is rewired to
|
|
321
|
+
* depend on ALL leaves (so downstream work waits for the whole split), and the
|
|
322
|
+
* parent becomes a `completed` container. Refuses a running task (cancel it
|
|
323
|
+
* first) or empty subtask list. Returns the new leaf ids (empty on refusal).
|
|
324
|
+
* The scheduler picks the new pending leaves up on its next dispatch pass.
|
|
325
|
+
*/
|
|
326
|
+
splitTask(taskId: string, subtasks: SddSubtaskSpec[]): string[];
|
|
327
|
+
private waitWhilePaused;
|
|
328
|
+
/**
|
|
329
|
+
* Continuous dependency-driven execution. Unlike a wave-barrier loop (where a
|
|
330
|
+
* whole batch must finish before the next starts), this fills free worker
|
|
331
|
+
* slots the instant a task's dependencies are satisfied: a fast task's
|
|
332
|
+
* dependent starts immediately rather than waiting for a slow sibling. Truly
|
|
333
|
+
* independent tasks run in parallel; dependency chains run in order. Returns
|
|
334
|
+
* the final summary when the graph settles, deadlocks, stops, or hits a backstop.
|
|
335
|
+
*/
|
|
336
|
+
run(): Promise<RunResult>;
|
|
337
|
+
/**
|
|
338
|
+
* Compute the blocking chains for a deadlock: every still-incomplete task and
|
|
339
|
+
* the blockers (by node id) that are NOT completed. Failed blockers are
|
|
340
|
+
* included since they're the usual deadlock cause once retries are exhausted.
|
|
341
|
+
*/
|
|
342
|
+
private computeDeadlockChains;
|
|
343
|
+
/** Requeue failed tasks that block an incomplete dependent. Returns true if any. */
|
|
344
|
+
private recoverFailedBlockers;
|
|
345
|
+
/**
|
|
346
|
+
* Requeue every terminal-failed task that the user did NOT cancel, giving each
|
|
347
|
+
* a fresh `maxRetries` budget. Shared by the automatic end-of-run sweep and
|
|
348
|
+
* the manual "retry all failed" control. Returns the number requeued.
|
|
349
|
+
*/
|
|
350
|
+
private requeueFailedTasks;
|
|
351
|
+
/**
|
|
352
|
+
* Manually requeue all failed tasks to `pending` (board "Retry all failed").
|
|
353
|
+
* Unlike the automatic sweep this also clears any `cancelled` marker, so a
|
|
354
|
+
* user can bring cancelled tasks back in the same action — mirroring
|
|
355
|
+
* `retryTask`. Picked up by the running scheduler on its next dispatch pass.
|
|
356
|
+
* Returns the number of tasks requeued.
|
|
357
|
+
*/
|
|
358
|
+
retryAllFailed(): number;
|
|
359
|
+
/** Restore per-task retry counts persisted in node metadata (resume support). */
|
|
360
|
+
private restoreRetryMap;
|
|
361
|
+
/**
|
|
362
|
+
* Reset orphaned `in_progress` tasks (no agent runs them after a crash) back
|
|
363
|
+
* to `pending` so a fresh run re-executes them. Call before constructing a run
|
|
364
|
+
* from a reloaded graph. Static so callers don't need a run instance.
|
|
365
|
+
*/
|
|
366
|
+
static resetOrphans(tracker: TaskTracker): number;
|
|
367
|
+
/** Clean teardown after a stop: reset interrupted tasks + release worktrees. */
|
|
368
|
+
private teardown;
|
|
369
|
+
private buildCoordinator;
|
|
370
|
+
private defaultFactory;
|
|
371
|
+
/**
|
|
372
|
+
* Execute a batch of tasks together. Retained as a thin wrapper over the
|
|
373
|
+
* single-task primitive `executeOne` so the wave-oriented tests and any
|
|
374
|
+
* batch callers keep working; the continuous scheduler in `run()` calls
|
|
375
|
+
* `executeOne` directly. Throws if no coordinator is wired or a spawn fails
|
|
376
|
+
* (surfaced from `executeOne`), preserving the original all-or-nothing contract.
|
|
377
|
+
*/
|
|
378
|
+
executeWave(batch: TaskBatch): Promise<WaveResult>;
|
|
379
|
+
/**
|
|
380
|
+
* Execute one task end-to-end: assign a worker identity, allocate its worktree,
|
|
381
|
+
* spawn + assign the subagent, await its result, then update tracker status
|
|
382
|
+
* (success / retry / terminal-fail / cancelled) and resolve the worktree. This
|
|
383
|
+
* is the unit the continuous scheduler dispatches into a free slot. Throws on a
|
|
384
|
+
* missing coordinator or failed spawn so callers can enforce all-or-nothing.
|
|
385
|
+
*/
|
|
386
|
+
executeOne(task: TaskNode): Promise<TaskOutcome>;
|
|
387
|
+
/**
|
|
388
|
+
* Apply a task failure: retry (→ pending, bump retry count) while attempts
|
|
389
|
+
* remain, else consult the optional supervisor (which can rescue via
|
|
390
|
+
* retry/reassign/split), else terminal-fail (→ failed). Shared by the
|
|
391
|
+
* worker-failure, verification-gate, and merge-conflict paths so all three
|
|
392
|
+
* negotiate the same retry budget and emit the same events.
|
|
393
|
+
*/
|
|
394
|
+
private applyTaskFailure;
|
|
395
|
+
/**
|
|
396
|
+
* Consult `superviseFailure` for a task that has exhausted its retries.
|
|
397
|
+
* Applies the verdict (retry / reassign+retry / split) and returns true when
|
|
398
|
+
* the task was rescued (caller must NOT terminal-fail it). Bounded per task by
|
|
399
|
+
* `maxSupervisorEscalations` so an always-"retry" supervisor can't loop forever.
|
|
400
|
+
*/
|
|
401
|
+
private trySupervisorRescue;
|
|
402
|
+
/**
|
|
403
|
+
* Integrate a verified-successful task's worktree into the base branch.
|
|
404
|
+
* Commits, squash-merges (optionally running `conflictResolver` first), and on
|
|
405
|
+
* success releases the worktree. On an UNRESOLVED conflict it returns
|
|
406
|
+
* `{ok:false}` with the conflicting files so the caller routes the task into
|
|
407
|
+
* the failure path (a retry forks a fresh worktree off the now-advanced base,
|
|
408
|
+
* which usually clears the conflict). No-op `{ok:true}` when worktrees are
|
|
409
|
+
* disabled or none was allocated for this task. Never throws — a merge hiccup
|
|
410
|
+
* degrades to a (retryable) failure rather than wedging the run.
|
|
411
|
+
*/
|
|
412
|
+
private integrateWorktree;
|
|
413
|
+
/** Allocate a fresh git worktree per task in the batch (no-op without a manager). */
|
|
414
|
+
private allocateWorktrees;
|
|
415
|
+
/**
|
|
416
|
+
* Resolve each task's worktree after its result is known. Serialized merges
|
|
417
|
+
* (one at a time) keep the base branch consistent; the wave structure already
|
|
418
|
+
* guarantees dependency order (a task's blockers merged in an earlier wave).
|
|
419
|
+
*/
|
|
420
|
+
private resolveWorktrees;
|
|
421
|
+
private forgetWorktree;
|
|
422
|
+
/** Persist a task's retry count into node metadata (survives crash → resume). */
|
|
423
|
+
private persistRetries;
|
|
424
|
+
private buildProgress;
|
|
425
|
+
}
|
|
426
|
+
export {};
|
|
427
|
+
//# sourceMappingURL=sdd-parallel-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdd-parallel-run.d.ts","sourceRoot":"","sources":["../src/sdd-parallel-run.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExE,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EA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IACG,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CAgMrD;IAED;;;;;;OAMG;YACW,gBAAgB;IA2B9B;;;;;OAKG;YACW,mBAAmB;IAyCjC;;;;;;;;;OASG;YACW,iBAAiB;IAyE/B,qFAAqF;YACvE,iBAAiB;IAuB/B;;;;OAIG;YACW,gBAAgB;IAsC9B,OAAO,CAAC,cAAc;IAMtB,iFAAiF;IACjF,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,aAAa;CAgBtB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { SddBoardSnapshot } from './board-types.js';
|
|
2
|
+
import type { SddSubtaskSpec } from './sdd-parallel-run.js';
|
|
3
|
+
/**
|
|
4
|
+
* Control surface over a live SDD run, exposed to every steering surface
|
|
5
|
+
* (TUI, CLI-hosted WebUI in-process; standalone WebUI via a control file the
|
|
6
|
+
* run drains). The run itself stays CLI-owned — this is the only sanctioned
|
|
7
|
+
* way to pause / retry / reassign from outside the run loop.
|
|
8
|
+
*/
|
|
9
|
+
export interface SddRunControl {
|
|
10
|
+
runId: string;
|
|
11
|
+
specId?: string | undefined;
|
|
12
|
+
pause(): void;
|
|
13
|
+
resume(): void;
|
|
14
|
+
stop(): void;
|
|
15
|
+
retryTask(taskId: string): boolean;
|
|
16
|
+
/** Requeue every failed task to pending (board "Retry all failed"). Returns the count. */
|
|
17
|
+
retryAllFailed(): number;
|
|
18
|
+
reassignTask(taskId: string, agentName: string): boolean;
|
|
19
|
+
/** Set/override a task's worker model (+ optional provider). Next dispatch. */
|
|
20
|
+
setTaskModel(taskId: string, model: string | undefined, provider?: string | undefined): boolean;
|
|
21
|
+
/** Set/override a task's fallback model chain. Next dispatch. */
|
|
22
|
+
setTaskFallbacks(taskId: string, fallbackModels: string[] | undefined): boolean;
|
|
23
|
+
/** Set/override a task's completion-gate verification command. Next dispatch. */
|
|
24
|
+
setTaskVerification(taskId: string, verificationCommand: string | undefined): boolean;
|
|
25
|
+
/** Cancel a task — abort it if running, else mark it cancelled. */
|
|
26
|
+
cancelTask(taskId: string): Promise<boolean> | boolean;
|
|
27
|
+
/** Delete a not-started task from the graph (refused while running). */
|
|
28
|
+
deleteTask(taskId: string): boolean;
|
|
29
|
+
/** Split a task into sub-tasks (refused while running). Returns the new leaf ids. */
|
|
30
|
+
splitTask(taskId: string, subtasks: SddSubtaskSpec[]): string[];
|
|
31
|
+
/**
|
|
32
|
+
* Remove every git worktree + branch the run created (refused while running —
|
|
33
|
+
* stop first). Returns the number removed.
|
|
34
|
+
*/
|
|
35
|
+
cleanupWorktrees(): Promise<number>;
|
|
36
|
+
/**
|
|
37
|
+
* Undo the run's merged commits by reverting each on the base branch (refused
|
|
38
|
+
* while running). History-preserving; refuses on a dirty tree / revert conflict.
|
|
39
|
+
*/
|
|
40
|
+
rollback(): Promise<{
|
|
41
|
+
ok: boolean;
|
|
42
|
+
reverted: number;
|
|
43
|
+
reason?: string;
|
|
44
|
+
}>;
|
|
45
|
+
/** Base branch the run's squash commits land on (worktree runs only). */
|
|
46
|
+
getBaseBranch(): string | undefined;
|
|
47
|
+
/** Squash commits the run landed on the base branch, in landing order. */
|
|
48
|
+
getMergedCommits(): ReadonlyArray<{
|
|
49
|
+
taskId: string;
|
|
50
|
+
sha: string;
|
|
51
|
+
title: string;
|
|
52
|
+
}>;
|
|
53
|
+
/** Latest board snapshot (built on demand). */
|
|
54
|
+
snapshot(): SddBoardSnapshot;
|
|
55
|
+
isRunning(): boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* In-process registry of the active SDD run. One run is active at a time (a
|
|
59
|
+
* single fleet drives it); a new run replaces the previous. Lives in the CLI
|
|
60
|
+
* process where the fleet runs.
|
|
61
|
+
*/
|
|
62
|
+
export declare class SddRunRegistry {
|
|
63
|
+
private current;
|
|
64
|
+
register(control: SddRunControl): void;
|
|
65
|
+
clear(runId: string): void;
|
|
66
|
+
getActive(): SddRunControl | null;
|
|
67
|
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C,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,MAAM,EAAE,CAAC;IAChE;;;OAGG;IACH,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxE,yEAAyE;IACzE,aAAa,IAAI,MAAM,GAAG,SAAS,CAAC;IACpC,0EAA0E;IAC1E,gBAAgB,IAAI,aAAa,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClF,+CAA+C;IAC/C,QAAQ,IAAI,gBAAgB,CAAC;IAC7B,SAAS,IAAI,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAA8B;IAE7C,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAErC;IAED,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAEzB;IAED,SAAS,IAAI,aAAa,GAAG,IAAI,CAEhC;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { BrainArbiter } from '@wrongstack/core';
|
|
2
|
+
import type { TaskNode } from '@wrongstack/core/types';
|
|
3
|
+
import type { SddSubtaskSpec, SddSupervisorVerdict } from './sdd-parallel-run.js';
|
|
4
|
+
export interface SddSupervisorOptions {
|
|
5
|
+
/** Decision authority (policy/LLM/human). Reuse the session's TOKENS.BrainArbiter. */
|
|
6
|
+
brain: BrainArbiter;
|
|
7
|
+
/**
|
|
8
|
+
* Models to rotate through on a `reassign` verdict (e.g. the run's fallback
|
|
9
|
+
* chain). Omit to drop the reassign option entirely.
|
|
10
|
+
*/
|
|
11
|
+
reassignModels?: string[] | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Optional sub-task generator for a `split` verdict — typically an LLM call
|
|
14
|
+
* that decomposes the failing task into smaller pieces. Omit to drop the split
|
|
15
|
+
* option. Returning an empty array degrades the split into a retry.
|
|
16
|
+
*/
|
|
17
|
+
generateSubtasks?: ((info: {
|
|
18
|
+
task: TaskNode;
|
|
19
|
+
error: string;
|
|
20
|
+
}) => Promise<SddSubtaskSpec[]>) | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Let the tiered brain's LLM layer actually pick the verdict.
|
|
23
|
+
*
|
|
24
|
+
* Default (false) requests `fallback: 'continue'`, which the policy layer
|
|
25
|
+
* answers immediately (a bounded retry) — the LLM never runs, so `reassign`/
|
|
26
|
+
* `split` can't be chosen. Set true to request `fallback: 'ask_human'`, which
|
|
27
|
+
* makes the policy escalate so the autonomous (LLM) layer decides.
|
|
28
|
+
*
|
|
29
|
+
* ONLY enable this when the supplied `brain` will NOT block on a human prompt
|
|
30
|
+
* for an unresolved decision (i.e. it has an autonomous layer and is NOT
|
|
31
|
+
* wrapped in `HumanEscalatingBrainArbiter`). When the LLM can't decide (no
|
|
32
|
+
* autonomous layer / over the risk ceiling / LLM down) the brain returns
|
|
33
|
+
* `ask_human`, which the supervisor degrades to a **bounded retry** (never a
|
|
34
|
+
* block, never a dead-end). A human-escalating brain would instead block
|
|
35
|
+
* inside `decide()` and wedge the run — keep this false there.
|
|
36
|
+
*/
|
|
37
|
+
requestLlmVerdict?: boolean | undefined;
|
|
38
|
+
}
|
|
39
|
+
export declare class SddSupervisor {
|
|
40
|
+
private readonly opts;
|
|
41
|
+
constructor(opts: SddSupervisorOptions);
|
|
42
|
+
/**
|
|
43
|
+
* Bind this as `SddParallelRunOptions.superviseFailure`. Returns a verdict the
|
|
44
|
+
* run applies, or `undefined`/`{action:'fail'}` to let the task terminal-fail.
|
|
45
|
+
*/
|
|
46
|
+
readonly superviseFailure: (info: {
|
|
47
|
+
task: TaskNode;
|
|
48
|
+
error: string;
|
|
49
|
+
attempts: number;
|
|
50
|
+
}) => Promise<SddSupervisorVerdict | undefined>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=sdd-supervisor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdd-supervisor.d.ts","sourceRoot":"","sources":["../src/sdd-supervisor.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAElF,MAAM,WAAW,oBAAoB;IACnC,sFAAsF;IACtF,KAAK,EAAE,YAAY,CAAC;IACpB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACtC;;;;OAIG;IACH,gBAAgB,CAAC,EACb,CAAC,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,GACxE,SAAS,CAAC;IACd;;;;;;;;;;;;;;;OAeG;IACH,iBAAiB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACzC;AAED,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAjC,YAA6B,IAAI,EAAE,oBAAoB,EAAI;IAE3D;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,SAAgB;QACvC,IAAI,EAAE,QAAQ,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;KAClB,KAAG,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC,CAoD3C;CACH"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SddTaskDecomposer
|
|
3
|
+
*
|
|
4
|
+
* Converts a TaskGraph (from SDD's TaskGenerator) into a dependency-aware
|
|
5
|
+
* sequence of batches for ParallelEternalEngine.
|
|
6
|
+
*
|
|
7
|
+
* Key behaviour:
|
|
8
|
+
* - Each `nextBatch()` call returns up to `parallelSlots` ready tasks
|
|
9
|
+
* (all blockers completed, sorted by priority).
|
|
10
|
+
* - Tasks that are blocked by an in-progress task are NOT included
|
|
11
|
+
* in the batch — they wait for the blocker to complete.
|
|
12
|
+
* - When `isDone()` returns true the whole graph is either completed
|
|
13
|
+
* or deadlocked (all remaining tasks are blocked by failed tasks).
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* ```
|
|
17
|
+
* const decomposer = new SddTaskDecomposer(tracker, graph, { parallelSlots: 4 });
|
|
18
|
+
* while (!decomposer.isDone()) {
|
|
19
|
+
* const batch = decomposer.nextBatch();
|
|
20
|
+
* if (batch.length === 0) break; // deadlock
|
|
21
|
+
* await fanOut(batch);
|
|
22
|
+
* decomposer.acknowledgeBatch(batch.map(t => t.id));
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import type { TaskNode, TaskGraph } from '@wrongstack/core/types';
|
|
27
|
+
import type { TaskTracker } from '@wrongstack/core/tasking';
|
|
28
|
+
export interface SddTaskDecomposerOptions {
|
|
29
|
+
/** Max tasks per batch. Default: 4. Range 1–16. */
|
|
30
|
+
parallelSlots?: number | undefined;
|
|
31
|
+
}
|
|
32
|
+
export interface TaskBatch {
|
|
33
|
+
/** Tasks ready to execute in this wave. */
|
|
34
|
+
tasks: TaskNode[];
|
|
35
|
+
/** 0-based wave number since the decomposer was constructed. */
|
|
36
|
+
wave: number;
|
|
37
|
+
/** True when every node in the graph is either completed or failed. */
|
|
38
|
+
allDone: boolean;
|
|
39
|
+
/** True when no batch was produced because remaining tasks are all blocked by failed nodes. */
|
|
40
|
+
deadlocked: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare class SddTaskDecomposer {
|
|
43
|
+
private readonly tracker;
|
|
44
|
+
private readonly slots;
|
|
45
|
+
private wave;
|
|
46
|
+
constructor(tracker: TaskTracker, _graph: TaskGraph, opts?: SddTaskDecomposerOptions);
|
|
47
|
+
/**
|
|
48
|
+
* Return the next batch of runnable tasks.
|
|
49
|
+
* Returns `allDone: true` when every node is completed.
|
|
50
|
+
* Returns `deadlocked: true` when no batch can be produced because
|
|
51
|
+
* all remaining tasks are blocked by failed nodes.
|
|
52
|
+
*/
|
|
53
|
+
nextBatch(): TaskBatch;
|
|
54
|
+
/**
|
|
55
|
+
* Advance the wave counter after a batch completes.
|
|
56
|
+
* Call this once per `nextBatch()` result that was fan-out.
|
|
57
|
+
*/
|
|
58
|
+
acknowledgeBatch(_completedTaskIds: string[]): void;
|
|
59
|
+
/**
|
|
60
|
+
* True when every node in the graph is completed.
|
|
61
|
+
* Use this to exit the fan-out loop after `isDone() || deadlocked`.
|
|
62
|
+
*/
|
|
63
|
+
isDone(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Total waves produced so far.
|
|
66
|
+
*/
|
|
67
|
+
getWaveCount(): number;
|
|
68
|
+
/**
|
|
69
|
+
* All ready (dependency-satisfied) pending tasks, priority-sorted — UNSLICED.
|
|
70
|
+
* The continuous scheduler fills its own free slots from this list, so unlike
|
|
71
|
+
* `nextBatch()` it does not cap at `slots`.
|
|
72
|
+
*/
|
|
73
|
+
readyNodes(): TaskNode[];
|
|
74
|
+
/**
|
|
75
|
+
* True when every node has reached a terminal state (completed or failed).
|
|
76
|
+
* This — not `isDone()` (which requires ALL completed) — is the correct loop
|
|
77
|
+
* exit for the continuous scheduler: a terminally-failed task must not keep
|
|
78
|
+
* the run spinning to its backstop.
|
|
79
|
+
*/
|
|
80
|
+
isSettled(): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Return pending nodes whose blockers are all completed.
|
|
83
|
+
* Sorted by priority (critical first), then by creation time.
|
|
84
|
+
*/
|
|
85
|
+
private pendingReadyNodes;
|
|
86
|
+
/** True when at least one non-completed, non-failed task is blocked. */
|
|
87
|
+
private hasAnyBlockedTasks;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=sdd-task-decomposer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdd-task-decomposer.d.ts","sourceRoot":"","sources":["../src/sdd-task-decomposer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,WAAW,wBAAwB;IACvC,mDAAmD;IACnD,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,WAAW,SAAS;IACxB,2CAA2C;IAC3C,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAC;IACjB,+FAA+F;IAC/F,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,qBAAa,iBAAiB;IAK1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,IAAI,CAAK;IAEjB,YACmB,OAAO,EAAE,WAAW,EACrC,MAAM,EAAE,SAAS,EACjB,IAAI,GAAE,wBAA6B,EAGpC;IAMD;;;;;OAKG;IACH,SAAS,IAAI,SAAS,CAerB;IAED;;;OAGG;IACH,gBAAgB,CAAC,iBAAiB,EAAE,MAAM,EAAE,GAAG,IAAI,CAElD;IAED;;;OAGG;IACH,MAAM,IAAI,OAAO,CAGhB;IAED;;OAEG;IACH,YAAY,IAAI,MAAM,CAErB;IAED;;;;OAIG;IACH,UAAU,IAAI,QAAQ,EAAE,CAEvB;IAED;;;;;OAKG;IACH,SAA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