+
    jHàjDˆ  ã                  óx  € R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIt]P                  ! ]	4      t
R tR tR tR tR tR	 tR
 tR tR tR tR tR tR tR tR tR tR tRtRtR tRRRR/R ltR t R1R lt!R t"R1R lt# ! R  R!]$4      t%R" t&R# t'R$ t(R% t)R& t*R' t+R( t,R) t-R* t.R+ t/R, t0R- t1R. t2R/ t3R2R0 lt4R# )3a¶  Session-runtime lifecycle owned by the ordinary gateway bootstrap.

One SessionAuthority per reserved profile home. The launch home always has one; under
``gateway.multiplex_profiles`` every served secondary gets its own, built under that
profile's runtime scope against that profile's ``state.db``. ``runner.session_authority``
stays the launch profile's authority so single-profile behaviour is byte-identical.

The served set is not frozen at boot: ``serve_profile_runtime`` / ``unserve_profile_runtime``
grow and shrink it for the hot-serve reconcile, and a secondary whose store cannot be opened
is parked (logged, left out of ``served_profiles``) instead of aborting every other profile.
)ÚannotationsN)ÚPathc                ó¬  € ^ RI Hp V! 4       P                  4       p\        V RR4      ;'       g    RV3.p\        V P                  RR4      '       d|   \        V P                  RR4      ;'       g    RpV FT  w  rV\        V4      P                  4       pWr8w  g   K&  Ys UU	u0 uF  w  r‰V	kK	  	  up	p9  g   KB  VP                  WW34       KV  	  V# u up	pi )	zY``(name, home)`` pairs this process reserved: launch home first, then served secondaries.©Úget_hermes_homeÚ_primary_profile_nameNÚdefaultÚmultiplex_profilesFÚ_runtime_profile_homes© )Úhermes_constantsr   ÚresolveÚgetattrÚconfigr   Úappend)
Úrunnerr   ÚlaunchÚhomesÚreservedÚnameÚhomeÚ	canonicalÚ_Úhs
   &         Ú8/home/ubuntu/.hermes/hermes-agent/gateway/run_runtime.pyÚreserved_profile_homesr      s¼   € å0ÙÓ×&Ñ&Ó(€FÜ�fÐ5°tÓ<×IÐIÀ	È6ÐRÐS€EÜˆv�}‰}Ð2°E×:Ò:Ü˜6Ÿ=™=Ð*BÀDÓI×OÐOÈRˆÛ"‰JˆDÜ˜T›
×*Ñ*Ó,ˆIØÖ" yÀuÔ8MÁu¹t¸q»ÁuÒ8MÖ'MØ—‘˜dÐ.Ö/ñ #ð €Lùó 9Ns   Â!C
c          
   ƒ  ó¶  "  € ^ RI Hp ^ RIHp V P                  pV P
                  R,          pV! VRR7      ;_uu_ 4        \        V P                  RV P                  4      pVf   \        \        W4      4      h\        P                  ! \        VP                  4      P                  4      G Rj  x€L
 P                  V8w  d   \        RV 24      hVP!                  VRVR	7        V! V \#        V4      WxVR
7      G Rj  x€L
 p	 RRR4       TP)                  TX	4       T	#  Lp L#  \$         d    TP'                  T4       h i ; i  + '       g   i     LI; i5i)zYOne profile's authority against its own ``state.db``; raises when that store is unusable.)Ú_profile_runtime_scope)Úinitialize_session_authorityÚinstance_idF)Úhydrate_secretsÚ_dbNzCsession authority database does not belong to the reserved profile )r   )Ú
profile_idr   ÚdbÚregister)Úgateway.runr   Úgateway.session_authorityr   Úsession_authoritiesÚsession_runtime_descriptorr   Ú_session_dbÚRuntimeErrorÚ_store_open_failureÚasyncioÚ	to_threadr   Údb_pathr   ÚparentÚaddÚstrÚBaseExceptionÚremoveÚreplace)
r   r   r   r$   r   r   Úregistryr   r#   Ú	authoritys
   &&&$      r   Ú_build_profile_authorityr7   $   s)  é € å2ÝFØ×)Ñ)€HØ×3Ñ3°MÕB€Kñ 
  °e×	<Ö	<Ü�V×'Ñ'¨°×0BÑ0BÓCˆØŠ:ÜÔ2°6Ó@ÓAÐAÜ×#Ò#¤D¨¯©Ó$4×$<Ñ$<Ó=×=×EÑEÈÔMÜÐ!dÐeiÐdjÐkÓlÐlØ�‰�T˜4 dˆÔ+ð	Ù:Ø¤3 t£9¸+ÐW_ôa÷ a‰I÷ 
