Feature: Retry Service Patterns Coverage
  Scenarios targeting specific uncovered lines in retry_service_patterns.py
  to improve code coverage beyond the current 94.3%.

  # --- _is_async_callable edge cases (lines 82, 85, 86, 90) ---

  Scenario: _is_async_callable detects partial wrapping an async callable object
    Given I have a functools.partial wrapping a callable object with async __call__
    When I check if the partial wrapping async callable is async
    Then the async callable partial result should be True

  Scenario: _is_async_callable returns False for partial wrapping a class type
    Given I have a functools.partial wrapping a class type
    When I check if the partial-wrapped type is async callable
    Then rspcov the result should be False for partial type detection

  Scenario: _is_async_callable returns False for a non-callable non-partial value
    Given I have a plain integer value
    When I check if the integer is async callable
    Then rspcov the result should be False for the non-callable value

  # --- retry_service_operation async: CircuitBreakerOpen with no breaker (line 254) ---

  Scenario: Async retry service operation logs circuit open with no circuit breaker
    Given I have an async function decorated with retry_service_operation and no circuit breaker
    And the async function raises CircuitBreakerOpen
    When I call the decorated async service operation
    Then CircuitBreakerOpen should propagate with failure count zero

  # --- RetryContext.execute rejects async callables (lines 444-446) ---

  Scenario: RetryContext.execute raises TypeError for async callables
    Given I have a RetryContext for operation "async-reject-test"
    And I have an async callable to pass to sync execute
    When I call execute with the async callable
    Then a TypeError should be raised indicating async_execute is needed

  # --- RetryContext.execute nesting guard (lines 452-453) ---

  Scenario: RetryContext.execute skips retry at max nesting depth
    Given I have a RetryContext for operation "nesting-sync-test"
    And the retry depth is already at maximum
    When I call execute at max nesting depth with a sync function
    Then the function should execute once without retry wrapping
    And the attempt count should be 1

  # --- RetryContext.async_execute nesting guard (lines 507-508) ---

  Scenario: RetryContext.async_execute skips retry at max nesting depth
    Given I have a RetryContext for operation "nesting-async-test"
    And the retry depth is already at maximum for async
    When I call async_execute at max nesting depth
    Then the async function should execute once without retry wrapping
    And the async attempt count should be 1

  # --- RetryContext.execute RuntimeError safeguard (line 482) ---

  Scenario: RetryContext.execute raises RuntimeError when Retrying yields no iterations
    Given I have a RetryContext for operation "empty-retrying-test"
    And Retrying is patched to yield zero iterations
    When I call execute expecting a RuntimeError from empty retrying
    Then a RuntimeError about Retrying executing at least once should be raised

  # --- RetryContext.async_execute RuntimeError safeguard (line 537) ---

  Scenario: RetryContext.async_execute raises RuntimeError when AsyncRetrying yields no iterations
    Given I have a RetryContext for operation "empty-async-retrying-test"
    And AsyncRetrying is patched to yield zero async iterations
    When I call async_execute expecting a RuntimeError from empty async retrying
    Then a RuntimeError about AsyncRetrying executing at least once should be raised

  # --- retry_auto_debug rejects sync callables (lines 575-577) ---

  Scenario: retry_auto_debug raises TypeError for sync callables
    Given I have a synchronous function decorated with retry_auto_debug
    When I invoke the retry_auto_debug wrapper for the sync function
    Then a TypeError about async callables should be raised

  # --- retry_auto_debug returns None with zero attempts (line 639) ---

  Scenario: retry_auto_debug returns None when max_debug_attempts is zero
    Given I have an async function decorated with retry_auto_debug with zero attempts
    When I invoke the retry_auto_debug wrapper with zero attempts
    Then rspcov the result should be None from exhausted attempts
