@calmo/task-runner 1.2.1 → 1.2.3
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/.gemini/commands/openspec/apply.toml +21 -0
- package/.gemini/commands/openspec/archive.toml +25 -0
- package/.gemini/commands/openspec/proposal.toml +26 -0
- package/AGENTS.md +18 -0
- package/CHANGELOG.md +23 -0
- package/GEMINI.md +8 -0
- package/coverage/coverage-final.json +5 -2
- package/coverage/index.html +20 -20
- package/coverage/lcov-report/index.html +20 -20
- package/coverage/lcov-report/src/EventBus.ts.html +337 -0
- package/coverage/{TaskGraphValidator.ts.html → lcov-report/src/TaskGraphValidator.ts.html} +44 -14
- package/coverage/lcov-report/src/TaskRunner.ts.html +307 -0
- package/coverage/lcov-report/src/WorkflowExecutor.ts.html +457 -0
- package/coverage/lcov-report/src/contracts/RunnerEvents.ts.html +217 -0
- package/coverage/lcov-report/src/contracts/index.html +116 -0
- package/coverage/lcov-report/src/index.html +161 -0
- package/coverage/lcov.info +190 -165
- package/coverage/src/EventBus.ts.html +337 -0
- package/coverage/{lcov-report → src}/TaskGraphValidator.ts.html +44 -14
- package/coverage/src/TaskRunner.ts.html +307 -0
- package/coverage/src/WorkflowExecutor.ts.html +457 -0
- package/coverage/src/contracts/RunnerEvents.ts.html +217 -0
- package/coverage/src/contracts/index.html +116 -0
- package/coverage/src/index.html +161 -0
- package/dist/EventBus.d.ts +26 -0
- package/dist/EventBus.js +56 -0
- package/dist/EventBus.js.map +1 -0
- package/dist/TaskGraphValidator.d.ts +6 -0
- package/dist/TaskGraphValidator.js +9 -0
- package/dist/TaskGraphValidator.js.map +1 -1
- package/dist/TaskRunner.d.ts +3 -36
- package/dist/TaskRunner.js +8 -127
- package/dist/TaskRunner.js.map +1 -1
- package/dist/WorkflowExecutor.d.ts +32 -0
- package/dist/WorkflowExecutor.js +109 -0
- package/dist/WorkflowExecutor.js.map +1 -0
- package/dist/contracts/ITaskGraphValidator.d.ts +6 -0
- package/dist/contracts/RunnerEvents.d.ts +36 -0
- package/dist/contracts/RunnerEvents.js +2 -0
- package/dist/contracts/RunnerEvents.js.map +1 -0
- package/openspec/AGENTS.md +456 -0
- package/openspec/changes/add-external-task-cancellation/proposal.md +14 -0
- package/openspec/changes/add-external-task-cancellation/tasks.md +10 -0
- package/openspec/project.md +31 -0
- package/package.json +1 -1
- package/src/EventBus.ts +84 -0
- package/src/TaskGraphValidator.ts +10 -0
- package/src/TaskRunner.ts +11 -196
- package/src/WorkflowExecutor.ts +124 -0
- package/src/contracts/ITaskGraphValidator.ts +7 -0
- package/src/contracts/RunnerEvents.ts +44 -0
- package/test-report.xml +49 -37
- package/coverage/TaskRunner.ts.html +0 -862
- package/coverage/lcov-report/TaskRunner.ts.html +0 -862
package/src/TaskRunner.ts
CHANGED
|
@@ -2,48 +2,12 @@ import { TaskStep } from "./TaskStep.js";
|
|
|
2
2
|
import { TaskResult } from "./TaskResult.js";
|
|
3
3
|
import { TaskGraphValidator } from "./TaskGraphValidator.js";
|
|
4
4
|
import { TaskGraph } from "./TaskGraph.js";
|
|
5
|
+
import { RunnerEventPayloads, RunnerEventListener } from "./contracts/RunnerEvents.js";
|
|
6
|
+
import { EventBus } from "./EventBus.js";
|
|
7
|
+
import { WorkflowExecutor } from "./WorkflowExecutor.js";
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
export interface RunnerEventPayloads<TContext> {
|
|
10
|
-
workflowStart: {
|
|
11
|
-
context: TContext;
|
|
12
|
-
steps: TaskStep<TContext>[];
|
|
13
|
-
};
|
|
14
|
-
workflowEnd: {
|
|
15
|
-
context: TContext;
|
|
16
|
-
results: Map<string, TaskResult>;
|
|
17
|
-
};
|
|
18
|
-
taskStart: {
|
|
19
|
-
step: TaskStep<TContext>;
|
|
20
|
-
};
|
|
21
|
-
taskEnd: {
|
|
22
|
-
step: TaskStep<TContext>;
|
|
23
|
-
result: TaskResult;
|
|
24
|
-
};
|
|
25
|
-
taskSkipped: {
|
|
26
|
-
step: TaskStep<TContext>;
|
|
27
|
-
result: TaskResult;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* A generic listener type that maps the event key to its specific payload.
|
|
33
|
-
*/
|
|
34
|
-
export type RunnerEventListener<
|
|
35
|
-
TContext,
|
|
36
|
-
K extends keyof RunnerEventPayloads<TContext>,
|
|
37
|
-
> = (data: RunnerEventPayloads<TContext>[K]) => void | Promise<void>;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Helper type for the listeners map to avoid private access issues in generic contexts.
|
|
41
|
-
*/
|
|
42
|
-
type ListenerMap<TContext> = {
|
|
43
|
-
[K in keyof RunnerEventPayloads<TContext>]?: Set<
|
|
44
|
-
RunnerEventListener<TContext, K>
|
|
45
|
-
>;
|
|
46
|
-
};
|
|
9
|
+
// Re-export types for backward compatibility
|
|
10
|
+
export { RunnerEventPayloads, RunnerEventListener };
|
|
47
11
|
|
|
48
12
|
/**
|
|
49
13
|
* The main class that orchestrates the execution of a list of tasks
|
|
@@ -51,8 +15,7 @@ type ListenerMap<TContext> = {
|
|
|
51
15
|
* @template TContext The shape of the shared context object.
|
|
52
16
|
*/
|
|
53
17
|
export class TaskRunner<TContext> {
|
|
54
|
-
private
|
|
55
|
-
private listeners: ListenerMap<TContext> = {};
|
|
18
|
+
private eventBus = new EventBus<TContext>();
|
|
56
19
|
private validator = new TaskGraphValidator();
|
|
57
20
|
|
|
58
21
|
/**
|
|
@@ -69,15 +32,7 @@ export class TaskRunner<TContext> {
|
|
|
69
32
|
event: K,
|
|
70
33
|
callback: RunnerEventListener<TContext, K>
|
|
71
34
|
): void {
|
|
72
|
-
|
|
73
|
-
// Type assertion needed because TypeScript cannot verify that the generic K
|
|
74
|
-
// matches the specific key in the mapped type during assignment.
|
|
75
|
-
this.listeners[event] = new Set() as unknown as ListenerMap<TContext>[K];
|
|
76
|
-
}
|
|
77
|
-
// Type assertion needed to tell TS that this specific Set matches the callback type
|
|
78
|
-
(this.listeners[event] as Set<RunnerEventListener<TContext, K>>).add(
|
|
79
|
-
callback
|
|
80
|
-
);
|
|
35
|
+
this.eventBus.on(event, callback);
|
|
81
36
|
}
|
|
82
37
|
|
|
83
38
|
/**
|
|
@@ -89,38 +44,7 @@ export class TaskRunner<TContext> {
|
|
|
89
44
|
event: K,
|
|
90
45
|
callback: RunnerEventListener<TContext, K>
|
|
91
46
|
): void {
|
|
92
|
-
|
|
93
|
-
(this.listeners[event] as Set<RunnerEventListener<TContext, K>>).delete(
|
|
94
|
-
callback
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Emit an event to all subscribers.
|
|
101
|
-
* @param event The event name.
|
|
102
|
-
* @param data The payload for the event.
|
|
103
|
-
*/
|
|
104
|
-
private emit<K extends keyof RunnerEventPayloads<TContext>>(
|
|
105
|
-
event: K,
|
|
106
|
-
data: RunnerEventPayloads<TContext>[K]
|
|
107
|
-
): void {
|
|
108
|
-
const listeners = this.listeners[event] as
|
|
109
|
-
| Set<RunnerEventListener<TContext, K>>
|
|
110
|
-
| undefined;
|
|
111
|
-
if (listeners) {
|
|
112
|
-
for (const listener of listeners) {
|
|
113
|
-
try {
|
|
114
|
-
listener(data);
|
|
115
|
-
} catch (error) {
|
|
116
|
-
// Prevent listener errors from bubbling up
|
|
117
|
-
console.error(
|
|
118
|
-
`Error in event listener for ${String(event)}:`,
|
|
119
|
-
error
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
47
|
+
this.eventBus.off(event, callback);
|
|
124
48
|
}
|
|
125
49
|
|
|
126
50
|
/**
|
|
@@ -141,119 +65,10 @@ export class TaskRunner<TContext> {
|
|
|
141
65
|
|
|
142
66
|
const validationResult = this.validator.validate(taskGraph);
|
|
143
67
|
if (!validationResult.isValid) {
|
|
144
|
-
|
|
145
|
-
const affectedTasks = new Set<string>();
|
|
146
|
-
const errorDetails: string[] = [];
|
|
147
|
-
|
|
148
|
-
for (const error of validationResult.errors) {
|
|
149
|
-
errorDetails.push(error.message);
|
|
150
|
-
switch (error.type) {
|
|
151
|
-
case "cycle": {
|
|
152
|
-
// details is { cyclePath: string[] }
|
|
153
|
-
const path = (error.details as { cyclePath: string[] }).cyclePath;
|
|
154
|
-
// The last element duplicates the first in the path representation, so valid unique tasks are slice(0, -1) or just all as Set handles uniq
|
|
155
|
-
path.forEach((t) => affectedTasks.add(t));
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
case "missing_dependency": {
|
|
159
|
-
// details is { taskId: string, missingDependencyId: string }
|
|
160
|
-
const d = error.details as { taskId: string };
|
|
161
|
-
affectedTasks.add(d.taskId);
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
case "duplicate_task": {
|
|
165
|
-
const d = error.details as { taskId: string };
|
|
166
|
-
affectedTasks.add(d.taskId);
|
|
167
|
-
break;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Legacy error format: "Circular dependency or missing dependency detected. Unable to run tasks: A, B"
|
|
173
|
-
const taskList = Array.from(affectedTasks).join(", ");
|
|
174
|
-
const legacyMessage = `Circular dependency or missing dependency detected. Unable to run tasks: ${taskList}`;
|
|
175
|
-
const detailedMessage = `Task graph validation failed: ${errorDetails.join("; ")}`;
|
|
176
|
-
|
|
177
|
-
// Combine them to satisfy both legacy tests (checking for legacy message) and new requirements (clear details)
|
|
178
|
-
throw new Error(`${legacyMessage} | ${detailedMessage}`);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
this.emit("workflowStart", { context: this.context, steps });
|
|
182
|
-
|
|
183
|
-
const results = new Map<string, TaskResult>();
|
|
184
|
-
const executingPromises = new Set<Promise<void>>();
|
|
185
|
-
|
|
186
|
-
// Helper to process pending steps and launch ready ones
|
|
187
|
-
const processPendingSteps = () => {
|
|
188
|
-
const pendingSteps = steps.filter(
|
|
189
|
-
(step) => !results.has(step.name) && !this.running.has(step.name)
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
// 1. Identify and mark skipped tasks
|
|
193
|
-
for (const step of pendingSteps) {
|
|
194
|
-
const deps = step.dependencies ?? [];
|
|
195
|
-
const failedDep = deps.find(
|
|
196
|
-
(dep) => results.has(dep) && results.get(dep)?.status !== "success"
|
|
197
|
-
);
|
|
198
|
-
if (failedDep) {
|
|
199
|
-
const result: TaskResult = {
|
|
200
|
-
status: "skipped",
|
|
201
|
-
message: `Skipped due to failed dependency: ${failedDep}`,
|
|
202
|
-
};
|
|
203
|
-
results.set(step.name, result);
|
|
204
|
-
this.emit("taskSkipped", { step, result });
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Re-filter pending steps as some might have been skipped above
|
|
209
|
-
const readySteps = steps.filter((step) => {
|
|
210
|
-
if (results.has(step.name) || this.running.has(step.name)) return false;
|
|
211
|
-
const deps = step.dependencies ?? [];
|
|
212
|
-
return deps.every(
|
|
213
|
-
(dep) => results.has(dep) && results.get(dep)?.status === "success"
|
|
214
|
-
);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
// 2. Launch ready tasks
|
|
218
|
-
for (const step of readySteps) {
|
|
219
|
-
this.running.add(step.name);
|
|
220
|
-
this.emit("taskStart", { step });
|
|
221
|
-
|
|
222
|
-
const taskPromise = (async () => {
|
|
223
|
-
try {
|
|
224
|
-
const result = await step.run(this.context);
|
|
225
|
-
results.set(step.name, result);
|
|
226
|
-
} catch (e) {
|
|
227
|
-
results.set(step.name, {
|
|
228
|
-
status: "failure",
|
|
229
|
-
error: e instanceof Error ? e.message : String(e),
|
|
230
|
-
});
|
|
231
|
-
} finally {
|
|
232
|
-
this.running.delete(step.name);
|
|
233
|
-
const result = results.get(step.name)!;
|
|
234
|
-
this.emit("taskEnd", { step, result });
|
|
235
|
-
}
|
|
236
|
-
})();
|
|
237
|
-
|
|
238
|
-
// Wrap the task promise to ensure we can track it in the Set
|
|
239
|
-
const trackedPromise = taskPromise.then(() => {
|
|
240
|
-
executingPromises.delete(trackedPromise);
|
|
241
|
-
});
|
|
242
|
-
executingPromises.add(trackedPromise);
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
// Initial check to start independent tasks
|
|
247
|
-
processPendingSteps();
|
|
248
|
-
|
|
249
|
-
while (results.size < steps.length && executingPromises.size > 0) {
|
|
250
|
-
// Wait for the next task to finish
|
|
251
|
-
await Promise.race(executingPromises);
|
|
252
|
-
// After a task finishes, check for new work
|
|
253
|
-
processPendingSteps();
|
|
68
|
+
throw new Error(this.validator.createErrorMessage(validationResult));
|
|
254
69
|
}
|
|
255
70
|
|
|
256
|
-
|
|
257
|
-
return
|
|
71
|
+
const executor = new WorkflowExecutor(this.context, this.eventBus);
|
|
72
|
+
return executor.execute(steps);
|
|
258
73
|
}
|
|
259
74
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { TaskStep } from "./TaskStep.js";
|
|
2
|
+
import { TaskResult } from "./TaskResult.js";
|
|
3
|
+
import { EventBus } from "./EventBus.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Handles the execution of the workflow steps.
|
|
7
|
+
* @template TContext The shape of the shared context object.
|
|
8
|
+
*/
|
|
9
|
+
export class WorkflowExecutor<TContext> {
|
|
10
|
+
private running = new Set<string>();
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param context The shared context object.
|
|
14
|
+
* @param eventBus The event bus to emit events.
|
|
15
|
+
*/
|
|
16
|
+
constructor(
|
|
17
|
+
private context: TContext,
|
|
18
|
+
private eventBus: EventBus<TContext>
|
|
19
|
+
) {}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Executes the given steps.
|
|
23
|
+
* @param steps The list of steps to execute.
|
|
24
|
+
* @returns A Promise that resolves to a map of task results.
|
|
25
|
+
*/
|
|
26
|
+
async execute(steps: TaskStep<TContext>[]): Promise<Map<string, TaskResult>> {
|
|
27
|
+
this.eventBus.emit("workflowStart", { context: this.context, steps });
|
|
28
|
+
|
|
29
|
+
const results = new Map<string, TaskResult>();
|
|
30
|
+
const executingPromises = new Set<Promise<void>>();
|
|
31
|
+
const pendingSteps = new Set(steps);
|
|
32
|
+
|
|
33
|
+
// Initial pass
|
|
34
|
+
this.processQueue(pendingSteps, results, executingPromises);
|
|
35
|
+
|
|
36
|
+
while (results.size < steps.length && executingPromises.size > 0) {
|
|
37
|
+
// Wait for the next task to finish
|
|
38
|
+
await Promise.race(executingPromises);
|
|
39
|
+
// After a task finishes, check for new work
|
|
40
|
+
this.processQueue(pendingSteps, results, executingPromises);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.eventBus.emit("workflowEnd", { context: this.context, results });
|
|
44
|
+
return results;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Logic to identify tasks that can be started or must be skipped.
|
|
49
|
+
* Iterate only over pending steps to avoid O(N^2) checks on completed tasks.
|
|
50
|
+
*/
|
|
51
|
+
private processQueue(
|
|
52
|
+
pendingSteps: Set<TaskStep<TContext>>,
|
|
53
|
+
results: Map<string, TaskResult>,
|
|
54
|
+
executingPromises: Set<Promise<void>>
|
|
55
|
+
): void {
|
|
56
|
+
const toRemove: TaskStep<TContext>[] = [];
|
|
57
|
+
const toRun: TaskStep<TContext>[] = [];
|
|
58
|
+
|
|
59
|
+
for (const step of pendingSteps) {
|
|
60
|
+
const deps = step.dependencies ?? [];
|
|
61
|
+
let blocked = false;
|
|
62
|
+
let failedDep: string | undefined;
|
|
63
|
+
|
|
64
|
+
for (const dep of deps) {
|
|
65
|
+
const depResult = results.get(dep);
|
|
66
|
+
if (!depResult) {
|
|
67
|
+
// Dependency not finished yet
|
|
68
|
+
blocked = true;
|
|
69
|
+
} else if (depResult.status !== "success") {
|
|
70
|
+
failedDep = dep;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (failedDep) {
|
|
76
|
+
const result: TaskResult = {
|
|
77
|
+
status: "skipped",
|
|
78
|
+
message: `Skipped due to failed dependency: ${failedDep}`,
|
|
79
|
+
};
|
|
80
|
+
results.set(step.name, result);
|
|
81
|
+
this.eventBus.emit("taskSkipped", { step, result });
|
|
82
|
+
toRemove.push(step);
|
|
83
|
+
} else if (!blocked) {
|
|
84
|
+
toRun.push(step);
|
|
85
|
+
toRemove.push(step);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Cleanup pending set
|
|
90
|
+
for (const step of toRemove) {
|
|
91
|
+
pendingSteps.delete(step);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Execute ready tasks
|
|
95
|
+
for (const step of toRun) {
|
|
96
|
+
const taskPromise = this.runStep(step, results).then(() => {
|
|
97
|
+
executingPromises.delete(taskPromise);
|
|
98
|
+
});
|
|
99
|
+
executingPromises.add(taskPromise);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Handles the lifecycle of a single task execution.
|
|
105
|
+
*/
|
|
106
|
+
private async runStep(step: TaskStep<TContext>, results: Map<string, TaskResult>): Promise<void> {
|
|
107
|
+
this.running.add(step.name);
|
|
108
|
+
this.eventBus.emit("taskStart", { step });
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const result = await step.run(this.context);
|
|
112
|
+
results.set(step.name, result);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
results.set(step.name, {
|
|
115
|
+
status: "failure",
|
|
116
|
+
error: e instanceof Error ? e.message : String(e),
|
|
117
|
+
});
|
|
118
|
+
} finally {
|
|
119
|
+
this.running.delete(step.name);
|
|
120
|
+
const result = results.get(step.name)!;
|
|
121
|
+
this.eventBus.emit("taskEnd", { step, result });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -11,4 +11,11 @@ export interface ITaskGraphValidator {
|
|
|
11
11
|
* @returns A ValidationResult object indicating the outcome of the validation.
|
|
12
12
|
*/
|
|
13
13
|
validate(taskGraph: TaskGraph): ValidationResult;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates a human-readable error message from a validation result.
|
|
17
|
+
* @param result The validation result containing errors.
|
|
18
|
+
* @returns A formatted error string.
|
|
19
|
+
*/
|
|
20
|
+
createErrorMessage(result: ValidationResult): string;
|
|
14
21
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { TaskStep } from "../TaskStep.js";
|
|
2
|
+
import { TaskResult } from "../TaskResult.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Define the payload for every possible event in the lifecycle.
|
|
6
|
+
*/
|
|
7
|
+
export interface RunnerEventPayloads<TContext> {
|
|
8
|
+
workflowStart: {
|
|
9
|
+
context: TContext;
|
|
10
|
+
steps: TaskStep<TContext>[];
|
|
11
|
+
};
|
|
12
|
+
workflowEnd: {
|
|
13
|
+
context: TContext;
|
|
14
|
+
results: Map<string, TaskResult>;
|
|
15
|
+
};
|
|
16
|
+
taskStart: {
|
|
17
|
+
step: TaskStep<TContext>;
|
|
18
|
+
};
|
|
19
|
+
taskEnd: {
|
|
20
|
+
step: TaskStep<TContext>;
|
|
21
|
+
result: TaskResult;
|
|
22
|
+
};
|
|
23
|
+
taskSkipped: {
|
|
24
|
+
step: TaskStep<TContext>;
|
|
25
|
+
result: TaskResult;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A generic listener type that maps the event key to its specific payload.
|
|
31
|
+
*/
|
|
32
|
+
export type RunnerEventListener<
|
|
33
|
+
TContext,
|
|
34
|
+
K extends keyof RunnerEventPayloads<TContext>,
|
|
35
|
+
> = (data: RunnerEventPayloads<TContext>[K]) => void | Promise<void>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Helper type for the listeners map.
|
|
39
|
+
*/
|
|
40
|
+
export type ListenerMap<TContext> = {
|
|
41
|
+
[K in keyof RunnerEventPayloads<TContext>]?: Set<
|
|
42
|
+
RunnerEventListener<TContext, K>
|
|
43
|
+
>;
|
|
44
|
+
};
|
package/test-report.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
-
<testsuites name="vitest tests" tests="
|
|
3
|
-
<testsuite name="tests/ComplexScenario.test.ts" timestamp="2026-01-
|
|
4
|
-
<testcase classname="tests/ComplexScenario.test.ts" name="Complex Scenario Integration Tests > 1. All steps execute when all succeed and context is hydrated" time="0.
|
|
2
|
+
<testsuites name="vitest tests" tests="35" failures="0" errors="0" time="0.22304865">
|
|
3
|
+
<testsuite name="tests/ComplexScenario.test.ts" timestamp="2026-01-18T14:25:37.497Z" hostname="runnervmmtnos" tests="2" failures="0" errors="0" skipped="0" time="0.010231018">
|
|
4
|
+
<testcase classname="tests/ComplexScenario.test.ts" name="Complex Scenario Integration Tests > 1. All steps execute when all succeed and context is hydrated" time="0.006235483">
|
|
5
5
|
<system-out>
|
|
6
6
|
Running StepA
|
|
7
7
|
Running StepB
|
|
@@ -15,73 +15,85 @@ Running StepG
|
|
|
15
15
|
|
|
16
16
|
</system-out>
|
|
17
17
|
</testcase>
|
|
18
|
-
<testcase classname="tests/ComplexScenario.test.ts" name="Complex Scenario Integration Tests > 2. The 'skip' propagation works as intended if something breaks up in the tree" time="0.
|
|
18
|
+
<testcase classname="tests/ComplexScenario.test.ts" name="Complex Scenario Integration Tests > 2. The 'skip' propagation works as intended if something breaks up in the tree" time="0.00138321">
|
|
19
19
|
</testcase>
|
|
20
20
|
</testsuite>
|
|
21
|
-
<testsuite name="tests/
|
|
22
|
-
<testcase classname="tests/
|
|
21
|
+
<testsuite name="tests/EventBus.test.ts" timestamp="2026-01-18T14:25:37.498Z" hostname="runnervmmtnos" tests="1" failures="0" errors="0" skipped="0" time="0.018978727">
|
|
22
|
+
<testcase classname="tests/EventBus.test.ts" name="EventBus > should handle async listeners throwing errors without crashing" time="0.016583628">
|
|
23
23
|
</testcase>
|
|
24
|
-
|
|
24
|
+
</testsuite>
|
|
25
|
+
<testsuite name="tests/TaskGraphValidator.test.ts" timestamp="2026-01-18T14:25:37.499Z" hostname="runnervmmtnos" tests="9" failures="0" errors="0" skipped="0" time="0.007340745">
|
|
26
|
+
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should be instantiated" time="0.001387989">
|
|
27
|
+
</testcase>
|
|
28
|
+
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should return valid result for empty graph" time="0.001089122">
|
|
25
29
|
</testcase>
|
|
26
|
-
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should detect duplicate tasks" time="0.
|
|
30
|
+
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should detect duplicate tasks" time="0.001244392">
|
|
27
31
|
</testcase>
|
|
28
|
-
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should detect missing dependencies" time="0.
|
|
32
|
+
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should detect missing dependencies" time="0.000319586">
|
|
29
33
|
</testcase>
|
|
30
|
-
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should detect cycles" time="0.
|
|
34
|
+
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should detect cycles" time="0.000454157">
|
|
31
35
|
</testcase>
|
|
32
|
-
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should return valid for a correct graph" time="0.
|
|
36
|
+
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should return valid for a correct graph" time="0.000401499">
|
|
33
37
|
</testcase>
|
|
34
|
-
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should not detect cycles if missing dependencies are present" time="0.
|
|
38
|
+
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should not detect cycles if missing dependencies are present" time="0.000238875">
|
|
35
39
|
</testcase>
|
|
36
|
-
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should detect more complex cycles" time="0.
|
|
40
|
+
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should detect more complex cycles" time="0.000207848">
|
|
37
41
|
</testcase>
|
|
38
|
-
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should handle cycle detection with no cycles but shared dependencies" time="0.
|
|
42
|
+
<testcase classname="tests/TaskGraphValidator.test.ts" name="TaskGraphValidator > should handle cycle detection with no cycles but shared dependencies" time="0.000228516">
|
|
39
43
|
</testcase>
|
|
40
44
|
</testsuite>
|
|
41
|
-
<testsuite name="tests/TaskRunner.test.ts" timestamp="2026-01-
|
|
42
|
-
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should run tasks in the correct sequential order" time="0.
|
|
45
|
+
<testsuite name="tests/TaskRunner.test.ts" timestamp="2026-01-18T14:25:37.501Z" hostname="runnervmmtnos" tests="10" failures="0" errors="0" skipped="0" time="0.111638951">
|
|
46
|
+
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should run tasks in the correct sequential order" time="0.002716698">
|
|
43
47
|
</testcase>
|
|
44
|
-
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should handle an empty list of tasks gracefully" time="0.
|
|
48
|
+
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should handle an empty list of tasks gracefully" time="0.000317112">
|
|
45
49
|
</testcase>
|
|
46
|
-
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should run independent tasks in parallel" time="0.
|
|
50
|
+
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should run independent tasks in parallel" time="0.10065072">
|
|
47
51
|
</testcase>
|
|
48
|
-
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should skip dependent tasks if a root task fails" time="0.
|
|
52
|
+
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should skip dependent tasks if a root task fails" time="0.000465769">
|
|
49
53
|
</testcase>
|
|
50
|
-
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should throw an error for 'circular dependency'" time="0.
|
|
54
|
+
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should throw an error for 'circular dependency'" time="0.002694306">
|
|
51
55
|
</testcase>
|
|
52
|
-
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should throw an error for 'missing dependency'" time="0.
|
|
56
|
+
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should throw an error for 'missing dependency'" time="0.00041795">
|
|
53
57
|
</testcase>
|
|
54
|
-
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should handle tasks that throw an error during execution" time="0.
|
|
58
|
+
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should handle tasks that throw an error during execution" time="0.000376783">
|
|
55
59
|
</testcase>
|
|
56
|
-
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should skip tasks whose dependencies are skipped" time="0.
|
|
60
|
+
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should skip tasks whose dependencies are skipped" time="0.000786016">
|
|
57
61
|
</testcase>
|
|
58
|
-
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should handle tasks that throw a non-Error object during execution" time="0.
|
|
62
|
+
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should handle tasks that throw a non-Error object during execution" time="0.000431165">
|
|
59
63
|
</testcase>
|
|
60
|
-
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should handle duplicate steps where one gets skipped due to failed dependency" time="0.
|
|
64
|
+
<testcase classname="tests/TaskRunner.test.ts" name="TaskRunner > should handle duplicate steps where one gets skipped due to failed dependency" time="0.000468434">
|
|
61
65
|
</testcase>
|
|
62
66
|
</testsuite>
|
|
63
|
-
<testsuite name="tests/TaskRunnerEvents.test.ts" timestamp="2026-01-
|
|
64
|
-
<testcase classname="tests/TaskRunnerEvents.test.ts" name="TaskRunner Events > should fire all lifecycle events in a successful run" time="0.
|
|
67
|
+
<testsuite name="tests/TaskRunnerEvents.test.ts" timestamp="2026-01-18T14:25:37.503Z" hostname="runnervmmtnos" tests="7" failures="0" errors="0" skipped="0" time="0.012381248">
|
|
68
|
+
<testcase classname="tests/TaskRunnerEvents.test.ts" name="TaskRunner Events > should fire all lifecycle events in a successful run" time="0.00382187">
|
|
69
|
+
</testcase>
|
|
70
|
+
<testcase classname="tests/TaskRunnerEvents.test.ts" name="TaskRunner Events > should fire taskSkipped event when dependency fails" time="0.003792205">
|
|
65
71
|
</testcase>
|
|
66
|
-
<testcase classname="tests/TaskRunnerEvents.test.ts" name="TaskRunner Events > should
|
|
72
|
+
<testcase classname="tests/TaskRunnerEvents.test.ts" name="TaskRunner Events > should not crash if a listener throws an error" time="0.001438714">
|
|
67
73
|
</testcase>
|
|
68
|
-
<testcase classname="tests/TaskRunnerEvents.test.ts" name="TaskRunner Events > should
|
|
74
|
+
<testcase classname="tests/TaskRunnerEvents.test.ts" name="TaskRunner Events > should fire workflow events even for empty step list" time="0.000282257">
|
|
69
75
|
</testcase>
|
|
70
|
-
<testcase classname="tests/TaskRunnerEvents.test.ts" name="TaskRunner Events > should
|
|
76
|
+
<testcase classname="tests/TaskRunnerEvents.test.ts" name="TaskRunner Events > should handle unsubscribe correctly" time="0.000443788">
|
|
71
77
|
</testcase>
|
|
72
|
-
<testcase classname="tests/TaskRunnerEvents.test.ts" name="TaskRunner Events > should handle
|
|
78
|
+
<testcase classname="tests/TaskRunnerEvents.test.ts" name="TaskRunner Events > should safely handle off() when no listeners exist" time="0.000271827">
|
|
79
|
+
</testcase>
|
|
80
|
+
<testcase classname="tests/TaskRunnerEvents.test.ts" name="TaskRunner Events > should support multiple listeners for the same event" time="0.000377915">
|
|
81
|
+
</testcase>
|
|
82
|
+
</testsuite>
|
|
83
|
+
<testsuite name="tests/WorkflowExecutor.test.ts" timestamp="2026-01-18T14:25:37.504Z" hostname="runnervmmtnos" tests="3" failures="0" errors="0" skipped="0" time="0.057149901">
|
|
84
|
+
<testcase classname="tests/WorkflowExecutor.test.ts" name="WorkflowExecutor > should execute steps sequentially when dependencies exist" time="0.003667222">
|
|
73
85
|
</testcase>
|
|
74
|
-
<testcase classname="tests/
|
|
86
|
+
<testcase classname="tests/WorkflowExecutor.test.ts" name="WorkflowExecutor > should skip dependent steps if dependency fails" time="0.000479825">
|
|
75
87
|
</testcase>
|
|
76
|
-
<testcase classname="tests/
|
|
88
|
+
<testcase classname="tests/WorkflowExecutor.test.ts" name="WorkflowExecutor > should run independent steps in parallel" time="0.05083559">
|
|
77
89
|
</testcase>
|
|
78
90
|
</testsuite>
|
|
79
|
-
<testsuite name="tests/integration.test.ts" timestamp="2026-01-
|
|
80
|
-
<testcase classname="tests/integration.test.ts" name="TaskRunner Validation Integration > should throw validation error with clear message for duplicate tasks" time="0.
|
|
91
|
+
<testsuite name="tests/integration.test.ts" timestamp="2026-01-18T14:25:37.505Z" hostname="runnervmmtnos" tests="3" failures="0" errors="0" skipped="0" time="0.00532806">
|
|
92
|
+
<testcase classname="tests/integration.test.ts" name="TaskRunner Validation Integration > should throw validation error with clear message for duplicate tasks" time="0.003098401">
|
|
81
93
|
</testcase>
|
|
82
|
-
<testcase classname="tests/integration.test.ts" name="TaskRunner Validation Integration > should throw validation error with clear message for missing dependencies" time="0.
|
|
94
|
+
<testcase classname="tests/integration.test.ts" name="TaskRunner Validation Integration > should throw validation error with clear message for missing dependencies" time="0.000340456">
|
|
83
95
|
</testcase>
|
|
84
|
-
<testcase classname="tests/integration.test.ts" name="TaskRunner Validation Integration > should throw validation error with clear message for cycles" time="0.
|
|
96
|
+
<testcase classname="tests/integration.test.ts" name="TaskRunner Validation Integration > should throw validation error with clear message for cycles" time="0.000287436">
|
|
85
97
|
</testcase>
|
|
86
98
|
</testsuite>
|
|
87
99
|
</testsuites>
|