+
    jHàjV  ã                   óN   € R t ^ RIt^ RIHtHtHt ^ RIHt RtR t	R t
R tR tR# )	aú  ACP v0.9 has no per-session destroy: the last viewer leaving an idle ACP session ends it (#118216).

The in-process adapter stamped ``ended_at`` at its stdio shutdown; under the gateway the ACP process
is only a viewer, so the owner stamps it when the last subscription goes or the gateway stops. Without
a writer, source='acp' rows stay open forever and the ended-session guard keeps prune/archive away.
A later ``session/load`` + prompt reopens the row (``session_local_recovery.reopen_local_session``).
N)ÚPOLICY_PREFIXÚend_idle_local_sessionÚlocal_receipt)ÚRuntimeStoreErrorÚacp_disconnectc           
     ó  € V P                   P                  V4      pVe   VP                  '       d   R#  \        V P                  V4      pTP                  R/ 4      P                  R4      R8w  d   R#  \        \        T P                  T P                  TTR,          R,          \        R7      4      #   \
         d     R# i ; i  \
        \        \        3 d1    \        P                  ! \        4      P                  RTR	R
7        R# i ; i)zXEnd *session_id* iff it is an ACP-created local session with no viewer and an idle FIFO.FÚpolicyÚsourceÚacpÚentryÚ
session_id©Úepochr   Ú	target_idÚreasonzACP session %s not endedT©Úexc_info)ÚsessionsÚgetÚsubscribersr   Údbr   Úboolr   r   ÚACP_END_REASONÚKeyErrorÚ	TypeErrorÚloggingÚ	getLoggerÚ__name__Úwarning)Ú	authorityr   ÚliveÚreceipts   &&  ÚB/home/ubuntu/.hermes/hermes-agent/gateway/session_acp_lifecycle.pyÚend_idle_acp_sessionr#      sð   € à×Ñ×!Ñ! *Ó-€DØÒ˜D×,×,Ð,ÙðÜ 	§¡¨jÓ9ˆð ‡{�{�8˜RÓ ×$Ñ$ XÓ.°%Ô7ÙðÜÔ*¨9¯<©<¸y¿¹Ð[eØ5<¸WÕ5EÀlÕ5SÔ\jôló mð 	møô ô Úðûô œx¬Ð3ô Ü×Òœ(Ó#×+Ñ+Ð,FÈ
Ð]aÐ+ÔbÚðús$   µB3 Á4>C Â3CÃCÃADÄ
Dc           
     ó&  € V P                   P                  V4      pVe   VP                  '       d   R#  \        V P                  V4      pTP                  R/ 4      P                  R4      R8X  d   \        Y4      #  \        \        T P                  T P                  TTR,          R,          TR7      4      #   \
         d     R# i ; i  \
        \        \        3 d1    \        P                  ! \        4      P                  RTR	R
7        R# i ; i)a  ``session.detach {end_reason}`` from the last viewer: end *session_id*'s idle local row with the
viewer's own reason (main's classic CLI ``end_session(sid, 'cli_close')`` and its switch reasons).
ACP rows keep their own reason; a busy FIFO keeps the row open, as for ACP.Fr   r	   r
   r   r   r   zlocal session %s not endedTr   )r   r   r   r   r   r   r#   r   r   r   r   r   r   r   r   r   )r   r   r   r    r!   s   &&&  r"   Úend_idle_viewer_sessionr%   #   sú   € ð ×Ñ×!Ñ! *Ó-€DØÒ˜D×,×,Ð,ÙðÜ 	§¡¨jÓ9ˆð ‡{�{�8˜RÓ ×$Ñ$ XÓ.°%Ô7Ü# IÓ:Ð:ðÜÔ*¨9¯<©<¸y¿¹Ð[eØ5<¸WÕ5EÀlÕ5SÐ\bôdó eð 	eøô ô Úðûô œx¬Ð3ô Ü×Òœ(Ó#×+Ñ+Ð,HÈ*Ð_cÐ+ÔdÚðús$   µB8 Á=:C
 Â8CÃCÃ
ADÄDc              ƒ  ó0  "  € V P                   P                  V4      pV'       dm   Vei   VP                  '       dW   ^ RIp\	        V P
                  V4      R,          R,          pVP                  V P
                  P                  V4      G Rj  x€L
  V#  L5i)z¬On the owner loop after the close committed: a viewer attached meanwhile, so the session
it watches is live again (the stamp would make active work prune/archive eligible).Nr   r   )r   r   r   Úasyncior   r   Ú	to_threadÚreopen_session)r   r   Úendedr    r'   Útargets   &&&   r"   Úreopen_if_reattachedr,   8   sx   é € ð ×Ñ×!Ñ! *Ó-€Dß�Ò! d×&6×&6Ð&6ÛÜ˜yŸ|™|¨ZÓ8¸ÕAÀ,ÕOˆØ×Ñ 	§¡× ;Ñ ;¸VÓD×DÐDØ€Lñ 	Eùs   ‚9B¼ABÂBÂBc           	     ó:  a € S P                   P                  4       ;_uu_ 4       pVP                  R\        R,           34       Uu. uF  q"^ ,          \	        \        4      R NK  	  ppRRR4       \        V 3R lX 4       4      # u upi   + '       g   i     L*; i)zPGateway shutdown: every ACP session nobody is viewing, attached this run or not.z+SELECT key FROM state_meta WHERE key LIKE ?Ú%Nc              3   ó<   <"  € T F  p\        SV4      x € K  	  R # 5i)N)r#   )Ú.0Úsidr   s   & €r"   Ú	<genexpr>Ú(end_idle_acp_sessions.<locals>.<genexpr>H   s   øé € ÐC¹s¸Ô# I¨s×3Ð3»sùs   ƒ)r   Ú	_read_ctxÚexecuter   ÚlenÚsum)r   ÚconnÚrowÚidss   f   r"   Úend_idle_acp_sessionsr;   C   s‡   ø€ à	�‰×	Ñ	×	!Ô	! TØ6:·l±lØ9¼MÈCÕ<OÐ;Qô7Só Tñ 7S¨s�1�v”cœ-Ó(Ð)Ó*ñ 7Sˆð T÷ 
"ô ÔC¹sÓCÓCÐCùòT÷ 
"×	!ús   ¤!B
Á!BÁ&B
ÂB
Â
B	)Ú__doc__r   Úhermes_state_localr   r   r   Úhermes_state_runtimer   r   r#   r%   r,   r;   © ó    r"   Ú<module>rA      s2   ðñó ç SÑ SÝ 2à!€òò&ò*ôDr@   