+
    2ji                    ,   R t ^ RIHt ^ RIHt ^ RIHtHtHt ^ RI	H
t
Ht ^ RIHtHtHtHt ^RIHtHtHtHt ^RIHt ^RIHt ^R	IHt ^R
IHt ^RIHt ^RI H!t!H"t"H#t#H$t$H%t%H&t&H't'H(t(H)t) ]'       d   ^ RI*H+t+ . R"Ot,Rt-]
! RR7       ! R R]]$])3,          4      4       t. ! R R]]$])3,          4      t/ ! R R]]$])3,          4      t0]
 ! R R]]$,          4      4       t1 ! R R]]$])3,          4      t2R R lt3R R lt4 ! R  R]]$])3,          4      t5R!# )#a  PubGrub dependency resolver.

Implements unit propagation, conflict resolution with clause learning, and
non-chronological backjumping.  PubGrub was designed by Natalie Weizenbaum
for Dart's pub, adapting CDCL (conflict-driven clause learning) from SAT
solving to version resolution.

The phase functions live in :mod:`nab_resolver.propagate`,
:mod:`nab_resolver.conflict`, :mod:`nab_resolver.decide`, and
:mod:`nab_resolver.incompat_index`.  ``Resolver`` is a thin coordinator that
holds shared state and delegates to those modules.  State attributes are
named without leading underscores so the phase modules can read and mutate
them directly; the supported public API is ``__init__``, ``resolve``,
``solve``, and ``stats``.

Specification: https://github.com/dart-lang/pub/blob/master/doc/solver.md
Original blog post: https://nex3.medium.com/pubgrub-2fb6470504f
Rust implementation: https://github.com/pubgrub-rs/pubgrub
)annotations)defaultdict)CallableMappingSequence)	dataclassfield)TYPE_CHECKINGAnyGenericProtocol)conflictdecideincompat_index	propagate)ResolutionError)PartialSolution)Range)build_solution_data)ROOT)	IncompatibilityIncompatibilityCauseIncompatibilityStatePackageTypeRangeProtocolRootRequirementSetRelationTermVersionType)TypeIsBaseProviderResolverResolverObserverResolverProviderResolverStatsSolutioni@ T)frozenc                  :    ] tR t^Et$ RtR]R&   R]R&   R]R&   RtR	# )
r%   af  Pins and dependency relationships from a finished resolution.

