+
    iHàj7  ã                  ó–   € R t ^ RIHt ^ RIHtHtHtHtHtH	t	 Rt
RtRtRtRtRtR	 R
 ltR R ltRR R lltRR R lltRR R lltR# )ab  Exact held-row coverage for an in-place archive.

A watermark cap archives every active row up to the newest id the caller held.
That deletes a gap below that id, and a trailing unpersisted turn makes the cap
fall back to the lease watermark. When the caller can name the rows the
compressor actually held, the commit archives those and clones the rest.
)Úannotations)ÚAnyÚDictÚListÚOptionalÚSequenceÚTupleÚ_absorbed_row_idsÚ_merged_durable_rowsÚ_unnamed_durable_rowsÚ_retired_durable_rowsÚ_retired_rowÚ_own_rowc               ó    € V ^8„  d   QhRRRR/# )é   Úmessagezdict[str, Any]Úreturn© )Úformats   "ÚK/home/ubuntu/.hermes/hermes-agent/agent/conversation_compression_archive.pyÚ__annotate__r      s   € ÷ ñ  ð °Nñ ó    c                óX  € RV P                  R4      RV P                  R4      /pV P                  R4      '       d   V R,          VR&   V P                  R4      ;'       g    R Uu. uF,  p\        V\        4      '       g   K  VP                  R4      NK.  	  ppV'       d   W1R&   V# u upi )z7The fields the commit matches a retired id-less row by.ÚroleÚcontentÚtool_call_idÚ
tool_callsÚidÚtool_call_idsr   )ÚgetÚ
isinstanceÚdict)r   ÚpayloadÚcallÚcallss   &   r   Úretired_row_payloadr%      s–   € à% w§{¡{°6Ó':¸IÀwÇ{Á{ÐS\ÓG]Ð^€GØ‡{�{�>×"Ò"Ø")¨.Õ"9ˆ�ÑØ(/¯©°LÓ(A×(GÐ(GÀRÐ(GÓbÑ(G Ì:ÐVZÔ\`×KaŒ^ˆT�X‰X�dŽ^Ñ(G€EÐbßØ#(�Ñ Ø€Nùò cs   Á%B'ÂB'c               ó    € V ^8„  d   QhRRRR/# )r   Úvaluer   r   úOptional[int]r   )r   s   "r   r   r   *   s   € ÷ ñ ˜ð  ñ r   c                óp   € \        V \        4      '       d    \        V \        4      '       g
   V ^ 8”  d   V # R# )é    N)r    ÚintÚbool)r'   s   &r   Ú_positive_idr-   *   s)   € Ü�%œ×Ò¤j°¼×&=Ò&=À%È!Ä)ØˆÙr   Nc               ó$   € V ^8„  d   QhRRRRRR/# )r   ÚmessagesúSequence[Any]Úverbatim_tailúOptional[Sequence[Any]]r   z&tuple[list[int], list[dict[str, Any]]]r   )r   s   "r   r   r   0   s$   € ÷ 4ñ 4Øð4Ø,Cð4à+ñ4r   c                óÜ  € . p. pT ;'       g    RT;'       g    R3 F­  pV F¤  p\        V\        4      '       g   K  \        VP                  R4      4      pVf   VP	                  V4       MVP	                  V4       VP                  \
        4      ;'       g    R F%  p\        V4      pVf   K  VP	                  V4       K'  	  K¦  	  K¯  	  \        \        P                  V4      4      V3# )aJ  ``(covered ids, unresolved dicts)`` from the history the compressor was handed.

A positive ``_row_id`` is covered, including ids a repair merged into that dict.
A dict with no id is unresolved: the commit matches one durable row, and a
marker-less miss is an unpersisted turn rather than a reason to archive the
lease watermark.
Ú_row_idr   )r    r!   r-   r   ÚappendÚABSORBED_ROW_IDSÚlistÚfromkeys)	r/   r1   ÚcoveredÚ
unresolvedÚbatchr   Úrow_idÚabsorbedÚabsorbed_ids	   &&       r   Úheld_archive_coverager?   0   sÎ   € ð €GØ')€JØ—.�.˜b -×"5Ð"5°2Ó6ˆÛˆGÜ˜g¤t×,Ò,ÙÜ! '§+¡+¨iÓ"8Ó9ˆFØŠ~Ø×!Ñ! 'Õ*à—‘˜vÔ&Ø#ŸK™KÔ(8Ó9×?Ð?¸RÒ?�Ü*¨8Ó4�ØÔ*Ø—N‘N ;Ö/ó @ó ñ 7ô ”—‘˜gÓ&Ó'¨Ð3Ð3r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r/   r0   r1   r2   r   r(   r   )r   s   "r   r   r   L   s$   € ÷ )ñ )Øð)Ø,Cð)àñ)r   c                óÚ  € ^ RI Hp . pT ;'       g    R Fc  p\        V\        4      '       d   VP	                  V4      '       g   K2  \        VP	                  R4      4      pVf   KR  VP                  V4       Ke  	  T;'       g    R FL  p\        V\        4      '       g   K  \        VP	                  R4      4      pVf   K;  VP                  V4       KN  	  V'       d   \        V4      # R# )zÏNewest held id that still names the row the compressor saw.

