+
    „WÝj  ã                  ó   a € 0 t $ R t^ RIHt ^ RIt^ RIt^ RIt^ RIHtH	t	 ]P                  ! R4      t ! R R]4      t]! RR4      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 R ltR R ltR R ltR# )uš  PID-namespace identity for state.db lock/lease holders.

A ``pid=<n>`` holder is relative to its writer's PID namespace; a reader in a
sibling namespace (two containers on one volume, systemd ``PrivatePIDs=``) sees
a live holder as absent and would reclaim its unexpired row. Holders are
stamped with ``pidns=<inode of /proc/self/ns/pid>`` and a foreign stamp is
never probed. Unstamped (pre-upgrade) records differ by policy:

* :func:`holder_pid_checkable` â€” STRICT, for TTL rows (compression locks,
  turn leases): unstamped defers to its expiry (<= TTL; a false defer
  self-heals, a false reclaim ends a live turn).
* :func:`persistent_record_pidns_checkable` â€” LEGACY, for no-expiry flock
  records: unstamped keeps probing so orphaned-lock cleanup still works.

Platforms without PID namespaces (macOS, Windows) keep the plain pid probe; a
failed Linux lookup is not cached and makes every holder unverifiable.
)ÚannotationsN)Ú
NamedTupleÚOptionalz(?:^|:)pidns=(\d+)(?::|$)c                  ó0   € ] tR t^t$ RtR]R&   R]R&   RtR# )ÚLocalPidNamespaceuO  What this process knows about its own PID namespace.

Three states, and the ``checkable`` predicates treat each differently:
``supported`` False â€” the platform has no namespace identity at all;
``supported`` True with an ``id`` â€” resolved; ``supported`` True with an
``id`` of None â€” resolution failed, see the module docstring.
úOptional[str]ÚidÚboolÚ	supported© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__Ú__static_attributes__r   ó    ÚFC:\Users\johnn\AppData\Local\hermes\hermes-agent\hermes_state_pidns.pyr   r      s   ‡ ñð 	ÓØ‡Or   r   FzOptional[LocalPidNamespace]Ú_LOCAL_PID_NSc               ó   € V ^8„  d   QhRR/# ©é   Úreturnr   r   )Úformats   "r   Ú__annotate__r   4   s   € ÷ Fñ FÐ&7ñ Fr   c                 ó"  € \         P                  R 8w  d   \        #  \        P                  ! R4      p \        P                  ! RT 4      p\        T'       d   TP                  ^4      R4      # RR4      #   \
         d    \        RR4      u # i ; i)Úlinuxz/proc/self/ns/pidNTz	\[(\d+)\])
ÚsysÚplatformÚ_UNSUPPORTEDÚosÚreadlinkÚOSErrorr   ÚreÚsearchÚgroup)ÚlinkÚmatchs     r   Ú_resolve_local_pid_namespacer)   4   sy   € Ü
‡|�|�wÔÜÐð-Ü�{Š{Ð.Ó/ˆô �IŠI�l DÓ)€EÜ¯u˜UŸ[™[¨›^ÀÓEÐE¸$ÀÓEÐEøô ô -Ü   tÓ,Ò,ð-ús   �A4 Á4BÂBc               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r   ?   s   € ÷ ñ Ð/ñ r   c                 óz   € \         f/   \        4       p V P                  f   V P                  '       g   V s V # \         # )zFThis process' PID-namespace identity (see :class:`LocalPidNamespace`).)r   r)   r   r
   )Úlocals    r   Ú_local_pid_namespacer-   ?   s4   € ô ÒÜ,Ó.ˆØ�8‰8Ò u§§ Ø!ˆMØˆÜÐr   c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r   r   J   s   € ÷ %ñ %˜-ñ %r   c                 ó*   € \        4       P                  # )z¹What a holder records: the ``/proc/self/ns/pid`` inode on Linux, ``None``
