+
    2j                        R t ^ RIHt ^ RIHtHt ^RIHtHtH	t	 ]'       d   ^RI
Ht . ROt^tR R ltR R ltR	 R
 ltR R ltR# )a  Incompatibility index and dependency-clause merging.

The resolver keeps two derived indexes alongside ``incompatibilities``:
``package_to_incompatibilities`` (package -> list of clause indices) for
unit-propagation lookup, and ``dependency_index`` (merge key -> index)
for collapsing many singleton dependency clauses into one
``pkg in {v1, v2, ...}`` clause (pubgrub-rs's ``merge_dependents``).
)annotations)TYPE_CHECKINGAny)IncompatibilityIncompatibilityCauseTerm)Resolverc               $    V ^8  d   QhRRRRRR/# )   resolverResolver[Any, Any]incompatibilityIncompatibility[Any, Any]returnNone )formats   "f/home/user/billing-ledger-validation/.venv/lib/python3.14/site-packages/nab_resolver/incompat_index.py__annotate__r       s$     7 7 73L7	7    c                "   \        W4      '       d   R# \        V P                  4      pV P                  P                  V4       VP                   F/  pV P
                  VP                  ,          P                  V4       K1  	  \        WV4       R# )zDAdd an incompatibility, merging into an existing clause if possible.N)maybe_merge_dependencylenincompatibilitiesappendtermspackage_to_incompatibilitiespackageindex_dependency)r   r   indexterms   &&  r   add_incompatibilityr!       sm     h88**+E%%o6%%--dll;BB5I &X6r   c                    V ^8  d   QhRRRR/# )r
   r   r   r   z!tuple[Any, Any, Any, bool] | Noner   )r   s   "r   r   r   .   s      .&r   c                .   V P                   \        P                  Jg   \        V P                  4      \
        8w  d   R# V P                  w  rVP                  4       '       g   R# VP                  VP                  VP                  VP                  4       3# )an  Return the merge key for a two-term DEPENDENCY clause, else None.

Every DEPENDENCY clause we emit is ``[package_term (positive), dep_term]``,
so we trust call-site order: first term is the package, second is the dep.
Clauses with matching ``(package, dep_package, dep_constraint, dep_positive)``
tuples can be merged by unioning the package term's positive ranges.
N)	causer   
DEPENDENCYr   r   _DEPENDENCY_CLAUSE_TERMSis_positiver   
constraint)r   pkg_termdep_terms   &  r   dependency_merge_keyr+   .   s     	%9%D%DD$$%)AA(..H!! 		 r   c               (    V ^8  d   QhRRRRRRRR/# )	r
   r   r   r   r   r   intr   r   r   )r   s   "r   r   r   J   s0     / / /./ / 
	/r   c                D    \        V4      pVe   W P                  V&   R# R# )z@Record this incompatibility as the canonical clause for its key.N)r+   dependency_index)r   r   r   keys   &&& r   r   r   J   s&     
/C
).!!#& r   c               $    V ^8  d   QhRRRRRR/# )r
   r   r   r   r   r   boolr   )r   s   "r   r   r   U   s$     " " "3L"	"r   c                   \        V4      pVf   R# V P                  P                  V4      pVf   R# V P                  V,          pVP                  w  rVVP                  w  rxVP
                  VP
                  ,          p	WP
                  8X  d   R# \        \        VP                  V	RR7      V.\        P                  R7      p
WP                  V&   R# )zTry to merge ``incompatibility`` into an existing clause.

Returns ``True`` if a merge happened (caller should not also append).
Replaces the existing package term with the union; the dep term stays
unchanged so semantics are preserved.
FT)positive)r$   )r+   r/   getr   r   r(   r   r   r   r   r%   )r   r   r0   existing_indexexistingexisting_pkgexisting_depnew_pkg_merged_constraintmergeds   &&         r   r   r   U   s     
/C
{..2237N)).9H!)L &&JG$//'2D2DD333%%'84H	
 #--F 28~.r   N)r!   r+   r   r   )__doc__
__future__r   typingr   r   typesr   r   r   r   r   __all__r&   r!   r+   r   r   r   r   r   <module>rC      sA    # % > >"  78/"r   