A head row counts only while it still carries the persist marker. A ``here N``
tail is marker-swept copies; its id counts when the copy kept one.
©Ú_DB_PERSISTED_MARKERr4   Nr   )Úagent.context_compressorrC   r    r!   r   r-   r5   Úmax)r/   r1   rC   Úexactr   r<   s   &&    r   Únewest_exact_held_idrG   L   s¾   € õ >à€EØ—>�>˜r’>ˆÜ˜'¤4×(Ò(°·±Ð<P×0QÒ0QÙÜ˜gŸk™k¨)Ó4Ó5ˆØÔØ�L‰L˜Ö ñ "ð !×&Ð& BÒ&ˆÜ�gœt×$Ô$Ü! '§+¡+¨iÓ"8Ó9ˆFØÔ!Ø—‘˜VÖ$ñ	 '÷
 Œ3ˆu‹:Ð( DÐ(r   c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R
/# )r   Ú
session_dbr   Ú
session_idÚstrr/   r0   r1   r2   r   z:tuple[Optional[list[int]], Optional[list[dict[str, Any]]]]r   )r   s   "r   r   r   e   s7   € ÷ #ñ #Øð#Ø!$ð#Ø0=ð#à*ð#ð @ñ#r   c                óÄ  a€ ^ RI Ho \        W#4      p\        V RR4      pVe   \	        V4      '       d   V! W4      f   R# \        W#4      w  rg. pV F¥  p	V	P                  \        4      ;'       g    R U
u. uF  p
\        V
\        4      '       g   K  V
NK  	  pp
\        V	P                  \        4      ;'       g    ^ 4      \        R V 4       4      8”  d   Ru # VP                  V3R lV 4       4       K§  	  . VOVOpV U	u. uF6  p	\        V	\        4      '       g   K  V	P                  S4      '       g   K4  V	NK8  	  pp	V'       g   V'       g   R# Wg3# u up
i u up	i )aÐ  Coverage to pass into ``archive_and_compact``, or ``(None, None)`` to keep the watermark.

``None`` when the newest exact held row is already inactive (another compaction
won: archiving only the held ids would clone the winner), when nothing held
is a durable row, or when a held dict counts more rows than it can name: naming
the rest would clone those behind the running turn. A trailing unpersisted turn
does not take this branch: the rows above it stay unnamed and are cloned.
The rows a dict names in ``RETIRED_DURABLE_ROWS`` join the unresolved set, so a
dropped row does not throw away the coverage of everything else: the watermark
would also archive rows another surface appended that the compressor never saw.
rB   Úget_message_roleNc              3  ó^   "  € T F#  qP                  \        4      '       d   K  ^x € K%  	  R# 5i)é   N)r   ÚOWN_ROW)Ú.0Úrows   & r   Ú	<genexpr>Ú&coverage_for_commit.<locals>.<genexpr>~   s   é € Ð<hÉ%À3×W^ÑW^Ô_f×Wg¿QºQË%ùs   ‚-£
-c              3  ó@   <"  € T F  p/ VCSR \         R /Cx € K  	  R# 5i)TN)ÚRETIRED_ROW)rQ   rR   rC   s   & €r   rS   rT   €   s&   øé € Ð_ÑY^ÐRUÐM˜#ÐMÐ3°T¼;ÈÖMÓY^ùs   ƒ)NNr   )rD   rC   rG   ÚgetattrÚcallabler?   r   ÚRETIRED_DURABLE_ROWSr    r!   r+   ÚUNNAMED_DURABLE_ROWSÚsumÚextend)rI   rJ   r/   r1   ÚnewestÚrole_ofr9   r:   Úretiredr   rR   ÚnamedÚmarkedrC   s   &&&&         @r   Úcoverage_for_commitrb   e   sG  ø€ õ >ä! (Ó:€FÜ�jÐ"4°dÓ;€GØÒœh w×/Ò/±G¸JÓ4OÒ4WØÐÜ/°ÓHÑ€GØ$&€GÛˆØ '§¡Ô,@Ó A× GÐ GÀRÐ GÓaÑ G˜Ì:ÐVYÔ[_×K`—�Ñ GˆÐaÜˆw�{‰{Ô/Ó0×5Ð5°AÓ6¼Ñ<hÉ%Ó<hÓ9hÔhØÒØ�‰Ô_ÑY^Ó_Ö_ñ	 ð
 )�:Ð( Ð(€Já)óÙ)�GÜ�gœt×$ô 	Ø)0¯©Ð5I×)J÷ 	ˆ™zð ð ÷ Ÿ6ØÐØÐÐùò bùò
s   Á6EÂEÄEÄ"EÄ;E)N)Ú__doc__Ú
__future__r   Útypingr   r   r   r   r   r   r6   ÚMERGED_DURABLE_ROWSrZ   rY   rV   rP   r%   r-   r?   rG   rb   r   r   r   Ú<module>rg      s]   ðñõ #ç =× =à&Ð ð -Ð ð /Ð ð /Ð à€ð €õõ÷4÷8)÷2#ñ #r   