+
    „WÝj§  ã                   óf  a € R t 0 t R t^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	H
t
  ^ RItRtR R ltRtR R	 lt]! 0 Rm4      tRs] ^ k R
 R ltR R ltR R ltR R lt]P0                  ! 4       t] ^k R R ltRs] ^k ]P8                  ! 4       tR R ltR R ltR#   ] d    Rt Lƒi ; i)a   Live-DB test-isolation guard and the per-process "last init error" record.
Every SessionDB construction resolves its path through _ensure_test_isolation
so a pytest-context process (env OR ancestry) can never open a production
state.db; env-based so subprocess children are protected too.N)ÚPath)ÚAnyÚOptionalÚHERMES_STATE_DB_GUARD_BYPASSc                ó:   € V ^8„  d   QhR\         \        ,          /# ©é   Úreturn)r   r   )Úformats   "ÚFC:\Users\johnn\AppData\Local\hermes\hermes-agent\hermes_state_guard.pyÚ__annotate__r      s   € ÷ ñ ¤8¬D¥>ñ ó    c                 ó”  €  \        \        P                  P                  R4      4      p \        P
                  R8X  da   \        P                  P                  RR4      P                  4       pV'       d   \        V4      R,          MV R,          R,          R,          pM	V R,          pVP                  4       #   \         d     R	# i ; i)
zÅThe REAL platform-default Hermes root. Avoids ``Path.home()`` /
``hermes_constants`` (tests monkeypatch Path.home to a tempdir); ``expanduser``
reads HOME/passwd, which the conftest never rewrites.Ú~Úwin32ÚLOCALAPPDATAÚ ÚhermesÚAppDataÚLocalz.hermesN)r   ÚosÚpathÚ
expanduserÚsysÚplatformÚenvironÚgetÚstripÚresolveÚ	Exception)ÚhomeÚbaseÚroots      r   Ú_real_platform_state_rootr#      s“   € ð	Ü”B—G‘G×&Ñ& sÓ+Ó,ˆÜ�<‰<˜7Ô"Ü—:‘:—>‘> .°"Ó5×;Ñ;Ó=ˆDß,0”4˜“: Ö(°d¸YÕ6FÈÕ6PÐS[Õ6[‰Dà˜)Õ#ˆDØ�|‰|‹~ÐøÜô Úðús   ‚A2B8 Á5AB8 Â8CÃCÚHERMES_TEST_ISOLATIONc                ó$   € V ^8„  d   QhR\         /# r   ©Úbool)r
   s   "r   r   r   6   s   € ÷ ñ œtñ r   c                 óö   € \        \        P                  P                  R4      ;'       gK    \        P                  P                  R4      ;'       g$    \        P                  P                  \        4      4      # )zBTrue when this process (or a parent test process) is a pytest run.ÚPYTEST_CURRENT_TESTÚPYTEST_VERSION)r'   r   r   r   Ú_TEST_ISOLATION_MARKER_ENV© r   r   Ú_running_under_pytestr-   6   sV   € äÜ
�
‰
�‰Ð,Ó-÷ 	6ð 	6Ü�:‰:�>‰>Ð*Ó+÷	6ð 	6ä�:‰:�>‰>Ô4Ó5óð r   c                ó0   € V ^8„  d   QhR\         R\        /# )r   Úprocr	   )r   r'   )r
   s   "r   r   r   G   s   € ÷ ñ ¤Sð ¬Tñ r   c                óp  €  V P                  4       ;'       g    . pT Fp  p \        T4      P                  R4      P                  R4      P	                  RR4      P                  R^4      R,          P                  4       pT\        9   g   Ko   R# 	  R#   \         d     R# i ; i  \         d     K–  i ; i)z�True when *proc*'s command line is a pytest invocation. Unreadable cmdline
=> not pytest: guessing the other way would refuse production opens.FÚ"Ú'Ú\Ú/Téÿÿÿÿ)Úcmdliner   Ústrr   ÚreplaceÚrsplitÚlowerÚ_PYTEST_LAUNCHER_NAMES)r/   r6   ÚargÚnames   &   r   Ú_process_looks_like_pytestr>   G   s¬   € ðØ—,‘,“.×&Ð& Bˆó ˆð	ä�s“8—>‘> #Ó&×,Ñ,¨SÓ1×9Ñ9¸$ÀÓD×KÑKÈCÐQRÓSÐTVÕW×]Ñ]Ó_ˆDð Ô)Ö)Úñ ñ øô ô Úðûô ô 	Úð	ús(   ‚B ™B ¢AB&ÂB#Â"B#Â&B5Â4B5c                ó$   € V ^8„  d   QhR\         /# r   r&   )r
   s   "r   r   r   Y   s   € ÷ ñ œdñ r   c                 ó\  € \         e   \         # Rp \        e|    \        ;QJ d=    R \        P                  ! 4       P	                  4        4       F  '       g   K   RM2	  RM.! R \        P                  ! 4       P	                  4        4       4      p V s V # V s V #   \
         d	    Rp  T s T # i ; i)a,  True when an ancestor process is a pytest run: a child spawned with a
rebuilt env loses PYTEST_* and the HERMES_HOME redirect together, ancestry
survives that. Fails open without psutil / on walk errors.

