+
    jHàj—  ã                   ó€   € R t ^ RIt^ RIHt R tR tR tR tRR ltR t	R	 t
RR
RRR/R lltR tR tR tR tR tR# )zLPhysical worker liveness and cooperative Stop across every served authority.N)Úall_authoritiesc              #   ó2  "  € \        V R / 4      P                  4        Fs  w  r\        \        VRR4      RR4      ;'       g    / pVP                  pVP                  R4      f   KH  Vf   KN  VP	                  4       '       d   Kf  WVR,          3x € Ku  	  R# 5i)ÚsessionsÚevent_streamNÚ	executionÚexecution_generation)ÚgetattrÚitemsÚtaskÚgetÚdone)Ú	authorityÚsidÚliver   r
   s   &    ÚD/home/ubuntu/.hermes/hermes-agent/gateway/session_runtime_workers.pyÚexecuting_sessionsr      s‚   é € Ü˜Y¨
°BÓ7×=Ñ=Ö?‰	ˆÜœG D¨.¸$Ó?ÀÈdÓS×YÐYÐWYˆ	Ø�y‰yˆØ�=‰=Ð/Ó0Ô<ÀÔAQÐZ^×ZcÑZc×ZeÔZeØ˜YÐ'=Õ>Ð>Ô>ó	 @ùs   ‚ABÁ&BÁ,BÂBc                ó¾   a€ \        V R/ 4      o\        V 4      p\        R V 4       4      pV\        V3R lV 4       4      ,           \        R V 4       4      ,           # )zWCount claims absent from the ordinary agent map, including pre-bootstrap managed turns.Ú_running_agentsc              3   ó¤   "  € T FF  p\        VR / 4      P                  4        F$  pVP                  P                  4       '       * x € K&  	  KH  	  R# 5i©Ú_managed_workersN)r   ÚvaluesÚclosedÚis_set)Ú.0r   Úworkers   &  r   Ú	<genexpr>Ú)uncounted_runtime_work.<locals>.<genexpr>   sI   é € ð U¹k°Ü '¨	Ð3EÀrÓ J× QÑ QÖ S�fð —m‘m×*Ñ*Ó,×,Ñ,Ù Sñ -»kùs   ‚AAc              3   óœ   <"  € T FA  p\        V4       F/  w  r#pVP                  S9  ;'       d    V\        VR / 4      9  x € K1  	  KC  	  R# 5ir   )r   Úrouter   )r   r   r   r   Ú_Úrunnings   &    €r   r   r      sU   øé € ð `Ù!,�IÔASÐT]ÖA^±°¸Að Ÿ*™*¨GÑ3×mÐm¸Ä7È9ÐVhÐjlÓCmÑ8mÔmÙA^ñ nÛ!,ùs
   ƒ+A¯Ac              3   ó|   "  € T F2  p\        \        V4      4      \        \        V4      4      ,           x € K4  	  R # 5i©N)ÚlenÚmutation_tasksÚside_agents)r   r   s   & r   r   r      s/   é € ÐlÑ`kÐS\”#”n YÓ/Ó0´3´{À9Ó7MÓ3N×NÒNÓ`kùs   ‚:<)r   r   Úsum)ÚrunnerÚauthoritiesÚmanagedr!   s   &  @r   Úuncounted_runtime_workr+      sp   ø€ ä�fÐ/°Ó4€GÜ! &Ó)€KÜñ U¹kó Uó U€Gà”cô `Ù!,ó`ó `õ `äÑlÑ`kÓlÓlõmð nó    c                ó¬   € ^ RI Hp \        \        V R/ 4      P	                  4       4       UUu. uF  w  r#V! V4      '       d   K  W#3NK  	  upp# u uppi )zú``(thread, holder)`` for each detached side agent (/bg, /btw, preview restart) whose thread
