+
    jHàj�  ã                   ó`   € R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHtHtH	t	H
t
Ht ^tR tR tR tR# )zêPrivate owner-side reservation for a concrete already-started admission.

The producer retains the Popen handle and holds the child's bootstrap pipe until
this returns. Public worker.register remains idle-only for unreserved callers.
N)Úadmission_fingerprint)ÚRuntimeStoreErrorÚ
_admissionÚ_epochÚ_secret_digestÚ_sessionc                ó�  € ^ RI p\        V \        P                  4      '       d   V P	                  4       e   \        R4      h\        V\        4      '       dÏ   VP                  R4      R8w  g¹   \        VP                  R4      4      \        Jg—   \        VP                  R4      4      \        \        39  gn   \        VP                  R4      \        4      '       dI   \        ;QJ d#    R VR,           4       F  '       g   K   R	M	  R
M! R VR,           4       4      '       d   \        R4      hVR,          pV^ 8:  g   V\        P                  ! 4       8X  d   \        R4      h VP                  V P                   4      pVP#                  4       \        P                  ! 4       8w  g    VP%                  4       VP&                  8X  d   \        R4      hTP                  V4      p^ RIHp V! V4      pWqR,          8w  g6   VP-                  4       '       d    VP%                  4       VP&                  8X  d   \        R4      hVP/                  4       R\0          Uu. uF  qˆP                   NK  	  p	pY0P                   8w  d   T P                   T	9  d   \        R4      hY73# u upi   TP2                   d   p
\        R4      T
hRp
?
ii ; i)aE  Return the verified ``(pid, birth)`` of the interpreter behind ``process``.

``Popen.pid`` may be a launcher trampoline, so the worker reports its own pid and
birth in a ``hello`` frame; the OWNER proves that pid is alive, carries that birth,
and descends from (or is) the reserved handle. The worker never decides equality.
NÚworker_not_liveÚtypeÚhelloÚpidÚbirthÚ	ancestorsc              3   óD   "  € T F  p\        V4      \        Jx € K  	  R # 5i)N)r
   Úint)Ú.0Úps   & ÚG/home/ubuntu/.hermes/hermes-agent/gateway/session_worker_reservation.pyÚ	<genexpr>Ú)verify_worker_identity.<locals>.<genexpr>   s   é € ÐBÑ/A¨!”4˜“7¤#Õ%Ó/Aùs   ‚ TFÚinvalid_worker_frameÚpermission_denied)Úprocess_birth)ÚpsutilÚ
isinstanceÚ
subprocessÚPopenÚpollr   ÚdictÚgetr
   r   ÚfloatÚlistÚanyÚosÚgetpidÚProcessr   ÚppidÚstatusÚSTATUS_ZOMBIEÚhermes_cli.process_identityr   Ú
is_runningÚparentsÚMAX_LAUNCHER_HOPSÚError)Úprocessr   r   r   ÚhandleÚworkerr   r   r   ÚchainÚexcs   &&         r   Úverify_worker_identityr3      s  € ó Ü�gœz×/Ñ/×0Ò0°G·L±L³NÒ4NÜÐ 1Ó2Ð2Ü�uœd×#Ò# u§y¡y°Ó'8¸GÔ'CÄtÈEÏIÉIÐV[ÓL\ÓG]ÔehÓGhÜ�E—I‘I˜gÓ&Ó'´´U¨|Ô;Ä:ÈeÏiÉiÐXcÓNdÔfj×CkÒCkß‹sÑB¨u°[Ö/AÓB�s�sŠsÑB¨u°[Ö/AÓB×BÒBÜÐ 6Ó7Ð7Ø
��,€CØ
ˆa„x�3œ"Ÿ)š)›+Ô%ÜÐ 3Ó4Ð4ð<Ø—‘ §¡Ó,ˆØ�;‰;‹=œBŸIšI›KÔ'¨6¯=©=«?¸f×>RÑ>RÔ+RÜ#Ð$7Ó8Ð8Ø—‘ Ó$ˆÝ=Ù˜fÓ%ˆØ˜'•NÔ"¨&×*;Ñ*;×*=Ò*=ÀÇÁÃÐTZ×ThÑThÔAhÜ#Ð$7Ó8Ð8à &§¡Ó 0Ð1CÔ2CÑ DÓEÑ D˜1—”Ñ DˆÐEð �k‰kÔ˜gŸk™k°Ô6ÜÐ 3Ó4Ð4Øˆ:Ðùò FøØ�<‰<ô <ÜÐ 1Ó2¸Ð;ûð<ús2   Å'B.J# ÈAJ# ÉJÉ-J# ÊJ# Ê#KÊ4K Ë Kc               óÂ   a aaaaa€ S P                  4        \        W$4      w  oo\        P                  ! ^ 4      oVV VVVV3R lpS P                  P                  V4      # )a2  Return a private bootstrap scope; never accept caller-selected kind/target.

Only the owner process may reserve its live direct exec child. The admission
supplies physical session and generation; its durable principal must match
the producer. Do not publish the returned secret on any client event stream.
c           
      ón  <€ \        V S
P                  4       \        V S	4      pVR ,          R8w  g   VR,          S
P                  8w  d   \        R4      hVR,          S8w  d   \        R4      hVR,          VR,          r2\	        W4      R,          V8w  d   \        R	4      h^ R
IHp V! W4      pRS	,           pV P                  RV34      P                  4       '       d   \        R4      hV P                  RV34      P                  4       '       d   \        R	4      hV P                  RW534       WR8w  d   V P                  RVS	34       \        S
P                  WVVSSSR7      p\        WWRS/,          R7      pV P                  RWeS
P                  V\        V4      34       VRS
P                  /,          # )r'   ÚstartedÚowner_epochÚproducer_not_startedÚprincipal_idr   Útarget_session_idÚ
generationÚruntime_generationÚstale_generation)Úlocal_physical_targetzadmission-worker:z4SELECT 1 FROM worker_executions WHERE execution_id=?Úadmission_conflictzISELECT 1 FROM worker_executions WHERE session_id=? AND status!='terminal'z3UPDATE sessions SET runtime_generation=? WHERE id=?zbUPDATE session_admissions SET lineage_json=json_insert(lineage_json,'$[#]',?) WHERE admission_id=?)Ú
profile_idÚ
session_idÚexecution_idr;   r   r   ÚsecretÚ	principal)Úcanonical_targetÚpayloadz’INSERT INTO worker_executions(execution_id,session_id,kind,owner_epoch,generation,status,adoption_digest) VALUES(?,?,'compute',?,?,'registered',?)Úepoch)r   rG   r   r   r   Úhermes_state_local_lineager>   ÚexecuteÚfetchoner   r@   r   r   )ÚconnÚ	admissionÚownerr;   r>   ÚsidrB   ÚscopeÚclaimÚadmission_idÚ	authorityr   r   r9   rC   s   &        €€€€€€r   ÚwriteÚ'reserve_admission_worker.<locals>.write@   s¢  ø€ Üˆt�Y—_‘_Ô%Ü˜t \Ó2ˆ	Ø�XÕ )Ô+¨y¸Õ/GÈ9Ï?É?Ô/ZÜ#Ð$:Ó;Ð;Ø�^Õ$¨Ô4Ü#Ð$7Ó8Ð8Ø%Ð&9Õ:¸IÀlÕ<SˆzÜ�DÓ Ð!5Õ6¸*ÔDÜ#Ð$6Ó7Ð7ÝDÙ# DÓ0ˆØ*¨\Õ9ˆØ�<‰<ÐNÐQ]ÐP_Ó`×iÑi×kÒkÜ#Ð$8Ó9Ð9Ø�<‰<ÐcÐfiÐekÓl×uÑu×wÒwÜ#Ð$6Ó7Ð7ð 	�‰ÐJÈZÐL]Ô^ØŒ<Ø�L‰Lð 0Ø25°|Ð1DôFä 	× 4Ñ 4ÀØ *°¸5ÈôQˆä%°sÈ[ÐZfÐLgÕDgÔhˆØ�‰ð @à"¨¯©¸*ÄnÐUZÓF[Ð\ô	^ð ˜ §¡Ð1Õ1Ð1ó    )Ú_require_admission_openr3   ÚsecretsÚtoken_urlsafeÚdbÚ_execute_write)	rR   rQ   r.   r9   r   rS   r   r   rC   s	   fd$d$ @@@r   Úreserve_admission_workerr[   5   sP   ý€ ð ×%Ñ%Ô'Ü'¨Ó7�J€CˆÜ×"Ò" 2Ó&€F÷2ò 2ð> �<‰<×&Ñ& uÓ-Ð-rU   c                óN   aa€ VV3R lpV P                   P                  V4       R# )zÝRevoke a private assignment and pause its FIFO; no inference replay.

