Skip to content

Extract shared task-graph coordination base class from FlowExecution / TaskExecution#33

Merged
adelrodriguez merged 1 commit intomainfrom
03-07-extract_shared_task-graph_coordination_base_class_from_flowexecution___taskexecution_
Mar 7, 2026
Merged

Extract shared task-graph coordination base class from FlowExecution / TaskExecution#33
adelrodriguez merged 1 commit intomainfrom
03-07-extract_shared_task-graph_coordination_base_class_from_flowexecution___taskexecution_

Conversation

@adelrodriguez
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown
Owner Author

adelrodriguez commented Mar 7, 2026

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 7, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

This pull request refactors the executor architecture by introducing TaskGraphExecutionBase, an abstract base class that centralizes common orchestration logic including task mapping, result/error tracking, resolvers, cancellation, and disposers. TaskExecution and FlowExecution are refactored to extend this base class, removing duplicated logic. Error handling is enhanced to normalize non-Error failures to UnhandledException with proper cause mapping. The executeTasks function in all.ts is reworked with staged error handling and explicit catch path coordination. A planning documentation file is removed, and comprehensive tests are added covering new error handling semantics, settlement behavior, and disposer cleanup ordering.

Possibly related PRs

  • PR #22: Modifies the same core executor files (shared.ts, flow.ts) with changes to error handling and task execution semantics.
  • PR #24: Refactors the same executor core with overlapping code-level changes to task execution and lifecycle wiring across shared.ts, flow.ts, and all.ts.
  • PR #18: Implements the executor base-class refactor design (TaskGraphExecutionBase and TaskExecution structure) that directly aligns with the architectural changes introduced here.
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to evaluate whether a description exists and is related to the changeset. Add a pull request description explaining the motivation, implementation approach, and benefits of extracting the shared base class.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Extract shared task-graph coordination base class from FlowExecution / TaskExecution' accurately describes the main refactoring: extracting a new TaskGraphExecutionBase class from existing implementations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 03-07-extract_shared_task-graph_coordination_base_class_from_flowexecution___taskexecution_

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@adelrodriguez adelrodriguez marked this pull request as ready for review March 7, 2026 18:40
Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/lib/executors/shared.ts (1)

72-200: Let TypeScript infer these internal helper return types.

Most of these new protected helpers are implementation details, so the added : void, : boolean, : Error, and : Promise<unknown> annotations add maintenance noise without strengthening the public surface.

