+
    D#j%&                       R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
Ht ]P                  ! 4       R,          R,          R,          R	,          R
,          tRtRtRHt ! R R]]	4      t ! R R]]	4      t]! RR7       ! R R4      4       t]! RR7       ! R R4      4       t]! RR7       ! R R4      4       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' R( ltR) R* ltR+ R, lt R- R. lt!R/ R0 lt"R1 R2 lt#R3 R4 lt$R5 R6 lt%R7 R8 lt&R9 R: lt'R; R< lt(R= R> lt)R? R@ lt*RA]#/RB RC llt+RIRDRRERRA]#/RF RG lllt,R# )JzRead-only global factory visibility for the systray.

Identity comparison follows ``adw_modules.control`` (recorded argv subsequence
contract). This module never mutates the trace database.
)annotationsN)	dataclass)Enum)Pathz.localstateoverdeckfactoryzsssf.dbzhttp://127.0.0.1:31337z/factoryc                      ] tR t^tRtRtRtR# )FactoryAvailability	availableunavailable N)__name__
__module____qualname____firstlineno__	AVAILABLEUNAVAILABLE__static_attributes__r       _/home/user/overdeck-private-tests/subrouter-s5-systray-latest/modules/systray/factory_status.pyr
   r
      s    IKr   r
   c                      ] tR t^tRtRtRtR# )FactoryActivityliveidler   N)r   r   r   r   LIVEIDLEr   r   r   r   r   r      s    DDr   r   T)frozenc                  ,    ] tR t^ t$ R]R&   R]R&   RtR# )FactoryLiveRunstradw_idz
str | Nonerepor   Nr   r   r   r   __annotations__r   r   r   r   r   r       s    K
r   r   c                  @    ] tR t^&t$ R]R&   R]R&   R]R&   R]R&   RtR# )FactoryPendingDecisionr    decision_idr!   question
created_atr   Nr#   r   r   r   r&   r&   &   s    KMOr   r&   c                      ] tR t^.t$ R]R&   R]R&   R]R&   R]R&   R	]R
&   RtR]R&   RtR]R&   ]R]! ]	4      R
R/R R ll4       t
]R]! ]	4      /R R ll4       tRtR# )FactoryStatusSnapshotr
   availabilityr   activityztuple[FactoryLiveRun, ...]	live_runsr    db_pathbool
db_present"tuple[FactoryPendingDecision, ...]pending_decisionstuple[str, ...]all_pending_decision_idsFc               $    V ^8  d   QhRRRRRR/# )   r/   r    r1   r0   returnr+   r   )formats   "r   __annotate__"FactoryStatusSnapshot.__annotate__9   s*     
 
 
 	

 

r   c               	    T ! V'       g   \         P                  M\         P                  \        P                  RVVR 7      # )r,   r-   r.   r/   r1   r   )r
   r   r   r   r   )clsr/   r1   s   &$$r   	idle_safeFactoryStatusSnapshot.idle_safe8   s8     @J,88PcPmPm$))!
 	
r   c                    V ^8  d   QhRRRR/# )r7   r/   r    r8   r+   r   )r9   s   "r   r:   r;   H   s     
 
S 
DY 
r   c               	T    V ! \         P                  \        P                  RVR R7      # )Fr=   r   )r
   r   r   r   )r>   r/   s   &$r   r   !FactoryStatusSnapshot.unavailableG   s*    ,88$))
 	
r   r   N)r   r   r   r   r$   r3   r5   classmethodr    DEFAULT_DB_PATHr?   r   r   r   r   r   r+   r+   .   s    %%))L<>9>02o2
 ?+
 !	
 
 
3+? 
 
