Module recovery

Source
Expand description

Recovery logic for handling failed or stuck operations.

This module provides pure functions for determining and executing recovery actions when vault operations fail or get stuck in unexpected states.

§Recovery Actions

  • KernelAction::AbortAllocating: Cancel an allocation operation and return to Idle
  • KernelAction::AbortWithdrawing: Cancel a withdrawal operation and refund escrow
  • KernelAction::AbortRefreshing: Cancel a refresh operation and return to Idle
  • KernelAction::SettlePayout: Complete a payout operation (success or failure path)

§Design Principles

  1. Recovery is deterministic based on state and provided timing context
  2. All recovery paths ensure escrow shares are properly handled
  3. Recovery should be safe to retry

Structs§

RecoveryContext
Context for determining recovery actions.
RecoveryOutcome
Outcome of a recovery operation.
RecoveryProgress
Progress timestamps for an in-flight operation.
RecoveryStats
Compute recovery statistics from the current state.

Functions§

compute_payout_failure_outcome
Compute a failure payout outcome from escrow shares and idle restore amount.
compute_payout_success_outcome
Compute a success payout outcome from escrow and collected amounts.
compute_recovery_stats
Compute recovery statistics from the current state.
compute_settlement_shares
Compute the shares to burn and refund based on collected vs expected amounts.
determine_recovery_action
Determine the appropriate recovery action for the current state.
handle_allocation_failure
Handle a failed allocation operation.
handle_payout_failure
Handle a failed payout operation.
handle_payout_failure_default
Handle a failed payout operation using the payout amount as the idle restore value.
handle_refresh_failure
Handle a failed refresh operation.
handle_withdrawal_failure
Handle a failed withdrawal operation.