=ð ×Ñ�T˜9Ô%ØÐñ >ñaøäô 	Ø�O‰O˜DÔ!Øð	ú÷ 
=×	<üsT   ‚>EÁ A0EÂ0D!Â15EÃ'D%Ã?D#Ä D%ÄEÄ!EÄ#D%Ä%EÅEÅE	ÅEc                óÂ   a€ VR,          o\        \        V RR4      RR4      \        V RR4      3p\        R V3R lV 4        4       R4      pV'       d   S R	V 2# S R
2# )a™  Why *home*'s ``state.db`` has no handle: the scoped handle caches answer None for a failed open
(and while they back off), so the park reason named an ownership mismatch over the real cause, a
legacy store that crashed its migration on every open (#141467). The reason is the exception the
failed open recorded; reopening here to learn it could create or migrate the store, and would skip
the caches' backoff.zstate.dbÚsession_storeNÚ_db_handle_cacheÚ_session_db_handle_cachec              3  ó8   "  € T F  q'       g   K  Vx € K  	  R # 5i©Nr   )Ú.0Úes   & r   Ú	<genexpr>Ú&_store_open_failure.<locals>.<genexpr>F   s   é € ÐXÑR˜ÓVW—!’!ÓRùs   ‚	�
c              3  óP   <"  € T F  qf   K  VP                  S4      x € K  	  R # 5ir=   )Ú
last_error)r>   ÚcÚpaths   & €r   r@   rA   F   s    øé € ÐR¹&°QÔ0˜aŸl™l¨4×0Ð0»&ùs   ƒ&�&Ú z did not open: z5 is unavailable (its last open failed; retry pending))r   Únext)r   r   ÚcachesÚerrorrE   s   &&  @r   r+   r+   =   sv   ø€ ð �*Õ€DÜ”g˜f o°tÓ<Ð>PÐRVÓWÜ�fÐ8¸$Ó?ðA€FäÑXÔR¹&ÔRÓXÐZ\Ó]€EßØ�� u gÐ.Ð.ØˆVÐHÐIÐIó    c                óh   € \         P                  RWV4       \        W4       \        WRV 24       R# )zðA secondary whose store is unusable is parked: logged, unreserved, left out of
``served_profiles`` and named under ``parked_profiles`` in the runtime descriptor. Boot
continues for every other profile (a runtime hot-add parks the same way).zK[MULTIPLEX] Profile '%s' not served: its session store is unusable (%s): %szsession store unusable: N)ÚloggerrI   Úrelease_profile_homeÚpark_profile)r   r   r   Úexcs   &&&&r   Ú_park_reserved_profilerP   L   s2   € ô ‡L�LÐ^Ø˜Sô"ä˜Ô&Ü�Ð!9¸#¸Ð?Ö@rJ   c                óZ   € \        V 4      p\        V4      R,          W1&   \        V4       R# )a  Publish *name* under ``parked_profiles`` (name -> reason) in the runtime descriptor and the
root's ``gateway_state.json``: a client of that profile then gets a terminal ``profile_parked``
verdict from ``ensure`` instead of waiting its whole deadline for a service that never comes.:Niô  NN)Úparked_profile_mapr1   Ú_record_parked_profiles)r   r   ÚreasonÚparkeds   &&& r   rN   rN   V   s&   € ô   Ó'€FÜ�v“;˜tÕ$€F�LÜ˜FÖ#rJ   c                ó^   € \        V 4      pVP                  VR 4      e   \        V4       R # R # r=   )rR   ÚpoprS   )r   r   rU   s   && r   Úunpark_profilerX   _   s*   € Ü Ó'€FØ‡z�z�$˜ÓÒ)Ü Ö'ñ *rJ   c                ó�   € \        V RR4      ;'       g    / p\        V4      ;'       d    YP                  R4      ;'       g    / 9   # )z¬True when *name* is parked: not served now, but a rescan serves it again, so its ingress is
temporarily unavailable (retry it), never an invalid route (refuse it for good).r(   NÚparked_profiles)r   ÚboolÚget)r   r   Ú
descriptors   && r   Úprofile_parkedr^   e   sB   € ô ˜Ð!=¸tÓD×JÐJÈ€JÜ�‹:×KÐK˜$§>¡>Ð2CÓ#D×#JÐ#JÈÑKÐKrJ   c                óv   € ^ RI Hp ^ RIHp V! V! 4       4      p\	        W4      '       d   ^ RIHp V! V4      hR# )zîAn API request under a parked profile's ``/p/<profile>/`` prefix finds no authority: refuse it
retryably (``runtime_draining``, a 503 with ``Retry-After``), not with the final
``profile_mismatch`` of a profile this gateway does not serve.)Úserved_profile_namer   )ÚParkedProfileRefusalN)Úgateway.session_authoritiesr`   r   r   r^   Úgateway.parked_route_refusalra   )r   r`   r   r   ra   s   &    r   Úrefuse_parked_scoperd   l   s6   € õ @Ý0Ù™Ó0Ó1€DÜ�f×#Ò#ÝEÙ" 4Ó(Ð(ñ $rJ   c                óX   € \        V R R4      pVf	   / ;qn        VP                  R/ 4      # )r(   NrZ   )r   r(   Ú
setdefault)r   r]   s   & r   rR   rR   x   s6   € Ü˜Ð!=¸tÓD€JØÒØ9;Ð;ˆ
Ô6Ø× Ñ Ð!2°BÓ7Ð7rJ   c                óŠ   €  ^ RI Hp V! \        V 4      R7       R#   \         d    \        P                  RRR7        R# i ; i)é    )Úwrite_runtime_status)rZ   z could not record parked_profilesT©Úexc_infoN)Úgateway.statusri   ÚdictÚ	ExceptionrL   Údebug)rU   ri   s   & r   rS   rS      s9   € ðHÝ7Ù¬T°&«\×:øÜô HÜ�‰Ð7À$ˆ×GðHús   ‚ œ"AÁAc           
   ƒ  óú  "  € ^ RI Hp ^ RIHp ^ RIHp \        V 4      pV F*  w  rVVP                  V4      '       d   K  \        RV 24      h	  \        P                  ! 4       P                  pRVR^RRR	. R
. /pW€n        V! V^ ,          ^,          \        V P                  RR4      R7      p	W�n        \!        V4       F!  w  p
w  r¶ \#        WWj^ 8H  R7      G Rj  x€L
  K#  	  V	P(                  P*                  VR&   V	P-                  4       VR