``pins`` maps every transitively reachable package to its decided
version.  ``edges`` are distinct ``(parent, child)`` pairs in
breadth-first order from ``roots``.  Both endpoints of each edge are
keys of ``pins``.  ``roots`` are the packages the caller required
directly, in requirement order.
dict[PackageType, VersionType]pinsz+tuple[tuple[PackageType, PackageType], ...]edgesztuple[PackageType, ...]roots N)__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__r,       `/home/user/billing-ledger-validation/.venv/lib/python3.14/site-packages/nab_resolver/resolver.pyr%   r%   E   s     )(66""r4   c                      ] tR t^UtRtR R ltR R ltR R ltR R	 ltRR R ll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tR
# )r#   zInterface for supplying version and dependency information.

Modeled after pubgrub-rs v0.3+ ``DependencyProvider``:
https://docs.rs/pubgrub/latest/pubgrub/trait.DependencyProvider.html
c               $    V ^8  d   QhRRRRRR/# )   packager   version_rangeRangeProtocol[VersionType]returnzVersionType | Noner,   )formats   "r5   __annotate__ResolverProvider.__annotate__\   s$      "3M	r4   c                    R# )z9Pick a version for package within version_range, or None.Nr,   selfr9   r:   s   &&&r5   choose_versionResolverProvider.choose_version\        	r4   c               $    V ^8  d   QhRRRRRR/# )r8   r9   r   r:   r;   r<   boolr,   )r=   s   "r5   r>   r?   b   s$      "3M	r4   c                    R# )a  Return whether ``choose_version`` would pick a version in ``version_range``.

A diagnostic query with no lasting side effect: it is used to attribute a
``NO_VERSIONS`` failure to a user constraint only when the un-narrowed
range still offers a version the constraint clipped away.  Providers that
queue clauses or record state during ``choose_version`` must not let any
of that escape here.
Nr,   rA   s   &&&r5   has_satisfying_version'ResolverProvider.has_satisfying_versionb        	r4   c               $    V ^8  d   QhRRRRRR/# )r8   r9   r   versionr   r<   0Mapping[PackageType, RangeProtocol[VersionType]]r,   )r=   s   "r5   r>   r?   o   s$      "-8	9r4   c                    R# )zAReturn ``{dependency_package: required_range}`` for this version.Nr,   rB   r9   rM   s   &&&r5   get_dependencies!ResolverProvider.get_dependencieso   rE   r4   c                   V ^8  d   QhRR/# r8   r<   Noner,   )r=   s   "r5   r>   r?   u   s     	 	T 	r4   c                    R# )aZ  Announce the start of one decision scan.

``choose_package_to_decide`` builds every undecided package's sort key
from ``prioritize`` and ``is_ready``, so both must answer from state
that does not move until the next call.  Providers whose answers depend
on another thread freeze that state here; for providers with no such
state this is a no-op.
Nr,   rB   s   &r5   begin_decision_scan$ResolverProvider.begin_decision_scanu   s     	r4   Nc          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r8   r9   r   r:   r;   conflict_countszMapping[PackageType, int]culprit_countsz Mapping[PackageType, int] | Noner<   r
   r,   )r=   s   "r5   r>   r?      s<       2 3	
 9 
r4   c                    R# )a  Return a sort key for deciding which package to resolve next.

Lower values resolve first.  ``conflict_counts`` tracks how often a
decision on this package was discarded; ``culprit_counts`` tracks how
often this package was decided earlier and caused another's decision
to be discarded.
Nr,   )rB   r9   r:   r[   r\   s   &&&&&r5   
prioritizeResolverProvider.prioritize   s     	r4   c                    V ^8  d   QhRRRR/# r8   r9   r   r<   rG   r,   )r=   s   "r5   r>   r?      s        r4   c                    R# )zReturn True when the provider can answer cheaply for ``package``.

Lets the resolver prefer ready packages while async fetches are still
in flight.  Providers without an async layer should return True.
Nr,   rB   r9   s   &&r5   is_readyResolverProvider.is_ready   s     	r4   c               $    V ^8  d   QhRRRRRR/# r8   positive_rangesrN   	decisionsz!Mapping[PackageType, VersionType]r<   rU   r,   )r=   s   "r5   r>   r?      s(      I 5 
	r4   c                    R# )aa  Accept a snapshot of positive ranges and decisions.

Called before ``choose_version`` so providers can forward-check the
candidate's dependencies against accumulated constraints.
``decisions`` is the subset with concrete versions (not derivations);
decision-based reasoning is safer because decisions cannot be undone
in isolation.  Default is a no-op.
Nr,   rB   rh   ri   s   &&&r5   receive_partial_solution_hint.ResolverProvider.receive_partial_solution_hint   s     	r4   c                   V ^8  d   QhRR/# r8   r<   z/list[Incompatibility[PackageType, VersionType]]r,   )r=   s   "r5   r>   r?      s     
 
	8
r4   c                    R# )aR  Return incompatibilities the provider queued during ``choose_version``.

Drained after every ``choose_version`` call.  When non-empty AND
``choose_version`` returned None, the resolver suppresses the default
``NO_VERSIONS`` clause (which would persist across backjumps) so the
provider's context-aware clauses become the source of truth.
Nr,   rW   s   &r5   consume_pending_clauses(ResolverProvider.consume_pending_clauses   s     	r4   c                   V ^8  d   QhRR/# r8   r<   zlist[PackageType]r,   )r=   s   "r5   r>   r?      s      1B r4   c                    R# )ag  Return packages the provider wants force-backtracked.

Drained after every ``choose_version`` call. When non-empty,
the resolver bumps each package's culprit count past the
demote threshold, queues it, and fires
``apply_targeted_backtrack`` without waiting for the normal
conflict-count gate.

Providers without a force-backtrack signal return an empty list.
Nr,   rW   s   &r5   consume_force_backtrack_targets0ResolverProvider.consume_force_backtrack_targets   rK   r4   c               $    V ^8  d   QhRRRRRR/# )r8   r9   r   rM   r   r<   z!RangeProtocol[VersionType] | Noner,   )r=   s   "r5   r>   r?      s$      "-8	*r4   c                    R# )a  Return a widened stand-in for ``version`` in dependency clauses, or None.

Called at most once per decision, after ``get_dependencies``
returned a non-empty mapping for ``version``, so a provider may
answer from what that call cached.

Soundness contract: the returned range must contain ``version``, and
every version inside it that could ever be chosen for ``package`` in
this resolution must have exactly the dependencies being recorded
for ``version``; versions inside it that can never be selected are
harmless.  ``None`` keeps the exact singleton.  Widening merges
dependency clauses for adjacent rejected versions into contiguous
ranges instead of one hole per version, and lets a single clause
reject a whole run of same-dependency versions.
Nr,   rP   s   &&&r5   widen_decisionResolverProvider.widen_decision   s    $ 	r4   c               $    V ^8  d   QhRRRRRR/# r8   r9   r   
constraintr;   r<   r,   )r=   s   "r5   r>   r?      s$      "0J	#r4   c                    R# )aK  Map a possibly-widened ``constraint`` back onto known versions.

Applied at error-render time only; the derivation state is never
mutated.  The renderer narrows every originally-positive term, so
``package`` may be the virtual root sentinel or another package
outside the provider's namespace; return such constraints
unchanged, as providers that do not widen do for all input.

Soundness contract: the result must hold the same known versions as
``constraint``.  The renderer reports what a narrowing drops as a range
holding no version, so dropping one that exists states a falsehood.
Nr,   rB   r9   r~   s   &&&r5   narrow_for_display#ResolverProvider.narrow_for_display   s     	r4   r,   N)r-   r.   r/   r0   r1   rC   rI   rQ   rX   r^   rd   rl   rq   rv   rz   r   r3   r,   r4   r5   r#   r#   U   sC    	 
( r4   c                  b    ] tR t^tR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tR# )r    a  Defaults for the six provider methods a synchronous provider does not need.

Supplies ``begin_decision_scan``, ``is_ready``,
``receive_partial_solution_hint``, ``consume_pending_clauses``,
``consume_force_backtrack_targets`` and ``narrow_for_display``, the six
:class:`ResolverProvider` methods with nothing to do when there is no async
layer, no queued clauses and no widening.  A subclass still owes
``choose_version``, ``has_satisfying_version``, ``get_dependencies``,
``prioritize`` and ``widen_decision``.

Subclassing is optional; the resolver accepts anything that satisfies the
protocol.  Nothing re-exports this, so import it as
``from nab_resolver.resolver import BaseProvider``.
c                   V ^8  d   QhRR/# rT   r,   )r=   s   "r5   r>   BaseProvider.__annotate__   s     < <T <r4   c                    R# )z-Freeze nothing: no state moves between scans.Nr,   rW   s   &r5   rX    BaseProvider.begin_decision_scan       r4   c                    V ^8  d   QhRRRR/# ra   r,   )r=   s   "r5   r>   r      s        r4   c                    ?R# )zAReport every package ready, since answers do not wait on a fetch.Tr,   rc   s   &&r5   rd   BaseProvider.is_ready   s    r4   c               $    V ^8  d   QhRRRRRR/# rg   r,   )r=   s   "r5   r>   r      s(     ' 'I' 5' 
	'r4   c                
    ??R# )z:Drop the snapshot: nothing here forward-checks against it.Nr,   rk   s   &&&r5   rl   *BaseProvider.receive_partial_solution_hint   s	     Yr4   c                   V ^8  d   QhRR/# ro   r,   )r=   s   "r5   r>   r     s      	8r4   c                    . # )z2Return no clauses: ``choose_version`` queues none.r,   rW   s   &r5   rq   $BaseProvider.consume_pending_clauses  s	     	r4   c                   V ^8  d   QhRR/# rt   r,   )r=   s   "r5   r>   r     s      1B r4   c                    . # )z>Return no targets: there is no force-backtrack signal to give.r,   rW   s   &r5   rv   ,BaseProvider.consume_force_backtrack_targets  s    	r4   c               $    V ^8  d   QhRRRRRR/# r}   r,   )r=   s   "r5   r>   r     s$     	 	"	0J		#	r4   c                    ?V# )zReturn the constraint unchanged, as a provider that never widens does.

A subclass whose ``widen_decision`` widens overrides this as well, or
its error text carries widened ranges instead of known versions.
r,   r   s   &&&r5   r   BaseProvider.narrow_for_display  s     r4   r,   N)r-   r.   r/   r0   r1   rX   rd   rl   rq   rv   r   r3   r,   r4   r5   r    r       s*    <
'	 	r4   c                      ] tR tRt$ Rt^ tR]R&   ^ tR]R&   ^ tR]R&   ^ t	R]R&   ^ t
R]R&   ^ tR]R	&   ^ tR]R
&   ^ tR]R&   ]! R R7      tR]R&   ]! R R7      tR]R&   RtR# )r$   i  zRunning statistics for resolution observability.

Inspired by SAT solver statistics (MiniSat, CaDiCaL) which track
decisions, conflicts, propagations, and restarts as standard metrics.
See: https://minisat.se/MiniSat.html
introundsri   	conflictsderivations	backjumpsrestartstargeted_backtracksincompatibilities_learnedc                 	     \        \        4      # r   r   r   r,   r4   r5   <lambda>ResolverStats.<lambda>.  	    C 0r4   )default_factoryzdefaultdict[PackageType, int]package_conflict_countsc                 	     \        \        4      # r   r   r,   r4   r5   r   r   1  r   r4   package_culprit_countsr,   N)r-   r.   r/   r0   r1   r   r2   ri   r   r   r   r   r   r   r   r   r   r3   r,   r4   r5   r$   r$     s     FCOIsIsKIsHc  %&s&=B0>:  =B0=9 r4   c                  n    ] tR tRtR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 R ltRtR# )r"   i5  z.Override methods to observe resolution events.c               (    V ^8  d   QhRRRRRRRR/# )	r8   r9   r   rM   r   levelr   r<   rU   r,   )r=   s   "r5   r>   ResolverObserver.__annotate__8  s,     / /"/-8/AD/	/r4   c                    R# )z Handle a version decision event.Nr,   )rB   r9   rM   r   s   &&&&r5   on_decisionResolverObserver.on_decision8  r   r4   c               (    V ^8  d   QhRRRRRRRR/# )	r8   r9   r   positiverG   cause)Incompatibility[PackageType, VersionType]r<   rU   r,   )r=   s   "r5   r>   r   =  s2     9 99 	9
 99 
9r4   c                   R# )z*Handle a derivation from unit propagation.Nr,   )rB   r9   r   r   s   &&$$r5   on_derivationResolverObserver.on_derivation=  r   r4   c                    V ^8  d   QhRRRR/# r8   incompatibilityr   r<   rU   r,   )r=   s   "r5   r>   r   F  s     1 1H1	1r4   c                    R# )z"Handle a conflict detection event.Nr,   rB   r   s   &&r5   on_conflictResolverObserver.on_conflictF  r   r4   c                    V ^8  d   QhRRRR/# r   r,   )r=   s   "r5   r>   r   K  s     6 6H6	6r4   c                    R# )z'Handle a learned incompatibility event.Nr,   r   s   &&r5   
on_learnedResolverObserver.on_learnedK  r   r4   c               $    V ^8  d   QhRRRRRR/# )r8   
from_levelr   to_levelr<   rU   r,   )r=   s   "r5   r>   r   P  s!     ' 'c 'S 'T 'r4   c                    R# )zHandle a backjump event.Nr,   )rB   r   r   s   &&&r5   on_backjumpResolverObserver.on_backjumpP  r   r4   c               $    V ^8  d   QhRRRRRR/# )r8   r9   r   r:   r;   r<   rU   r,   )r=   s   "r5   r>   r   S  s$     4 4"43M4	4r4   c                    R# )z%Handle a no-versions-available event.Nr,   rA   s   &&&r5   on_no_versionsResolverObserver.on_no_versionsS  r   r4   c               4    V ^8  d   QhRRRRRRRRR	RR
RRR/# )r8   r   r   satisfier_packager   satisfier_is_decisionrG   satisfier_levelr   previous_levelcan_backjumpr<   rU   r,   )r=   s   "r5   r>   r   X  sY     
D 
DB
D '	
D
  $
D 
D 
D 
D 

Dr4   c                   R# )z5Handle one iteration of the conflict resolution loop.Nr,   )rB   r   r   r   r   r   r   s   &&$$$$$r5   on_conflict_step!ResolverObserver.on_conflict_stepX  r   r4   r,   N)r-   r.   r/   r0   r1   r   r   r   r   r   r   r   r3   r,   r4   r5   r"   r"   5  s/    8/
91
6
'4

D 
Dr4   c                    V ^8  d   QhRRRR/# )r8   requirementsfMapping[PackageType, RangeProtocol[VersionType]] | Sequence[RootRequirement[PackageType, VersionType]]r<   z;TypeIs[Sequence[RootRequirement[PackageType, VersionType]]]r,   )r=   s   "r5   r>   r>   e  s!     1 1:1 A1r4   c                ,    \        V \        4      '       * # )a  Return whether the caller passed the one-clause-per-requirement form.

A ``TypeIs`` rather than a bare ``isinstance``: one type can satisfy both
members of the union, so plain narrowing can leave an intersection that
has lost the mapping's value type.  ty needs the sequence rather than the
mapping as the narrowed side to keep those parameters, while the test
itself stays on ``Mapping`` so every non-mapping iterable is still taken
as the sequence form.
)
isinstancer   )r   s   &r5   _is_root_sequencer   e  s     ,000r4   c                    V ^8  d   QhRRRR/# )r8   r   r   r<   3Sequence[RootRequirement[PackageType, VersionType]]r,   )r=   s   "r5   r>   r>   u  s       : 9r4   c                    \        V 4      '       d   V # V P                  4        UUu. uF"  w  r\        \        \        3,          ! W4      NK$  	  upp# u uppi )zGAccept either shape ``Resolver.resolve`` takes and return the sequence.)r   itemsr   r   r   )r   r9   required_ranges   &  r5   _as_root_requirementsr   u  sW    
 &&
 (4'9'9';';#G 	[01'J';  s   (Ac                      ] tR tRtRt^t^t^t^t^@t	R]
]^]3R R lltRR R lltRR R	 lltR
 R ltR R ltR R ltR R ltR R ltRtR# )r!   i  aa  PubGrub dependency resolver.

The main loop follows the PubGrub specification:
1. Unit propagation: derive constraints from incompatibilities
2. Conflict resolution: learn new incompatibilities and backjump
3. Decision making: pick the next package and version to try

Reference: https://github.com/dart-lang/pub/blob/master/doc/solver.md#the-algorithm
Nc               4    V ^8  d   QhRRRRRRRRR	R
RRRR/# )r8   providerz*ResolverProvider[PackageType, VersionType]observerz1ResolverObserver[PackageType, VersionType] | Nonemax_iterationsr   
range_typeztype[RangeProtocol[Any]]root_versionr
   format_rangezCallable[[Any], str]r<   rU   r,   )r=   s   "r5   r>   Resolver.__annotate__  sQ     9 9<9 D9 	9
 -9 9 +9 
9r4   c                >   Wn         T;'       g    \        4       V n        W0n        W@n        WPn        W`n        . V n        \        \        4      V n
        / V n        \        VR7      V n        \        4       V n        / V n        / V n        . V n        / V n        / V n        R# )a  Create a resolver with the given provider and optional observer.

