@calmo/task-runner 4.0.4 → 4.1.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.
Files changed (46) hide show
  1. package/.github/workflows/codeql.yml +1 -1
  2. package/.github/workflows/release-please.yml +2 -2
  3. package/.jules/nexus.md +5 -0
  4. package/.release-please-manifest.json +1 -1
  5. package/AGENTS.md +1 -0
  6. package/CHANGELOG.md +19 -0
  7. package/CODE_OF_CONDUCT.md +131 -0
  8. package/CONTRIBUTING.md +89 -0
  9. package/dist/TaskResult.d.ts +9 -0
  10. package/dist/TaskRunner.js +47 -34
  11. package/dist/TaskRunner.js.map +1 -1
  12. package/dist/TaskStateManager.d.ts +22 -6
  13. package/dist/TaskStateManager.js +101 -45
  14. package/dist/TaskStateManager.js.map +1 -1
  15. package/dist/WorkflowExecutor.js +17 -10
  16. package/dist/WorkflowExecutor.js.map +1 -1
  17. package/dist/strategies/DryRunExecutionStrategy.d.ts +1 -1
  18. package/dist/strategies/DryRunExecutionStrategy.js +2 -4
  19. package/dist/strategies/DryRunExecutionStrategy.js.map +1 -1
  20. package/dist/utils/PriorityQueue.d.ts +13 -0
  21. package/dist/utils/PriorityQueue.js +82 -0
  22. package/dist/utils/PriorityQueue.js.map +1 -0
  23. package/openspec/changes/add-resource-concurrency/proposal.md +18 -0
  24. package/openspec/changes/add-resource-concurrency/specs/task-runner/spec.md +25 -0
  25. package/openspec/changes/add-resource-concurrency/tasks.md +9 -0
  26. package/openspec/changes/{feat-task-metrics → archive/2026-01-22-feat-task-metrics}/proposal.md +1 -1
  27. package/openspec/changes/archive/2026-01-22-feat-task-metrics/tasks.md +6 -0
  28. package/openspec/changes/feat-conditional-retries/proposal.md +18 -0
  29. package/openspec/changes/feat-conditional-retries/specs/task-runner/spec.md +23 -0
  30. package/openspec/changes/feat-conditional-retries/tasks.md +37 -0
  31. package/openspec/changes/feat-state-persistence/specs/task-runner/spec.md +47 -0
  32. package/openspec/specs/release-pr/spec.md +31 -0
  33. package/openspec/specs/task-runner/spec.md +12 -0
  34. package/package.json +1 -1
  35. package/src/TaskResult.ts +9 -0
  36. package/src/TaskRunner.ts +55 -36
  37. package/src/TaskStateManager.ts +114 -46
  38. package/src/WorkflowExecutor.ts +21 -11
  39. package/src/strategies/DryRunExecutionStrategy.ts +2 -3
  40. package/src/utils/PriorityQueue.ts +101 -0
  41. package/openspec/changes/feat-task-metrics/tasks.md +0 -6
  42. /package/openspec/changes/{adopt-release-pr → archive/2026-01-22-adopt-release-pr}/design.md +0 -0
  43. /package/openspec/changes/{adopt-release-pr → archive/2026-01-22-adopt-release-pr}/proposal.md +0 -0
  44. /package/openspec/changes/{adopt-release-pr → archive/2026-01-22-adopt-release-pr}/specs/release-pr/spec.md +0 -0
  45. /package/openspec/changes/{adopt-release-pr → archive/2026-01-22-adopt-release-pr}/tasks.md +0 -0
  46. /package/openspec/changes/{feat-task-metrics → archive/2026-01-22-feat-task-metrics}/specs/001-generic-task-runner/spec.md +0 -0
@@ -57,7 +57,7 @@ jobs:
57
57
  # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
58
58
  steps:
59
59
  - name: Checkout repository
60
- uses: actions/checkout@v4
60
+ uses: actions/checkout@v6
61
61
 
62
62
  # Add any setup steps before running the `github/codeql-action/init` action.
63
63
  # This includes steps like installing compilers or runtimes (`actions/setup-node`
@@ -20,7 +20,7 @@ jobs:
20
20
  token: ${{ secrets.GITHUB_TOKEN }}
21
21
  target-branch: main
22
22
 
23
- - uses: actions/checkout@v4
23
+ - uses: actions/checkout@v6
24
24
  if: ${{ steps.release.outputs.release_created }}
25
25
 
26
26
  - name: Setup pnpm
@@ -29,7 +29,7 @@ jobs:
29
29
  version: 10.28.0
30
30
  if: ${{ steps.release.outputs.release_created }}
31
31
 
32
- - uses: actions/setup-node@v4
32
+ - uses: actions/setup-node@v6
33
33
  with:
34
34
  node-version: "lts/*"
35
35
  registry-url: "https://registry.npmjs.org"
package/.jules/nexus.md CHANGED
@@ -14,3 +14,8 @@
14
14
 
15
15
  **Insight:** Users' optimization efforts are blind without granular metrics. Users often don't know *which* task is slow, only that the workflow is slow.
16
16
  **Action:** Always include telemetry requirements (like start/end times and duration) in execution engine specs to enable data-driven optimization.
17
+
18
+ ## 2026-01-20 - The "All or Nothing" Retry Trap
19
+
20
+ **Insight:** Blindly retrying failing tasks is a "Product Anti-pattern". Retrying a `SyntaxError` or invalid user input 3 times (with exponential backoff!) is annoying and wasteful.
21
+ **Action:** We must distinguish between "Transient" (network, resource lock) and "Permanent" (logic, validation) failures. Exposing a `shouldRetry` predicate gives the user control without complicating the core runner logic.
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "4.0.4"
2
+ ".": "4.1.0"
3
3
  }
package/AGENTS.md CHANGED
@@ -25,6 +25,7 @@ Keep this managed block so 'openspec update' can refresh the instructions.
25
25
  - Its forbidden to have coverage drop below 100%, thats non negotiable.
26
26
  - **Strict Null Safety:** Do not use `??` or optional chaining `?.` when you can guarantee existence via prior validation. Use non-null assertions `!` only when the invariant is locally provable or enforced by a validator.
27
27
  - **Dead Code Elimination:** Avoid `v8 ignore` comments. If code is unreachable, restructure the logic to prove it is unreachable to the compiler, or remove the branch if the invariant is guaranteed.
28
+ - **Signal Combination:** Prefer `AbortSignal.any()` over manual event listeners when combining multiple `AbortSignal`s to simplify logic and avoid memory leaks.
28
29
 
29
30
  ## Operational Protocols
30
31
 