&   \/        \1        V 4      4       V! WyP3                  4       4      V n        \7        V 4       R#  Lp  \$         d    pT
^ 8X  d   h \'        YYl4        Rp?K´  Rp?ii ; i5i)rh   )ÚTicketStore©Úprocess_ownership)ÚSessionAuthoritiesz7session authority requires reserved profile ownership: r   Úruntime_protocolÚstateÚstartingÚcapabilitiesÚserved_profilesr	   F)Úmultiplexed©r$   NÚauthority_epoch)Úgateway.runtime_bootstraprq   Úgateway.runtime_ownershiprs   rb   rt   r   Úownsr*   ÚuuidÚuuid4Úhexr(   r   r   r'   Ú	enumerater7   rn   rP   r   Úepochry   rS   rR   Úprofile_idsÚsession_ticket_storeÚrelease_unknown_turn_markers)r   rq   rs   rt   r   Ú_namer   r   r]   r5   Úindexr   rO   s   &            r   Úinitialize_gateway_runtimerŠ   ‡   s`  é € Ý5Ý;Ý>ä" 6Ó*€EÛ‰ˆØ ×%Ñ% d×+Ô+ÜÐ!XÐY]ÐX^Ð_Ó`Ð`ñ ô —*’*“,×"Ñ"€Kà�{Ð$6¸Ø�˜^¨RØ˜2ð€Jð
 )3Ô%Ù! %¨¥(¨1¥+¼7À6Ç=Á=ÐRfÐhmÓ;nÔo€HØ!)ÔÜ(¨Ö/Ñˆ‰|�ð	<Ü*¨6¸ÐQRÉ
ÔS×SÒSñ  0ð %-§O¡O×$9Ñ$9€JÐ Ñ!Ø$,×$<Ñ$<Ó$>€JÐ Ñ!äÔ.¨vÓ6Ô7Ù"-¨k×;OÑ;OÓ;QÓ"R€FÔÜ  Ö(ñ TøÜô 	<Ø˜ŒzØÜ" 6°×;Ò;ûð	<üsI   ‚9E;Á BE;ÃEÃEÃEÃ A,E;ÅEÅE8ÅE3Å-E;Å3E8Å8E;c                ó  € ^ RI HpHp \        V RR4      pVf   R# \	        V 4       FÉ  pV! V4      ;_uu_ 4        VP
                  P                  R4       Uu0 uF  qUR,          kK  	  ppV'       g    RRR4       KW  VP                  4        FV  pVP                  '       g   K  V! WGP                  4      V9   g   K0  VP                  VP                  VP                  4       KX  	  RRR4       KË  	  R# u upi   + '       g   i     Kå  ; i)ao  Before the unclean-start pass reads crash-left turn markers: a marked turn whose canonical
admission recovered ``unknown`` (the owner died before its terminal commit) owes no reply, so
its marker is cleared rather than ledgered as a delivery the FIFO never committed. A terminal
admission keeps its marker: its persisted reply is ledgered and sent once, never re-run.)Úadmission_ownerÚowner_scoper9   NzPSELECT DISTINCT target_session_id FROM session_admissions WHERE status='unknown'Útarget_session_id)rb   rŒ   r�   r   Ú_authoritiesr#   Ú	_read_allÚlist_sessionsÚactive_turn_tokenÚ
session_idÚclear_turn_activeÚsession_key)r   rŒ   r�   Ústorer6   ÚrowÚunknownÚentrys   &       r   r‡   r‡   ¨   sì   € ÷
 IÜ�F˜O¨TÓ2€EØ‚}ÙÜ! &Ö)ˆ	Ù˜×#Õ#Ø;D¿<¹<×;QÑ;QØbô<dó eñ <d°CÐ.×/Ð/ñ <dˆGð eçØ÷	 $Ñ#ð
 ×,Ñ,Ö.�Ø×*×*Ò*©¸y×JZÑJZÓ/[Ð_fÖ/fØ×+Ñ+¨E×,=Ñ,=¸u×?VÑ?VÖWñ /÷ $Ñ#ó *ùòe÷ $×#Ð#ús/   ºC;ÁC6
Á)C;Á>"C;Â%C;Â>*C;Ã6C;Ã;Dc                ó–   € V P                   pVP                  4       V P                  R &   VP                  4       V P                  n        R# )ry   N)r'   ry   r(   r…   r†   )r   r5   s   & r   Ú_publish_served_setr›   ¼   s>   € Ø×)Ñ)€HØ;C×;SÑ;SÓ;U€F×%Ñ%Ð&7Ñ8Ø.6×.BÑ.BÓ.D€F×ÑÖ+rJ   c                óX  a€ ^ RI Hp \        S4      P                  4       oVP	                  S.4       \        V P                  RR4      pVe]   \        ;QJ d    V3R lV 4       F  '       d   K   RM	  RM! V3R lV 4       4      '       d   . VOVS3N5V P                  n        R# R# R# )u  Grow the process reservation by one profile (hot-serve): take its ``gateway.lock`` and add it
to the frozen boot set, so every reader of the reservation â€” and the next restart's
all-or-nothing reserve â€” sees it. ``OwnershipConflict`` when another gateway owns the home.rr   r
   Nc              3  ó`   <"  € T F#  w  r\        V4      P                  4       S8g  x € K%  	  R # 5ir=   ©r   r   )r>   Ú_nr   r   s   &  €r   r@   Ú'reserve_profile_home.<locals>.<genexpr>Ê   s#   øé € Ð#TÉ8Á%À"¤D¨£G§O¡OÓ$5¸Ö$=Ë8ùs   ƒ+.FT)	r~   rs   r   r   Úreserver   r   Úallr
   )r   r   r   rs   r   s   &&f  r   Úreserve_profile_homer£   Â   s†   ø€ õ <Ü�‹:×ÑÓ€DØ×Ñ˜t˜fÔ%Ü�v—}‘}Ð&>ÀÓE€HØÒ§£Ô#TÉ8Ó#T§§¢Ô#TÉ8Ó#T× TÒ TØ/H°Ð/H¸DÀ$¸<Ñ/Hˆ�‰Ö,ñ !UÑrJ   c                óÚ   € ^ RI Hp \        V4      P                  4       p\	        V RR4      pVe   VP                  V4      e   \        R4      h\        W4       VP                  V4       R# )zWShrink the reservation by one profile (deleted, or parked because it cannot be served).rr   r'   Nz:Profile authority must retire before ownership is released)	r~   rs   r   r   r   Úfor_homer*   Ú_withdraw_profile_homeÚrelease)r   r   rs   r5   s   &&  r   rM   rM   Î   s^   € å;Ü�‹:×ÑÓ€DÜ�vÐ4°dÓ;€HØÒ × 1Ñ 1°$Ó 7Ò CÜÐWÓXÐXÜ˜6Ô(Ø×Ñ˜dÖ#rJ   c                óÄ   a€ \        V P                  RR4      pVeD   \        ;QJ d    . V3R lV 4       F  NK  	  5M! V3R lV 4       4      V P                  n        R# R# )z£Drop *home* from the served set every startup consumer reads (adapters, served status, cron
ticks, ingress, spool recovery) without releasing its ``gateway.lock``.r
   Nc              3  óv   <"  € T F.  p\        V^,          4      P                  4       S8w  g   K*  Vx € K0  	  R# 5i)é   Nrž   )r>   r™   r   s   & €r   r@   Ú)_withdraw_profile_home.<locals>.<genexpr>Þ   s/   øé € ð 5MÙ'�e¬4°°aµ«>×+AÑ+AÓ+CÀtÑ+K�EŠE›xùs   ƒ'9¯
9)r   r   Útupler
   )r   r   r   s   &f r   r¦   r¦   Ù   sY   ø€ ô �v—}‘}Ð&>ÀÓE€HØÒß/4¬uô 5MÙ'ó5M¯u©uô 5MÙ'ó5Mó 0Mˆ�‰Ö,ñ rJ   c                ó>  € V P                   P                  4        Uu. uF  qP                  f   K  VP                  NK   	  ppVP                  \	        V RR4      4       ^ RIHp VP                  V! V 4      4       \        \        P                  V4      4      # u upi )zISnapshot every async task family owned directly by one session authority.Ú_bot_receipt_tasks)Úmutation_tasksr   )
ÚsessionsÚvaluesÚtaskÚextendr   Úgateway.session_runtime_workersr¯   Úlistrm   Úfromkeys)r6   ÚliveÚtasksr¯   s   &   r   Ú_authority_tasksr¹   â   su   € à#,×#5Ñ#5×#<Ñ#<Ô#>ÓXÑ#>˜4Ç)Á)ŒYˆT�YŒYÑ#>€EÐXØ	‡L�L”˜Ð$8¸"Ó=Ô>Ý>Ø	‡L�L‘ 	Ó*Ô+Ü”—‘˜eÓ$Ó%Ð%ùò	 Ys
   �B±Bg     €F@g      $@c                ó   € ^ RI Hp V! V 4      # )zSUnmapped claims, managed workers and owner mutations across the served authorities.)Úuncounted_runtime_work)r´   r»   )r   r»   s   & r   Úmanaged_turn_countr¼   ó   s   € åFÙ! &Ó)Ð)rJ   Ú
in_processFrT   c               óö  € ^ RI Hp ^ p\        V R/ 4      p\        VP	                  4       4       Fw  pVP
                  P                  4       '       g0   \        VRR4      e#   VP                  P                  4       '       d   KT  W&n         VP                  RR/4       V^,          pKy  	  V\        WV4      ,          pV'       g   V# ^ RIHp ^ RIHp	 \        V P$                  R	/ 4      p
