+
    5mj  c                     ^ RI Ht ^ RIt^ RIHu Ht ^ RIt^ RI	t	^ RI
Ht ^ RIHt ^ RIt]	P                  P!                  ^ ]! ]! ]4      P'                  4       P(                  ^,          4      4       ^ RIt^ RIt^ RIHtHtHt ^ RIHtHt RR R l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# )    )annotationsN)PathSimpleNamespace)AccountLockedErrorAccountLockStoreHumanOverrideError)AccountRegistryAccountRegistryKindc               $    V ^8  d   QhRRRRRR/# )   base_dirr   slugstrreturn )formats   "j/home/user/overdeck-private-tests/workstation-ai-broad2/modules/systray/tests/test_claudex_account_lock.py__annotate__r      s!     	 	T 	 	4 	    c           	     p   V R ,          V,          R,          R,          pVP                   P                  RR7       VP                  \        P                  ! R/ /4      RR7       V R,          P                  \        P                  ! R R	VR
R/./4      RR7       V R,          P                  V R2RR7       V# )accounts
CODEX_HOME	auth.jsonT)parentstokensutf-8encodingzaccounts.jsonr   aliasOwnerdefault_slug
)parentmkdir
write_textjsondumps)r   r   	auth_paths   && r   _codex_accountr)      s    :%,|;kII4(XrN3gF++

J&$!A BCD ,  **dV2;*Ir   c               $    V ^8  d   QhRRRRRR/# r   tmp_pathr   monkeypatchzpytest.MonkeyPatchr   Noner   )r   s   "r   r   r      s$     	2 	2	2!3	2		2r   c                f  a  \        S 4       \        S 4      P                  R RR4       VP                  \        RV 3R l4       VP                  \        RR 4       \
        P                  ! \        4      ;_uu_ 4        \        P                  ! R4       RRR4       R#   + '       g   i     R# ; i)codexnightT_codex_tray_dirsc                    < S S R ,          3# legacyr   r,   s   r   <lambda>Dtest_direct_codex_selection_refuses_locked_account.<locals>.<lambda>#       hS[H[=\r   _require_codex_spend_headroomc                    R # Nr   _slugs   &r   r7   r8   $       PTr   N)	r)   r   
set_lockedsetattrclaudexpytestraisesr   resolve_selected_accountr,   r-   s   f&r   2test_direct_codex_selection_refuses_locked_accountrG      sy     8X))'7DA!35\]!@BTU	)	*	*((1 
+	*	*	*s   >BB0	c               $    V ^8  d   QhRRRRRR/# r+   r   )r   s   "r   r   r   *   $     5 55!35	5r   c                T
  aaa V R ,          oV R,          o\        S4      p\        S4      pVP                  RRR4       VP                  \        RVV3R l4       VP                  \        RR 4       \
        P                  ! \        4      ;_uu_ 4        \        P                  ! R4       R	R	R	4       . oVP                  \        R
V3R l4       \        P                  ! RR4      pVP                  qUV8H  qf'       g   \        P                  ! RV3RWR34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                   ! V4      MRR\        P                   ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                   ! V4      MR/,          pRRV/,          p\#        \        P$                  ! V4      4      hR	;rVVP&                  qUS8H  qf'       Eg    \        P                  ! RV3RVS34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                   ! V4      MRR\        P                   ! V4      RR \        P                  ! 4       9   g   \        P                  ! S4      '       d   \        P                   ! S4      MR /,          pRRV/,          p\#        \        P$                  ! V4      4      hR	;rVR.p	SV	8H  qU'       g   \        P                  ! RV3R SV	34      RR\        P                  ! 4       9   g   \        P                  ! S4      '       d   \        P                   ! S4      MRR\        P                   ! V	4      /,          p
RRV
/,          p\#        \        P$                  ! V4      4      hR	;rYVP(                  pRpRq! Wl4      pRqVJ q'       Eg	   \        P                  ! R!V3R"W34      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                   ! V4      MRR\        P                   ! V4      R\        P                   ! V4      R\        P                   ! V4      R\        P                   ! V4      R\        P                   ! V4      /,          pRRV/,          p\#        \        P$                  ! V4      4      hR	;p;p;p;p;rR	#   + '       g   i     ELs; i)#currentr5   r0   r1   Tr2   c                    < S S3# r<   r   )rK   r5   s   r   r7   Jtest_direct_codex_legacy_copy_uses_canonical_lock_policy.<locals>.<lambda>2   s
    gv=Nr   r:   c                    R # r<   r   r=   s   &r   r7   rM   3   r?   r   Nconfirm_human_actionc                *   < SP                  WV34      # r<   appendactiontoolr   confirmationss   &&&r   r7   rM   <       =#7#7t8L#Mr   py0selectedpy2py4r(   assert %(py6)spy6rV   py3assert %(py5)spy5storepy8py11assert %(py13)spy13==z8%(py2)s
{%(py2)s = %(py0)s.native_auth_path
} == %(py4)s)z0%(py2)s
{%(py2)s = %(py0)s.base_dir
} == %(py4)szuse-oncer0   r1   z%(py0)s == %(py3)siszY%(py8)s
{%(py8)s = %(py2)s
{%(py2)s = %(py0)s.is_locked
}(%(py4)s, %(py6)s)
} is %(py11)s)r)   r   r@   rA   rB   rC   rD   r   rE   account_locknative_auth_path
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationr   	is_locked)r,   r-   r(   ra   rY   @py_assert1@py_assert3@py_format5@py_format7@py_assert2@py_format4@py_format6@py_assert5@py_assert7@py_assert10@py_assert9@py_format12@py_format14rV   rK   r5   s   &&                @@@r   8test_direct_codex_legacy_copy_uses_canonical_lock_policyr   *   s    "G Fv&IW%E	Wgt,!35NO!@BTU	)	*	*((1 
+ 13MM
 //>H$$1	11111$111111811118111$111111	1111	11111111''''''''''''8''''8''''''''''''''''''''';<<=<<<<<<=<<<<<<<=<<<<=<<<<<<<<<<<<??474G4?7,4444444,444444544445444?4447444G444,444444444444 
+	*	*s   TT'	c               $    V ^8  d   QhRRRRRR/# r+   r   )r   s   "r   r   r   F   rI   r   c                  a a \        S 4      p\        S 4      pVP                  R RR4       VP                  \        RV 3R l4       VP                  \        RR 4       . oVP                  \
        RV3R l4       \        P                  ! RR4      pVP                  pRqeV8H  qw'       g   \        P                  ! R V3R!WV34      R	R
\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR
R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p	\        \        P                  ! V	4      4      hR;p;rvVP                   qUV8H  qw'       g   \        P                  ! R V3R"WR34      R	R
\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR
R\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR/,          p
RRV
/,          p\        \        P                  ! V4      4      hR;rWVP"                  pRqeVJqw'       g   \        P                  ! R#V3R$WV34      R	R
\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR
R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p	\        \        P                  ! V	4      4      hR;p;rvVP"                  qUP$                  pRqVJ q'       g   \        P                  ! R%V3R&W|34      R	R
\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR
R\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      /,          p	RRV	/,          p\        \        P                  ! V4      4      hR;p;p;rR'.pSV8H  qU'       g   \        P                  ! R V3R(SV34      R	R\        P                  ! 4       9   g   \        P                  ! S4      '       d   \        P                  ! S4      MRR\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;r_VP&                  pR pRq! W}4      pRpVVJ pV'       Eg
   \        P                  ! R%V3R)VV34      R	R\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;p;p;p;pp\(        P*                  ! \,        RR7      ;_uu_ 4        \        P                  ! RR4       RRR4       R#   + '       g   i     R# ; i)*r0   r1   Tr2   c                    < S S R ,          3# r4   r   r6   s   r   r7   Gtest_direct_codex_human_override_is_explicit_one_shot.<locals>.<lambda>L   r9   r   r:   c                    R # r<   r   r=   s   &r   r7   r   M   r?   r   rO   c                *   < SP                  WV34      # r<   rQ   rS   s   &&&r   r7   r   R   rW   r   rX   rY   rZ   r`   assert %(py7)spy7Nr[   r(   r\   r]   assert %(py9)spy9rV   r^   r_   ra   rb   rc   rd   re   explicit --accountmatchrf   z,%(py2)s
{%(py2)s = %(py0)s.slug
} == %(py5)srh   is notz9%(py2)s
{%(py2)s = %(py0)s.authorization
} is not %(py5)srk   zZ%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.authorization
}.locked_override
} is %(py7)sri   rj   rm   )r)   r   r@   rA   rB   rn   rE   r   rp   rq   rr   rs   rt   ru   rv   rw   ro   authorizationlocked_overriderx   rC   rD   r   )r,   r-   r(   ra   rY   ry   @py_assert4rz   r   @py_format8r{   r|   @py_assert6r   @py_format10r}   r~   r   r   r   r   r   rV   s   f&                    @r   5test_direct_codex_human_override_is_explicit_one_shotr   F   s    x(IX&E	Wgt,!35\]!@BTU02MM //>H==#G#G#####=######8####8###=###G########$$1	11111$111111811118111$111111	1111	11111111!!-------!------8----8---!-----------!!9119T9T999991999999899998999!9991999T99999999;<<=<<<<<<=<<<<<<<=<<<<=<<<<<<<<<<<<??474G4?7,44,44444,444444544445444?4447444G444,444444444444	)1E	F	F((t4 
G	F	F	Fs   Z<<[	c               $    V ^8  d   QhRRRRRR/# r+   r   )r   s   "r   r   r   b   s$     < <<!3<	<r   c                  a  VP                  \        R V 3R l4       \        P                  ! \        RR7      ;_uu_ 4        \        P
                  ! RR4       RRR4       \        P                  ! \        RR7      ;_uu_ 4        \        P
                  ! RR4       RRR4       \        P                  ! \        RR7      ;_uu_ 4        \        P                  ! RR4       RRR4       \        P                  ! \        RR7      ;_uu_ 4        \        P                  ! RR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L|; i  + '       g   i     R# ; i)r2   c                    < S S R ,          3# r4   r   r6   s   r   r7   Stest_direct_human_override_rejects_implicit_or_fallback_selectors.<locals>.<lambda>e   r9   r   r   r   NTzexactly oneznight,agent)rA   rB   rC   rD   r   rE   resolve_claude_accountrF   s   f&r   Atest_direct_human_override_rejects_implicit_or_fallback_selectorsr   b   s     !35\]	)1E	F	F((t4 
G	)	?	?((= 
@	)1E	F	F&&tT2 
G	)	?	?&&}d; 
@	? 
G	F	?	?	F	F	?	?	?s0   D/E	EE(/D?	E	E%	(E9	c               $    V ^8  d   QhRRRRRR/# r+   r   )r   s   "r   r   r   q   s$     / //!3/	/r   c                l
  a a VP                  \        P                  R V 3R l4       S R,          p\        V\        P
                  R7      pVP                  RR4      oSR,          P                  RRR	7       VP                  RR
4       VP                  \        P                  RR 4       VP                  \        RV3R l4       \        P                  ! \        4      ;_uu_ 4        \        P                  ! R4       RRR4       VP                  \        RR 4       \        P                  ! RR
4      pVP                  pRqeV8H  qw'       g   \         P"                  ! RV3R WV34      RR\$        P&                  ! 4       9   g   \         P(                  ! V4      '       d   \         P*                  ! V4      MRR\         P*                  ! V4      R\         P*                  ! V4      /,          pRRV/,          p	\-        \         P.                  ! V	4      4      hR;p;rvVP0                  pRqeVJqw'       g   \         P"                  ! R!V3R"WV34      RR\$        P&                  ! 4       9   g   \         P(                  ! V4      '       d   \         P*                  ! V4      MRR\         P*                  ! V4      R\         P*                  ! V4      /,          pRRV/,          p	\-        \         P.                  ! V	4      4      hR;p;rvVP0                  qUP2                  pR
qV
J q'       g   \         P"                  ! R#V3R$Wz34      RR\$        P&                  ! 4       9   g   \         P(                  ! V4      '       d   \         P*                  ! V4      MRR\         P*                  ! V4      R\         P*                  ! V4      R\         P*                  ! V
4      /,          p	RRV	/,          p\-        \         P.                  ! V4      4      hR;p;p;rVP4                  pRqu! V4      pR
qVJ q'       g   \         P"                  ! R#V3R%W34      RR\$        P&                  ! 4       9   g   \         P(                  ! V4      '       d   \         P*                  ! V4      MRR\         P*                  ! V4      R\         P*                  ! V4      R\         P*                  ! V4      R\         P*                  ! V4      /,          pRRV/,          p\-        \         P.                  ! V4      4      hR;p;p;p;rR#   + '       g   i     EL+; i)&homec                    < S # r<   r   r6   s   r   r7   Atest_direct_claude_selection_enforces_same_lock.<locals>.<lambda>t   s    hr   z%.local/state/overdeck/systray/runtime)r   kindr1   r    .credentials.jsonz{}r   r   Tsync_before_execc                     . # r<   r   _argss   *r   r7   r   z   s    RTr   resolve_credentialsc                *   < \        SR ,          R7      # )r   )pathr   )_homeaccount_homes   &r   r7   r   ~   s    o<:M+MNr   NrO   c                     R # r<   r   r   s   *r   r7   r      s    Tr   rX   rY   rZ   r`   r   r   r[   r   r   registryr]   zassert %(py11)src   rf   r   r   r   rk   r   )zO%(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.is_locked
}(%(py4)s)
} is %(py9)s)rA   rB   r   r	   r
   CLAUDEadd_dirr%   r@   ClaudeAdapterrC   rD   r   r   rn   r   rp   rq   rr   rs   rt   ru   rv   rw   r   r   rx   )r,   r-   r   r   rY   ry   r   rz   r   r   r   r   r   @py_assert8r   r   r   s   f&              @r   /test_direct_claude_selection_enforces_same_lockr   q   s    f.>?AAH7J7Q7QRH##GW5L''33D73K&--/ACTUN 
)	*	*&&w/ 
+ &<>QR--gt<H==#G#G#####=######8####8###=###G########!!-------!------8----8---!-----------!!9119T9T999991999999899998999!9991999T99999999.g.g&.$.$.....&......8....8......g...&...$......... 
+	*	*s   )T""T3	c                   V ^8  d   QhRR/# )r   r   r.   r   )r   s   "r   r   r      s     	G 	G4 	Gr   c                    \         P                  ! . RO4      w  r\         P                  pRpRpRqR! W4V4      q`V8H  qw'       Eg_   \        P                  ! RV3RW34      RR\
        P                  ! 4       9   g   \        P                  ! V 4      '       d   \        P                  ! V 4      MRRR	\
        P                  ! 4       9   g!   \        P                  ! \         4      '       d   \        P                  ! \         4      MR	R
\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      R\        P                  ! V4      /,          pRRV/,          p	\        \        P                  ! V	4      4      hR;p;p;p;p;rVRR.qV
8H  qw'       g   \        P                  ! RV3RW34      RR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V
4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;rz\        P                  ! \         P                  RR7      ;_uu_ 4        \         P                  ! R.4       RRR4       R#   + '       g   i     R# ; i)--codex-accountr1   --modelsolNTrX   r   rZ   rB   r[   r]   rb   py10py12zassert %(py14)spy14	forwardedr^   r_   r`   zdoes not take a valuer   z--human-override-lock=yes)r   r1   --human-override-lockr   r   rf   )zk%(py0)s == %(py12)s
{%(py12)s = %(py4)s
{%(py4)s = %(py2)s.AccountOverrides
}(%(py6)s, %(py8)s, %(py10)s)
}rj   )rB   parse_account_overridesAccountOverridesrp   rq   rr   rs   rt   ru   rv   rw   rC   rD   ClaudexError)r   r   rz   r   r   r   @py_assert11ry   @py_format13@py_format15r}   r~   r   s                r   9test_parse_account_overrides_consumes_human_override_flagr      s   !99OH //DDDtD/tDDDDDDDD8DDDDDD8DDDD8DDDDDDDwDDDDwDDD/DDDDDDDDDtDDDDDDDDDDDDD"E********9******9****9************	w++3J	K	K'')D(EF 
L	K	K	Ks   K  K	c                    V ^8  d   QhRRRR/# )r   capsyszpytest.CaptureFixture[str]r   r.   r   )r   s   "r   r   r      s      I I&I	Ir   c           	        \         P                  ! R R.4      pV P                  4       p^Mq1V8H  qD'       g   \        P                  ! RV3RW34      RR\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;rCRqrP                  qV9   q3'       g   \        P                  ! RV3RWx34      R	\        P                  ! V4      RR
\
        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MR