The ``root_version`` is a sentinel passed to ``range_type.singleton()``
to build the virtual root package's range.  The default ``1``
works for :class:`~nab_resolver.ranges.Range` (which accepts any
comparable type) but a PEP 440 range type such as
:class:`packaging.ranges.VersionRange` requires a parseable
version string or :class:`~packaging.version.Version` here.

``format_range`` renders a constraint in a failure report.  It travels
with ``range_type``: the default ``str`` reads well for
:class:`~nab_resolver.ranges.Range`, while a range type whose ``str``
is a debug representation needs its own.
r   N)r   r"   r   r   r   r   r   incompatibilitiesr   listpackage_to_incompatibilitiesdependency_indexr   solutionr$   statsconstraintsroot_package_orderpending_targeted_backtracktiebreak_cacherelation_cache)rB   r   r   r   r   r   r   s   &&&&&&&r5   __init__Resolver.__init__  s    . !**(* 	 -$((BDITJ
) 133B!4
 2?
MOKM=?' HJ  	r4   c               $    V ^8  d   QhRRRRRR/# )r8   r   r   r   7Mapping[PackageType, RangeProtocol[VersionType]] | Noner<   r(   r,   )r=   s   "r5   r>   r     s+     : :>: M	:
 
(:r4   c                8    V P                  W4      P                  # )zResolve requirements and return ``{package: version}``.

The pins of :meth:`solve`, for a caller that has no use for the
dependency graph.
)solver)   )rB   r   r   s   &&&r5   resolveResolver.resolve  s     zz,4999r4   c               $    V ^8  d   QhRRRRRR/# )r8   r   r   r   r   r<   "Solution[PackageType, VersionType]r,   )r=   s   "r5   r>   r     s+     90 90>90 M	90
 