r   r+   c                   V ^8  d   QhRR/# r7   r8   r    r   )r9   s   "r   r:   r:   R   s     Q Qs Qr   c                 h    \         P                  P                  R \        4      P	                  R4      # )OVERDECK_WEB_URL/)osenvirongetDEFAULT_DECK_BASE_URLrstripr   r   r   deck_base_urlrP   R   s$    ::>>,.CDKKCPPr   c                   V ^8  d   QhRR/# rG   r   )r9   s   "r   r:   r:   V   s     4 4# 4r   c                 &    \        4        \         2# N)rP   FACTORY_DECK_ROUTEr   r   r   deck_factory_urlrU   V   s    o1233r   c                    V ^8  d   QhRRRR/# r7   tokenr    r8   r0   r   )r9   s   "r   r:   r:   Z   s     1 1 1 1r   c                >    R V 9   ;'       g    V P                  R4      # )rJ   .)
startswithrX   s   &r   _is_path_liker]   Z   s    %<005++C00r   c                    V ^8  d   QhRRRR/# )r7   rX   r    r8   r   )r9   s   "r   r:   r:   ^   s      # # r   c                    \        V 4      '       g   V #  \        \        V 4      P                  4       4      #   \         d    T u # i ; irS   )r]   r    r   resolveOSErrorr\   s   &r   _resolve_tokenrb   ^   sC    4;&&()) s   !7 AAc                    V ^8  d   QhRRRR/# rW   r   )r9   s   "r   r:   r:   g   s     : :# :$ :r   c                h    \        V 4      P                  pVR 8H  ;'       g    VP                  R4      # )pythonpython3)r   namer[   )rX   rg   s   & r   _is_python_interpreterrh   g   s-    ;D899ty99r   c                    V ^8  d   QhRRRR/# )r7   recorded_commandr    r8   	list[str]r   )r9   s   "r   r:   r:   l   s      C I r   c                    V P                  4       pV'       g   . #  \        P                  ! V4      #   \         d    . u # i ; irS   )stripshlexsplit
ValueError)rj   texts   & r   recorded_command_argvrr   l   s@    !!#D	{{4   	s   2 AAc                    V ^8  d   QhRRRR/# )r7   tokensrk   r8   r   )r9   s   "r   r:   r:   v   s     7 7Y 79 7r   c                B    V  Uu. uF  p\        V4      NK  	  up# u upi rS   )rb   )rt   rX   s   & r   command_tokens_for_matchrv   v   s    /56veN5!v666s   c                    V ^8  d   QhRRRR/# )r7   	proc_argvrk   r8   r   )r9   s   "r   r:   r:   z   s     / /9 / /r   c                    \        V 4      # rS   )rv   )rx   s   &r   proc_argv_for_matchrz   z   s    #I..r   c                    V ^8  d   QhRRRR/# )r7   rx   rk   r8   zlist[list[str]]r   )r9   s   "r   r:   r:   ~   s      9  r   c                    \        V 4      pV.p\        V 4      ^8  dZ   \        V ^ ,          4      '       dB   \        V ^,          4      '       d*   \	        V R,          4      pW18w  d   VP                  V4       V# )r7   :r7   NN)rz   lenrh   r]   rv   append)rx   resolved
candidatesstrippeds   &   r   _proc_argv_match_candidatesr   ~   sg    "9-HJ
9~5ilCCV_`aVbHcHc+IbM:h'r   c               $    V ^8  d   QhRRRRRR/# )r7   recordedrk   r   r8   z!list[tuple[list[str], list[str]]]r   )r9   s   "r   r:   r:      s"     	 	9 	I 	Bc 	r   c                    W3.pV '       dZ   V'       dR   \        V ^ ,          4      '       d:   \        V^ ,          4      '       d"   VP                  V R,          VR,          34       V# )    :   NN)rh   r~   )r   r   pairss   && r   _recorded_live_pairsr      sO    E"8A;//"47++hrlDH-.Lr   c               $    V ^8  d   QhRRRRRR/# )r7   r   rk   r   r8   r0   r   )r9   s   "r   r:   r:      s!     	 	 	) 	 	r   c                    W8X  d   R # \        V 4      pV\        V4      8  d   R# \        \        V4      V,
          ^,           4       F  pWW2,            V 8X  g   K   R # 	  R# )TF)r}   range)r   r   mis   &&  r   _subsequence_matchr      sT    HA3t9}3t9q=1$%AE?h& & r   c               $    V ^8  d   QhRRRRRR/# )r7   rx   rk   rj   r    r8   r0   r   )r9   s   "r   r:   r:      s"       c VZ r   c                    \        \        V4      4      pV'       g   R # \        V 4       F,  p\        W#4       F  w  rE\	        WE4      '       g   K    R# 	  K.  	  R # )FT)rv   rr   r   r   r   )rx   rj   r   r   recorded_cmplive_cmps   &&    r   !argv_matches_recorded_subsequencer      sN    '(=>N(OPH+I6&:8&J"L!,99 'K 7 r   c                    V ^8  d   QhRRRR/# )r7   pidintr8   zlist[str] | Noner   )r9   s   "r   r:   r:      s     
 
 
 0 
r   c                V   \        R V  R24      pVP                  4       '       g   R# VP                  4       pV'       g   R# VP                  R4       Uu. uF  q3P	                  RR7      NK  	  ppV'       d"   VR,          '       g   VP                  4        K)  T;'       g    R# u upi )z/proc/z/cmdlineN    replace)errors)r   exists
read_bytesro   decodepop)r   pathrawpartpartss   &    r   read_proc_argvr      s    &X&'D;;==
//
C7:yy7GH7Gt[[	[*7GEH
b				==D Is   B&c                    V ^8  d   QhRRRR/# )r7   r/   r   r8   sqlite3.Connectionr   )r9   s   "r   r:   r:      s      t (: r   c                    \         P                  ! R V  R2RR7      pVP                  R4       VP                  R4       V# )zfile:z?mode=roT)urizPRAGMA busy_timeout = 5000zPRAGMA query_only = ON)sqlite3connectexecute)r/   conns   & r   _open_readonly_dbr      s:    ??U7)84$?DLL-.LL)*Kr   c                    V ^8  d   QhRRRR/# r7   r   r   r8   r0   r   )r9   s   "r   r:   r:      s     < <1 <d <r   c                   a V P                  R 4      P                  4       pV Uu0 uF  q"^ ,          kK  	  upo\        ;QJ d#    V3R l\         4       F  '       d   K   R# 	  R# ! V3R l\         4       4      # u upi )z3SELECT name FROM sqlite_master WHERE type = 'table'c              3  ,   <"   T F	  qS9   x  K  	  R # 5irS   r   ).0tablenamess   & r   	<genexpr>'_has_required_schema.<locals>.<genexpr>   s     ;?%~?s   FT)r   fetchallallREQUIRED_TABLES)r   rowsrowr   s   &  @r   _has_required_schemar      sf    <<=hj 	  $$tVVt$E3;?;33;3;3;?;;; %s   A;c                    V ^8  d   QhRRRR/# r   r   )r9   s   "r   r:   r:      s     1 1$6 14 1r   c                    V P                  R 4      P                  4       p\        ;QJ d    R V 4       F  '       g   K   R# 	  R# ! R V 4       4      # )PRAGMA table_info(sessions)c              3  8   "   T F  q^,          R8H  x  K  	  R# 5i)r   r"   Nr   r   r   s   & r   r   ,_sessions_has_repo_column.<locals>.<genexpr>   s     04C1v4   TFr   r   anyr   r   s   & r   _sessions_has_repo_columnr      sC    <<56??AD304033030304000r   c                    V ^8  d   QhRRRR/# r   r   )r9   s   "r   r:   r:      s     5 5(: 5t 5r   c                    V P                  R 4      P                  4       p\        ;QJ d    R V 4       F  '       g   K   R# 	  R# ! R V 4       4      # )r   c              3  8   "   T F  q^,          R8H  x  K  	  R# 5i)r   archivedNr   r   s   & r   r   0_sessions_has_archived_column.<locals>.<genexpr>   s     4t1v#tr   TFr   r   s   & r   _sessions_has_archived_columnr      sC    <<56??AD34t43343434t444r   c                    V ^8  d   QhRRRR/# r   r   )r9   s   "r   r:   r:      s      1 d r   c                V    V P                  R 4      P                  4       p\        V4      # )zJSELECT name FROM sqlite_master WHERE type = 'table' AND name = 'decisions')r   r   r0   r   s   & r   _has_decisions_tabler      s)    <<Thj 	 :r   c                    V ^8  d   QhRRRR/# )r7   r   r   r8   r2   r   )r9   s   "r   r:   r:      s      "4 9[ r   c                    \        V 4      '       g   R# \        V 4      '       d   R MRpV P                  RV R24      P                  4       p\        ;QJ d    . R V 4       F  NK  	  5# ! R V 4       4      # )zCOALESCE(s.archived, 0) = 0z1 = 1zSELECT d.decision_id, d.adw_id, d.question, d.created_at FROM decisions d INNER JOIN sessions s ON s.adw_id = d.adw_id WHERE d.status = 'pending' AND z ORDER BY d.created_atc           
   3     "   T FO  w  rr4\        \        V4      \        V4      \        T;'       g    R 4      \        T;'       g    R 4      R7      x  KQ  	  R# 5i) )r'   r!   r(   r)   N)r&   r    )r   r'   r!   r(   r)   s   &    r   r   *_load_pending_decisions.<locals>.<genexpr>   sW       :>5K 	K(v;R(:++,		
 	
 :>s   AAAr   )r   r   r   r   tuple)r   archived_filterr   s   &  r   _load_pending_decisionsr      s    %%	)Ft)L)L%RY  <<	++:*;;Q	S hj	 	
 5  :>5 5  :>  r   c                    V ^8  d   QhRRRR/# )r7   r   r   r8   r4   r   )r9   s   "r   r:   r:      s     > >); > >r   c                    \        V 4      '       g   R# V P                  R 4      P                  4       p\        ;QJ d    . R V 4       F  NK  	  5# ! R V 4       4      # )zNSELECT decision_id FROM decisions WHERE status = 'pending' ORDER BY created_atc              3  <   "   T F  w  p\        V4      x  K  	  R # 5irS   )r    )r   r'   s   & r   r   1_load_all_pending_decision_ids.<locals>.<genexpr>   s     =n{[!!s   r   )r   r   r   r   r   s   & r   _load_all_pending_decision_idsr      sQ    %%	<<Xhj 	 5==5=5====r   read_proc_argv_fnc               $    V ^8  d   QhRRRRRR/# )r7   r   r   r!   r    r8   r0   r   )r9   s   "r   r:   r:      s&      

 
r   c                   V P                  R V34      P                  4       pV'       g   R# RpV F<  w  rVV! \        V4      4      pVf   K  \        Yv;'       g    R4      '       d   RpK;   R# 	  V# )zFSELECT pid, command FROM processes WHERE adw_id=? AND ended_at IS NULLFr   T)r   r   r   r   )r   r!   r   r   has_verifiedr   commandrx   s   &&$     r   _session_is_verified_liver      sw     <<P		 hj 	 L%c#h/	,Y2FFL  r   exists_implopen_db_implc                    V ^8  d   QhRRRR/# )r7   r/   zstr | Path | Noner8   r+   r   )r9   s   "r   r:   r:     s     4 44 4r   c                  \        T ;'       g    \        4      p\        VP                  4       4      pT;'       g    R  pV! V4      '       g   \        P                  VR7      # T;'       g    \        p V! V4      p \        T4      '       g'   \        P                  TR7      TP                  4        # \        T4      p	T	'       d   RMRp
TP                  RT
 R24      P                  4       p. pT FI  w  r\        T\        T4      TR7      '       g   K$  TP!                  \#        \        T4      TR7      4       KK  	  T'       d   \$        P&                  M\$        P(                  p\	        \*        P,                  T\/        T4      TR\1        T4      \3        T4      R	7      TP                  4        #   \        \        P                  3 d    \        P                  TR7      u # i ; i  \        P                   d*    \        P                  TR7      u TP                  4        # i ; i  TP                  4        i ; i)
c                "    V P                  4       # rS   )r   )	candidates   &r   <lambda>%load_factory_status.<locals>.<lambda>  s    y/?/?/Ar   )r/   r"   zNULL AS repozSELECT adw_id, z> FROM sessions WHERE status='running' ORDER BY started_at DESC)r   )r!   r"   T)r,   r-   r.   r/   r1   r3   r5   )r   rE   r    r`   r+   r   r   ra   r   Errorr   closer   r   r   r   r~   r   r   r   r   r
   r   r   r   r   )r/   r   r   r   r   r   r   openerr   has_repo	repo_exprrunningr.   r!   r"   r-   s   &$$$            r   load_factory_statusr     s    **?+D4<<>"HBBAF$<<$000BB...FCd|!#D))(44X4F> 	

; -T2&FN	,,i[(fg

(* 	 +-	#LF,F"3 
 ^3v;TJK $ ,5?''/:N:N$,66I&5d;%CD%I
 	

I W]]# C$000BBCB == C$000BB

C 	

sD   5F3 >&G* 5BG* AG* 31G'&G'*+H(H+ 'H((H+ +H=)sessions	processesrS   )-__doc__
__future__r   rK   rn   r   dataclassesr   enumr   pathlibr   homerE   rN   rT   r   r    r
   r   r   r&   r+   rP   rU   r]   rb   rh   rr   rv   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      si   # 	   !  ))+(72Z?)KiW0  + #t  
c4 
 $  
 $   $ 
  
  
FQ41:
7/		
<1
5
,> %	24 4 	4
 %4 4r   