R\        P                  ! V4      /,          pRRV/,          p	\        \        P                  ! V	4      4      hR;p;r8\        P                  ! VP                  4      R,          pRqV
8H  q3'       gy   \        P                  ! RV3RWz34      R	\        P                  ! V4      R\        P                  ! V
4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;p;r:R# )rB   r   rX   	exit_coder^   r_   r`   Nr   py1capturedr   r   reasonzhuman-override-deniedr[   r\   r]   rf   rj   )in)z+%(py1)s in %(py5)s
{%(py5)s = %(py3)s.err
})z%(py1)s == %(py4)s)rB   main
readouterrrp   rq   rr   rs   rt   ru   rv   rw   errr&   loadsout)r   r   r   r}   ry   r~   r   @py_assert0r   r   rz   r{   r|   s   &            r   Dtest_top_level_human_override_without_account_returns_policy_refusalr      sX    i)@ABI  "H?999/<</<//////////////8////8///<////////::hll#H-H1HH1HHHHHH-HHH-HHH1HHHHHHHHHr   c               $    V ^8  d   QhRRRRRR/# r+   r   )r   s   "r   r   r      s$     % %%!3%	%r   c                
  aaaa \         P                  ! R V R,          V R,          4      o\         P                  ! RV R,          / 4      o. o. oR VV3R llpR VV3R llpVP                  \         R	V4       VP                  \         R