,90r4   c                &   V P                  V4       V P                  \        V4      4       V P                  pV P                  p\
        p\        V P                  4       F  pV P                  ;P                  ^,          un	        \        P                  ! W4      pVe   V P                  VVV4      w  rSpKX  \        P                  ! V 4      pVf   V P                  4       u # V P!                  V4      pK  	  RV P                   R2p	\#        V	4      h)a-  Resolve requirements and return the pins, roots, and edges.

``requirements`` is either one range per package, or a sequence of
:class:`~nab_resolver.types.RootRequirement` when the caller has more
than one requirement on a package and wants each named as written in
the failure report.

Constraints restrict a package's version range but do not cause
it to be installed.  They are injected lazily: only when the
resolver is about to decide a constrained package (meaning
something already depends on it).

Raises ``ResolutionError`` if no solution exists.
zResolution exceeded z iterations)_reset_add_root_requirementsr   _RESTART_THRESHOLD_MAX_RESTARTSr   ranger   r   r   r   unit_propagation_handle_conflictr   choose_package_to_decide_build_result_decide_nextr   )
rB   r   r   restart_thresholdrestarts_remainingchanged_package_conflicting_incompatibilitynext_packageexceeded_messages
   &&&       r5   r   Resolver.solve  s   ( 	K ##$9,$GH !33!//#t**+AJJ" +4*D*D+' +6))3)* G4F  "::4@L# ))++"//=O3 ,6 2$2E2E1FkR.//r4   c               (    V ^8  d   QhRRRRRRRR/# )r8   r  zIncompatibility[Any, Any]r  r   r  r<   ztuple[Any, int, int]r,   )r=   s   "r5   r>   r     s8     F F%>F F  	F
 
Fr4   c                t   V P                   ;P                  ^,          un        V P                  P                  V4       \        P
                  ! W4      pVP                  ^ ,          P                  p\        P                  ! V 4      pVe   Tp\        P                  ! WV4      w  r#pV'       d   \        pWRV3# )z@Run conflict resolution, targeted backtrack, and restart phases.)r   r   r   r   r   conflict_resolutiontermsr9   maybe_targeted_backtrackmaybe_restartr   )rB   r  r  r  learnedr  
triggering	restarteds   &&&&    r5   r
  Resolver._handle_conflict  s     	

!!!"=>..tQ&}}Q/7766t<
!(O;C;Q;Q%7<
8y "O3EEEr4   c                    V ^8  d   QhRRRR/# )r8   r  r
   r<   r,   )r=   s   "r5   r>   r   4  s     7 7 7 7r4   c                   \         P                  ! W4      p\         P                  ! V 4      p\        V P                  P                  4       4      pV'       d   \        P                  ! W4      pVe   V# Vf   \         P                  ! WVR7       V# V P                  P                  W4       V P                  ;P                  ^,          un        V P                  P                  WV P                  P                  4       V P                  P                  W4      pV'       g   V# V P                   P#                  V4      pV P                  P%                  W4      pVf   TMTp	VP'                  4        F  w  rW8g  pV'       g   W+9   d   K  \)        WRR7      .pM\)        WRR7      \)        WRR7      .p\+        V\,        P.                  R7      p\0        P2                  ! W4       V'       g   K}  \         P4                  ! W
W4       K  	  V# )zIRun the decision phase for ``next_package``. Return next changed package.)had_pendingTr   F)r   )r   rC   absorb_pending_clausesr   r   rv   r   force_targeted_backtrackrecord_no_versionsr   r   ri   r   r   decision_levelrQ   r   	singletonrz   r   r   r   r   
DEPENDENCYr   add_incompatibilityabsorb_redundant_requirement)rB   r  chosen_versionr"  force_targetsr  dependenciesexact_rangewidenedparent_rangedependency_packagedependency_rangecross_packager  r   s   &&             r5   r  Resolver._decide_next4  s   ..tB33D9
 T]]JJLM!::4OJ%!!!%%dkR\:

