
    4Rj                        U d Z ddlmZ ddlZddlZddlmZmZ g dZej                  efZ
ded<    eh d	      Zd
dddZddZddZy)a  Shared backoff / jitter / retry-classification helpers for the runner helpers.

Extracted so the control-plane poller, the session tool runner, and the worker
heartbeat all compute backoff and classify retryable failures the same way.
Consumed by the runner helpers only.
    )annotationsN   )APIErrorAPIStatusError)backoffjitteris_fatal_status_errorTRANSIENT_ERRORSztuple[type[Exception], ...]r
   >         g       @)basec                    t        ||| z        S )zCExponential backoff for ``attempt`` (1-indexed), capped at ``cap``.)min)attemptcapr   s      \/var/www/html/meridian/meridian-ai/venv/lib/python3.12/site-packages/anthropic/lib/_retry.pyr   r       s    sD'M""    c                .    t        j                  | |      S )uE   Uniform random delay in ``[low, high)`` — spreads out retry storms.)randomuniform)lowhighs     r   r   r   %   s    >>#t$$r   c                    t        | t              xr. d| j                  cxk  xr dk  nc xr | j                  t        vS )zTrue for a 4xx that retrying will not fix (bad key, missing resource).

    Aligns with the core client's ``_should_retry`` policy: 408 / 409 / 429 are
    transient and worth retrying; every other 4xx is fatal.
    i  i  )
isinstancer   status_code_RETRYABLE_4XX)errs    r   r	   r	   *   s6     c>*uscoo/K/KuPSP_P_guPuur   )r   intr   floatr   r    returnr    )r   r    r   r    r!   r    )r   	Exceptionr!   bool)__doc__
__future__r   r   httpx_exceptionsr   r   __all__	HTTPErrorr
   __annotations__	frozensetr   r   r   r	    r   r   <module>r-      sU    #   2
L 27(0K - K
 ?+ 8; #
%
vr   