has not unwound (``gateway/session_tui_side.py`` ``_spawn``). A stopped ``/btw`` whose fork
is gone (``_SideQuestionStop.abandoned``) is no longer owner work.)Ú
_abandonedÚ_side_agents)Úgateway.session_tui_sider.   Úlistr   r	   )r   r.   ÚthreadÚholders   &   r   r&   r&      sS   € õ 4Ü37¼À	È>Ð[]Ó8^×8dÑ8dÓ8fÔ3gô 'Ñ3g¡ Ù˜f×%ô ˆVÓÑ3gò 'ð 'ùó 's   ®AÁAc           	     óÐ   € ^ RI Hp ^ p\        V 4       FN  p\        V4       F<  w  rVV'       g   K  V^ ,          f   K  V\	        V! V^ ,          V4      4      ,          pK>  	  KP  	  V# )z©Hard-interrupt every counted side agent's holder across served authorities (the stop
drain waits for them, so its timed-out interrupt must reach them). Returns how many.©Úrequest_hard_interrupt)Úagent.interrupt_compatr6   r   r&   Úbool)r(   Úreasonr6   Úcountr   r    r3   s   &&     r   Úinterrupt_side_agentsr;   #   s\   € õ >Ø€EÜ$ VÖ,ˆ	Ü$ YÖ/‰IˆAß‰v˜& �)Ô/ØœÑ4°V¸AµYÀÓGÓHÕH’ó 0ñ -ð €Lr,   c                óP   € \        \        V RR4      RR4      pVe
   V! 4        R# R# )a  Re-publish the runner's in-flight count when owner work it counts (a drain, a tracked
mutation, a mailbox operation) ends: the agent-slot release that last wrote
``gateway_state.json`` ran while that work was still live, so without this write the
persisted count never returns to zero.r(   NÚ_persist_active_agents)r   )r   Ú_taskÚpersists   && r   Úpersist_work_countr@   /   s-   € ô
 ”g˜i¨°4Ó8Ð:RÐTXÓY€GØÒÙŽ	ñ r,   c                 ó–   € 0 \        V R R4      m\        V RR4      mpV Uu. uF  q"P                  4       '       d   K  VNK  	  up# u upi )Ú_mutation_tasksÚ_bot_mailbox_operations© )r   r   )r   Útasksr
   s   &  r   r%   r%   9   sF   € ØlŒg�iÐ!2°BÓ7Ðl¼'À)ÐMfÐhjÓ:kÐl€EÙ"Ó6™U�T¯)©)¯+�DˆD™UÑ6Ð6ùÒ6s
   ¡A½Ac                 óÌ   a a€ \        S R R4      oSf   \        4       ;oS n        \        P                  ! V4      pSP                  V4       V V3R lpVP                  V4       V# )rB   Nc                 óŒ   <€ SP                  V 4       V P                  4       '       g   V P                  4        \        S4       R # r#   )ÚdiscardÚ	cancelledÚ	exceptionr@   )r   r   rE   s   &€€r   ÚfinishedÚ track_mutation.<locals>.finishedD   s.   ø€ Ø�‰�dÔØ�~‰~×ÒØ�N‰NÔÜ˜9Ö%r,   )r   ÚsetrB   ÚasyncioÚcreate_taskÚaddÚadd_done_callback)r   Ú	operationr
   rK   rE   s   f&  @r   Útrack_mutationrS   >   s[   ù€ Ü�IÐ0°$Ó7€EØ‚}Ü,/«EÐ1ˆ�	Ô)Ü×Ò˜yÓ)€DØ	‡I�Iˆd„Oö&ð
 	×Ñ˜8Ô$Ø€Kr,   ÚorderedFÚafterc             ƒ  ó°  aaaaa	"  € \        V RR4      o	S'       d!   S	f   \        P                  ! 4       ;o	V n        V	VVV3R lp\	        W! 4       4      pSf   \        P
                  ! V4      G Rj  x€L
 #  \        P
                  ! V4      G Rj  x€L
 pS! T4       T#  L- L  \        P                   d    T3R lpTP                  T4       h i ; i5i)a  Run a synchronous ledger write (``write()``) in a worker thread, off the owner loop.