!!!$--*F*F	
 }}55lSoo//?--..|L&-o{74@4F4F4H0.>M  "5l$GH dC+N .1<<O ..tE}33.>- 5I2 r4   c                   V ^8  d   QhRR/# )r8   r<   r  r,   )r=   s   "r5   r>   r   m  s     = =A =r4   c                    \        V P                  P                  4       V P                  V P                  P
                  \        R7      w  rp\        WVR7      # )zBuild the final result, including only reachable packages.

Per the PubGrub spec, the solution must not contain extra packages:
"all selected packages are transitively reachable from the root."
)root_sentinel)r)   r*   r+   )r   r   ri   r   r   rQ   r   r%   )rB   r)   r*   r+   s   &   r5   r  Resolver._build_resultm  sK     1MM##%""MM**	
U Te<<r4   c                    V ^8  d   QhRRRR/# )r8   r   r   r<   rU   r,   )r=   s   "r5   r>   r   {  s     $ $L$ 
$r4   c                   V P                   P                  4        V P                  P                  4        V P                  P                  4        \	        V P
                  R7      V n        \        4       V n        T;'       g    / V n	        V P                  P                  4        V P                  P                  4        V P                  P                  4        V P                  P                  4        R# )z(Reset solver state for a new resolution.r   N)r   clearr   r   r   r   r   r$   r   r   r   r   r   r   )rB   r   s   &&r5   r  Resolver._reset{  s    
 	$$&))//1##%'4??C"_
