+
    2jx                        R t ^ RIHt ^ RIHtHt ^RIHt ^RIH	t	 ^RI
HtHtHtHt ]'       d   ^RIHt . ROtR R ltR	 R
 ltR R ltR R ltR R ltR R ltR# )a
  Decision making for the PubGrub resolver.

Picks the next undecided package, asks the provider for a version,
and records ``NO_VERSIONS`` clauses or constraint clauses as needed.

Reference: https://github.com/dart-lang/pub/blob/master/doc/solver.md#decision-making
)annotations)TYPE_CHECKINGAny)add_incompatibility)ROOT)IncompatibilityIncompatibilityCauseRangeProtocolTerm)Resolverc                    V ^8  d   QhRRRR/# )   resolverResolver[Any, Any]return
Any | None )formats   "^/home/user/billing-ledger-validation/.venv/lib/python3.14/site-packages/nab_resolver/decide.py__annotate__r      s     )( )('9 )(j )(    c           	     0  aaaaaaa	a
 V P                   P                  4       pVP                  \        4       V'       g   R# V P                  P                  4        V P                  P                  oV P                  P                  oV P                   P                  oV P                  P                  4       oV P                  P                  oV P                  P                  oV P                  o
V P                  o	R VVVVVVV	V
3R llp\!        WR7      # )a  Choose the next undecided package, or None if all decided.

Prefers ``is_ready`` packages so resolution keeps making progress while
other listings/metadata are still in flight.  ``begin_decision_scan`` marks
the start of the scan so a provider fed by another thread can hold the
state behind its sort key still: ``min`` only picks correctly over a key
that does not move while it runs.
Nc                    V ^8  d   QhRRRR/# )r   packager   r   ztuple[Any, ...]r   )r   s   "r   r   .choose_package_to_decide.<locals>.__annotate__6   s     3 3# 3/ 3r   c                   < S	! T S! V 4      ;'       g    SSS4      pS! V 4      '       d   ^ M^pSP                  V 4      pVf)   S
P                  V 4      pVf   ^^ \        V 4      3pVSV &   W!V3# )    )getstr)r   priorityready_penaltytiebreak	any_rangeconflict_countsculprit_counts	get_rangeis_ready
prioritize
root_ordertiebreak_caches   &   r   sort_key*choose_package_to_decide.<locals>.sort_key6   s    g++)	
 &g..A!%%g.!~~g.Hq#g,/&.N7#22r   )key)solutionundecided_packagesdiscardr   providerbegin_decision_scanstatspackage_conflict_countspackage_culprit_countsr   
range_typefullr'   r&   r)   root_package_ordermin)r   	undecidedr*   r"   r#   r$   r%   r&   r'   r(   r)   s   &  @@@@@@@@r   choose_package_to_decider:      s     !!446Id))+nn<<O^^::N!!%%I##((*I""--J  ))H,,N,,J3 3  y''r   c               $    V ^8  d   QhRRRRRR/# )r   r   r   r   r   r   r   r   )r   s   "r   r   r   I   s'     D D/ D# D* Dr   c                   V P                   P                  V4      ;'       g    V P                  P                  4       pV P                  P                  V4      pVe	   W#,          pV P
                  P                  V P                   P                  4       V P                   P                  4       4       V P
                  P                  W4      # )zAsk the provider to pick a version within the allowed range.

A user constraint narrows the acceptable range here rather than acting
as an incompatibility: it restricts which version is picked but never
forces the package into the solution.
)
r-   r   r5   r6   constraintsr0   receive_partial_solution_hintpositive_ranges	decisionschoose_version)r   r   current_range
constraints   &&  r   rA   rA   I   s     %%))'2PPh6I6I6N6N6PM%%))'2J%233))+##% ++GCCr   c                    V ^8  d   QhRRRR/# )r   r   r   r   boolr   )r   s   "r   r   r   [   s      %7 D r   c                    \        V P                  P                  4       4      pV F  p\        W4       K  	  \	        V4      # )a#  Drain provider-queued incompatibilities into the formula.

Look-ahead providers push binary clauses like
``{candidate==v, blocking_decision==w}`` instead of relying on the
broader ``NO_VERSIONS`` clause.  Returns True so the caller can suppress
the default ``NO_VERSIONS`` clause this turn.
)listr0   consume_pending_clausesr   rE   )r   clausesincompatibilitys   &  r   absorb_pending_clausesrK   [   s9     8$$<<>?G"H6 #=r   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r   r   r   r   r   requirementRangeProtocol[Any]causezIncompatibility[Any, Any]r   Noner   )r   s   "r   r   r   i   sA     M M MM $M %	M
 
Mr   c                X   V P                   P                  V4      pVf   R# WB,          pWT8w  d{   VP                  V4      '       db   V P                   P                  WRVR7       V P                  ;P
                  ^,          un        V P                  P                  VRVR7       R# R# R# )a  Derive a requirement that refines a package's range without narrowing it.

Unit propagation acts only on requirements that narrow a package's version
set. When a version-set-redundant requirement still yields a different
range, that difference is a refinement the range type carries (such as a
pre-release opt-in), so derive it onto the package. The derivation rides the
parent decision level, is undone on backtracking, and leaves every term
relation unchanged, so nothing re-propagates.
NT)positiverO   )r-   positive_range	is_subsetderiver2   derivationsobserveron_derivation)r   r   rM   rO   rR   foldeds   &&&&  r   absorb_redundant_requirementrZ   i   s       //8H #Fh00==  E R""a'"''$e'L >r   c               (    V ^8  d   QhRRRRRRRR/# )	r   r   r   r   r   rB   rN   r   rE   r   )r   s   "r   r   r      s2     L L L+.L?QL	Lr   c                8    V P                   P                  W4      # )a  Return whether a user constraint is why ``choose_version`` found nothing.

``choose_version`` already returned None over the constraint-narrowed range.
Ask whether the un-narrowed ``current_range`` would still yield a version: a
hit means the constraint clipped away what would otherwise have been chosen,
so the constraint is the cause; a miss means the package fails on its own (no
versions, or none satisfy the requirement) and the constraint is irrelevant.
)r0   has_satisfying_version)r   r   rB   s   &&&r   _constraint_hid_a_versionr^      s     33GKKr   c               (    V ^8  d   QhRRRRRRRR/# )	r   r   r   r   r   had_pendingrE   r   rP   r   )r   s   "r   r   r      s,     ! ! !+.!@D!	!r   c                  V'       d   R# V P                   P                  V4      ;'       g    V P                  P                  4       pV P                  P                  W4       V P                  P                  V4      pVRJ;'       d    \        WV4      pV'       d   \        P                  pTpM\        P                  pRp\        V \        \        WRR7      .VVR7      4       R# )zAdd the default ``NO_VERSIONS`` clause for ``package``.

Skipped when the provider already supplied context-aware clauses;
otherwise the broad clause would persist past the backjump that lifts
the supporting decisions.
NT)rR   )rO   constraint_range)r-   r   r5   r6   rW   on_no_versionsr=   r^   r   
CONSTRAINTNO_VERSIONSr   r   r
   )r   r   r`   rB   rC   constrainedrO   rb   s   &&$     r   record_no_versionsrg      s     %%))'2PPh6I6I6N6N6PM$$W<%%))'2JD(  -F=.K $//%$00'489-	
r   N)rK   rZ   r:   rA   rg   )__doc__
__future__r   typingr   r   incompat_indexr   rootr   typesr   r   r	   r
   r   r   __all__r:   rA   rK   rZ   r^   rg   r   r   r   <module>ro      sM    # % /  M M")(XD$M8L!r   