+
    2j                        R t ^ RIHt ^ RIHt ^ RIHt ^RIHt ]'       d   ^ RI	H
t
 ^ RIHt ^RIHt ^RIHt ^t^t^ t^t^tR	tR
R/R R lltR R ltR R ltRR R lltR# )a@  Priority computation for :class:`nab_python.provider.Provider`.

Owns the tier/matching/culprit logic that backs ``prioritize``.
Affected packages with high conflict counts get tier 0 (decide
first inside a conflict cluster); runaway top culprits get tier 2
(uv's deprioritise-on-conflict); everything else gets tier 1.
)annotations)
itemgetter)TYPE_CHECKING)VersionRange)Mapping)RangeProtocol)Version)Provideri  force_backtrackedFc               0    V ^8  d   QhRRRRRRRRRR	R
R/# )   
normalizedstraffected_countintculprit_countculprit_countsMapping[str, int] | Noner
   boolreturn )formats   "h/home/user/billing-ledger-validation/.venv/lib/python3.14/site-packages/nab_python/_provider/priority.py__annotate__r   )   sD        -	  	    c               |    V\         8  d   \        # V'       d   \        # \        WV4      '       d   \        # \        # )zDecide the priority tier from conflict and culprit counts.

``force_backtracked`` short-circuits the gap rule: the look-ahead
abort is a precise enough culprit signal on its own.
)CONFLICT_THRESHOLDTIER_AFFECTEDTIER_CULPRITis_dominant_culpritTIER_NORMAL)r   r   r   r   r
   s   &&&&$r   compute_tierr!   )   s5     ++:nEEr   c               (    V ^8  d   QhRRRRRRRR/# )	r   providerr	   r   r   version_rangeRangeProtocol[Version]r   r   r   )r   s   "r   r   r   ?   s6     C CCC *C 		Cr   c           
     R   V P                   P                  V4      pVe   VP                  V4      pVe   V# WP                  9   ;'       g%    WP                  9   ;'       g    WP                  9   pWP
                  9  d   V'       g   V P                  '       d   V P                  V4      MV P                  V4      pVeT   V P                  W4      pWpP
                  V&   V P                  ;P                  ^,          un        V P                  W4       WP
                  9   d[   \        V\        4      '       g   Q hV P
                  V,          p\        R VP!                  VR\#        ^ 4      RR7       4       4      pMV'       d   ^pM\$        # Vf   / ;q0P                   V&   WV&   V# )a@  Return the count of cached versions of ``normalized`` in ``version_range``.

Also fires speculative metadata prefetch when this is the first time we
notice the listing has arrived in the coordinator index.  Returns
:data:`_NO_LISTING_PRIOR` while the listing is still in flight, reading
arrival through ``arrived_listing`` so it agrees with ``is_ready`` for the
whole decision scan.

Under :attr:`~nab_python.provider.DecisionOrder.STABLE` it waits for the
listing instead, so the count is the real one and this sentinel is only
reached by a package with no listing to count.
c              3  &   "   T F  p^x  K	  	  R# 5i)   Nr   ).0_s   & r   	<genexpr>#compute_matching.<locals>.<genexpr>o   s      
 s   T
descending)prereleaseskeyassume_sorted)matching_cachegetlocal_sourcesvcs_sourcesarchive_sourcesversions_cachesettle_listingssettled_listingarrived_listingfilter_distributionsstatslistings_fetchedspeculative_prefetch
isinstancer   sumfilterr   _NO_LISTING_PRIOR)	r#   r   r$   per_pkgcachedhas_local_sourcefilesversionsmatchings	   &&&      r   compute_matchingrH   ?   s   " %%))*5G]+M
 	,,, 	2 	2---	2 	2111 
 0009I ''' $$Z0))*5 	
 44ZGH2:##J/NN++q0+))*?,,,-6666**:6  
")) qM*	 * 
 
 
 ! 8::))*5%MOr   c               (    V ^8  d   QhRRRRRRRR/# )	r   packager   package_countr   r   r   r   r   r   )r   s   "r   r   r      s6     F FFF -F 
	Fr   c                   a  Ve   V\         8  d   R# \        V 3R lVP                  4        4       ^ R7      pW,
          \         8  # )zReturn True when ``package`` is the runaway top culprit.

Demote only when the gap to the next culprit is >= CULPRIT_DEMOTE_THRESHOLD;
co-dominant culprits stay within ~1 of each other so the standard ordering
wins.
Fc              3  >   <"   T F  w  rVS8w  g   K  Vx  K  	  R # 5iNr   )r)   othercountrJ   s   &  r   r+   &is_dominant_culprit.<locals>.<genexpr>   s     N#9<5Ug=M#9s   
)default)CULPRIT_DEMOTE_THRESHOLDmaxitems)rJ   rK   r   second_highests   f&& r   r   r      sE     1I!IN>#7#7#9NN )-EEEr   Nc               0    V ^8  d   QhRRRRRRRRR	R
RR/# )r   r#   r	   rJ   r   r$   r%   conflict_countszMapping[str, int]r   r   r   ztuple[int, int, bool]r   )r   s   "r   r   r      sD     4 444 *4 '	4
 -4 4r   c                L   V P                   ;P                  ^,          un        V P                  V4      w  rVpVP                  V^ 4      pVe   VP                  V^ 4      M^ p	V P	                  V4      ^ 8  p
V	\
        8  ;'       d    V
'       * pV'       dD   V P                  P                  V4      pVe%   V^ ,          VJ d   V^,          V8X  d
   V^,          # \        VVV	VV
R7      p\        WV4      pWVRJ 3pV'       d"   WpP                  9   d   W(V3V P                  V&   V# )a  Prioritize packages for resolution order.

Returns ``(tier, matching_count, is_base)``.  Extras proxies sort before
their base at equal tier so they pin the base version directly (avoids
the backtrack storm when the base is decided before the extras proxy).

Blocks on I/O only under
:attr:`~nab_python.provider.DecisionOrder.STABLE`, which waits for a
listing rather than ranking its absence.
N)r
   )
r;   prioritize_callssplit_and_normalizer2   force_backtrack_countrS   priority_cacher!   rH   r6   )r#   rJ   r$   rX   r   r*   extrar   r   r   r
   	cacheablerC   tierrG   prioritys   &&&&&           r   
prioritizerb      s-   " NN##q(##77@Aj$((Q7N-;-G:q)Q  !66zBQF
  88RRAR=RI((,,W5q	]*q	^+!9+D  mDH.H Z#:#::,98+T(Or   rN   )__doc__
__future__r   operatorr   typingr   _vendor.packaging.rangesr   collections.abcr   nab_resolver.typesr   _vendor.packaging.versionr   r#   r	   r   rS   r   r    r   rA   r!   rH   r   rb   r   r   r   <module>rk      sv    #    3'03#        $,CLF(4 4r   