@calmo/task-runner 3.4.0 → 3.4.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.
Files changed (87) hide show
  1. package/.github/dependabot.yml +7 -7
  2. package/.github/workflows/ci.yml +4 -4
  3. package/.jules/backlog_maniac.md +1 -0
  4. package/.jules/nexus.md +1 -0
  5. package/.jules/sentinel.md +1 -0
  6. package/.releaserc.json +2 -7
  7. package/AGENTS.md +8 -2
  8. package/CHANGELOG.md +178 -174
  9. package/README.md +23 -23
  10. package/coverage/coverage-final.json +8 -8
  11. package/coverage/index.html +7 -7
  12. package/coverage/lcov-report/index.html +7 -7
  13. package/coverage/lcov-report/src/EventBus.ts.html +27 -21
  14. package/coverage/lcov-report/src/TaskGraphValidationError.ts.html +12 -3
  15. package/coverage/lcov-report/src/TaskGraphValidator.ts.html +152 -137
  16. package/coverage/lcov-report/src/TaskRunner.ts.html +48 -45
  17. package/coverage/lcov-report/src/TaskRunnerBuilder.ts.html +29 -5
  18. package/coverage/lcov-report/src/TaskRunnerExecutionConfig.ts.html +1 -1
  19. package/coverage/lcov-report/src/TaskStateManager.ts.html +1 -1
  20. package/coverage/lcov-report/src/WorkflowExecutor.ts.html +21 -12
  21. package/coverage/lcov-report/src/contracts/RunnerEvents.ts.html +1 -1
  22. package/coverage/lcov-report/src/contracts/index.html +1 -1
  23. package/coverage/lcov-report/src/index.html +8 -8
  24. package/coverage/lcov-report/src/strategies/DryRunExecutionStrategy.ts.html +4 -4
  25. package/coverage/lcov-report/src/strategies/RetryingExecutionStrategy.ts.html +29 -11
  26. package/coverage/lcov-report/src/strategies/StandardExecutionStrategy.ts.html +5 -5
  27. package/coverage/lcov-report/src/strategies/index.html +1 -1
  28. package/coverage/lcov.info +266 -262
  29. package/coverage/src/EventBus.ts.html +27 -21
  30. package/coverage/src/TaskGraphValidationError.ts.html +12 -3
  31. package/coverage/src/TaskGraphValidator.ts.html +152 -137
  32. package/coverage/src/TaskRunner.ts.html +48 -45
  33. package/coverage/src/TaskRunnerBuilder.ts.html +29 -5
  34. package/coverage/src/TaskRunnerExecutionConfig.ts.html +1 -1
  35. package/coverage/src/TaskStateManager.ts.html +1 -1
  36. package/coverage/src/WorkflowExecutor.ts.html +21 -12
  37. package/coverage/src/contracts/RunnerEvents.ts.html +1 -1
  38. package/coverage/src/contracts/index.html +1 -1
  39. package/coverage/src/index.html +8 -8
  40. package/coverage/src/strategies/DryRunExecutionStrategy.ts.html +4 -4
  41. package/coverage/src/strategies/RetryingExecutionStrategy.ts.html +29 -11
  42. package/coverage/src/strategies/StandardExecutionStrategy.ts.html +5 -5
  43. package/coverage/src/strategies/index.html +1 -1
  44. package/dist/EventBus.js +13 -11
  45. package/dist/EventBus.js.map +1 -1
  46. package/dist/TaskGraphValidationError.js.map +1 -1
  47. package/dist/TaskGraphValidator.js +9 -9
  48. package/dist/TaskGraphValidator.js.map +1 -1
  49. package/dist/TaskRunner.js.map +1 -1
  50. package/dist/TaskRunnerBuilder.js.map +1 -1
  51. package/dist/WorkflowExecutor.js +2 -1
  52. package/dist/WorkflowExecutor.js.map +1 -1
  53. package/dist/strategies/RetryingExecutionStrategy.js +3 -1
  54. package/dist/strategies/RetryingExecutionStrategy.js.map +1 -1
  55. package/dist/strategies/StandardExecutionStrategy.js +1 -1
  56. package/dist/strategies/StandardExecutionStrategy.js.map +1 -1
  57. package/openspec/AGENTS.md +81 -15
  58. package/openspec/changes/archive/2026-01-18-add-concurrency-control/proposal.md +7 -4
  59. package/openspec/changes/archive/2026-01-18-add-concurrency-control/tasks.md +1 -0
  60. package/openspec/changes/archive/2026-01-18-add-external-task-cancellation/proposal.md +4 -1
  61. package/openspec/changes/archive/2026-01-18-add-external-task-cancellation/tasks.md +2 -1
  62. package/openspec/changes/archive/2026-01-18-add-integration-tests/proposal.md +3 -0
  63. package/openspec/changes/archive/2026-01-18-add-integration-tests/tasks.md +1 -0
  64. package/openspec/changes/archive/2026-01-18-add-task-retry-policy/proposal.md +3 -0
  65. package/openspec/changes/archive/2026-01-18-add-task-retry-policy/tasks.md +1 -0
  66. package/openspec/changes/archive/2026-01-18-add-workflow-preview/proposal.md +3 -0
  67. package/openspec/changes/archive/2026-01-18-add-workflow-preview/tasks.md +1 -0
  68. package/openspec/changes/archive/2026-01-18-refactor-core-architecture/proposal.md +3 -0
  69. package/openspec/changes/archive/2026-01-18-refactor-core-architecture/tasks.md +1 -0
  70. package/openspec/changes/feat-per-task-timeout/proposal.md +11 -6
  71. package/openspec/changes/feat-per-task-timeout/tasks.md +1 -1
  72. package/openspec/project.md +21 -15
  73. package/package.json +1 -1
  74. package/src/EventBus.ts +18 -16
  75. package/src/TaskGraph.ts +8 -8
  76. package/src/TaskGraphValidationError.ts +4 -1
  77. package/src/TaskGraphValidator.ts +148 -143
  78. package/src/TaskRunner.ts +42 -41
  79. package/src/TaskRunnerBuilder.ts +11 -3
  80. package/src/WorkflowExecutor.ts +13 -10
  81. package/src/contracts/ITaskGraphValidator.ts +12 -12
  82. package/src/contracts/ValidationError.ts +6 -6
  83. package/src/contracts/ValidationResult.ts +4 -4
  84. package/src/strategies/DryRunExecutionStrategy.ts +3 -3
  85. package/src/strategies/RetryingExecutionStrategy.ts +15 -9
  86. package/src/strategies/StandardExecutionStrategy.ts +4 -4
  87. package/test-report.xml +108 -108
package/README.md CHANGED
@@ -36,7 +36,7 @@ runner.on("taskEnd", ({ step, result }) => {
36
36
  Here is a simple example showing how to define a context, create steps, and execute them.
37
37
 
38
38
  ```typescript
39
- import { TaskRunner, TaskStep } from './src';
39
+ import { TaskRunner, TaskStep } from "./src";
40
40
 
41
41
  // 1. Define your domain-specific context
42
42
  interface ValidationContext {
@@ -49,42 +49,42 @@ interface ValidationContext {
49
49
 
50
50
  // 2. Define your steps
51
51
  const UrlFormatStep: TaskStep<ValidationContext> = {
52
- name: 'UrlFormatStep',
52
+ name: "UrlFormatStep",
53
53
  run: async (ctx) => {
54
- const valid = ctx.issueBody.includes('github.com');
54
+ const valid = ctx.issueBody.includes("github.com");
55
55
  return valid
56
- ? { status: 'success' }
57
- : { status: 'failure', error: 'Invalid URL' };
56
+ ? { status: "success" }
57
+ : { status: "failure", error: "Invalid URL" };
58
58
  },
59
59
  };
60
60
 
61
61
  const DataLoaderStep: TaskStep<ValidationContext> = {
62
- name: 'DataLoaderStep',
63
- dependencies: ['UrlFormatStep'],
62
+ name: "DataLoaderStep",
63
+ dependencies: ["UrlFormatStep"],
64
64
  run: async (ctx) => {
65
65
  // Simulate API call
66
- ctx.prData = { additions: 20, ciStatus: 'success' };
67
- return { status: 'success', message: 'Data fetched' };
66
+ ctx.prData = { additions: 20, ciStatus: "success" };
67
+ return { status: "success", message: "Data fetched" };
68
68
  },
69
69
  };
70
70
 
71
71
  const MaxChangesStep: TaskStep<ValidationContext> = {
72
- name: 'MaxChangesStep',
73
- dependencies: ['DataLoaderStep'],
72
+ name: "MaxChangesStep",
73
+ dependencies: ["DataLoaderStep"],
74
74
  run: async (ctx) => {
75
75
  // Safe access because dependencies ensured execution order
76
- if (!ctx.prData) return { status: 'failure', error: 'Missing PR Data' };
76
+ if (!ctx.prData) return { status: "failure", error: "Missing PR Data" };
77
77
 
78
78
  return ctx.prData.additions < 50
79
- ? { status: 'success' }
80
- : { status: 'failure', error: 'Too many changes' };
79
+ ? { status: "success" }
80
+ : { status: "failure", error: "Too many changes" };
81
81
  },
82
82
  };
83
83
 
84
84
  // 3. Execute the runner
85
85
  async function main() {
86
86
  const context: ValidationContext = {
87
- issueBody: 'https://github.com/org/repo/pull/1',
87
+ issueBody: "https://github.com/org/repo/pull/1",
88
88
  };
89
89
 
90
90
  const runner = new TaskRunner(context);
@@ -104,7 +104,7 @@ If a task fails or is skipped, the `TaskRunner` automatically marks all subseque
104
104
 
105
105
  ## Context Hydration
106
106
 
107
- One nice thing to do is to avoid optional parameters and excessive use of ```!``` operator, with task dependencies we can chain our steps and context usages to make sure steps are executed only when pre requisites are met.
107
+ One nice thing to do is to avoid optional parameters and excessive use of `!` operator, with task dependencies we can chain our steps and context usages to make sure steps are executed only when pre requisites are met.
108
108
 
109
109
  This decouples **Data Loading** from **Business Logic**.
110
110
 
@@ -130,23 +130,23 @@ interface MyProjectFullContext extends MyProjectContext {
130
130
 
131
131
  // Step 1: Hydrate the context
132
132
  class UserLoaderStep implements TaskStep<MyProjectContext> {
133
- name = 'UserLoaderStep';
133
+ name = "UserLoaderStep";
134
134
  async run(ctx: MyProjectContext & Partial<MyProjectFullContext>) {
135
135
  // Fetch data and update context
136
- ctx.apiData = { user: 'john_doe', isPro: true };
137
- return { status: 'success' };
136
+ ctx.apiData = { user: "john_doe", isPro: true };
137
+ return { status: "success" };
138
138
  }
139
139
  }
140
140
 
141
141
  // Step 2: Use the hydrated data
142
142
  class PremiumCheckStep implements TaskStep<MyProjectContext> {
143
- name = 'PremiumCheckStep';
144
- dependencies = ['UserLoaderStep']; // Ensures data is ready
143
+ name = "PremiumCheckStep";
144
+ dependencies = ["UserLoaderStep"]; // Ensures data is ready
145
145
 
146
146
  async run(ctx: MyProjectFullContext) {
147
147
  return ctx.apiData.isPro
148
- ? { status: 'success' }
149
- : { status: 'failure', error: 'User is not a Pro member' };
148
+ ? { status: "success" }
149
+ : { status: "failure", error: "User is not a Pro member" };
150
150
  }
151
151
  }
152
152
  ```