where there is no namespace identity or the lookup failed.  A holder never
asserts a namespace it cannot prove.)r-   r   r   r   r   Úpid_namespace_idr0   J   s   € ô  Ó!×$Ñ$Ð$r   c               ó   € V ^8„  d   QhRR/# )r   r   Ústrr   )r   s   "r   r   r   Q   s   € ÷ (ñ ( ñ (r   c                 ó4   € \        4       p V '       d   RV  2# R# )u–   The ``:pidns=<id>`` fragment to append to a new holder string, or ``""``.

Callers build ``f"pid={os.getpid()}{holder_namespace_token()}:turn=â€¦"``.
z:pidns=Ú )r0   )Únss    r   Úholder_namespace_tokenr6   Q   s   € ô
 
Ó	€BßˆW�R�Dˆ>Ð' RÐ'r   c               ó    € V ^8„  d   QhRRRR/# )r   Úholderr2   r   r   r   )r   s   "r   r   r   Z   s   € ÷ -ñ - ð -¨ñ -r   c                óv   € \         P                  T ;'       g    R4      pV'       d   VP                  ^4      # R# )zHThe ``pidns=`` stamp from a holder string, or None when it carries none.r4   N)Ú_PIDNS_TOKEN_REr%   r&   )r8   r(   s   & r   Ú_recorded_namespacer;   Z   s-   € ä×"Ñ" 6§< <¨RÓ0€Eß"ˆ5�;‰;�q‹>Ð,¨Ð,r   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úrecordedr   Úunstamped_checkabler	   r   r   )r   s   "r   r   r   `   s!   € ÷ 
 ñ 
 �}ð 
 ¸dð 
 Àtñ 
 r   c               ó†   € \        4       pVP                  '       g   R# V f   V# VP                  f   R# WP                  8H  # )z�The shared matrix; *unstamped_checkable* is the policy for a record that
carries no namespace (see the module docstring for why there are two).TF)r-   r
   r   )r=   r>   r,   s   &$ r   Ú_qualifyr@   `   s>   € ô !Ó"€EØ�?�?ˆ?ÙØÒØ"Ð"Ø‡x�xÒÙØ—x‘xÑÐr   c               ó    € V ^8„  d   QhRRRR/# )r   r8   r2   r   r	   r   )r   s   "r   r   r   m   s   € ÷ Lñ L ð L¨ñ Lr   c                ó.   € \        \        V 4      RR7      # )uL  STRICT: may a structured holder string's ``pid=`` be probed here?

The policy for TTL-bounded rows (compression locks, session turn leases):
a foreign-namespace or unstamped holder is never probed â€” it defers to the
row's own expiry instead (at most the remaining TTL; a false defer
self-heals, a false reclaim ends a live turn).
F©r>   )r@   r;   )r8   s   &r   Úholder_pid_checkablerD   m   s   € ô Ô'¨Ó/ÀUÔKÐKr   c               ó    € V ^8„  d   QhRRRR/# )r   r=   r   r   r	   r   )r   s   "r   r   r   x   s   € ÷ 8ñ 8°ð 8À$ñ 8r   c                ó   € \        V RR7      # )uM  LEGACY ROLLOUT: may a persistent record (no expiry) be probed here?

The policy for the flock holder records: a foreign-namespace record is
never probed, while an unstamped one keeps main's behavior â€” those records
never expire, so refusing to probe them would permanently disable
orphaned-lock cleanup (see the module docstring).
TrC   )r@   )r=   s   &r   Ú!persistent_record_pidns_checkablerG   x   s   € ô �H°$Ô7Ð7r   )Ú__conditional_annotations__r   Ú
__future__r   r!   r$   r   Útypingr   r   Úcompiler:   r   r    r   r   r)   r-   r0   r6   r;   r@   rD   rG   )rH   s   @r   Ú<module>rL      s~   øðôõ$ #ã 	Û 	Û 
ß 'ð —*’*Ð9Ó:€ô
˜
ô 
ñ !  uÓ-€ð .2€Ð*Ó 1õFõõ%õ(õ-õ
 õL÷8r   