\        V P&                  P)                  4       4       F³  w  r¼VP*                  P,                  P/                  R
4      pVe   Wµ9   g   V\        V R/ 4      9   d   KH  V P0                  P/                  VR4      w  rïWí8w  d   V
P/                  VP2                  4      pVe   WùJ d   WÐP4                  V&   MV! VRRR7       V^,          pKµ  	  V#   T d,   p\        P                  RTP                  4        Rp?ELVRp?ii ; i)a—  Cooperative Stop for every turn *authority* is executing: the control a user's Stop sends to a
managed worker (acknowledged, or terminated within STOP_ACK_SECONDS, and the admission settles
through its own fenced path). ``in_process`` also hard-interrupts the running agent of each
executing in-process turn, or latches the generation ``adopt_agent`` consumes before it exists.
``reason`` (a gateway restart/shutdown) is recorded on each worker it signals, so the turn settles
with that cause; a worker already stopped (the user's Stop came first) keeps none. A worker
still being spawned gets the same Stop and cause through latches (``_stop_spawning_managed``).©ÚRuntimeStoreErrorÚ_managed_workersÚstopNÚtypez4managed Stop not queued (%s); the latch escalates it)Úrequest_hard_interrupt)Ú_AGENT_PENDING_SENTINELÚ_running_agentsÚexecution_generationÚ_managed_spawningzProfile stoppingzgateway shutdown)Útool_reason©NN)Úhermes_state_runtimerÀ   r   rµ   r±   ÚclosedÚis_setrÂ   Ú
stop_causeÚcontrolrL   ro   rT   Ú_stop_spawning_managedÚagent.interrupt_compatrÄ   r%   rÅ   r   r°   ÚitemsÚevent_streamÚ	executionr\   ÚadoptedÚrouteÚpending_stops)r6   r½   rT   rÀ   Ú	signalledÚworkersÚworkerrO   rÄ   rÅ   ÚrunningÚsidr·   Ú
generationÚadopted_generationÚagents   &$$             r   Ústop_authority_turnsrà   ù   sÀ  € õ 7Ø€IÜ�iÐ!3°RÓ8€GÜ�w—~‘~Ó'Ö(ˆØ�=‰=×Ñ×!Ò!¤g¨f°f¸dÓ&CÒ&OÐTZ×T_ÑT_×TfÑTf×ThÒThÙØ"Ôð	]Ø�N‰N˜F FÐ+Ô,ð
 	�Q�Š	ñ )ð Ô'¨	¸FÓCÕC€IßØÐÝ=Ý3Ü�i×&Ñ&Ð(9¸2Ó>€GÜ˜)×,Ñ,×2Ñ2Ó4Ö5‰	ˆØ×&Ñ&×0Ñ0×4Ñ4Ð5KÓLˆ
ØÒ ¤°3¼'À)ÐM`ÐbdÓ:eÔ3eÙØ$-×$5Ñ$5×$9Ñ$9¸#¸|Ó$LÑ!ÐØÔ+Ø—K‘K §
¡
Ó+ˆEØŠ=˜EÓ<Ø+5×#Ñ# CÒ(á" 5Ð*<ÐJ\Õ]Ø�Q�Š	ñ 6ð Ðøð/ !ô 	]ô �L‰LÐOÐQT×Q[ÑQ[×\Ò\ûð	]ús   Â
GÇG8Ç G3Ç3G8c                ó  € ^ p\        \        V R/ 4      P                  4       4       Fb  w  rEWA9   d   K  V P                  pV'       d5   VP	                  V4      V8w  d   \        V RR4      pVf	   / ;qpn        WR3Wt&   WVV&   V^,          pKd  	  V# )aQ  A managed turn whose worker is still being spawned has nothing to signal yet: latch the
Stop for its generation (``adopt_agent`` delivers it to the worker, which is never
bootstrapped) and, for a gateway restart/shutdown, the cause its pre-bootstrap interrupted
result carries (#134889 GW-22). A user's Stop latched first keeps no cause.rÈ   Úpending_stop_causesN)rµ   r   rÒ   r×   r\   râ   )r6   rÙ   rT   ÚstoppedrÜ   rÝ   ÚstopsÚcausess   &&&     r   rÐ   rÐ   $  s“   € ð
 €GÜ¤¨	Ð3FÈÓ K× QÑ QÓ SÖT‰ˆØŒ>ÙØ×'Ñ'ˆß�e—i‘i “n¨
Ô2Ü˜YÐ(=¸tÓDˆFØŠ~Ø9;Ð;�Ô6Ø%Ð.ˆF‰KØˆc‰
Ø�1�Šñ Uð €NrJ   c                ó@   a€ \        V3R l\        V 4       4       4      # )zP``stop_authority_turns`` across every served authority (whole-runtime shutdown).c              3  ó>   <"  € T F  p\        VSR 7      x € K  	  R# 5i))rT   N)rà   )r>   r6   rT   s   & €r   r@   Ú%stop_managed_turns.<locals>.<genexpr>:  s   øé € ÐdÑOcÀ)Ô# I°f×=Ñ=ÓOcùs   ƒ)Úsumr�   )r   rT   s   &fr   Ústop_managed_turnsrê   8  s   ø€ äÔdÌ|Ð\bÔOcÓdÓdÐdrJ   c                ó   € ^ RI Hp V! W4      # )zYWhole-runtime shutdown: interrupt every counted side agent (``session_runtime_workers``).)Úinterrupt_side_agents)r´   rì   )r   rT   Ú	interrupts   && r   rì   rì   =  s   € åRÙ�VÓ$Ð$rJ   c              ƒ  ór  "  € ^ RI Hp ^ RIHpHp Vf   \
        MTpRV n        \        V P                  RR4      e   \        V P                  4       T! V 4       ^ RI
Hp V! V 4       \        V RR4      pVf   RM5\        P                  ! \        P                  ! VP                  VR7      4      p V! W4      G Rj  x€L
  RpVRJ ;'       g    VG Rj  x€L
 R
Jp	V	'       g!   \         P#                  RV P$                  4       V'       d	   V	'       g   R
# \'        V 4      p
V
 F  pVP)                  4        K  	  V
'       d   \        P*                  ! V
RR/ G Rj  x€L
  T! V 4       RV n        ^ RIHp V P2                  P5                  4        V P6                  P9                  4        F2  pVP;                  4       '       d   K  VP=                  V! R4      4       K4  	  V P6                  P5                  4        R#  EL>  \         d'    \         P#                  R	T P$                  4       R
p ELji ; i EL] LÙ5i)aÉ  Stop profile-local services and turns before its ownership is released.

