Skip to content

feat(core): align grouped business-error recovery - #100

Merged
medz merged 3 commits into
mainfrom
feat/grouped-business-recovery
Oct 28, 2026
Merged

medz merged 3 commits into
mainfrom
feat/grouped-business-recovery

Conversation

@medz

@medz medz commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Adding concurrent failures no longer disables an existing business-error fallback. Task and Flow recovery and retry now select the first business error when the complete cause contains no defect, including nullable errors and recorded cancellation. The fallback handles the whole eligible cause; active owner cancellation still follows the existing mask protocol.

final Task<String, String> load = Task.failCause(Cause.combine([
  const Cause.failure('offline'),
  const Cause.failure('replica unavailable'),
]));
final cached = load.recover((error) => Task.succeed('Cached: $error'));

Flow retires failed production through onExit before applying the same recovery rule. Cleanup defects preserve the complete original group, delivered values remain available, and replacement failures bypass the original handler. Selective timeout and configuration-default handlers preserve unmatched causes and their failure occurrences instead of treating the first business error as the whole failure. No new public APIs or compatibility paths are introduced.

Related issues

Closes #14

Validation

  • dart pub get
  • dart format --output=none --set-exit-if-changed .
  • dart analyze --fatal-infos
  • dart test — 1,365 tests passed

Coverage includes grouped and nullable errors, recorded versus active cancellation, mask restoration, complete cleanup causes, one-time fallback reports, independent failure occurrences, Flow retry and replacement boundaries, non-timeout groups, and configuration groups containing non-missing causes.

@medz medz added the enhancement New feature or request label Oct 28, 2026 — with ChatGPT Codex Connector

medz commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T19:03:35.099679Z 2b1feb3 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8d3cb209-4512-40ae-909d-4c151ebac2ca
Commits

Reviewing files that changed from the base of the PR and between 926c420 and 00b8de9.

Files selected for processing: 9
  • lib/src/core/flow.dart
  • lib/src/core/flow_timing.dart
  • lib/src/core/task.dart
  • test/core/fiber_failure_routing_test.dart
  • test/core/flow_retry_test.dart
  • test/core/flow_test.dart
  • test/core/task_mask_test.dart
  • test/core/task_test.dart
  • test/core/task_timing_test.dart

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Task and Flow recovery and retry now select the first business failure from causes that contain no defects. Recorded cancellations do not prevent selection. Tests cover grouped causes, cleanup defects, retry outcomes, and cancellation during recovery.

Changes: Failure recovery and retry

Layer / File(s) Summary
Task recovery selection
lib/src/core/task.dart, test/core/task_test.dart, test/core/task_mask_test.dart, test/core/fiber_failure_routing_test.dart
TaskOperations.recover selects the first business failure in an eligible cause, including a nullable error. Defects and causes without business failures bypass the handler. Tests cover replacement failures, cleanup, cancellation, and failure reporting.
Flow recovery lifecycle
lib/src/core/flow.dart, test/core/flow_test.dart
FlowOperations.recover finishes the failed source before opening its replacement. Tests cover preserving prior values and cause order, and skipping recovery when cleanup adds a defect.
Retry selection and scheduling
lib/src/core/task.dart, lib/src/core/flow_timing.dart, test/core/task_timing_test.dart, test/core/flow_retry_test.dart
Task and Flow retry use the selected business error for retry predicates. Defects and pure cancellation bypass retry. Tests cover predicate rejection, retries, and exhaustion.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant FlowOperations
  participant CurrentFlow
  participant TaskOperations
  participant ReplacementFlow
  FlowOperations->>CurrentFlow: finish failed pull with its exit
  FlowOperations->>TaskOperations: recover selected business failure
  TaskOperations->>ReplacementFlow: open replacement
Loading

Possibly related issues

  • odroe/any#28: The PR updates ordinary Flow recovery and retry to use the grouped business-failure selection rule.
  • odroe/any#16: The PR updates Task and Flow retry predicates to receive the selected business error.
Merge Risk: Minimal · up to 00b8d

No specific issue remains that needs resolution before merging.

Pre-merge checks: Passed 4
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: aligning grouped business-error recovery across core operations.
Linked Issues check Passed Issue #14 is directly linked and remains open. The Task change selects the first business failure from a defect-free grouped cause, including nullable errors and recorded cancellation. It bypasses def…
Out of Scope Changes check Passed The changes stay within issue #14. Source changes update Task recovery and retry, existing Flow recovery and retry, and related documentation. Tests validate the requested behavior. No implementation …
Full details: Linked Issues check

Explanation

Issue #14 is directly linked and remains open. The Task change selects the first business failure from a defect-free grouped cause, including nullable errors and recorded cancellation. It bypasses defects and pure cancellation. The Flow and Flow retry changes reuse this rule, finish failed production before recovery, retain delivered values, and preserve replacement boundaries. The added tests cover grouped errors, cleanup defects, cancellation, retry predicates, replacement failures, and one-time fallback behavior. The diff adds no public API.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #14. Source changes update Task recovery and retry, existing Flow recovery and retry, and related documentation. Tests validate the requested behavior. No implementation for separate Flow whole-cause operations in #28 or competing-task winner selection in #38 appears in the reviewed changes.

Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

medz commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

@codex review

Please review the current head, 00b8de94d5a1ea8180234c42dca18ac7bfc0d668. The follow-up only clarifies that cleanup defects prevent ordinary recovery; local formatting, analysis, and all 1,361 tests pass on this head.

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

Copy link
Copy Markdown

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: 00b8de94d5

ℹ️ 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".

Comment thread lib/src/core/task.dart Resolved

medz commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

@codex review

The timeoutOrElse finding and the same selective-recovery issue in Config defaults are fixed in 2b1feb3. Please review the current head, including preservation of unmatched cause groups and failure occurrences.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 2b1feb3b3f

ℹ️ 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".

@medz
medz merged commit ed49eb8 into main Oct 28, 2026
3 checks passed
@medz
medz deleted the feat/grouped-business-recovery branch October 28, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align Task and Flow recovery for grouped business errors

1 participant