As per coding guidelines, **/*.{ts,tsx}: Prefer type inference whenever possible in TypeScript. Do not add explicit return types unless required by tooling, declaration emit, or a public API contract. Do not use explicit return types when inference already produces the correct result.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/executors/shared.ts` around lines 72 - 200, Remove redundant explicit
return-type annotations on internal helper methods so TypeScript can infer them:
drop the explicit return types for getTaskHandler (keep param types),
createResultProxy, waitForResult, storeResult, storeError, resolveWaiters,
rejectWaiters, abortInternal, onTaskResult, onTaskError, mapStoredError,
shouldAbortOnTaskError, and shouldRethrowTaskError; leave public/abstract API
signatures that need a declared type (e.g., createTaskContext) intact. Ensure
only implementation-internal helpers lose the ": void", ": boolean", ": Error",
and ": Promise<unknown>" annotations referenced above.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/lib/executors/flow.ts`:
- Around line 18-29: The execute() method starts all tasks but uses await
Promise.allSettled(promises) which prevents returning early on a FlowExitSignal;
change execute() to short-circuit when this.firstRejection is set (especially if
it's a FlowExitSignal) by racing the full-settle promise against a
"firstRejection" notifier: create a promise (or helper like
waitForFirstRejection) that resolves as soon as this.firstRejection is assigned
and then use Promise.race([Promise.allSettled(promises),
waitForFirstRejection()]); after the race, if this.firstRejection is a
FlowExitSignal return its value (as FlowResult<T>) otherwise throw the rejection
— reference execute(), this.firstRejection, FlowExitSignal, runTask(), and
Promise.allSettled() in the change.

In `@src/lib/executors/shared.ts`:
- Around line 136-138: storeError currently stores the raw unknown and calls
rejectWaiters with that value, causing inconsistent rejections vs waitForResult;
change storeError to normalize the error first by calling
this.mapStoredError(error), then this.errors.set(taskName, mappedError) and
this.rejectWaiters(taskName, mappedError). Apply the same change to the other
place in the file where an error is set and waiters are rejected (the second
occurrence that mirrors storeError).
- Around line 249-261: The execute() path currently always awaits
Promise.allSettled(promises), which prevents fail-fast behavior and can lead to
throwing undefined; change the logic so that when this.#mode !== "settled"
(i.e., fail-fast) you await Promise.all(promises) to let the first rejection
propagate immediately, while keeping Promise.allSettled(promises) for the
settled path; additionally, when checking this.firstRejection ensure you never
throw undefined by throwing this.firstRejection ?? new Error("Task failed")
(refer to execute, this.#mode, this.runTask, this.firstRejection, and
this.#returnValue).

---

Nitpick comments:
In `@src/lib/executors/shared.ts`:
- Around line 72-200: Remove redundant explicit return-type annotations on
internal helper methods so TypeScript can infer them: drop the explicit return
types for getTaskHandler (keep param types), createResultProxy, waitForResult,
storeResult, storeError, resolveWaiters, rejectWaiters, abortInternal,
onTaskResult, onTaskError, mapStoredError, shouldAbortOnTaskError, and
shouldRethrowTaskError; leave public/abstract API signatures that need a
declared type (e.g., createTaskContext) intact. Ensure only
implementation-internal helpers lose the ": void", ": boolean", ": Error", and
": Promise<unknown>" annotations referenced above.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a9489db9-e67e-41fd-afac-4bc805140aaa

📥 Commits

Reviewing files that changed from the base of the PR and between 83a4624 and e6d9410.

📒 Files selected for processing (3)
  • .plans/01-pr-18-review-triage-checklist.md
  • src/lib/executors/flow.ts
  • src/lib/executors/shared.ts
💤 Files with no reviewable changes (1)
  • .plans/01-pr-18-review-triage-checklist.md

@adelrodriguez adelrodriguez force-pushed the 03-07-extract_shared_task-graph_coordination_base_class_from_flowexecution___taskexecution_ branch 2 times, most recently from 4835355 to 006edfb Compare March 7, 2026 19:02
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 006edfb3dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@adelrodriguez adelrodriguez force-pushed the 03-07-extract_shared_task-graph_coordination_base_class_from_flowexecution___taskexecution_ branch from 006edfb to 1b7c4ec Compare March 7, 2026 19:10
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/lib/executors/shared.ts (1)

255-270: Unnecessary async wrapper on line 256.

Since runTask is already an async method returning Promise<void>, the async (name) => wrapper is redundant and adds a slight overhead.

🔧 Suggested simplification
   async execute(): Promise<Record<string, unknown>> {
-    const promises = this.taskNames.map(async (name) => this.runTask(name))
+    const promises = this.taskNames.map((name) => this.runTask(name))

     if (this.#mode === "settled") {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/executors/shared.ts` around lines 255 - 270, The map callback in
execute() is using an unnecessary async wrapper (async (name) =>
this.runTask(name)); since runTask(name) already returns a Promise, replace the
wrapper with a direct call to runTask to avoid the extra microtask: e.g. create
promises with this.taskNames.map(name => this.runTask(name)) (or
this.taskNames.map(this.runTask.bind(this)) if you prefer passing the method
directly) so Promise.all/Promise.allSettled receive the original promises from
runTask.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/lib/executors/shared.ts`:
- Around line 255-270: The map callback in execute() is using an unnecessary
async wrapper (async (name) => this.runTask(name)); since runTask(name) already
returns a Promise, replace the wrapper with a direct call to runTask to avoid
the extra microtask: e.g. create promises with this.taskNames.map(name =>
this.runTask(name)) (or this.taskNames.map(this.runTask.bind(this)) if you
prefer passing the method directly) so Promise.all/Promise.allSettled receive
the original promises from runTask.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e94d24c9-7daa-45d3-a742-64ae4763f105

📥 Commits

Reviewing files that changed from the base of the PR and between e6d9410 and 1b7c4ec.

📒 Files selected for processing (8)
  • .plans/01-pr-18-review-triage-checklist.md
  • src/__tests__/index.test.ts
  • src/index.ts
  • src/lib/executors/__tests__/all.test.ts
  • src/lib/executors/__tests__/flow.test.ts
  • src/lib/executors/__tests__/shared.test.ts
  • src/lib/executors/flow.ts
  • src/lib/executors/shared.ts
💤 Files with no reviewable changes (2)
  • .plans/01-pr-18-review-triage-checklist.md
  • src/index.ts

@adelrodriguez adelrodriguez force-pushed the 03-07-extract_shared_task-graph_coordination_base_class_from_flowexecution___taskexecution_ branch from 1b7c4ec to f945f82 Compare March 7, 2026 19:16
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b7c4ecc69

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f945f82520

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@adelrodriguez adelrodriguez force-pushed the 03-07-extract_shared_task-graph_coordination_base_class_from_flowexecution___taskexecution_ branch from f945f82 to a90f927 Compare March 7, 2026 19:22
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a90f927ac9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@adelrodriguez adelrodriguez force-pushed the 03-07-extract_shared_task-graph_coordination_base_class_from_flowexecution___taskexecution_ branch from a90f927 to 088550a Compare March 7, 2026 19:32
Copy link
Copy Markdown
Owner Author

adelrodriguez commented Mar 7, 2026

Merge activity

  • Mar 7, 7:35 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 7, 7:35 PM UTC: @adelrodriguez merged this pull request with Graphite.

@adelrodriguez adelrodriguez merged commit f834842 into main Mar 7, 2026
6 of 7 checks passed
@adelrodriguez adelrodriguez deleted the 03-07-extract_shared_task-graph_coordination_base_class_from_flowexecution___taskexecution_ branch March 7, 2026 19:35
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 088550a82d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

} else if (catchFn) {
const context = {
failedTask: execution.failedTask,
partial: execution.returnValue as Partial<AllValue<T>>,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Snapshot partial results before invoking catch handler

ctx.partial now points at the live execution.returnValue object while sibling tasks are still running, so an async catch handler can observe different values depending on timing (e.g., ctx.partial.a is undefined before an await and populated after). This makes catch-mapping nondeterministic in fail-fast runs introduced by this refactor, because the handler no longer receives a stable failure-time view of partial results.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant