+
    „WÝjNk  ã                  ó  € R t ^ RIHt ^ RIHt ^ RIt^ RIt^ RIt^ RIH	t	 ^ RI
HtHt ^ RIHt ]'       d   ^ RIHt Rt]! R	R
7       ! R R4      4       t]! R	R
7       ! R R4      4       tR R ltR R ltR R ltR R lt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]P>                  R%8H  t R& R' lt!R(] /R) R* llt"R+R,/R- R. llt#R/ R0 lt$R1 R2 lt%R3t&]'! R4R504      t(R6 R7 lt)R+]R4R8/R9 R: llt*R# )<zHValidated, credential-free gateway endpoint discovery for local clients.)Úannotations)Ú	dataclassN)ÚPath)ÚTYPE_CHECKINGÚLiteral)Úurlsplit)ÚRuntimeStateg      N@T)Úfrozenc                  óz   € ] tR t^t$ R]R&   R]R&   R]R&   R]R&   R]R&   R]R	&   R
]R&   RtR]R&   RtR]R&   RtR# )ÚGatewayEndpointÚstrÚ
profile_idÚinstance_idÚintÚauthority_epochÚruntime_protocolÚ
api_originz<Literal['none', 'systemd', 'launchd', 'windows', 'external']Ú
supervisorzfrozenset[str]ÚcapabilitiesNú
str | NoneÚcontrol_homeÚcode_sha© )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__annotations__r   r   Ú__static_attributes__r   ó    ÚNC:\Users\johnn\AppData\Local\hermes\hermes-agent\hermes_cli\gateway_runtime.pyr   r      sB   ‡ àƒOØÓØÓØÓØƒOØLÓLØ Ó ð  $€L�*Ó#ð  €Hˆj×r   r   c                  óL   € ] tR t^)t$ R]R&   RtR]R&   RtR]R&   RtR]R&   R	tR# )
ÚGatewayDiscoveryr   ÚstateNúGatewayEndpoint | NoneÚendpointr   Úreason_codeÚdetailr   )	r   r   r   r   r   r%   r&   r'   r   r   r   r    r"   r"   )   s)   ‡ àÓØ'+€HÐ$Ó+Ø"€K�Ó"ð
 €FˆJ×r   r"   c               ó    € V ^8„  d   QhRRRR/# )é   Úresultr"   ÚreturnÚboolr   )Úformats   "r    Ú__annotate__r.   5   s   € ÷ 	qñ 	qÐ'ð 	q¨Dñ 	qr   c                ó¨   € V P                   f   R# ^ RIHp V P                  R8H  ;'       g'    V P                  R8H  ;'       d    V P                  V8H  # )aT  Whether a client may attach to this discovery/ensure verdict.

``ready`` owners, plus a restart's after-turn wait (``draining``/``restart_wait``): that owner
still owns its turns and must stay reachable to answer a parked approval/clarify (#139041).
Shared by every client bootstrap (``connect_gateway`` and Ink's ``gateway_bootstrap.py``).F©ÚRESTART_WAIT_REASONÚreadyÚdraining)r%   Úgateway.drain_controlr1   r#   r&   )r*   r1   s   & r    Ú
attachabler5   5   sH   € ð ‡�ÒÙÝ9Ø�<‰<˜7Ñ"×pÐp v§|¡|°zÑ'A×'oÐ'oÀf×FXÑFXÐ\oÑFoÐpr   c               ó    € V ^8„  d   QhRRRR/# )r)   Úhomeú
str | Pathr+   r   r   )r-   s   "r    r.   r.   A   s   € ÷ Dñ D˜*ð D¨ñ Dr   c                óœ   € \         P                  P                  \        \	        V 4      P                  4       P                  4       4      4      # ©N)ÚosÚpathÚnormcaser   r   Ú
expanduserÚresolve©r7   s   &r    Ú_canonical_homerA   A   s2   € Ü�7‰7×ÑœC¤ T£
× 5Ñ 5Ó 7× ?Ñ ?Ó AÓBÓCÐCr   c               ó    € V ^8„  d   QhRRRR/# )r)   r7   r8   r+   r   r   )r-   s   "r    r.   r.   E   s   € ÷ Bñ B˜zð B¨dñ Br   c                ób   € \        \        V 4      P                  4       P                  4       4      # )ac  The profile home whose gateway serves *home*: the home itself, or for a private overlay home
(a task dir mirroring a profile through symlinks, its ``gateway.lock`` among them) the profile its
lock names. A client compares the owner's ``profile_id`` with this, never the overlay path.
Not normcased: ``profile_id`` keeps the owner's own spelling (Windows).)Ú_overlay_owner_homer   r>   r?   r@   s   &r    Úgateway_profile_homerE   E   s%   € ô
 œt D›z×4Ñ4Ó6×>Ñ>Ó@ÓAÐAr   c               ó    € V ^8„  d   QhRRRR/# )r)   r7   r   r+   r   )r-   s   "r    r.   r.   M   s   € ÷ ñ ˜dð  tñ r   c                ój  € \         P                  R8X  d   V # ^ RIHpHpHp V R,          p V! V RRR7       VP                  RR7      pVP                  4       '       d   VP                  R8w  d   V # V! VP                  RRR7       V! V4       VP                  #   \        \        T3 d    T u # i ; i)zJReturn the owner named by a private overlay's gateway lock, if it has one.Únt)ÚDiscoveryErrorÚ_private_lockÚ_private_nodeúgateway.lockÚ	directoryT)Úkindr7   )Ústrict)r;   ÚnameÚ$hermes_cli.gateway_runtime_discoveryrI   rJ   rK   r?   Ú
is_symlinkÚparentÚFileNotFoundErrorÚOSError)r7   rI   rJ   rK   ÚlockÚtargets   &     r    rD   rD   M   s£   € ä	‡w�w�$„ØˆßaÑaØ�.Õ €Dðñ 	�d °4Õ8Ø—‘ T�Ó*ˆØ�‰× Ò  F§K¡K°>Ô$AØˆKÙ�f—m‘m¨+¸DÕAÙ�fÔð �=‰=Ðøô œw¨Ð7ô ØŠðús   ¬2B ÁB Á2B ÂB2Â1B2c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r)   ÚpayloadÚdictr7   r   r   úPath | Noner+   r"   r   )r-   s   "r    r.   r.   b   s/   € ÷ 6Bñ 6B�tð 6B 4ð 6B°{ð 6BÐN^ñ 6Br   c                ó8	  € \        V P                  R 4      4      \        Jg   V R ,          ^8w  d   \        RR R7      # V P                  R4      p\	        V\
        4      '       g   \        RRR7      # \        V4      pV Uu. uF]  p\	        V\        4      '       g   K  \	        VP                  R4      \        4      '       g   KB  \        VR,          4      V8X  g   K[  VNK_  	  pp\        V4      ^8w  gC   \	        V^ ,          P                  R4      \        4      '       d   V^ ,          R,          '       g   \        RRR7      # T P                  R4      p^ R	I
Hp VR
8H  ;'       d    V P                  R4      V8H  p	VR9   dE   V	'       g=   VR
8H  ;'       d    V P                  R4      R8H  p
\        Yz'       d   RR7      # RR7      # VR8w  d   V	'       g   \        RRR7      # V P                  R4      p\	        V\
        4      '       dB   \        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       d   RV9  d   \        RRR7      # V P                  R4      V P                  R4      rÜ\        V4      \        Jg&   V^ 8:  g   \	        V\        4      '       d	   V'       g   \        RRR7      # V P                  R4      p\	        V\        4      '       g   \        RRR7      #  \        V4      pVP                  R 9  g§   VP                  '       d•   VP                   f‡   VP"                  fy   VP$                  '       gg   VP&                  '       gU   VP(                  '       gC   VP*                  '       d1   \,        P.                  ! VP                  4      P0                  '       g   \        RRR7      #  T P                  R4      pTR!9  d   \        RRR7      # \        T	'       d   R
MR\5        T^ ,          R,          TT^TT\7        T4      Te   \        T4      MR\	        T P                  R4      ;p\        4      '       d   T'       d   TMRR7	      T	'       d   TR7      # RR7      # u upi   \2         d    \        RRR7      u # i ; i)"r   Úincompatible©r&   Úserved_profilesÚinaccessibleÚprofile_mismatchr7   r   r#   r0   r3   Údrain_reasonÚ	idle_exitNr2   Úinvalid_runtime_stater   c              3  óB   "  € T F  p\        V\        4      x € K  	  R # 5ir:   )Ú
isinstancer   )Ú.0Úcs   & r    Ú	<genexpr>Ú_endpoint.<locals>.<genexpr>}   s   é € Ð5_ÑR^ÈQ´jÀÄC×6HÐ6HÓR^ùs   ‚FTzsession-authority-v1Úsession_authority_unavailabler   r   Úinvalid_runtime_identityr   Úinvalid_api_originr   Úinvalid_supervisorr   )	r   r   r   r   r   r   r   r   r   >   Úconflictr3   Ústarting>   ÚhttpÚhttps>   ÚnoneÚlaunchdÚsystemdÚwindowsÚexternal)ÚtypeÚgetr   r"   rf   ÚlistrA   rZ   r   Úlenr4   r1   Úallr   ÚschemeÚhostnameÚusernameÚpasswordr<   ÚqueryÚfragmentÚportÚ	ipaddressÚ
ip_addressÚis_loopbackÚ
ValueErrorr   Ú	frozenset)rY   r7   r   ÚprofilesÚwantedÚpÚmatchesr#   r1   Úrestart_waitÚidler   ÚepochÚinstanceÚoriginÚparsedr   r   s   &&&               r    Ú	_endpointr“   b   s¸  € ÜˆG�K‰KÐ*Ó+Ó,´CÓ7¸7ÐCUÕ;VÐZ[Ô;[Ü Ð<NÔOÐOØ�{‰{Ð,Ó-€HÜ�h¤×%Ò%Ü Ð<NÔOÐOô ˜TÓ"€FÙ"ó \™(�Q¤j°´D×&9ŒqÜ˜aŸe™e F›m¬S×1ô Ü6EÀaÈÅiÓ6PÐTZÑ6Z÷ ˆq™(€Gð \ä
ˆ7ƒ|�qÔ¤
¨7°1­:¯>©>¸,Ó+GÌ× MÒ MÐU\Ð]^ÕU_Ð`l×UmÔUmÜ Ð<NÔOÐOØ�K‰K˜Ó €Eõ :Ø˜JÑ&×]Ð]¨7¯;©;°~Ó+FÐJ]Ñ+]€LØÐ4Ô4¿\ð ˜
Ñ"×QÐQ w§{¡{°>Ó'BÀkÑ'QˆÜ Æ$°;ÔQÐQÈDÔQÐQØ�Ô§Ü Ð<SÔTÐTØ—;‘;˜~Ó.€LÜ�|¤T×*Ò*·#³#Ñ5_ÑR^Ó5_·#·#²#Ñ5_ÑR^Ó5_×2_Ò2_Ø%¨\Ô9Ü Ð<[Ô\Ð\Ø—k‘kÐ"3Ó4°g·k±kÀ-Ó6Pˆ8ÜˆEƒ{œ#Ó ¨!¤´:¸hÌ×3LÒ3L×T\Ü Ð<VÔWÐWØ�[‰[˜Ó&€FÜ�fœc×"Ò"Ü Ð<PÔQÐQðRÜ˜&Ó!ˆØ�M‰MÐ!2Ô2¸&¿/¿/¸/Ø—?‘?Ò.°&·/±/Ò2MØ—;—;�; &§,§, ,°&·/·/°/ÈÏÏÈÜ ×+Ò+¨F¯O©OÓ<×H×HÐHÜ# NÐ@TÔUÐUð Ið —‘˜\Ó*€JØÐNÔNÜ Ð<PÔQÐQÜ¯,™J¸GÄ_Ø˜1•:˜lÕ+¸Ø°¸fØ¬I°lÓ,CØ*6Ò*B”S˜Ô&ÈÜ'°G·K±KÀ
Ó4KÐ(K¨ÌS×QÒQ×V^‘ÐdhôF÷ +7Ð&ôBð Bð =AôBð BùòO\øôD ô RÜ Ð<PÔQÒQðRúsN   ÂQ9Â"Q9ÃQ9ÃQ9Ë4-Q> Ì"-Q> ÍQ> Í"Q> Í4Q> Î/Q> Î6Q> Ñ>RÒRc               ó$   € V ^8„  d   QhRRRRRR/# )r)   r7   r   r%   r$   r+   r   )r-   s   "r    r.   r.   ›   s"   € ÷ ñ ˜4ð Ð+Að Àdñ r   c                ó\   € Ve(   VP                   '       d   \        VP                   4      # V # )z`Home whose control socket mints tickets for *endpoint* (the multiplexer's for a served profile).)r   r   )r7   r%   s   &&r    Úcontrol_home_forr–   ›   s)   € àÒ × 5× 5Ð 5Ü�H×)Ñ)Ó*Ð*Ø€Kr   c               ó    € V ^8„  d   QhRRRR/# )r)   r7   r   r+   r[   r   )r-   s   "r    r.   r.   ¢   s   € ÷ Zñ Z Tð Z¨kñ Zr   c                óT   € ^ RI Hp ^ RIHp V! V 4      pVe   V! V4      R8X  d   V# R# )ad  The root whose reservation is pending AND whose boot policy would serve *home*, else None.
A ``gateway.standalone: true`` secondary is never served by it, so a reserved (or ready) root
must not make its client wait out the deadline instead of starting the profile's own owner.
One uncached config parse plus a lock probe: call it once per ensure iteration.)Úmissing_owner_state)Úimplied_host_rootNrp   )rQ   r™   Ú$hermes_cli.gateway_runtime_multiplexrš   )r7   r™   rš   Úroots   &   r    Ú_starting_multiplexer_rootr�   ¢   s3   € õ
 IÝFÙ˜TÓ"€DØÒ#Ñ(;¸DÓ(AÀZÔ(Oˆ4ÐYÐUYÐYr   c               ó    € V ^8„  d   QhRRRR/# )r)   rœ   r   r+   r   r   )r-   s   "r    r.   r.   ­   s   € ÷ 
,ñ 
,¨ð 
,°*ñ 
,r   c                óR   € ^ RI Hp V! V R,          4      pV'       d
   VR,          # R# )a  A live host's reason for not serving its named profiles, if it published one.

A held root lock ordinarily means that a named profile should wait for its
multiplexer.  A host which published a guard refusal is different: it is a
standalone gateway and can never add the named profile during that boot. Read
with the same liveness rules as ``hermes gateway status``'s standalone box.
)Úrecorded_standalone_reasonzgateway_state.jsonºNiô  NN)Ú!hermes_cli.gateway_multiplex_moder    )rœ   r    Úreasons   &  r    Ú_standalone_multiplexer_reasonr¤   ­   s)   € õ MÙ'¨Ð/CÕ(CÓD€Fß!ˆ6�$�<Ð+ tÐ+r   c               ó$   € V ^8„  d   QhRRRRRR/# )r)   rY   rZ   r7   r   r+   úGatewayDiscovery | Noner   )r-   s   "r    r.   r.   º   s'   € ÷ lñ l Dð l°ð lÐ9Pñ lr   c                ó.  aa€ V P                  R4      p\        V\        4      '       g   R# ^ RIHo S! VP
                  4      o\        VV3R lVP                  4        4       R4      pVf   R# \        RR\        V4      R,          ;'       g    RR7      # )	a  A secondary the multiplexer could not serve (unusable store, home owned elsewhere) is
published under ``parked_profiles`` (name -> reason). That is a terminal verdict for its
clients: waiting for a ``served_profiles`` entry that will never appear is the wrong answer.Úparked_profilesN)Únormalize_profile_namec              3  ó\   <"  € T F!  w  rS! \        V4      4      S8X  g   K  Vx € K#  	  R # 5ir:   )r   )rg   ÚnÚrrP   r©   s   &  €€r    ri   Ú)_parked_by_multiplexer.<locals>.<genexpr>Ã   s'   øé € ÐZ¡™˜Ñ3IÌ#ÈaË&Ó3QÐUYÑ3Y—1’1£ùs   ƒ,¢
,r`   Úprofile_parkedr¡   ©r&   r'   )
ry   rf   rZ   Úhermes_cli.profilesr©   rP   ÚnextÚitemsr"   r   )rY   r7   Úparkedr£   rP   r©   s   &&  @@r    Ú_parked_by_multiplexerr´   º   s|   ù€ ð �[‰[Ð*Ó+€FÜ�fœd×#Ò#ÙÝ:Ù! $§)¡)Ó,€DÜÕZ §¡¤ÓZÐ\`Óa€FØ‚~ÙÜ˜NÐ8HÔQTÐU[ÓQ\Ð]aÕQb×QjÐQjÐfjÔkÐkr   c               ó    € V ^8„  d   QhRRRR/# )r)   ÚexcÚPermissionErrorr+   r¦   r   )r-   s   "r    r.   r.   É   s   € ÷ ñ  ð Ð4Kñ r   c                óv   € ^ RI Hp \        W4      '       d"   \        RV P                  \        V 4      R7      # R# )zWThe named refusal when the client proved the boundary from the control pipe, else None.)ÚRefusedOwnerr`   r¯   N)Ú!gateway.runtime_bootstrap_windowsr¹   rf   r"   r&   r   )r¶   r¹   s   & r    Ú_refused_owner_verdictr»   É   s-   € å>Ü�#×$Ò$Ü ¸C¿O¹OÔTWÐX[ÓT\Ô]Ð]Ùr   c               ó$   € V ^8„  d   QhRRRRRR/# )r)   r7   r   ÚtimeoutÚfloatr+   r¦   r   )r-   s   "r    r.   r.   Ñ   s"   € ÷ ñ  ð °5ð Ð=Tñ r   c          	     ó¤  € ^ RI HpHp ^ RIHp V! V 4      pVf   R#  V! WQR7      p\        Y`TR7      p
T
P                   R8X  d   T
P"                  R	8X  d   \%        Y`4      # T
#   \
         d:   p\        T4      pTf    Rp?R# ^ RIHp	 T	! YP4      RJ d    Rp?R# Tu Rp?# Rp?i\        \        \        T\        \        \        3 d     R# i ; i)