This also fences a result already in the pipe at loss/shutdown. Retention
requires a still-started admission even when the generation has not changed.
c                 ód  <€ \        V SR ,          4       \        V SR,          4      pVR,          R8w  g+   VR,          SR ,          8w  g   VR,          SR,          8w  d   \        R4      hV P                  RSR,          34      P	                  4       pVe+   VR,          SR,          8w  g   VR,          SR ,          8w  d   \        R4      hT P                  R
SR,          34       ^ RIHp V! V SR,          4       V P                  RSR,          34       V P                  RVR,          34       R	# )rG   rQ   r'   r6   r7   r;   r=   z4SELECT * FROM worker_executions WHERE execution_id=?rB   NzCUPDATE worker_executions SET status='terminal' WHERE execution_id=?)Úcompact_terminal_receiptszCUPDATE session_admissions SET status='unknown' WHERE admission_id=?zBUPDATE sessions SET runtime_revision=runtime_revision+1 WHERE id=?r:   )r   r   r   rI   rJ   Úhermes_state_runtime_workersr^   )rK   Úcurrentr0   r^   ÚrowrO   s   &   €€r   rS   Ú$lose_admission_worker.<locals>.writeh   s  ø€ Üˆt�U˜7•^Ô$Ü˜T 3 ~Õ#6Ó7ˆØ�HÕ Ô*¨g°mÕ.DÈÈgÍÔ.VØ˜<Õ(¨E°,Õ,?Ô?Ü#Ð$6Ó7Ð7Ø—‘ÐTØ$ ^Õ4Ð6ó8ß8@¹»
ð 	àŠ>˜V LÕ1°U¸<Õ5HÔHÈFÐS`ÕLaÐejÐkrÕesÔLsÜ#Ð$6Ó7Ð7Ø�‰ÐZÐ]bÐcqÕ]rÐ\tÔuÝJÙ! $¨¨nÕ(=Ô>Ø�‰ÐZÐ]`ÐaoÕ]pÐ\rÔsØ�‰ÐYÐ\cÐdwÕ\xÐ[zÖ{rU   N)rY   rZ   )rR   ra   rO   rS   s   &ff r   Úlose_admission_workerrc   b   s   ù€ ö|ð ‡L�L×Ñ Ö&rU   )Ú__doc__r#   rW   r   Úgateway.session_admissionr   Úhermes_state_runtimer   r   r   r   r   r,   r3   r[   rc   © rU   r   Ú<module>rh      s7   ðñó
 
Û Û å ;ß `Õ `ð Ð ò òF*.ôZ'rU   