&,,"%%'''--/!!#!!#r4   c                    V ^8  d   QhRRRR/# )r8   r   r   r<   rU   r,   )r=   s   "r5   r>   r     s     " "O"	"r4   c                >   \        V4       F  w  r#\        \        V P                  P	                  V P
                  4      RR7      p\        P                  ! V \        V\        VP                  VP                  RR7      .\        P                  VP                  R7      4       V P                  P                  VP                  ^ VR34       K  	  V P                  P!                  \        V P
                  4       V P"                  ;P$                  ^,          un        R# )zACreate one root incompatibility per requirement, and decide root.Tr#  F)r   origin N)	enumerater   r   r   r(  r   r   r*  r   r9   r~   r   r@  r   
setdefaultr   r   r   ri   )rB   r   idxroot	root_terms   &&   r5   r  Resolver._add_root_requirements  s     #<0IC(,doo//0A0ABT)I ..T\\4??U ST.33;; ##..t||ab\J 1 	T4#4#45

!r4   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r-   r.   r/   r0   r1   r  r  CULPRIT_THRESHOLDTARGETED_BT_MIN_CONFLICTSMAX_TARGETED_BACKTRACKSDEFAULT_MAX_ITERATIONSr   strr   r   r   r
  r  r  r  r  r3   r,   r4   r5   r!   r!     sl     M
  " 
 GK4/4-09v:90vF07r=$"" "r4   N)rK  r    r   r   r   r   r!   r"   r#   r$   r   r   r%   r   )6r1   
__future__r   collectionsr   collections.abcr   r   r   dataclassesr   r   typingr	   r
   r   r   rA  r   r   r   r   errorsr   partial_solutionr   rangesr   resultr   rE  r   typesr   r   r   r   r   r   r   r   r   typing_extensionsr   __all__rK  r%   r#   r    r$   r"   r   r   r!   r,   r4   r5   <module>rY     s  ( # # 7 7 ( 8 8 9 9 # -  ' 
 
 
 (" !  $#w{K/0 # #Nx[ 89 Nb37;34 3l GK(  0-Dw{K78 -D`1 \"w{K/0 \"r4   