+
    iHàjŸÏ ã                  ó  a € 0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI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 ^ RIH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-H.t.H/t/ ^ RI0H1t1 ^ RI2H3t3H4t4 ^ RI5H6t6H7t7 ^ RI8H9t9 ^ RI:H;t< ^ RI=H>t> ^ RI?H@t@ ]P‚                  ! ]B4      tC]Pˆ                  RR/R R ll4       tE]F! ]6PŽ                  ]6P�                  04      tI^<tJRtKR]K R2tLR]K R2tMRtNR R ltOR R ltPR tQR!tRR"tSR#tTR$tUR%tVR&tWR'tX]L]M]N]QP³                  R(R)7      ]RP³                  R*R+R,7      ]SP³                  R-R*R.7      ]TP³                  R/^^R07      ]UP³                  ^^R17      ]VP³                  R/R*R17      ]WP³                  R*R/R27      3
tZR3 R4 lt[R5 R6 lt\ERht]ERit^R7 R8 lt_]PÀ                  ! 4       ta]PÄ                  ! R9RR:7      tcR;]dR<&   R= R> lteR? R@ ltfRA RB ltgRC RD lthRE RF ltiRG RH ltjRI RJ ltkRK RL ltlRM RN ltmRO RP ltnRQRRRRRSR/RT RU lltoRV RW ltp ! RX RY4      tqRZtrRss]PÀ                  ! 4       ttR[tuR\tvR] R^ ltw^tx]PÀ                  ! 4       ty^ szR_ R` lt{ERjRa Rb llt|Rc t}RdR/Re Rf llt~Rg Rh ltRi Rj lt€Rk Rl lt�Rm Rn lt‚Ro Rp ltƒRq Rr lt„RsRRtRRuRRvRRwR/Rx Ry llt…Rz R{ lt†R| R} lt‡R~ R ltˆR€ R� lt‰R‚ Rƒ ltŠR„RRtRRsRR…RRuRR†R‡RvRRˆRR‰RRŠR/
R‹ RŒ llt‹^ R�IŒH�t�HŽtŽ RŽ R� lt�R�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Ÿ R  lt—R¡ R¢ lt˜R£ R¤ lt™R¥ R¦ ltšR�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µ R¶ lt¢R·R/R¸ R¹ llt£ ! Rº R»4      t¤R¼ R½ lt¥ ! R¾ R¿4      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­ERjRÎ RÏ llt®ERkt¯RÐ RÑ lt°ERlt±RÒ RÓ l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æ lt½Rç Rè lt¾]ERm,          t¿Ré Rê ltÀRë Rì ltÁRí Rî ltÂRïR/Rð Rñ lltÃRòtÄRó Rô ltÅRõ Rö ltÆR÷ Rø ltÇRù Rú ltÈ ! Rû Rü4      tÉ ! Rý Rþ4      tÊRÿ ER  ltËERjER ER lltÌER ER ltÍER ER ltÎER ER ltÏER	 ER
 ltÐER ER ltÑER ER ltÒER ER ltÓER ER ltÔER ER ltÕER ER ltÖER ER lt×ER ER ltØER ER ltÙER ER ltÚER ER  ltÛER! ER" ltÜER#ER$/ER% ER& lltÝER' ER( ltÞER) ER* ltß]	EPÀ                   ! ER+ ER,4      4       táER- ER. ltâERntã]Pˆ                  ER/ ER0 l4       täER1RER2R/ER3 ER4 lltå]	EPÀ                   ! ER5 ER64      4       tæER7 ER8 ltç]	EPÀ                   ! ER9 ER:4      4       tèER;RER<RER=R/ER> ER? lltéER@ ERA ltêERB ERC ltëERD ERE ltìER<RERFERGERHRERIRR·RERJRERKRER1RER;RERLRER=R/ERM ERN lltíERotîEROERPERQERRERSERTERUERVERWERVERXERY/tïERpERZ ER[ lltðER\ ER] ltñER^ ER_ ltòER` ERa ltóERb ERc ltôERdERe/ERf ERg lltõ. ERqOtöR# (r  aÜ  Context compression: feasibility probe, warning replay, compress, image fix.

Thread-safety contract for extension points: with ``compression.context_timeout_seconds > 0`` (default) the
whole pass, context engines and memory providers included, runs on a pooled daemon thread. Calls may arrive
on any pooled thread (never rely on thread-affinity/locals); the message list is a private deep snapshot
(in-place mutation is invisible to the live conversation unless the pass commits); state is published ONLY
on an admitted :class:`CompressionCommitFence` commit (work still running after a host timeout is discarded);
one pass per session at a time (durable lock) but sessions run concurrently, so shared engines must be thread-safe.
)ÚannotationsN)Údatetime)ÚPath)ÚAnyÚCallableÚDictÚListÚLiteralÚOptionalÚTuple)ÚAuxiliaryExplicitCancellation)Ú_accepts_keyword_argument)Ú#automatic_compaction_status_messageÚsanitize_memory_context)Ú&_compress_context_via_codex_app_server)Ú$resolve_context_compression_timeouts)Ú_emit_aborted_attempt_telemetryÚ_emit_blocked_attempt_telemetryÚ _emit_bypassed_attempt_telemetryÚ#_emit_compression_attempt_telemetryÚ _record_committed_attempt_effectÚ"_snapshot_compression_effect_input)Ú#PRE_COMPRESS_CHECKPOINT_API_VERSION)Úestimate_messages_tokens_roughÚestimate_request_tokens_rough)ÚActivityProvenanceÚnormalize_activity_provenance)Úset_usage_anchor)Únew_session_id)Úholder_namespace_token)Úheld_archive_watermarkÚexc_infoFc               ó    € V ^8„  d   QhRRRR/# )é   ÚmessageÚstrr!   Úbool© )Úformats   "ÚC/home/ubuntu/.hermes/hermes-agent/agent/conversation_compression.pyÚ__annotate__r*   4   s   € ÷ Yñ Y�cð Y¨ñ Yó    c             #  ó¾   "  €  Rx € R#   \          dF   pT'       d   \        P                  T RR7        Rp?R# \        P                  Y4        Rp?R# Rp?ii ; i5i)zLRun a best-effort block; on Exception log ``message`` at DEBUG and continue.NT©r!   )Ú	ExceptionÚloggerÚdebug)r$   r!   Úexcs   &$ r)   Ú_swallowr2   3   sB   é € ðYÝøÜô Yß08Œ�‰�W tˆ×,Ò,¼f¿l¹lÈ7×>XÒ>XûðYüs4   ‚A„
 ˆAŠA•A´AºAÁAÁAÁAzCompacting contextu   ðŸ—œï¸� u:    â€” summarizing earlier conversation so I can continue...u@    â€” still summarizing earlier conversation so I can continue...u6   âœ“ Context compaction complete â€” continuing turn...c               ó    € V ^8„  d   QhRRRR/# )r#   Úmsgsr   Úreturnr'   )r(   s   "r)   r*   r*   S   s   € ÷ sñ s sð s¨sñ sr+   c                ó  € ^ RI Hp \        V \        4      '       g   V # V  UUUu. uFG  p\        V\        4      '       d-   VP                  4        UUu/ uF  w  r4W18w  g   K  W4bK  	  uppMTNKI  	  uppp# u uppi u upppi )a  Copy ``msgs`` with the ``_db_persisted`` marker removed for no-op comparison.
Live dicts carry the marker while ``compress()`` output is swept, so a raw ``==`` would misclassify an
identical no-op copy as progress. Non-list inputs and non-dict entries pass through unchanged.©Ú_DB_PERSISTED_MARKER)Úagent.context_compressorr8   Ú
isinstanceÚlistÚdictÚitems)r4   r8   ÚmÚkÚvs   &    r)   Ú_strip_marker_for_comparisonrA   S   sk   € õ >Ü�dœD×!Ò!ØˆÙmqÕrÑmqÐhiÌÐTUÔW[×I\ÒI\˜aŸg™gœiÔE™i‘d�a¨1Ñ+DŒTˆQŠT™iÓEÐbcÒcÑmqÓrÐrùÓEùÔrs   ¥.A=Á
A7Á"A7Á(
A=Á7A=c               ó    € V ^8„  d   QhRRRR/# ©r#   Úagentr   r5   ÚNoner'   )r(   s   "r)   r*   r*   ]   s   € ÷ =ñ = ð =¨ñ =r+   c                ó²   € \        V RR4      pV'       g   R# \        RRR7      ;_uu_ 4        V! R\        4       RRR4       R#   + '       g   i     R# ; i)z;Emit the structured terminal edge for a started compaction.Ústatus_callbackNz.status_callback error in compaction completionTr-   Ú	compacted)Úgetattrr2   ÚCOMPACTION_DONE_STATUS)rD   rG   s   & r)   Ú_emit_compaction_donerK   ]   s@   € ä˜eÐ%6¸Ó=€OßÙÜ	ÐBÈT×	RÖ	RÙ˜Ô%;Ô<÷ 
S×	R×	RÒ	Rús   ­AÁA	ur   ðŸ“¦ Pre-API compression: ~{tokens:,} tokens near the context/output limit. Compacting before the next model call.ub   ðŸ“¦ Preflight compression: ~{tokens:,} tokens >= {threshold:,} threshold. This may take a moment.u\   ðŸ’¤ Resumed after {idle_seconds}s idle â€” compacting ~{tokens:,} tokens before continuing.uS   ðŸ—œï¸� Context too large (~{tokens:,} tokens) â€” compressing ({attempt}/{cap})...u=   ðŸ—œï¸� Compressed {before} â†’ {after} messages, retrying...uA   ðŸ—œï¸� Compressed ~{before:,} â†’ ~{after:,} tokens, retrying...uL   ðŸ—œï¸� Context reduced to {new_ctx:,} tokens (was {old_ctx:,}), retrying...uè   âš  Context is over the compression threshold (~{tokens:,} tokens >= {threshold:,}) but compression is currently blocked ({reason}). The model may stop responding. Run /new to start a fresh session or /compress to retry immediately.i@â )ÚtokensiÀÔ i † )rL   Ú	thresholdi  )Úidle_secondsrL   i�Ð )rL   ÚattemptÚcap)ÚbeforeÚafter)Únew_ctxÚold_ctxc               ó    € V ^8„  d   QhRRRR/# )r#   Útextz
str | Noner5   r&   r'   )r(   s   "r)   r*   r*   •   s   € ÷ \ñ \¨
ð \°tñ \r+   c                ó  € \        V \        4      '       d   V P                  4       MRpV'       g   R# \        V9   d   R# V\        8X  d   R# VP                  4       pRV9   g   RV9   d   R# RV9   ;'       g    RV9   ;'       g    RV9   # )	a1  True for in-progress auto-compaction lifecycle lines (not the done edge).
The gateway re-tags matches as ``kind="compacting"`` for the whole pause; matching only the marker left
idle/preflight/retry lines looking hung. ``COMPACTION_DONE_STATUS`` is emitted as ``kind="compacted"`` and
must not match here.Ú FTzcompaction completez compression is currently blockedÚcompactÚcompresszcontext reduced to)r:   r%   ÚstripÚCOMPACTION_STATUS_MARKERrJ   Úlower)rV   ÚbodyÚlowereds   &  r)   Úis_compaction_progress_statusr`   •   s€   € ô
 & d¬C×0Ò0ˆ4�:‰:Œ<°b€DßÙÜ 4Ô'ÙØÔ%Ô%ÙØ�j‰j‹l€Gà Ô'Ð+MÐQXÔ+XÙØ˜Ñ×[Ð[ :°Ñ#8×[Ð[Ð<PÐT[Ñ<[Ð[r+   c               ó   € V ^8„  d   QhRR/# ©r#   r5   r&   r'   )r(   s   "r)   r*   r*   ¨   s   € ÷ ñ ¨dñ r+   c                ó†   € ^ RI Hp V! V RR7      pV'       d    \        P                  R\	        V4      4       \        V4      # )zÈRebuild agent.tools at the compaction commit boundary (the only moment config reaches a forever-session's
frozen tool schemas; the prompt cache is already invalid). Returns True when tools were added.)Úrefresh_agent_mcp_toolsT)Úcontent_awarez'Compaction tool refresh added tools: %s)Útools.mcp_tool_agentrd   r/   ÚinfoÚsortedr&   )rD   rd   Úaddeds   &  r)   Ú_refresh_agent_tool_definitionsrj   ¨   s3   € õ =Ù# E¸Ô>€EßÜ�‰Ð=¼vÀe»}ÔMÜ�‹;Ðr+   c               ó    € V ^8„  d   QhRRRR/# )r#   Ú
compressorr   r5   údict[str, Any]r'   )r(   s   "r)   r*   r*   Ä   s   € ÷ #ñ #°3ð #¸>ñ #r+   c                ó¾   €  \        V 4      p\         Uu/ uF  q"T9   g   K  Y!T,          bK  	  pp\        P                  ! T4      #   \         d    / u # i ; iu upi )zÝCopy only the mutable bookkeeping owned by one compression attempt.
The allow-list avoids copying clients, DB handles, locks and plugin resources; missing fields are ignored
so legacy/third-party compressors keep working.)ÚvarsÚ	TypeErrorÚ _COMPRESSOR_ATTEMPT_STATE_FIELDSÚcopyÚdeepcopy)rl   ÚvaluesÚnameÚselecteds   &   r)   Ú"_snapshot_compressor_attempt_staterw   Ä   sc   € ðÜ�jÓ!ˆõ 0PÓbÑ/O tÐ[aÑSaÔ"�˜T•lÒ"Ñ/O€HÐbô �=Š=˜Ó"Ð"øô ô ØŠ	ðüâbs   ‚A •A¢AÁAÁAÚ$hermes_compressor_attempt_generation)Údefaultzcontextvars.ContextVar[Any]Ú_COMPRESSOR_ATTEMPT_GENERATIONc               ó    € V ^8„  d   QhRRRR/# )r#   rl   r   r5   r'   )r(   s   "r)   r*   r*   ï   s   € ÷ ñ °ð ¸ñ r+   c                ó  € \         ;_uu_ 4        \        V RR4      pVf   \        P                  ! 4       p Wn        VuuRRR4       #   \
         d#    \        P                  ! 4       u uuRRR4       # i ; i  + '       g   i     R# ; i)aë  Per-compressor lock serializing the durable cooldown rollback against claims. The process-wide
claim lock must stay cheap (every compressor in a gateway shares it), so the slow SQLite write in
``_restore_compressor_attempt_state`` is fenced by THIS lock instead; ``_claim_compressor_attempt``
takes it first so a claim on that compressor waits for the restore while other compressors proceed.
A slotted/frozen compressor that cannot hold the attribute gets a no-op (its guard is off anyway).Ú _compression_attempt_serial_lockN)Ú_COMPRESSOR_ATTEMPT_LOCKrI   Ú	threadingÚLockr}   r.   Ú
contextlibÚnullcontext)rl   Úlocks   & r)   Ú_compressor_attempt_serial_lockr„   ï   sv   € ÷ 
"Ö	!Ü�zÐ#EÀtÓLˆØŠ<Ü—>’>Ó#ˆDð0Ø>BÔ;ð ÷ 
"Ò	!øô ô 0Ü!×-Ò-Ó/Ñ/÷ 
"Ò	!ð0ú÷ 
"×	!Ð	!ús-   �'A9·A	½A9Á	 A6Á)A9Á5A6Á6A9Á9B
	c               ó    € V ^8„  d   QhRRRR/# )r#   rl   r   r5   Úintr'   )r(   s   "r)   r*   r*      s   € ÷ 
ñ 
¨#ð 
°#ñ 
r+   c                óv  € \        V 4      ;_uu_ 4        \        ;_uu_ 4        \        \        V R^ 4      ;'       g    ^ 4      ^,           p Wn        TuuRRR4       uuRRR4       #   \
         d     RRR4       RRR4       ^ # i ; i  + '       g   i     M; iRRR4       R#   + '       g   i     R# ; i)zÚClaim the compressor for a new attempt; return its monotonic generation id.
Restores or cancelled-check mutations stamped with an OLDER generation no-op, so a detached late attempt
cannot clobber its successor's state.Ú_compression_attempt_generationN)r„   r~   r†   rI   rˆ   r.   ©rl   Ú
generations   & r)   Ú_claim_compressor_attemptr‹      s�   € ô 
)¨×	4Õ	4×6NÖ6NÜœ Ð-NÐPQÓR×WÐWÐVWÓXÐ[\Õ\ˆ
ð	Ø9CÔ6ð ÷ 7OÑ6N×	4Ò	4øô ô 	Ø÷ 7O×	4Ñ	4ð	ú÷	 7O×6Nú×	4×	4×	4Ò	4úsL   ”B'£(B
	ÁA(ÁB
	Á
B'Á(BÁ3B
	Á4B'ÂBÂB
	Â
BÂB'Â'B8	c               ó$   € V ^8„  d   QhRRRRRR/# ©r#   rl   r   rŠ   r†   r5   r&   r'   )r(   s   "r)   r*   r*     s&   € ÷ añ a¨sð aÀð aÈñ ar+   c           	     ó¶   € V'       g   R# \         ;_uu_ 4        \        \        V R^ 4      ;'       g    ^ 4      V8H  uuRRR4       #   + '       g   i     R# ; i)zETrue when *generation* still owns the compressor (or guard disabled).Trˆ   N)r~   r†   rI   r‰   s   &&r)   Ú_compressor_attempt_is_currentr�     s>   € çÙß	!Ö	!Ü”7˜:Ð'HÈ!ÓL×QÐQÐPQÓRÐV`Ñ`÷ 
"×	!×	!Ó	!ús   ™#AÁA	c               ó$   € V ^8„  d   QhRRRRRR/# )r#   rl   r   rŠ   r†   r5   rE   r'   )r(   s   "r)   r*   r*     s&   € ÷ Lñ L°ð LÀ#ð LÈ$ñ Lr+   c           	     óä   € \         ;_uu_ 4        \        P                  ! \        4      ;_uu_ 4        Wn        RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)a<  Publish the generation of the attempt that is ACTUALLY running summary work.

The entry claim is taken before the breaker gates and the per-session lock, so no-op
entries (lock sit-outs, transient gates) bump ``_compression_attempt_generation``
without doing any work. Candidate supersession must key on this separate marker,
published only when the summary dispatch begins, or those no-op claims discard a
completed candidate and compression livelocks. Slotted/frozen compressors that
cannot hold the attribute keep the entry-generation check as a conservative fallback.
N)r~   r�   Úsuppressr.   Ú'_compression_working_attempt_generationr‰   s   &&r)   Ú _mark_compressor_working_attemptr”     sA   € ÷ 
"Ö	!Ü× Ò ¤×+Õ+ØAKÔ>÷ ,÷ 
"Ñ	!ß+×+ú÷ 
"×	!Ð	!ús!   �#A²A	¹AÁAÁAÁA/	c               ó    € V ^8„  d   QhRRRR/# ©r#   rl   r   r5   rE   r'   )r(   s   "r)   r*   r*   $  s   € ÷ .ñ .¨ð .°ñ .r+   c                ó<   € \        V 4      '       g   \        4       hR# )zÜUnwind the CALLING attempt (its generation rides the ContextVar) as a cancellation when a newer
attempt has since begun summary work on *compressor*, so none of the shared-state writes that
follow the call site can land.N)Ú_caller_attempt_is_currentr   ©rl   s   &r)   Ú_raise_if_stale_attemptrš   $  s   € ô & j×1Ò1Ü+Ó-Ð-ñ 2r+   c               ó    € V ^8„  d   QhRRRR/# )r#   rl   r   r5   r&   r'   )r(   s   "r)   r*   r*   ,  s   € ÷ Yñ Y¨3ð Y°4ñ Yr+   c                ó>   € \        V \        P                  4       4      # )u`   Working-attempt check for the calling attempt's own generation (ContextVar; None â†’ unguarded).)Ú_working_attempt_is_currentrz   Úgetr™   s   &r)   r˜   r˜   ,  s   € ä& zÔ3Q×3UÑ3UÓ3WÓXÐXr+   c               ó$   € V ^8„  d   QhRRRRRR/# )r#   rl   r   rŠ   r5   r&   r'   )r(   s   "r)   r*   r*   1  s!   € ÷ .ñ .¨Cð .¸Sð .ÀTñ .r+   c           	     ó:  € V'       g   R# \         ;_uu_ 4        \        V RR4      pVf>   \        \        V R^ 4      ;'       g    ^ 4      pV'       * ;'       g    W18H  uuRRR4       # \        V4      \        V4      8H  uuRRR4       #   + '       g   i     R# ; i)a4  True when *generation* is still the last attempt that began summary work.

Without a published marker (attribute-less compressor, or the attempt never reached
dispatch) supersession falls back to the entry-generation ownership check; a compressor
that no attempt has ever claimed cannot have been superseded.Tr“   Nrˆ   )r~   rI   r†   )rl   rŠ   ÚmarkerÚentry_generations   &&  r)   r�   r�   1  s   € ÷ Ùß	!Ö	!Ü˜Ð%NÐPTÓUˆØŠ>Ü"¤7¨:Ð7XÐZ[Ó#\×#aÐ#aÐ`aÓbÐØ'Ô'×IÐIÐ+;Ñ+I÷	 
"Ò	!ô
 �6‹{œc *›oÑ-÷ 
"×	!×	!Ó	!ús   ™*B	ÁB	ÁB	Á(B	Â	B	c               ó(   € V ^8„  d   QhRRRRRRRR/# )r#   rl   r   ÚcheckrŠ   r†   r5   rE   r'   )r(   s   "r)   r*   r*   A  s0   € ÷ Gñ G°Sð GÀð GÐRUð GÐZ^ñ Gr+   c           	     óð   € \         ;_uu_ 4        \        P                  ! \        4      ;_uu_ 4        Wn        W n        RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)zDInstall the F4 cancellation consult, stamped with its owner attempt.N)r~   r�   r’   r.   Ú_compression_cancelled_checkÚ"_compression_cancelled_check_owner)rl   r¤   rŠ   s   &&&r)   Ú$_install_compression_cancelled_checkr¨   A  sE   € ç	!Ö	!Ü× Ò ¤×+Õ+Ø6;Ô3Ø<FÔ9÷ ,÷ 
"Ñ	!ß+×+ú÷ 
"×	!Ð	!ús!   �#A$²A	¿A$ÁA!ÁA$Á$A5	c               ó$   € V ^8„  d   QhRRRRRR/# r�   r'   )r(   s   "r)   r*   r*   I  s"   € ÷ 
ñ 
¸Cð 
ÈSð 
ÐUYñ 
r+   c           	     óJ  € \         ;_uu_ 4        \        V RR4      pVe   V'       d   W!8w  d    RRR4       R# \        P                  ! \        4      ;_uu_ 4        RV n        RV n        RRR4        RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)z®Clear the cancellation consult only when *generation* installed it.
Prevents a detached late primary from tearing down a newer fallback's callback. Returns True when cleared.r§   NFT)r~   rI   r�   r’   r.   r¦   r§   )rl   rŠ   Úowners   && r)   Ú+_clear_compression_cancelled_check_if_ownerr¬   I  s{   € ÷ 
"Ö	!Ü˜
Ð$HÈ$ÓOˆØÒ§°Ô0CØ÷ 
"Ñ	!ô × Ò ¤×+Õ+Ø6:ˆJÔ3Ø<@ˆJÔ9÷ ,ð ÷ 
"Ñ	!÷ ,×+ú÷	 
"×	!Ð	!ús-   �B©Bº"BÁA>	Á+	BÁ>BÂ	BÂB"	c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R
/# )r#   rl   r   Úsnapshotrm   ÚauthoritativeúOptional[bool]Údurable_stateúOptional[dict[str, Any]]r5   rE   r'   )r(   s   "r)   r*   r*   V  s4   € ÷ 0ñ 0Øð0Ø-ð0Ø>Lð0Ø]uð0à	ñ0r+   c           
     óJ  € \        V 4      P                  R4      p\        V 4      P                  R4      pVe	   V'       g   R# VRJ dV   \        \        V4      RR4      p\	        V4      '       d   Vf   \        R4      hV! WE\        P                  ! V4      4       R# \        RRR7      ;_uu_ 4        \        VR	,          ;'       g    R
4      p\        R
V\        P                  ! 4       ,
          4      pV^ 8”  d\   \        \        V4      RR4      p	\	        V	4      '       d4   V	! WE\        P                  ! 4       V,           VP                  R4      4       M/\        \        V4      RR4      p
\	        V
4      '       d	   V
! WE4       RRR4       R#   + '       g   i     R# ; i)zÜRecreate/clear the durable cooldown row from the attempt snapshot.
Authoritative captures use the exact raw-row restore API (verifies read-back, propagates failure); the
legacy path re-derives deadline/error best-effort.Ú_session_dbÚ_session_idNTÚ(restore_compression_failure_cooldown_rowz6exact compression cooldown rollback API is unavailablez0compression cooldown persistence rollback failedr-   Ú_summary_failure_cooldown_untilç        Ú#record_compression_failure_cooldownÚ_last_summary_errorÚ"clear_compression_failure_cooldown)ro   rž   rI   ÚtypeÚcallableÚRuntimeErrorrr   rs   r2   ÚfloatÚmaxÚtimeÚ	monotonic)rl   r®   r¯   r±   Ú
session_dbÚ
session_idÚrestorerÚdeadlineÚ	remainingÚrecorderÚclearers   &&&&       r)   Ú_rollback_durable_cooldownrÊ   V  sG  € ô �jÓ!×%Ñ% mÓ4€JÜ�jÓ!×%Ñ% mÓ4€JØÒ§ÙØ˜ÓÜœ4 
Ó+Ð-WÐY]Ó^ˆÜ˜×!Ò! ]Ò%:ÜÐWÓXÐXÙ�¬¯ª°}Ó)EÔFÙÜ	ÐDÈt×	TÖ	TÜ˜Ð"CÕD×KÐKÈÓLˆÜ˜˜X¬¯ªÓ(8Õ8Ó9ˆ	Ø�qŒ=Üœt JÓ/Ð1VÐX\Ó]ˆHÜ˜×!Ò!Ù˜´·²³¸yÕ1HÈ(Ï,É,ÐWlÓJmÔnøäœd :Ó.Ð0TÐVZÓ[ˆGÜ˜× Ò Ù˜
Ô/÷ 
U×	T×	TÒ	Tús   Â3CFÆF"	Údurable_cooldown_authoritativeÚdurable_cooldown_stateÚattempt_generationc               ó0   € V ^8„  d   QhRRRRRRRRR	R
RR/# )r#   rl   r   r®   rm   rË   r°   rÌ   r²   rÍ   úOptional[int]r5   rE   r'   )r(   s   "r)   r*   r*   s  s>   € ÷ --ñ --Øð--Ø-ð--ØR`ð--à4ð--àQ^ð--ð 
ñ--r+   c               óÎ  € Ve6   \        W4      '       g%   \        P                  RV\        V RR4      4       R# \        P
                  ! V4      p\        V 4      ;_uu_ 4        \        ;_uu_ 4        T;'       d$    \        \        V R^ 4      ;'       g    ^ 4      V8g  pRRR4       X'       d"   \        P                  RV4        RRR4       R# RV9   d:   VRJd4   VRJ g"   \        VP                  RR4      4      '       g   \        WW#4       VP                  4        F  w  rx\        WV4       K  	  RRR4       R#   + '       g   i     L¨; i  + '       g   i     R# ; i)	aZ  Restore the per-attempt snapshot after a pre-commit hard cancel.
A restore stamped with a stale ``attempt_generation`` no-ops so a timed-out primary's late unwind cannot
roll back state owned by the fallback attempt.

``attempt_generation`` (when provided) is the claim the calling attempt took via
:func:`_claim_compressor_attempt`. See #96634.
NzªSkipping stale compressor attempt-state restore: attempt generation %s no longer owns the compressor (current: %s). A newer (stall-fallback) attempt's state is preserved.rˆ   zuSkipping stale compressor attempt-state restore at write time: attempt generation %s lost the compressor mid-restore.r·   FTÚ_cooldown_persist_failed)r�   r/   ÚwarningrI   rr   rs   r„   r~   r†   r&   rž   rÊ   r=   Úsetattr)	rl   r®   rË   rÌ   rÍ   ÚrestoredÚlostru   Úvalues	   &&$$$    r)   Ú!_restore_compressor_attempt_stater×   s  s4  € ð Ò%Ô.LÈZ×.lÒ.lÜ�‰ð@à¤¨
Ð4UÐW[Ó \ô	
ñ
 	Ü�}Š}˜XÓ&€Hô 
)¨×	4Õ	4ß%Ö%Ø%÷  Dð  D¬#¬g°jÐBcÐefÓ.g×.lÐ.lÐklÓ*mð  rDñ  +DˆD÷ &çÜ�N‰NðOØPbôð ÷ 
5Ñ	4ð .°Ô9Ø.°eÓ;Ø/°4Ó7¼tÀHÇLÁLÐQkÐmrÓDs×?tÒ?tä& zÐ=[ÔtØ#Ÿ>™>Ö+‰KˆDÜ�J eÖ,ñ ,÷% 
5Ñ	4ß%×%ú÷ 
5×	4Ð	4ús7   Á#EÁ2#E 	Â
E 	Â EÂ0EÃA%EÅ EÅEÅE$	c               ó$   € V ^8„  d   QhRRRRRR/# )r#   rl   r   Úattempt_snapshotrm   r5   z/tuple[Optional[bool], Optional[dict[str, Any]]]r'   )r(   s   "r)   r*   r*   £  s$   € ÷ #.ñ #.Øð#.Ø'5ð#.à4ñ#.r+   c                ó°  €  ^ RI Hp \        W4      '       g   R# \        V 4      pVP	                  R4      pVP	                  R4      pVe	   V'       g   R# \        \        V4      RR4      p\        V4      '       g   R# V! WE4      p\        V\        4      '       g   \        R4      hVP                  V RR7       \        T R
R4      p	T	RJd   T	R3# \        T 4      p\         F)  p
Y£9   g   K  \        P                   ! Y:,          4      Y&   K+  	  R\        P                   ! T4      3#   \         d#   p\        P                  R	T4       Ru Rp?# Rp?ii ; i)a)  Refresh and snapshot built-in durable cooldown state under the lease.
Third-party compressors are not invoked: plugin code must not run under the lease. Returns ``False`` on
durable read failure (rollback must not mistake unknown state for an empty row) and ``None`` when the
legacy API is absent.©ÚContextCompressorNr´   rµ   Ú$get_compression_failure_cooldown_rowz3raw compression cooldown snapshot must be a mappingT)Úrefreshz5authoritative compression cooldown capture failed: %sÚ(_last_cooldown_refresh_was_authoritative©NN©FN)r9   rÜ   r:   ro   rž   rI   r¼   r½   r<   rp   Ú'get_active_compression_failure_cooldownr.   r/   r0   Ú!_COMPRESSOR_COOLDOWN_STATE_FIELDSrr   rs   )rl   rÙ   rÜ   rt   rÃ   rÄ   Ú
raw_readerr±   r1   r¯   ru   s   &&         r)   Ú+_capture_authoritative_cooldown_under_leaserå   £  s;  € ðÝ>Ü˜*×8Ò8ØÐÜ�jÓ!ˆØ—Z‘Z Ó.ˆ
Ø—Z‘Z Ó.ˆ
ØÒ§ZàÐÜœT *Ó-Ð/UÐW[Ó\ˆ
Ü˜
×#Ò#ØÐá" :Ó:ˆÜ˜-¬×.Ò.ÜÐQÓRÐRØ×AÑAÀ*ÐVZÐAÔ[ô ˜JÐ(RÐTXÓY€MØ˜DÓ Ø˜dÐ"Ð"Ü�*Ó€Fß1ˆØŽ>Ü%)§]¢]°6µ<Ó%@ÐÓ"ñ 2ð ”—’˜}Ó-Ð-Ð-øô ô Ü�‰ÐLÈcÔRØÕûðús4   ‚D( ›8D( ÁD( Á(D( Á?<D( Ä(EÄ3EÅ
EÅEc                  óŽ  € ] tR tRtRtR7R R lltR R ltR R	 ltR
 R ltR R lt	]
R R l4       t]
R R l4       t]
R R l4       tR R ltR7R R lltR R ltR7R R lltR R lt]
R R l4       t]
R  R! l4       tR" R# ltR$ R% lt]
R& R' l4       tR( R) ltR* R+ ltR, R- ltR. R/ ltR0 R1 ltR2 R3 ltR4 R5 ltR6tR# )8ÚCompressionCommitFenceiÉ  a  Fence timeout cancellation against post-summary session mutation.
The sync worker thread cannot be killed; the fence makes the commit boundary deterministic: cancellation
wins before mutation starts, or waits for an already-started commit to finish completely.Nc               ó    € V ^8„  d   QhRRRR/# )r#   Útotal_ceiling_secondsúfloat | Noner5   rE   r'   )r(   s   "r)   r*   Ú#CompressionCommitFence.__annotate__Î  s   € ÷ #Bñ #B¨lð #BÀdñ #Br+   c                	ó‚  € \         P                  ! 4       V n        R V n        R V n        \         P
                  ! 4       V n        R V n        \         P                  ! 4       V n        RV n	        R V n
        \        P                  ! 4       V n        R V n        RV n        R V n        R V n        Ve   V P%                  V4       R# R# rá   )r   r€   Ú_lockÚ
_cancelledÚ_commit_startedÚEventÚ_commit_phaseÚ_admission_revokedÚ_lock_release_guardÚ_cancelled_lock_releaseÚ!_cancelled_lock_release_requestedrÁ   rÂ   Ú_last_progressÚ_progress_observedÚ	_deadlineÚ(_retain_cancelled_lock_until_worker_doneÚ_commit_watermark_fencedÚset_total_ceiling_seconds)Úselfré   s   &&r)   Ú__init__ÚCompressionCommitFence.__init__Î  s£   € Ü—^’^Ó%ˆŒ
ØˆŒØ$ˆÔô 'Ÿ_š_Ó.ˆÔð #(ˆÔô $-§>¢>Ó#3ˆÔ ØEIˆÔ$Ø16ˆÔ.ä"ŸnšnÓ.ˆÔØ"'ˆÔØ'+ˆŒØ8=ˆÔ5à(-ˆÔ%Ø Ò,Ø×*Ñ*Ð+@ÖAñ -r+   c               ó    € V ^8„  d   QhRRRR/# )r#   Úsecondsr¿   r5   rE   r'   )r(   s   "r)   r*   rë   ó  s   € ÷ 4ñ 4°ð 4¸4ñ 4r+   c                ó‚   € \        V4      pV^ 8:  d   \        R4      h\        P                  ! 4       V,           V n        R# )z:Arm the wall-clock deadline shared by the host and worker.z*total compression ceiling must be positiveN)r¿   Ú
ValueErrorrÁ   rÂ   rø   )rü   r   s   &&r)   rû   Ú0CompressionCommitFence.set_total_ceiling_secondsó  s1   € ä˜“.ˆØ�aŒ<ÜÐIÓJÐJÜŸšÓ)¨GÕ3ˆŽr+   c               ó    € V ^8„  d   QhRRRR/# )r#   rÆ   r¿   r5   rE   r'   )r(   s   "r)   r*   rë   ú  s   € ÷ "ñ "¸ð "À4ñ "r+   c                óL   € \        V4      pV^ 8:  d   \        R4      hWn        R# )zZArm one absolute pre-commit deadline shared across route attempts (primary + stall retry).z%compression deadline must be positiveN)r¿   r  rø   ©rü   rÆ   s   &&r)   Ú set_precommit_deadline_monotonicÚ7CompressionCommitFence.set_precommit_deadline_monotonicú  s#   € ä˜“?ˆØ�qŒ=ÜÐDÓEÐEØ!Žr+   c               ó    € V ^8„  d   QhRRRR/# )r#   r   r¿   r5   r&   r'   )r(   s   "r)   r*   rë     s   € ÷ !ñ ! uð !°ñ !r+   c                ó´  € V^ 8:  g#   V P                   P                  RR7      '       g   R#  V P                  RJ;'       d<    V P                  \        P                  ! 4       8„  ;'       d    V P
                  '       * pV'       d   V ;P                  V,          un        VV P                   P                  4        #   T P                   P                  4        i ; i)a  Push the armed deadline back by *seconds* (time llama-server spent reading the prompt). A cancelled
attempt or a passed deadline stays final, so a late progress chunk can't revive it; while a commit or a
cancellation holds the lock there is nothing to extend.F©ÚblockingN)rí   Úacquirerø   rÁ   rÂ   Úis_cancelledÚrelease)rü   r   Úalives   && r)   Úextend_deadlineÚ&CompressionCommitFence.extend_deadline  s—   € ð �aŒ<˜tŸz™z×1Ñ1¸5Ð1×AÒAÙð	!Ø—N‘N¨$Ð.×nÐn°4·>±>ÄDÇNÂNÓDTÑ3T×nÐnÐ]a×]nÑ]nÔYnˆEßØ—’ 'Õ)•Øà�J‰J×ÑÕ øˆD�J‰J×ÑÕ ús   ­B; Á)B; Á,B; ÂB; Â;Cc               ó   € V ^8„  d   QhRR/# ©r#   r5   rE   r'   )r(   s   "r)   r*   rë     s   € ÷ 'ñ ' ñ 'r+   c                óH   € \         P                  ! 4       V n        RV n        R# )zURecord forward progress (a streamed token); a bare float store is atomic, so no lock.TN)rÁ   rÂ   rö   r÷   ©rü   s   &r)   Útouch_progressÚ%CompressionCommitFence.touch_progress  s   € ä"ŸnšnÓ.ˆÔØ"&ˆÖr+   c               ó   € V ^8„  d   QhRR/# rb   r'   )r(   s   "r)   r*   rë     s   € ÷ 'ñ ' 4ñ 'r+   c                ó   € V P                   # )zAWhether semantic provider progress was reported for this attempt.)r÷   r  s   &r)   Úprogress_observedÚ(CompressionCommitFence.progress_observed  s   € ð ×&Ñ&Ð&r+   c               ó   € V ^8„  d   QhRR/# rb   r'   )r(   s   "r)   r*   rë     s   € ÷ Eñ E 4ñ Er+   c                	ób   € V P                   pVR J;'       d    \        P                  ! 4       V8¬  # ©N)rø   rÁ   rÂ   r  s   & r)   Údeadline_exceededÚ(CompressionCommitFence.deadline_exceeded  s*   € à—>‘>ˆØ˜tÐ#×DÐD¬¯ªÓ(8¸HÑ(DÐDr+   c               ó   € V ^8„  d   QhRR/# )r#   r5   rê   r'   )r(   s   "r)   r*   rë     s   € ÷ 	ñ 	 Lñ 	r+   c                ó   € V P                   # )u(  Armed deadline (absolute monotonic); the worker's stream consumer stops when the host stops waiting.

:meth:`set_total_ceiling_seconds` documents this deadline as "shared by the host and worker", but
until #99692 only the host could read it â€” ``deadline_exceeded`` answers "is it past?" for a caller
that is already polling, which is useless to a worker blocked inside a provider stream. Publishing
the instant itself lets the worker's stream consumer stop at exactly the moment the host stops
waiting (see ``auxiliary_client.aux_stream_deadline``).
)rø   r  s   &r)   Údeadline_monotonicÚ)CompressionCommitFence.deadline_monotonic  s   € ð �~‰~Ðr+   c               ó   € V ^8„  d   QhRR/# )r#   r5   r¿   r'   )r(   s   "r)   r*   rë   *  s   € ÷ @ñ @¨ñ @r+   c                ób   € \        R\        P                  ! 4       V P                  ,
          4      # )z8Seconds since the worker last reported forward progress.r¸   )rÀ   rÁ   rÂ   rö   r  s   &r)   Úseconds_since_progressÚ-CompressionCommitFence.seconds_since_progress*  s!   € ä�3œŸšÓ(¨4×+>Ñ+>Õ>Ó?Ð?r+   c               ó    € V ^8„  d   QhRRRR/# ©r#   Úcancel_eventr   r5   r&   r'   )r(   s   "r)   r*   rë   .  s   € ÷ ,ñ ,°ð ,Àñ ,r+   c                óä   € V P                   ;_uu_ 4        V P                  '       g   RV n        Ve   VP                  4        V P                  '       * uuRRR4       #   + '       g   i     R# ; i)zYCancel a pending commit (``True``), or block until an active commit finishes (``False``).TN)rí   rï   rî   Úset©rü   r,  s   &&r)   Úcancel_before_commitÚ+CompressionCommitFence.cancel_before_commit.  sH   € à�Z�Z‹ZØ×'×'Ð'Ø"&�”ØÒ'Ø× Ñ Ô"Ø×+Ñ+Ô+÷ �Z�Z‹Zús   •>AÁA/	c               ó   € V ^8„  d   QhRR/# )r#   r5   r°   r'   )r(   s   "r)   r*   rë   7  s   € ÷ 	!ñ 	!¨.ñ 	!r+   c                ó  € V P                   P                  RR7      '       g   R#  V P                  '       g   RV n        V P                  '       * V P                   P	                  4        #   T P                   P	                  4        i ; i)zZNon-blocking :meth:`cancel_before_commit`; ``None`` while an active commit owns the fence.Fr  NT)rí   r  rï   rî   r  r  s   &r)   Útry_cancel_before_commitÚ/CompressionCommitFence.try_cancel_before_commit7  sb   € à�z‰z×!Ñ!¨5Ð!×1Ò1Ùð	!Ø×'×'Ð'Ø"&�”Ø×+Ñ+Ô+à�J‰J×ÑÕ øˆD�J‰J×ÑÕ ús   ¦A* ¸A* Á*Bc               ó    € V ^8„  d   QhRRRR/# r+  r'   )r(   s   "r)   r*   rë   B  s   € ÷ ñ ¨ð ¸ñ r+   c                ó”  € V P                   P                  4        V P                  '       g6   V P                  '       g$   Vee   \	        VP                  4       4      '       dF   RV n        V P                   P                  4        V P                  '       d   V P                  4        R# RV n	        V P                  P                  4        R# )z?Atomically admit commit unless a hard cancellation already won.TF)rí   r  r  rò   r&   Úis_setrî   r  Ú"release_cancelled_compression_lockrï   rñ   r.  r/  s   &&r)   Úbegin_commitÚ#CompressionCommitFence.begin_commitB  s’   € à�
‰
×ÑÔØ××Ð × 7× 7Ð 7¸LÒ<TÔY]Ð^j×^qÑ^qÓ^s×YtÒYtØ"ˆDŒOØ�J‰J×ÑÔ Ø×&×&Ð&à×7Ñ7Ô9ÙØ#ˆÔà×Ñ×ÑÔ Ùr+   c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   rë   Q  s   € ÷ 6ñ 6˜tñ 6r+   c                ó¶   € V P                   P                  4        V P                  P                  4        V P                  '       d   V P                  4        R# R# )z8Leave a commit boundary entered by :meth:`begin_commit`.N)rñ   Úclearrí   r  rò   r9  r  s   &r)   Úfinish_commitÚ$CompressionCommitFence.finish_commitQ  sA   € à×Ñ× Ñ Ô"Ø�
‰
×ÑÔØ×"×"Ð"à×3Ñ3Ö5ñ #r+   c               ó   € V ^8„  d   QhRR/# rb   r'   )r(   s   "r)   r*   rë   Z  s   € ÷ +ñ + $ñ +r+   c                ó6   € V P                   P                  4       # )zbLock-free read: an admitted commit is in progress (hosts reach the overrun loop on a hung commit).)rñ   r8  r  s   &r)   Úcommit_in_flightÚ'CompressionCommitFence.commit_in_flightY  s   € ð ×!Ñ!×(Ñ(Ó*Ð*r+   c               ó   € V ^8„  d   QhRR/# rb   r'   )r(   s   "r)   r*   rë   _  s   € ÷ Tñ T˜dñ Tr+   c                ój   € V P                   ;'       g!    V P                  ;'       g    V P                  # )z7True after cancellation won before the commit boundary.)rî   rò   r   r  s   &r)   r  Ú#CompressionCommitFence.is_cancelled^  s*   € ð �‰×SÐS $×"9Ñ"9×SÐS¸T×=SÑ=SÐSr+   c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   rë   c  s   € ÷ =ñ =¸4ñ =r+   c                ó   € RV n         R# )z9Prevent a timed-out live worker from overlapping a retry.TN©rù   r  s   &r)   Ú)retain_compression_lock_until_worker_doneÚ@CompressionCommitFence.retain_compression_lock_until_worker_donec  s
   € à8<ˆÖ5r+   c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   rë   g  s   € ÷ 	-ñ 	-¨dñ 	-r+   c                ó   € RV n         R# )u-  Record a watermark-bounded commit (later rows survive as tail); a detached worker may keep admission.

Called by the compression worker right after it captures ``get_active_message_watermark()`` under
the durable compression lock (#75316/#87484). A watermark-fenced commit archives ONLY rows at or
below the watermark; rows appended later â€” e.g. the user turn the host released at the turn-hold
boundary (#97963) â€” are cloned as live concurrent tail. That is exactly the property a host needs
before letting a detached worker keep its commit admission.
TN©rú   r  s   &r)   Úmark_commit_watermark_fencedÚ3CompressionCommitFence.mark_commit_watermark_fencedg  s   € ð )-ˆÖ%r+   c               ó   € V ^8„  d   QhRR/# rb   r'   )r(   s   "r)   r*   rë   s  s   € ÷ -ñ -¨ñ -r+   c                ó   € V P                   # )z9Lock-free read: the worker's commit is watermark-bounded.rO  r  s   &r)   Úcommit_watermark_fencedÚ.CompressionCommitFence.commit_watermark_fencedr  s   € ð ×,Ñ,Ð,r+   c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   rë   w  s   € ÷ >ñ >¨dñ >r+   c                ó   € RV n         R# )zdUndo :meth:`retain_compression_lock_until_worker_done` once a bounded join proved the worker exited.FNrJ  r  s   &r)   Úallow_cancelled_lock_releaseÚ3CompressionCommitFence.allow_cancelled_lock_releasew  s
   € à8=ˆÖ5r+   c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   rë   {  s   € ÷ 
%ñ 
%¨ñ 
%r+   c                óð   € RV n         V P                  P                  RR7      '       d.    V P                  4        V P                  P	                  4        R# R#   T P                  P	                  4        i ; i)a+  Revoke FUTURE commit admission without blocking on the fence lock.
An in-flight commit is never abandoned (``begin_commit`` re-checks the flag under the lock). The lease
release must not run mid-commit: released now if the lock is free, else deferred to
``finish_commit``/refusal (holder-qualified).TFr  N)rò   rí   r  r9  r  r  s   &r)   Úrevoke_commit_admissionÚ.CompressionCommitFence.revoke_commit_admission{  s^   € ð
 #'ˆÔØ�:‰:×Ñ uÐ×-Ò-ð%Ø×7Ñ7Ô9à—
‘
×"Ñ"Ö$ñ	 .øð —
‘
×"Ñ"Õ$ús   «A ÁA5c               ó   € V ^8„  d   QhRR/# rb   r'   )r(   s   "r)   r*   rë   �  s   € ÷ ñ  $ñ r+   c                óº   € V P                   P                  4        V P                  '       g   V P                  '       d   V P                   P	                  4        R# R# )zbHold the fence across lock acquisition + release-hook publication so a timeout cannot win between.FT)rí   r  r  rò   r  r  s   &r)   Úbegin_lock_setupÚ'CompressionCommitFence.begin_lock_setup�  s?   € à�
‰
×ÑÔØ××Ð × 7× 7Ð 7Ø�J‰J×ÑÔ ÙÙr+   c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   rë   —  s   € ÷ ñ  4ñ r+   c                ó:   € V P                   P                  4        R# )z@Leave a lock setup boundary entered by :meth:`begin_lock_setup`.N)rí   r  r  s   &r)   Úfinish_lock_setupÚ(CompressionCommitFence.finish_lock_setup—  s   € à�
‰
×ÑÖr+   c               ó    € V ^8„  d   QhRRRR/# )r#   r  úCallable[[], None]r5   r&   r'   )r(   s   "r)   r*   rë   ›  s   € ÷ ñ Ð7Ið Èdñ r+   c                ó¨   € V P                   ;_uu_ 4        Wn        V P                  pRRR4       X'       d   V! 4        V#   + '       g   i     L!; i)zhPublish the worker's holder-qualified release; if cleanup was already requested, run it and return True.N)ró   rô   rõ   )rü   r  Ú	requesteds   && r)   Úregister_cancelled_lock_releaseÚ6CompressionCommitFence.register_cancelled_lock_release›  s=   € à×%×%Ó%Ø+2Ô(Ø×>Ñ>ˆI÷ &÷ ÙŒIØÐ÷ &×%ús   •AÁA	c               ó    € V ^8„  d   QhRRRR/# )r#   r  rg  r5   rE   r'   )r(   s   "r)   r*   rë   ¤  s   € ÷ 4ñ 4Ð4Fð 4È4ñ 4r+   c                ó–   € V P                   ;_uu_ 4        V P                  VJ d   RV n        RRR4       R#   + '       g   i     R# ; i)z>Forget ``release`` after the worker's normal cleanup finishes.N)ró   rô   ©rü   r  s   &&r)   Úclear_cancelled_lock_releaseÚ3CompressionCommitFence.clear_cancelled_lock_release¤  s3   € à×%×%Ó%Ø×+Ñ+¨wÓ6Ø/3�Ô,÷ &×%×%Ò%ús	   •7·A	c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   rë   ª  s   € ÷ ñ °Dñ r+   c                óÎ   € V P                   '       d   R# V P                  ;_uu_ 4        RV n        V P                  pRRR4       Xe
   V! 4        R# R#   + '       g   i     L; i)zdAfter cancellation won: release the worker's lock (a request ahead of hook publication is retained).NT)rù   ró   rõ   rô   rn  s   & r)   r9  Ú9CompressionCommitFence.release_cancelled_compression_lockª  sP   € à×8×8Ð8ÙØ×%×%Ó%Ø59ˆDÔ2Ø×2Ñ2ˆG÷ &ð ÒÙŽIñ ÷ &×%ús   ©AÁA$	)rò   rî   rô   rõ   rñ   rï   rú   rø   rö   rí   ró   r÷   rù   r  ) Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rý   rû   r  r  r  Úpropertyr  r   r$  r(  r0  r4  r:  r?  rC  r  rK  rP  rT  rX  r\  r`  rd  rj  ro  r9  Ú__static_attributes__r'   r+   r)   rç   rç   É  së   † ña÷#BõJ4õ"õ!õ'ð
 ô'ó ð'ð ôEó ðEð ô	ó ð	õ@÷,õ	!÷õ6ð ô+ó ð+ð ôTó ðTõ=õ	-ð ô-ó ð-õ>õ
%õ(õõõ4÷ñ r+   rç   Ústall_interruptedg      >@g      @c               ó$   € V ^8„  d   QhRRRRRR/# )r#   Úfuturer   Úgrace_secondsr¿   r5   r&   r'   )r(   s   "r)   r*   r*   É  s!   € ÷ ñ  3ð °uð Àñ r+   c                óÔ  € Rp\         P                  ! \        \        4      ;_uu_ 4        \	        \        V4      R4      pRRR4        V P                  VR7       R#   + '       g   i     L%; i  \        P                  P                   d    T P                  4       u # \        P                  P                   d     R# \         d    \        P                  RRR7        R# i ; i)zýBest-effort bounded join of a fence-cancelled compression worker.
Returns True when the future settled within ``grace_seconds`` (thread provably exited); False for a
still-running worker, which the caller must treat as an orphan behind the poison fence.r¸   N©ÚtimeoutTz5cancelled compression worker exited with an exceptionr-   )r�   r’   rp   r  rÀ   r¿   ÚresultÚ
concurrentÚfuturesÚTimeoutErrorÚdoneÚCancelledErrorr.   r/   r0   )r}  r~  Úgraces   && r)   Ú_join_cancelled_workerr‰  É  s¯   € ð €EÜ	×	Ò	œY¬
×	3Õ	3Ü”E˜-Ó(¨#Ó.ˆ÷ 
4ðØ�‰˜eˆÔ$Ù÷	 
4×	3ûô
 ×Ñ×*Ñ*ô ð �{‰{‹}ÒÜ×Ñ×,Ñ,ô âÜô ä�‰ÐLÐW[ˆÔ\Úðús5   ªAÁ	A0 ÁA-	Á0/C'Â!C'Â>C'ÃC'ÃC'Ã&C'c               ó   € V ^8„  d   QhRR/# rb   r'   )r(   s   "r)   r*   r*   ñ  s   € ÷ ñ  Dñ r+   c                 ó¬   € \         ;_uu_ 4        \        \        8¼  d    RRR4       R# \        ^,          s RRR4       R#   + '       g   i     R# ; i)z9Reserve one bounded compression-pool admission slot (F6).NFT)Ú_compress_admission_lockÚ_compress_admitted_countÚ_COMPRESS_EXECUTOR_MAX_WORKERSr'   r+   r)   Ú_try_admit_compression_jobr�  ñ  s=   € ÷ 
"Ö	!Ü#Ô'EÔEØ÷ 
"Ñ	!ô 	! AÕ%Ð Ø÷	 
"×	!×	!Ò	!ús   �AªAÁA	c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   r*   û  s   € ÷ *ñ *°Dñ *r+   c                óŒ   € \         ;_uu_ 4        \        ^ 8”  d   \        ^,          sRRR4       R#   + '       g   i     R# ; i)z?Free an admission slot (future done-callback or failed submit).N)rŒ  r�  )Ú_futures   &r)   Ú_release_compression_admissionr“  û  s,   € ÷ 
"Ö	!Ü# aÔ'Ü$¨Õ)Ð$÷ 
"×	!×	!Ò	!ús	   �2²A	c                 ó¸   € \         p V e   V # ^ RIHp \        ;_uu_ 4        \         f   V! \        RR7      s \         uuRRR4       #   + '       g   i     R# ; i)zBReturn the process-wide compress-timeout DaemonThreadPoolExecutor.N)ÚDaemonThreadPoolExecutorzcompress-ctx-timeout)Úmax_workersÚthread_name_prefix)Ú_compress_timeout_executorÚtools.daemon_poolr•  Ú_compress_timeout_executor_lockrŽ  )Úexecutorr•  s     r)   Ú_get_compress_timeout_executorrœ    sH   € ô *€HØÒØˆÝ:ß	(Ö	(Ü%Ò-á)AÜ:ÐOeô*Ð&ô *÷ 
)×	(×	(Ó	(ús   ¡AÁA	Úidle_timeout_secondsc               ó(   € V ^8„  d   QhRRRRRRRR/# )	r#   Úcommit_fenceú Optional[CompressionCommitFence]Ú
started_atr¿   r�  úOptional[float]r5   r&   r'   )r(   s   "r)   r*   r*     s,   € ÷ ñ Ø5ðØCHðØ`oðà	ñr+   c                óh  € TpVf   \        4       w  r4 \        V4      pT^ 8:  d   R# T e    \        T P	                  4       4      T8¬  #  \        P                  ! 4       \        T4      ,
          T8¬  #   \        \        3 d     R# i ; i  \
         d     R# i ; i  \        \        3 d     R# i ; i)uú  Return whether a pre-commit cancel landed after the stall window.
An early ``/stop`` stays cooldown-neutral; an interrupt after the inactivity budget counts as a stall so
the next automatic turn does not blindly retry.

When the fence (or, without a fence, the attempt clock) has already sat idle for the configured
compression inactivity budget, the interrupt is a stalled attempt â€” the same condition the host timeout
uses â€” and the next automatic turn must not blindly retry that strategy (#96775).
F)r   r¿   rp   r  r(  r.   rÁ   rÂ   )rŸ  r¡  r�  ÚidleÚ_ceilings   $$$  r)   Úcompression_attempt_stalledr¦    s»   € ð  €DØ‚|Ü=Ó?‰ˆðÜ�T‹{ˆð ˆq„yÙØÒð	Ü˜×<Ñ<Ó>Ó?À4ÑGÐGðÜ—’Ó ¤5¨Ó#4Õ4¸Ñ=Ð=øô ”zÐ"ô Úðûô ô 	Úð	ûô ”zÐ"ô Úðús4   ”A2 ­B
 Á
'B Á2BÂBÂ
BÂBÂB1Â0B1c               ó(   € V ^8„  d   QhRRRRRRRR/# )r#   rD   r   ÚmessagesÚapprox_tokensrÏ   r5   r%   r'   )r(   s   "r)   r*   r*   2  s)   € ÷ >ñ > Sð >°Cð >Èð >ÐZ]ñ >r+   c                ó„  € \        V RR4      p\        VRR4      ;'       g    \        V RR4      ;'       g    Rp\        V\        4      '       d   \        V4      M^ p^ p\        P
                  ! \        \        4      ;_uu_ 4        \        T;'       g    ^ 4      pRRR4       RV RV RV 2#   + '       g   i     L; i)	z:Identity of the stalled source context + summary strategy.Úcontext_compressorNÚsummary_modelÚmodelrX   zmsgs=z:tokens=z:model=)	rI   r:   r;   Úlenr�   r’   rp   r  r†   )rD   r¨  r©  rl   r­  Ú
n_messagesrL   s   &&&    r)   Ú_stall_source_fingerprintr°  2  s¢   € ä˜Ð 4°dÓ;€JÜ�J °Ó6×]Ð]¼'À%ÈÐRVÓ:W×]Ð]Ð[]€EÜ",¨X´t×"<Ò"<”�X”À!€JØ€FÜ	×	Ò	œY¬
×	3Õ	3Ü�]×'Ð' aÓ(ˆ÷ 
4à�:�,˜h v h¨g°e°WÐ=Ð=÷ 
4×	3ús   ÂB/Â/B?	c               ó0   € V ^8„  d   QhRRRRRRRRRR	R
R/# )r#   rD   r   rŸ  r   r¡  r¿   r¨  r©  rÏ   r5   r&   r'   )r(   s   "r)   r*   r*   =  s>   € ÷ ñ ØðØ!AðØOTðØ`cðà ðð 
ñr+   c               ór  € \        WR7      '       g   R# \        V RR4      p\        VRR4      p\        V4      '       g   R# \         R\	        WV4       2p V! VRR7       \        P                  R\        T RR4      ;'       g    RT4       R
#   \
         d    \        P                  R	R
R7        R# i ; i)zÄPersist a stall-interrupted cooldown after snapshot restore.
Must run *after* ``_restore_compressor_attempt_state`` so rollback cannot wipe the new row. Returns True
when the backoff was recorded.)rŸ  r¡  Fr«  NÚrecord_timeout_failureÚ:r{  )Úfailure_kindz5stall-interrupted compression cooldown persist failedTr-   z?Recorded stall-interrupted compression backoff (session=%s, %s)rÄ   Únone)	r¦  rI   r½   ÚSTALL_INTERRUPTED_FAILURE_CLASSr°  r.   r/   r0   rg   )rD   rŸ  r¡  r¨  r©  rl   ÚrecordÚerrors   &$$$$   r)   Ú!_record_stall_interrupted_backoffrº  =  sÁ   € ô '°L×XÓXÙÜ˜Ð 4°dÓ;€Jô �ZÐ!9¸4Ó@€FÜ�F×ÒÙÜ.Ð/¨qÔ1JÈ5Ð\iÓ1jÐ0kÐl€EðÙˆuÐ#6Õ7ô ‡K�KØIÌ7ÐSXÐZfÐhlÓKm×KwÐKwÐqwØôñ øô ô Ü�‰ÐLÐW[ˆÔ\Úðús   Á
B Â"B6Â5B6c               ó   € V ^8„  d   QhRR/# )r#   r5   zOptional[dict]r'   )r(   s   "r)   r*   r*   Y  s   € ÷ &ñ &¨Nñ &r+   c                 ó  €  ^ RI Hp Hp V! R4      P                  R4      p\        T\        4      '       g   R# \        T4       EFg  w  r4\        T\        4      '       g   K  \        TP                  R4      ;'       g    R	4      P                  4       p\        TP                  R
4      ;'       g    R	4      P                  4       pT'       d	   T'       g   K”   T ! T4      p^ RI Hp T! TP                  R4      4      p	RRT RT R2RTR
TR\        TP                  R4      ;'       g    R	4      P                  4       ;'       g    RRT;'       g    RR\        TP                  R4      ;'       g    TP                  R4      ;'       g    R	4      P                  4       ;'       g    RRT	/u # 	  R#   \         d    \
        P                  RRR7        R# i ; i  \         d    \
        P                  RTRR7       Rp EL"i ; i)as  Return the first usable ``auxiliary.compression.fallback_chain`` entry.
The aux client applies the chain only from its exception handler, so a silent stall never reaches it; this
pins the route onto one bounded retry instead. Only the first complete entry: if it errors, the aux
client's own exception path walks the rest. ``None`` when none is usable (skip compression).)Ú_fallback_entry_api_keyÚ_get_auxiliary_task_configÚcompressionÚfallback_chainz(compression fallback_chain lookup failedTr-   NÚproviderrX   r­  z8compression fallback_chain[%d] api key resolution failed)Ú_coerce_positive_timeoutr�  Úlabelzfallback_chain[z](Ú)Úbase_urlÚapi_keyÚapi_modeÚ	transport)Úagent.auxiliary_clientr½  r¾  rž   r.   r/   r0   r:   r;   Ú	enumerater<   r%   r[   rÂ  )
r½  r¾  ÚchainÚindexÚentryrÁ  r­  rÆ  rÂ  r�  s
             r)   Ú"resolve_compression_fallback_routerÎ  Y  sÃ  € ð
ß^Ù*¨=Ó9×=Ñ=Ð>NÓOˆô �eœT×"Ò"ÙÜ! %×(‰ˆÜ˜%¤×&Ò&ÙÜ�u—y‘y Ó,×2Ð2°Ó3×9Ñ9Ó;ˆÜ�E—I‘I˜gÓ&×,Ð,¨"Ó-×3Ñ3Ó5ˆ÷ ŸuÙð	Ù-¨eÓ4ˆGõ 	DÙ*¨5¯9©9°YÓ+?Ó@ˆà� u g¨R°¨z¸Ð;Ø˜Ø�UØœ˜EŸI™I jÓ1×7Ð7°RÓ8×>Ñ>Ó@×HÐHÀDØ�w—� $Øœ˜EŸI™I jÓ1×QÐQ°U·Y±Y¸{Ó5K×QÐQÈrÓR×XÑXÓZ×bÐbÐ^bØ�wð
ò 	
ñ! )ñ2 øô= ô Ü�‰Ð?È$ˆÔOÚðûô  ô 	Ü�L‰LÐSÐUZÐeiˆLÔjØ‹Gð	ús#   ‚F2 ÃGÆ2"GÇGÇ%HÈHc               ó    € V ^8„  d   QhRRRR/# )r#   Úescalate_deterministicr&   r5   r;   r'   )r(   s   "r)   r*   r*   ‚  s   € ÷ ñ °ð ¸ñ r+   c                óž   € \        4       3 Uu. uF
  qf   K  VNK  	  ppV '       d!   ^ RIHp VP                  \	        V4      4       V# u upi )z¿Pinned routes for the stall retry, in order: the configured chain entry, then (only once a
stall-class backoff has already burned a window in this session) the deterministic fallback summary.)ÚDETERMINISTIC_SUMMARY_ROUTE)rÎ  r9   rÒ  Úappendr<   )rÐ  ÚrouteÚroutesrÒ  s   &   r)   Ú_stall_retry_routesrÖ  ‚  sF   € ô #EÓ"FÑ!HÓ^Ñ!H˜�eˆeÑ!H€FÐ^ßÝHØ�‰”dÐ6Ó7Ô8Ø€Mùò	 _s
   ŽA
˜A
c               ó    € V ^8„  d   QhRRRR/# )r#   rD   r   r5   r†   r'   )r(   s   "r)   r*   r*   Œ  s   € ÷ Rñ R 3ð R¨3ñ Rr+   c                ó’   € \        \        V RR4      R^ 4      p\        V\        4      '       d   \        V\        4      '       g   V# ^ # )zZTimeout-class failures this session that no healthy summary has cleared yet (type-pinned).r«  NÚ_consecutive_timeout_failures)rI   r:   r†   r&   )rD   Úcounts   & r)   Ú_prior_timeout_failuresrÛ  Œ  s@   € ä”G˜EÐ#7¸Ó>Ð@_ÐabÓc€EÜ˜u¤c×*Ò*´:¸eÄT×3JÒ3Jˆ5ÐQÐPQÐQr+   c               ó$   € V ^8„  d   QhRRRRRR/# )r#   rD   r   Úrequest_tokensr5   r°   r'   )r(   s   "r)   r*   r*   ’  s!   € ÷ 	#ñ 	#¨ð 	#¸Sð 	#À^ñ 	#r+   c                ó   € \        \        V RR4      RR4      p\        V\        4      '       g   \        V\        4      '       d   V^ 8:  d   R# \        V\        4      '       g   \        V\        4      '       g   R# W8„  # )a  Whether a ~``request_tokens`` request cannot be sent at all (above the model's context window).
``None`` when either side is unknown (no compressor / unresolvable window / no estimate), so callers
keep their conservative default instead of treating "unknown" as "fits".r«  NÚcontext_length)rI   r:   r&   r†   )rD   rÝ  Úwindows   && r)   Úrequest_exceeds_model_windowrá  ’  se   € ô ”W˜UÐ$8¸$Ó?ÐAQÐSWÓX€FÜ�&œ$×Ò¤z°&¼#×'>Ò'>À&ÈAÄ+ÙÜ�.¤$×'Ò'¬z¸.Ì#×/NÒ/NÙØÑ"Ð"r+   Úon_commit_overrunÚon_timeout_causeÚtelemetry_agentÚ	new_fencerÐ  c               óH   € V ^8„  d   QhRRRRRRRRR	RR
RRRRRRRRRRRRR/# )r#   Úworkerú4Callable[[CompressionCommitFence], tuple[list, str]]r¨  r;   Úsystem_prompt_fallbackr   r�  r¿   ré   Úprecommit_deadline_monotonicrâ  ú(Optional[Callable[[float, float], None]]rã  ú&Optional[Callable[[bool, bool], None]]rä  rå  ú.Optional[Callable[[], CompressionCommitFence]]rÐ  r&   r5   úOptional[tuple[list, str]]r'   )r(   s   "r)   r*   r*   ž  s   € ÷ )ñ )ØCð)ØOSð)àð)à7<ð)àUZð)ð #(ð)ð @ð	)ð
 =ð)ð
 WZð)ð >ð)ð _cð)ð  ñ)r+   c                óà   € \        VRR4      p\        \        VRR4      4      '       d   VP                  4       '       d   R# \        V
4       F  p\	        WÀWW4VWgVV	R7      pVf   K  Vu # 	  R# )ué  Re-run an aborted compression with the summary route pinned: once on the configured chain entry,
then â€” when ``escalate_deterministic`` (a stall backoff already burned one idle window this session,
#112420) â€” once with the summary LLM skipped so compress() commits its deterministic fallback summary.
Returns ``(messages, system_prompt)`` on real compression, else ``None`` and the caller degrades as
before. The entry's ``timeout`` sets the idle window. Re-runs the whole worker, so pre-compression
callbacks must be idempotent.

A summary-model retry spends only the primary's REMAINING pre-commit budget
(``precommit_deadline_monotonic``, shared with the primary attempt), so a stalled primary plus a
stalled fallback cannot each burn a full ceiling; when the budget is spent the retry is skipped. The
entry's own ``timeout`` (when declared) still sets the retry's idle window (#62452), clamped to that
remaining budget. The deterministic route makes no provider call, so it keeps its own budget: it is
the over-window last resort (#114594) and must not be starved by the routes that stalled before it.
Known limitation (accepted, #96634 review): the retry re-runs the COMPLETE worker, which repeats
memory/plugin pre-compression callbacks. Built-in callbacks are idempotent (re-reads and overwrites of
attempt-scoped state); third-party plugin callbacks are advised to be. Splitting the worker to resume
mid-pipeline would couple this path to every host's callback ordering â€” deliberately out of scope.
Ú_hard_interrupt_requestedNr8  )
rç  r¨  ré  r�  ré   rê  râ  rã  rä  rå  )rI   r½   r8  rÖ  Ú_run_pinned_compression_retry)rç  r¨  ré  r�  ré   rê  râ  rã  rä  rå  rÐ  Úhard_cancelrÔ  Ú	recovereds   $$$$$$$$$$$   r)   Ú$_retry_compression_on_fallback_chainrô  ž  sy   € ô8 ˜/Ð+FÈÓM€KÜ”˜ X¨tÓ4×5Ò5¸+×:LÑ:L×:NÒ:NÙÜ$Ð%;Ö<ˆÜ1Ø¨8Ø!5Ø)EØ/ÐdsØô
ˆ	ð Ô ØÒñ =ñ r+   c               óH   € V ^8„  d   QhRRRRRRRRR	R
RR
RR
RRRRRRRRRR/# )r#   rÔ  r<   rç  rè  r¨  r;   ré  r   r�  r¿   ré   rê  râ  rë  rã  rì  rä  rå  rí  r5   rî  r'   )r(   s   "r)   r*   r*   Ê  sŠ   € ÷ Z&ñ Z&ØðZ&ØPðZ&Ø\`ðZ&àðZ&à7<ðZ&àUZðZ&ð #(ðZ&ð @ð	Z&ð Tzð	Z&ð
 ðZ&ð
 &TðZ&ð  ñZ&r+   c       
        óâ  € V P                  R4      RJ pV'       g:   \        P                  ! 4       V8¼  d    \        P	                  RV R,          4       R# RpV
e	    V
! 4       p\        V\        4      '       g    \        P                  R4       \        4       p\        V P                  R	4      ;'       g    T4      pV'       d   \        \        V4      V4      RrþM^V\        P                  ! 4       ,
          TrþV^ 8:  d0   VP                  4        \        P	                  R
V R,          4       R# \        WÞ4      pV'       d   \        P                  RV R,          4       M&\        P                  RV R,          V R,          V4       \        V	RR4      p\        VR^ 4      p ^ RIHp V! V 4      ;_uu_ 4        \!        WVWÞVWŒV	RVR7      w  ppRRR4       XTJ d    \        P                  RT R,          4       R# \        TR^ 4      pT'       g4   \        T\"        4      '       d?   \        T\"        4      '       d)   TT8”  d"   \        P                  RT R,          4       TX3# \        P	                  RT R,          4       TX3#   \
         d    \        P                  RRR7        ELFi ; i  + '       g   i     Lè; i  \
         d$    \        P                  RT R,          RR7        R# i ; i)zaOne bounded re-run of ``worker`` with ``route`` pinned; ``None`` when it produced no compression.ÚdeterministicTzQSkipping compression stall fallback on %s: the shared pre-commit ceiling is spentrÃ  Nzœcompression stall-fallback fence factory failed; the retry will run on an unpublished fence (a /stop mid-retry cannot serialize against its commit boundary)r-   z¨compression stall-fallback retry running on an unpublished fence; hard-interrupt admission will read the aborted attempt's fence rather than the retry's commit boundaryr�  zXSkipping compression stall fallback on %s: its setup spent the shared pre-commit ceilingu�   Context compression stalled on every summary route â€” committing the %s (no summary model) before continuing without compressionu«   Context compression stalled on the configured summary route â€” retrying once on %s (%s) within %.1fs of the shared pre-commit budget before continuing without compressionr­  r«  Ú_fallback_compression_streak)Úpin_summary_routeF)rç  r¨  ré  r�  ré   râ  rã  Úfencerä  Ústall_fallbackrê  z1Context compression fallback attempt on %s failedzbContext compression fallback attempt on %s produced no compression; continuing without compressionz�Context compression committed a deterministic fallback summary on %s after the primary summary route stalled (no summary model produced output)zKContext compression recovered on %s after the primary summary route stalled)rž   rÁ   rÂ   r/   rg   r.   rÒ   r:   rç   r¿   rÀ   r\  ÚminrI   r9   rù  Ú*run_compress_context_with_progress_timeoutr†   )rÔ  rç  r¨  ré  r�  ré   rê  râ  rã  rä  rå  r÷  Úretry_fencer¤  ÚceilingrÆ   rl   Ústreak_beforerù  Úresult_msgsÚresult_promptÚstreak_afters   &$$$$$$$$$$           r)   rñ  rñ  Ê  s¬  € ð —I‘I˜oÓ.°$Ð6€MßœTŸ^š^Ó-Ð1MÔMÜ�‰Ø_ÐafÐgnÕaoô	
ñ ð €KØÒð	Ù#›+ˆKô �kÔ#9×:Ò:Ü�‰ðuô	
ô -Ó.ˆÜ�—‘˜9Ó%×=Ð=Ð)=Ó>€Dßä¤Ð&;Ó <¸dÓCÀT‘à8¼4¿>º>Ó;KÕKÐMi�Ø�aŒ<Ø×/Ñ/Ô1Ü�K‰KØjØ�g•ôñ Ü�4Ó!ˆßÜ�‰ð4Ø5:¸7µ^õ	
ô
 	�‰ð"à#(¨¥>°5¸µ>À7ô	
ô
 ˜Ð*>ÀÓE€JÜ˜JÐ(FÈÓJ€MðÝ>Ù˜u×%Õ%Ü)SØÐI_Ø%)Ð\mØ!1ÐVeØ$À8ô	*Ñ&ˆK˜÷ &ð �hÓä�‰ØpØ�'�Nô	
ñ ô ˜:Ð'EÀqÓI€Lßœ L´#×6Ò6¼:ÀmÔUX×;YÒ;YÐ^jÐmzÔ^zÜ�‰ð9Ø:?À½.ô	
ð ˜Ð%Ð%ô 	�‰ÐaÐchÐipÕcqÔrØ˜Ð%Ð%øôM ô 	Ü�N‰Nðtàð ÷ ð	ú÷R &×%ûô ô ô 	�‰ÐJÈEÐRYÍNÐeiˆÔjÚð	úsB   ÁJ Æ K  Æ6J-ÇK  Ê"J*Ê)J*Ê-J=	Ê8K  Ê=K  Ë *K.Ë-K.c               ó0   € V ^8„  d   QhRRRRRRRRRRR	R
/# )r#   r}  r   rú  rç   r¤  r¿   rÿ  Úwait_startedr5   ztuple[bool, Any]r'   )r(   s   "r)   r*   r*   '  s<   € ÷ ñ ØðØ.ðØ9>ðØINðØ^cðàñr+   c               óÀ  €  VP                   ;'       g	    WC,           \        P                  ! 4       ,
          pV^ 8:  d   R# VP                  4       p\	        \        W&,
          R4      V4      p RV P                  VR7      3#   \        P                  P                   d½    T P                  4       '       dC   T P                  4       pTf   RT P                  4       3u # \        P                  RT4       Ru # \        P                  ! 4       T,
          p	TP                  4       pTP                  '       g"   Yb8  d   \        P                  RY–T4        EKW  Ru # i ; i)zTPoll ``future`` under the idle budget + ceiling; ``(True, result)`` when it settled.Tg{®Gázt?r€  uC   Context compression worker exited with %r â€” taking the stall pathul   Context compression still streaming after %.0fs (last progress %.1fs ago) â€” extending wait (ceiling %.0fs)rá   )r$  rÁ   rÂ   r(  rü  rÀ   r‚  rƒ  r„  r…  r†  Ú	exceptionr/   rg   r   )
r}  rú  r¤  rÿ  r  Úremaining_ceilingÚsince_progressÚ
wait_slicer1   Úwaiteds
   &&$$$     r)   Ú_await_worker_within_budgetr  '  s/  € ð à"×5Ñ5×OÐO¸Õ9OÔSW×SaÒSaÓScÕcÐØ Ô!ØÐà×5Ñ5Ó7ˆÜœ˜TÕ2°EÓ:Ð<MÓNˆ
ð	Ø˜Ÿ™¨z˜Ó:Ð:Ð:øÜ×!Ñ!×.Ñ.ô 	ð �{‰{�}Š}Ø×&Ñ&Ó(�Ø’;Ø §¡£Ð0Ò0Ü—‘ÐaÐcfÔgØ"Ò"Ü—^’^Ó%¨Õ4ˆFØ"×9Ñ9Ó;ˆNØ×*×*Ð*¨~Ô/DÜ—‘ð CØ¨Gôó ØÒð#	ús0   Á.B Â4EÂ7&EÃEÃ9=EÄ7EÅEÅEc          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )	r#   r}  r   rÿ  r¿   r  râ  rë  r5   r'   )r(   s   "r)   r*   r*   I  s4   € ÷ $ñ $Øð$Ø"ð$Ø27ð$ØLtð$àñ$r+   c               ój  € Rp^ p \         P                  ! 4       V,
          pW,
          pV^ 8:  d�   \        \        \	        VR4      4      pV^,          pV^8:  d   \
        P                  M\
        P                  pV! RWa,
          VV4       V'       g-   Ve)   Rp\        RRR7      ;_uu_ 4        V! Wa4       RRR4        V P                  VR7      #   + '       g   i     L#; i  \        P                  P                   d.    T P                  4       '       d   T P                  4       u #  EK,  i ; i)	zâbegin_commit won the race: the SessionDB mutation cannot be fence-cancelled, so wait
in bounded slices, logging (escalating) + surfacing once via ``on_commit_overrun``
WHILE the commit hangs. Never silently hung or abandoned.
FTçš™™™™™©?uÕ   Context compression SessionDB commit still running %.1fs past the total ceiling (waited %.1fs, ceiling %.1fs); commit cannot be abandoned mid-flight â€” continuing to wait (check SessionDB health if this persists)Nz/compress_context commit-overrun callback failedr-   r€  )rÁ   rÂ   rü  Ú"_COMMIT_OVERRUN_WAIT_SLICE_SECONDSrÀ   r/   rÒ   r¹  r2   r‚  rƒ  r„  r…  r†  )	r}  rÿ  r  râ  Úoverrun_surfacedÚoverrun_reportsr  rÇ   Úlogs	   &$$$     r)   Ú_await_in_flight_commitr  I  s  € ð ÐØ€OØ
Ü—’Ó! LÕ0ˆØÕ$ˆ	Ø˜Œ>äÔ>ÄÀGÈTÓ@RÓSˆIØ˜qÕ ˆOØ$3°qÔ$8”&—.’.¼f¿l¹lˆCÙðOàPVÕP`ÐbhØô	÷ $Ð(9Ò(EØ#'Ð ÜÐOÐZ^×_Ö_Ù% fÔ6÷ `ð		Ø—=‘=¨�=Ó3Ð3÷ `×_ûô ×!Ñ!×.Ñ.ô 	ð �{‰{�}Š}Ø—}‘}“Ò&ó ð	ús$   Â/	CÃC& ÃC#	Ã&4D2ÄD2Ä1D2c               ó    € V ^8„  d   QhRRRR/# )r#   rú  rç   r5   r&   r'   )r(   s   "r)   r*   r*   p  s   € ÷ ñ Ð"8ð ¸Tñ r+   c                óˆ   €  V P                   '       d   R# V P                  4       pVe   V# \        P                  ! R4       KC  )zSCancel pre-commit; ``False`` when an admitted commit owns the fence (caller waits).Fgš™™™™™™?)rC  r4  rÁ   Úsleep)rú  Ú	cancelleds   & r)   Ú_cancel_or_join_workerr  p  s>   € à
ð ×!×!Ð!ÙØ×2Ñ2Ó4ˆ	ØÒ ØÐô 	�
Š
�5Ör+   c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R
/# )r#   r}  r   rú  rç   Útotal_exhaustedr&   rÿ  r¿   r5   rE   r'   )r(   s   "r)   r*   r*     s4   € ÷ /ñ /Øð/Ø.ð/ØDHð/ØSXð/à	ñ/r+   c               óÆ   € V'       dI   \        \        V4      p\        W4      '       d   VP                  4        M\        P                  RV4       VP                  4        R# )aE  Idle-timeout unwind: free the worker's durable lease via the holder-qualified hook.
Total-ceiling only: bounded grace for the worker to exit (it checks the fence between provider phases; an
uninterruptible call is orphaned). Idle-stall skips the join: the worker is hung, the fallback needs a
prompt return, the fence guards.uÛ   Cancelled compression worker did not exit within %.1fs grace â€” orphaning it behind the poison fence (late result will be discarded); retaining the session compression lease until it exits so no new attempt overlaps itN)rü  Ú(_CANCELLED_WORKER_TEARDOWN_GRACE_SECONDSr‰  rX  r/   rÒ   r9  )r}  rú  r  rÿ  rˆ  s   &&$$ r)   Ú_release_cancelled_workerr    sP   € ÷ ÜÔ<¸gÓFˆÜ! &×0Ò0ð ×.Ñ.Õ0ä�N‰NðQàRWôð
 
×,Ñ,Ö.r+   Ú
on_timeoutrú  rû  TÚfallback_workerÚrequest_exceeds_windowrê  c                óX   € V ^8„  d   QhRRRRRRRRR	RR
RRRRRRRRRRRRRRRRRRRRR/# )r#   rç  rè  r¨  r;   ré  r   r�  r¿   ré   r  z/Optional[Callable[[float, float, float], None]]rã  rì  râ  rë  rú  r   rä  rû  r&   rå  rí  r   z>Optional[Callable[[CompressionCommitFence], tuple[list, str]]]r!  rê  r¢  r5   útuple[list, str]r'   )r(   s   "r)   r*   r*   •  s»   € ÷ J,ñ J,ØCðJ,ØOSðJ,àðJ,à7<ðJ,àUZðJ,ð @ðJ,ð =ð	J,ð
 @ðJ,ð ,ðJ,ð FIðJ,ð bfðJ,ð >ðJ,ð TðJ,ð !ðJ,ð #2ðJ,ð ñJ,r+   c                ó,  a aaaaaaa	a
aaaaaaaa€ V^ 8:  d   \        R4      hR V3R llo\        \        V4      \        V4      4      o\        V4      oV'       d   So\        P                  ! 4       oSf   SS,           oML\        S\        S4      S,
          4      oS^ 8:  d   Se   SP                  4        SS! 4       3# \        SS4      oSe   SM	\        4       oSP                  S4       S
;'       d    T;'       g    \        S	4      ^8¬  o^ RI
Hp \        4       p\        4       '       gL   \        P                  R\         4       S	e%   \#        S	\        P                  ! 4       RRRR	R
7       SS! 4       3# R VV 3R llp VP%                  V! V4      S4      pTP+                  \(        4       R	pR T3R llpR TTTTTTTTTTTTT
TT	TT 3R llp \-        TSSSSR7      w  ppT'       d›   RpS
'       dv   SP.                  '       dd   T! T4      '       dV   Se2   \1        RRR7      ;_uu_ 4        S! RSP2                  4       RRR4       T! 4       T'       g   SP                  4        # # TT'       g   SP                  4        # # TP5                  4        SP.                  pT'       d   SP7                  4        Se2   \1        RRR7      ;_uu_ 4        S! TSP2                  4       RRR4       \9        S4      '       g~   \;        T\        SSP<                  S,
          4      SSR7      pRpS
'       d/   T! T4      '       d!   T! 4       T'       g   SP                  4        # # TT'       g   SP                  4        # # Rp\?        TSTSR7       T! 4       T'       g   SP                  4        # #   \&         d    \)        4        h i ; i  + '       g   i     ELŽ; i  + '       g   i     Lý; i  T'       g   SP                  4        i i ; i)ut  Run ``worker(fence)`` under a sync progress-aware (idle + ceiling) timeout.
Budgets bound the PRE-commit phase only: an admitted commit always completes (overrun logged, surfaced
once via ``on_commit_overrun``). A pre-commit cancel returns ``(messages, system_prompt_fallback)`` (lazy
callable), detaching the worker; a stall first retries the chain once on ``new_fence``, then on_timeout.
``request_exceeds_window``: the request this compaction must shrink is above the model's context
window, so "continue without compression" is not an option â€” a stall escalates to the deterministic
fallback summary on the FIRST timeout instead of waiting for a prior stall in the session (#114594).
``precommit_deadline_monotonic``: an absolute deadline inherited from an earlier attempt (the stall
retry passes the primary's), clamping this attempt's ceiling so the attempts share one budget.zwrun_compress_context_with_progress_timeout requires idle_timeout_seconds > 0; call compress_context directly to disablec               ó   € V ^8„  d   QhRR/# )r#   r5   r%   r'   )r(   s   "r)   r*   Ú@run_compress_context_with_progress_timeout.<locals>.__annotate__°  s   € ÷ hñ h cñ hr+   c                 ó8   <€ \        S 4      '       d   S ! 4       # S # r  )r½   )ré  s   €r)   Ú_resolve_fallback_promptÚLrun_compress_context_with_progress_timeout.<locals>._resolve_fallback_prompt°  s   ø€ Ü+3Ð4J×+KÒ+KÑ%Ó'ÐgÐQgÐgr+   N)Úpropagate_context_to_threaduþ   Context compression pool saturated (%d workers busy) â€” refusing new compression this cycle and continuing without compression. Wedged workers are fence-cancelled and free their slot when they return; if this persists, check the summary provider health.ÚabortedÚpool_saturatedF)r¡  Úcommit_statusÚsplit_statusÚfailure_classÚinclude_last_telemetryc               ó   € V ^8„  d   QhRR/# )r#   Úworker_fencerç   r'   )r(   s   "r)   r*   r&  è  s   € ÷ $ñ $Ð*@ñ $r+   c                óÌ   <€ V P                   '       d    \        P                  P                  R 4      hV P                  '       d   \
        P                  R4       SR3# S! V 4      # )z0compression deadline expired before worker startz<Skipping stale compression job: fence cancelled before startrX   )r   rƒ  r„  r…  r  r/   rg   )r2  r¨  rç  s   &€€r)   Ú_fence_gated_workerÚGrun_compress_context_with_progress_timeout.<locals>._fence_gated_workerè  sW   ø€ ð ×)×)Ð)Ü×$Ñ$×1Ñ1Ð2dÓeÐeØ×$×$Ð$Ü�K‰KÐVÔWØ˜R�<ÐÙ�lÓ#Ð#r+   c               ó    € V ^8„  d   QhRRRR/# )r#   r‚  r   r5   r&   r'   )r(   s   "r)   r*   r&  þ  s   € ÷ %ñ % sð %¨tñ %r+   c                ó   <€ V ^ ,          SJ # )é    r'   )r‚  r¨  s   &€r)   Ú_is_unchanged_snapshotÚJrun_compress_context_with_progress_timeout.<locals>._is_unchanged_snapshotþ  s   ø€ à�a�y˜HÐ$Ð$r+   c               ó   € V ^8„  d   QhRR/# )r#   r5   z tuple[list[dict[str, Any]], str]r'   )r(   s   "r)   r*   r&    s   € ÷ 4ñ 4Ð!Añ 4r+   c                 óž  <€ \         P                  ! 4       S,
          p SP                  4       pS'       d;   \        S;'       g    SS	SSSSP                  ;'       g    SSSSS
SR7      pVe   V# Se)   \        RRR7      ;_uu_ 4        S! SW4       RRR4       M\        P                  RWS4       S	S! 4       3#   + '       g   i     L; i)z¹One stall-fallback ladder for every host-side stall exit (idle timeout, settled-at-deadline
no-op, post-cancel unchanged commit): retry chain, then on_timeout, then the degraded prompt.)rç  r¨  ré  r�  ré   rê  râ  rã  rä  rå  rÐ  Nz(compress_context timeout callback failedTr-   zpContext compression made no progress for %.1fs (total wait %.1fs, ceiling %.1fs); continuing without compression)rÁ   rÂ   r(  rô  r$  r2   r/   rÒ   )r  r	  ró  r(  rÿ  rÐ  r   rú  r¤  r¨  rå  râ  r  rã  rê  rû  ré  rä  r  rç  s      €€€€€€€€€€€€€€€€€r)   Ú_recover_from_stallÚGrun_compress_context_with_progress_timeout.<locals>._recover_from_stall  sÐ   ø€ ô —’Ó! LÕ0ˆØ×5Ñ5Ó7ˆ÷ Ü<Ø&×0Ð0¨&¸8Ð\rØ%)Àà-2×-EÑ-E×-eÐ-eÐIeØ"3Ø!1À?Ð^gØ'=ôˆIð Ò$Ø Ð ØÒ!ÜÐDÈt×TÖTÙ˜4 Ô8÷ UÐTô �N‰NðØ-°wôð Ñ1Ó3Ð3Ð3÷ U×Tús   Â	
B<Â<C	)r¤  rÿ  r  Tz.compress_context timeout-cause callback failedr-   )rÿ  r  râ  )r  rÿ  ) r  rÀ   r¿   rÁ   rÂ   rü  r\  rç   r  rÛ  Útools.thread_contextr*  rœ  r�  r/   rÒ   rŽ  r   ÚsubmitÚBaseExceptionr“  Úadd_done_callbackr  r   r2   r  ÚcancelrK  r  r  r$  r  )rç  r¨  ré  r�  ré   r  rã  râ  rú  rä  rû  rå  r   r!  rê  r*  r›  r4  r}  Úhandled_exitr9  r=  Úsettledr‚  r  r(  rÿ  rÐ  r¤  r  s   ddd$$dddddddd$d          @@@@@r)   rý  rý  •  sÙ  ÿÿø€ ð* ˜qÔ ÜðRó
ð 	
÷
hð hô ”%Ð-Ó.´Ð6JÓ0KÓL€GÜÐ%Ó&€D÷ ØˆÜ—>’>Ó#€LØ#Ò+Ø'3°gÕ'=Ñ$ä�gœuÐ%AÓBÀ\ÕQÓRˆØ�aŒ<ØÒ Ø×-Ñ-Ô/ØÑ5Ó7Ð7Ð7Ü�4˜Ó!ˆØÒ&‰EÔ,BÓ,D€EØ	×*Ñ*Ð+GÔHð
 ,÷ ð Ø×OÐOÔ"9¸/Ó"JÈaÑ"Oð õ
 AÜ-Ó/€Hô &×'Ò'Ü�‰ðZô +ô		
ð Ò&Ü/Ø¬D¯NªNÓ,<ÈIÐdmØ.Àuõð Ñ1Ó3Ð3Ð3÷$ñ $ðØ—‘Ñ!<Ð=PÓ!QÐSXÓYˆð ×ÑÔ;Ô<ð €L÷%ð %÷4÷ 4÷ 4ð 4ð@=,Ü5Ø�E ¨gÀLô
‰ˆ�÷ ØˆL÷
  %×"9×"9Ð"9Ñ>TÐU[×>\Ò>\Ø#Ò/Ü!Ð"RÐ]a×bÖbÙ(¨¨u×/FÑ/FÔG÷ cá*Ó,÷X ð ×)Ñ)Õ+ð ðW ÷V ð ×)Ñ)Õ+ð ðO 	�‰ŒØ×1Ñ1ˆ÷ ð ×;Ñ;Ô=ØÒ'ÜÐJÐUY×ZÖZÙ  °%×2IÑ2IÔJ÷ [ä% e×,Ò,Ü,Ø¤ G¨U×-EÑ-EÈÕ-TÓ UÐdpØ"3ô5ˆFð  ˆL÷ Ñ"8¸×"@Ò"@Ù*Ó,÷ ð ×)Ñ)Õ+ð ð ÷ ð ×)Ñ)Õ+ð ð ˆÜ! &¨%ÀÐZaÕbñ #Ó$çð ×)Ñ)Õ+ð øôM ô Ü&Ô(Øðú÷p c×bÐbú÷, [×Zû÷0 ð ×)Ñ)Õ+ð ús   ÆN7 Ç$O8 Ç?O8 ÈO8 ÈO8 È8OÉO8 É4O8 Ê#O8 Ê3)O8 ËO%Ë0AO8 ÍO8 Í+O8 ÎO8 Î7OÏO"	Ï	O8 Ï%O5	Ï0O8 Ï8P)Ú_checkpoint_blockedÚ_checkpoint_incapablec               ó    € V ^8„  d   QhRRRR/# )r#   Úlock_dbr   r5   r&   r'   )r(   s   "r)   r*   r*   e  s   € ÷ ñ ¨sð °tñ r+   c                ó¦   €  ^ RI Hp \        4       p\        V 4      VJ ;'       d    \        P
                  ! VRV4      VJ #   \         d     R# i ; i)zäWhether the live in-memory SessionDB class structurally predates locks.
Only the exact old ``hermes_state.SessionDB`` class (hot-reload skew) may fail open; proxies, lookalikes,
non-callables and descriptor failures fail closed.)Ú	SessionDBÚtry_acquire_compression_lockF)Úhermes_staterK  Úobjectr¼   ÚinspectÚgetattr_staticr.   )rI  rK  Úmissings   &  r)   Ú!_lock_api_is_absent_on_session_dbrR  e  s\   € ðÝ*Ü“(ˆä�‹M˜YÐ&÷ fð fÜ×&Ò& yÐ2PÐRYÓZÐ^eÐeð	
øô ô Úðús   ‚#A ¦A ÁAÁAÚinclude_cooldownc               ó$   € V ^8„  d   QhRRRRRR/# )r#   rl   r   rS  r&   r5   rE   r'   )r(   s   "r)   r*   r*   t  s(   € ÷ Xñ X°cð XÐPTð XÐ`dñ Xr+   c               ó,  € R/ 3R/ 3.pV'       d   VP                  ^ RRR/34       V F8  w  r4\        \        V 4      VR4      p\        V4      '       g   K.   V! V 3/ VB  K:  	  R#   \         d"   p\
        P                  RY64        Rp?Ke  Rp?ii ; i)zFRefresh durable automatic-compression guards on a built-in compressor.Ú!_load_fallback_compression_streakÚ#_load_ineffective_compression_countrâ   rÞ   TNz)compression guard refresh failed (%s): %s)ÚinsertrI   r¼   r½   r.   r/   r0   )rl   rS  Úmethod_callsÚmethod_nameÚkwargsÚmethodr1   s   &$     r)   Ú%_refresh_persisted_compression_guardsr]  t  sž   € à8¸"Ð=Ð@eÐgiÐ?jÐk€LßØ×Ñ˜AÐ IÈIÐW[ÐK\Ð]Ô^Û+ÑˆÜœ˜jÓ)¨;¸Ó=ˆÜ˜×ÒÙð	XÙ�:Ñ( Ô(ó  ,øô ô 	XÜ�L‰LÐDÀk×WÒWûð	Xús   Á	A'Á'BÁ2BÂBc               ó$   € V ^8„  d   QhRRRRRR/# ©r#   rÃ   r   rÄ   r%   r5   r&   r'   )r(   s   "r)   r*   r*   ƒ  s&   € ÷ pñ p°Cð pÀSð pÈTñ pr+   c                óè   € \        \        V 4      RR4      p\        V4      '       g   R# V! W4      p\        T;'       d0    VP	                  R4      RJ;'       d    VP	                  R4      R8H  4      # )zDReturn whether another path already rotated this compression parent.Úget_sessionNFÚended_atÚ
end_reasonr¿  )rI   r¼   r½   r&   rž   )rÃ   rÄ   ÚgetterÚsessions   &&  r)   Ú#_session_was_rotated_by_compressionrf  ƒ  sf   € ä”T˜*Ó% }°dÓ;€FÜ�F×ÒÙÙ�ZÓ,€GÜ�×nÐn˜GŸK™K¨
Ó3¸4Ð?×nÐnÀGÇKÁKÐP\ÓD]ÐanÑDnÓoÐor+   c               ó$   € V ^8„  d   QhRRRRRR/# ©r#   rD   r   Úsystem_messager%   r5   r'   )r(   s   "r)   r*   r*   Œ  s&   € ÷ gñ g 3ð g¸ð gÀñ gr+   c                óN   € \        V RR4      ;'       g    V P                  V4      # )zLCached system prompt, or a fresh build when nothing is cached (abort paths).Ú_cached_system_promptN)rI   Ú_build_system_prompt)rD   ri  s   &&r)   Ú_existing_system_promptrm  Œ  s&   € ä�5Ð1°4Ó8×fÐf¸E×<VÑ<VÐWeÓ<fÐfr+   c               ó$   € V ^8„  d   QhRRRRRR/# )r#   r¨  r;   r®   úOptional[list]r5   rE   r'   )r(   s   "r)   r*   r*   ‘  s!   € ÷ .ñ .¨ð .¸ð .ÈDñ .r+   c                óT   € Ve$   W8w  d   \         P                  ! V4      V R&   R# R# R# )zLPut the pre-compression deep snapshot back into the live list if it drifted.NºNNN)rr   rs   )r¨  r®   s   &&r)   Ú_restore_messages_snapshotrr  ‘  s'   € àÒ Ô 4Ü—m’m HÓ-ˆ�‹ñ !5Ñr+   c               ó$   € V ^8„  d   QhRRRRRR/# )r#   rl   r   r®   r<   r5   rE   r'   )r(   s   "r)   r*   r*   —  s&   € ÷ ]ñ ]¨Cð ]¸4ð ]ÀDñ ]r+   c                ó4   € RV9   d   VR,          V n         R# R# )zîRestore ONLY the prune runway from the attempt snapshot.
compress() zeroes it in memory while the durable copy only clears on a successful commit; a kept
transcript keeps its cached prefix, and 0 would let the next prune break that cache.Ú_proactive_prune_rearm_tokensN)ru  )rl   r®   s   &&r)   Ú_restore_prune_rearm_tokensrv  —  s   € ð '¨(Ô2Ø3;Ð<[Õ3\ˆ
Ö0ñ 3r+   c               ó    € V ^8„  d   QhRRRR/# ©r#   rD   r   r5   r&   r'   )r(   s   "r)   r*   r*   Ÿ  s   € ÷ 1ñ 1¨3ð 1°4ñ 1r+   c                óT   € \        V RR4      pVRJ ;'       g    \        V\        4      # )a  Type-pinned read of the per-session lock-skip signal.
``agent._compression_skipped_due_to_lock`` is a holder string or ``True`` when a pass no-oped because the
lock was held, ``None`` otherwise. Pinning avoids MagicMock auto-attributes hijacking mocked agents into
the lock-skip branch.Ú _compression_skipped_due_to_lockNT)rI   r:   r%   ©rD   Ú_sigs   & r)   Úcompression_skipped_due_to_lockr}  Ÿ  s,   € ô
 �5Ð<¸dÓC€DØ�4ˆ<×0Ð0œ: d¬CÓ0Ð0r+   c               ó$   € V ^8„  d   QhRRRRRR/# )r#   rD   r   Úcreater&   r5   z/Optional[tuple[Any, Optional[threading.local]]]r'   )r(   s   "r)   r*   r*   ¨  s)   € ÷ Kñ KØðKØðKà4ñKr+   c               óÊ  €  \        V 4      pTP                  R\        P                  ! 4       4      pT;_uu_ 4        TP                  R4      pT'       d:   \        T\        P                  4      '       g   \        P                  ! 4       pYBR&   T\        T\        P                  4      '       d   TMR3uuRRR4       #   \         d     R# i ; i  + '       g   i     R# ; i)zCReturn the stable lock and thread-local timeout state for an agent.NÚ'_context_compression_timeout_state_lockÚ"_context_compression_timeout_state)ro   rp   Ú
setdefaultr   r€   rž   r:   Úlocal)rD   r  Ú
attributesrƒ   Ústates   &$   r)   Ú&_get_context_compression_timeout_stater‡  ¨  s§   € ðÜ˜%“[ˆ
ð × Ñ Ð!JÌIÏNÊNÓL\Ó]€Dß	ŠØ—‘ÐCÓDˆßœ* U¬I¯O©O×<Ò<Ü—O’OÓ%ˆEØ?DÐ;Ñ<Øœj¨´	·±×@Ò@‘UÀdÐJ÷ 
Šøô ô Úðú÷ 
�ˆús   ‚B? ¼A8CÂ?CÃCÃC"	c               ó$   € V ^8„  d   QhRRRRRR/# )r#   rD   r   Ú	timed_outr&   r5   rE   r'   )r(   s   "r)   r*   r*   ¹  s!   € ÷ 
6ñ 
6°Cð 
6ÀDð 
6ÈTñ 
6r+   c                ó¶   € \        V RR7      ;'       g    Rw  r#Vf	   Wn        R# V;_uu_ 4        Wn        Wn        RRR4       R#   + '       g   i     R# ; i)zµWrite this thread's owned-compression timeout outcome.
The ``agent._last_compression_timed_out`` mirror stays authoritative for minimal agent doubles that do not
support ``vars()``.T©r  Nrà   )r‡  Ú_last_compression_timed_outr‰  )rD   r‰  rƒ   r†  s   &&  r)   Ú(_set_context_compression_timeout_outcomer�  ¹  sE   € ô 9¸ÀtÔL×\Ð\ÐP\�K€DØ‚}Ø,5Ô)Ùß	ŠØ#ŒØ,5Ô)÷ 
��Šús   °AÁA	c               ó    € V ^8„  d   QhRRRR/# rC   r'   )r(   s   "r)   r*   r*   Æ  s   € ÷ ;ñ ;°Sð ;¸Tñ ;r+   c                ó   € \        V R4       R# )z=Clear the current thread's owned-compression timeout outcome.FN©r�  ©rD   s   &r)   Ú)reset_context_compression_timeout_outcomer’  Æ  s   € ä,¨U°EÖ:r+   c               ó    € V ^8„  d   QhRRRR/# rC   r'   )r(   s   "r)   r*   r*   Ë  s   € ÷ :ñ :¨cð :°dñ :r+   c                ó   € \        V R4       R# )z5Mark the current owned compression as host-timed-out.TNr�  r‘  s   &r)   Ú"mark_context_compression_timed_outr•  Ë  s   € ä,¨U°DÖ9r+   c               ó    € V ^8„  d   QhRRRR/# rx  r'   )r(   s   "r)   r*   r*   Ð  s   € ÷ 
Gñ 
G¨ð 
G°ñ 
Gr+   c                ó
  € \        V RR7      pVeR   Vw  r#T;_uu_ 4        \        V\        P                  4      '       d   \	        VRR4      RJ uuRRR4       #  RRR4       \	        V RR4      RJ #   + '       g   i     L; i)zÚReturn whether this thread's owned compression hit its host timeout.
Thread-local so overlapping automatic/manual entrypoints cannot hide each other's timeout; attribute
fallback for minimal doubles; reads type-pinned.Fr‹  Nr‰  TrŒ  )r‡  r:   r   r„  rI   )rD   Úlocked_staterƒ   r†  s   &   r)   Úcontext_compression_timed_outr™  Ð  sr   € ô :¸%ÈÔN€LØÒØ"‰ˆßŠTÜ˜%¤§¡×1Ò1Ü˜u k°4Ó8¸DÐ@÷ ŠTØ1÷ ô �5Ð7¸Ó>À$ÐFÐF÷ �Tús    /A2Á2B	c               ó(   € V ^8„  d   QhRRRRRRRR/# )r#   rD   r   Úbypass_cooldownr&   rS  r5   úOptional[str]r'   )r(   s   "r)   r*   r*   Ý  s,   € ÷ ñ ØðØ!%ðØ<@ðàñr+   c               óZ  € V P                   p\        W2R7       \        \        V4      RR4      p\	        V4      '       g   R# T;'       d    \        VR4      pV'       d   V! VRR7      '       g    R# V! V4      '       g   R# R\        VRR4      rv\	        V4      '       dI   \        RRR	7      ;_uu_ 4        V'       d   \        VR4      '       d
   V! RR7      MV! 4       pRRR4       \        V\        4      '       d   V'       d   TMR
p\        WV4       V#   + '       g   i     L@; i)aK  Refresh durable guards, then evaluate the automatic breaker gate; return its block reason or None. The gate and
the reason both get ``ignore_cooldown`` when ``bypass_cooldown`` and they accept it (older engines get the no-arg
call), so a bypassed cooldown is never the reason. When blocked, the transient-block signal is published.©rS  Ú_automatic_compression_blockedNÚignore_cooldownT)r   Ú_compression_block_reasonz$compression block-reason read failedr-   Úunknown)
r«  r]  rI   r¼   r½   r   r2   r:   r%   Ú#_mark_compression_blocked_transient)rD   r›  rS  rl   ÚblockedÚignoreÚreasonÚ	reason_fns   &&$     r)   Ú"_automatic_compression_gate_blocksr¨  Ý  sö   € ð ×)Ñ)€JÜ)¨*ÕXÜ”d˜:Ó&Ð(HÈ$ÓO€GÜ�G×ÒÙØ×VÐVÔ!:¸7ÐDUÓ!V€Fß9?‰G�J°×5Ô5Ùñ FMÈZ×EXÒEXÙØœg jÐ2MÈtÓTˆIÜ�	×ÒÜÐ<Àt×LÖLç39Ô>WÐXaÐct×>uÒ>u‘	¨$Õ/Ù“[ð ÷ Mô
 " &¬#×.Ò.·6‰V¸y€FÜ'¨¸6ÔBØ€M÷ M×Lús   Â7+DÄD*	c               ó    € V ^8„  d   QhRRRR/# rx  r'   )r(   s   "r)   r*   r*   ÷  s   € ÷ 0ñ 0¨3ð 0°4ñ 0r+   c                ób   € \        V RR4      p\        V\        4      ;'       d    \        V4      # )uG  Type-pinned read of the transient-block signal.
Set when an automatic pass no-ops on a TRANSIENT guard (summary-failure cooldown or structural backoff).
Consumers must defer, not count it toward ``compression_exhausted``, or an overflow auto-reset wipes a
session that was merely cooling down. The permanent ``ineffective`` breaker never sets it.

See #97488.
Consumers (the overflow-recovery loops in ``conversation_loop``) must treat such a no-op as a temporary
defer, NOT as evidence the session is incompressible: counting it toward ``compression_exhausted`` lets
a real upstream ``context_length_exceeded`` auto-reset (wipe) a session whose compression was merely
cooling down (#97488). The permanent ``ineffective`` breaker intentionally does NOT set this signal â€” a
genuinely incompressible session must still be able to exhaust.
Ú_compression_blocked_transientN)rI   r:   r%   r&   r{  s   & r)   Úcompression_blocked_transientlyr¬  ÷  s,   € ô �5Ð:¸DÓA€DÜ�dœCÓ ×/Ð/¤T¨$£ZÐ/r+   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r#   rD   r   rl   r¦  r%   r5   rE   r'   )r(   s   "r)   r*   r*     s)   € ÷ :ñ :¨sð :Àð :ÈSð :ÐUYñ :r+   c           
     ót  € VP                  R4      '       g   VP                  R4      '       dv   \        P                  RT\        V RR4      ;'       g    R\        VRR4      ;'       g    R4       \        P
                  ! \        4      ;_uu_ 4        W n        RRR4       R# R#   + '       g   i     R# ; i)	zÖPublish the transient-block signal when the active guard is transient.
``reason`` comes from ``_compression_block_reason``: ``cooldown:*`` and ``structural_backoff:*`` are
transient; ``ineffective`` stays unmarked.ÚcooldownÚstructural_backoffu¯   Skipping automatic compression re-entry: transient guard active (%s, session=%s, last failure: %s) â€” will retry after the backoff lapses; /compress forces an immediate retryrÄ   Nr¶  rº   r¢  )Ú
startswithr/   rg   rI   r�   r’   r.   r«  )rD   rl   r¦  s   &&&r)   r£  r£    s—   € ð ×Ñ˜×$Ò$¨×(9Ñ(9Ð:N×(OÒ(OÜ�‰ðFàGMÜ�E˜<¨Ó.×8Ð8°&Ü�JÐ 5°tÓ<×IÐIÀ	ô	
ô × Ò ¤×+Õ+Ø39Ô0÷ ,Ñ+ñ )P÷ ,×+Ð+ús   ÂB&Â&B7	c               ó    € V ^8„  d   QhRRRR/# )r#   rÄ   r%   r5   rE   r'   )r(   s   "r)   r*   r*     s   € ÷ 	(ñ 	(¨ð 	(°ñ 	(r+   c                ó  €  ^ RI Hp V! V 4       \
        P                  ! \        4      ;_uu_ 4        ^ RIHp V! V 4       RRR4       R#   \         d    T \        P                  R&    L[i ; i  + '       g   i     R# ; i)zOPoint the worker thread's session ContextVar and log context at ``session_id``.)Úset_current_session_idÚHERMES_SESSION_ID)Úset_session_contextN)	Úgateway.session_contextr´  r.   ÚosÚenvironr�   r’   Úhermes_loggingr¶  )rÄ   r´  r¶  s   &  r)   Ú_rebind_session_contextr»    sb   € ð5ÝBÙ˜zÔ*ô 
×	Ò	œY×	'Õ	'Ý6Ù˜JÔ'÷ 
(Ñ	'øô ô 5Ø*4Œ�
‰
Ð&Ó'ð5úç	'×	'Ð	'ús   ‚A ²A/ÁA,Á+A,Á/B 	c               ó(   € V ^8„  d   QhRRRRRRRR/# )r#   rD   r   rÃ   Úparent_session_idr%   r5   úOptional[list[dict[str, Any]]]r'   )r(   s   "r)   r*   r*   $  s2   € ÷ Bñ BØðBØðBØ47ðBà#ñBr+   c                ó\  € \        \        V4      RR4      p\        \        V4      RR4      p\        \        V4      RR4      p\        V4      '       d#   \        V4      '       d   \        V4      '       g   R# V! W4      pV'       d   \        V4      \        V4      8X  d   R# \        V4      pV! W4      p\	        V\
        4      '       d   VP                  R4      e   R# V! W4      p	\	        V	\        4      '       d	   V	'       g   R# V! W4      p
V
'       d   \        V
4      V8w  d   R# Ypn        \        V4       \        W'4       RV n        ^ RIHp VP                  R4      pV'       d   V! W4      '       d   TMRV n        \        V	4      V n        Wpn        V	 Uu0 uF&  p\	        V\
        4      '       g   K  \%        V4      kK(  	  upV n        \        V P(                  R	R4      p\        V4      '       dL   \+        R
4      ;_uu_ 4        T! TRTT\        V RR4      ;'       g    R\        V RR4      R7       RRR4       M\\        V P(                  RR4      p\        V4      '       d5   \,        P.                  ! \0        4      ;_uu_ 4        V! WR7       RRR4       \+        R4      ;_uu_ 4        V P2                  '       d   V P2                  P5                  WrRRR7       RRR4       V	# u upi   + '       g   i     Lc; i  + '       g   i     Lv; i  + '       g   i     T	# ; i)uî  Move a stale compression contender onto the live continuation tip.
Resolve and load first, then mutate the agent, so ambiguous lineage or an unreadable handoff fails closed.
Uses the transitive ``get_compression_tip`` walk; a tip is adopted only while its row is still live.

Resolution uses the canonical transitive walk ``get_compression_tip`` so a lineage with >=2 compression
hops (root -> mid -> tip) recovers to the live tip â€” the depth-1 ``find_live_compression_child`` lookup
this used to call finds no live *direct* child in that shape and skipped recovery (#82001). The tip walk
returns the input id when no continuation exists, and a resolved tip is adopted only while its row is
still live â€” both cases fail closed exactly as before.
Úget_compression_tipNra  Úget_messages_as_conversationrb  T)Ú_stored_prompt_matches_runtimeÚsystem_promptÚon_session_startz4context engine compression-child adoption failed: %sr¿  ÚplatformÚcliÚ_gateway_session_key)Úboundary_reasonÚold_session_idrÃ   rÅ  Úconversation_idÚbind_session_state)rÃ   rÄ   z4memory manager compression-child adoption failed: %sF©r½  Úresetr¦  )rI   r¼   r½   r%   r:   r<   rž   r;   rÄ   r»  Ú_hand_off_metrics_segmentÚ_session_db_createdÚagent.conversation_looprÂ  rk  r®  Ú_last_flushed_db_idxÚ_flushed_db_message_session_idÚidÚ_flushed_db_message_idsr«  r2   r�   r’   r.   Ú_memory_managerÚon_session_switch)rD   rÃ   r½  ÚresolverÚ
row_getterÚloaderÚtipÚchild_session_idÚchildró  Ú	confirmedrÂ  Úchild_promptr$   rÄ  Ú
bind_states   &&&             r)   Ú_adopt_live_compression_childrà  $  s“  € ô ”t˜JÓ'Ð)>ÀÓE€HÜœ˜jÓ)¨=¸$Ó?€JÜ”T˜*Ó%Ð'EÀtÓL€FÜ�H×Ò¤X¨j×%9Ò%9ÄÈ&×AQÒAQÙÙ
�:Ó
1€Cß”#�c“(œcÐ"3Ó4Ô4ÙÜ˜3“xÐÙ�zÓ4€EÜ�eœT×"Ò" e§i¡i°
Ó&;Ò&GÙÙ�zÓ4€IÜ�y¤$×'Ò'¯IÙñ ˜Ó7€Ißœ˜I›Ð*:Ô:ÙØ'ÔÜÐ,Ô-ÜÐ/ÔBØ $€EÔõ GØ—9‘9˜_Ó-€Lç$Ñ)GÈ×)\Ò)\‰Ðbfð 
Ôô "% Y£€EÔØ+;Ô(Ù@IÓ$gÁ	°WÌZÐX_Ôae×Mf¤[¤R¨¦[Á	Ñ$g€EÔ!Ü˜u×7Ñ7Ð9KÈTÓRÐÜÐ ×!Ò!ÜÐL×MÕMÙØ °-ÐPaØ%´¸¸zÈ4Ó0P×0YÐ0YÐTYÜ '¨Ð/EÀtÓ Lõ÷ NÐMô ˜U×5Ñ5Ð7KÈTÓRˆ
Ü�J×ÒÜ×$Ò$¤Y×/Õ/Ù jÕN÷ 0ä	ÐH×	IÕ	IØ× × Ð Ø×!Ñ!×3Ñ3Ø ÈUÐ[hð 4ô ÷ 
Jð
 Ðùò' %h÷ N×Mú÷ 0×/úç	IÖ	Ið
 Ðús0   ÆK/Æ;K/È/K4Ê
LÊ41LË4L	ÌL	ÌL+	c               ó$   € V ^8„  d   QhRRRRRR/# )r#   rÃ   r   rÄ   r%   r5   rE   r'   )r(   s   "r)   r*   r*   i  s&   € ÷ 	añ 	a¨ð 	a¸ð 	aÀñ 	ar+   c                ó  € \        \        V 4      RR4      p\        V4      '       g   R#  V! W4      '       d   \        P	                  RV4       R# R#   \
         d"   p\        P	                  RY4        Rp?R# Rp?ii ; i)zOReopen a compression-ended parent that has no continuation and no lease holder.Ú#reopen_orphaned_compression_sessionNzGcompression recovery: reopened orphaned session=%s with no continuationz5orphaned compression session reopen failed for %s: %s)rI   r¼   r½   r/   rÒ   r.   )rÃ   rÄ   Úorphan_reopenerr1   s   &&  r)   Ú_reopen_orphaned_parentrå  i  sp   € äœd :Ó.Ð0UÐW[Ó\€OÜ�O×$Ò$ÙðaÙ˜:×2Ò2Ü�N‰NÐdÐfpÖqñ 3øäô aÜ�‰ÐNÐPZ×`Ò`ûðaús   «$A ÁA?ÁA:Á:A?c               ó    € V ^8„  d   QhRRRR/# )r#   rD   r   r5   r¾  r'   )r(   s   "r)   r*   r*   u  s   € ÷ ñ ¨sð Ð7Uñ r+   c                ó"  € \        V RR4      p\        V RR4      ;'       g    RpVe	   V'       g   R#  \        W4      '       g   R# \        VRR4      p\        ^4       Fh  p\        WV4      pVe   Vu # \	        V4      '       d	   V! V4      MRpV'       g   \        W4        R# V^8X  d    R# \        P                  ! R4       Kj  	  R#   \         d7   p\        P                  RT\        T4      P                  T4        Rp?R# Rp?ii ; i)zFRecover a stale live agent before a new turn writes to its old parent.r´   NrÄ   rX   Úget_compression_lock_holderr  z;compression session recovery failed for session=%s (%s: %s))rI   rf  Úrangerà  r½   rå  rÁ   r  r.   r/   rÒ   r¼   rt  )rD   rÃ   rÄ   Úholder_getterrO   ró  Úholderr1   s   &       r)   Ú#recover_rotated_compression_sessionrì  u  sò   € ä˜ ¨tÓ4€JÜ˜ ¨dÓ3×9Ð9°r€JØÒ§ÙðÜ2°:×JÒJÙô   
Ð,IÈ4ÓPˆÜ˜R–yˆGÜ5°eÈÓTˆIØÒ$Ø Ò Ü2:¸=×2IÒ2I‘] :Ô.ÈtˆFßÜ'¨
Ô?ÚØ˜"Œ}ÚÜ�JŠJ�tÖñ !ñ øÜô Ü�‰ØIÈ:ÔW[Ð\_ÓW`×WiÑWiÐknô	
õ ûð	ús5   ´C Á.C Á6"C ÂC Â'C Â1C ÃDÃ+D	Ä	Dc               ó    € V ^8„  d   QhRRRR/# )r#   rD   r   r5   r%   r'   )r(   s   "r)   r*   r*   ”  s   € ÷ Gñ G Cð G¨Cñ Gr+   c           
     óÚ   € R\         P                  ! 4        \        4        R\        P                  ! 4        R\        V 4      R R\        P                  ! 4       P                  R,           2	# )zØBuild a unique lock holder id: ``pid[:pidns]:tid:agent-instance:uuid`` (pidns: see ``hermes_state_pidns``).
pid+tid tell crashed holders apart; instance id and per-acquire uuid disambiguate co-resident/pooled agents.zpid=z:tid=z:agent=Úxz:nonce=:Né   N)	r¸  Úgetpidr   r   Ú	get_identrÓ  ÚuuidÚuuid4Úhexr‘  s   &r)   Ú_compression_lock_holderrö  ”  sz   € ð ”"—)’)“+�Ô5Ó7Ð8¸¼i×>QÒ>QÓ>SÐ=TÐT[Ô\^Ð_dÓ\eÐfgÐ[hÐhoÔpt×pzÒpzÓp|÷  qAñ  qAð  BDõ  qEð  pFð  Gð  Gr+   r›  c               ó4   € V ^8„  d   QhRRRRRRRRR	R
RRRR/# )r#   Úcompress_fnr   Úcurrent_tokensrÏ   Úfocus_topicrœ  Úforcer&   Úmemory_contextr%   r›  r5   r<   r'   )r(   s   "r)   r*   r*   š  sO   € ÷ Uñ UØðUØ)6ðUØERðUØ[_ðUàðUà*.ðUð 
ñUr+   c               óÐ  € RVRVRV/pV'       d   RVR&   V'       d   WFR&    \         P                  ! V 4      P                  p\
        ;QJ d*    R TP                  4        4       F  '       g   K   RM	  RM! R TP                  4        4       4      '       d   T# TP                  4        UU	u/ uF  w  r‰Y‡9   g   K  Y‰bK  	  up	p#   \        \        3 d    RT/u # i ; iu up	pi )	zÀReturn only compression kwargs accepted by an engine callable.
Inspecting first keeps older plugin signatures compatible without catching ``TypeError`` and running a
stateful compressor twice.rù  rú  rû  Tr›  rü  c              3  ól   "  € T F*  qP                   \        P                  P                  J x € K,  	  R # 5ir  )ÚkindrO  Ú	ParameterÚVAR_KEYWORD)Ú.0Ú	parameters   & r)   Ú	<genexpr>Ú0_supported_compression_kwargs.<locals>.<genexpr>¬  s%   é € Ð
`ÑL_¸y�>‰>œW×.Ñ.×:Ñ:Õ:ÓL_ùs   ‚24F)rO  Ú	signatureÚ
parametersrp   r  Úanyrt   r=   )
rø  rù  rú  rû  rü  r›  Ú
candidatesr  ru   rÖ   s
   &$$$$$    r)   Ú_supported_compression_kwargsr
  š  sÛ   € ð # N°MÀ;ÐPWÐY^Ð_€JßØ(,ˆ
Ð$Ñ%ßØ'5Ð#Ñ$ð2Ü×&Ò& {Ó3×>Ñ>ˆ
÷
 ƒsÑ
`ÈJ×L]ÑL]ÔL_Ó
`‡s‡s‚sÑ
`ÈJ×L]ÑL]ÔL_Ó
`×`Ò`ØÐØ+5×+;Ñ+;Ô+=ÔTÑ+=™K˜DÀÑASŒKˆDŠKÑ+=ÒTÐTøô ”zÐ"ô 2ð ! .Ð1Ò1ð2üó Us   £ C Â.
C"Â=C"ÃCÃCc                  óŽ   € ] tR tRtRtRRRRR/R R llltR	 R
 ltRR R lltR R ltRRRR/R R llt	R R lt
R R ltRtR# )Ú_CompressionActivityHeartbeati±  zMRefresh the agent inactivity tracker while compression blocks in an aux call.NÚemit_client_statusFrŸ  c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R
/# )r#   rD   r   Úinterval_secondsrê   r  r&   rŸ  r   r5   rE   r'   )r(   s   "r)   r*   Ú*_CompressionActivityHeartbeat.__annotate__´  s=   € ÷ nñ nØðnØ,8ðnØX\ðnà6ðnð 
ñnr+   c               	óš  € Wn         W@n        R V n        Vf   \        VRR4      p \	        T;'       g    R4      p\
        P                  ! V4      '       g   Rp\        RT4      T n
        Y0n        \        P                  ! 4       T n        \        P                  ! T P                   RRR7      T n        R#   \        \        3 d    Rp Lpi ; i)FNÚ(_compression_activity_heartbeat_intervalç      N@çš™™™™™¹?zcompression-activity-heartbeatT©Útargetru   Údaemon)Ú_agentÚ_commit_fenceÚ_suppressedrI   r¿   ÚmathÚisfiniterp   r  rÀ   Ú_interval_secondsÚ_emit_client_statusr   rð   Ú_stopÚThreadÚ_runÚ_thread)rü   rD   r  r  rŸ  s   &&&$$r)   rý   Ú&_CompressionActivityHeartbeat.__init__´  s¿   € ð ŒØ)Ôð !ˆÔØÒ#Ü& uÐ.XÐZ^Ó_Ðð	$Ü$Ð%5×%=Ð%=¸Ó>ÐÜ—=’=Ð!1×2Ò2Ø#'Ð ô "% SÐ*:Ó!;ˆÔð $6Ô Ü—_’_Ó&ˆŒ
Ü ×'Ò'¨t¯y©yÐ?_ÐhlÔmˆŽøô œ:Ð&ô 	$Ø#Òð	$ús   ¦B4 ´"B4 ÁB4 Â4C
Ã	C
c               ó   € V ^8„  d   QhRR/# )r#   r5   r  r'   )r(   s   "r)   r*   r  Í  s   € ÷ ñ Ð4ñ r+   c                	ón   € R V n         V P                  RRR7       V P                  P                  4        V # )Fzcontext compression startedT)Úallow_terminal_overwrite)r  Ú_touchr"  Ústartr  s   &r)   r(  Ú#_CompressionActivityHeartbeat.startÍ  s2   € ð !ˆÔØ�‰Ð1ÈDˆÔQØ�‰×ÑÔØˆr+   c               ó    € V ^8„  d   QhRRRR/# ©r#   Údescr%   r5   rE   r'   )r(   s   "r)   r*   r  Õ  s   € ÷ 
.ñ 
.˜ð 
.À4ñ 
.r+   c                	óN  € V P                   P                  4        V P                  P                  4       '       d@   \        P
                  ! 4       V P                  Jd   V P                  P                  R R7       V P                  4       '       d   R# V P                  VRR7       R# )ç      ð?r€  NT)Úforce_persist)	r  r.  r"  Úis_aliver   Úcurrent_threadÚjoinÚ_should_suppressr'  )rü   r,  s   &&r)   ÚstopÚ"_CompressionActivityHeartbeat.stopÕ  sr   € Ø�
‰
�‰ÔØ�<‰<× Ñ ×"Ò"¤y×'?Ò'?Ó'AÈÏÉÓ'UØ�L‰L×Ñ cÐÔ*ð × Ñ ×"Ò"Ùð 	�‰�D¨ˆÖ-r+   c               ó   € V ^8„  d   QhRR/# rb   r'   )r(   s   "r)   r*   r  á  s   € ÷  ñ   $ñ  r+   c                	ó    € V P                   '       g2   V P                  e$   V P                  P                  '       d   RV n         V P                   # ©NT)r  r  r  r  s   &r)   r3  Ú._CompressionActivityHeartbeat._should_suppressá  s>   € Ø××Ð D×$6Ñ$6Ò$BÀt×GYÑGY×Gf×GfÐGfØ#ˆDÔØ×ÑÐr+   r&  r/  c               ó(   € V ^8„  d   QhRRRRRRRR/# )r#   r,  r%   r&  r&   r/  r5   rE   r'   )r(   s   "r)   r*   r  æ  s0   € ÷ jñ j˜3ð j¸Tð jÐZ^ð jÐkoñ jr+   c          	     	ó
  € \        R RR7      ;_uu_ 4        V'       g_   V P                  4       '       d    RRR4       R# \        \        V P                  RR4      4      pV\
        9   d   RV n         RRR4       R# \        V P                  RR4      p\        V4      '       dC   V'       g"   V P                  4       '       d    RRR4       R# V! V\        P                  VR7       RRR4       R#   + '       g   i     R# ; i)z+compression activity heartbeat touch failedTr-   NÚ_last_activity_provenanceÚ_touch_activity)Ú
provenancer/  )
r2   r3  r   rI   r  Ú!_TERMINAL_COMPRESSION_PROVENANCESr  r½   r   ÚAGENT_COMPRESSION)rü   r,  r&  r/  ÚcurrentÚtouchs   &&$$  r)   r'  Ú$_CompressionActivityHeartbeat._touchæ  sÉ   € ÜÐCÈd×SÖSß+Ø×(Ñ(×*Ò*Ø÷ TÑSô 8¼ÀÇÁÐMhÐjnÓ8oÓp�ØÔ?Ô?Ø'+�DÔ$Ø÷ TÑSô ˜DŸK™KÐ):¸DÓAˆEÜ˜�Š÷ 0°D×4IÑ4I×4KÒ4KØ÷ TÑSñ �dÔ'9×'KÑ'KÐ[hÕi÷ T×S×SÒSús.   –C1µC1Á 3C1Á=/C1Â-C1ÃC1ÃC1Ã1D	c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   r  ÷  s   € ÷ ñ  tñ r+   c                óî   € V P                   '       g   R# \        V P                  RR4      p\        V4      '       g   R#  V! \        4       R#   \
         d    \        P                  RRR7        R# i ; i)uÜ  Re-publish the compacting status so remote transports see progress.

Compression can stream for minutes with no deltas, tool events, or
status lines reaching remote transports. Idle-progress watchdogs on
those clients (e.g. the Android relay app's 180s turn watchdog)
treat the silence as a dead turn and fire ``session.interrupt`` â€”
killing a healthy compression mid-flight and rolling back its work,
which retriggers on the next prompt and loops forever on sessions
near the context ceiling (#98371).

Routed through ``agent._emit_status`` like every other compaction
status: same "lifecycle" key (the TUI gateway re-tags it to
``compacting``; Telegram edits one bubble per key), same chat-platform
filter, same CLI print path.
NÚ_emit_statusz*status emit error in compression heartbeatTr-   )r  rI   r  r½   ÚCOMPACTION_HEARTBEAT_STATUSr.   r/   r0   )rü   Úemits   & r)   Ú_emit_progress_statusÚ3_CompressionActivityHeartbeat._emit_progress_status÷  sd   € ð  ×'×'Ð'ÙÜ�t—{‘{ N°DÓ9ˆÜ˜�~Š~Ùð	ÙÔ,Ö-øÜô 	Ü�L‰LØ<Àtð ÷ ð	ús   Á A Á"A4Á3A4c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   r    s   € ÷ )ñ )�dñ )r+   c                	óÒ   € V P                   P                  V P                  4      '       g<   V P                  4       '       d   R # V P	                  R4       V P                  4        Kf  R # )Nzcontext compression in progress)r  Úwaitr  r3  r'  rI  r  s   &r)   r!  Ú"_CompressionActivityHeartbeat._run  sK   € Ø—*‘*—/‘/ $×"8Ñ"8×9Ò9Ø×$Ñ$×&Ò&ÙØ�K‰KÐ9Ô:Ø×&Ñ&Ö(ñ	 :r+   )r  r  r  r  r  r  r"  r  )úcontext compression completed)rt  ru  rv  rw  rx  rý   r(  r4  r3  r'  rI  r!  rz  r'   r+   r)   r  r  ±  sX   † ÙWñnØ_dðnà9=÷nð nõ2÷
.õ ð
jÀEð jÐaf÷ jõ"÷8)ñ )r+   r  c               ó    € V ^8„  d   QhRRRR/# )r#   r¨  r   r5   zlist[dict[str, Any]]r'   )r(   s   "r)   r*   r*     s   € ÷ ñ °sð Ð?Sñ r+   c                ó(  € ^ RI Hp . pT ;'       g    .  Fó  p\        V\        4      '       g   K  VP	                  R4      pVR9  g   VP	                  V4      '       d   KL  VR8X  d�   VP	                  R4      '       dy   VP	                  R4      p\        \        V\        4      '       d   VP                  4       MT4      pV'       g   K¶  VP                  4        UUu/ uF  w  rxVR8w  g   K  WxbK  	  pppVP                  V4       Kõ  	  V# u uppi )zÙReturn direct user/assistant evidence safe for memory checkpointing.
Summaries, tool rows and system messages are omitted; assistant prose is kept with ``tool_calls``
stripped, and pure tool-call wrappers are dropped.)ÚCOMPRESSED_SUMMARY_METADATA_KEYÚroleÚ	assistantÚ
tool_callsÚcontent>   ÚuserrT  )
r9   rR  r:   r<   rž   r&   r%   r[   r=   rÓ  )	r¨  rR  Údirect_messagesr$   rS  rV  Ú	has_proser?   r@   s	   &        r)   Ú(_direct_messages_for_pre_compress_memoryrZ    sã   € õ
 IØ,.€OØ—>�>˜r’>ˆÜ˜'¤4×(Ò(ÙØ�{‰{˜6Ó"ˆØÐ,Ô,°·±Ð<[×0\Ò0\ÙØ�;Ô 7§;¡;¨|×#<Ò#<Ø—k‘k )Ó,ˆGÜ´
¸7ÄC×0HÒ0H˜WŸ]™]œ_ÈgÓVˆIßÙØ(/¯©¬ÔM©¡ ¸1ÀÑ;L”t�q’t©ˆGÑMØ×Ñ˜wÖ'ñ "ð Ðùó Ns   ÃDÃ.Dc                  óJ   € ] tR tRtRR R lltR R ltR R ltR	 R
 ltRtR# )Ú_CompressionLockLeaseRefresheri2  Nc               ó0   € V ^8„  d   QhRRRRRRRRRR	R
R/# )r#   Údbr   rÄ   r%   rë  Úttl_secondsr¿   Úrefresh_interval_secondsrê   r5   rE   r'   )r(   s   "r)   r*   Ú+_CompressionLockLeaseRefresher.__annotate__3  sD   € ÷ hñ hØðhØ#&ðhØ03ðhØBGðhØcoðhà	ñhr+   c                	óš  € Wn         W n        W0n        W@n        Vf   \	        R\        RVR,          4      4      p\	        R\        V4      4      V n        \	        ^\        V P                  V P                  ,          4      4      V n	        \        P                  ! 4       V n        \        P                  ! V P                  RRR7      V n        R # )Nr.  r  g       @r  zcompression-lock-refreshTr  )Ú_dbrµ   Ú_holderÚ_ttl_secondsrÀ   rü  r¿   Ú_refresh_interval_secondsr†   Ú_max_consecutive_failuresr   rð   r  r   r!  r"  )rü   r^  rÄ   rë  r_  r`  s   &&&&&&r)   rý   Ú'_CompressionLockLeaseRefresher.__init__3  sŸ   € ð ŒØ%ÔØŒØ'ÔØ#Ò+Ü'*¨3´°D¸+ÈÕ:KÓ0LÓ'MÐ$Ü),¨S´%Ð8PÓ2QÓ)RˆÔ&ô *-¨Q´°D×4EÑ4EÈ×HfÑHfÕ4fÓ0gÓ)hˆÔ&Ü—_’_Ó&ˆŒ
Ü ×'Ò'¨t¯y©yÐ?YÐbfÔgˆŽr+   c               ó   € V ^8„  d   QhRR/# )r#   r5   r\  r'   )r(   s   "r)   r*   ra  C  s   € ÷ ñ Ð5ñ r+   c                	ó:   € V P                   P                  4        V # r  )r"  r(  r  s   &r)   r(  Ú$_CompressionLockLeaseRefresher.startC  s   € Ø�‰×ÑÔØˆr+   c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   ra  G  s   € ÷ +ñ +�dñ +r+   c                	ó   € V P                   P                  4        V P                  P                  4       '       dD   \        P
                  ! 4       V P                  Jd   V P                  P                  R R7       R# R# R# )r.  r€  N)r  r.  r"  r0  r   r1  r2  r  s   &r)   r4  Ú#_CompressionLockLeaseRefresher.stopG  sW   € Ø�
‰
�‰Ôð �<‰<× Ñ ×"Ò"¤y×'?Ò'?Ó'AÈÏÉÓ'UØ�L‰L×Ñ cÐÖ*ñ (VÑ"r+   c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   ra  N  s   € ÷ ñ �dñ r+   c                	ó8  € ^ pRpV'       g,   V P                   P                  V P                  4      '       gÐ   V'       d%   RpV P                   P                  4       '       d   R# Rp\	        R4      ;_uu_ 4        V P
                  P                  V P                  V P                  V P                  R7      pRRR4       V'       d   ^ pKÅ  V^,          pWP                  8¼  g   Kà  \        P                  RWP                  4       R# R#   + '       g   i     L[; i)r8  TFz#compression lock refresh raised: %s©r_  NzZcompression lock refresh failed %d times in a row; stopping lease refresher for session %s)r  rM  rf  r8  r2   rc  Úrefresh_compression_lockrµ   rd  re  rg  r/   r0   )rü   Úconsecutive_failuresÚfirstÚ	refresheds   &   r)   r!  Ú#_CompressionLockLeaseRefresher._runN  sà   € ð  !Ðð ˆß˜4Ÿ:™:Ÿ?™?¨4×+IÑ+I×JÒJßØ�Ø—:‘:×$Ñ$×&Ò&ÙØˆIÜÐ?×@Õ@Ø ŸH™H×=Ñ=¸d×>NÑ>NÐPT×P\ÑP\Ðjn×j{Ñj{Ð=Ó|�	÷ AçØ'(Ð$ÙØ  AÕ%Ð Ø#×'EÑ'EÖEÜ—‘ØpØ(×*:Ñ*:ôñ ñ# K÷ A×@ús   Á9=D	Ä	D	)rc  rd  rg  rf  rµ   r  r"  re  r  )	rt  ru  rv  rw  rý   r(  r4  r!  rz  r'   r+   r)   r\  r\  2  s   † ÷hõ õ+÷ñ r+   r\  c               ó$   € V ^8„  d   QhRRRRRR/# )r#   rD   r   Úmsgr%   r5   rE   r'   )r(   s   "r)   r*   r*   i  s!   € ÷ 'ñ ' Cð '¨cð '°dñ 'r+   c                óh   € \        V RR4      V8X  d   R# Wn        Wn        V P                  V4       R# )zÆStore + emit a feasibility verdict once per distinct text: every main-runtime change re-probes, and an
unchanged verdict must not re-warn on each `/model --once` restore or fallback cycle (#114707).Ú_last_feasibility_noticeN)rI   rz  Ú_compression_warningÚ_emit_diagnostic_status)rD   rx  s   &&r)   Ú_emit_feasibility_noticer}  i  s3   € ô ˆuÐ0°$Ó7¸3Ô>ÙØ%(Ô"Ø!$ÔØ	×!Ñ! #Ö&r+   c               ó0   € V ^8„  d   QhRRRRRRRRRRR	R
/# )r#   rD   r   Ú	aux_modelr%   Úaux_contextr†   Úaux_providerÚaux_base_urlr5   rE   r'   )r(   s   "r)   r*   r*   s  sD   € ÷ Kñ KØðKØ!ðKØ03ðKØCFðKØVYðKà	ñKr+   c               óv  € V P                   pVP                  pT;qun        W%n        \        VRR4      p\        VRR4      R8X  d	   RVn        M2\        V\        \        34      '       d   \        Wx,          4      Vn        VP                  p	V	'       d   Wy,          Vn
        V	'       d   \        W),          ^d,          4      M^2p
^ RIHp RpV	'       dE   \        W[4      '       d4   VP                  W›P                  Wš^d,          4      \        VRR4      4      pVRJ ;'       g    WÂ8*  p\        V RR4      ;'       g    R	p\        V R
R4      ;'       g    RpV'       d
   VR8w  d   TMRpV'       g$    ^ RIHp V! V4      P"                  ;'       g    TpV'       d	   V RV R2MTpV RV R2pRV RVR RV RVR RVR R2pV'       d   VRVR RV
R 2,          pMVRVR RV RV	R RVR RVR R2,          p\'        V V4       \(        P+                  RWWg4       R#   \$         d    T;'       g    Rp L¤i ; i) a/  Lower the live threshold to the aux model's window and tell the user how to fix config.
The summariser sends one user prompt (no system/tools), so threshold == aux_context is safe.
Retention is recalibrated through its selected policy: lean is window-relative;
only legacy follows the lowered threshold.Úsummary_target_ratioNÚ	tail_modeÚleanrÛ   Ú
max_tokensr­  rX   Ú?rÁ  Úauto)Úurlparsez (rÄ  u   âš  Compression model z context is Ú,z tokens, but the main model z's compression threshold was z2 tokens. Auto-lowered this session's threshold to z  tokens so compression can run.
u¢     To make this permanent, edit config.yaml â€” either:
  1. Use a larger compression model:
       auxiliary:
         compression:
           model: <model-with-z[+-context>
  2. Lower the compression threshold:
       compression:
         threshold: 0.Ú02dz�  To make this permanent, use a larger compression model in config.yaml:
       auxiliary:
         compression:
           model: <model-with-uG   +-context>
  (Lowering compression.threshold cannot help here â€” with z's zb-token window, Hermes's small-context floor and output reservation would recompute the trigger to z- tokens, still above the compression model's z.)u´   Auxiliary compression model %s has %d token context, below the main model's compression threshold of %d tokens â€” auto-lowered session threshold to %d to keep compression working.)r«  Úthreshold_tokensÚ_aux_context_ceilingrI   Ú_tail_token_budgetr:   r†   r¿   Útail_token_budgetrß  Úthreshold_percentr9   rÜ   Ú_compute_threshold_tokensÚ_effective_threshold_percentÚurllib.parserŠ  Úhostnamer.   r}  r/   rÒ   )rD   r  r€  r�  r‚  rl   Úold_thresholdÚnew_thresholdr„  Úmain_ctxÚsafe_pctÚ_CCÚrecomputed_thresholdÚthreshold_suggestion_viableÚ_main_modelÚ_main_providerÚ_aux_provider_labelrŠ  Ú_main_labelÚ
_aux_labelrx  s   &$$$$                r)   Ú_lower_threshold_to_aux_contextr¢  s  s£  € ð ×)Ñ)€JØ×/Ñ/€MØ2=Ð=€MÔ/ð '2Ô#Ü" :Ð/EÀtÓLÐÜˆz˜;¨Ó-°Ô7à(,ˆ
Õ%Ü	Ð(¬3´¨,×	7Ò	7Ü'*¨=Õ+OÓ'Pˆ
Ô$Ø×(Ñ(€HßØ'4Õ'?ˆ
Ô$ß6>Œs�KÕ*¨cÕ1Ô2ÀB€Hõ BØÐß”J˜z×/Ò/Ø"×<Ñ<Ø×6Ñ6°xÈCÅÓPÜ�J ¨dÓ3ó 
Ðð #7¸$Ð">×"eÐ"eÐBVÑBeÐä˜% ¨"Ó-×4Ð4°€KÜ˜U J°Ó3×9Ð9°r€Nß*6¸<È6Ô;Q™,ÐWYÐßð	9Ý-Ù"*¨<Ó"8×"AÑ"A×"QÐ"QÀ\Ð÷ :H�[�M  NÐ#3°1Ñ5È[€KØ�;˜bÐ!4Ð 5°QÐ7€Jà
   ¨L¸ÀQ¸ÐGcØˆ-Ð4°]À1Ð4Eð F4Ø4AÀ!Ð3DÐDeð	gð ÷
 #ØðWØWdÐefÐVgð haØaiÐjmÐ`nðpõ	
‰ð 	ðDØDQÐRSÐCTð UKØKVÈ-ÐWZÐ[cÐdeÐZfð gbà# AÐ&Ð&SÐT_Ð`aÐSbÐbdð	fõ	
ˆô ˜U CÔ(Ü
‡N�Nð	WØXaØöøô1 ô 	9Ø".×"8Ð"8°&Òð	9ús   Å1H ÆH ÈH8È2H8È7H8c               ó(   € V ^8„  d   QhRRRRRRRR/# )r#   rD   r   r  r%   r‚  r5   r&   r'   )r(   s   "r)   r*   r*   Á  s.   € ÷ Pñ P Cð P°Cð PÀsð PÈtñ Pr+   c           	     ór  € ^ RI Hp \        T;'       g    R4      P                  4       P	                  4       \        \        V RR4      ;'       g    R4      P                  4       P	                  4       8w  d   R# T! \        \        V RR4      ;'       g    R4      4      pV'       * ;'       g    V! V4      V8H  # )zRTrue when the auxiliary compression client is the main model on the main endpoint.)Únormalize_route_base_urlrX   r­  FrÅ  )Úhermes_cli.route_identityr¥  r%   r[   r]   rI   )rD   r  r‚  r¥  Ú	main_bases   &&&  r)   Ú_aux_inherits_main_router¨  Á  s‘   € åBÜ
ˆ9�?ˆ?˜Ó×!Ñ!Ó#×)Ñ)Ó+¬s´7¸5À'È2Ó3N×3TÐ3TÐRTÓ/U×/[Ñ/[Ó/]×/cÑ/cÓ/eÔeÙÙ(¬¬W°U¸JÈÓ-K×-QÐ-QÈrÓ)RÓS€IØŒ=×OÐOÑ4°\ÓBÀiÑOÐOr+   c               ó    € V ^8„  d   QhRRRR/# rC   r'   )r(   s   "r)   r*   r*   Ê  s"   € ÷ YRñ YR¨sð YR°tñ YRr+   c                ó6  € V P                   '       g   R#  ^ RIHpHpHp ^ RIHpHp  V! R4      w  p   pV! RV P                  4       R7      w  r‰Ve	   V	'       gU   V! RV4      w  r«pV
eE   V'       d=   Y«r˜RV9   d4   VP                  R4      '       d   VP                  R^4      ^,          RR pVe	   V	'       g;   V'       d   VR	8w  d   R
V R2pMRp\        W4       \        P                  R4       R# \        \!        VRR4      4      p\!        VRR4      p\#        V4      '       d   \%        V\        4      '       g   RM\        T;'       g    R4      pV'       d
   VR	8w  d   TM\!        V RR4      p\!        V RR4      pVf3   \'        W	V4      '       d!   \)        V P*                  P,                  4      pMV! WžVVVV P.                  R7      pV'       d)   VV8  d"   \1        RV	 RVR RVR RVR,           R2	4      hVV P*                  P2                  8  d   \5        W	VVVR7       R# \!        V RR4      e   RV n        RV n        R# R#   \         d    Rp EL&i ; i  \0         d    h \         d"   p\        P;                  RT4        Rp?R# Rp?ii ; i)zçWarn at session start if the aux compression context is below the threshold.
Called from ``AIAgent.__init__`` (CLI sees it via ``_vprint``); the gateway wires ``status_callback``
later, so ``replay_compression_warning`` resends it.N)Ú_resolve_task_provider_modelÚ/_try_configured_fallback_for_unavailable_clientÚget_text_auxiliary_client)ÚMINIMUM_CONTEXT_LENGTHÚget_model_context_lengthr¿  rX   )Úmain_runtimeÚ(rÄ  r‰  u/   âš  Configured auxiliary compression provider 'z ' is unavailable, so older messages in long chats will be cut without a summary. Sign in to that provider again, or change auxiliary.compression in your config.u°   âš  No auxiliary LLM provider configured: Hermes has no helper model for summarising long chats, so older messages will be cut without a summary. Run `hermes setup` to add one.uL   No auxiliary LLM provider for compression â€” summaries will be unavailable.rÅ  rÆ  rÁ  Ú&_aux_compression_context_length_config)rÅ  rÆ  Úconfig_context_lengthrÁ  Úcustom_providerszAuxiliary compression model z has a context window of r‹  z$ tokens, which is below the minimum zE required by Hermes Agent.  Choose a compression model with at least iè  z–K context (set auxiliary.compression.model in config.yaml), or set auxiliary.compression.context_length to override the detected value if it is wrong.)r  r€  r�  r‚  rz  z4Compression feasibility check failed (non-fatal): %séÿÿÿÿ)Úcompression_enabledrÉ  r«  r¬  r­  Úagent.model_metadatar®  r¯  r.   Ú_current_main_runtimeÚendswithÚrsplitr}  r/   rÒ   r%   rI   r½   r:   r¨  r†   r«  rß  Ú_custom_providersr  r�  r¢  rz  r{  r0   )rD   r«  r¬  r­  r®  r¯  Ú_aux_cfg_providerÚ_Úclientr  Ú	fb_clientÚfb_modelÚfb_labelrx  r‚  Ú_raw_aux_keyÚaux_api_keyÚ_aux_providerÚ_aux_cfg_ctxr€  r1   s   &                    r)   Ú#check_compression_model_feasibilityrÆ  Ê  sÑ  € ð ×$×$Ð$ÙðSR÷	
ñ 	
÷ 	Zð	#Ù,HÈÓ,WÑ)Ð˜q ! Q¨ñ 6°mÐRW×RmÑRmÓRoÔpÑˆØŠ>§Ù,[ØÐ0ó-Ñ)ˆI ð Ò$¯Ø$-˜	Ø˜(”? x×'8Ñ'8¸×'=Ò'=Ø(0¯©¸¸QÓ(?ÀÕ(BÀ3ÀBÐ(GÐ%ØŠ>§ß Ð%6¸&Ô%@àEÐFWÐEXð YVð Vñ ðrð ô % UÔ0Ü�N‰NÐiÔjÙÜœ7 6¨:°rÓ:Ó;ˆô ˜v y°"Ó5ˆÜ% l×3Ò3¼JÀ|ÔUX×<YÒ<Y‘bÔ`cÐdp×dvÐdvÐtvÓ`wˆ÷ "3Ð7HÈFÔ7RÑÔX_Ð`eÐgqÐsuÓXvð 	ô ˜uÐ&NÐPTÓUˆØÒÔ$<¸UÈ|×$\Ò$\ô ˜e×6Ñ6×EÑEÓF‰Ká2Ø¸+Ð]iØ&¸×9PÑ9PôˆK÷
 ˜;Ð)?Ô?ÜØ.¨y¨kð :Ø(¨˜Oð ,Ø1°!Ð4ð 5Dà)¨TÕ1Ð2ð 31ð	2ó	ð 	ð ˜×1Ñ1×BÑBÔBÜ+Ø¸ÐRcØ)÷ô �UÐ6¸Ó=ÒIð .2ˆEÔ*Ø)-ˆEÖ&ñ	 JøôA ô 	#Ø "Óð	#ûôJ ô àÜô RÜ�‰ÐKÈS×QÒQûðRús~   –I! ©I ·%I! ÁI! Á5I! Â'I! Â=I! Ã0I! Ã7AI! ÅI! Å A7I! ÇAI! È,I! ÉIÉI! ÉIÉI! É!JÉ6JÉ7JÊJc               ó    € V ^8„  d   QhRRRR/# rC   r'   )r(   s   "r)   r*   r*   &  s   € ÷ 2ñ 2¨cð 2°dñ 2r+   c                óÂ   € RV n         \        V RR4      '       g   R#  \        V 4       RT n         R#   \         d"   p\        P                  RT4        Rp?R# Rp?ii ; i)a…  Re-run the aux feasibility probe after the main runtime changed (model switch, fallback activation,
primary restore). ``update_model()`` already voided the previous ceiling; probing now clamps the trigger
before the first compaction on the new window rather than after it (#114707). A probe failure leaves the
latch unset so the lazy probe at the next compaction re-raises hard rejections.Fr«  NzDCompression feasibility re-check deferred to the next compaction: %sT)Ú _compression_feasibility_checkedrI   rÆ  r.   r/   r0   )rD   r1   s   & r)   Ú"revalidate_compression_feasibilityrÊ  &  s[   € ð
 .3€EÔ*Ü�5Ð.°×5Ò5ÙðÜ+¨EÔ2ð .2€EÖ*øô ô Ü�‰Ð[Ð]`ÔaÝûðús   ž2 ²A½AÁAc               ó$   € V ^8„  d   QhRRRRRR/# )r#   rD   r   Úestimated_tokensr†   r5   rE   r'   )r(   s   "r)   r*   r*   6  s"   € ÷ 2ñ 2°#ð 2Èð 2ÐQUñ 2r+   c                ó  € \        V RR4      '       g   \        V RR4      '       g   R# ^ RIHp \        T;'       g    ^ 4      V8  d   R#  \	        V 4       RT n        R#   \
         d"   p\        P                  RT4        Rp?R# Rp?ii ; i)uà  Run the deferred aux feasibility probe once a request first reaches ``MINIMUM_CONTEXT_LENGTH`` â€” the
smallest window any summariser may have â€” so an aux clamp lands before the first compaction fires on the
main-window threshold instead of after it (#114707). Below that size no summariser can be too small, so
short sessions keep the probe-free cold start (#28957). A probe failure leaves the latch unset for the
lazy probe in ``compress_context`` to re-raise hard rejections.rÉ  Fr«  N)r®  zBCompression feasibility probe deferred to the first compaction: %sT)	rI   r·  r®  r†   rÆ  r.   r/   r0   rÉ  )rD   rÌ  r®  r1   s   &&  r)   Ú&ensure_compression_feasibility_checkedrÎ  6  s�   € ô ˆuÐ8¸%×@Ò@ÌÐPUÐWkÐmq×HrÒHrÙÝ;Ü
Ð× Ð ˜qÓ!Ð$:Ô:ÙðÜ+¨EÔ2ð .2€EÖ*øô ô Ü�‰ÐYÐ[^Ô_Ýûðús   ÁA  Á BÁ+BÂBc               ó    € V ^8„  d   QhRRRR/# rC   r'   )r(   s   "r)   r*   r*   I  s   € ÷ 	Dñ 	D cð 	D¨dñ 	Dr+   c                ó  € \        V RR4      pV'       d`   V P                  '       dL   ^ RIHp \        P
                  ! \        4      ;_uu_ 4        V P                  RV! V4      4       RRR4       R# R# R#   + '       g   i     R# ; i)zÊRe-send the stored compression warning through ``status_callback``.
Called once at the start of the first ``run_conversation()``, when the gateway callback (absent during
``__init__``) is finally wired.r{  N)ÚDiagnosticTextÚ	lifecycle)rI   rG   Úgateway.warning_notificationsrÑ  r�   r’   r.   )rD   rx  rÑ  s   &  r)   Úreplay_compression_warningrÔ  I  se   € ô �%Ð/°Ó
6€Cß
ˆu×$×$Ð$å@Ü× Ò ¤×+Õ+Ø×!Ñ! +©~¸cÓ/BÔC÷ ,Ñ+ñ %�s÷ ,×+Ð+ús   ÁA7Á7B	c               ó(   € V ^8„  d   QhRRRRRRRR/# )r#   rD   r   r¨  r;   Úprevious_historyro  r5   r'   )r(   s   "r)   r*   r*   U  s,   € ÷ ñ ØðØðØ2@ðàñr+   c                óÜ   € \        \        V RR4      4      '       d)   \        V RR4      pVRJ d   \        V4      # VRJ d   R# V# \        \        V RR4      4      '       d   \        V4      # R# )aq  Return the correct flush baseline after a compression boundary.
Session rotation returns ``None`` so the child gets the full compacted list. In-place compaction returns a
shallow copy of the already-persisted rows (else the identity flush re-appends them). Aborted/no-op
attempts keep the baseline: marking all persisted drops unflushed turns; clearing re-appends rows.Ú"_last_compression_attempt_recordedFÚ"_last_compression_attempt_in_placeNTÚ_last_compaction_in_place)r&   rI   r;   )rD   r¨  rÖ  Úattempt_in_places   &&& r)   Ú&conversation_history_after_compressionrÜ  U  so   € ô ŒG�EÐ?ÀÓG×HÒHÜ" 5Ð*NÐPTÓUÐØ˜tÓ#Ü˜“>Ð!Ø˜uÓ$ÙØÐÜŒG�EÐ6¸Ó>×?Ò?Ü�H‹~ÐÙr+   c               ó    € V ^8„  d   QhRRRR/# )r#   r$   r   r5   r%   r'   )r(   s   "r)   r*   r*   o  s   € ÷ ñ ˜3ð  3ñ r+   c                óä   € \        V \        4      '       d   V P                  R 4      MRp\        V\        4      '       d   V# \        V\        4      '       d   RP                  R V 4       4      # R# )rV  NÚ
c              3  óÌ   "  € T FZ  p\        V\        4      '       g   K  \        VP                  R 4      ;'       g    VP                  R4      ;'       g    R4      x € K\  	  R# 5i)rV   rV  rX   N)r:   r<   r%   rž   )r  Úparts   & r)   r  Ú _message_text.<locals>.<genexpr>t  sL   é € ð 
ÙKRÀ4ÔV`ÐaeÔgk×VlÔ>ŒC�—‘˜Ó ×=Ð= D§H¡H¨YÓ$7×=Ð=¸2×>Ð>Ë7ùs   ‚A$ŸA$¼A$ÁA$rX   )r:   r<   rž   r%   r;   r2  )r$   rV  s   & r)   Ú_message_textrã  o  s`   € Ü(2°7¼D×(AÒ(Aˆg�k‰k˜)Ô$Àt€GÜ�'œ3×ÒØˆÜ�'œ4× Ò Ø�y‰yñ 
ÙKRó
ó 
ð 	
ñ r+   c               ó    € V ^8„  d   QhRRRR/# ©r#   r$   r   r5   r&   r'   )r(   s   "r)   r*   r*   €  s   € ÷ Nñ N 3ð N¨4ñ Nr+   c                ó¨  a € \        S \        4      '       d   S P                  R4      R8w  d   R# \        ;QJ d#    V 3R l\         4       F  '       g   K   RM	  RM! V 3R l\         4       4      '       d   R# \        S 4      P                  4       pV'       d   VP                  \        4      '       d   R# ^ RI	H
p VP                  S 4      '       * # )zºDistinguish human intent from user-role runtime scaffolding.
A compaction summary flipped to ``role="user"`` for alternation is scaffolding and must not short-circuit
anchor restoration.rS  rW  Fc              3  óF   <"  € T F  pSP                  V4      x € K  	  R # 5ir  )rž   )r  Úflagr$   s   & €r)   r  Ú(_is_real_user_message.<locals>.<genexpr>†  s   øé € Ð
?Ñ)> ˆ7�;‰;�t×ÐÓ)>ùó   ƒ!TrÛ   )r:   r<   rž   r  Ú_SYNTHETIC_USER_FLAGSrã  r[   r±  Ú_SYNTHETIC_USER_PREFIXESr9   rÜ   Ú#_is_synthetic_compression_user_turn)r$   rV   rÜ   s   f  r)   Ú_is_real_user_messagerî  €  sŠ   ø€ ô �gœt×$Ò$¨¯©°FÓ(;¸vÔ(EÙß
ƒsÔ
?Õ)>Ó
?‡s‡s‚sÔ
?Õ)>Ó
?×?Ò?ÙÜ˜Ó!×'Ñ'Ó)€Dß�4—?‘?Ô#;×<Ò<ÙÝ:Ø ×DÑDÀWÓMÔMÐMr+   z[OUT-OF-BAND USER MESSAGEz[/OUT-OF-BAND USER MESSAGE]c               ó   € V ^8„  d   QhRR/# )r#   r5   ztuple[str, str]r'   )r(   s   "r)   r*   r*   “  s   € ÷ ;ñ ;˜ñ ;r+   c                 óT   €  ^ RI Hp Hp W3#   \         d    \        \
        3u # i ; i)zU``(open, close)`` steer markers from prompt_builder, or the stable fallback literals.©ÚSTEER_MARKER_CLOSEÚSTEER_MARKER_OPEN)Úagent.prompt_builderrò  ró  r.   Ú_STEER_FALLBACK_OPENÚ_STEER_FALLBACK_CLOSErñ  s     r)   Ú_steer_markersr÷  “  s.   € ð;ßNØ Ð4Ð4øÜô ;Ü#Ô%:Ð:Ò:ð;ús   ‚
 �'¦'c               ó    € V ^8„  d   QhRRRR/# rå  r'   )r(   s   "r)   r*   r*   œ  s   € ÷ 8ñ 8¨#ð 8°$ñ 8r+   c                ód   € \        V 4      pV'       g   R# \        4       w  r#W!9   ;'       d    W19   # )zõReturn whether *message* carries a busy-steer marker.
Steer follow-ups are now their own ``role=user`` rows (caught by ``_is_real_user_message``); in
transcripts persisted before that they ride inside ``role=tool`` results, so those still count.F)rã  r÷  )r$   rV   Úopen_markerÚclose_markers   &   r)   Ú_message_contains_busy_steerrü  œ  s3   € ô ˜Ó!€DßÙÜ .Ó 0Ñ€KØÑ×7Ð7 <Ñ#7Ð7r+   c               ó    € V ^8„  d   QhRRRR/# )r#   r$   r   r5   rœ  r'   )r(   s   "r)   r*   r*   §  s   € ÷ +ñ +¨cð +°mñ +r+   c                óì  € \        V 4      pV'       g   R# \        4       w  r#VP                  V4      pVR8X  dX   VP                  \        4      pVR8X  d   R# VP                  RV4      pVR8w  d
   V^,           MV\	        \        4      ,           pMV\	        V4      ,          pVP                  W44      pVR8X  d    VP                  \
        V4      pVR8X  d   R# WV P                  4       ;'       g    R# )z9Extract the inner user text from a steer marker, or None.Nrß  rµ  )rã  r÷  Úfindrõ  r®  rö  r[   )r$   rV   rú  rû  r(  ÚnlÚends   &      r)   Ú _extract_steer_text_from_messager  §  sÑ   € ä˜Ó!€DßÙÜ .Ó 0Ñ€KØ�I‰I�kÓ"€EØ�„{à—	‘	Ô.Ó/ˆØ�BŒ;ÙØ�Y‰Y�t˜UÓ#ˆØ œ(��Q–¨´Ô4HÓ0IÕ(I‰à”�[Ó!Õ!ˆØ
�)‰)�LÓ
(€CØ
ˆb„yØ�i‰iÔ-¨uÓ5ˆØ�"Œ9ÙØ�cˆ?× Ñ Ó"×*Ð* dÐ*r+   c               ó    € V ^8„  d   QhRRRR/# )r#   r¨  r;   r5   r&   r'   )r(   s   "r)   r*   r*   ¿  s   € ÷ ñ ¨ð °$ñ r+   c                ój   € \         ;QJ d    R V  4       F  '       g   K   R# 	  R# ! R V  4       4      # )z¬Whether *messages* already carries a steer marker in a ``role=tool`` row.
Only tool rows count, so a summary merely quoting the marker text is not mistaken for live intent.c              3  ó    "  € T FD  p\        V\        4      ;'       d(    VP                  R 4      R8H  ;'       d    \        V4      x € KF  	  R# 5i)rS  ÚtoolN)r:   r<   rž   rü  )r  rx  s   & r)   r  Ú-_compressed_has_busy_steer.<locals>.<genexpr>Â  sC   é € ð ÙmuÐfiŒ
�3œÓ×aÐa #§'¡'¨&£/°VÑ";×aÐaÔ@\Ð]`Ó@aÔaÓmuùs   ‚AžAºATF)r  )r¨  s   &r)   Ú_compressed_has_busy_steerr  ¿  s?   € ÷ ‹3ñ Ùmuó�3Œ3ð Š3ð ˆ3ñ Ùmuóó ð r+   c               ó    € V ^8„  d   QhRRRR/# )r#   rV  r   r5   r'   )r(   s   "r)   r*   r*   Ç  s   € ÷ ñ ¨ð °ñ r+   c                óT  € ^ RI Hp \        V \        4      '       d.   V P	                  V4      pVR8X  d   V # V RV P                  4       # \        V \        4      '       dÉ   . pV  F¾  p\        V\        4      '       d;   VP                  R4      R8X  d%   \        VP                  R4      ;'       g    R4      MRpV'       d   VP	                  V4      MRpVR8X  d   VP                  V4       KŠ  VRV P                  4       ;p'       g   K§  VP                  / VCRV/C4       KÀ  	  V# V # )zÝRemove a previously merged todo-snapshot block from message content.
Snapshots are appended to the trailing user turn, so a surviving header is stale; stripping before
re-injection prevents accumulation across boundaries.)ÚTODO_INJECTION_HEADERNr¼   rV   rX   rµ  )
Útools.todo_toolr  r:   r%   rÿ  Úrstripr;   r<   rž   rÓ  )rV  r  ÚidxÚcleanedrá  rV   Ústrippeds   &      r)   Ú_strip_stale_todo_snapshotr  Ç  s  € õ 6Ü�'œ3×ÒØ�l‰lÐ0Ó1ˆØ�"Œ9ØˆNØ�t˜ˆ}×#Ñ#Ó%Ð%Ü�'œ4× Ò ØˆÛˆDÜ2<¸TÄ4×2HÒ2HÈTÏXÉXÐV\ÓM]ÐagÔMg”3�t—x‘x Ó'×-Ð-¨2Ô.ÐmoˆDß6:�$—)‘)Ð1Ô2ÀˆCØ�bŒyØ—‘˜tÖ$Ø! $ 3˜Z×.Ñ.Ó0Ð0�×0Ð0Ø—‘Ð9 $Ð9¨°Ñ9Ö:ñ ð ˆØ€Nr+   c               ó$   € V ^8„  d   QhRRRRRR/# )r#   rV  r   r  r5   r&   r'   )r(   s   "r)   r*   r*   Þ  s!   € ÷ 	ñ 	¨Cð 	¸3ð 	À4ñ 	r+   c                óî   € \        V \        4      '       d,   \        V\        4      '       d   VP                  4       '       * # \        V \        4      '       d   \        V\        4      '       d   V'       * # R# )a-  Return whether stripping the snapshot leaves no structured content.
Text snapshots trail a string; structured ones occupy their own text part, so only an empty remainder
proves the row was scaffolding alone. Text extraction is deliberately not used: image, audio and other
non-text parts must survive.F)r:   r%   r[   r;   )rV  r  s   &&r)   Ú_todo_snapshot_is_only_contentr  Þ  sQ   € ô
 �'œ3×Ò¤J¨x¼×$=Ò$=Ø—>‘>Ó#Ô#Ð#Ü�'œ4× Ò ¤Z°¼$×%?Ò%?ØŒ|ÐÙr+   c               ó$   € V ^8„  d   QhRRRRRR/# )r#   r$   r<   rV  r   r5   rE   r'   )r(   s   "r)   r*   r*   ê  s!   € ÷ $ñ $ dð $°Sð $¸Tñ $r+   c                ó*   € ^ RI Hp WR&   V! V 4       R# )zFRewrite message content without allowing an old API sidecar to replay.)Údrop_stale_api_contentrV  N)Úagent.turn_contextr  )r$   rV  r  s   && r)   Ú_replace_message_contentr  ê  s   € å9Ø ˆIÑÙ˜7Ö#r+   uJ   [Skills pruned during compression â€” reload before acting on these tasks]c               ó    € V ^8„  d   QhRRRR/# )r#   Ú
compressedr;   r5   r%   r'   )r(   s   "r)   r*   r*   ÷  s   € ÷ ñ ¨Dð °Sñ r+   c                ó  € ^ RI HpHp . pV  FL  p\        V\        4      '       g   K  V! \        V4      4       F  pWS9  g   K  VP                  V4       K  	  KN  	  W1R1 V'       g   R# RP                  R V 4       4      p\         RV R2# )zÐReload notice for skills whose bodies were pruned, or ``""``.
Scans ``[SKILL_PRUNED: ...]`` markers in the post-compression transcript; first-seen order, deduplicated,
capped at ``_MAX_PRUNED_SKILL_MARKERS``.)Ú_MAX_PRUNED_SKILL_MARKERSÚ_extract_pruned_skill_namesNrX   z; c              3  ó.   "  € T F  pR V R2x € K  	  R# 5i)zskill_view(name='z')Nr'   )r  ru   s   & r)   r  Ú._pruned_skill_reload_notice.<locals>.<genexpr>	  s   é € ÐE¹u°tÐ)¨$¨¨rÕ2»uùs   ‚zÎ
The task list above crossed the compression boundary verbatim, but the skill instructions that governed it were pruned. Before executing any preserved task that depends on these skills, reload them first: uˆ   . After reloading, re-check that each pending task is still justified â€” findings recorded before the boundary may have invalidated it.)	r9   r  r  r:   r<   rã  rÓ  r2  Ú"_PRUNED_SKILL_RELOAD_NOTICE_HEADER)r  r  r  Únamesr$   ru   Úcallss   &      r)   Ú_pruned_skill_reload_noticer$  ÷  s–   € ÷ `Ø€EÛˆÜ˜'¤4×(Ò(ÙÙ/´¸gÓ0FÖGˆDØÖ Ø—‘˜TÖ"ó Hñ ð 	Ñ(Ð)ßÙØ�I‰IÑE¹uÓEÓE€Eä-Ð
.ð /ð �gð eð		eðr+   c               ó$   € V ^8„  d   QhRRRRRR/# )r#   r  r<   Úanchorr5   rE   r'   )r(   s   "r)   r*   r*   	  s&   € ÷ @ñ @¨Dð @¸$ð @À4ñ @r+   c                ó²  € VP                  R4      pV P                  R4      p\        V\        4      '       g   \        V\        4      '       d&   R R lp\        W! V4      V! V4      ,           4       M4T;'       g    R RT;'       g    R 2P	                  4       p\        W4       \
         F  pV P                  VR4       K  	  ^ RIHp V! WRR	7       R# )
zÍFold the human anchor into an existing user-role scaffolding turn.
Used only when any insertion would create consecutive user turns. Anchor text leads, scaffolding follows,
and synthetic flags are cleared.rV  c               ó    € V ^8„  d   QhRRRR/# )r#   rV  r   r5   r;   r'   )r(   s   "r)   r*   Ú5_merge_anchor_into_user_message.<locals>.__annotate__	  s   € ÷ 	rñ 	r˜Cð 	r Dñ 	rr+   c                óx   € \        V \        4      '       d   \        V 4      # R RR\        T ;'       g    R4      /.# )r¼   rV   rX   )r:   r;   r%   )rV  s   &r)   Ú_partsÚ/_merge_anchor_into_user_message.<locals>._parts	  s:   € Ü$.¨w¼×$=Ò$=”4˜“=ÐqÀVÈVÐU[Ô]`Ðah×anÐanÐlnÓ]oÐDpÐCqÐqr+   rX   ú

N)Úrecord_absorbed_messageT)Údropped_leads)	rž   r:   r;   r  r[   rë  ÚpopÚagent.message_metadatar.  )r  r&  Úanchor_contentÚtarget_contentr+  Úmergedrè  r.  s   &&      r)   Ú_merge_anchor_into_user_messager5  	  s´   € ð —Z‘Z 	Ó*€NØ—Z‘Z 	Ó*€NÜ�.¤$×'Ò'¬:°nÄd×+KÒ+Kõ	rô 	! ¨°Ó)?Á&ÈÓBXÕ)XÕYà"×(Ð( bÐ)¨¨n×.BÐ.BÀÐ-CÐD×JÑJÓLˆÜ  Ô0ß%ˆØ�
‰
�4˜Öñ &õ ?á˜F¸$×?r+   c               ó$   € V ^8„  d   QhRRRRRR/# )r#   r¨  r;   r&  r<   r5   ÚCompressedUserTurnOutcomer'   )r(   s   "r)   r*   r*   ,	  s"   € ÷ ñ  tð °Tð Ð>Wñ r+   c                óÂ  a aa€ ^ RI HoHp R R lpR VVV 3R llp\        S 4       F@  w  rVV! V4      R8X  g   K  V^ 8X  g   V! S V^,
          ,          4      R8w  g   K8  V! V4      u # 	  S '       d<   V! S R
,          4      R8w  g(   VP	                  \        S R
,          4      4      '       d   V! \        S 4      4      # \        S R
,          S4       RS R
,          S&   R	# )z?Insert the latest human turn without breaking role alternation.)r8   rÜ   c               ó    € V ^8„  d   QhRRRR/# )r#   rx  r   r5   rœ  r'   )r(   s   "r)   r*   Ú._insert_real_user_anchor.<locals>.__annotate__0	  s   € ÷ Bñ B�3ð B˜=ñ Br+   c                óT   € \        V \        4      '       d   V P                  R 4      # R# )rS  N©r:   r<   rž   )rx  s   &r)   Ú_roleÚ'_insert_real_user_anchor.<locals>._role0	  s!   € Ü",¨S´$×"7Ò"7ˆs�w‰w�v‹ÐA¸TÐAr+   c               ó    € V ^8„  d   QhRRRR/# )r#   rÌ  r†   r5   r7  r'   )r(   s   "r)   r*   r:  3	  s   € ÷ ñ �cð Ð7ñ r+   c                ó6   <€ R SS&   SP                  V S4       R# )TÚinserted)rX  )rÌ  r8   r&  r¨  s   &€€€r)   Ú_placeÚ(_insert_real_user_anchor.<locals>._place3	  s   ø€ Ø'+ˆÐ#Ñ$Ø�‰˜˜vÔ&Ùr+   rT  rW  Tr4  rµ  )r9   r8   rÜ   rÊ  Ú_is_context_summary_contentrã  r®  r5  )r¨  r&  rÜ   r=  rB  rÌ  r$   r8   s   ff     @r)   Ú_insert_real_user_anchorrE  ,	  s¾   ú€ çPõB÷ò ô $ HÖ-‰ˆÙ�‹>˜[Ö(¨e°q¬j¹EÀ(È5ÐSTÍ9ÕBUÓ<VÐZ`Ö<`Ù˜%“=Ò ñ .÷ Ù�˜"•Ó &Ô(Ø×8Ñ8¼ÀxÐPRÅ|Ó9T×UÒUá”c˜(“mÓ$Ð$ô $ H¨R¥L°&Ô9Ø)-€HˆR…LÐ%Ñ&Ùr+   c               ó$   € V ^8„  d   QhRRRRRR/# )r#   Úoriginal_messagesr;   r  r5   r7  r'   )r(   s   "r)   r*   r*   M	  s"   € ÷ "ñ "¸ð "È$ð "ÐSlñ "r+   c                ór  a€ \         ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       g   \        V4      '       d   R# ^ RIHoHpHp \         ;QJ d    V3R lV 4       F  '       g   K   RM	  RM! V3R lV 4       4      '       d   R# \        V 4       Fz  p\        V4      '       d   \        W! V4      4      u # \        V\        4      '       d   VP                  R4      R8w  d   KU  \        V4      pV'       g   Kj  \        VRR	R
V/4      u # 	  ^ RIHp V! VRR	R
V/4       R# )zDPreserve human intent, not merely a synthetic user-role placeholder.c              3  ó8   "  € T F  p\        V4      x € K  	  R # 5ir  ©rî  )r  r$   s   & r)   r  Ú3_ensure_compressed_has_user_turn.<locals>.<genexpr>O	  s   é € Ð
D¹¨gÔ  ×)Ð)»ùs   ‚TFÚalready_present)rÜ   Ú%COMPRESSION_CONTINUATION_USER_CONTENTÚ_fresh_compaction_message_copyc              3  óF   <"  € T F  pSP                  V4      x € K  	  R # 5ir  )Ú_has_merged_inflight_replay)r  r$   rÜ   s   & €r)   r  rK  Z	  s"   øé € Ð
\ÑQ[ÀgÐ×8Ñ8¸×AÐAÓQ[ùrê  rS  r  rW  rV  )Úappend_messageÚplaceholder_appended)r  r  r9   rÜ   rM  rN  Úreversedrî  rE  r:   r<   rž   r  r1  rQ  )rG  r  rM  rN  r$   Ú
steer_textrQ  rÜ   s   &&     @r)   Ú _ensure_compressed_has_user_turnrU  M	  sø   ø€ ç
ƒsÑ
D¹Ó
D‡s‡s‚sÑ
D¹Ó
D×DÒDÔHbÐcm×HnÒHnÙ ÷ñ ÷ ƒsÔ
\ÑQ[Ó
\‡s‡s‚sÔ
\ÑQ[Ó
\×\Ò\á ô Ð-Ö.ˆÜ  ×)Ò)Ü+¨JÐ8VÐW^Ó8_Ó`Ò`Ü˜'¤4×(Ò(¨G¯K©K¸Ó,?À6Ô,IÙÜ5°gÓ>ˆ
ß‰:Ü+¨J¸ÀÈÐT^Ð8_Ó`Ò`ñ /õ 6Ù�: ¨°	Ð;`ÐaÔbÙ!r+   c               ó$   € V ^8„  d   QhRRRRRR/# )r#   Úleftr   Úrightr5   r&   r'   )r(   s   "r)   r*   r*   o	  s!   € ÷ ñ ¨#ð °cð ¸dñ r+   c                óR  € \        V \        4      '       da   \        V\        4      '       dK   V P                  R4      VP                  R4      8w  g&   V P                  R4      VP                  R4      8w  d   R# V P                  R4      pVP                  R4      pVe	   Ve   W#8H  # R# )zCCompare the live turn identity we care about for rotation stamping.rS  rV  FÚ	timestampTr<  )rW  rX  Úleft_timestampÚright_timestamps   &&  r)   Ú_messages_match_scoped_identityr]  o	  sˆ   € ô �tœT×"Ò"Ü˜%¤×&Ò&Ø�8‰8�FÓ˜uŸy™y¨Ó0Ô0Ø�8‰8�IÓ %§)¡)¨IÓ"6Ô6áØ—X‘X˜kÓ*€NØ—i‘i Ó,€OØÒ! oÒ&AØÑ0Ð0Ùr+   Úexact_counts_stampedc               ó(   € V ^8„  d   QhRRRRRRRR/# )	r#   Útargetsr;   Úsourcer<   r^  r&   r5   rE   r'   )r(   s   "r)   r*   r*   	  s)   € ÷ 0ñ 0 ð 0¨tð 0Èdð 0Ð_cñ 0r+   c               óÜ  € ^ RI Hp VP                  R4      pRpVe~   V  Fm  p\        V\        4      '       d(   VP                  R4      V8w  g   \        Wa4      '       g   KB  VP                  V4      '       d   T;'       g    TpKg  RWc&   RpKo  	  V'       d   R# V  FK  p\        V\        4      '       g   K  VP                  V4      '       d   K4  \        Wa4      '       g   KG  RWc&   KM  	  R# )aA  Stamp ``_db_persisted`` on every unstamped scoped twin of ``source`` in ``targets``.
Exact-timestamp twins are preferred: when the source carries a timestamp and any exact twin was stamped
(or, with ``exact_counts_stamped``, merely exists), the broad scoped pass is skipped so a content-equal
old duplicate is left alone.r7   rZ  FNT)r9   r8   rž   r:   r<   r]  )r`  ra  r^  r8   Úsource_timestampÚ	exact_hitr  s   &&$    r)   Ú_stamp_scoped_twinsre  	  sÈ   € õ
 >Ø—z‘z +Ó.ÐØ€IØÒ#ÛˆFä˜v¤t×,Ò,Ø—:‘:˜kÓ*Ð.>Ô>Ü6°v×FÒFáØ�z‰zÐ.×/Ò/Ø%×=Ð=Ð)=�	ÙØ+/ˆFÑ(ØŠIñ ÷ ÙÛˆä�vœt×$Ô$Ø—J‘JÐ3×4Ô4Ü/°×?Ô?à+/ˆFÓ(ó r+   Ú0_pending_context_engine_compression_notificationc               ó$   € V ^8„  d   QhRRRRRR/# )r#   rÉ  r%   r   r5   rE   r'   )r(   s   "r)   r*   r*   ¢	  s!   € ÷ 7ñ 7¨cð 7À3ð 7È4ñ 7r+   c                ó†   € \        RRR7      ;_uu_ 4        ^ RIHp V! W4       RRR4       R#   + '       g   i     R# ; i)z[Shared metrics count one conversation across the rotation (a no-op when collection is off).z&shared-metrics segment hand-off failedTr-   )Úrotate_segmentN)r2   Ú-hermes_cli.observability.relay_shared_metricsri  )rÉ  r   ri  s   && r)   rÎ  rÎ  ¢	  s+   € ä	Ð:ÀT×	JÖ	JÝPÙ�~Ô6÷ 
K×	J×	JÒ	Jús	   –/¯A 	c               ó(   € V ^8„  d   QhRRRRRRRR/# )r#   rD   r   r   r%   rÉ  r5   r&   r'   )r(   s   "r)   r*   r*   ©	  s*   € ÷ ñ °sð Èsð Ðdgð Ðlpñ r+   c               óâ  € \        RRR7      ;_uu_ 4        ^ RIHp VP                  P	                  VP                  4       WR7       RRR4       \        W!4       \        V P                  RR4      p\        V4      '       g   R#  T! TR	T\        V R
R4      ;'       g    R\        V RR4      R7       R#   + '       g   i     Lu; i  \         d    \        P                  RRR7        R# i ; i)zDNotify the active context engine after a durable compression commit.z*relay segment rotation notification failedTr-   )Úrelay_runtime)Úprofile_keyrÄ   rÉ  NrÄ  Fr¿  rÅ  rÆ  rÇ  )rÈ  rÉ  rÅ  rÊ  z4context engine on_session_start (compression) failed)r2   rD   rm  ÚSESSION_COORDINATORÚnotify_session_compactedÚcurrent_profile_keyrÎ  rI   r«  r½   r.   r/   r0   )rD   r   rÉ  rm  Úcallbacks   &$$  r)   Ú+_notify_context_engine_compression_completers  ©	  sÛ   € ô 
Ð>È×	NÖ	NÝ'Ø×)Ñ)×BÑBØ%×9Ñ9Ó;Èð 	Cô 	
÷ 
Oô
 ˜nÔ=Ü�u×/Ñ/Ð1CÀTÓJ€HÜ�H×ÒÙðÙØ¨MÈ.Ü˜U J°Ó5×>Ð>¸Ü# EÐ+AÀ4ÓHõ	
ñ
 ÷ 
O×	Nûô  ô ô 	�‰ÐKÐVZˆÔ[Úð	ús#   –2B5ÂC ÂC Â5C	Ã"C.Ã-C.c               ó(   € V ^8„  d   QhRRRRRRRR/# )r#   rD   r   r   r%   rÉ  r5   rE   r'   )r(   s   "r)   r*   r*   Ä	  s1   € ÷ 
Bñ 
B¸#ð 
BÐRUð 
BÐgjð 
BÐosñ 
Br+   c               óš   a aa€ \        \        S \        R4      4      '       d   \        R4      hR V VV3R llp\	        S \        V4       R# )zCStage exactly one existing hook call for an outer host transaction.Nú-a compression notification is already pendingc               ó   € V ^8„  d   QhRR/# rb   r'   )r(   s   "r)   r*   ÚD_queue_context_engine_compression_notification.<locals>.__annotate__É	  s   € ÷ 
ñ 
�Tñ 
r+   c                 ó    <€ \        S SSR 7      # )©r   rÉ  )rs  )rD   r   rÉ  s   €€€r)   Ú_notifyÚ?_queue_context_engine_compression_notification.<locals>._notifyÉ	  s   ø€ Ü:Ø .Àô
ð 	
r+   )r½   rI   Ú$_PENDING_CONTEXT_ENGINE_NOTIFICATIONr¾   rÓ   )rD   r   rÉ  r{  s   fdd r)   Ú._queue_context_engine_compression_notificationr~  Ä	  s=   ú€ ä”˜ÔCÀTÓJ×KÒKÜÐJÓKÐK÷
ò 
ô
 ˆEÔ7¸ÖAr+   c               ó$   € V ^8„  d   QhRRRRRR/# )r#   rD   r   Ú	committedr&   r5   r'   )r(   s   "r)   r*   r*   Ñ	  s"   € ÷ ñ ¸Cð Ètð ÐX\ñ r+   c               óœ   € \        V \        R4      p\        V \        R4       V'       d   \        V4      '       g   R# \	        V! 4       4      # )zCEmit or discard a deferred notification; repeated calls are no-ops.NF)rI   r}  rÓ   r½   r&   )rD   r€  Úpendings   &$ r)   Ú0finalize_context_engine_compression_notificationrƒ  Ñ	  s:   € ä�eÔAÀ4ÓH€GÜˆEÔ7¸Ô>ßœH W×-Ò-ÙÜ‘“	‹?Ðr+   c                  ó:   € ] tR tRtRtR R ltRR/R R lltR	tR
# )Ú_CompactionLifecycleiÚ	  zÒOwns the one-shot terminal edge of the compaction status lifecycle.
``commit_status`` is rebound to "committed" only on success and read at ``complete()`` time, so abort
paths keep the terminal edge suppressed.c               ó$   € V ^8„  d   QhRRRRRR/# )r#   rD   r   Ústatus_emittedr&   r5   rE   r'   )r(   s   "r)   r*   Ú!_CompactionLifecycle.__annotate__ß	  s!   € ÷ 'ñ '˜cð '°4ð '¸Dñ 'r+   c                	ó:   € Wn         W n        R V n        RV n        R# )Fr+  N)r  r‡  Ú_done_emittedr-  )rü   rD   r‡  s   &&&r)   rý   Ú_CompactionLifecycle.__init__ß	  s   € ØŒØ,ÔØ"ˆÔØ&ˆÖr+   Úforce_terminalFc               ó    € V ^8„  d   QhRRRR/# )r#   rŒ  r&   r5   rE   r'   )r(   s   "r)   r*   rˆ  å	  s   € ÷ /ñ /¨$ð /¸4ñ /r+   c               	óÄ   € V P                   '       d   R # RV n         V P                  '       d3   V P                  R8X  g	   V'       d   \        V P                  4       R # R # R # )NTr€  )rŠ  r‡  r-  rK   r  )rü   rŒ  s   &$r)   ÚcompleteÚ_CompactionLifecycle.completeå	  sL   € Ø××ÐÙØ!ˆÔð ××Ð D×$6Ñ$6¸+Ô$EÏÜ! $§+¡+Ö.ñ JXÑr+   )r  rŠ  r-  r‡  N)rt  ru  rv  rw  rx  rý   r�  rz  r'   r+   r)   r…  r…  Ú	  s   † ñ0õ'ð/°÷ /ó /r+   r…  c                  óx   € ] tR tRtRtR R lt]R R l4       tR R ltR	 R
 lt	R R lt
R R ltR R ltRtR# )Ú_CompressionLeaseið	  ax  The per-attempt durable compression lock plus its lifecycle plumbing.
``holder`` is None when no durable lock is owned (legacy DB, no session db); ``watermark`` is the highest
active row the compaction already represents: MAX(id) at lease start, advanced to the newest row of an
adopted durable snapshot (None = archive everything, no concurrent-tail preservation this cycle).c               ó8   € V ^8„  d   QhRRRRRRRRRRR	R
RRRR/# )r#   rD   r   r^  Úsidr%   Úttlr¿   Úrefresh_intervalrŸ  r   rÒ  r…  r5   rE   r'   )r(   s   "r)   r*   Ú_CompressionLease.__annotate__ö	  sN   € ÷ )ñ )Øð)Ø!$ð)Ø+.ð)Ø5:ð)ØNQð)à6ð)àCWð)ð 
ñ)r+   c               	óÔ   € Wn         W n        W0n        W@n        WPn        W`n        Wpn        R V n        R V n        R V n	        RV n
        \        P                  ! 4       V n        RV n        R # ©NF)r  r^  r”  r•  Ú_refresh_intervalr  Ú
_lifecyclerë  Ú	watermarkÚ
_refresherÚ	_releasedr   r€   Ú_release_guardÚ_lock_setup_entered)rü   rD   r^  r”  r•  r–  rŸ  rÒ  s   &&$$$$$$r)   rý   Ú_CompressionLease.__init__ö	  s^   € ð ŒØŒØŒØŒØ!1ÔØ)ÔØ#ŒØ%)ˆŒØ(,ˆŒØDHˆŒØˆŒÜ'ŸnšnÓ.ˆÔð $)ˆÖ r+   c               ó   € V ^8„  d   QhRR/# rb   r'   )r(   s   "r)   r*   r—  
  s   € ÷ .ñ . ñ .r+   c                ó.   € V P                   P                  # )zSTrue when the routine compaction start status was shown (heartbeats may follow it).)r›  r‡  r  s   &r)   r‡  Ú _CompressionLease.status_emitted

  s   € ð �‰×-Ñ-Ð-r+   c               ó   € V ^8„  d   QhRR/# rb   r'   )r(   s   "r)   r*   r—  
  s   € ÷ (ñ ( $ñ (r+   c                	óx   € V P                   f   R# V P                   P                  4       V n        V P                  # r8  )r  r`  r   r  s   &r)   r`  Ú"_CompressionLease.begin_lock_setup
  s4   € Ø×ÑÒ%ÙØ#'×#5Ñ#5×#FÑ#FÓ#HˆÔ Ø×'Ñ'Ð'r+   c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   r—  
  s   € ÷ /ñ / 4ñ /r+   c                	óŒ   € V P                   '       d   V P                  f   R # RV n         V P                  P                  4        R # r™  )r   r  rd  r  s   &r)   rd  Ú#_CompressionLease.finish_lock_setup
  s6   € Ø×'×'Ð'¨4×+=Ñ+=Ò+EÙØ#(ˆÔ Ø×Ñ×,Ñ,Ö.r+   c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   r—  
  s   € ÷ 4ñ 4 ñ 4r+   c                	óX  € V P                   f   R # \        V P                  V P                  V P                   V P                  V P
                  4      pV P                  ;_uu_ 4        V P                  '       g   VP                  4       V n	        R R R 4       R #   + '       g   i     R # ; ir  )
rë  r\  r^  r”  r•  rš  rŸ  rž  r(  r�  )rü   Ú	candidates   & r)   Ústart_refresherÚ!_CompressionLease.start_refresher
  so   € Ø�;‰;ÒÙÜ2°4·7±7¸D¿H¹HÀdÇkÁkÐSW×S[ÑS[Ð]a×]sÑ]sÓtˆ	ð × × Ó Ø—>—>�>Ø"+§/¡/Ó"3�”÷ !× × Ò ús   Á&(BÂB)	c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   r—  %
  s   € ÷ Lñ L Tñ Lr+   c           	     óî  € V P                   ;_uu_ 4        V P                  '       d    RRR4       R# RV n        \        V P                  RR4      V P                  8X  d   RV P                  n        V P                  e7   \        R4      ;_uu_ 4        V P                  P                  4        RRR4       V P                  eq   V P                  '       d_   V P                  '       dM   \        R4      ;_uu_ 4        V P                  P                  V P                  V P                  4       RRR4       RRR4       R#   + '       g   i     L˜; i  + '       g   i     L-; i  + '       g   i     R# ; i)zÍStop this holder's refresher and release only its durable lock.
Holder-qualified and idempotent: safe for the host after a timeout because a newer holder's lease can
never be deleted by this stale release.NTÚ_active_compression_lock_holderz*compression lock refresher stop failed: %sz#compression lock release failed: %s)rŸ  rž  rI   r  rë  r²  r�  r2   r4  r^  r”  Úrelease_compression_lockr  s   &r)   Úrelease_holder_onlyÚ%_CompressionLease.release_holder_only%
  sò   € ð × × Ó Ø�~�~ˆ~Ø÷ !Ñ ð "ˆDŒNÜ�t—{‘{Ð$EÀtÓLÐPT×P[ÑP[Ô[Ø>B�—‘Ô;Ø�‰Ò*ÜÐJ×KÕKØ—O‘O×(Ñ(Ô*÷ Là�w‰wÒ" t§x§x x°D·K·K°KÜÐC×DÕDØ—G‘G×4Ñ4°T·X±X¸t¿{¹{ÔK÷ E÷ !Ñ ÷ L×Kú÷ E×Dú÷ !× Ð úsM   •E#³AE#ÂD=	Â-'E#ÃE#Ã'E#Ã:1E	Ä+E#Ä=EÅE#ÅE ÅE#Å#E4	c               ó   € V ^8„  d   QhRR/# r  r'   )r(   s   "r)   r*   r—  6
  s   € ÷ -ñ -˜ñ -r+   c                óf  €  V P                   P                  4         V P                  4         V P                  e&   V P                  P	                  V P                  4       V P                  4        R#   T P                  4        i ; i   T P                  e&   T P                  P	                  T P                  4       T P                  4        i   T P                  4        i ; i; i   T P                  4         T P                  e&   T P                  P	                  T P                  4       T P                  4        i   T P                  4        i ; i   T P                  e&   T P                  P	                  T P                  4       T P                  4        i   T P                  4        i ; i; i; i)z?Finish lifecycle cleanup and release the OLD session lock once.N)r›  r�  r´  r  ro  rd  r  s   &r)   r  Ú_CompressionLease.release6
  sJ  € ð
	-Ø�O‰O×$Ñ$Ô&ð-Ø×(Ñ(Ô*ð-Ø×)Ñ)Ò5Ø×*Ñ*×GÑGÈ×H`ÑH`Ôaà×*Ñ*Ö,ø�D×*Ñ*Õ,ûð	-Ø×)Ñ)Ò5Ø×*Ñ*×GÑGÈ×H`ÑH`Ôaà×*Ñ*Õ,ø�D×*Ñ*Õ,þð-Ø×(Ñ(Ô*ð-Ø×)Ñ)Ò5Ø×*Ñ*×GÑGÈ×H`ÑH`Ôaà×*Ñ*Õ,ø�D×*Ñ*Õ,ûð	-Ø×)Ñ)Ò5Ø×*Ñ*×GÑGÈ×H`ÑH`Ôaà×*Ñ*Õ,ø�D×*Ñ*Õ,ÿøs{   ‚C& �B ®3A3 Á3BÂC#Â
3CÂ=C#ÃC Ã C#Ã&F0Ã(EÃ93D=Ä,F0Ä=EÅF0ÅF-Å3FÆF-ÆF*Æ*F-Æ-F0)r  r  r›  r   rš  r�  rŸ  rž  r^  rë  r”  r•  rœ  N)rt  ru  rv  rw  rx  rý   ry  r‡  r`  rd  r®  r´  r  rz  r'   r+   r)   r’  r’  ð	  s@   † ñiõ
)ð( ô.ó ð.õ(õ/õ4õL÷"-ñ -r+   r’  c               ó    € V ^8„  d   QhRRRR/# )r#   rI  r   r5   ztuple[Any, Optional[Exception]]r'   )r(   s   "r)   r*   r*   E
  s   € ÷ ñ ˜sð Ð'Fñ r+   c                óÊ   € V f   R#  \        V 4      '       d   R# V P                  p\        T4      '       g   R\	        R4      3# TR3#   \         d   pRT3u Rp?# Rp?ii ; i)zÕReturn ``(try_acquire_compression_lock, lookup_error)`` for ``lock_db``.
``(None, None)`` = no db or legacy SessionDB without the lock API (fail open); ``(None, exc)`` = lookup
itself failed (caller fails closed).Nz0compression lock API is present but not callablerà   )rR  rL  r.   r½   rp   )rI  Útry_acquirer1   s   &  r)   Ú_resolve_lock_apir¼  E
  su   € ð ‚ØÐðÜ,¨W×5Ò5ØÐØ×:Ñ:ˆô �K× Ò Ø”YÐQÓRÐRÐRØ˜ÐÐøô	 ô Ø�SˆyÕûðús"   ˆA	 ›A	 Á	A"ÁAÁA"ÁA"c               ó4   € V ^8„  d   QhRRRRRRRRR	RR
RRR/# )r#   rD   r   rÒ  r…  ri  r%   rO   Ú_Attemptr/  Úpromptrœ  r5   útuple[None, str]r'   )r(   s   "r)   r*   r*   V
  sF   € ÷ 	ñ 	Øð	Ø/ð	ØADð	ØOWð	àð	à -ð	ð ñ	r+   c                óŒ   € Vf   \        W4      p\        WP                  WCP                  4       VP	                  RR7       RV3# )zVSit-out return for lease acquisition: prompt, aborted telemetry, terminal status edge.NT©rŒ  )rm  r   r¡  Úseedr�  )rD   rÒ  ri  rO   r/  r¿  s   &&&&&&r)   Ú_abort_leaserÄ  V
  sB   € ð
 ‚~Ü(¨Ó?ˆÜ# E×+=Ñ+=¸}ÏlÉlÔ[Ø×Ñ dÐÔ+Ø�ˆ<Ðr+   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r#   Úleaser’  r»  r   rŸ  r5   r&   r'   )r(   s   "r)   r*   r*   b
  s+   € ÷ ñ Ð%6ð ÀSð ÐX[ð Ð`dñ r+   c                ó\  €  V! V P                   V P                  V P                  R7      pV'       dp    V P                  P	                  V P                   4      V n        Ve>   \        P                  ! \        4      ;_uu_ 4        VP                  4        RRR4       V#  V# V#   + '       g   i     T# ; i  \         d4   p\        P                  RT P                   T4       RT n         Rp?T# Rp?ii ; i  \         d¨   p\        R4      ;_uu_ 4        T P                  P                  T P                   T P                  4       RRR4       M  + '       g   i     M; iRT n        \        P                  RT P                   \        T4      P                   T4        Rp?R# Rp?ii ; i)a»  Acquire the durable lock for ``lease.holder`` and capture the start watermark.
Watermark = MAX(id) of active rows at START: appends aren't blocked during summary; later rows are
concurrent tail that archive_and_compact re-sequences. Capture is safety-additive (fallback archives
everything), so its failure never aborts. An acquire that raises is not version skew: fail closed and
release holder-qualified best-effort (safe if never acquired).rq  Nu}   compression watermark capture failed for session=%s (%s) â€” concurrent appends this cycle will be archived with the snapshotz8compression lock cleanup after failed acquire failed: %sul   compression lock acquisition raised unexpectedly for session=%s (%s: %s) â€” skipping compression this cycleF)r”  rë  r•  r^  Úget_active_message_watermarkrœ  r�   r’   ÚAttributeErrorrP  r.   r/   rÒ   r2   r³  r¼   rt  )rÆ  r»  rŸ  ÚacquiredÚ_wm_errÚ	_lock_errs   &&&   r)   Ú_try_acquire_durable_lockrÍ  b
  sH  € ðÙ˜uŸy™y¨%¯,©,ÀEÇIÁIÔNˆßð'Ø"'§(¡(×"GÑ"GÈÏ	É	Ó"R�”ð  Ò+Ü#×,Ò,¬^×<Õ<Ø$×AÑAÔC÷ =ð ˆð ,ð ˆˆxˆ÷ =Ö<ð ˆûô ô 'Ü—‘ð9Ø:?¿)¹)ÀWôð #'�—�Øˆûð'ûô ô ÜÐP×QÕQØ�H‰H×-Ñ-¨e¯i©i¸¿¹ÔF÷ R×Q×QÐQúàˆŒÜ�‰ØzØ�I‰I”t˜I“×/Ñ/°ô	
õ ûðúsŠ   ‚0C9 ´AB8 ÂB$ÂB8 ÂC9 ÂC9 Â"C9 Â$B5	Â/B8 Â3C9 Â5B8 Â8C6Ã(C1Ã+C9 Ã1C6Ã6C9 Ã9F+ÄF&Ä1EÅ	F&ÅE!ÅAF&Æ&F+c               ó4   € V ^8„  d   QhRRRRRRRRR	R
RRRR/# )r#   rD   r   rÆ  r’  rÒ  r…  ri  r%   r©  rÏ   rO   r¾  r5   rÀ  r'   )r(   s   "r)   r*   r*   „
  sF   € ÷  ñ  Øð Ø(ð Ø5Ið Ø[^ð à ð à+3ð ð ñ r+   c                ód  € Rp\         P                  ! \        4      ;_uu_ 4        VP                  P	                  VP
                  4      pRRR4       \        P                  RVP
                  V4       RVn        T;'       g    RV n	        \        V RR4      VP
                  8w  dN   VP
                  V n        \         P                  ! \        4      ;_uu_ 4        V P                  R4       RRR4       \        WW5R\        W4      4      #   + '       g   i     LÉ; i  + '       g   i     L:; i)zNAnother path holds the lock: publish the lock-skip signal, warn once, sit out.Nu~   compression skipped: another path is compressing session=%s (holder=%s) â€” returning messages unchanged to avoid session forkTÚ"_last_compression_lock_warning_siduw   âš  Skipping concurrent compression â€” another path is already compressing this session. Will retry after it finishes.Úlock_contended)r�   r’   r.   r^  rè  r”  r/   rÒ   rë  rz  rI   rÐ  Ú_emit_warningrÄ  rm  )rD   rÆ  rÒ  ri  r©  rO   Úexistings   &&&&&& r)   Ú_sit_out_lock_contentionrÔ  „
  sí   € ð
 €HÜ	×	Ò	œY×	'Õ	'Ø—8‘8×7Ñ7¸¿	¹	ÓBˆ÷ 
(ä
‡N�Nð	MØNSÏiÉiÐYaôð €E„Lð .6×-=Ð-=¸€EÔ*äˆuÐ:¸DÓAÀUÇYÁYÔNØ38·9±9ˆÔ0Ü× Ò ¤×+Õ+Ø×Ñð%ô÷ ,ô ˜¨.ÐCSÔUlØóVó  ð  ÷) 
(×	'ú÷ ,×+ús   ¥&DÃDÄD	ÄD/	c               ó4   € V ^8„  d   QhRRRRRRRRR	R
RRRR/# )r#   rD   r   rŸ  r   rÒ  r…  ri  r%   r©  rÏ   rO   r¾  r5   z1tuple[Optional[_CompressionLease], Optional[str]]r'   )r(   s   "r)   r*   r*   ¢
  sO   € ÷ Gñ GØðGØ!AðGØNbðGàðGà(5ðGà@HðGð 7ñGr+   c               ó  € \        V RR4      pV P                  ;'       g    RpRV n        \        V4      w  r‰Rp
\        P
                  ! \        \        4      ;_uu_ 4        \        \        V RR4      ;'       g    R4      p
RRR4       \        WWz\        V RR4      VVR7      pVEe   V'       Ed   \        V 4      Vn        V	e6   RVn        \        P                  RV\        V	4      P                  V	4       R	pMœVf9   RVn        \        V R
R4      V8w  d   Wpn        \        P                  RV4       RpM`VP#                  4       '       g?   \        P%                  RV P                  ;'       g    R4       R	V n        \)        WW5R4      # \+        W¸V4      pV'       g   VP-                  4        \/        WW#WE4      # VP                  e¨   VP                  V n        Ve“   VP3                  VP4                  4      '       dr   \        P%                  RV P                  ;'       g    R4       R	V n        \7        W4      p\9        WP:                  RVP<                  4       VP?                  4        RV3# VR3#   + '       g   i     ELý; i)a²  Take the per-session compression lock; ``(None, prompt)`` means sit out.
Two AIAgents sharing a session_id (e.g. background review fork) would both rotate and orphan a child.
Keyed on the OLD id (what rivals read from SessionEntry). Loser sits out: messages unchanged, caller sees
no-op. Only structural absence of the lock API (version skew) fails open; once resolved, any exception
fails closed since unlocked runs can fork lineage.r´   NrX   g     Àr@Ú_compression_lock_ttl_secondsÚ"_compression_lock_refresh_interval)r^  r”  r•  r–  rŸ  rÒ  ug   compression lock lookup raised unexpectedly for session=%s (%s: %s) â€” skipping compression this cycleFÚ _last_compression_lock_error_siduÃ   compression lock subsystem unavailable for session=%s â€” proceeding without lock. This usually means a stale in-memory module after an update; restart the process (or `hermes update`) to resync.TzBCompression commit cancelled before lock acquisition (session=%s).r¶  Úcommit_fence_cancelledzBCompression commit cancelled before summary dispatch (session=%s).) rI   rÄ   rz  r¼  r�   r’   rp   r  r¿   r’  rö  rë  r/   rÒ   r¼   rt  rÙ  r`  rg   rÚ  rÄ  rÍ  rd  rÔ  r²  rj  r´  rm  r   r¡  rÃ  r  )rD   rŸ  rÒ  ri  r©  rO   Ú_lock_dbÚ	_lock_sidÚ_try_acquire_lockÚ_lock_lookup_errorÚ	_lock_ttlrÆ  Ú_lock_acquiredÚ_existing_sps   &$$$$$        r)   Ú_acquire_compression_leaserâ  ¢
  sV  € ô �u˜m¨TÓ2€HØ× Ñ ×&Ð& B€Ið .2€EÔ*Ü,=¸hÓ,GÑ)ÐØ€IÜ	×	Ò	œY¬
×	3Õ	3Üœ' %Ð)HÈ%ÓP×YÐYÐTYÓZˆ	÷ 
4äØ 	Ü  Ð(LÈdÓSÐbnØô€Eð
 Ó§	 	Ü/°Ó6ˆŒØÒ)ð  ˆEŒLÜ�N‰NØyØœ4Ð 2Ó3×<Ñ<Ð>Pôð #‰NØÒ&ð  ˆEŒLÜ�uÐ@À$ÓGÈ9ÔTØ9BÔ6Ü—‘ðlàôð
 "‰Nà×)Ñ)×+Ò+Ü—‘ØXÐZ_×ZjÑZj×ZtÐZtÐntôð 38�Ô/Ü# E°nÐOgÓhÐhÜ6°uÐQ]Ó^ˆNßØ×#Ñ#Ô%Ü+Ø˜i¸óð ð ‡|�|ÒØ05·±ˆÔ-ØÒ#¨×(TÑ(TÐUZ×UnÑUn×(oÒ(oä�K‰KØTÐV[×VfÑVf×VpÐVpÐjpôð /4ˆEÔ+Ü2°5ÓIˆLÜ+¨E×3EÑ3EÐG_Ðah×amÑamÔnØ�M‰MŒOØ˜Ð%Ð%Ø�$ˆ;Ð÷o 
4×	3Ð	3ús   Á!!I6É6J	c               ó4   € V ^8„  d   QhRRRRRRRRR	R
RRRR/# )r#   rD   r   rÆ  r’  r¨  r;   ri  r%   rO   r¾  r©  rÏ   r5   rî  r'   )r(   s   "r)   r*   r*   ì
  sF   € ÷ '"ñ '"Øð'"Ø(ð'"Ø48ð'"ØJMð'"Ø[cð'"à ð'"ð  ñ'"r+   c          
     ó  € VP                   e   VP                  '       g   R#  \        VP                   VP                  4      pT'       g   R# \        YP                   TP                  4      pTP                  4        \        YP                  RRYTP                  R7       \        Y4      p	Te/   \        P                  RTP                  T P                  4       Y‰3# \        P                  R	TP                  4       Y)3#   \         d€   p\        P                  RTP                  \        T4      P                  T4       TP                  4        \        YP                  RRYTP                  R7       T\        Y4      3u Rp?# Rp?ii ; i)
aZ  Sit out (or adopt the live child) when the parent was already rotated.
A late contender can take the parent lock after the winner released it and rotated; holding the lock does
not prove this agent still owns a live parent. Returns the ``compress_context`` result to hand back, or
None to proceed. Each returning exit logs its own attempt record.Nzecompression session ownership lookup failed for session=%s (%s: %s) - skipping compression this cycler+  Úsession_ownership_unreadable©r-  r/  r©  Úattempt_seedÚskippedÚsession_ownership_lostz<compression recovery: stale session=%s adopted live child=%szzcompression skipped: session=%s was already rotated by another compression path, but no unique live child could be adopted)r^  r”  rf  r.   r/   rÒ   r¼   rt  r  r   r¡  rÃ  rm  rà  rÄ   )
rD   rÆ  r¨  ri  rO   r©  Ú_parent_already_rotatedÚ_session_errÚrecovered_messagesrá  s
   &&&&$$    r)   Ú_adopt_if_parent_rotatedrí  ì
  sL  € ð ‡x�xÒ˜uŸyŸy˜yÙðHÜ"EÀeÇhÁhÐPU×PYÑPYÓ"ZÐ÷ #ÙÜ6°u¿h¹hÈÏ	É	ÓRÐØ	‡M�M„OÜ$Ø×!Ñ!°ÐJbØ#·,±,õô +¨5ÓA€LØÒ%Ü�‰ÐUÐW\×W`ÑW`Ðbg×brÑbrÔsØ!Ð/Ð/Ü
‡N�Nð	NØOTÏyÉyôð Ð!Ð!øô7 ô 
HÜ�‰ØsØ�I‰I”t˜LÓ)×2Ñ2°Lô	
ð 	�‰ŒÜ(Ø×%Ñ%°YÐNlØ'·l±lõ	
ð Ô0°ÓGÐGÕGûð
Hús   ¤ D ÄFÄA4FÆ FÆFc               ó(   € V ^8„  d   QhRRRRRRRR/# )	r#   rD   r   rÆ  r’  r¨  r;   r5   ro  r'   )r(   s   "r)   r*   r*     s+   € ÷ 0ñ 0 sð 0Ð3Dð 0ÐPTð 0ÐYgñ 0r+   c           	     óà  € VP                   e   VP                  '       g   R# \        \        VP                   4      RR4      p\	        V4      '       g   R# V! VP                   VP                  4      p\        V\        4      '       d   \        V4      \        V4      8”  g   R# \        V RR4      pRp\        V\        4      '       d^   ^ Tu;8:  d   \        V4      8  dF   M MBRp\        P                  ! \        4      ;_uu_ 4        V P                  W"RV R7      pRRR4       V'       g7   \        P                  RVP                  \        V4      \        V4      4       R# V! VP                   VP                  RR7      p\        V\        4      '       d   \        V4      \        V4      8”  g   R# V Uu. uF/  p\        VP                  R	R4      ;p\        4      '       g   K-  VNK1  	  p	pVP                   e%   V	'       d   \#        VP                   .V	O5!  Vn        \        P%                  R
VP                  \        V4      \        V4      4       V#   + '       g   i     ELB; iu upi )u¾  Return the durable parent transcript when it outgrew the in-memory snapshot.
Rotation only (in-place never loses rows). The snapshot predates the lease: if durable grew, a writer
committed a turn â€” ADOPT it (aborting wedged busy sessions forever). Length check only: in-memory edits of
past turns are legal. Adoption advances ``lease.watermark`` to the snapshot's newest row, so publication
clones only rows the snapshot does not already carry.NrÁ  Ú_persist_user_message_idxTF©Úconversation_historyu´   compression: session=%s grew before lease (%d â†’ %d msgs) but the pre-adoption flush of the live tail failed; skipping durable-snapshot adoption so un-persisted user input is kept)Úinclude_row_idsÚ_row_iduU   compression: session=%s grew before lease (%d â†’ %d msgs); adopting durable snapshot)r^  r”  rI   r¼   r½   r:   r;   r®  r†   r�   r’   r.   Ú_flush_messages_to_session_dbr/   rÒ   r0  rœ  rÀ   rg   )
rD   rÆ  r¨  Údurable_loaderÚdurable_parentÚ_preflush_idxÚ_preflush_okr>   ÚridÚadopted_row_idss
   &&&       r)   Ú_adopt_grown_durable_parentrü    sÔ  € ð ‡x�xÒ˜uŸyŸy˜yÙÜœT %§(¡(›^Ð-KÈTÓR€NÜ�N×#Ò#ÙÙ# E§H¡H¨e¯i©iÓ8€NÜ�~¤t×,Ò,´°^Ó1DÄsÈ8Ã}Ô1TÙô ˜EÐ#>ÀÓE€Mà€LÜ�-¤×%Ò%¨!¨}Ö*L¼sÀ8»}×*LØˆÜ× Ò ¤×+Õ+Ø ×>Ñ>¸xÐguÐhuÐ^vÐ>ÓwˆL÷ ,çÜ�‰ðfà�I‰I”s˜8“}¤c¨.Ó&9ô	
ñ
 á# E§H¡H¨e¯i©iÈÔN€NÜ�~¤t×,Ò,´°^Ó1DÄsÈ8Ã}Ô1TÙÙ$2Óe¡N˜q´jÈÏÉÈiÐY]ÓH^ÐA^ÀÔ`c×6d—s�s¡N€OÐeØ‡�Ò"§Ü˜eŸo™oÐ@°Ó@ˆŒÜ
‡K�KØ_Ðaf×ajÑajÔloÐpxÓlyÜˆNÓôð Ð÷) ,×+Ð+üò fs   ÄIÆ8*I+Ç'I+ÉI(	c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r#   rD   r   r¨  r;   Úcheckpoint_requiredr&   r5   r%   r'   )r(   s   "r)   r*   r*   I  s*   € ÷ $ñ $¨ð $°tð $ÐRVð $Ð[^ñ $r+   c                ó¼  € Rp\        V RR4      p\        V4      pV'       d'   \        V RR4      '       d   Vf   \        V RR4      RJpV'       d¡   \        VRR4      pVe   \        V4      '       g   \        R\         24      h \        V! \        4      4      pT'       g   \        R
\         24      h TP                  YR\        R7      p	\        T	\        4      '       d   \        T	4      pT# V'       da   \         P"                  ! \        4      ;_uu_ 4        VP                  WR7      p	\        V	\        4      '       d   \        V	4      pRRR4       V# V#   \         d   p\        R	4      ThRp?ii ; i  \         dC   p\        P                  R\        T4      P                  4       \        R\         R24      ThRp?ii ; i  + '       g   i     T# ; i)aB  Provider ``on_pre_compress()`` insights to surface in the summary ("" if none).
Raw messages stay the API v1 provider contract; normalized evidence goes only to API v2+ checkpoint
providers inside MemoryManager.on_pre_compress(). Raises :class:`CompressionCheckpointUnavailable` when a
required checkpoint cannot be taken.rX   rÕ  NÚ_persist_disabledFr´   Ú supports_pre_compress_checkpointz.no active provider implements checkpoint API vz provider capability probe failedz3active provider does not implement checkpoint API vT)Úevidence_messagesÚrequire_checkpointÚcheckpoint_api_versionz,Required pre-compress checkpoint failed (%s)zprovider checkpoint API vz failed)r  )rI   rZ  r½   rG  r   r&   r.   rF  Úon_pre_compressr/   rÒ   r¼   rt  r:   r%   r   r�   r’   )
rD   r¨  rþ  rü  Úmemory_managerr  Úsupports_checkpointÚ
compatibler1   Ú
_maybe_ctxs
   &&&       r)   Ú_pre_compress_memory_contextr
  I  sÜ  € ð
 €NÜ˜UÐ$5°tÓ<€NÜ@ÀÓJÐçœw uÐ.AÀ5×IÒIÈnÒNdÜ% e¨]¸DÓAÈÐMÐßÜ% nÐ6XÐZ^Ó_ÐØÒ!¬Ð2E×)FÒ)FÜ'Ð*XÔY|ÐX}Ð(~ÓÐð	SÜÑ1Ô2UÓVÓWˆJ÷ Ü'Ð*]ô  _Bð  ^Cð  )Dó  Eð  Eð	yØ'×7Ñ7ØÐRVÜ'Jð 8ó ˆJô �j¤#×&Ò&Ü4°ZÓ@ˆNð Ð÷ 
Ü× Ò ¤×+Õ+Ø'×7Ñ7¸Ð7ÓfˆJÜ˜*¤c×*Ò*Ü!8¸Ó!D�÷ ,ð Ðˆ>Ðøô' ô 	SÜ%Ð&HÓIÈsÐRûð	Sûô ô 	yÜ�N‰NÐIÌ4ÐPSË9×K]ÑK]Ô^Ü%Ð(AÔBeÐAfÐfmÐ&nÓoÐuxÐxûð	yú÷ ,Ö+ð Ðús<   ÂE Â6E: Ä4G
ÅE7Å&E2Å2E7Å:GÆ=GÇGÇ
G	c               ó4   € V ^8„  d   QhRRRRRRRRR	R
RRRR/# )r#   rD   r   r©  rÏ   rú  rœ  rû  r&   rü  r%   r›  r5   z)tuple[Callable[..., Any], dict[str, Any]]r'   )r(   s   "r)   r*   r*   p  sF   € ÷ (ñ (Øð(Ø"/ð(Ø>Kð(ØTXð(Øjmð(àð(ð /ñ(r+   c          	     óP  € V P                   P                  p\        WaW#VVR7      pVP                  4       '       dj   RV9  dc   \	        V P                   R\        V P                   4      P                  4      p\	        V RR4      V8w  d   W€n        \        P                  RV4       Wg3# )z>Bind ``compress()`` and only the kwargs its signature accepts.)rù  rú  rû  rü  r›  rü  ru   Ú'_last_memory_context_unsupported_engineNzfcontext engine %s does not accept memory_context; continuing without provider-supplied summary context)
r«  rZ   r
  r[   rI   r¼   rt  r  r/   rÒ   )	rD   r©  rú  rû  rü  r›  rø  Úcompress_kwargsÚengine_names	   &$$$$$   r)   Ú_resolve_compress_callr  p  s�   € ð
 ×*Ñ*×3Ñ3€KÜ3Ø¸{ÐhvØ'ô€Oð ×Ñ×ÒÐ"2¸/Ô"IÜ˜e×6Ñ6¸ÄÀU×E]ÑE]Ó@^×@gÑ@gÓhˆÜ�5ÐCÀTÓJÈkÔYØ<GÔ9Ü�N‰NØxØôð Ð'Ð'r+   c               ó8   € V ^8„  d   QhRRRRRRRRR	R
RRRRRR/# )r#   rD   r   r¨  r;   rø  zCallable[..., Any]r  rm   rŸ  r   rÍ   Úhard_cancel_eventr5   r'   )r(   s   "r)   r*   r*   …  sN   € ÷ 8ñ 8Øð8Øð8Ø-?ð8ØR`ð8à2ð8àHKð8à`cð8ð 
ñ8r+   c               ó¨  aa€ ^ RI HpHp ^ RIHp	 Se   SP
                  MR p
Se   \        V P                  V3R lV4       R VV3R llp\        P                  V4      p Se@   SP                  '       d.   \        P                  RV P                  ;'       g    R	4       TpM�V! V
4      ;_uu_ 4        V	! S4      ;_uu_ 4        V! VR
7      ;_uu_ 4        \        V P                  V4       V! V3/ VB pSe!   SP                  4       '       d   \!        4       hRRR4       RRR4       RRR4       \        P#                  V4       Se   \%        V P                  V4       X#   + '       g   i     LQ; i  + '       g   i     L\; i  + '       g   i     Lg; i  \        P#                  T4       Se   \%        T P                  T4       i i ; i)zQRun the compressor under the fence's progress hook, deadline and interrupt guard.)Úaux_interrupt_protectionÚaux_progress_hook)Úcompression_deadline_scopeNc                 ó   € R # r  r'   r'   r+   r)   Ú<lambda>Ú'_run_summary_dispatch.<locals>.<lambda>�  s   € Ñ[_r+   c                 ó   <€ S P                   # r  )r  )rŸ  s   €r)   r  r  ™  s   ø€ ¨l×.GÒ.Gr+   c               ó   € V ^8„  d   QhRR/# rb   r'   )r(   s   "r)   r*   Ú+_run_summary_dispatch.<locals>.__annotate__œ  s   € ÷ 
ñ 
¨4ñ 
r+   c                 óŽ   <€ \        SR J;'       d    SP                  4       ;'       g    S R J;'       d    S P                  4      # r  )r&   r8  r  )rŸ  r  s   €€r)   Ú_compression_cancel_requestedÚ<_run_summary_dispatch.<locals>._compression_cancel_requestedœ  sL   ø€ ÜØ dÐ*×IÐIÐ/@×/GÑ/GÓ/I÷ Hð HØ DÐ(×FÐF¨\×-FÑ-Fó
ð 	
r+   uU   Compression cancelled before summary dispatch (session=%s) â€” skipping summary work.r¶  )Úcancel_check)rÉ  r  r  Ú'agent.conversation_compression_deadliner  r  r¨   r«  rz   r.  r  r/   rg   rÄ   r”   r8  r   rÍ  r¬   )rD   r¨  rø  r  rŸ  rÍ   r  r  r  r  Ú_progress_hookr  Ú_attempt_ctx_tokenr  s   &&&&d$d       r)   Ú_run_summary_dispatchr$  …  sˆ  ù€ ÷ SÝRØ4@Ò4L�\×0Ò0ÑS_€Nð
 Òô 	-Ø×$Ñ$Ô&GÐI[ô	
÷
ñ 
ô 8×;Ñ;Ð<NÓOÐðfð Ò#¨×(A×(AÐ(AÜ�K‰KØgØ× Ñ ×*Ð* Fôð "‰Jñ " .×1Õ1Ñ3MÈl×3[Õ3[Ù(Ð6S×TÖTô
 1°×1IÑ1IÐK]Ô^Ù(¨ÑE°_ÑE�
à$Ò0Ð5F×5MÑ5M×5OÒ5OÜ7Ó9Ð9÷ U÷ 4\×1ô 	'×,Ñ,Ð-?Ô@ØÒ#Ü7¸×8PÑ8PÐRdÔeØÐ÷ U×Tú÷ 4\×3[ú×1×1ûô 	'×,Ñ,Ð-?Ô@ØÒ#Ü7¸×8PÑ8PÐRdÕeð $úsf   Á#F Á9"F ÂF Â6FÃE9	Ã9E&Ä
E&ÄE9	Ä%FÄ-F Å&E6Å1E9	Å9F	ÆFÆF	ÆF Æ2Gc               ó$   € V ^8„  d   QhRRRRRR/# )r#   rD   r   r  r;   r5   rE   r'   )r(   s   "r)   r*   r*   À  s+   € ÷ Glñ Gl˜sð Gl°ð Gl¸ñ Glr+   c                ó(  € V P                   P                  4       p\        V P                   RR4      pRp\        P                  ! \
        4      ;_uu_ 4        \        V4      '       d   \        V! 4       4      MRpRRR4       V'       d÷   \        \        V4      ^,
          RR4       FÕ  pW,          p\        V\        4      '       d   VP                  R4      R8w  d   K9  VP                  R4      p\        V4      pW‡8X  d   K]  VP                  R4      '       dE   \        Wx4      '       d4   VP                  V4       V\        V4      8  d   V P!                  V4       M\#        Wh4       VP                  RR4        M	  V'       Edp   \%        V4      p	V	'       d   V RV	 2p^ R	IHp
 RpV'       d'   \        VR,          \        4      '       d
   VR,          MRpVe÷   VP                  R4      R8X  dá   \        VP                  R4      4      pVP+                  4        UUu/ uF  w  rïVR8w  g   K  WïbK  	  pppVVR&   \-        V4      '       d;   \        V\.        4      '       d   V'       d   RV 2MTp\#        WÊ! VV4      4       R
pMJWÜP                  R4      8w  d6   \1        RRRV/4      P3                  4       '       g   \#        WÂ4       R
VR&   R
pV'       g   VP5                  RRRVRR
/4       R# R# R#   + '       g   i     EL‰; iu uppi )zSStrip stale todo snapshots from ``compressed`` and fold the live one in (in place).Ú	has_itemsNFrS  rW  rV  Ú_todo_snapshot_syntheticr-  )Ú_append_text_to_contentTrµ  )Ú_todo_storeÚformat_for_injectionrI   r�   r’   r.   r½   r&   ré  r®  r:   r<   rž   r  r  r0  Ú_repair_message_sequencer  r$  r9   r)  r=   rî  r%   rã  r[   rÓ  )rD   r  Útodo_snapshotÚ_todo_has_itemsÚ_todo_store_is_authoritativeÚ	_todo_idxÚ_todo_messageÚ_todo_contentÚ_todo_strippedÚ_reload_noticer)  r4  Ú_tailÚ	_strippedÚkeyrÖ   Ú_probeÚ_snapshot_texts   &&                r)   Ú_fold_todo_snapshotr:  À  s°  € à×%Ñ%×:Ñ:Ó<€Mô ˜e×/Ñ/°¸dÓC€Oð $)Ð Ü	×	Ò	œY×	'Õ	'ÜBJÈ?×B[ÒB[¤t©OÓ,=Ô'>ÐafÐ$÷ 
(ç#Üœs :›°Õ2°B¸Ö;ˆIØ&Õ1ˆMÜ˜m¬T×2Ò2°m×6GÑ6GÈÓ6OÐSYÔ6YÙØ)×-Ñ-¨iÓ8ˆMÜ7¸ÓFˆNØÔ.ÙØ× Ñ Ð!;×<Ò<ÔA_Ø÷Bò Bð —‘˜yÔ)Øœs :›Ô.ð ×2Ñ2°:Ô>øä(¨ÔGð ×!Ñ!Ð"<¸dÔCÙñ+ <÷, €}ô 5°ZÓ@ˆßØ,˜o¨T°.Ð1AÐBˆMõ 	EØˆß",´¸JÀr½NÌD×1QÒ1Q�
˜2–ÐW[ˆØÒ §¡¨6Ó!2°fÔ!<Ü2°5·9±9¸YÓ3GÓHˆIØ38·;±;´=ÔU±=¡Z SÀCÈ9ÑDT”j�c’j±=ˆFÑUØ )ˆF�9ÑÜ$ V×,Ò,Ü;EÀiÔQT×;UÒ;U×Zc 4¨ Ñ!7Ðiv�Ü(¨Ð0GÈ	ÐSaÓ0bÔcØ‘àŸY™Y yÓ1Ô1¼-ÈÐQWÐYbÐdmÐHnÓ:o×:uÑ:u×:wÒ:wô )¨Ô>Ø48�Ð0Ñ1Ø�ßØ×Ñ˜v v¨y¸-ÐIcÐeiÐjÖkñ ñI ÷3 
(×	'Ð	'üó^ Vs   Á$K:È"LÈ2LË:L	c               ó$   € V ^8„  d   QhRRRRRR/# rh  r'   )r(   s   "r)   r*   r*   
  s!   € ÷ 7ñ 7¨cð 7À3ð 7È3ñ 7r+   c                óx  € \        V RR4      RJ d/   V P                  '       d   ^ RIHp V! WRR7       V P                  # V P                  pV P	                  4         \        V 4       V P                  V4      pVe!   WC8X  d   T;qPn        ^ RIHp V! WR	R7       V# T;qPn        Vej   \        V R
R4      RJ d   \        P                  M\        P                  pT! RV P                  ;'       g    R\        V4      \        V4      4       RV n        V#   \         d    \        P                  RRR7        LÐi ; i)zJRefresh tool schemas and rebuild the system prompt at the commit boundary.Ú_retain_seeded_system_promptFT)Úreconstruct_static_prefixzcompression seeded-prompt)ri  Ú	log_labelzWcompaction tool-definition refresh failed; keeping the session's existing tool snapshotr-   zcompression keep-promptÚ_compaction_prompt_drift_loggedzªCompaction rebuilt a drifted system prompt (session=%s, %d -> %d chars): builder output changed since the stored snapshot (update, config change, or memory/skills growth)r¶  )rI   rk  Úagent.system_promptr>  Ú_invalidate_system_promptrj   r.   r/   rÒ   rl  r0   rg   rÄ   r®  r@  )rD   ri  r>  Úcached_system_promptÚrebuilt_system_promptÚnew_system_promptr  s   &&     r)   Ú"_rebuild_system_prompt_at_boundaryrF  
  sE  € äˆuÐ4°eÓ<ÀÓDð ×&×&Ð&ÝEÙ% eÐVqÕrØ×*Ñ*Ð*Ø ×6Ñ6ÐØ	×#Ñ#Ô%ð
Ü'¨Ô.ð "×6Ñ6°~ÓFÐØÒ'Ð,AÔ,YØ:NÐNÐÔ7ÝAÙ! %ÐRkÕlð Ðð ;PÐOÐÔ7ØÒ+ô #*¨%Ð1RÐTYÓ"ZÐ^bÓ"b”&—,’,Ôhn×hsÑhsˆCÙð]à× Ñ ×*Ð* F¬CÐ0DÓ,EÄsÐK\ÓG]ôð
 59ˆEÔ1ØÐøô? ô 
Ü�‰ØeÐptð 	ö 	
ð
ús   ÁD Ä"D9Ä8D9c               ó0   € V ^8„  d   QhRRRRRRRRRR	R
R/# )r#   rD   r   rG  r;   r  ri  r%   rO   r¾  r5   z$tuple[Optional[list], Optional[str]]r'   )r(   s   "r)   r*   r*   D  s<   € ÷ 9ñ 9Øð9Ø#'ð9Ø59ð9ØNQð9Ø\dð9à)ñ9r+   c               óÔ  € \        V4      p\        V4      pWe8”  dZ   ^ RIHp V! WVR7      pVeF   \        V4      p	W•8  d5   \        P	                  RV P
                  ;'       g    RVR V	R 4       TpT	pWe8”  Ed1   \        P                  RV P
                  ;'       g    RVR VR 4       \        P                  ! \        4      ;_uu_ 4        RV P                  n        RRR4       \        P                  ! \        4      ;_uu_ 4        V P                  R	4       RRR4       \        W4      p
\        WP                  R
VP                   4       \#        RRR7      ;_uu_ 4        V P                  P%                  4        RRR4       \'        V P                  VP(                  4       RV
3# VR3#   + '       g   i     LØ; i  + '       g   i     L¯; i  + '       g   i     L^; i)aB  Anti-growth guard at the COMMIT SITE (in-place commits before the gateway can inspect).
Compares like-for-like rough estimates; on growth tries one mechanical salvage pass, else treats the
attempt as a refused no-op. Returns ``(compressed, None)`` to proceed or ``(None, prompt)`` when refused
(caller releases the lease).)Úsalvage_grown_transcript)ÚbudgetNzTCompression salvage recovered a shrinking transcript (session=%s, ~%s -> ~%s tokens)r¶  r‹  z—Compression refused: compressed transcript would be larger than the original (session=%s, ~%s -> ~%s tokens); keeping the original transcript unchangedTu«   âš ï¸� Compression refused: the generated summary would have GROWN the conversation instead of shrinking it. No messages were dropped â€” conversation continues unchanged.Ú
would_growz+could not record rejected-compaction striker-   )r   r9   rI  r/   rg   rÄ   rÒ   r�   r’   r.   r«  Ú!_last_compress_refused_would_growrÒ  rm  r   r¡  rÃ  r2   Úrecord_rejected_compactionrv  r®   )rD   rG  r  ri  rO   Ú	_rough_inÚ
_rough_outrI  Ú	_salvagedÚ	_salv_estrá  s   &&&$$      r)   Ú#_salvage_or_refuse_grown_transcriptrR  D  s   € ô /Ð/@ÓA€IÜ/°
Ó;€JØÔõ 	FÙ,Ð->ÐS\Ô]ˆ	ØÒ Ü6°yÓAˆIØÔ$Ü—‘ØjØ×$Ñ$×.Ð.¨°9¸Q°-ÀYÈqÀMôð '�
Ø&�
ØÕÜ�‰ðAØBG×BRÑBR×B\ÐB\ÐV\Ø˜ˆmØ˜!ˆnô		
ô × Ò ¤×+Õ+ØIMˆE×$Ñ$ÔF÷ ,ä× Ò ¤×+Õ+Ø×Ñð_ô÷ ,ô
 /¨uÓEˆÜ'¨×/AÑ/AÀ<ÐQX×Q]ÑQ]Ô^ô ÐCÈd×SÖSð ×$Ñ$×?Ñ?ÔA÷	 Tô
 	$ E×$<Ñ$<¸g×>NÑ>NÔOØ�\Ð!Ð!Ø�tÐÐ÷% ,×+úç+×+ú÷ T×Sús$   ÃF1ÄGÅ&GÆ1G	ÇG	ÇG'	c               ó$   € V ^8„  d   QhRRRRRR/# r_  r'   )r(   s   "r)   r*   r*   €  s!   € ÷ ñ ¨3ð ¸Cð ÀDñ r+   c                ó  € \        V RR4      p\        V4      '       g   R#  ^ RIHp V! V4      ;'       g    / pVP	                  R4      RJ;'       d    V! VP	                  R4      4      '       * #   \
         d     R# i ; i)z›True when the parent row was ended by a non-automatic reason. Fails OPEN: an
unreadable row must not turn a cheap guard into a new way to lose compression.ra  NF)Úis_automatic_end_reasonrb  rc  )rI   r½   Úhermes_state_commonrU  rž   r.   )rÃ   rÄ   ÚreaderrU  Úrows   &&   r)   Ú_parent_deliberately_endedrY  €  s{   € ô �Z °Ó5€FÜ�F×ÒÙðÝ?Ù�ZÓ ×&Ð& BˆØ�w‰w�zÓ"¨$Ð.×eÐeÑ7NÈsÏwÉwÐWcÓOdÓ7eÔ3eÐeøÜô Úðús   ¢A1 ·A1 ÁA1 Á1B Á?B c               ó(   € V ^8„  d   QhRRRRRRRR/# )r#   rD   r   rÉ  r%   Ú	old_titler5   rE   r'   )r(   s   "r)   r*   r*   Ž  s/   € ÷ Oñ O¨ð O¸cð OÈcð OÐVZñ Or+   c                ó¬  € ^ RI Hp V! W4       \        R4      ;_uu_ 4        ^ RIHp V! W4       RRR4       V'       g   R# Rp\        R4      ;_uu_ 4        V P
                  P                  V4      pRRR4        V P
                  P                  V P                  V4       TeE   \        R4      ;_uu_ 4        T P
                  P                  T P                  T4       RRR4       R# R#   + '       g   i     LÄ; i  + '       g   i     L”; i  \         d"   p\        P                  RT4        Rp?R# Rp?ii ; i  + '       g   i     R# ; i)a¹  Migrate /goal, /heartbeat, /loop state, rejected-thinking fingerprints and the title from the parent to the child.
Each lookup is a flat per-session read with no parent walk, so state would silently die at the boundary. The title
is carried unchanged (renumbering per rotation made one session look like many); its provenance is read BEFORE the
transfer clears the ancestor's row, then restored so an inherited auto-title stays upgradeable.
)Úcarry_compression_automationz4Could not carry rejected thinking on compression: %s)Ú"carry_rejected_thinking_to_sessionNz#Could not read title provenance: %sz,Could not propagate title on compression: %sz(Could not propagate title provenance: %s)Úagent.compression_automationr]  r2   Úagent.anthropic_thinking_replayr^  r´   Úget_session_title_sourceÚset_session_titlerÄ   r.   r/   r0   Úset_session_title_source)rD   rÉ  r[  r]  r^  Ú_srcÚes   &&&    r)   Ú_carry_session_state_to_childrf  Ž  s  € õ JÙ  Ô7Ü	ÐH×	IÕ	IÝVÙ*¨5ÔA÷ 
J÷ ÙØ€DÜ	Ð7×	8Õ	8Ø× Ñ ×9Ñ9¸.ÓIˆ÷ 
9ðØ×Ñ×+Ñ+¨E×,<Ñ,<¸iÔHð
 ÒÜÐ@×AÕAØ×Ñ×6Ñ6°u×7GÑ7GÈÔN÷ BÑAñ ÷ 
J×	Iú÷ 
9×	8ûô ô Ü�‰ÐCÀQÔGÝûðú÷
 B×AÐAús;   ¢C-ÁD Á=&D Â:'EÃ-C=	Ä D	ÄD?ÄD:Ä:D?ÅE	c               ó$   € V ^8„  d   QhRRRRRR/# )r#   rD   r   r½  r%   r5   r'   )r(   s   "r)   r*   r*   ª  s&   € ÷ 	@ñ 	@ Sð 	@¸Sð 	@ÀSñ 	@r+   c                ó:  € Rp\         P                  ! \        4      ;_uu_ 4        V P                  P	                  V4      pRRR4       V'       d!   VP                  R4      '       d
   VR,          # ^ RIHp V! \        V RR4      4      #   + '       g   i     LQ; i)zÍThe parent row's persisted source: a compression child is the same conversation, so a ``--source tool``,
``oneshot`` or inherited ``kanban`` label must not degrade to the bare ``agent.platform`` (#112550).Nra  )Úsession_source_forrÅ  )	r�   r’   r.   r´   ra  rž   Úagent.session_sourceri  rI   )rD   r½  Úparentri  s   &&  r)   Ú_compression_child_sourcerl  ª  sr   € ð €FÜ	×	Ò	œY×	'Õ	'Ø×"Ñ"×.Ñ.Ð/@ÓAˆ÷ 
(ç�&—*‘*˜X×&Ò&Ø�hÕÐÝ7Ùœg e¨Z¸Ó>Ó?Ð?÷ 
(×	'ús   ¥B
Â
B	c               ó8   € V ^8„  d   QhRRRRRRRRRR	R
RRRRR/# )r#   rD   r   r¨  r;   r  rE  r%   rÆ  r’  rÉ  Úcompressed_user_turn_outcomer5   rE   r'   )r(   s   "r)   r*   r*   ¶  sb   € ÷ DDñ DDØðDDØðDDØ,0ðDDØHKðDDØTeðDDàðDDà7:ðDDð 
ñDDr+   c               ó@  € \        V RR4      p\        V\        4      '       d!   ^ Tu;8:  d   \        V4      8:  d	   M MVRV MRp\	        V P
                  V4      '       d   \        RV 24      hRp	\        P                  ! \        4      ;_uu_ 4        V P
                  P                  V P                  4      p	RRR4       \        P                  ! \        4      ;_uu_ 4        V P                  WR7       RRR4       Rp
\        P                  ! \        4      ;_uu_ 4        ^ RIHp V! 4       p
RRR4       V
R8X  d   RMT
p
V P
                  P                  V P                  4      p\!        4       p^ RIHp ^ RIHp V P
                  P+                  Y]\-        W4      V P.                  V! V P0                  V4      Y2\        V R	R4      T
VP2                  VP2                  RJVP2                  RJVP4                  V	e   VP6                  MRV	R
7       VR9   do   \9        R \;        V4       4       R4      p\        V\<        4      '       d=   RVV&   \        V RR4      p\        V\>        4      '       d   VVJd   \A        VVRR7       V F   p\        V\<        4      '       g   K  RVV&   K"  	  WÐn        RV n!        \E        V P                  4       RV n#        \I        WV4       R#   + '       g   i     EL3; i  + '       g   i     EL
; i  + '       g   i     ELä; i)zýRotate the session: flush the parent, publish the child, re-point the agent.
Flushes current-turn msgs to the OLD session, passing the durable prefix (messages[:persist idx]) so
preflight, which runs before rows are marker-stamped, can't re-append them.rð  Nz"Compression parent already ended: rñ  )Úget_active_profile_namery   r7   )Úwith_session_yoloÚworking_directory)r½  rÛ  ra  r­  Úmodel_configrÃ  r¨  ÚcwdÚprofile_nameÚcompression_lock_holderÚrequire_compression_leaseÚrequire_lease_refreshÚlease_ttl_secondsrœ  Úwatermark_ceilingc              3  óL   "  € T F  p\        V4      '       g   K  Vx € K  	  R # 5ir  rJ  )r  r>   s   & r)   r  Ú._publish_rotated_compaction.<locals>.<genexpr>ê  s   é € Ð)dÑ5G°ÔK`Ðab×Kc¯!ª!Ó5Gùs   ‚$š
$TÚ_session_messages)r^  >   r4  rA  )%rI   r:   r†   r®  rY  r´   r¾   r�   r’   r.   rÈ  rÄ   rõ  Úhermes_cli.profilesrp  Úget_session_titleÚmint_session_idr9   r8   Útools.approval_yolorq  Úpublish_compression_childrl  r­  Ú_session_init_model_configrë  r•  rœ  ÚnextrS  r<   r;   re  Ú_db_flush_scan_prefixr»  rÏ  rf  )rD   r¨  r  rE  rÆ  rÉ  rn  Úcurrent_idxÚpersisted_historyÚ_foreign_tail_ceilingÚ_profile_for_childrp  r[  r   r8   rq  Ú_compressed_anchor_sourcer}  Ú_handoff_messages   &&&$$$$            r)   Ú_publish_rotated_compactionrŒ  ¶  s¨  € ô ˜%Ð!<¸dÓC€Kä",¨[¼#×">Ò">À1ÈÖCdÔWZÐ[cÓWd×Cdˆ��+ÑÐjnð ô " %×"3Ñ"3°^×DÒDÜÐ?ÀÐ?OÐPÓQÐQð
 !ÐÜ	×	Ò	œY×	'Õ	'Ø %× 1Ñ 1× NÑ NÈu×O_ÑO_Ó `Ð÷ 
(ä	×	Ò	œY×	'Õ	'Ø×+Ñ+¨HÐ+Ô]÷ 
(ð ÐÜ	×	Ò	œY×	'Õ	'Ý?Ù4Ó6Ð÷ 
(ð "4°yÔ!@™ÐFXÐØ×!Ñ!×3Ñ3°E×4DÑ4DÓE€IÜ$Ó&€NÝ=Ý5Ø	×Ñ×/Ñ/Ø(Ü(¨Ó?ÀuÇ{Á{Ù& u×'GÑ'GÈÓXØ'Ü�EÐ.°Ó5ÐDVØ %§¡ÈÏÉÐ\`ÐH`Ø#Ÿl™l°$Ð6È%Ï)É)Ø&;Ò&G�5—?’?ÈTØ/ð 0ô 
ð $Ð'=Ô=ô %)Ñ)d´X¸hÔ5GÓ)dÐfjÓ$kÐ!ÜÐ/´×6Ò6Ø>BÐ%Ð&:Ñ;Ü '¨Ð/BÀDÓ IÐÜÐ+¬T×2Ò2Ð7HÐPXÓ7Xô $Ð$5Ð7PÐgkÕlÛ&ÐÜÐ&¬×-Ô-Ø59ÐÐ1Ó2ñ 'ð &ÔØ"&€EÔÜ˜E×,Ñ,Ô-Ø $€EÔÜ! %¸ÖC÷_ 
(×	'Ð	'úç	'×	'Ð	'ú÷
 
(×	'Ð	'ús$   Â&K$Ã$K8Ä#LË$K5	Ë8L		ÌL	c               ó    € V ^8„  d   QhRRRR/# rC   r'   )r(   s   "r)   r*   r*   ý  s   € ÷ ñ ¨ð °ñ r+   c                óº  € \        V P                  RR4      pV'       d2   \        V RR4      V8w  d   Wn        V P                  RV R24       R# R# \        V P                  RR4      p\        V P                  RR4      pW#3pV'       dR   \        V RR4      V8w  d>   W@n        \
        P                  R	Y#;'       g    R
4       V P                  RV R24       R# R# R# )zPSurface a failed summary, or a recovered-but-broken aux compression model, once.rº   NÚ!_last_compression_summary_warningu    âš  Compression summary failed: z%. Inserted a fallback context marker.Ú_last_aux_model_failure_modelÚ_last_aux_model_failure_errorÚ_last_aux_fallback_warning_keyzLConfigured compression model %r failed (%s); recovered using the main model.úunknown erroru"   â„¹ Configured compression model 'zn' failed, so Hermes summarised with your main model instead. Check auxiliary.compression.model in your config.)rI   r«  r�  rÒ  r’  r/   rÒ   )rD   Úsummary_errorÚ_aux_fail_modelÚ_aux_fail_errÚ_aux_keys   &    r)   Ú_warn_summary_or_aux_fallbackr˜  ý  sê   € ä˜E×4Ñ4Ð6KÈTÓR€MßÜ�5Ð=¸tÓDÈÔUØ6CÔ3Ø×ÑÐ"BÀ=À/ÐQvÐ wÖxñ Vô " %×":Ñ":Ð<[Ð]aÓbˆÜ × 8Ñ 8Ð:YÐ[_Ó`ˆà#Ð3ˆßœw uÐ.NÐPTÓUÐYaÔaØ3;Ô0Ü�N‰NØ^Ø×!AÐ!A°/ôð ×ÑØ4°_Ð4Eð Fbð böñ  b‰?r+   rÄ   rX   c               ó$   € V ^8„  d   QhRRRRRR/# )r#   Útask_idr%   rÄ   r5   rE   r'   )r(   s   "r)   r*   r*     s!   € ÷ (ñ ( cð (¸#ð (Àtñ (r+   c               óà  € \         P                  ! \        4      ;_uu_ 4        ^ RIHp V! V 4       RRR4       V'       d:   \         P                  ! \        4      ;_uu_ 4        ^ RIHp V! V4       RRR4       \         P                  ! \        4      ;_uu_ 4        ^ RIHp V! V 4       RRR4       R#   + '       g   i     LŒ; i  + '       g   i     L^; i  + '       g   i     R# ; i)a‡  Advance the file-read and skill_view repeat-read dedup to a fresh generation after a boundary.
The mtime map is kept: the first read of each unchanged key returns full content compaction may have
omitted; later reads return stubs, and stub-hit counters restart at the same boundary (#84857).
The computer_use screenshot dedup is session-keyed and forgets its last frame for the same reason.
)Úreset_file_dedupN)Úreset_screenshot_dedup)Úreset_skill_view_dedup)	r�   r’   r.   Útools.file_tools_read_trackingrœ  Útools.computer_use.toolr�  Útools.skills_toolrž  )rš  rÄ   rœ  r�  rž  s   &$   r)   Ú_reset_read_dedup_cachesr¢    s�   € ô 
×	Ò	œY×	'Õ	'ÝCÙ˜Ô!÷ 
(÷ Ü× Ò ¤×+Õ+ÝFÙ" :Ô.÷ ,ô 
×	Ò	œY×	'Õ	'Ý<Ù˜wÔ'÷ 
(Ñ	'÷ 
(×	'ú÷ ,×+ú÷ 
(×	'Ð	'ús#   £B6Á$C	ÂCÂ6C	Ã	C	ÃC-	c               óL   € V ^8„  d   QhRRRRRRRRR	R
RR
RR
RR
RR
RR
RR
RRRR/# )r#   rD   r   r  r;   rE  r%   rÉ  rœ  Úin_placer&   Úcompacted_in_placeÚsession_commit_succeededÚ!defer_context_engine_notificationÚcompression_made_progressÚcompression_used_fallbackÚcompression_feasibility_skiprš  r5   r†   r'   )r(   s   "r)   r*   r*   )  s‘   € ÷ [ñ [Øð[Ø ð[Ø8;ð[ØMZð[Øfjð[àð[à8<ð[àaeð[ð  $ð[ð AEð[ð eið[ð ð	[ð
 	ñ[r+   c       
        ó:  € TpT;'       g    V P                   ;'       g    RpV'       dc   V'       d[   \        RRR7      ;_uu_ 4        \        V RR4      p\        \        \	        V4      RR4      ;p4      '       d	   V! Wì4       RRR4       V'       dL   \        V4      '       g	   V'       d3   V'       d   \        M\        pT! Y P                   ;'       g    RVR7       \        R	4      ;_uu_ 4        \        V4      '       g	   V'       dF   V P                  '       d4   V P                  P                  V P                   ;'       g    RVR
RR7       RRR4       V P                  pVP                  pV^8¼  d+   V P                   RV R2pVV n        V P                  V4       \        V RR4      '       dk   \        R4      ;_uu_ 4        T P                  RRV P                   ;'       g    RRV P                   RT;'       g    RRVRVP                  /4       RRR4       WPn        WPn        \'        Y;'       g    RV P(                  ;'       g    RR7      pVVn        RVn        ^ Vn        RVn        \3        V R4       V'       d:   \        \	        V4      RR4      p\        V4      '       d   V! VWšR7       MRVn        \7        Y°P                   ;'       g    RR7       V#   + '       g   i     ELf; i  + '       g   i     EL­; i  + '       g   i     Lú; i)z•Post-commit bookkeeping: notify engines/providers/hooks, re-arm usage tracking.
Returns the rough post-compression token estimate (diagnostics only).rX   zGfailed to clear archived compression parent's activity labels (ignored)Tr-   r´   NÚclear_session_activity_labelsrz  z2memory manager on_session_switch (compression): %sFr¿  rÌ  u   âš ï¸�  Session compressed u>    times â€” accuracy may degrade. Consider /new to start fresh.Úevent_callbackz,event_callback error on session:compress: %szsession:compressrÅ  rÄ   rÉ  r¤  Úcompression_count)rÃ  ÚtoolsÚrecord_completed_compaction)Úused_fallbackÚfeasibility_skip©rÄ   rµ  )rÄ   r2   rI   r½   r¼   r&   r~  rs  rÕ  rÖ  r«  r®  Ú
log_prefixr{  r|  r­  rÅ  rÙ  rÚ  r   r¯  Úlast_compression_rough_tokensÚlast_prompt_tokensÚlast_completion_tokensÚ%awaiting_real_usage_after_compressionr   Ú$_verify_compaction_cleared_thresholdr¢  )rD   r  rE  rÉ  r¤  r¥  r¦  r§  r¨  r©  rª  rš  Ú_old_sidÚ_boundary_parentÚ
_labels_dbÚ_clear_labelsÚnotifyrl   Ú_ccÚ_cc_msgÚ_compressed_estÚrecord_boundarys   &&$$$$$$$$$$          r)   Ú_finish_compaction_boundaryrÃ  )  s¸  € ð €HØ×9Ð9 5×#3Ñ#3×9Ð9°rÐ÷ ×,ÜÐ_Ðjn×oÖoÜ  ¨°tÓ<ˆJÜ¬´°jÓ1AÐCbÐdhÓ)iÐi˜×jÒjÙ˜jÔ3÷ p÷  ¤T¨(§^¢^×7I÷ 1õ ;ä<ð 	ñ
 	ˆu×%5Ñ%5×%;Ð%;¸ÐL\Õ]ô 
ÐF×	GÕ	GÜ��NŠNŸh¨E×,A×,AÐ,AØ×!Ñ!×3Ñ3Ø× Ñ ×&Ð& BÐ:JÐRWÐ`mð 4ô ÷ 
Hð ×)Ñ)€JØ
×
&Ñ
&€CØ
ˆa„xà×ÑÐ Ð ;¸C¸5Ð@~Ðð 	ð &-ˆÔ"Ø×%Ñ% gÔ.ô ˆuÐ&¨×-Ò-ÜÐD×EÕEØ× Ñ Ø"à §¡× 4Ð 4°"°lÀE×DTÑDTØ$ h§n n°"°jÀ(Ø'¨×)EÑ)Eðô÷ Fð 0BÔ,Ø&8Ô#ô 4Ø×"9Ð"9°rÀÇÁ×ATÐATÐPTô€Oð 0?€JÔ,Ø$&€JÔ!Ø()€JÔ%Ø7;€JÔ4ô �U˜DÔ!÷ !Ü!¤$ zÓ"2Ð4QÐSWÓXˆÜ�O×$Ò$ÙØÐ*Cöð ?CˆJÔ;Ü˜W×1AÑ1A×1GÐ1GÀRÕHØÐ÷W p×oÐoú÷" 
H×	GÐ	Gú÷( F×Eús<   Á=K"Ã3K6ÄK6Ä'K6ÅK6Ç	8L
ÈL
Ë"K3	Ë6L	Ì
L	c               ó0   € V ^8„  d   QhRRRRRRRRRRR	R
/# )r#   rD   r   r  r¨  r;   Úmessages_before_compressionrO   r¾  r5   r&   r'   )r(   s   "r)   r*   r*   ‡  sF   € ÷ Kñ KØðKØðKØ+/ðKØNRðKàðKð 
ñKr+   c          	     óX  € \        V P                  RR4      '       d~   \        V P                  RR4      pT;'       g    Rp\        V RR4      V8w  d   W`n        V P                  RV R24       \	        YP
                  T;'       d    R	VP                  4       R
# W8X  g   \        V4      \        V4      8X  dœ   \        P                  RV P                  ;'       g    R4       \        RR
R7      ;_uu_ 4        \        \        V P                  RR4      ;p4      '       d	   V! R4       RRR4       \	        WP
                  RVP                  4       R
# V'       gŠ   \        P                  RV P                  ;'       g    R4       \        P                  ! \         4      ;_uu_ 4        V P                  R4       RRR4       \	        WP
                  RVP                  4       R
# \#        V P                  VP$                  4      '       gx   \        V P                  RR4      p\        P'                  RVP$                  TV P                  ;'       g    R4       RV n        \	        WP
                  RVP                  4       R
# R#   + '       g   i     ELd; i  + '       g   i     Læ; i)a  Reject an unusable compression candidate before any session mutation.
Order matters: compressor-reported abort, no progress, empty transcript, superseded attempt. Each branch surfaces
its own warning/telemetry; the caller releases the lease and returns the input unchanged when True.
Ú_last_compress_abortedFrº   Nr“  r�  u   âš  Compression aborted: uz   . No messages were dropped â€” conversation continues unchanged. Run /compress to retry, or /new to start a fresh session.Úsummary_generation_abortedTuH   Compression made no progress (session=%s) â€” skipping boundary rewrite.r¶  zno-progress backoff arm failedr-   Ú_record_structural_no_opz:compaction returned the transcript unchanged (no_progress)Úno_progresszocontext compression returned an empty transcript; refusing to rotate session=%s so the parent remains resumableuo   âš  Compression returned an empty transcript. No session split was performed; conversation continues unchanged.Úempty_transcriptr“   zŠDiscarding late compression candidate: attempt generation %s was superseded by a newer working attempt (current working: %s) (session=%s).Úattempt_superseded)rI   r«  r�  rÒ  r   r¡  rÃ  rA   r/   rg   rÄ   r2   r½   r¹  r�   r’   r.   r�   rŠ   rÒ   rÚ  )	rD   r  r¨  rÅ  rO   Ú_summary_errorÚ_errÚ	_recorderÚ_working_gens	   &&&&$    r)   Ú_candidate_rejectedrÑ  ‡  sQ  € ô ˆu×'Ñ'Ð)AÀ5×IÒIÜ  ×!9Ñ!9Ð;PÐRVÓWˆØ×0Ð0 ˆÜ�5Ð=¸tÓDÈÔLØ6:Ô3Ø×ÑØ+¨D¨6ð 2Lð Lôô
 	(Ø×%Ñ% ~×'VÐ'VÐ:VÐX_×XdÑXdô	
ñ ð Ô0Ü$ ZÓ0Ô4PÐQlÓ4mÔmä�‰ØVÐX]×XhÑXh×XrÐXrÐlrô	
ô
 Ð6À×FÖFÜ¤W¨U×-EÑ-EÐGaÐcgÓ%hÐh˜	×iÒiÙÐVÔW÷ Gô 	(¨×/AÑ/AÀ=ÐRY×R^ÑR^Ô_ÙßÜ�‰Ø}Ø×Ñ×&Ð& ô	
ô × Ò ¤×+Õ+Ø×Ñð Bô÷ ,ô 	(¨×/AÑ/AÐCUÐW^×WcÑWcÔdÙô ' u×'?Ñ'?À×ASÑAS×TÒTÜØ×$Ñ$Ð&OÐQUó
ˆô 	�‰ð_à×ÑØØ×Ñ×&Ð& ô	
ð +0ˆÔ'Ü'¨×/AÑ/AÐCWÐY`×YeÑYeÔfÙÙ÷I G×FÐFú÷ ,×+ús   Ã91JÆ)JÊJ	ÊJ)	c                  ó„   € ] tR tRt$ RtR]R&   R]R&   RtR]R	&   RtR]R
&   RtR]R&   Rt	R]R&   Rt
R]R&   RtR]R&   RtR# )Ú_CommitOutcomeiÕ  z<Result of the SessionDB commit phase (in-place or rotation).r;   r  r¿   Úcommit_started_atNrœ  Úrefused_promptrÉ  Únot_applicabler%   r.  Fr&   r¦  r¥  Úmade_progressr'   )rt  ru  rv  rw  rx  Ú__annotations__rÕ  rÉ  r.  r¦  r¥  r×  rz  r'   r+   r)   rÓ  rÓ  Õ  sO   ‡ áFàÓØÓØ$(€N�MÓ(Ø$(€N�MÓ(Ø(€L�#Ó(Ø%*Ð˜dÓ*Ø$Ð˜Ó$Ø€M�4×r+   rÓ  c          
     ó,   € V ^8„  d   QhRRRRRRRRR	R/# )
r#   rD   r   rœ  rÏ   r¨  r;   Úverbatim_tailro  r5   r'   )r(   s   "r)   r*   r*   ã  s8   € ÷ kñ k˜3ð k¨=ð kÀDð kÐYgð kÐlyñ kr+   c                óF   € \        V P                  V P                  WV4      # )z>The in-place commit's cap; see :func:`held_archive_watermark`.)r    r´   rÄ   )rD   rœ  r¨  rÚ  s   &&&&r)   Ú_held_watermarkrÜ  ã  s    € ä! %×"3Ñ"3°U×5EÑ5EÀyÐ\iÓjÐjr+   c               ó   € V ^8„  d   QhRR/# )r#   rl   r   r'   )r(   s   "r)   r*   r*   î  s   € ÷ 1ñ 1¨ñ 1r+   c           
   #  ó(  a "  € \         ;QJ d    . V 3R l\         4       F  NK  	  5M! V 3R l\         4       4      p Rx € \        \        V4       F<  w  r#\        P                  ! \
        4      ;_uu_ 4        \        S W#4       RRR4       K>  	  R#   + '       g   i     KS  ; i  \        \        T4       FP  w  r#\        P                  ! \
        4      ;_uu_ 4        \        S Y#4       RRR4       K>    + '       g   i     KO  ; i	  i ; i5i)zWRestore the live attempt's telemetry after a call that may reset it (the memory flush).c              3  ó>   <"  € T F  p\        SVR 4      x € K  	  R # 5ir  )rI   )r  ru   rl   s   & €r)   r  Ú*_hold_attempt_telemetry.<locals>.<genexpr>ð  s   øé € ÐWÑ=V°T”˜ T¨4×0Ð0Ó=Vùs   ƒN)ÚtupleÚ_ATTEMPT_TELEMETRY_FIELDSÚzipr�   r’   r.   rÓ   )rl   Úheldru   rÖ   s   f   r)   Ú_hold_attempt_telemetryrå  í  s³   øé € ÷ Œ5ÔWÕ=VÓW�5‰5ÔWÕ=VÓWÓW€Dð1ÛäÔ8¸$Ö?‰KˆDÜ×$Ò$¤Y×/Õ/Ü˜
 DÔ0÷ 0Ñ/ó @ß/×/Ð/ûô Ô8¸$Ö?‰KˆDÜ×$Ò$¤Y×/Õ/Ü˜
 DÔ0÷ 0×/×/Ò/úò @üsL   ƒ;D¿B) Á7DÁ:BÂDÂB&Â 	DÂ)8DÃ!C8Ã.
DÃ8D	ÄDÄDrÚ  Úcarried_messagesc               óP   € V ^8„  d   QhRRRRRRRRRR	R
RRRRRRRRRRRRRRRRR/# )r#   rD   r   r¨  r;   r  r¤  r&   rÆ  r’  rE  r%   ri  rn  rÅ  ro  r×  rO   r¾  rÚ  ræ  r5   rÓ  r'   )r(   s   "r)   r*   r*   ù  s�   € ÷ zñ zØðzØðzØ,0ðzØ?CðzØL]ðzàðzà,/ðzàORðzð "0ðzð AEðzð PXðzð "ð	zð =Kð	zð
 ñzr+   c       
        óx
  a$a%€ RpRp\         P                  ! 4       pRpRpV P                  '       Ed   Rp V Uu0 uF@  p\        V\        4      '       g   K  VP                  RR4      '       g   K5  \        V4      kKB  	  upo%Ve   TMTp\        V VW&V
R7      w  ppVf   \        VVVR7      # \        V P                  4      ;_uu_ 4        V P                  V4       RRR4       ^ RIHpHp ^ R	IHp V'       EdT   \#        V%3R
 lV 4       4      pV\%        ^ \'        V4      V,
          4      R p\)        V RR4      p\)        V RR4      eq   \        V\*        4      '       d[   ^ Tu;8:  d   \'        V4      8  dC   M M?^ RIHo$ V\#        V$3R lV\%        V\'        V4      V,
          4      R  4       4      ,          p^ RIHpHp T\'        V UUu0 uFy  p\        V\        4      '       g   K  \5        TVP7                  V4      ;'       g    R 4       F5  pVf   K	  V P                  P9                  V P:                  V4      f   K3  VkK7  	  K{  	  upp4      ,          pTpV'       d   V! W+4      pV\'        V4      ,          p^ RIHp V! V P                  V P:                  VV4      w  p p!V P                  P?                  V P:                  VVR/\A        WPB                  W4      VPD                  VVV V!R7	       TpRpT! . VOT;'       g    R O4       \G        4       V n$        RpV P                  PK                  V P:                  V4       ^ V n&        M_V P:                  pV'       d	   V! W+4      p\O        WW%VVVR7       V'       d	   V! V4       Rp\'        V4      V n&        V P:                  V n(        Rp\        W/VVVWéR7      # u upi   + '       g   i     ELñ; iu uppi   \R         EdN   p"T'       * ;'       d    T;'       d    T P:                  T8H  p#T#'       g   T'       dS   TR8w  dL   TeH   T#'       d   Rp\T        PV                  ! T4      TR&   TpRp	\Y        T P                  T
PZ                  4       Tf   T'       g   RMRpTf5   T'       g-   \\        P_                  RT P:                  ;'       g    RT"4       M\\        P_                  RT"4       \a        RRR7      ;_uu_ 4        T P                  Pc                  \d        RT" 24       RRR4        Rp"?"EKk    + '       g   i      Rp"?"EL€; iRp"?"ii ; i)!a­  Persist the compacted transcript: anti-growth guard, memory extraction, then the
in-place archive or the parent->child rotation.

Failures roll the live list back and arm the split-failure cooldown; a refused (would-grow) candidate returns
``refused_prompt`` so the caller hands back the input unchanged. ``verbatim_tail`` (``/compress here N``) is
re-inserted after the compacted head by either commit and stamped once durable.
FrÖ  Nr‚  Ú_compaction_tail)ri  rO   )r  rÕ  rÔ  )Ú&PROACTIVE_PRUNE_REARM_MODEL_CONFIG_KEYÚstamp_db_persisted_markers)Úrejoin_compressed_head_and_tailc              3  óL   <"  € T F  p\        V4      S9   g   K  ^x € K  	  R# 5i)é   N)rÓ  )r  r>   Ú_tail_tagged_idss   & €r)   r  Ú%_commit_compaction.<locals>.<genexpr>%  s   øé € Ð T©J q¼"¸Q»%ÐCSÑ:S§¢«Jùs   ƒ$š
$rð  Ú!_active_session_turn_lease_holderr7   c              3  óØ   <"  € T F_  p\        V\        4      '       g   K  VP                  S4      '       d   K4  \        VP                  R 4      \        4      '       d   K[  ^x € Ka  	  R# 5i)rô  N)r:   r<   rž   r†   )r  r>   r8   s   & €r)   r  rð  0  sO   øé € ð &CÙ#X˜aÜ% a¬×.ô Ø78·u±uÐ=Q×7Rô ä *¨1¯5©5°Ó+;¼S× A÷ šÓ#Xùs   ƒA* A*¹"A*Á 
A*)ÚABSORBED_ROW_IDSÚ_positive_id)Úcoverage_for_commit)Úmodel_config_patchrœ  Úlock_holderÚ
tail_countræ  Úcovered_idsÚunresolved_heldÚin_place_committedT)rE  rÆ  rÉ  rn  Úrotated_committedrq  r+  Úfailed_not_indexedzKCompression rotation aborted and rolled back to the parent session (%s): %srˆ  uK   Session DB compression split failed â€” new session will NOT be indexed: %sz'could not record split-failure cooldownr-   zsession_split_failed: )r  rÔ  rÉ  r.  r¦  r¥  r×  r'   )3rÁ   rÂ   r´   r:   r<   r0  rÓ  rR  rÓ  rå  r«  Úcommit_memory_sessionr9   rê  rë  Úhermes_cli.partial_compressrì  ÚsumrÀ   r®  rI   r†   r8   Ú&agent.conversation_compression_archiveró  rô  Úmaprž   Úget_message_rolerÄ   rõ  Úarchive_and_compactrÜ  rœ  rë  r.  rÔ  Úupdate_system_promptrÑ  rŒ  rÒ  r.   rr   rs   rv  r®   r/   rÒ   r2   Ú$_record_compression_failure_cooldownÚ_SPLIT_FAILURE_COOLDOWN_SECONDS)&rD   r¨  r  r¤  rÆ  rE  ri  rn  rÅ  r×  rO   rÚ  ræ  r¦  r¥  rÔ  r.  rÉ  r>   rG  Ú_refused_sprê  rë  rì  rø  Ú
_tail_heldÚ	_turn_idxró  rô  ÚrÚ	persistedrõ  rù  rú  re  Úrotation_rollbackr8   rï  s&   &&&$$$$$$$$$$                       @@r)   Ú_commit_compactionr  ù  sß  ù€ ð  %ÐØÐÜŸšÓ(ÐØ#€LØ$(€NØ××ÑØ ˆða	ñ 0:Óu©z¨!¼ZÈÌ4×=P¤ÐUV×UZÑUZÐ[mÐos×Ut¤¤ 1¦©zÑuÐØ?ZÒ?fÑ ;ÐltÐÜ&IØÐ(¨*Ð]dô'Ñ#ˆJ˜ð Ò!Ü%Ø'¸ÐWhôð ô )¨×)AÑ)A×BÕBØ×+Ñ+Ð,=Ô>÷ CçsÝSßˆxô
 !Ô T©JÓ TÓT�
Ø%¤c¨!¬S°«]¸ZÕ-GÓ&HÐ&IÐJ�
ô $ EÐ+FÈÓM�	Ü˜EÐ#FÈÓMÒYÜ& y´#×6Ò6¸1À	Ö;YÌCÐPXËM×;YÝMØ¤#ô &CØ#+¬C°	¼3¸x»=È:Õ;UÓ,VÐ,WÑ#Xó&Có #Cõ C�J÷ bØœcÙ)ô#nÙ)˜!¬Z¸¼4×-@”AÜ  ¨q¯u©uÐ5EÓ/F×/LÐ/LÈ"ÖM˜Øô à).×):Ñ):×)KÑ)KÈE×L\ÑL\Ð^_Ó)`÷ �AÙMñ ™zò#nó oõ o�
ð '�	ß ñ !@À
Ó Z�IØ¤# mÓ"4Õ4�JÝVÙ/BØ×%Ñ% u×'7Ñ'7Ø%Ø!ó0#Ñ,�˜_ð ×!Ñ!×5Ñ5Ø×$Ñ$ iÐEkÐmqÐDrÜ-¨e·_±_ÀhÓ^Ø %§¡¸ÐVfØ +¸_ð	 6ô ð '�
Ø3�ñ +Ð+P¨ZÐ+P¸=×;NÐ;NÈBÐ+PÔQÜ03³�Ô-ð &*Ð"à×!Ñ!×6Ñ6°u×7GÑ7GÐIZÔ[Ø-.�Õ*ð  "'×!1Ñ!1�ß ñ "AÀÓ![�JÜ+Ø ZÐ\aØ#1ÐPlõ÷ !Ù.¨}Ô=Ø2�Ü-0°«_�Ô*Ø7<×7GÑ7G�Ô4Ø'+Ð$ôh ØÐSaØ!Ð<TØ-ôð ùò  v÷ C×BÐBüó:#nøôF õ 2	ð %-¤× fÐ f°× fÐ fÀE×DTÑDTÐXfÑDfÐß ß˜\Ð-AÔAÐFaÒFmç$Ø%)�Nô$ #ŸmšmÐ,GÓH�˜‘Ø%�
Ø %�Ü+¨E×,DÑ,DÀg×FVÑFVÔWØ(6Ò(>Çx™9ÐUiˆLð Ò%¯hÜ—‘ØaØ×$Ñ$×+Ð+¨¨Qõô
 —‘ÐlÐnoÔpô ÐCÈd×SÖSà×(Ñ(×MÑMÜ3Ð7MÈaÈSÐ5Qô÷ T×S×S×SÓSþð]2	úsÔ   ¶O  ºOÁOÁ1OÂ .O  Â/O  ÃOÃO  Ã=CO  ÇOÇ-OÈOÈ%OÉ
OÉO  É'C<O  Í$AO  ÏO  ÏO	ÏO  Ï T9Ï,T4ÐT4ÐT4Ð$T4Ð7A
T4ÒT4Ò"T4Ò54T4Ó)$TÔT4ÔT1Ô'T4Ô1T4Ô4T9c                  ól   € ] tR tRt$ RtR]R&   RtR]R&   RtR]R	&   RtR
]R&   ^ t	R]R&   Rt
R]R&   RtR# )Ú_SummaryPhasei¶  zPOutcome of the summary phase; ``abort_prompt`` set means hand ``messages`` back.r;   r¨  Nr   r  ro  rÅ  rÏ   r©  r†   Úpre_msg_countrœ  Úabort_promptr'   )rt  ru  rv  rw  rx  rØ  r  rÅ  r©  r  r  rz  r'   r+   r)   r  r  ¶  s=   ‡ áZàƒNØ€J�ÓØ26Ð Ó6Ø#'€M�=Ó'Ø€M�3ÓØ"&€L�-×&r+   r  c               óP   € V ^8„  d   QhRRRRRRRRR	RR
RRRRRRRRRRRRRRRRR/# )r#   rD   r   r¨  r;   rÆ  r’  r¤  r&   rþ  r©  rÏ   rú  rœ  rû  r›  rŸ  r   r  ri  r%   rO   r¾  r5   r  r'   )r(   s   "r)   r*   r*   Â  sš   € ÷ _ñ _Øð_Øð_Ø*;ð_ØGKð_Øbfð_à ð_à/<ð_àEIð_à\`ð_ð 3ð_ð HKð_ð ]`ð_ð ð	_ð
 ñ_r+   c          
     ó¶  a€ \        V4      pRoRpR V3R llp VP                  4        V'       g0   \        WV4      pVe    Tp\        V4      p^ p\        V4      V n        \	        WV4      p\        WWgVVR7      w  pp\        P                  ! V4      p\        W	VP                  R7      P                  4       o\        \        RR\        VP                  4      34       FH  w  pp\        P                   ! \"        4      ;_uu_ 4        \%        V P&                  VV4       RRR4       KJ  	  \)        WVVV	VP*                  V
R7      p T! R4       \G        TTTY]R7      #   + '       g   i     K�  ; i  \,         Edc     TP/                  T P&                  4       Mn  \0         da   p\3        Y4       T! R4       TP5                  4        \7        YP8                  R\;        T4      P<                   2TP                  4       h Rp?ii ; i\3        Y4       \?        Y	TP8                  TTR	7      pT! R
4       TP5                  4        T	RJ;'       d6    T	P@                  ;'       d"    T
RJ;'       d    T
PC                  4       '       * p\7        YP8                  T'       d   \D        MT'       d   RMRTP                  4       \G        T\I        Y4      R7      u T! R4       # \0         da   p\3        Y4       T! R4       TP5                  4        \7        YP8                  R\;        T4      P<                   2TP                  4       h Rp?ii ; i  T! R4       i ; i)a  Adopt a grown durable parent, gather memory context and run the summarizer.
A hard cancel restores the compressor snapshot + live list, records a stall backoff while the lease is
still held, and aborts; any other failure restores the live list, releases the lease and re-raises.Nc               ó    € V ^8„  d   QhRRRR/# r+  r'   )r(   s   "r)   r*   Ú(_run_summary_phase.<locals>.__annotate__Ï  s   € ÷ 'ñ '˜cð ' dñ 'r+   c                ó:   <€ Se   SP                  V 4       R oR # R # r  )r4  )r,  Ú_activity_heartbeats   &€r)   Ú_stop_heartbeatÚ+_run_summary_phase.<locals>._stop_heartbeatÏ  s"   ø€ àÒ*Ø×$Ñ$ TÔ*Ø"&Òñ +r+   )r©  rú  rû  rü  r›  )rŸ  r  )rŸ  rÍ   r  z#context compression rollback failedz	rollback:©rŸ  r¡  r¨  r©  zcontext compression cancelledrÚ  Úexplicit_interrupt)r¨  r  rO  zcontext compression failedú
exception:)r¨  r  rÅ  r©  r  )%r®  r®  rü  rð  r
  r  rr   rs   r  r‡  r(  rã  râ  r<   rÃ  r�   r’   r.   rÓ   r«  r$  rŠ   r   Úrestore_compressorrA  rr  r  r   r¡  r¼   rt  rº  r  r8  r·  r  rm  )rD   r¨  rÆ  r¤  rþ  r©  rú  rû  r›  rŸ  r  ri  rO   r  rÅ  r  Ú_adopted_parentrü  rø  r  Ú_nameÚ_valuer  Ú_rollback_excÚ_stall_backoffÚ_host_cancelÚ_compress_excr  s   &&$$$$$$$$$$$              @r)   Ú_run_summary_phaser&  Â  s'  ø€ ô ˜“M€MØCGÐØ"&Ð÷'ð 'ðH9Ø×ÑÔßÜ9¸%ÈÓQˆOØÒ*Ø*�Ü # H£�à !�ô 36°h³-�Ô/Ü5°eÐGZÓ[ˆÜ'=Ø¸KÐesØ+ô(
Ñ$ˆ�_ô '+§m¢m°HÓ&=Ð#Ü;ØÀ×AUÑAUô
ç
‰%‹'ð 	ô
 !Ô!:¸TÀ4ÌÈgÏlÉlÓI[Ð<\Ö]‰MˆE�6Ü×$Ò$¤Y×/Õ/Ü˜×0Ñ0°%¸Ô@÷ 0Ñ/ñ ^ô +Ø˜[¨/ÈØ&×1Ñ1ÐEVô
‰
ñ\ 	Ð7Ô8ÜØ jÐNiØ#ôð ÷c 0×/Ð/ûô )õ  mð	Ø×&Ñ& u×'?Ñ'?Õ@øÜô 		ô ' xÔMÙÐAÔBØ�M‰MŒOÜ+Ø×)Ñ)¨Y´t¸MÓ7J×7SÑ7SÐ6TÐ+UÐW^×WcÑWcôð ûð		úô 	# 8ÔIô ;Ø¸×9KÑ9KÐV^Ø'ô
ˆñ 	Ð7Ô8Ø�‰Œð $¨4Ð/÷ 
ð 
°L×4MÑ4M÷ 
ð 
Ø TÐ)×HÐHÐ.?×.FÑ.FÓ.HôS
ˆô 	(Ø×%Ñ%ß/=Õ+ß-9Ñ)Ð?SÐU\×UaÑUaô	
ô
  hÔ=TÐUZÓ=kÔlÑlñ 	Ð7Õ8ô ô Ü" 8ÔIÙÐ4Ô5Ø�‰ŒÜ'Ø×%Ñ%¨´D¸Ó4G×4PÑ4PÐ3QÐ'RÐT[×T`ÑT`ô	
ð 	ûðûñ 	Ð7Õ8ús‡   ›C.E4 Ä	E Ä!'E4 Å E1Å+	E4 Å4MÆFÆMÆHÆ(AHÈHÈAMÉ&MÉ2;MÊ.)MËM Ë!MË*MË+AMÍMÍM Í
Mc                  ól   € ] tR tRt$ RtR]R&   R]R&   R]R&   R	]R
&   RtR]R&   RtR]R&   R R ltRt	R# )r¾  i$  zIPer-attempt ownership state threaded through the compress_context phases.r<   r®   r†   rŠ   r¿   r¡  rm   rÃ  Nr°   rË   r²   rÌ   c               ó    € V ^8„  d   QhRRRR/# r–   r'   )r(   s   "r)   r*   Ú_Attempt.__annotate__1  s   € ÷ 
ñ 
¨Sð 
°Tñ 
r+   c                ót   € \        WP                  V P                  V P                  V P                  R7       R# )zPRoll the compressor back to this attempt's snapshot (durable cooldown included).)rË   rÌ   rÍ   N)r×   r®   rË   rÌ   rŠ   )rü   rl   s   &&r)   r  Ú_Attempt.restore_compressor1  s+   € ä)ØŸ™Àd×FiÑFiØ#'×#>Ñ#>ÐSW×SbÑSb÷	
r+   r'   )
rt  ru  rv  rw  rx  rØ  rË   rÌ   r  rz  r'   r+   r)   r¾  r¾  $  s>   ‡ áSàƒNØƒOØÓð ÓØ59Ð" NÓ9Ø7;ÐÐ4Ó;÷
ñ 
r+   r¾  Útriggerr©  Úoverflow_reasonc               ó4   € V ^8„  d   QhRRRRRRRRRR	R
RRR/# )r#   rD   r   rû  r&   Údefer_notificationr,  rœ  r©  rÏ   r-  r5   r¾  r'   )r(   s   "r)   r*   r*   9  sF   € ÷ &<ñ &<Øð&<Øð&<Ø48ð&<ØCPð&<à ð&<à:Gð&<ð ñ&<r+   c          
     óÀ  € \        V P                  4      p\        V P                  4      pV'       d,   \        \	        V \
        R4      4      '       d   \        R4      hRV n        RV n        RV n	        RV n
        \        P                  ! 4       p\        P                  ! 4       P                  p	T;'       g    V'       d   RMRpRT	R\	        V RR4      ;'       g    RR	VR
V/p
\         P"                  ! \$        4      ;_uu_ 4        W�n        ^ RIHp T! Y4;'       g    \	        V P                  RR4      4       RRR4       \-        WgWŠ4      #   + '       g   i     L; i)aC  Snapshot + claim the compressor, reset per-attempt agent signals, build this attempt's telemetry seed
(written to the compressor only at dispatch, in ``_run_summary_phase``).
The claim stops a late-unwinding sibling (stall-fallback overlap) from restoring its snapshot over ours or
clearing our cancellation consult. Signals are cleared at the VERY TOP, before codex/breaker
early-returns, so a stale value cannot make a later no-op look like lock contention;
``_last_compression_attempt_in_place=None`` means aborted/no boundary for
``conversation_history_after_compression()``.Nrv  TÚmanualr‰  Ú
attempt_idrÄ   rX   Útrigger_sourcer-  )Úbegin_compression_attemptr¶  )rw   r«  r‹   r½   rI   r}  r¾   rØ  rÙ  rz  r«  rÁ   rÂ   ró  rô  rõ  r�   r’   r.   Ú_compression_attempt_idÚ.hermes_cli.observability.shared_metrics_eventsr4  r¾  )rD   rû  r/  r,  r©  r-  r®   rŠ   r¡  r2  rÃ  r4  s   &$$$$$      r)   Ú_begin_compression_attemptr7  9  s  € ô 2°%×2JÑ2JÓK€HÜ*¨5×+CÑ+CÓD€Jßœh¤w¨uÔ6ZÐ\`Ó'a×bÒbÜÐJÓKÐKØ/3€EÔ,Ø/3€EÔ,Ø-1€EÔ*ð ,0€EÔ(Ü—’Ó!€JÜ—’“×!Ñ!€JØ×8Ð8§e™(°€Gà�j ,´¸¸|ÈTÓ0R×0XÐ0XÐVXÐZjÐlsØ˜?ð€Dô 
×	Ò	œY×	'Õ	'Ø(2Ô%Ý\á! '×+yÐ+y¼GÀE×D\ÑD\Ð^rÐtxÓ<yÔz÷	 
(ô
 �H¨*Ó;Ð;÷ 
(×	'ús   Ä4EÅE	c               ó<   € V ^8„  d   QhRRRRRRRRR	R
RRRRRRRR/	# )r#   rD   r   r¨  r;   ri  r%   rŸ  r   rO   r¾  r©  rÏ   rš  rû  r&   r5   r#  r'   )r(   s   "r)   r*   r*   b  sV   € ÷ )ñ )Øð)Øð)Ø03ð)ØFfð)àð)à&3ð)à>Að)àJNð)ð ñ)r+   c               ó�  € Vep   VP                  \        V RR4      4      '       gN   VP                  V P                  4       \	        WP
                  RRVRVP                  R7       V\        W4      3#  \        WW%WgVP
                  VP                  R7      Ve   VP                  4        # #   Te   TP                  4        i i ; i)zOCodex owns the real thread: run its own compact under the commit fence bracket.Nrð  r+  rÚ  Úcodex_app_server©r-  r/  r©  rÔ  rç  )r©  rš  rû  r¡  rç  )
r:  rI   r  r«  r   r¡  rÃ  rm  r   r?  )rD   r¨  ri  rŸ  rO   r©  rš  rû  s   &&&$$$$$r)   Ú_route_codex_compactionr<  b  sÆ   € ð
 Ò¨×(AÑ(AÄ'È%ÐQlÐnrÓBs×(tÒ(tØ×"Ñ" 5×#;Ñ#;Ô<Ü(Ø×%Ñ%°YÐNfØ'Ð/AÐPW×P\ÑP\õ	
ð Ô0°ÓGÐGÐGð)Ü5Ø˜^ÐRYØ×)Ñ)¸¿¹ô
ð
 Ò#Ø×&Ñ&Õ(ð $øˆ<Ò#Ø×&Ñ&Õ(ð $ús   Á5#B. ÂB. Â.Cc               ó    € V ^8„  d   QhRRRR/# rC   r'   )r(   s   "r)   r*   r*   x  s   € ÷ ñ  Cð ¨Dñ r+   c                óÜ   € \        V RR4      R8w  d   R# \        V RR4      p\        V4      '       d&   \        R4      ;_uu_ 4        V! 4        RRR4       R# R#   + '       g   i     R# ; i)z\Re-resolve a rotating Anthropic OAuth token so the summary call never carries a revoked one.rÇ  NÚanthropic_messagesÚ)_try_refresh_anthropic_client_credentialsz-pre-compression credential refresh failed: %s)rI   r½   r2   )rD   rÞ   s   & r)   Ú_refresh_main_credentialrA  x  sZ   € äˆu�j $Ó'Ð+?Ô?ÙÜ�eÐHÈ$ÓO€GÜ�×ÒÜÐE×FÕFÙŒI÷ GÑFñ ßF×FÐFús   ÁAÁA+	c               ó0   € V ^8„  d   QhRRRRRRRRR	R
RR/# )r#   rD   r   Úmessage_countr†   r©  rÏ   rú  rœ  rû  r&   r5   r…  r'   )r(   s   "r)   r*   r*   ‚  s<   € ÷ 5ñ 5Øð5Ø"%ð5Ø6Cð5ØR_ð5Øhlð5àñ5r+   c          
     óH  € \         P                  RV P                  ;'       g    RY'       d   VR MRV P                  V4       \        pV'       g%   \        V P                  RWRWP                  VR7      pV'       d   V P                  V4       \        V \        V4      4      # )zXLog the attempt, emit the (engine-customisable) compacting status, return the lifecycle.zPcontext compression started: session=%s messages=%d tokens=~%s model=%s focus=%rr¶  r‹  r¢  rZ   )ÚphaseÚdefault_messager©  rC  r­  rú  )
r/   rg   rÄ   r­  ÚCOMPACTION_STATUSr   r«  rF  r…  r&   )rD   rC  r©  rú  rû  Ústatuss   &$$$$ r)   Ú_announce_compression_startrI  ‚  sŠ   € ô ‡K�KØZÐ\a×\lÑ\l×\vÐ\vÐpvØ®}˜-¨Ñ*À)ÈUÏ[É[ÐZeôô €FßÜ4Ø×$Ñ$¨JÈØ'¯{©{Èô
ˆ÷ Ø×Ñ˜6Ô"Ü ¤t¨F£|Ó4Ð4r+   rš  ry   rú  rû  r§  rŸ  Úsnapshot_is_currentc               óT   € V ^8„  d   QhRRRRRRRRR	RR
RRRRRRRRRRRRRRRRRRR/# )r#   rD   r   r¨  r;   ri  r%   r©  rÏ   rš  rú  rœ  rû  r&   r›  r§  rŸ  r   rÚ  ro  r,  rJ  zOptional[Callable[[], bool]]r-  r5   r#  r'   )r(   s   "r)   r*   r*   •  sª   € ÷ A-ñ A-ØðA-ØðA-Ø03ðA-ØGTðA-àðA-à+8ðA-àHLðA-ð ðA-ð GKðA-ð 3ð	A-ð KYð	A-ð
 ðA-ð
 9UðA-ð #ðA-ð ñA-r+   c               óô  a € \        S WhVW=R7      p\        S RR4      RJ p\        S RR4      R8X  db   V'       dJ   \        R4      p\        S VP                  R	R
\        V4      P                   2VRVP                  R7       Vh\        S WWžVWFR7      # V'       gE   \        S V4      ;p'       d1   \        S VP                  W>P                  V4       V\        S V4      3# \        V4      p\        \        S RR4      4      p\        S VW5VR7      p\        S 4       \        S RR4      '       g    \!        S 4       RS n        \)        S V	VVW>R7      w  ppVf   VV3# VP+                  4         VRJ ;'       g    V! 4       pT'       gA   \1        S TP                  RTP                  4       TP/                  4        T\        S T4      3# \3        S TYYãR7      pTe   T# \5        S P6                  TP8                  4      w  Tn        Tn        TP:                  RJ dC   TP/                  4        \        S TP                  R	RY>P                  R7       T\        S T4      3# T'       d   RM\        S TRR7      pT'       dA   TP/                  4        \        S TP                  Y>P                  T4       T\        S T4      3# \        S RR4      p\?        S TTTTY5YgT	TY.R7      pTP@                  e   TPB                  TP@                  3# TPB                  TPD                  ppTPF                  pTPH                  TPJ                  pp\M        TT
4      pRp T 3R lR) 4       w  pp p!\O        S TTTTR7      '       dE   \Q        TT4       T\        S T4      3 TP/                  4        T'       d   T	PS                  4        # # T	eõ   T	PU                  T4      pT'       gÜ   TPW                  S P6                  4       \Q        TT4       \X        P[                  RS P\                  ;'       g    R4       RS n/        \a        S YžP                  TTR7      p"\        S T4      p#\1        S TP                  T"'       d   \b        MRTP                  4       TT#3 TP/                  4        T'       d   T	PS                  4        # # \e        S 4       ^ RI3H4p$ T
'       d   RMT$! TTS P\                  R 7      p%T%e+   \X        P[                  R!S P\                  ;'       g    R4       \k        S T4       \m        TT4      p&\o        S T4      p'\q        S TTTTT'TT&TTYêT%e   T%.MRR"7      p(T(Pr                  eE   \Q        TT4       TT(Pr                  3 TP/                  4        T'       d   T	PS                  4        # # T(PD                  pT(Pt                  p)\w        S TT'T(Px                  TT(Pz                  T(P|                  TT(P~                  T T!TR#7      p*\X        P[                  R$S P\                  ;'       g    RT\        T4      T*R% 4       T)R*9   d   R&MR	Tn@        T(Pz                  ;'       g    TTJp+T+'       g   TP€                  R&8X  d   \ƒ        S TTT
T)4       \…        S TP                  TP€                  T)T)R+9   d   R'MRT(P†                  TP                  T+R(7       TT'3 TP/                  4        T'       d   T	PS                  4        # #   \"         d    TP%                  RR7       h i ; i  \,         d    TP/                  4        h i ; i  T'       d   T	PS                  4        i i ; i  T'       d   T	PS                  4        i i ; i  T'       d   T	PS                  4        i i ; i  T'       d   T	PS                  4        i i ; i   TP/                  4        T'       d   T	PS                  4        i i   T'       d   T	PS                  4        i i ; i; i),u
  Compress conversation context and split the session in SQLite.
``force`` (manual /compress) clears the summary-failure cooldown; ``bypass_cooldown`` (provider-proven
overflow) skips it once, breakers still apply. ``commit_fence`` stops a timed-out worker mutating session
state. Returns ``(messages, system_prompt)``; on abort input is unchanged, NOT split.

Args: agent: The owning :class:`AIAgent`. messages: Current message history (will be summarised).
system_message: Current system prompt; used when compression needs a rebuilt cached prompt.
approx_tokens: Pre-compression token estimate, logged for ops. task_id: Tool task scope (used for
clearing file-read dedup state). focus_topic: Optional focus string for guided compression â€” the
summariser will prioritise preserving information related to this topic. Inspired by Claude Code's
``/compact <focus>``. force: If True, bypass any active summary-failure cooldown. Set by the manual
``/compress`` slash command so users can retry immediately after an auto-compress abort. Auto-compress
callers use the default ``False``. bypass_cooldown: If True, the automatic breaker gates ignore ONLY the
summary-failure cooldown for this attempt (#100661). Set by the provider-proven overflow recovery path:
the provider already rejected the request, so deferring until the cooldown lapses wedges the session.
Unlike ``force`` it does not clear the cooldown, and the ineffective/structural breakers still apply; a
failed attempt records its cooldown normally. defer_context_engine_notification: Delay the existing
context-engine hook until a manual host commits its outer history transaction. commit_fence: Optional
cooperative fence for executor callers that may time out. It prevents a late worker from mutating
session state after its caller has moved on. verbatim_tail: The exchanges ``/compress here N`` keeps
after ``messages``; an in-place commit stores them after the compacted head and returns head + tail.
trigger: Why this attempt runs (``"overflow"``, ``"pre_api"``, ``"post_tool"``, ``"idle"``, ...); defaults
to manual/auto from ``force``. Feeds attempt telemetry only; shared metrics bucket it coarsely.
snapshot_is_current: Optional host snapshot validation after durable lease admission. This protects
edits completed before admission; it is not a substitute for the host's final publication fence.
overflow_reason: The error classifier's reason for the provider rejection an ``"overflow"`` attempt
recovers from (``"context_overflow"``, ``"payload_too_large"``, ``"long_context_tier"``). Telemetry only.
)rû  r/  r,  r©  r-  Úcompression_checkpoint_requiredFTrÇ  Nr:  zpcodex_app_server owns the authoritative thread and does not expose a truthful pre-compaction transcript boundaryr+  r  r;  )rŸ  rO   r©  rš  rû  Úcompression_in_place)rC  r©  rú  rû  rÉ  rÂ  )rŸ  rÒ  ri  r©  rO   Úsnapshot_stale)rO   r©  Úcooldown_state_unreadableræ  rž  rð  )rÆ  r¤  rþ  r©  rú  rû  r›  rŸ  r  ri  rO   c              3  ód   <"  € T F%  p\        \        SP                  VR 4      4      x € K'  	  R# 5irá   )r&   rI   r«  )r  ru   rD   s   & €r)   r  Ú#compress_context.<locals>.<genexpr>4  s0   øé € ð a
át�ô ”˜×1Ñ1°4¸Ó?×@Ð@Ûtùs   ƒ-0)rO   zBCompression commit cancelled before session mutation (session=%s).r¶  r  rÚ  )Ú-_ensure_compressed_keeps_last_assistant_replyr³  zsCompression: engine folded away the just-delivered assistant reply; reinserted it into the active set (session=%s).)
r¤  rÆ  rE  ri  rn  rÅ  r×  rO   rÚ  ræ  )
rE  rÉ  r¤  r¥  r¦  r§  r¨  r©  rª  rš  z^context compression done: session=%s messages=%d->%d rough_tokens=~%s awaiting_real_usage=truer‹  r€  Úsession_split_failed)r¡  r-  r.  r/  rÔ  rç  Úhistory_rewritten)Ú_last_compression_made_progressÚ_last_summary_fallback_usedÚ_last_feasibility_skip>   rÖ  rü  rû  >   r+  rý  )Dr7  rI   rF  r   r¡  r¼   rt  rÃ  r<  r¨  r   rm  r®  r&   rI  rA  rÆ  r.   r�  rÉ  râ  rd  rA  r  r   rí  rå   r«  r®   rË   rÌ   r&  r  r¨  r  rÅ  r©  r  r   rÑ  rr  r?  r:  r  r/   rg   rÄ   rÚ  rº  r·  r˜  Ú+agent.conversation_compression_reply_anchorrS  r:  rU  rF  r  rÕ  r.  rÃ  rÉ  r¥  r¦  r×  r-  r   r   rÔ  ),rD   r¨  ri  r©  rš  rú  rû  r›  r§  rŸ  rÚ  r,  rJ  r-  rO   rþ  r¤  Úblock_reasonÚ_pre_msg_countr¤  rÒ  rÆ  Ú_abort_promptrA  Ú_adoptedÚ_hard_cancel_eventrE  r  rÅ  Úeffect_messages_beforeÚ_commit_fence_enteredÚ_compression_made_progressÚ_compression_used_fallbackÚ_compression_feasibility_skipr#  rá  rS  Úreinserted_replyrn  rE  Úcommitr.  rÁ  Ú	rewrittens,   f&&$$$$$$$$$$$                              r)   Úcompress_contextrg  •  s  ø€ ôH )Ø�UÐZaØ#ô€Gô " %Ð)JÈEÓRÐVZÐZÐÜˆu�j $Ó'Ð+=Ô=ßÜ)ð CóˆGô -Ø�w×)Ñ)¸ÐT^Ô_cÐdkÓ_l×_uÑ_uÐ^vÐRwØ+Ð3EÐT[×T`ÑT`õð ˆMÜ&Ø�8¸,ÐgtØô
ð 	
÷ Ô&HÈÐP_Ó&`Ð`�lÖ`Ü'¨¨w×/AÑ/AÀ=×R^ÑR^Ð`lÔmØÔ0°¸ÓGÐGÐGä˜“]€Nô ”G˜EÐ#9¸4Ó@ÓA€Hô ,Ø˜^¸=Ðinô€Iô ˜UÔ#ô
 �5Ð<¸e×DÒDð	Ü/°Ô6ð 26ˆÔ.Ü5Ø˜L°IÈnØ#ôÑ€Eˆ=ð ‚}Ø˜Ð&Ð&ð 
×ÑÔðØ%¨Ð-×FÐFÑ1DÓ1Fˆ÷ Ü'¨¨w×/AÑ/AÐCSÐU\×UaÑUaÔbØ�‰ŒØÔ0°¸ÓGÐGÐGÜ'Øˆu�h¸ô€Hð ÒØˆô
 	4°E×4LÑ4LÈg×N^ÑN^Ó_ñ K€GÔ*¨GÔ,Jð ×-Ñ-°Ó6ð 	�‰ŒÜ(Ø�7×%Ñ%°YÐNiØ'·l±lõ	
ð Ô0°¸ÓGÐGÐG÷ !‘4Ô&HÈÐP_ÐrwÔ&x€LßØ�‰ŒÜ'¨¨w×/AÑ/AÀ=×R^ÑR^Ð`lÔmØÔ0°¸ÓGÐGÐGô ! Ð(CÀTÓJÐÜØˆx˜u¨xÐM`Ø#ÀEØ!Ð5GÐXfô€Eð
 ×ÑÒ%Ø�~‰~˜u×1Ñ1Ð1Ð1Ø Ÿ>™>¨5×+;Ñ+;ˆj€HØ"'×"CÑ"CÐØ$)×$7Ñ$7¸×9LÑ9L�>€MÜ?Ð@[Ð]jÓkÐØ!Ððd-ôa
átóa
Ñ]Ð"Ð$>Ð@]ô Ø�:˜xÐ)DÈg÷
ó 
ô ' xÐ1LÔMØÔ4°U¸NÓKÐKðj	-Ø�M‰MŒOç$Ø×*Ñ*Õ,ð %ðo Ò#Ø$0×$=Ñ$=Ð>PÓ$QÐ!ß(Ø×*Ñ*¨5×+CÑ+CÔDÜ*¨8Ð5PÔQÜ—‘ØXÐZ_×ZjÑZj×ZtÐZtÐntôð 38�Ô/Ü!BØ¨×ASÑASÐ^fØ"/ô"�ô  7°u¸nÓM�Ü/Ø˜7×-Ñ-ß7EÕ3ÐKcÐel×eqÑeqôð   Ð-ðD	-Ø�M‰MŒOç$Ø×*Ñ*Õ,ð %ôI 	& eÔ,õ
 	n÷ $1™4Ñ6cØ�j¨U×-=Ñ-=ô7
Ðð Ò'Ü�K‰Kð+Ø,1×,<Ñ,<×,FÐ,FÀôô 	˜E :Ô.Ü'GÈÐR\Ó']Ð$Ü>¸uÀnÓUÐÜ#Ø�8˜Z°(À%Ð[lØ)ÐHdØ(CÐSmØð
 4DÒ3OÐ.Ñ/ÐUYô

ˆð × Ñ Ò,Ü& xÐ1LÔMØ˜V×2Ñ2Ð2ð<	-Ø�M‰MŒOç$Ø×*Ñ*Õ,ð %ðA ×&Ñ&ˆ
Ø×*Ñ*ˆÜ5Ø�:Ð1BÐSY×ShÑShØ°&×2KÑ2KØ%+×%DÑ%DØ.OØ&,×&:Ñ&:ÐVpØ)FÐPWô
ˆô 	�‰ØlØ×Ñ×&Ð& ¨¼¸J»ÈOÐ\]ÐK^ô	
ð
 (Ð+hÔh‰KÐnwð 	Ôð ×-Ñ-×KÐK°À8Ð1Kˆ	ß˜	×/Ñ/°;Ô>Ü,¨UÐ4JÈJÐXeÐgsÔtÜ+Ø˜g×0Ñ0À	×@WÑ@WÐfrØ5AÐEfÔ5fÑ1ÐlpØ$×6Ñ6ÀWÇ\Á\Ðenõ	
ð
 Ð,Ð,ð	-Ø�M‰MŒOç$Ø×*Ñ*Õ,ð %øôW ô 	Ø×Ñ¨dÐÔ3Øð	ûô  ô Ø�‰ŒØðû÷v %Ø×*Ñ*Õ,ð %û×$Ø×*Ñ*Õ,ð %û×$Ø×*Ñ*Õ,ð %û×$Ø×*Ñ*Õ,ð %ûð	-Ø�M‰MŒOç$Ø×*Ñ*Õ,ð %ø×$Ø×*Ñ*Õ,ð %ýs®   Ä.[3 Å,
\ Å7\ Í?^- Î\5Î8^- ÏA	^- ÐA&^- Ò]Ò0A^- ÔA0^- Õ8]1Ö"A9^- Ø7^- Ù^- Ù!A'^- Û	^Û3\Ü\2Ü5]Ý].Ý1^Þ^*Þ-_7Þ/_Þ?_7ß_4ß4_7z	image/pngz.pngz	image/gifz.gifz
image/webpz.webpú
image/jpegú.jpgz	image/jpgz	image/bmpz.bmpc               ó$   € V ^8„  d   QhRRRRRR/# )r#   Úheaderr%   ry   r5   r'   )r(   s   "r)   r*   r*   ¢  s!   € ÷ ñ ˜3ð ¨ð Àñ r+   c                óÌ   € V P                  R4      '       dM   V \        R4      R P                  R^4      ^ ,          P                  4       pVP                  R4      '       d   V# V# )z?``image/*`` mime from a ``data:`` URL header, else ``default``.údata:NÚ;úimage/)r±  r®  Úsplitr[   )rk  ry   r­  s   && r)   Ú_data_url_mimerq  ¢  sZ   € à×Ñ˜×!Ò!Øœ3˜w›<˜>Ð*×0Ñ0°°aÓ8¸Õ;×AÑAÓCˆ	Ø×Ñ ×)Ò)ØÐØ€Nr+   c               ó    € V ^8„  d   QhRRRR/# )r#   Údata_urlr%   r5   zOptional[tuple]r'   )r(   s   "r)   r*   r*   «  s   € ÷ ñ ˜Sð  _ñ r+   c                ór  €  ^ RI p^ RIpV P                  R4      w   r4V'       d   V P                  R4      '       g   R# ^ RIHp VP                  VP                  VP                  V4      4      4      ;_uu_ 4       pVP                  uuRRR4       #   + '       g   i     R# ; i  \         d     R# i ; i)z```(width, height)`` of a base64 data URL; None when Pillow is missing or the payload is corrupt.Nr‹  rm  )ÚImage)Úbase64ÚioÚ	partitionr±  ÚPILru  ÚopenÚBytesIOÚ	b64decodeÚsizer.   )rs  rv  rw  r½  Údata_dru  Ú_imgs   &      r)   Ú_decode_pixelsr€  «  sƒ   € ð	ßØ×)Ñ)¨#Ó.‰ˆˆ1ß˜X×0Ñ0°×9Ò9ÙÝØ�Z‰Z˜Ÿ
™
 6×#3Ñ#3°FÓ#;Ó<×=Ô=ÀØ—9‘9÷ >×=×=Ó=ûäô Úðús4   ‚:B' ¿=B' Á<BÂ
B' ÂB$	ÂB' Â$B' Â'B6Â5B6c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r#   Úurlr%   Úmax_dimensionr†   Ú	resize_fnr   r5   rá  r'   )r(   s   "r)   r*   r*   ¹  s(   € ÷ 2.ñ 2.˜#ð 2.°ð 2.Àð 2.Èñ 2.r+   c          	     ó@  € \         p\        V \        4      '       d   V P                  R4      '       g   R# \	        V 4      V8”  d   RMRpVf$   \        V 4      pVe   \        V4      V8:  d   R# Rp V P                  R4      w  rgp\        V4      p	^ RI	p
V
P                  V4      p\        P                  ! R\        P                  V	R4      RR	7      p VP                  V4       VP!                  4        V! \#        VP$                  4      W“VR
7      p\&        P(                  ! \*        4      ;_uu_ 4        \#        VP$                  4      P-                  RR7       RRR4       T'       g   R# \        T4      pTR8X  d;   \	        T4      \	        T 4      8  ;'       d    TRJ ;'       g    \        T4      T8*  pM*Te   \        T4      T8*  pM\	        T4      \	        T 4      8  pT'       d   TR3# R#   + '       g   i     Lž; i  \&        P(                  ! \*        4      ;_uu_ 4        \#        TP$                  4      P-                  RR7       RRR4       i   + '       g   i     i ; i; i  \*         d'   p\.        P1                  RT4       RTRJ3u Rp?# Rp?ii ; i)a¤  Return ``(resized_url, unshrinkable)`` for a data URL.
``resized_url`` is None when no rewrite applied. ``unshrinkable`` is True only when the image violated a
constraint and resizing failed to satisfy that same constraint, so the caller knows a retry is pointless.
The accept gate MUST use the axis that triggered the shrink: a pixel downscale can re-encode to MORE bytes
(PNG non-monotonic); a byte-only reject wedges.rm  NFÚbytesÚ	dimensionr‹  Úhermes_shrink_ri  )ÚprefixÚsuffixÚdelete)Ú	mime_typeÚmax_base64_bytesrƒ  T)Ú
missing_oku.   image-shrink recovery: re-encode failed â€” %sr™  r8  )Ú_IMAGE_SHRINK_TARGET_BYTESr:   r%   r±  r®  r€  rÀ   rx  rq  rv  r|  ÚtempfileÚNamedTemporaryFileÚ_IMAGE_SUFFIX_BY_MIMErž   ÚwriteÚcloser   ru   r�   r’   r.   Úunlinkr/   rÒ   )r‚  rƒ  r„  Útarget_bytesÚtriggered_byÚdimsrk  r½  ÚdataÚmimeÚ_b64ÚrawÚtmpÚresizedÚnew_dimsÚokr1   s   &$$              r)   Ú_shrink_data_urlr¡  ¹  s  € ô .€LÜ�cœ3×Ò s§~¡~°g×'>Ò'>ØÐÜ! #›h¨Ô5‘7¸4€LØÒä˜cÓ"ˆØŠ<œ3˜t›9¨Ô5ØÐØ"ˆð".ØŸ-™-¨Ó,‰ˆ�4Ü˜fÓ%ˆÛØ�n‰n˜TÓ"ˆÜ×)Ò)Ø#Ô,A×,EÑ,EÀdÈFÓ,SÐ\aô
ˆð	7Ø�I‰I�cŒNØ�I‰IŒKÙÜ�S—X‘X“¨$Ð]jôˆGô ×$Ò$¤Y×/Õ/Ü�S—X‘X“×%Ñ%°Ð%Ô6÷ 0çØÐÜ! 'Ó*ˆØ˜7Ô"ô �W“¤ C£Ñ(×aÐa¨h¸$Ð.>×.`Ð.`Ä#ÀhÃ-ÐS`ÑB`‰BØÒ!ä�X“ -Ñ/‰Bô �W“¤ C£Ñ(ˆBß#%�˜ÐÐ7¨<Ð7÷! 0×/û”×$Ò$¤Y×/Õ/Ü�S—X‘X“×%Ñ%°Ð%Ô6÷ 0×/×/Ð/þô" ô .Ü�‰ÐGÈÔMØ�\¨Ð-Ð-Õ-ûð.úsŒ   Á2A!I, Ã?H Ä"I, Ä5&G1ÅI, Å+I, Å-/I, ÆI, Æ)AI, Ç+I, Ç/I, Ç1H	Ç<I, È#I)È'&I	É	I)ÉI&É!I)É)I, É,JÉ7JÊJÊJc               ó    € V ^8„  d   QhRRRR/# )r#   ra  r   r5   rœ  r'   )r(   s   "r)   r*   r*   î  s   € ÷ cñ c ð c¨ñ cr+   c                óf  € \        V \        4      '       d   V P                  R4      R8w  d   R# V P                  R4      p\        V\        4      '       d	   V'       g   R# \        V P                  R4      ;'       g    R4      P	                  4       pRVP                  R4      '       d   TMR R	V 2# )
uK   Anthropic ``{"type": "base64", ...}`` image source â†’ data URL, else None.r¼   rv  Nr™  Ú
media_typerh  rm  ro  z;base64,)r:   r<   rž   r%   r[   r±  )ra  r™  r¤  s   &  r)   Ú_source_to_data_urlr¥  î  s�   € ä�fœd×#Ò# v§z¡z°&Ó'9¸XÔ'EÙØ�:‰:�fÓ€DÜ�dœC× Ò ¯ÙÜ�V—Z‘Z Ó-×=Ð=°Ó>×DÑDÓF€JØ ×!6Ñ!6°x×!@Ò!@‘:ÀlÐSÐS[Ð\`Ð[aÐbÐbr+   c               ó$   € V ^8„  d   QhRRRRRR/# )r#   ra  r<   rs  r%   r5   r'   )r(   s   "r)   r*   r*   ù  s&   € ÷ \ñ \ dð \°cð \¸dñ \r+   c                óT   € VP                  R4      w  r#p/ V CRRR\        V4      RV/C# )zÌReturn a NEW source dict carrying the re-encoded payload.
Copy-on-write: parts may be shared with the persistent history, so mutating in place would store the
degraded image; the caller replaces the part.r‹  r¼   rv  r¤  r™  )rx  rq  )ra  rs  rk  r½  r™  s   &&   r)   Ú_write_data_url_to_sourcer¨  ù  s8   € ð ×(Ñ(¨Ó-�O€FˆtØ[ˆfÐ[�f˜h¨´nÀVÓ6LÈfÐVZÑ[Ð[r+   rƒ  i@  c               ó$   € V ^8„  d   QhRRRRRR/# )r#   Úapi_messagesr;   rƒ  r†   r5   r&   r'   )r(   s   "r)   r*   r*     s'   € ÷ Lñ L°Tð LÈSð LÐ\`ñ Lr+   c               óÞ  aa€ V '       g   R#  ^ RI Ho ^ p^ pR TT3R llpT  EFÅ  p\        T\        4      '       g   K  TP                  R4      p\        T\        4      '       g   KE  Rp\        T4       EFc  w  rš\        T
\        4      '       g   K  T
P                  R4      pRpTR	8X  d_   T
P                  R
4      pT! \        T4      ;'       g    R4      w  rïT'       d(   \        T\        4      '       d   / T
CR
\        YÞ4      /CpM–TR9   d�   T
P                  R4      p\        T\        4      '       d2   T! TP                  RR4      4      w  rïT'       d   / T
CR/ TCRT/C/CpM7\        T\        4      '       d   T! T4      w  rïT'       d	   / T
CRT/CpMEK)  EK,  Te    Tf   \        T4      pYÈT	&   T^,          pEKO  T'       g   EKZ  T^,          pEKf  	  Tf   EKÁ  Y†R&   EKÈ  	  \        R,          pT'       d   \        P                  RTT4       T'       d   \        P	                  RTT4       R# T^ 8„  #   \         d"   p\        P	                  RT4        Rp?R# Rp?ii ; i)au  Re-encode oversized native image parts to recover from image-too-large errors.
Mutates ``api_messages`` in place. Returns True if any part was replaced, False if nothing to shrink or
Pillow could not help. Targets data-URL parts over 4 MB or ``max_dimension`` (Anthropic's per-side pixel
cap, parsed from the rejection by the caller); http(s) image URLs are left untouched.F)Ú_resize_image_for_visionu6   image-shrink recovery: vision_tools unavailable â€” %sNc               ó    € V ^8„  d   QhRRRR/# )r#   r‚  r   r5   rá  r'   )r(   s   "r)   r*   Ú8try_shrink_image_parts_in_messages.<locals>.__annotate__  s   € ÷ fñ f�Sð f˜Uñ fr+   c                ó    <€ \        V SSR 7      # ))rƒ  r„  )r¡  )r‚  r¬  rƒ  s   &€€r)   Ú_shrinkÚ3try_shrink_image_parts_in_messages.<locals>._shrink  s   ø€ Ü °=ÐLdÔeÐer+   rV  r¼   Úimagera  rX   Ú	image_urlr‚  zGimage-shrink recovery: re-encoded %d image part(s) to fit under %.0f MBu…   image-shrink recovery: %d oversized image part(s) could not be shrunk under %.0f MB â€” not retrying (would re-send rejected payload)>   r³  Úinput_imagei   )Útools.vision_toolsr¬  r.   r/   rÒ   r:   r<   rž   r;   rÊ  r¥  r¨  r%   r�  rg   )rª  rƒ  r1   Úchanged_countÚunshrinkable_oversizedr°  rx  rV  Únew_contentÚpart_idxrá  ÚptypeÚreplacementra  rž  ÚunshrinkableÚimage_valueÚ	target_mbr¬  s   &d                @r)   Ú"try_shrink_image_parts_in_messagesr¿    sP  ù€ ÷
 ÙðÝ?ð €Mð Ð÷fñ fô ˆÜ˜#œt×$Ò$ÙØ—'‘'˜)Ó$ˆÜ˜'¤4×(Ò(Ùð $(ˆÜ'¨×0‰NˆHÜ˜d¤D×)Ò)ÙØ—H‘H˜VÓ$ˆEØˆKØ˜ÔØŸ™ (Ó+�Ù(/Ô0CÀFÓ0K×0QÐ0QÈrÓ(RÑ%�ßœz¨&´$×7Ò7Ø"` TÐ"`¨8Ô5NÈvÓ5_Ñ"`�KøØÐ6Ô6Ø"Ÿh™h {Ó3�ô ˜k¬4×0Ò0Ù,3°K·O±OÀEÈ2Ó4NÓ,OÑ)�GßØ&\¨Ð&\¨{Ð<[¸{Ð<[ÈEÐSZÑ<[Ñ&\˜øÜ ¬S×1Ò1Ù,3°KÓ,@Ñ)�GßØ&D¨Ð&D¨{¸GÑ&D˜øââØÒ&ØÒ&Ü"& w£-�KØ(3˜HÑ%Ø Õ"“ß’Ø&¨!Õ+Ó&ñA 1ðB Õ"Ø(�	ŒNñW ôX +¨kÕ:€IßÜ�‰Ð]Ð_lÐnwÔxßô 	�‰ðUØVlØô	
ñ
 Ø˜1ÑÐøôG ô Ü�‰ÐOÐQTÔUÝûðús   ŽI  É I,ÉI'É'I,)!Ú_previous_summaryÚ_summary_has_user_turnr®  Ú_last_compression_savings_pctÚ_ineffective_compression_countÚ_anti_thrash_recovery_deadlinerø  r¹  rV  r·   rÑ   rº   rÙ  Ú _consecutive_truncation_failuresÚ_last_summary_dropped_countrW  rÇ  Ú_last_summary_auth_failureÚ_last_summary_network_failureÚ#_last_summary_empty_content_failureÚ_last_summary_truncated_failureÚ_last_summary_overload_failureÚ_consecutive_overload_abortsÚ_last_summary_overload_degradedr‘  r�  Ú_last_aux_resolved_modelÚ_summary_model_fallen_backr¬  Ú_last_compression_telemetryÚ_active_compression_telemetryÚ_compression_telemetry_seedru  )r·   rº   rÑ   r  )z-[System: Your previous response was truncatedz*[System: The previous response was cut offz [System: Your previous tool callz@[Your active task list was preserved across context compression]z[IMPORTANT: Background process )r(  Ú_empty_recovery_syntheticÚ_verification_stop_syntheticÚ_pre_verify_syntheticÚ_dropped_toolcall_nudge)rA  r4  rL  rR  )rÐ  rÑ  rÒ  i  @ )rh  )rJ   rG  rG  r\   rÆ  rg  rÎ  r`   rÔ  rÊ  r¿  )÷Ú__conditional_annotations__rx  Ú
__future__r   Úconcurrent.futuresrƒ  r�   Úcontextvarsrr   ÚdataclassesrO  ÚjsonÚloggingr  r¸  r�  rÁ   ró  r   r   Úpathlibr   Útypingr   r   r   r   r	   r
   r   rÉ  r   Ú agent.context_compressor_summaryr   Úagent.context_enginer   r   Ú$agent.conversation_compression_codexr   r!  r   Ú(agent.conversation_compression_telemetryr   r   r   r   r   r   Úagent.memory_providerr   r·  r   r   Úagent.session_activityr   r   Úagent.usage_anchorr   Úhermes_state_idsr   r€  Úhermes_state_pidnsr   Ú(agent.conversation_compression_watermarkr    Ú	getLoggerrt  r/   Úcontextmanagerr2   Ú	frozensetÚAGENT_COMPRESSION_TIMEOUTÚAGENT_COMPRESSION_COOLDOWNr?  r  r\   rG  rG  rJ   rA   rK   Ú#PRE_API_COMPRESSION_STATUS_TEMPLATEÚ%PREFLIGHT_COMPRESSION_STATUS_TEMPLATEÚIDLE_COMPACTION_STATUS_TEMPLATEÚ+COMPRESSION_RETRY_TOO_LARGE_STATUS_TEMPLATEÚ*COMPRESSION_RETRY_MESSAGES_STATUS_TEMPLATEÚ(COMPRESSION_RETRY_TOKENS_STATUS_TEMPLATEÚ1COMPRESSION_RETRY_CONTEXT_REDUCED_STATUS_TEMPLATEÚ)CONTEXT_OVERFLOW_BLOCKED_WARNING_TEMPLATEr(   Ú"ROUTINE_COMPRESSION_STATUS_SAMPLESr`   rj   rq   rã   rw   r€   r~   Ú
ContextVarrz   rØ  r„   r‹   r�   r”   rš   r˜   r�   r¨   r¬   rÊ   r×   rå   rç   r·  r˜  rš  r  r  r‰  rŽ  rŒ  r�  r�  r“  rœ  r¦  r°  rº  rÎ  rÖ  rÛ  rá  rô  rñ  r  r  r  r  rý  Ú)agent.conversation_compression_checkpointrF  rG  rR  r]  rf  rm  rr  rv  r}  r‡  r�  r’  r•  r™  r¨  r¬  r£  r»  rà  rå  rì  rö  r
  r  rZ  r\  r}  r¢  r¨  rÆ  rÊ  rÎ  rÔ  rÜ  rì  rã  rë  rî  rõ  rö  r÷  rü  r  r  r  r  r  r!  r$  r5  r7  rE  rU  r]  re  r}  rÎ  rs  r~  rƒ  r…  r’  r¼  rÄ  rÍ  rÔ  râ  rí  rü  r
  r  r$  r:  rF  rR  rY  rf  rl  rŒ  r˜  r¢  rÃ  rÑ  Ú	dataclassrÓ  rÜ  râ  rå  r  r  r&  r¾  r7  r<  rA  rI  rg  r�  r’  rq  r€  r¡  r¥  r¨  r¿  Ú__all__)r×  s   @r)   Ú<module>rü     s6  øðôõ #ã Û Û Û Û Û Û Û Û Û 	Û Û Û Û Ý Ý ß F× FÑ Få @Ý Fß ]Ý WÝ X÷÷ õ Fß ^ß TÝ /Ý >Ý 5Ý Kà	×	Ò	˜8Ó	$€ð ×ÑðY¨uö Yó ðYñ %.Ø×1Ñ1Ð3E×3`Ñ3`Ðaó%Ð !ð #%Ð ð 0Ð ØÐ7Ð8Ð8rÐsÐ ð !)Ð)AÐ(Bð  CCð  DÐ àQÐ õsõ=ð yð $ð ið &ð cð  ð Zð ,ð .mÐ *Ø+nÐ (àRð 2ð1ð *ð Ð2Ð4JØ'×.Ñ.°fÐ.Ó=Ø)×0Ñ0¸È&Ð0ÓQØ#×*Ñ*¸ÀVÐ*ÓLØ/×6Ñ6¸fÈaÐUVÐ6ÓWØ.×5Ñ5¸RÀrÐ5ÓJØ,×3Ñ3¸6ÈÐ3ÓPØ5×<Ñ<ÀVÐU[Ð<Ó\ð	&Ð "õ\õ&ñ$Ð  ñ %{Ð !õ#ð< %Ÿ>š>Ó+Ð ð ?J×>TÒ>TØ*°Dô?Ð Ð ;ó õ
õ"
õaõLõ.õYõ
.õ Gõ
õ0ð:--Øcgð--à7;ð--àae÷--õ`#.÷Liñ ið` #6Ð ð "Ð Ø"+§.¢.Ó"2Ð ð &*Ð "ð ,/Ð (õðF "#Ð Ø$Ÿ>š>Ó+Ð ØÐ õ÷*ð *ò*ð Ørv÷õ>>õõ8&õRõRõ	#ð)ð CGð	)ð
 @Dð)ð
 ]að)ð AEð)ð fk÷)õXZ&õzõD$õNõ/ð,J,ð CGðJ,ð @Dð	J,ð
 CGðJ,ð /3ðJ,ð LPðJ,ð imðJ,ð AEðJ,ð W[ðJ,ð $)ðJ,ð 59÷J,÷Z aõðXÐW[÷ Xõpõgõ
.õ]õ1õKõ"
6õ;õ
:õ

GðØCG÷õ40õ":õ 	(õBõJ	aõõ>GðUà16÷U÷.g)ñ g)õT÷.4ñ 4õn'õKõ\PõYRõx2õ 2õ&	D÷ð ñ&Ð õñÐ õNð 3Ð Ø5Ð õ;õ8õ+õ0õõ.	õ$ð &rÐ "õõ4@ð0 $Ñ$cÕdÐ õõB"õDð 0ÐUZ÷ 0ð@ (ZÐ $õ7õõ6
Bõ÷/ñ /÷,R-ñ R-öj÷"	ò 	÷÷D ÷<G÷T'"÷T0÷f$÷N(÷*8÷vGl÷T7÷t9÷x÷O÷8	@÷DD÷Nñ4(Á÷ (ñ (÷$[÷|Kð\ ×Ò÷
 ò 
 ó ð
 ÷kñ
Ð ð
 ×Ñö1ó ð1ñzð %)ñ	zð NR÷	zñ zðz ×Ò÷'ò 'ó ð'÷_ðD ×Ò÷
ò 
ó ð
ñ(&<ØSWñ&<à#'ñ&<àJN÷&<ñ &<÷R)÷,÷5ñ&A-ØW[ñA-áñA-à;?ñA-àOTðA-ð "ñA-ð NSñA-ð 6:ñ	A-ð \`ñ	A-ð
 "ñA-ð
 X\ñA-ð &*÷A-ñ A-ñL -Ð á‘™¡f©l¹GÁ\ÑSYÑ[fÑhnÙ‘ðÐ ÷ò ÷÷2.÷jc÷\ñLÑSW÷ Lñ Ló^‚r+   