Claims are refused from here on; every executing turn gets a cooperative Stop, and its session
task is joined (an in-process turn's task ends only after its executor thread returned and the
admission settled). The hosted-room stop runs alongside that join under the same deadline: it
never interrupts accepted turns and its room threads wait for the member turns they observe, so
those turns must be signalled first or the room stop cannot finish. False when a turn or room
thread misses *timeout* (default TURN_SETTLE_SECONDS): it may still call tools and write
history, so the caller must keep the profile's reservation and store handles.)Úunbind_owner)Újoin_authority_workÚstop_authority_workNTr†   ©rÂ   Úhosted_room_service©Útimeoutz3Profile %s workers did not stop; ownership retainedFz8Profile %s hosted rooms did not stop; ownership retainedÚreturn_exceptionsr¿   Úruntime_draining)Úgateway.session_cronrï   r´   rð   rñ   ÚTURN_SETTLE_SECONDSÚretiringr   r   r›   Úgateway.session_llm_oneshotrÂ   r,   Úensure_futurer-   ÚTimeoutErrorrL   rI   r"   r¹   ÚcancelÚgatherÚretiredrË   rÀ   Únative_waitersÚclearÚwaitersr±   ÚdoneÚset_exception)r6   rõ   rï   rð   rñ   Ústop_oneshotsÚserviceÚroomsÚworkers_stoppedÚrooms_stoppedÚrestr²   rÀ   Úwaiters   &&            r   Ú_retire_profile_authorityr  C  sÍ  é € õ 2ßXØ%,¢_Õ!¸'€GØ€IÔÜˆy×ÑÐ!7¸Ó>ÒJÜ˜I×,Ñ,Ô-Ù˜	Ô"ÝAÙ�)ÔÜ�iÐ!6¸Ó=€GØ’O‰D¬×)>Ò)>¼w×?PÒ?PÐQX×Q]ÑQ]ÐgnÔ?oÓ)p€Eð Ù! )Ó5×5Ð5Øˆð ˜T�M×=Ð=¨5§[¸Ð%=€MßÜ�‰ÐOÐQZ×QeÑQeÔfß§Ùä˜IÓ&€DÛˆØ�‰Žñ çÜ�nŠn˜dÐ;°dÑ;×;Ð;Ù�Ôð €IÔõ 7Ø×Ñ×"Ñ"Ô$Ø×#Ñ#×*Ñ*Ö,ˆØ�{‰{�}Œ}Ø× Ñ Ñ!2Ð3EÓ!FÖGñ -ð ×Ñ×ÑÔÙò9 	6øäô  Ü�‰ÐJÈI×L`ÑL`ÔaØ‹ð úò &1ñ 	<ùs   ‚B/H7Â2G> Â=G;Â>G> Ã
H7ÃH7ÃH2ÃH7Ã$'H7ÄH7Ä-H7ÅH7ÅH5ÅA#H7Ç7H7Ç;G> Ç>-H/È+H7È.H/È/H7È5H7c                  ó   € ] tR tRtRtRtR# )ÚProfileOwnershipRetainedix  zZA retired attempt's writer is still live: the profile keeps its reservation and authority.r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   rJ   r   r  r  x  s   † ÝdrJ   r  c              ƒ  ó�  "  € ^ RI Hp ^ RIHpHp ^ RIHp ^ RIHp \        P                  ! \        V4      P                  4      G Rj  x€L
 pV P                  pVP                  V4      p	V	eP   \        V	RR4      '       d=   \!        V	^ R7      G Rj  x€L
 '       g   \#        R	V R
24      hVP%                  V4       MV	e   V	# \'        WVRR7      G Rj  x€L
 p
 V! V
4      ;_uu_ 4        \)        V
4       \+        V
4      G Rj  x€L
  V! V
RR7       V! V
4      G Rj  x€L
  \-        W
4       RRR4       \        V RR4      e   V! W
4      G Rj  x€L
  \1        T 4       T! T 4       T
#  EL" LÛ Lš Ll LT  + '       g   i     LO; i L7  \.         d.    \!        T
4      G Rj  x€L 
 '       d   TP%                  T4       h i ; i5i)us  Hot-serve one reserved profile's runtime: build its authority, recover its durable state and
publish it in the descriptor/ticket store â€” the steps boot performs per secondary. Raises when
the profile's store is unusable; the caller parks it (and releases the reservation). Its
queued native rows are recovered once its adapters connect (``recover_served_native_rows``).©r�   )Ú_ensure_hosted_serviceÚstart_ready_hosted_services©Úrecover_local_sessions©Úrecover_webhook_finalizationsNrú   Frô   zan earlier serve of z is still stoppingr{   T©ÚscheduleÚsession_control_server)rb   r�   Úgateway.session_hosted_servicer  r  Úgateway.session_local_recoveryr  Ú!gateway.platforms.webhook_ingressr  r,   r-   r   r   r'   r¥   r   r  r  r3   r7   Ú_drop_retired_local_adapterÚrecover_bot_mailboxÚ_recover_published_api_turnsr2   r›   )r   r   r   r�   r  r  r  r  r5   Úexistingr6   s   &&&        r   Úserve_profile_runtimer(  |  s„  é € õ
 8ßbÝEÝOÜ×"Ò"¤4¨£:×#5Ñ#5Ó6×6€DØ×)Ñ)€HØ× Ñ  Ó&€HØÒ¤¨°*¸e× DÒ Dô /¨xÀÔC×CÖCÜ*Ð-AÀ$ÀÐGYÐ+ZÓ[Ð[Ø�‰˜ÕØ	Ò	ØˆÜ.¨v¸TÈEÔR×R€IðÙ˜×#Õ#Ü'¨	Ô2Ü% iÓ0×0Ð0Ù" 9°tÕ<Ù/°	Ó:×:Ð:Ü(¨Ô;÷ $ô �6Ð3°TÓ:ÒFÙ(¨Ó;×;Ð;ô
 ˜ÔÙ Ô'ØÐò9 7ñ Dñ
 Sñ 1á:÷	 $×#úñ <øÜô Ü*¨9Ó5×5×5Ø�O‰O˜DÔ!Øðüs¯   ‚AGÁ	E+Á