a  A served secondary has no socket of its own: the default multiplexer's control socket
answers for it, and its ``identify`` lists the home under ``served_profiles``. Only the
multiplexer's live descriptor proves service; a held ``gateway.lock`` alone does not.)rI   Úquery_identify)Úmultiplexer_root_forN©r½   )Úhost_serves_named_profileF)r   r`   ra   )rQ   rI   rÀ   r›   rÁ   r·   r»   r¢   rÃ   rT   ÚConnectionRefusedErrorÚTimeoutErrorrU   r‡   Ú	TypeErrorr“   r#   r&   r´   )r7   r½   rI   rÀ   rÁ   rœ   rY   r¶   ÚnamedrÃ   r*   s   &$         r    Ú_served_by_multiplexerrÈ   Ñ   sÀ   € ÷ TÝIÙ Ó%€DØ‚|ÙðÙ  Ô7ˆô �w°4Ô8€FØ‡|�|�~Ô%¨&×*<Ñ*<Ð@RÔ*RÜ% gÓ4Ð4Ø€Møô# ô 
ô ' sÓ+ˆØŠ=ÝÝOÙ$ TÓ0°EÓ9ÝØ�ûÜÔ5´|À^Ü”Z¤ð,ô âðús5   ž	A# Á#CÁ.B"ÂB"ÂB"ÂCÂ"'CÃ
CÃCrH   c               ó    € V ^8„  d   QhRRRR/# )r)   r7   r   r+   z
int | Noner   )r-   s   "r    r.   r.   ó   s   € ÷ ñ �Tð ˜jñ r   c                ó0  € ^ RI HpHpHpHpHp R F�  pV! W,          RR7      pV! V4      pVe   V\        P                  ! 4       8X  d   K;  VP                  R4      p	V	e   W‘! V4      8w  d   K^  V! WpR7      '       d   Ko  V! Wx4      '       g   K  Vu # 	  R# )a  The PID a refusal may name: one of *home*'s gateway records whose process is provably that
gateway, else None (the caller keeps the generic ``authorization``).

Proof is the shared identity chain: alive, its recorded start time known and equal to the live
one (a recycled PID differs), its recorded home not another profile's, and its live command line
(or, when that is unreadable across the elevation boundary, its record) a gateway's. A stale
``gateway.pid`` falls through to ``gateway.lock`` instead of masking it.)Ú_get_process_start_timeÚ_live_pid_from_recordÚ_read_json_fileÚ _record_matches_live_gateway_pidÚrecorded_gateway_home_conflictsT)Úbare_pid_okNÚ
start_time)Úexpected_home)zgateway.pidrL   )	Úgateway.statusrË   rÌ   rÍ   rÎ   rÏ   r;   Úgetpidry   )
r7   rË   rÌ   rÍ   rÎ   rÏ   rP   ÚrecordÚpidÚrecordeds
   &         r    Ú
