Skip to content

Implement supervisor failure escalation#2

Merged
scrogson merged 1 commit into
mainfrom
feat/supervisor-failure-escalation
Feb 20, 2026
Merged

Implement supervisor failure escalation#2
scrogson merged 1 commit into
mainfrom
feat/supervisor-failure-escalation

Conversation

@scrogson
Copy link
Copy Markdown
Owner

Summary

When a supervisor exhausts its restart intensity (max_restarts within max_seconds), it now exits with an error reason that propagates up the supervision tree via links. This implements proper OTP-style failure escalation.

Changes

  • Add set_exit_reason/set_exit_reason_async to task-local context
  • ProcessScope::run now returns Option<ExitReason> for custom exit reasons
  • spawn_internal uses custom exit reason if set, otherwise Normal
  • Supervisor sets exit reason before returning on:
    • Initial child start failure
    • Max restart intensity reached
    • Received exit signal

Test plan

  • test_supervisor_exits_with_error_on_max_restarts - Verifies supervisor exits with error when restart limit hit
  • test_failure_escalation_to_parent_supervisor - Verifies child supervisor failure propagates to parent
  • test_transient_child_normal_exit_no_restart - Verifies transient children don't restart on normal exit
  • test_transient_child_abnormal_exit_restarts - Verifies transient children restart on abnormal exit
  • test_temporary_child_never_restarts - Verifies temporary children never restart

Closes #1

When a supervisor exhausts its restart intensity (max_restarts within
max_seconds), it now exits with an error reason that propagates up the
supervision tree via links.

Changes:
- Add set_exit_reason/set_exit_reason_async to task-local context
- ProcessScope::run now returns Option<ExitReason> for custom exit
- spawn_internal uses custom exit reason if set, otherwise Normal
- Supervisor sets exit reason before returning on:
  - Initial child start failure
  - Max restart intensity reached
  - Received exit signal

Tests added:
- test_supervisor_exits_with_error_on_max_restarts
- test_failure_escalation_to_parent_supervisor
- test_transient_child_normal_exit_no_restart
- test_transient_child_abnormal_exit_restarts
- test_temporary_child_never_restarts

Closes #1.
@scrogson scrogson force-pushed the feat/supervisor-failure-escalation branch from c765b5b to 062cc0a Compare January 23, 2026 16:53
@scrogson scrogson merged commit 8b7a8c5 into main Feb 20, 2026
4 checks passed
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.

Is there have any plan to implement Failure Escalation?

1 participant