AGÂE.Â	GÂ8GÃE0ÃGÃF Ã+E6ÄE2ÄE6ÄE4Ä E6Ä/"F ÅF	ÅF ÅGÅ.GÅ0GÅ2E6Å4E6Å6F	Æ	F ÆGÆ$F'Æ%
GÆ0GÇGc                óÖ   € ^ RI Hp ^ RIHp V! V 4      p\	        VP                  VP                  4      RR4      pVe+   W@Jd$   \	        VRR4      '       d   W1P                   R# R# R# R# )aT  A LOCAL adapter still bound to this profile's previous authority, once that authority fully
retired, gives way to *authority*'s own: restore and create otherwise refuse every local session
of the served profile as ``runtime_draining``. A retained writer never gets here (the serve is
refused while the previous authority is still retiring).©ÚPlatform)Úlocal_adapter_mapr6   Nr   F)Úgateway.configr+  r"  r,  r   r\   ÚLOCAL)r6   r+  r,  ÚadaptersÚpreviouss   &    r   r$  r$  ¤  s`   € õ
 (Ý@Ù  Ó+€HÜ�x—|‘| H§N¡NÓ3°[À$ÓG€HØÒ Ó 9¼gÀhÐPYÐ[`×>aÒ>aØ—^‘^Ò$ñ ?bÑ 9ÑrJ   c                óš   € ^ RI Hp \        V RR4      ;'       g    / P                  VP                  4      pVe   ^ RIHp V! W14       R# R# )z¡Boot recovers queued API turns when the launch API adapter is published
(``recover_api_turns``); a profile served after that runs the same pass on its own store.r*  r/  N)Úrecover_authority_api_turns)r-  r+  r   r\   Ú
API_SERVERÚgateway.session_api_turnr2  )r   r6   r+  Úapir2  s   &&   r   r&  r&  ±  sC   € õ (Ü�6˜: tÓ,×2Ð2°×
7Ñ
7¸×8KÑ8KÓ
L€CØ
‚ÝHÙ# CÖ3ñ rJ   c              ƒ  óî   "  € \        V RR4      f   R# ^ RIHp V! V 4       F  p \        W4      G Rj  x€L
  K  	  R#  L
  \         d'    \
        P                  RTP                  RR7        KO  i ; i5i)a­  Boot's native-row recovery once hot-served profiles' adapters connected (boot runs it after
every adapter connects), in every serving ledger: a ``bot_profile`` route runs a bot's messages
on another profile, so the new bots can carry rows queued in any ledger. A session already
draining keeps its one drain. A store that cannot answer leaves its rows queued for the next
start and never stops the other ledgers or the reconcile.r'   N)Úserving_authoritiesz%Native session recovery failed for %sTrj   )r   rb   r7  Úrecover_profile_native_sessionsrn   rL   rI   r"   )r   r7  r6   s   &  r   Úrecover_served_native_rowsr9  »  sm   é € ô ˆvÐ,¨dÓ3Ò;ÙÝ?Ù(¨Ö0ˆ	ð	gÜ1°&ÓD×DÒDó 1áDøÜô 	gÜ�L‰LÐ@À)×BVÑBVÐaeˆL×fð	güs5   ‚#A5¦A´?µA¹A5¿AÁ-A2Á.A5Á1A2Á2A5c              ƒ  ó0  "  € \         P                  ! \        V4      P                  4      G Rj  x€L
 pV P                  pVP                  V4      pVf   R# \        V4      G Rj  x€L
 pV'       g   R# VP                  V4       \        V 4       V#  Lb L.5i)zæRetire one profile's authority (deleted while running) and shrink the published set.
False when one of its turns outlived the Stop deadline (keep the reservation); True otherwise,
including for a profile this process never served.NTF)	r,   r-   r   r   r'   r¥   r  r3   r›   )r   r   r5   r6   r   s   &&   r   Úunserve_profile_runtimer;  Ë  s~   é € ô ×"Ò"¤4¨£:×#5Ñ#5Ó6×6€DØ×)Ñ)€HØ×!Ñ! $Ó'€IØÒÙÜ-¨iÓ8×8€GßÙØ‡O�O�DÔÜ˜ÔØ€Nñ 7ñ
 9ùs'   ‚-B¯B°5BÁ%BÁ&BÁ2!BÂBc                ó   € ^ RI Hp V! V 4      # )rh   )Úall_authorities)rb   r=  )r   r=  s   & r   r�   r�   Ü  s   € Ý;Ù˜6Ó"Ð"rJ   c              ƒ  óÌ   "  € ^ RI Hp ^ RIHp  V! V 4      G Rj  x€L
  R#  L  T d7   p\        P                  RT P                  P                  T4        Rp?R# Rp?ii ; i5i)aÞ  Owner-startup Bot Chat recovery, skipped when this token cannot use the mailbox dir.

An elevated install/update can leave ``runtime/bot_live_delivery`` owned by Administrators with
no entry for the user (#139485, #138872): the gateway cannot even open its ``.lock``. Bot Chat
deliveries pause (``_locked`` already logged the dir, its owner and the remedy); every other
client keeps working instead of the whole gateway refusing to start. Any other failure still
aborts startup.)Úrecover_bot_deliveries)ÚMailboxUnusableNz$Bot Chat recovery skipped for %s: %s)Úgateway.session_botr?  Útools.bot_live_deliveryr@  rL   Úwarningr#   r.   )r6   r?  r@  rO   s   &   r   r%  r%  á  sQ   é € õ ;Ý7ðZÙ$ YÓ/×/Ô/øØô ZÜ�‰Ð=¸y¿|¹|×?SÑ?SÐUX×YÒYûðZüs6   ‚A$�$ ›"œ$  A$¢$ ¤A!«+AÁA$ÁA!Á!A$c              ƒ  óÜ   "  € ^ RI Hp V! V 4      G Rj  x€L
 V n        V P                  P                  V P                  R&   \        V 4       F  p\        W4      G Rj  x€L
  K  	  R#  LS L5i)rh   )Ústart_gateway_apiNÚ
api_origin)Úgateway.run_apirE  Úsession_apirF  r(   r�   Ú_recover_profile_bot_mailbox)r   rE  r6   s   &  r   Ústart_gateway_runtime_apirJ  ñ  s[   é € Ý1Ù0°Ó8×8€FÔØ6<×6HÑ6H×6SÑ6S€F×%Ñ% lÑ3Ü! &Ö)ˆ	Ü*¨6Ó=×=Ò=ó *ñ 9ñ 	>ùs"   ‚A,”A(•AA,ÁA*ÁA,Á*A,c           	   ƒ  ó¸  "  € ^ RI Hp  V! V4      ;_uu_ 4        \        V4      G Rj  x€L
  RRR4       R#  L  + '       g   i     R# ; i  \         dÿ   p\	        T RR4      pTf   RMTP                  T4      pTf   h \        P                  RYSRR7       \        P                  ! \        TP                  4      P                  4      G Rj  x€L 
 p\        T4      G Rj  x€L 
 '       g$   \        Y4       \        YRT RT 24        Rp?R# TP!                  T4       \#        T 4       \%        Y4       \        YR	T R
T 24        Rp?R# Rp?ii ; i5i)ak  Startup Bot Chat recovery of one served profile. A secondary whose durable leftovers cannot
be recovered is parked like one whose store cannot be opened (retired, unreserved, named under
``parked_profiles``): under multiplex it would otherwise take every other profile down with it,
on every restart (#140018). The launch profile's failure still aborts the start.r  Nr'   z@[MULTIPLEX] Profile '%s' not served: startup recovery failed: %sTrj   zQstartup recovery failed; ownership retained (a control-socket rescan, `hermes -p z1 gateway run`, serves it once its writer stops): z=startup recovery failed (a control-socket rescan, `hermes -p z! gateway run`, serves it again): )rb   r�   r%  rn   r   Úprofile_namerL   rI   r,   r-   r   r"   r   r  r¦   rN   r3   r›   rM   )r   r6   r�   rO   r5   r   r   s   &&     r   rI  rI  ù  sD  é € õ
 8ð_Ù˜×#Õ#Ü% iÓ0×0Ð0÷ $Ñ#Ù0÷ $×#Ð#ûäô _Ü˜6Ð#8¸$Ó?ˆØÒ'‰t¨X×-BÑ-BÀ9Ó-MˆØŠ<ØÜ�‰ÐWÐY]Ø"ð 	ô 	$ä×&Ò&¤t¨I×,@Ñ,@Ó'A×'IÑ'IÓJ×JÐJˆÜ.¨yÓ9×9×9ô # 6Ô0Ü˜ð *5Ø59°FÐ:kÐloÐkpð(rô såØ�‰˜ÔÜ˜FÔ#Ü˜VÔ*Ü�Vð &1Ø15°Ð6WÐX[ÐW\ð$^÷ 	_ò 	_ûð%_üs„   ‚EŠA š:©8ª:®A ¶E¸:ºA	ÁA Á	EÁA ÁEÁA7EÃCÃEÃ$C'Ã%
EÃ0EÄEÄ9EÅEÅEÅEc              ƒ  óx  "  € ^ RI HpHp V! V 4      pV'       g   / # ^ RIHp V! V 4      G Rj  x€L
  ^ RIHp ^ RIHp / pV FX  pV! V4      ;_uu_ 4        V! VRR7       V! V4      G Rj  x€L
  RRR4       TP                  \        W4      G Rj  x€L
 4       KZ  	  V#  Lr L6  + '       g   i     L<; i L%5i)zäRecover against the published routing index and currently connected adapters.

Stored envelopes are input, not authority to create a route or reconnect a
transport. The authority preflights every queued sender before any claim.
)r�   r7  )Úensure_hosted_serviceNr  r  Tr  )rb   r�   r7  r!  rN  r"  r  r#  r  Úupdater8  )	r   r�   r7  ÚauthoritiesrN  r  r  Úresultsr6   s	   &        r   Úrecover_gateway_native_sessionsrR    s¢   é € ÷ MÙ% fÓ-€KßØˆ	ÝDÙ
 Ó
'×'Ð'ÝEÝOØ€GÛ ˆ	Ù˜×#Õ#Ù" 9°tÕ<Ù/°	Ó:×:Ð:÷ $ð 	�‰Ô<¸VÓO×OÖPñ	 !ð
 €Nñ (ñ ;÷ $×#úñ PùsE   ‚,B:®B!¯'B:ÁB%Á,B#
Á-B%Á1!B:ÂB8
ÂB:Â#B%Â%B5Â0	B:c              ƒ  ó–  "  € ^ RI Hp V! V4      ;_uu_ 4        VP                  P                  R4       Uu0 uF  q3R,          kK  	  ppV P                  P                  4        UUu. uF\  qUP                  f   K  VP                  VP                  4      qfV9   g   K5  WeP                  V P                  VP                  4      3NK^  	  pppVP                  V4      G Rj  x€L
 pRRR4       XP                  4        F&  w  rš\        P                  RW‘P                  V
4       K(  	  V# u upi u uppi  LS  + '       g   i     LY; i5i)zFBind one authority's queued native rows to the adapters connected now.r  z^SELECT DISTINCT target_session_id FROM session_admissions WHERE status IN ('queued','unknown')rŽ   Nz+Native session startup recovery %s (%s): %s)rb   r�   r#   r�   r9   r‘   ÚoriginÚlogical_ownerr“   Ú_adapter_for_sourceÚrecover_native_sessionsrÒ   rL   Úinfor"   )r   r6   r�   r—   Úpendingr™   ÚownerÚbindingsÚoutcomerÜ   Úverdicts   &&         r   r8  r8  /  s(  é € å7Ù	�Y×	Õ	Ø7@·|±|×7MÑ7MØlô8nó oñ 8n°Ð*×+Ð+ñ 8nˆð oð "(×!5Ñ!5×!CÑ!CÔ!EôbÙ!E˜ÏÉô Tà"+×"9Ñ"9¸%×:JÑ:JÓ"K˜ÐY`ÑP`ô T�UŸL™L¨&×*DÑ*DÀUÇ\Á\Ó*RÓSÙ!Eð 	ñ bð "×9Ñ9¸(ÓC×Cˆ÷ 
 ð  Ÿ™ž‰ˆÜ�‰ÐAÀ3×H\ÑH\Ð^eÖfñ (à€Nùòoùóbñ D÷ 
 ×	üsR   ‚E	™D6·D)ÁD6Á'D.
Á;D.
Â+D.
Ã	D6Ã D4Ã!D6Ã%AE	Ä)D6Ä6E	ÅE	c                ó  € V P                   pV P                  P                  P                  4       '       g%   V P                  '       d   V P
                  '       d   \        R 4      hTP                  R. ROR7       ^ RIH	p V! V 4       R# )z,gateway stopped before session API readinessÚready©rv   rx   )r  N)zsession-authority-v1zdurable-admission-v1zevent-replay-v1)
r(   rH  r²   r  Ú_runningÚ	_drainingr*   rO  r!  r  )r   r]   r  s   &  r   Úpublish_gateway_runtime_readyrc  >  sl   € Ø×2Ñ2€JØ×Ñ×Ñ×#Ñ#×%Ò%¨V¯_¯_¨_À×@P×@PÐ@PÜÐIÓJÐJØ×Ñ˜Gò 3KÐô LåJÙ Ö'rJ   c              ƒ  óü  "  € \         P                  ! V P                  4       4      pV P                  P                  p \         P
                  ! W0\         P                  R7      G Rj  x€L
 w  r4W#9   dd   V P                  '       gR   V P                  P                  R. R7       VP                  4       '       d   RMVP                  4       p\        R4      VhVG Rj  x€L
  VP                  4       '       g   VP                  4        \         P                  ! VRR7      G Rj  x€L
  R#  LÁ LN L
  TP                  4       '       g   TP                  4        \         P                  ! TRR7      G Rj  x€L 
  i ; i5i)zIA vanished interactive listener is fatal, not a healthy headless runtime.)Úreturn_whenNÚfailedr`  z(gateway session API stopped unexpectedlyT)rö   )r,   Úcreate_taskÚwait_for_shutdownrH  r²   ÚwaitÚFIRST_COMPLETEDrb  r(   rO  Ú	cancelledÚ	exceptionr*   r  rþ   rÿ   )r   ÚshutdownÚlistenerr  r   rI   s   &     r   Úwait_gateway_runtimero  H  s  é € ä×"Ò" 6×#;Ñ#;Ó#=Ó>€HØ×!Ñ!×&Ñ&€Hð
?ÜŸš hÐ%9Äw×G^ÑG^Ô_×_‰ˆØÔ F×$4×$4Ð$4Ø×-Ñ-×4Ñ4¸8ÐRTÐ4ÔUØ$×.Ñ.×0Ò0‘D°h×6HÑ6HÓ6JˆEÜÐIÓJÐPUÐUØ�ˆà�}‰}�ŠØ�O‰OÔÜ�nŠn˜X¸Ô>×>Ò>ñ `ñ
 	ñ 	?øð �}‰}�ŠØ�O‰OÔÜ�nŠn˜X¸Ô>×>Ò>üsl   ‚;E<¾*D0 Á(D*Á)D0 Â2D0 Â:#D0 ÃD,ÃD0 Ã"AE<Ä#D.Ä$E<Ä*D0 Ä,D0 Ä.E<Ä0AE9Å2E5Å3E9Å9E<c              ƒ  óÎ  "  € \        V RR4      pVf   R# RV n        VP                  R. R7       ^ RIHp VP                  R4      V8X  d   VR ^ RIHp V! V 4      G Rj  x€L
  V P                  P                  4        F  pVP                  R4       K  	  \        V R	/ 4      P                  4        F+  pVP                  4        F  pVP                  R4       K  	  K-  	  R#  L‚5i)
zFWithdraw admission before any await; close sockets before DB teardown.r(   NTÚdrainingr`  )ÚRESTART_WAIT_REASONÚdrain_reason)Ústop_hosted_serviceÚ_profile_adapters)r   rb  rO  Úgateway.drain_controlrr  r\   r!  rt  r/  r±   Úset_message_handler)r   r]   rr  rt  Úadapterr/  s   &     r   Údrain_gateway_runtimery  Y  sÏ   é € ä˜Ð!=¸tÓD€JØÒÙØ€FÔØ×Ñ˜J°RÐÔ8Ý9Ø‡~�~�nÓ%Ð)<Ô<Ø�~Ð&ÝBÙ
˜fÓ
%×%Ð%ð —?‘?×)Ñ)Ö+ˆØ×#Ñ# DÖ)ñ ,ä˜FÐ$7¸Ó<×CÑCÖEˆØ—‘Ö(ˆGØ×'Ñ'¨Ö-ó )ó Fñ &ùs   ‚AC%Á C#Á!BC%c           
   ƒ  ót  "  € \        V 4      p\        W4       ^ RIHp V F  pV! V4       K  	  V UUu. uF  p\	        V4       F  qfNK  	  K  	  pppVf   \
        M$\        R\        \
        V\        ,
          4      4      pV'       d—   V^ 8”  d    \        P                  ! WxR7      G Rj  x€L
 M\        4       \        V4      3w  ršV	 F+  pVP                  4       '       d   K  VP                  4        K-  	  V