_owner_pidrØ   ó   s�   € ÷õ ó 0ˆÙ  ¥¸$Ô?ˆÙ# FÓ+ˆØŠ;˜#¤§¢£Ô,ÙØ—:‘:˜lÓ+ˆØÒ˜xÐ+BÀ3Ó+GÔGÙÙ*¨6×FÓFÙÙ/°×<Ò<ÙØŠ
ñ 0ñ r   rv   c               ó$   € V ^8„  d   QhRRRRRR/# )r)   r7   r   rv   r,   r+   r"   r   )r-   s   "r    r.   r.     s'   € ÷ Iñ I�4ð I Tð IÐ@Pñ Ir   c               óÎ   € V'       d?   \        V 4      ;pe0   ^ RIHp  V! V4      pVe   \	        RV^ ,          V^,          R7      # \	        RRR7      #   \         d    Rp L<i ; i)a  The owner's control channel refused this same-user client. On Windows (*windows*, the host
fact) name the boundary (an elevated owner, or one in another logon session) with its remedy
instead of the generic ``authorization`` that reads as a credential failure (#139845, #140252).N)Úprobe_refused_ownerr`   r¯   Úauthorizationr^   )rØ   rº   rÛ   rU   r"   )r7   rv   rÖ   rÛ   rÇ   s   &$   r    Ú_refusedrÝ     sm   € ÷ œ: dÓ+Ð+�CÒ8ÝIð	Ù'¨Ó,ˆEð ÒÜ# NÀÀaÅÐQVÐWXÕQYÔZÐZÜ˜N¸ÔHÐHøô	 ô 	ØŠEð	ús   ŸA ÁA$Á#A$r½   g       @c               ó$   € V ^8„  d   QhRRRRRR/# )r)   Úprofile_homer8   r½   r¾   r+   r"   r   )r-   s   "r    r.   r.   !  s'   € ÷ !Tñ !T¨Jð !TÀEð !TÐTdñ !Tr   c               ó&  € ^ RI HpHpHp \        P
                  ! V4      '       d   V^ 8:  d   \        R4      h\        \        \        V 4      4      4      p \        V! WQR7      V4      #   \        \        3 dt    \        YQR7      pTe   Tu # T! T4      pTR8X  dC   \        P                  R8w  d.   ^ RIHp T! TR,          4      ;p	'       d   \%        TR	T	R
7      u # \%        T4      u # \&         d    \%        RRR7      u # T d2   p
\%        RT
P(                  T
P+                  R4      R
7      u Rp
?
# Rp
?
i\,         d'   p
\/        T
4      pTe   TM
\1        T4      u Rp
?
# Rp
?
i\2        \        \4        3 d    \%        RRR7      u # i ; i)züRead live control identity, preserving uncertainty instead of spawning.

A named profile served by the default multiplexer resolves to the multiplexer's endpoint
with ``profile_id`` = the profile's own home, so clients attach to it with that identity.
)rI   r™   rÀ   ú#timeout must be finite and positiverÂ   Nr`   rH   )Úunreadable_lock_recoveryrL   Úforeign_stale_lockr¯   Úcontrol_timeoutr^   iô  Úinvalid_control_peer)rQ   rI   r™   rÀ   ÚmathÚisfiniter‡   rD   r   rA   r“   rT   rÄ   rÈ   r;   rP   Úgateway.runtime_ownershiprâ   r"   rÅ   r£   Úbounded_detailr·   r»   rÝ   rU   rÆ   )rß   r½   rI   r™   rÀ   r7   Úservedr#   râ   r'   r¶   rÇ   s   &$          r    Údiscover_gateway_endpointrë   !  sU  € ÷ iÑhä�=Š=˜×!Ò! W°¤\ÜÐ>Ó?Ð?Üœt¤O°LÓ$AÓBÓC€DðTÜ™¨Ô>ÀÓEÐEøÜÔ5Ð6ô 	'Ü'¨Ô>ˆØÒØŠMÙ# DÓ)ˆØ�NÔ"¤r§w¡w°$¤ÝJÙ1°$¸Õ2GÓHÐHˆvÖHÜ'¨Ð;OÐX^Ô_Ò_Ü Ó&Ò&Üô OÜ Ð<MÔNÒNØô hä ¸C¿J¹JÈs×OaÑOaÐbeÓOfÔgÕgûÜô >Ü& sÓ+ˆØÒ)‰u¬x¸«~Õ=ûÜ”Z¤Ð+ô Tä Ð<RÔSÒSðTúsm   ÁA* Á*#FÂA FÃFÃ FÃ-FÃ6FÄFÄFÄ&D8Ä2FÄ8FÅFÅE'Å!FÅ'FÅ?FÆFc               ó   € V ^8„  d   QhRR/# )r)   r+   r,   r   )r-   s   "r    r.   r.   E  s   € ÷ ñ ˜Tñ r   c                ó°  € ^ RI p^ RIHp V  F¥  pW2P                  ,          p VP	                  4       pV'       gB   VP                  4       VP                  4       P                  ,
          VP                  8  d    R# TP                  T4      ^ ,          R9   g   TP                  4       '       g   K¤   R# 	  R#   \         d     K¹  \         d      R# i ; i)a1  True while an update owns the install, judged the way main's launchers and the Desktop
judge ``.hermes-update-in-progress``: a live (or still being written) marker, or a dead or
malformed one while the checkout lock is held (a killed update's tree still runs). A dead
marker over a free lock is a killed update: it never blocks a launch.

Read-only: a client never clears the updater's fence; the launch-time reclaim
(``update_lock.read_live_update``) and the next update remove a dead marker. A marker that
exists but cannot be read is unjudgeable and fences.
N)Úupdate_lockTF>   ÚliveÚours)ÚtimeÚ
hermes_clirî   ÚMARKER_NAMEÚ
read_bytesÚstatÚst_mtimeÚEMPTY_MARKER_GRACE_SECONDSrT   rU   Újudge_markerÚcheckout_lock_held)Úhomesrñ   rî   Ú
fence_homer<   Úraws   &     r    Ú_update_fencedrý   E  s®   € ó Ý&ãˆ
Ø×3Ñ3Õ3ˆð		Ø—/‘/Ó#ˆCßà—9‘9“; §¡£×!5Ñ!5Õ5¸×8^Ñ8^Ô^Úð
 ×#Ñ# CÓ(¨Õ+Ð/?Ô?À;×CaÑCa×CcÔCcÚñ ñ øô !ô 	ÚÜô 	Ûð	ús   £AB8Â8CÃCÃCÃCc               ó$   € V ^8„  d   QhRRRRRR/# )r)   r7   r   r½   r¾   r+   r"   r   )r-   s   "r    r.   r.   c  s'   € ÷ Eñ E˜$ð E¨ð EÐ3Cñ Er   c                ó|   € \        WR7      pVP                  R8X  d   \        V4      '       d   V# \        RRR7      # )ab  What ensure answers while an update owns the install. The update's own drain
(``pause-for-update``) is a restart's after-turn wait whose owner may hold a turn parked on
approval/clarify, so it is handed out for clients to answer it (#139041). Discovery only:
nothing is started or replaced while fenced, and any other owner state stays ``update_paused``.rÂ   r3   Úupdate_pausedr^   )rë   r#   r5   r"   )r7   r½   Úobserveds   && r    Ú_fenced_verdictr  c  s6   € ô
 )¨Ô?€HØ‡~�~˜Ô#¬