package/CHANGELOG.md CHANGED
@@ -18,6 +18,25 @@
18
18
  * refactor: Refactor TaskRunner to reduce cognitive complexity (#89) ([95c67d9](https://github.com/thalesraymond/task-runner/commit/95c67d9)), closes [#89](https://github.com/thalesraymond/task-runner/issues/89)
19
19
  * Refactor TaskGraphValidator to address SonarCloud issues (#88) ([77c1538](https://github.com/thalesraymond/task-runner/commit/77c1538)), closes [#88](https://github.com/thalesraymond/task-runner/issues/88)
20
20
 
21
+ ## [4.1.0](https://github.com/thalesraymond/task-runner/compare/task-runner-v4.0.4...task-runner-v4.1.0) (2026-01-24)
22
+
23
+
24
+ ### Features
25
+
26
+ * 🎸 Add task name to sucess message on dry run ([5b9fcd0](https://github.com/thalesraymond/task-runner/commit/5b9fcd0ddd61172687e464cf6a3b5fb65df20cdf))
27
+ * 🎸 metrics per task ([#103](https://github.com/thalesraymond/task-runner/issues/103)) ([c824c56](https://github.com/thalesraymond/task-runner/commit/c824c56dce6d958de8946e1fb9af598bd7e10e5e))
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * 🐛 getMermaidGraph ID collision for similar task names ([#100](https://github.com/thalesraymond/task-runner/issues/100)) ([0d3af0d](https://github.com/thalesraymond/task-runner/commit/0d3af0d1663346d31c4d05bfd0eb498456221b2f))
33
+ * 🛰️ Sonar Specialist: Refactor signal combination in TaskRunner ([#107](https://github.com/thalesraymond/task-runner/issues/107)) ([9c383cc](https://github.com/thalesraymond/task-runner/commit/9c383cc7a6657133136945cec01ccc50d30f752d))
34
+
35
+
36
+ ### Performance Improvements
37
+
38
+ * optimize Mermaid graph ID generation ([#112](https://github.com/thalesraymond/task-runner/issues/112)) ([59e78b1](https://github.com/thalesraymond/task-runner/commit/59e78b1b975e89120d27d827127fbd813a399e36))
39
+
21
40
  ## [4.0.4](https://github.com/thalesraymond/task-runner/compare/task-runner-v4.0.3...task-runner-v4.0.4) (2026-01-22)
22
41
 
23
42
 
@@ -0,0 +1,131 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement by contacting the project maintainers.
63
+ All complaints will be reviewed and investigated promptly and fairly.
64
+
65
+ All community leaders are obligated to respect the privacy and security of the
66
+ reporter of any incident.
67
+
68
+ ## Enforcement Guidelines
69
+
70
+ Community leaders will follow these Community Impact Guidelines in determining
71
+ the consequences for any action they deem in violation of this Code of Conduct:
72
+
73
+ ### 1. Correction
74
+
75
+ **Community Impact**: Use of inappropriate language or other behavior deemed
76
+ unprofessional or unwelcome in the community.
77
+
78
+ **Consequence**: A private, written warning from community leaders, providing
79
+ clarity around the nature of the violation and an explanation of why the
80
+ behavior was inappropriate. A public apology may be requested.
81
+
82
+ ### 2. Warning
83
+
84
+ **Community Impact**: A violation through a single incident or series of
85
+ actions.
86
+
87
+ **Consequence**: A warning with consequences for continued behavior. No
88
+ interaction with the people involved, including unsolicited interaction with
89
+ those enforcing the Code of Conduct, for a specified period of time. This
90
+ includes avoiding interactions in community spaces as well as external channels
91
+ like social media. Violating these terms may lead to a temporary or
92
+ permanent ban.
93
+
94
+ ### 3. Temporary Ban
95
+
96
+ **Community Impact**: A serious violation of community standards, including
97
+ sustained inappropriate behavior.
98
+
99
+ **Consequence**: A temporary ban from any sort of interaction or public
100
+ communication with the community for a specified period of time. No public or
101
+ private interaction with the people involved, including unsolicited interaction
102
+ with those enforcing the Code of Conduct, is allowed during this period.
103
+ Violating these terms may lead to a permanent ban.
104
+
105
+ ### 4. Permanent Ban
106
+
107
+ **Community Impact**: Demonstrating a pattern of violation of community
108
+ standards, including sustained inappropriate behavior, harassment of an
109
+ individual, or aggression toward or disparagement of classes of individuals.
110
+
111
+ **Consequence**: A permanent ban from any sort of public interaction within
112
+ the community.
113
+
114
+ ## Attribution
115
+
116
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
117
+ version 2.1, available at
118
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
119
+
120
+ Community Impact Guidelines were inspired by
121
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
122
+
123
+ For answers to common questions about this code of conduct, see the FAQ at
124
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available
125
+ at [https://www.contributor-covenant.org/translations][translations].
126
+
127
+ [homepage]: https://www.contributor-covenant.org
128
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
129
+ [Mozilla CoC]: https://github.com/mozilla/diversity
130
+ [FAQ]: https://www.contributor-covenant.org/faq
131
+ [translations]: https://www.contributor-covenant.org/translations
@@ -0,0 +1,89 @@
1
+ # Contributing to task-runner
2
+
3
+ First off, thanks for taking the time to contribute!
4
+
5
+ The following is a set of guidelines for contributing to `@calmo/task-runner`. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
6
+
7
+ ## Code of Conduct
8
+
9
+ This project and everyone participating in it is governed by the [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
10
+
11
+ ## Getting Started
12
+
13
+ 1. **Fork the repository** on GitHub.
14
+ 2. **Clone your fork** locally.
15
+ ```bash
16
+ git clone https://github.com/your-username/task-runner.git
17
+ cd task-runner
18
+ ```
19
+ 3. **Install dependencies** using `pnpm`.
20
+ ```bash
21
+ pnpm install
22
+ ```
23
+ *Note: This project uses `pnpm` for package management. Please do not use `npm` or `yarn`.*
24
+
25
+ ## Development Workflow
26
+
27
+ 1. **Create a branch** for your feature or fix.
28
+ ```bash
29
+ git checkout -b feature/my-new-feature
30
+ ```
31
+ 2. **Make your changes**.
32
+ 3. **Run checks** locally to ensure your changes are valid.
33
+
34
+ ### Scripts & Commands
35
+
36
+ The project uses several `pnpm` scripts to maintain code quality:
37
+
38
+ * **Build**: Compile the project.
39
+ ```bash
40
+ pnpm build
41
+ ```
42
+ * **Test**: Run tests with coverage.
43
+ ```bash
44
+ pnpm test
45
+ ```
46
+ **Important**: We enforce **100% code coverage**. If your changes lower the coverage, the CI will fail.
47
+ * **Lint**: Check for linting errors.
48
+ ```bash
49
+ pnpm lint
50
+ ```
51
+ * **Format**: Format the code using Prettier.
52
+ ```bash
53
+ pnpm format
54
+ ```
55
+
56
+ ## Coding Standards
57
+
58
+ Please strictly adhere to the following rules:
59
+
60
+ * **No `any`**: The use of `any` type is strictly forbidden. Use `unknown` or proper types.
61
+ * **Strict Null Safety**: Do not use `??` or optional chaining `?.` when you can guarantee existence via prior validation. Use non-null assertions `!` only when the invariant is locally provable or enforced by a validator.
62
+ * **Dead Code Elimination**: Avoid `v8 ignore` comments. Logic should be structured to prove unreachability.
63
+ * **Atomic Commits**: For complex features, commit after completing distinct tasks. Ensure `pnpm build`, `pnpm lint`, and `pnpm test` pass before each commit.
64
+
65
+ For more detailed agent-specific instructions (which are also good for humans), refer to `AGENTS.md`.
66
+
67
+ ## Commit Messages
68
+
69
+ We follow the **Conventional Commits** specification.
70
+
71
+ You can use the built-in helper to format your commit messages:
72
+ ```bash
73
+ pnpm commit
74
+ ```
75
+ Or format them manually:
76
+ * `feat(scope): add new feature`
77
+ * `fix(scope): fix bug`
78
+ * `docs: update documentation`
79
+ * `test: add tests`
80
+ * `refactor: refactor code`
81
+
82
+ ## Submitting a Pull Request
83
+
84
+ 1. Push your changes to your fork.
85
+ 2. Open a Pull Request against the `main` branch.
86
+ 3. Ensure the PR description clearly describes the problem and solution.
87
+ 4. Make sure all CI checks pass.
88
+
89
+ Thank you for your contributions!
@@ -11,4 +11,13 @@ export interface TaskResult {
11
11
  error?: string;
12
12
  /** Optional data produced by the step for later inspection. */
13
13
  data?: unknown;
14
+ /** Optional execution metrics for the task. */
15
+ metrics?: {
16
+ /** Start time in milliseconds (performance.now). */
17
+ startTime: number;
18
+ /** End time in milliseconds (performance.now). */
19
+ endTime: number;
20
+ /** Duration in milliseconds. */
21
+ duration: number;
22
+ };
14
23
  }
@@ -56,14 +56,49 @@ export class TaskRunner {
56
56
  */
57
57
  static getMermaidGraph(steps) {
58
58
  const graphLines = ["graph TD"];
59
- const sanitize = (name) => this.sanitizeMermaidId(name);
59
+ const idMap = new Map();
60
+ const usedIds = new Set();
61
+ const baseIdCounters = new Map();
62
+ const getUniqueId = (name) => {
63
+ if (idMap.has(name)) {
64
+ return idMap.get(name);
65
+ }
66
+ const sanitized = this.sanitizeMermaidId(name);
67
+ let uniqueId = sanitized;
68
+ // First check if the base sanitized ID is available
69
+ if (!usedIds.has(uniqueId)) {
70
+ usedIds.add(uniqueId);
71
+ idMap.set(name, uniqueId);
72
+ return uniqueId;
73
+ }
74
+ // If not, use the counter for this base ID
75
+ let counter = baseIdCounters.get(sanitized) || 1;
76
+ while (usedIds.has(uniqueId)) {
77
+ uniqueId = `${sanitized}_${counter}`;
78
+ counter++;
79
+ }
80
+ baseIdCounters.set(sanitized, counter);
81
+ usedIds.add(uniqueId);
82
+ idMap.set(name, uniqueId);
83
+ return uniqueId;
84
+ };
85
+ // Pre-calculate IDs for all steps to ensure stable generation order
86
+ // We sort steps by name to ensure deterministic ID generation regardless of input order if names clash
87
+ // But input order is usually significant in graph definition, so we'll stick to input order.
88
+ // However, we must process all step NAMES first.
89
+ for (const step of steps) {
90
+ getUniqueId(step.name);
91
+ }
60
92
  for (const step of steps) {
61
- graphLines.push(` ${sanitize(step.name)}[${JSON.stringify(step.name)}]`);
93
+ const stepId = getUniqueId(step.name);
94
+ graphLines.push(` ${stepId}[${JSON.stringify(step.name)}]`);
62
95
  }
63
96
  for (const step of steps) {
64
97
  if (step.dependencies) {
98
+ const stepId = getUniqueId(step.name);
65
99
  for (const dep of step.dependencies) {
66
- graphLines.push(` ${sanitize(dep)} --> ${sanitize(step.name)}`);
100
+ const depId = getUniqueId(dep);
101
+ graphLines.push(` ${depId} --> ${stepId}`);
67
102
  }
68
103
  }
69
104
  }
@@ -114,37 +149,15 @@ export class TaskRunner {
114
149
  * Executes tasks with a timeout, ensuring resources are cleaned up.
115
150
  */
116
151
  async executeWithTimeout(executor, steps, timeout, signal) {
117
- const controller = new AbortController();
118
- const timeoutId = setTimeout(() => {
119
- controller.abort(new Error(`Workflow timed out after ${timeout}ms`));
120
- }, timeout);
121
- let effectiveSignal = controller.signal;
122
- let onAbort;
123
- // Handle combination of signals if user provided one
124
- if (signal) {
125
- if (signal.aborted) {
126
- // If already aborted, use it directly (WorkflowExecutor handles early abort)
127
- // We can cancel timeout immediately
128
- clearTimeout(timeoutId);
129
- effectiveSignal = signal;
130
- }
131
- else {
132
- // Listen to user signal to abort our controller
133
- onAbort = () => {
134
- controller.abort(signal.reason);
135
- };
136
- signal.addEventListener("abort", onAbort);
137
- }
138
- }
139
- try {
140
- return await executor.execute(steps, effectiveSignal);
141
- }
142
- finally {
143
- clearTimeout(timeoutId);
144
- if (signal && onAbort) {
145
- signal.removeEventListener("abort", onAbort);
146
- }
147
- }
152
+ // Create a timeout signal that aborts after the specified time
153
+ const timeoutSignal = AbortSignal.timeout(timeout);
154
+ // If there's a user-provided signal, combine them.
155
+ // Otherwise, use the timeout signal directly.
156
+ const effectiveSignal = signal
157
+ ? AbortSignal.any([signal, timeoutSignal])
158
+ : timeoutSignal;
159
+ return executor.execute(steps, effectiveSignal);
160
+ // No explicit clean up needed for AbortSignal.timeout as it is handled by the platform
148
161
  }
149
162
  }
150
163
  //# sourceMappingURL=TaskRunner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TaskRunner.js","sourceRoot":"","sources":["../src/TaskRunner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAM7D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAKlF;;;;GAIG;AACH,MAAM,OAAO,UAAU;IASD;IARZ,QAAQ,GAAG,IAAI,QAAQ,EAAY,CAAC;IACpC,SAAS,GAAG,IAAI,kBAAkB,EAAE,CAAC;IACrC,iBAAiB,GACvB,IAAI,yBAAyB,CAAC,IAAI,yBAAyB,EAAE,CAAC,CAAC;IAEjE;;OAEG;IACH,YAAoB,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;IAEzC;;;;OAIG;IACI,EAAE,CACP,KAAQ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YAC5B,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;YAC1C,CAAC,CAAC,aAAa,CAAC;QAElB,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;QAChD,uFAAuF;IACzF,CAAC;CACF"}
@@ -10,6 +10,9 @@ export declare class TaskStateManager<TContext> {
10
10
  private results;
11
11
  private pendingSteps;
12
12
  private running;
13
+ private dependencyGraph;
14
+ private dependencyCounts;
15
+ private readyQueue;
13
16
  constructor(eventBus: EventBus<TContext>);
14
17
  /**
15
18
  * Initializes the state with the given steps.
@@ -17,8 +20,8 @@ export declare class TaskStateManager<TContext> {
17
20
  */
18
21
  initialize(steps: TaskStep<TContext>[]): void;
19
22
  /**
20
- * Processes the pending steps to identify tasks that can be started or must be skipped.
21
- * Emits `taskSkipped` for skipped tasks.
23
+ * Processes the pending steps to identify tasks that can be started.
24
+ * Emits `taskSkipped` for skipped tasks (handled during cascade).
22
25
  * @returns An array of tasks that are ready to run.
23
26
  */
24
27
  processDependencies(): TaskStep<TContext>[];
@@ -34,6 +37,17 @@ export declare class TaskStateManager<TContext> {
34
37
  * @param result The result of the task.
35
38
  */
36
39
  markCompleted(step: TaskStep<TContext>, result: TaskResult): void;
40
+ /**
41
+ * Marks a task as skipped and emits `taskSkipped`.
42
+ * @param step The task that was skipped.
43
+ * @param result The result object (status: skipped).
44
+ */
45
+ markSkipped(step: TaskStep<TContext>, result: TaskResult): void;
46
+ /**
47
+ * Internal method to mark skipped without triggering cascade (to be used inside cascade loop).
48
+ * Returns true if the task was actually marked skipped (was not already finished).
49
+ */
50
+ private internalMarkSkipped;
37
51
  /**
38
52
  * Cancels all pending tasks that haven't started yet.
39
53
  * @param message The cancellation message.
@@ -52,9 +66,11 @@ export declare class TaskStateManager<TContext> {
52
66
  */
53
67
  hasPendingTasks(): boolean;
54
68
  /**
55
- * Marks a task as skipped and emits `taskSkipped`.
56
- * @param step The task that was skipped.
57
- * @param result The result object (status: skipped).
69
+ * Handles successful completion of a task by updating dependents.
58
70
  */
59
- markSkipped(step: TaskStep<TContext>, result: TaskResult): void;
71
+ private handleSuccess;
72
+ /**
73
+ * Cascades failure/skipping to dependents.
74
+ */
75
+ private cascadeFailure;
60
76
  }