V4       \         P                  ! R RR4      p\         P
                  qU! V4      qfSJ qw'       Egl   \        P                  ! RV3RVS34      RR\        P                  ! 4       9   g!   \        P                  ! \         4      '       d   \        P                  ! \         4      MRR\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! S4      '       d   \        P                  ! S4      MR/,          pRRV/,          p	\        \        P                  ! V	4      4      hR;p;rg\         P                  qU! V4      qfSJ qw'       Egl   \        P                  ! RV3RVS34      RR\        P                  ! 4       9   g!   \        P                  ! \         4      '       d   \        P                  ! \         4      MRR\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! V4      '       d   \        P                  ! V4      MRR\        P                  ! V4      RR\        P                  ! 4       9   g   \        P                  ! S4      '       d   \        P                  ! S4      MR/,          pRRV/,          p	\        \        P                  ! V	4      4      hR;p;rgR.p
SV
8H  qU'       g   \        P                  ! RV3RSV
34      RR\        P                  ! 4       9   g   \        P                  ! S4      '       d   \        P                  ! S4      MRR\        P                  ! V
4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;rZR .p
SV
8H  qU'       g   \        P                  ! RV3RSV
34      RR\        P                  ! 4       9   g   \        P                  ! S4      '       d   \        P                  ! S4      MRR\        P                  ! V
4      /,          pRRV/,          p\        \        P                  ! V4      4      hR;rZR# )!r1   r   proxyworkclaudec                    V ^8  d   QhRRRR/# )r   argsobjectr   zclaudex.SelectedAccountr   )r   s   "r   r   Stest_override_flag_only_applies_to_explicitly_pinned_provider.<locals>.__annotate__   s      V (? r   c                 *   < SP                  V 4       S# r<   rQ   )r   codex_callsrY   s   *r   resolve_codexTtest_override_flag_only_applies_to_explicitly_pinned_provider.<locals>.resolve_codex   s    4 r   c                    V ^8  d   QhRRRR/# )r   r   r   r   zclaudex.ClaudeAccountr   )r   s   "r   r   r      s      f )> r   c                 *   < SP                  V 4       S# r<   rQ   )r   r   claude_callss   *r   resolve_claudeUtest_override_flag_only_applies_to_explicitly_pinned_provider.<locals>.resolve_claude   s    D!r   rE   r   NTrX   rB   rZ   r^   r   r`   r   rY   r   r   r   r_   r   rk   )ze%(py5)s
{%(py5)s = %(py2)s
{%(py2)s = %(py0)s._resolve_selected_for_overrides
}(%(py3)s)
} is %(py7)s)zc%(py5)s
{%(py5)s = %(py2)s
{%(py2)s = %(py0)s._resolve_claude_for_overrides
}(%(py3)s)
} is %(py7)s)r1   Trf   rj   r<   )rB   SelectedAccountClaudeAccountrA   r   _resolve_selected_for_overridesrp   rq   rr   rs   rt   ru   rv   rw   _resolve_claude_for_overrides)r,   r-   r   r   r   ry   r   r   r   r   r}   r~   r   r   r   r   rY   s   &&           @@@@r   =test_override_flag_only_applies_to_explicitly_pinned_providerr      s    &&;7H
 ""68h+>CF,.K-/L   !;]K!9>J''t<H22H28<HHHHHH<HHHHHH7HHHH7HHH2HHHHHH8HHHH8HHH<HHHHHHHHHHHHHHHHHH00D0:DfDDDDD:fDDDDDD7DDDD7DDD0DDDDDDDDDDDDD:DDDDDDfDDDDfDDDDDDDD*++;++++++;+++++++;++++;++++++++++++#9$<9$$$$$<9$$$$$$<$$$$<$$$9$$$$$$$$r   )r1   )&
__future__r   builtinsrr   _pytest.assertion.rewrite	assertionrewriterp   r&   syspathlibr   typesr   rC   r   insertr   __file__resolver   rn   rB   r   r   r   account_registryr	   r
   r)   rG   r   r   r   r   r   r   r   r   r   r   <module>r      s    "    
  !  3tH~--/77:; <   Q Q A		25858</8	GI%r   