A held SQLite writer (``_WRITE_PATIENCE_S``) must not freeze every session, timer, socket,
Stop and approval. The write and its loop-side follow-up (``then(result)``, sync or a
coroutine: publication, scheduling, the claim's execution stamp) are one task tracked like ``track_mutation``, so
retirement joins it, and shielded, so a cancelled caller cannot separate a commit from it.
``ordered`` writes (admissions) commit in call order, as they did on the loop: worker threads
alone would let a later input take an earlier FIFO position.

``after(result)`` (an admission's drain scheduling) runs in the CALLER's own step once the
write returns, as it did when admission was synchronous: the caller registers its delivery
waiter before any drain it scheduled can claim, settle or pause that admission. A caller
cancelled while the commit is in flight hands ``after`` to the commit's completion instead,
so a committed row is never stranded without a drain.Ú_ordered_writesNc               “   ó”  <"  € S'       dC   S;_uu_4       GR j  x€L
  \         P                  ! S4      G R j  x€L
 p R R R 4      GR j  x€L
  M\         P                  ! S4      G R j  x€L
 p Sf   X # S! X 4      p\         P                  ! V4      '       d   VG R j  x€L
 # T#  L‡ Lk L]  + GR j  x€L 
 '       g   i     LU; i L\ L*5ir#   )rN   Ú	to_threadÚiscoroutine)ÚresultÚfollowedÚorderrT   ÚthenÚwrites     €€€€r   ÚrunÚtracked_write.<locals>.run`   s�   øé € ßß—u’uÜ&×0Ò0°Ó7×7�÷ —u�uô #×,Ò,¨UÓ3×3ˆFØŠ<ØˆMÙ˜“<ˆÜ!(×!4Ò!4°X×!>Ò!>�X�~ÐLÀHÐLñ Ù7÷ —u—u’uúñ 4ñ ùs}   ƒCšB"›CžB(¸B$¹B(½CÁB&Á	CÁ'CÁ(-CÂCÂCÂCÂ$B(Â&CÂ(C	Â.B1Â/
C	Â:C	Â<	CÃCc                 óŒ   <€ V P                  4       '       g-   V P                  4       f   S! V P                  4       4       R # R # R # r#   )rI   rJ   r[   )r   rU   s   &€r   ÚlateÚtracked_write.<locals>.latep   s3   ø€ Ø—>‘>×#Ò#¨¯©Ó(8Ò(@Ù�d—k‘k“mÖ$ñ )AÑ#r,   )r   rN   ÚLockrW   rS   ÚshieldÚCancelledErrorrQ   )
r   r_   r^   rT   rU   r`   r
   r[   rc   r]   s
   &ffdd    @r   Útracked_writerh   M   s¼   üé € ô �IÐ0°$Ó7€Eß�5’=Ü,3¯LªL«NÐ:ˆ�	Ô)÷	Mð 	Mô ˜) S£UÓ+€DØ‚}Ü—^’^ DÓ)×)Ð)ðÜ—~’~ dÓ+×+ˆñ 
ˆ&„MØ€Mñ *á+øÜ×!Ñ!ô õ	%ð 	×Ñ˜tÔ$Øðüs<   ‡A,CÁ3B!Á4CÁ9B% ÂB#ÂB% ÂCÂ#B% Â%.CÃCc                 ó¾   a€ \        WV4      o\        P                  ! V P                  V4      4      Vn        Se"   VP                  P                  V3R l4       R # R # )Nc                 ó,   <€ \        \        S4      4      # r#   )r1   Úphysical_workers)r    r   s   &€r   Ú<lambda>Ú#start_turn_worker.<locals>.<lambda>   s   ø€ ¼Ô>NÈyÓ>YÔ9Zr,   )Útrack_turn_workerrN   Úensure_futureÚ_run_in_executor_with_contextÚexecutor_taskrQ   )r(   r   Úagent_holderÚrun_syncr   s   &&&&@r   Ústart_turn_workerrt   y   sP   ø€ Ü! &°,Ó?€IÜ"×0Ò0°×1UÑ1UÐV^Ó1_Ó`€FÔØÒð 	×Ñ×.Ñ.Ô/ZÖ[ñ r,   c                 ó¢   € ^ RI Hp V! V 4      pVe=   \        VRR4      pVf	   / ;qTn        \	        \        V4      4       W3V\        V4      &   V# )é    )Úactive_authorityNÚ_turn_workers)Úgateway.session_authoritiesrw   r   rx   r1   rk   Úid)r(   r   rr   rw   r   Úworkerss   &&&   r   rn   rn   ‚   sX   € Ý<Ù  Ó(€IØÒÜ˜) _°dÓ;ˆØŠ?Ø02Ð2ˆGÔ-ÜÔ˜iÓ(Ô)Ø%Ð4ˆ”�6“
ÑØÐr,   c              #   óÄ   "  € \        V R / 4      p\        VP                  4       4       F1  w  pw  r4VP                  P	                  4       '       d   W K,  W43x € K3  	  R# 5i)rx   N)r   r1   r	   Úworker_doner   )r   r{   Úkeyr   r3   s   &    r   rk   rk   Ž   sR   é € Ü�i °"Ó5€GÜ!% g§m¡m£oÖ!6ÑˆÑˆfØ×Ñ×$Ñ$×&Ò&Ø’à�.Ô ó	 "7ùs   ‚AA c                 ó&  € ^ RI Hp ^ RIHp V! V RR7       . \	        V 4      O\        V 4      O F,  w  r4V'       g   K  V^ ,          f   K  V! V^ ,          R4       K.  	  \        V R/ 4      P                  4        F  pVP                  4        K  	  R# )rv   )Ústop_authority_turnsr5   T)Ú
in_processNzProfile runtime is stoppingÚ_cron_cancellations)	Úgateway.run_runtimer€   r7   r6   rk   r&   r   r   rM   )r   r€   r6   r    r3   Úcancels   &     r   Ústop_authority_workr…   —   sz   € Ý8Ý=Ù˜¨tÕ4ØLÔ'¨	Ó2ÐL´[ÀÓ5KÓL‰	ˆß‰6�f˜Q•iÔ+Ù" 6¨!¥9Ð.KÖLñ Mô ˜)Ð%:¸BÓ?×FÑFÖHˆØ�
‰
Žó Ir,   c              ƒ   óÐ  "  € \         P                  ! 4       P                  4       V,           p \        V 4       \	        \        V 4      4      '       g?   \	        \        V 4      4      '       g%   \        V 4      '       g   \        V 4      '       g   R# \         P                  ! 4       P                  4       V8¼  d   \        R4      h\         P                  ! R4      G Rj  x€L
  K·   L5i)TNz0Profile workers did not stop; ownership retainedgš™™™™™©?)rN   Úget_running_loopÚtimer…   r1   rk   r   r%   r&   ÚTimeoutErrorÚsleep)r   ÚtimeoutÚdeadlines   && r   Újoin_authority_workr�   ¢   sž   é € Ü×'Ò'Ó)×.Ñ.Ó0°7Õ:€HØ
Ü˜IÔ&ÜÔ% iÓ0×1Ò1¼$Ô?QÐR[Ó?\×:]Ò:]Ü& y×1Ò1¼+Ài×:PÒ:PÙÜ×#Ò#Ó%×*Ñ*Ó,°Ô8ÜÐQÓRÐRÜ�mŠm˜CÓ × Ô ùs   ‚CC&ÃC$ÃC&r#   )Ú__doc__rN   ry   r   r   r+   r&   r;   r@   r%   rS   rh   rt   rn   rk   r…   r�   rD   r,   r   Ú<module>r�      s`   ðÙ RÛ å 7ò?ònò'ò	ôò7ò
ñ)Àð )ÈTõ )òX\ò	ò!òô	!r,   