``_running_under_pytest`` reads ``PYTEST_*`` env vars, which a child spawned with a rebuilt environment
loses at the same moment it loses the ``HERMES_HOME`` redirect: that child aims at the production DB
*and* disarms the guard in one step (#82770). Ancestry is the one test-context signal that survives an
env rebuild, so it backs the env check up.
Fc              3   ó8   "  € T F  p\        V4      x € K  	  R # 5i)N)r>   )Ú.0Úps   & r   Ú	<genexpr>Ú'_has_pytest_ancestor.<locals>.<genexpr>i   s   é € ÐZÑ?Y¸!Ô2°1×5Ð5Ó?Yùs   ‚T)Ú_PYTEST_ANCESTORÚpsutilÚanyÚProcessÚparentsr   )Úfounds    r   Ú_has_pytest_ancestorrL   Y   s›   € ô Ò#ÜÐØ€EÜÒð	ß“CÑZ¼v¿~º~Ó?O×?WÑ?WÔ?YÓZ—C—C’CÑZ¼v¿~º~Ó?O×?WÑ?WÔ?YÓZÓZˆEð ÐØ€Lð ÐØ€Løô ô 	Ø‰EØÐØ€Lð	ús   š
B ¥2B Á6B ÂB+Â*B+c                ó$   € V ^8„  d   QhR\         /# r   r&   )r
   s   "r   r   r   p   s   € ÷ =ñ =œ$ñ =r   c                 ó:   € \        4       ;'       g    \        4       # )zBTest run by environment or ancestry (memoised; env checked first).)r-   rL   r,   r   r   Ú_in_test_contextrO   p   s   € ä Ó"×<Ð<Ô&:Ó&<Ð<r   c                ó<   € V ^8„  d   QhR\         R\         R\        /# )r   Úresolvedr"   r	   )r   r'   )r
   s   "r   r   r   u   s!   € ÷ 	6ñ 	6¤dð 	6´$ð 	6¼4ñ 	6r   c                óÈ   € V P                   V8X  d   R#  V P                  V4      P                  p\	        T4      ^8H  ;'       d    T^ ,          R8H  #   \         d     R# i ; i)z�*resolved* is ``<root>/state.db`` or ``<root>/profiles/<name>/state.db``;
deeper scratch paths (repo worktrees) are deliberately NOT matched.TFÚprofiles)ÚparentÚrelative_toÚpartsÚ
ValueErrorÚlen)rQ   r"   rV   s   && r   Ú_is_production_state_dbrY   u   sc   € ð ‡�˜$ÔÙðØ×$Ñ$ TÓ*×0Ñ0ˆô ˆu‹:˜‰?×5Ð5˜u Q�x¨:Ñ5Ð5øô ô Úðús   •A ÁA!Á A!c                ó(   € V ^8„  d   QhR\         RR/# )r   Údbr	   N)r   )r
   s   "r   r   r   �   s   € ÷ ñ ¤ð ¨ñ r   c                ó¬   € \         P                  P                  \        4      '       d    \        P                  V 4       R# R#   \         d     R# i ; i)zGTrack *db* for suite-level teardown closing (test-isolation runs only).N)r   r   r   r+   Ú_test_instance_registryÚaddr   )r[   s   &r   Ú_register_test_instancer_   �   sB   € ä	‡z�z‡~�~Ô0×1Ò1ð	Ü#×'Ñ'¨Ö+ñ 2øô ô 	Úð	ús   «A ÁAÁAc                ó>   € V ^8„  d   QhR\         \        ,          RR/# )r   Úmsgr	   N©r   r7   )r
   s   "r   r   r   Ÿ   s   € ÷ ñ œh¤s�mð °ñ r   c                ó`   € \         ;_uu_ 4        V sRRR4       R#   + '       g   i     R# ; i)z°Record (or clear with None) the most recent init failure. __init__ never
clears on success: a concurrent open would erase the cause another thread's
/resume is about to format.N)Ú_last_init_error_lockÚ_last_init_error)ra   s   &r   Ú_set_last_init_errorrf   Ÿ   s   € ÷
 
Ö	ØÐ÷ 
×	×	Ò	ús   �œ-	c                ó:   € V ^8„  d   QhR\         \        ,          /# r   rb   )r
   s   "r   r   r   ¨   s   € ÷ ñ œX¤c�]ñ r   c                 ó   € \         # )zAMost recent state.db init failure (None if none/never attempted).)re   r,   r   r   Úget_last_init_errorri   ¨   s   € äÐr   c                óæ   € V ^8„  d   Qh/ ^ \         9   d   \        \        ,          ;R&   ^\         9   d   \        P                  \
        ,          ;R&   ^\         9   d   \        \        ,          ;R&   # )r   rF   r]   re   )Ú__conditional_annotations__r   r'   ÚweakrefÚWeakSetr   r7   )r
   s   "r   r   r      s_   € ÷ Añ A÷F (Ò '”(œ4•.Ñ 'ñGA÷X BÒ AœŸ™¬Õ-Ñ AñYA÷t 'Ò &”(œ3•-Ñ &òuAr   >   Úpytestúpy.testú
pytest.exeúpy.test.exe)!rk   Ú__doc__r   r   Ú	threadingrl   Úpathlibr   Útypingr   r   rG   ÚImportErrorÚ_STATE_DB_GUARD_BYPASS_ENVr#   r+   r-   Ú	frozensetr;   rF   r>   rL   rO   rY   rm   r]   r_   re   ÚLockrd   rf   ri   r   )rk   s   @r   Ú<module>rz      s¿   øðöAó
 
Û 
Û Û Ý ß  ðÛð <Ð õð2 5Ð õñ #Ò#UÓVÐ ð $(Ð Ó 'õõ$õ.=õ
	6ð0 18·²Ó0AÐ Ó Aõð #'Ð Ó &Ø!ŸšÓ(Ð õ÷øðs ô Ø‚Fðús   ¨B$ Â$	B0Â/B0