°8×(<Ò(<ØˆÜ˜J°OÔDÐDr   zVan older Hermes gateway still owns this profile after a stop; run: hermes gateway stoprc   Úreplacedc               ó(   € V ^8„  d   QhRRRRRRRR/# )	r)   r7   r   Údeadliner¾   r  z	set[Path]r+   r"   r   )r-   s   "r    r.   r.   t  s/   € ÷ @ñ @ 4ð @°5ð @ÀIð @ÐRbñ @r   c                óv  € ^ RI Hp \        W! V4      R7      pVP                  R8w  g   VP                  R8w  d   V# W9   d   \        RR\        R7      # ^ RIHp VP                  V 4       VP                  WR7      pVe-   \        RRVP                  P                  V\        4      R7      # \        RR	R
7      # )zºDiscovery, except that a gateway an older Hermes left on this home is stopped once (like
``hermes gateway stop``) and reported as retiring; a refusal keeps ``incompatible`` + its remedy.)Ú	remainingrÂ   r]   r   r¯   )Úgateway_runtime_replace©r  r3   r  r^   )Ú"hermes_cli.gateway_runtime_servicer  rë   r#   r&   r"   Ú_REPLACE_FAILED_DETAILrò   r  ÚaddÚreplace_incompatible_ownerÚREFUSAL_DETAILry   )r7   r  r  r  r  ÚreplaceÚrefusals   &&&    r    Ú_observe_replacing_staler  t  s®   € õ =Ü(¨°yÀÓ7JÔK€HØ‡~�~˜Ô'¨8×+?Ñ+?ÐCUÔ+UØˆØÔÜ Ð<NÔWmÔnÐnÝ=Ø‡L�L�ÔØ×0Ñ0°Ð0ÓI€GØÒÜ Ð<NØ'.×'=Ñ'=×'AÑ'AÀ'ÔKaÓ'bôdð 	dä˜J°JÔ?Ð?r   Fc               ó(   € V ^8„  d   QhRRRRRRRR/# )	r)   rß   r8   r½   r¾   rc   r,   r+   r"   r   )r-   s   "r    r.   r.   †  s6   € ÷ iTñ iT¨ð iTÀð iTØ&*ðiTØ7GñiTr   c          
     ó  € ^ RI p^ RIHpHpHpHp ^ RIHpHp	 \        P                  ! V4      '       d   V^ 8:  d   \        R4      hVP                  4       V,           p
\        \        \        V 4      4      4      pRpRpT^ rþRp\!        4       pRp  \#        W¹! 4       V! 4       04      '       d   \%        W¶! V
4      4      # Ve   VP'                  4       MRp\)        WºV4      pVP*                  R8X  d   \-        R	R
R7      # VP.                  R8X  d>   VP*                  \0        9   d)   RRRrÜpVP3                  \5        RV! V
4      4      4       K½  VP.                  R9  d   V# Ve8   VP.                  R8X  d'   ^ RIHp \-        RRV! WïVVP:                  4      R7      # VP.                  R	8X  d   V'       g   RpVP.                  R8X  d   RpVP.                  R8X  d   V'       g   \=        V4      MRpVe"   \?        V4      ;p'       d   \-        RRVR7      # Ve   RpVP.                  R8X  d¢   V'       gš   ^ RI H!pH"p V! V4      ;'       g    TpV! VV
R7      pVf    VV8X  d   V! V4      ;pe   TpV! VV
R7      p\G        W¶! V
4      R7      pVP.                  R8w  d   EK  Ve   V! VV
R7       M^ RIH$pH%p TV! V4      rþV! VW¢R7      pRpVP3                  \5        VV! V
4      4      4       \5        VR,          R4      pEKs    \L         d    \-        R	R
R7      u # T d,   p\-        TP.                  TPN                  R7      u Rp?# Rp?i\P         d    \S        T4      u # \T         d    \-        RRR7      u # i ; i)a�  Ensure once; pending remains pending at deadline.

Never installs anything. The one owner it replaces is a gateway an older Hermes left running on
this install's own home (``incompatible``/``runtime_protocol``, the upgrade case): it is stopped
the way ``hermes gateway stop`` stops it, once, and the current one started like any absent
owner. Another install's or a newer Hermes's gateway stays refused, with the reason in ``detail``
(``hermes_cli.gateway_runtime_replace``).

A successful service command or Popen is not session readiness. After an
owner/start request is observed this invocation never launches another.
``idle_exit``: an unmanaged daemon this call starts ends itself once idle (client entrypoints:
chat, TUI, cron/kanban/ACP clients). A gateway that is ending that way reports ``draining``
(``idle_exit``); this call waits for it to go and starts the replacement transparently.
N)ÚRuntimeStartErrorÚ!discover_existing_gateway_servicer  Ústart_existing_gateway_service)Úget_default_hermes_rootÚget_process_hermes_homerá   Fgš™™™™™™?Trä   rp   r  r^   r3   gš™™™™™¹?Úabsent)Ústartup_failure_reportr`   Úruntime_exitedr¯   r®   )rš   Úmultiplexer_serves_homer	  rÂ   )Úspawn_unmanaged_gatewayÚstdio_log_size)r  rc   g      ø?gš™™™™™©?Úruntime_start_failed>   r  rp   )+rñ   r
  r  r  r  r  Úhermes_constantsr  r  ræ   rç   r‡   Ú	monotonicrD   r   rA   Úsetrý   r  Úpollr  r&   r"   r#   Ú	_RETIRINGÚsleepÚminÚ hermes_cli.gateway_runtime_startr  rÖ   r�   r¤   r›   rš   r  rë   r  r  rÅ   r£   r·   rÝ   rU   ) rß   r½   rc   rñ   r  r  r  r  r  r  r  r7   Ú	requestedÚchildÚ
child_homeÚchild_offsetÚretiringr  ÚdelayÚstatusr  r  Úreservedr£   rš   r  rW   ÚserviceÚhostr  r  r¶   s    &$$                             r    Úensure_gateway_runtimer2  †  s:  € ó  ÷ó ÷ Rä�=Š=˜×!Ò! W°¤\ÜÐ>Ó?Ð?Ø�~‰~Ó 'Õ)€HÜœt¤O°LÓ$AÓBÓC€DØ€IØ€EØ# Q�ð €HÜ›%€HØ€EðETØä˜tÐ%<Ó%>Ñ@WÓ@YÐZ×[Ò[Ü& t¨Y°xÓ-@ÓAÐAð &+Ò%6�U—Z‘Z”\¸DˆFÜ/°ÀÓIˆHØ×#Ñ#Ð'8Ô8Ü'¨
À
ÔKÐKØ�~‰~ Ô+°×0DÑ0DÌ	Ô0QØ-1°5¸$ U�Ø—
‘
œ3˜s¡I¨hÓ$7Ó8Ô9ÙØ�~‰~Ð%;Ô;Ø�ØÒ! h§n¡n¸Ô&@õ TÜ'¨ÐDTÙ/EÀjÐ`fÐhm×hqÑhqÓ/rôtð tà�~‰~ Ô+·HØ �	Ø�~‰~ Ô)Ø �Ø;C¿>¹>ÈXÔ;U×^gÔ1°$Ô7ÐmqˆHØÒ#Ô3QÐRZÓ3[Ð)[¨Ö)[Ü'¨ÐDTÐ]cÔdÐdð Ò#Ø �	Ø�~‰~ Ô)·)÷ lÙ0°Ó6×>Ð>¸$�Ù;¸FÈXÔV�Ø’? v°¤~ÑCTÐUYÓCZÐ;Z¸4Ò:gð "�FÙ?ÀÐQYÔZ�Gä4°TÀ9ÈXÓCVÔW�Ø—>‘> XÔ-ÚØÒ&Ù2°7ÀXÖNçhØ/5±~ÀfÓ7M Ù3°FÀXÔc�EØ �	Ø�J‰J”s˜5¡)¨HÓ"5Ó6Ô7ô ˜ � TÓ*‹EøÜô DÜ 
¸
ÔCÒCØô CÜ §	¡	°s·z±zÔBÕBûÜô Ü˜‹~ÒÜô TÜ Ð<RÔSÒSðTúsz   Â.L Ã ?L Ä A L Å!:L ÆL Æ5-L Ç#1L ÈL È4L ÉB9L ÌM?ÌM?Ì#M?Ì$ M
ÍM?Í
M?ÍM?Í%M?Í.M?Í>M?r:   )+Ú__doc__Ú
__future__r   Údataclassesr   r„   ræ   r;   Úpathlibr   Útypingr   r   Úurllib.parser   Úgateway.runtime_contractr   ÚDEFAULT_ENSURE_TIMEOUTr   r"   r5   rA   rE   rD   r“   r–   r�   r¤   r´   r»   rÈ   rP   Ú_NATIVE_WINDOWSrØ   rÝ   rë   rý   r  r  rˆ   r$  r  r2  r   r   r    Ú<module>r<     s&  ðÙ Nå "å !Û Û Û 	Ý ß )Ý !çÝ5ð Ð ñ �$Ô÷ ð  ó ð ñ" �$Ô÷ð ó ðõ	qõDõBõ÷*6BõrõZõ
,õlõõð> —'‘'˜T‘/€õð>I¨O÷ Ið!TÈC÷ !TõHõ<Eð rÐ ñ �{ JÐ/Ó0€	õ@ð$iTÐI_ð iTØ-2÷iTñ iTr   