'       d!   \        P                  R\!        V
4      V4       ^ RIHp V F  p V! V^ 4      G Rj  x€L
  K  	  ^ R
IHp \        V 4       F  p V! V4       K  	  ^ RIHp \)        V RR4      pVe   VP;                  4        \)        V RR4      pVe   V! V4      G Rj  x€L
  R# R# u uppi  EL	 L~  \&         d&    \        P                  R\)        TRR	4      4        KÀ  i ; i  \.         d<    ^ RIpTP2                  ! \4        4      P                  R\)        TRR	4      RR7        Kß  i ; i L�5i)as  Keep authority tasks alive until their last durable settlement write, within a bound.

A managed turn still running here gets its Stop first (its worker acknowledges or is
terminated, and the admission settles interrupted or ``unknown``); a task that still misses
TURN_SETTLE_SECONDS (clamped to ``budget``, what the stop's watchdog leash has left, minus
STOP_TAIL_RESERVE_SECONDS) is logged and left running for recovery. The stop sequence continues:
the executor quiesce skips the DB close while a writer is live, and process exit releases
the ownership lock, so raising here would only skip teardown and disarm the watchdog.rò   Ng        rô   zC%d authority task(s) did not settle within %.0fs; left for recovery)rð   zOProfile %s still has live writers at shutdown; its admissions stay for recoveryr"   Ú?)Úend_idle_acp_sessionsz(ACP sessions of %s not ended at shutdownTrj   )Ústop_gateway_apir†   rH  )r�   rê   rû   rÂ   r¹   rù   ÚmaxÚminÚSTOP_TAIL_RESERVE_SECONDSr,   ri  Úsetrk  rl  rL   rC  Úlenr´   rð   rý   r   Úgateway.session_acp_lifecycler|  rn   ÚloggingÚ	getLoggerr  rG  r}  Úrevoke)r   ÚbudgetrT   rP  r  r6   r²   r¸   ri  r  rY  rð   r|  r„  r}  r–   Úhandles   &&&              r   Úsettle_gateway_runtimer‰  n  s  é € ô ˜vÓ&€KÜ�vÔ&ÝAÛ ˆ	Ù�iÖ ñ !á#.ÔW¡;�iÔ;KÈIÖ;V°4ŠTÑ;V‰T¡;€EÑWØ"(¢.Õ´c¸#¼sÔCVØCIÔLeÕCeó@gó 7h€DçØCGÈ!Ä8œgŸlšl¨5Ô?×?Ð?ÔRUÓRWÔY\Ð]bÓYcÐQd‰ˆÛˆDØ—>‘>×#Ô#Ø—‘Ö ñ ÷ Ü�N‰NÐ`Ü˜w›<¨ô/åCÛ ˆ	ð	BÙ% i°Ó3×3Ò3ñ !õ DÜ! &Ö)ˆ	ð	fÙ! )Ö,ñ *õ 1Ü�FÐ2°DÓ9€EØÒØ�‰ŒÜ�V˜]¨DÓ1€FØÒÙ˜vÓ&×&Ò&ñ ùóE Xò @ñ 4øÜô 	BÜ�N‰NÐlÜ" 9¨l¸CÓ@÷Bð	Bûô ô 	fãØ×ÒœhÓ'×/Ñ/Ð0ZÜ07¸	À<ÐQTÓ0UÐ`dð 0÷ fð	fúñ 	'ùs–   ‚3H8µF/Á9H8Â!H8Â,F5Â-3H8Ã%H8Ä+H8Ä-F:Ä9F8Ä:F:Ä>H8ÅG-ÅAH8Æ&H6Æ'H8Æ8F:Æ:,G*Ç&H8Ç)G*Ç*H8Ç-AH3È/H8È2H3È3H8r=   rÊ   )5r  Ú
__future__r   r,   r„  Úpathlibr   r€   r…  r  rL   r   r7   r+   rP   rN   rX   r^   rd   rR   rS   rŠ   r‡   r›   r£   rM   r¦   r¹   rù   r€  r¼   rà   rÐ   rê   rì   r  r*   r  r(  r$  r&  r9  r;  r�   r%  rJ  rI  rR  r8  rc  ro  ry  r‰  r   rJ   r   Ú<module>rŒ     s%  ðñ
õ #ã Û Ý Û à	×	Ò	˜8Ó	$€òòò2JòAò$ò(òLò	)ò8òHò)òBXò(Eò	Iò$òMò&ð Ð ð !Ð ò*ð(°%ð (Àô (òVô(eò
%ô2ôje˜|ô eò%òP
%ò4ògò ò"#ò
Zò >ò_ò>ò.ò(ò?ò".ö*1'rJ   