+
    jHàj   ã                  óÈ   a € 0 t $ R t^ RIHt ^ RIHt ]! ]4      P                  4       P                  P                  t	Rs
R]R&   R R ltR R	 ltR
 R ltR R ltR R ltR# )u*  Detect when the gateway is running stale code after a hot ``git pull``.

The gateway's ``sys.modules`` is frozen at boot.  If the checkout is updated
underneath it, a first-time lazy import can resolve a freshly-pulled module
against a stale cached dependency -> ImportError.  We snapshot the revision at
startup so risky callers (e.g. ``/model`` switching) can refuse with a clear
"restart the gateway" message.  If the revision can't be read (non-git install,
IO error) the boot snapshot stays ``None`` and detection no-ops â€” never a false positive.
)Úannotations)ÚPathNú
str | NoneÚ_boot_fingerprintc               ó   € V ^8„  d   QhRR/# ©é   Úreturnr   © )Úformats   "Ú6/home/ubuntu/.hermes/hermes-agent/gateway/code_skew.pyÚ__annotate__r      s   € ÷ ñ �jñ ó    c                 óL   €  ^ RI Hp  V ! \        4      #   \         d     R# i ; i)z�Current checkout fingerprint via the CLI's worktree-aware git-rev reader
(``hermes_cli.main`` is always already imported in a gateway process).©Ú_read_git_revision_fingerprintN)Úhermes_cli.mainr   Ú_PROJECT_ROOTÚ	Exceptionr   s    r   Ú_fingerprintr      s'   € ðÝBá-¬mÓ<Ð<øÜô Úðús   ‚ ”#¢#c               ó   € V ^8„  d   QhRR/# )r   r	   ÚNoner
   )r   s   "r   r   r      s   € ÷ +ñ + ñ +r   c                 ó.   € \         f   \        4       s R# R# )z?Snapshot the checkout revision at gateway startup (idempotent).N)r   r   r
   r   r   Úrecord_boot_fingerprintr      s   € ô Ò Ü(›NÒñ !r   c               ó    € V ^8„  d   QhRRRR/# )r   ÚfingerprintÚstrr	   r
   )r   s   "r   r   r   %   s   € ÷ _ñ _˜ð _ ñ _r   c                óœ   € V P                  R^4      R,          pV'       d!   VR8w  d   \        V4      ^
8”  d
   VR,          # T;'       g    T # )z<Render a ``git:<ref>:<sha>`` fingerprint as a compact label.Ú:Ú
unresolved:Né
   Néÿÿÿÿ)ÚrsplitÚlen©r   Úshas   & r   Ú_shortr&   %   sD   € à
×
Ñ
˜S !Ó
$ RÕ
(€Cß˜s lÔ2´s¸3³xÀ"´}ˆ3ˆs�8Ð^È3×K]ÐK]ÐR]Ð^r   c               ó   € V ^8„  d   QhRR/# r   r
   )r   s   "r   r   r   +   s   € ÷ 8ñ 8˜*ñ 8r   c                 óz   € \        4       p V f   R# V P                  R^4      R,          pV'       d
   VR8w  d   V# R# )zEFull SHA for the checkout currently on disk, or None when unresolved.Nr   r   r!   )r   r"   r$   s     r   Úcurrent_code_shar)   +   s=   € ä“.€KØÒÙØ
×
Ñ
˜S !Ó
$ RÕ
(€Cß˜# Ô-ˆ3Ð7°4Ð7r   c               ó   € V ^8„  d   QhRR/# )r   r	   ztuple[str, str] | Noner
   )r   s   "r   r   r   4   s   € ÷ 6ñ 6Ð0ñ 6r   c                 ó€   € \         e   \        4       MRp V e   V \         8X  d   R# \        \         4      \        V 4      3# )zX``(boot_rev, disk_rev)`` short labels if the checkout drifted since boot, else ``None``.N)r   r   r&   )Úcurrents    r   Údetect_code_skewr-   4   s5   € ä 1Ò =ŒlŒnÀ4€GØ‚˜'Ô%6Ô6ÙÜÔ#Ó$¤f¨W£oÐ5Ð5r   )Ú__conditional_annotations__Ú__doc__Ú
__future__r   Úpathlibr   Ú__file__ÚresolveÚparentr   r   Ú__annotations__r   r   r&   r)   r-   )r.   s   @r   Ú<module>r6      sV   øðôõ #å á�X“×&Ñ&Ó(×/Ñ/×6Ñ6€Ø $Ð �:Ó $õõ+õ_õ8÷6r   