
    jD                    @   d Z ddlmZ ddlZddlmc mZ ddl	Z	ddl
Z
ddlmZ ddlZ e ee      j!                         j"                  d         Ze
j&                  rWe
j&                  d   ek7  rEee
j&                  v re
j&                  j)                  e       e
j&                  j+                  de        ee
j.                        D ]k  Zedk(  s(ej3                  d      sedk(  sej3                  d	      s0 ee
j.                  e   d
d      xs dZeevsPe
j.                  j9                  ed       m ddlmZmZm Z  ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)  ee      j!                         j"                  d   dz  dz  Z*g dZ+g dZ,e+e,z   Z-d'dZ.d Z/d Z0d Z1d Z2d Z3d Z4d Z5d Z6d Z7d Z8d Z9ejt                  jw                  de-      d         Z<ejt                  jw                  de-      d!        Z=ejt                  jw                  de,      d"        Z>d# Z?d$ Z@d% ZAd& ZBy)(u  tests/regression/test_callback_registration_status_consistency.py

task-2635+1 — status schema 5축 분리 + 6 모순 조합 FAIL 단언.

회장 verbatim (task-2635+1 §7):
    `registration_result_status == NOT_REGISTERED` + `cron_schedule_id != None` → FAIL
    `registration_result_status == REGISTERED` + `cron_schedule_id == None` → FAIL
    `registration_attempted == False` + result ∈ (REGISTERED, REGISTER_FAILED) → FAIL
    `registration_result_status == SENDFILE_ONLY` + attempted_callback_registration == True → FAIL
    `callback_delivery_status == DELIVERED` + result != REGISTERED → FAIL
    `collector_receipt_status == RECEIVED` + callback_delivery_status != DELIVERED → FAIL

Also asserts that all 10 fixture scenarios (5 existing + 5 new) carry
contradiction-free envelopes, and that the build-then-register-then-update
pipeline produces axes that pass the contradiction scanner.

Live cokacdir CLI 호출 0 (모든 subprocess 는 mock runner 로 주입).
    )annotationsN)Path   dispatchz	dispatch.utilszutils.__file__ )build_callback_envelope$merge_registrar_result_into_envelopeRegistrarResult)ALL_DELIVERY_STATUSESALL_RECEIPT_STATUSESALL_RESULT_STATUSESCallbackDeliveryStatusCollectorReceiptStatusRegistrationResultStatusdetect_status_contradictionsvalidate_envelope   fixturesnormal_callback_registration)registered_normalnot_registered_envelope_onlysendfile_only_no_cronregister_failed_cli_errorskipped_explicit_reason_dryrun)registered_schedule_id_presentsendfile_only_not_registeredattempted_but_register_failedregistered_but_not_yet_receivedreceived_by_anu_collectorc            	     @   i ddddddddd	d
dddddt         j                  j                  dt        j                  j                  dt
        j                  j                  dddt         j                  j                  ddddddddddddddddd d!S )"zReturn a contradiction-free 5-axis envelope skeleton used as the base
    for each contradiction test. Every test mutates ONE axis to inject the
    target contradiction and asserts the scanner detects it.schemazutils.anu_callback_registrar.v2task_idztask-2635+1-contradiction-testexecutor_namedispatch-executor-dev6result_pathz7memory/tasks/task-2635+1-contradiction-test.result.jsonreport_pathz0memory/reports/task-2635+1-contradiction-test.mdregistration_intentTregistration_attemptedregistration_result_statuscallback_delivery_statuscollector_receipt_statusattempted_callback_registrationregistration_statusdelivery_methodanu_cron_callbackcollector_roleANUanu_keyc119085addb0f8b7cron_schedule_idzCRON-AXES-BASELINEregistered_at_tsz2026-05-23T03:30:00Zz$memory/events/baseline.callback_done(0000000000000000000000000000000000000000z5-axis baseline@0fbd1dad1e110c49474dfbdf13a21fb3bdd9c7f094128004dba8472840bb832d) collector_durable_success_markercollector_done_marker_pathenvelope_built_at
commit_shafile_summaryregression_summaryspec_sha256)r   
REGISTEREDvaluer   	DELIVEREDr   RECEIVED     U/home/jay/workspace/tests/regression/test_callback_registration_status_consistency.py_baseline_axesrH   Q   s-   33 	1 	P	
 	I 	t 	!$ 	%&>&I&I&O&O 	#$:$D$D$J$J 	#$:$C$C$I$I 	*4 	7BBHH 	. 	% 	%  	0!" 	2#$ -1&L3)/Y1 rF   c                 t   h d} t         | k(  }|st        j                  d|fdt         | f      dt        j                         v st        j
                  t               rt        j                  t               ndt        j                  |       dz  }dd|iz  }t        t        j                  |            d x}} y )N>   rA   SENDFILE_ONLYNOT_REGISTEREDREGISTER_FAILEDSKIPPED_WITH_EXPLICIT_REASON==z%(py0)s == %(py3)sr   py0py3assert %(py5)spy5)	r   
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanation@py_assert2@py_assert1@py_format4@py_format6s       rG    test_axis_3_enum_has_five_valuesrc   t   s    #  #    #             #      rF   c                 t   h d} t         | k(  }|st        j                  d|fdt         | f      dt        j                         v st        j
                  t               rt        j                  t               ndt        j                  |       dz  }dd|iz  }t        t        j                  |            d x}} y )N>   PENDINGrC   UNDELIVEREDNOT_APPLICABLErN   rP   r   rQ   rT   rU   )	r   rV   rW   rX   rY   rZ   r[   r\   r]   r^   s       rG    test_axis_4_enum_has_four_valuesrh   ~   s    %   %  
   %  
  
  !  
  !  
 %    
  rF   c                 t   h d} t         | k(  }|st        j                  d|fdt         | f      dt        j                         v st        j
                  t               rt        j                  t               ndt        j                  |       dz  }dd|iz  }t        t        j                  |            d x}} y )N>   rD   	TIMED_OUTUNCONFIRMEDrg   rN   rP   r   rQ   rT   rU   )	r   rV   rW   rX   rY   rZ   r[   r\   r]   r^   s       rG    test_axis_5_enum_has_four_valuesrl      s    $  $  
  $  
  
     
     
 $    
  rF   c                 8   t               } t        j                  j                  | d<   t        j                  j                  | d<   d| d<   t        j
                  j                  | d<   t        j
                  j                  | d<   d| d<   t        |       }d |D        }t        |      }|st        j                  d	|       d
z   dt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      t        j                  |      dz  }t        t        j                   |            dx}}t#        |       \  }}| }|s{t        j                  d      dz   ddt        j                         v st        j                  |      rt        j                  |      ndiz  }t        t        j                   |            d}d |D        }t        |      }|sddt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      t        j                  |      dz  }t        t        j                   |            dx}}y)u8   NOT_REGISTERED + cron_schedule_id present → must fail.r+   r/   Fr*   r,   r-   r.   c              3  0   K   | ]  }d |v xr d|v   yw)rK   zschedule_id presentNrE   .0cs     rG   	<genexpr>zMtest_contradiction_1_not_registered_with_schedule_id_fails.<locals>.<genexpr>   s$     \1$C)>!)CC\   z$contradiction #1 not detected. got: .
>assert %(py4)s
{%(py4)s = %(py0)s(%(py2)s)
}anyrR   py2py4Nz?validator must reject NOT_REGISTERED + cron_schedule_id present
>assert not %(py0)srR   okc              3  $   K   | ]  }d |v  
 yw)rK   NrE   rp   es     rG   rr   zMtest_contradiction_1_not_registered_with_schedule_id_fails.<locals>.<genexpr>   s     31$3   ,assert %(py4)s
{%(py4)s = %(py0)s(%(py2)s)
})rH   r   rK   rB   r   rg   r   r   ru   rV   _format_assertmsgrX   rY   rZ   r[   r\   r]   r   )envcontradictionsr`   @py_assert3@py_format5rz   errs@py_format2s           rG   :test_contradiction_1_not_registered_with_schedule_id_failsr      s   

C(@(O(O(U(UC$%!9!H!H!N!NC$)C !&<&K&K&Q&QC"#&<&K&K&Q&QC"#-2C)* 2#6N\^\ 3\\ \   /~.>?             ]    ]      !%HB6T6TTTTTTTTTrTTTrTTTTTT3d3333333333333333333333333333333rF   c                     t               } | j                  d       t        |       }d |D        }t        |      }|st	        j
                  d|       dz   dt        j                         v st	        j                  t              rt	        j                  t              ndt	        j                  |      t	        j                  |      dz  }t        t	        j                  |            dx}}t        |       \  }}| }|s{t	        j
                  d      d	z   d
dt        j                         v st	        j                  |      rt	        j                  |      ndiz  }t        t	        j                  |            d}y)u4   REGISTERED + cron_schedule_id missing → must fail.r6   c              3  0   K   | ]  }d |v xr d|v   yw)rA   zcron_schedule_id missingNrE   ro   s     rG   rr   zLtest_contradiction_2_registered_without_schedule_id_fails.<locals>.<genexpr>   s(      BC=8A==rs   z$contradiction #2 not detected. got: rt   ru   rv   Nz9validator must reject REGISTERED without cron_schedule_idry   rR   rz   )rH   popr   ru   rV   r   rX   rY   rZ   r[   r\   r]   r   )r   r   r`   r   r   rz   _errsr   s           rG   9test_contradiction_2_registered_without_schedule_id_failsr      s2   

CGG1#6NGU ?3   ?  ?->->	-n-=>? ?8>? ?&>&>  ? ?5>Y  ? ?5>Y ? ?5>Y ? ? ?+>+>? ? "#&IB6N6NNNNNNNNNrNNNrNNNNNNrF   c                    t               } d| d<   t        |       }d |D        }t        |      }|st        j                  d|       dz   dt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      t        j                  |      dz  }t        t        j                  |            dx}}y)	u2   attempted=False + result=REGISTERED → must fail.Fr*   c              3  $   K   | ]  }d |v  
 ywzregistration_attempted=FalseNrE   ro   s     rG   rr   zMtest_contradiction_3_attempted_false_with_registered_fails.<locals>.<genexpr>        Kq-2Kr~   z9contradiction #3 (REGISTERED variant) not detected. got: rt   ru   rv   N)rH   r   ru   rV   r   rX   rY   rZ   r[   r\   r]   r   r   r`   r   r   s        rG   :test_contradiction_3_attempted_false_with_registered_failsr      s    

C$)C ! 2#6NKNK 3KK K   DNCST             L    L     rF   c                    t               } d| d<   t        j                  j                  | d<   t        j                  j                  | d<   d| d<   t        j
                  j                  | d<   t        j                  j                  | d<   | j                  d	       t        |       }d
 |D        }t        |      }|st        j                  d|       dz   dt        j                         v st        j                  t              rt        j                   t              ndt        j                   |      t        j                   |      dz  }t#        t        j$                  |            dx}}y)u7   attempted=False + result=REGISTER_FAILED → must fail.Fr*   r+   r/   fakeerror_messager,   r-   r6   c              3  $   K   | ]  }d |v  
 ywr   rE   ro   s     rG   rr   zRtest_contradiction_3_attempted_false_with_register_failed_fails.<locals>.<genexpr>   r   r~   z>contradiction #3 (REGISTER_FAILED variant) not detected. got: rt   ru   rv   N)rH   r   rL   rB   r   rf   r   rg   r   r   ru   rV   r   rX   rY   rZ   r[   r\   r]   r   s        rG   ?test_contradiction_3_attempted_false_with_register_failed_failsr      s?   

C$)C !(@(P(P(V(VC$%!9!I!I!O!OC!C&<&H&H&N&NC"#&<&K&K&Q&QC"#GG1#6NKNK 3KK K   IHXY             L    L     rF   c                    t               } t        j                  j                  | d<   t        j                  j                  | d<   d| d<   d| d<   d| d<   t        j
                  j                  | d	<   t        j
                  j                  | d
<   | j                  d       t        |       }d |D        }t        |      }|st        j                  d|       dz   dt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      t        j                  |      dz  }t!        t        j"                  |            dx}}y)uC   SENDFILE_ONLY + attempted_callback_registration=True → must fail.r+   r/   Fr*   Tr.   sendfile_onlyr0   r,   r-   r6   c              3  0   K   | ]  }d |v xr d|v   yw)rJ   z$attempted_callback_registration=TrueNrE   ro   s     rG   rr   zJtest_contradiction_4_sendfile_only_with_attempted_fails.<locals>.<genexpr>   s+       	1L!G1!LLrs   z$contradiction #4 not detected. got: rt   ru   rv   N)rH   r   rJ   rB   r   rg   r   r   r   ru   rV   r   rX   rY   rZ   r[   r\   r]   r   s        rG   7test_contradiction_4_sendfile_only_with_attempted_failsr      si   

C(@(N(N(T(TC$%!9!G!G!M!MC$)C !-1C)*,C&<&K&K&Q&QC"#&<&K&K&Q&QC"#GG1#6N ?3   ?  ? .?->	-n-=>? ? 9?? ? '?&>  ? ? 6?Y  ? ? 6?Y ? ? 6?Y ? ? ? ,?+>? ?rF   c                    t               } t        j                  j                  | d<   t        j                  j                  | d<   d| d<   t        j
                  j                  | d<   | j                  d       t        |       }d |D        }t        |      }|st        j                  d|       d	z   d
t        j                         v st        j                  t              rt        j                  t              nd
t        j                  |      t        j                  |      dz  }t        t        j                   |            dx}}y)u/   DELIVERED + result != REGISTERED → must fail.r+   r/   r   r   r-   r6   c              3  $   K   | ]  }d |v  
 yw)z"callback_delivery_status=DELIVEREDNrE   ro   s     rG   rr   zJtest_contradiction_5_delivered_without_registered_fails.<locals>.<genexpr>   s      67,1r~   z$contradiction #5 not detected. got: rt   ru   rv   N)rH   r   rL   rB   r   rg   r   r   ru   rV   r   rX   rY   rZ   r[   r\   r]   r   s        rG   7test_contradiction_5_delivered_without_registered_failsr      s-   

C(@(P(P(V(VC$%!9!I!I!O!OC!C&<&K&K&Q&QC"#GG1#6N;I ?3   ?  ?->->	-n-=>? ?8>? ?&>&>  ? ?5>Y  ? ?5>Y ? ?5>Y ? ? ?+>+>? ?rF   c                    t               } t        j                  j                  | d<   t	        |       }d |D        }t        |      }|st        j                  d|       dz   dt        j                         v st        j                  t
              rt        j                  t
              ndt        j                  |      t        j                  |      dz  }t        t        j                  |            dx}}y)u/   RECEIVED + delivery != DELIVERED → must fail.r,   c              3  $   K   | ]  }d |v  
 yw)z!collector_receipt_status=RECEIVEDNrE   ro   s     rG   rr   zHtest_contradiction_6_received_without_delivered_fails.<locals>.<genexpr>   s      56+q0r~   z$contradiction #6 not detected. got: rt   ru   rv   N)rH   r   re   rB   r   ru   rV   r   rX   rY   rZ   r[   r\   r]   r   s        rG   5test_contradiction_6_received_without_delivered_failsr      s    

C&<&D&D&J&JC"# 2#6N:H ?3   ?  ?->->	-n-=>? ?8>? ?&>&>  ? ?5>Y  ? ?5>Y ? ?5>Y ? ? ?+>+>? ?rF   c                 T   t               } t        |       }g }||k(  }|st        j                  d|fd||f      dt	        j
                         v st        j                  t              rt        j                  t              nddt	        j
                         v st        j                  |       rt        j                  |       ndt        j                  |      t        j                  |      dz  }dd|iz  }t        t        j                  |            dx}x}}t        |       \  }}|s~t        j                  d	|       d
z   ddt	        j
                         v st        j                  |      rt        j                  |      ndiz  }t        t        j                  |            y)zSanity: the test baseline itself must be contradiction-free, otherwise
    the per-contradiction tests above could be passing for the wrong reason.rN   z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py6)sr   r   rR   py1rS   py6assert %(py8)spy8Nz%baseline envelope failed validation: z
>assert %(py0)srR   rz   )rH   r   rV   rW   rX   rY   rZ   r[   r\   r]   r   r   )	r   r_   @py_assert5@py_assert4@py_format7@py_format9rz   r   @py_format1s	            rG   *test_baseline_axes_has_zero_contradictionsr     s     
C',22,2222,222222'222'222222222222,2222222222 %HB==6tf=======2===2=====2rF   scenarioc                   t        j                  t        | z  dz  j                  d            }t	        |      }g }||k(  }|st        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      dz  }t        j                  |  d|       d	z   d
|iz  }t        t        j                  |            d x}}y )Nevidence.jsonutf-8encodingrN   rP   r   rQ   z+: fixture envelope carries contradictions: z
>assert %(py5)srU   )jsonloadsFIXTURE_ROOT	read_textr   rV   rW   rX   rY   rZ   r[   r   r\   r]   )r   evidencer   r_   r`   ra   rb   s          rG   -test_fixture_envelope_has_zero_contradictionsr     s    zz		 ?	2==w=OH 2(;N >R  >R                   *??OP    rF   c                "   t        j                  t        | z  dz  j                  d            }t        j                  t        | z  dz  j                  d            }dD ]  }||   }||   }||k(  }|st	        j
                  d|fd||f      t	        j                  |      t	        j                  |      dz  }t	        j                  |  d	| d
||   d||         dz   d|iz  }t        t	        j                  |            dx}x}} y)u1   expected.json 5축 값 == evidence.json 5축 값.r   r   r   expected.json)r)   r*   r+   r,   r-   rN   z%(py1)s == %(py4)sr   rx   z: axis u    mismatch — evidence=z vs expected=z
>assert %(py6)sr   N)
r   r   r   r   rV   rW   r[   r   r\   r]   )	r   r   expectedaxis@py_assert0r   r_   r   r   s	            rG   )test_fixture_expected_axes_match_evidencer     s%    zz		 ?	2==w=OH zz		 ?	2==w=OH 

 ~ 	
$ 	
~/ 	
 	
~ 	
 	
 
	  	
 	
 
	 "0 	
 	
  jv%<Xd^<N O#D>,.	
 	
 	
 	
 	
 	


rF   c                   t         | z  }d}||z  }|j                  } |       }|sddt        j                         v st	        j
                  |      rt	        j                  |      ndt	        j                  |      t	        j                  |      t	        j                  |      dz  }t        t	        j                  |            d x}x}x}}d}||z  }|j                  } |       }|sddt        j                         v st	        j
                  |      rt	        j                  |      ndt	        j                  |      t	        j                  |      t	        j                  |      dz  }t        t	        j                  |            d x}x}x}}d}||z  }|j                  } |       }|sddt        j                         v st	        j
                  |      rt	        j                  |      ndt	        j                  |      t	        j                  |      t	        j                  |      dz  }t        t	        j                  |            d x}x}x}}y )Nr   zNassert %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = (%(py0)s / %(py2)s).is_file
}()
}sdir)rR   rw   rU   py7r   zPROVENANCE.md)	r   is_filerX   rY   rV   rZ   r[   r\   r]   )r   r   r`   r   r   @py_assert6@py_format8s          rG   #test_new_fixtures_carry_three_filesr   3  sw   ("D"-D?"-"++-+--------D---D---?---+----------"-D?"-"++-+--------D---D---?---+----------"-D?"-"++-+--------D---D---?---+----------rF   c            	        t        ddddddddd	      } | d
   }d}||u }|slt        j                  d|fd||f      t        j                  |      t        j                  |      dz  }dd|iz  }t	        t        j
                  |            dx}x}}| d   }d}||u }|slt        j                  d|fd||f      t        j                  |      t        j                  |      dz  }dd|iz  }t	        t        j
                  |            dx}x}}| d   }t        j                  }|j                  }||k(  }|st        j                  d|fd||f      t        j                  |      dt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      t        j                  |      dz  }dd|iz  }	t	        t        j
                  |	            dx}x}x}}| d   }t        j                  }|j                  }||k(  }|st        j                  d|fd||f      t        j                  |      dt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      t        j                  |      dz  }dd|iz  }	t	        t        j
                  |	            dx}x}x}}| j                  }
d} |
|      }d}||u }|st        j                  d|fd||f      dt        j                         v st        j                  |       rt        j                  |       ndt        j                  |
      t        j                  |      t        j                  |      t        j                  |      dz  }	dd|	iz  }t	        t        j
                  |            dx}
x}x}x}}| d    }t        j                  }|j                  }||k(  }|st        j                  d|fd!||f      t        j                  |      d"t        j                         v st        j                  t              rt        j                  t              nd"t        j                  |      t        j                  |      dz  }dd|iz  }	t	        t        j
                  |	            dx}x}x}}| d#   }t        j                   }|j                  }||k(  }|st        j                  d|fd$||f      t        j                  |      d%t        j                         v st        j                  t              rt        j                  t              nd%t        j                  |      t        j                  |      dz  }dd|iz  }	t	        t        j
                  |	            dx}x}x}}y)&z@build_callback_envelope(default) seeds NOT_REGISTERED + PENDING.ztask-2635+1-seedr&   r.jsonr.mdr8   r9   r%   r'   r(   r=   r@   T)r$   resultr.   r*   r)   )is)z%(py1)s is %(py4)sr   assert %(py6)sr   Nr*   r+   rN   zQ%(py1)s == %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.NOT_REGISTERED
}.value
}r   r   rS   rU   r   assert %(py9)spy9r/   r6   )zI%(py6)s
{%(py6)s = %(py2)s
{%(py2)s = %(py0)s.get
}(%(py4)s)
} is %(py9)sr   )rR   rw   rx   r   r   zassert %(py11)spy11r,   )zJ%(py1)s == %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.PENDING
}.value
}r   r-   zN%(py1)s == %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.UNCONFIRMED
}.value
}r   )r
   rV   rW   r[   r\   r]   r   rK   rB   rX   rY   rZ   getr   re   r   rk   )r   r   r   r_   r   r   r   r   r   @py_format10r`   r   @py_assert8@py_assert7@py_format12s                  rG   0test_seed_envelope_axes_are_pre_attempt_defaultsr   >  s   
!"5#!"]
 )-#C $%--%----%---%----------'(0D0(D0000(D000(000D0000000+,]0H0W0W]0W0]0]],0]]]]],0]]]],]]]]]]0H]]]0H]]]0W]]]0]]]]]]]]$%V)A)P)PV)P)V)VV%)VVVVV%)VVVV%VVVVVV)AVVV)AVVV)PVVV)VVVVVVVV77.%.7%&.$.&$....&$......3...3...7...%...&...$.......)*R.D.L.LR.L.R.RR*.RRRRR*.RRRR*RRRRRR.DRRR.DRRR.LRRR.RRRRRRRR)*V.D.P.PV.P.V.VV*.VVVVV*.VVVV*VVVVVV.DVVV.DVVV.PVVV.VVVVVVVVrF   c            	        t        ddddddd      } t        t        j                  j                  d	d
t
        j                  j                  t        j                  j                  d      }t        | |      }|d   }t        j                  }|j                  }||k(  }|st        j                  d|fd||f      t        j                  |      dt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      t        j                  |      dz  }dd|iz  }t!        t        j"                  |            dx}x}x}}|d   }t        j                  }|j                  }||k(  }|st        j                  d|fd||f      t        j                  |      dt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      t        j                  |      dz  }dd|iz  }t!        t        j"                  |            dx}x}x}}|d   }d	}	||	k(  }|slt        j                  d|fd||	f      t        j                  |      t        j                  |	      dz  }
dd|
iz  }t!        t        j"                  |            dx}x}}	|d   }d
}	||	k(  }|slt        j                  d|fd||	f      t        j                  |      t        j                  |	      dz  }
dd|
iz  }t!        t        j"                  |            dx}x}}	|d   }t
        j                  }|j                  }||k(  }|st        j                  d|fd||f      t        j                  |      dt        j                         v st        j                  t
              rt        j                  t
              ndt        j                  |      t        j                  |      dz  }dd|iz  }t!        t        j"                  |            dx}x}x}}|d   }t        j                  }|j                  }||k(  }|st        j                  d|fd ||f      t        j                  |      d!t        j                         v st        j                  t              rt        j                  t              nd!t        j                  |      t        j                  |      dz  }dd|iz  }t!        t        j"                  |            dx}x}x}}t%        |      }g }||k(  }|st        j                  d|fd"||f      d#t        j                         v st        j                  t$              rt        j                  t$              nd#d$t        j                         v st        j                  |      rt        j                  |      nd$t        j                  |      t        j                  |      d%z  }d&d'|iz  }t!        t        j"                  |            dx}x}}| d   }t        j&                  }|j                  }||k(  }|st        j                  d|fd(||f      t        j                  |      dt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      t        j                  |      dz  }dd|iz  }t!        t        j"                  |            dx}x}x}}y))u   task-2635+1 §4 — register-after-update: post-register envelope carries
    REGISTERED across axes 3/4/5 + schedule_id + registered_at_ts.ztask-2635+1-merger&   r   r   r8   r9   r   r$   r   zCRON-MERGE-OK-1z2026-05-23T03:35:00Z  )statusschedule_idr7   delivery_statusreceipt_status
byte_countr+   rN   )zM%(py1)s == %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.REGISTERED
}.value
}r   r   r   r   Nr/   r6   r   r   r   r   r7   r,   )zL%(py1)s == %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.DELIVERED
}.value
}r   r-   r   r   r   r   mergedr   r   r   r   )r
   r   r   rA   rB   r   rC   r   rk   r   rV   rW   r[   rX   rY   rZ   r\   r]   r   rK   )r   rrr   r   r   r   r_   r   r   r   r   r   r   r   s                 rG   5test_merge_registrar_result_transitions_all_five_axesr   X  s    "#5#!"]
	C 
'2288%/.88>>-99??
B 2#r:F ./\3K3V3V\3V3\3\\/3\\\\\/3\\\\/\\\\\\3K\\\3K\\\3V\\\3\\\\\\\\'(U,D,O,OU,O,U,UU(,UUUUU(,UUUU(UUUUUU,DUUU,DUUU,OUUU,UUUUUUUU$%:)::%):::::%)::::%:::)::::::::$%?)??%)?????%)????%???)????????,-W1G1Q1QW1Q1W1WW-1WWWWW-1WWWW-WWWWWW1GWWW1GWWW1QWWW1WWWWWWWW,-Y1G1S1SY1S1Y1YY-1YYYYY-1YYYY-YYYYYY1GYYY1GYYY1SYYY1YYYYYYYY'/525/25555/2555555'555'555555555555/55525555555 +,]0H0W0W]0W0]0]],0]]]]],0]]]],]]]]]]0H]]]0H]]]0W]]]0]]]]]]]]rF   c                    t               } t        j                  j                  | d<   d| d<   t	        |       \  }}| }|s{t        j                  d      dz   ddt        j                         v st        j                  |      rt        j                  |      ndiz  }t        t        j                  |            d}d	 |D        }t        |      }|sd
dt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      t        j                  |      dz  }t        t        j                  |            dx}}y)u   Validator must reject the case where registration_status (legacy) and
    registration_result_status (new) disagree — single source of truth.r/   Tr*   z,validator must reject legacy/new alias driftry   rR   rz   Nc              3  $   K   | ]  }d |v  
 yw)zalias driftNrE   r|   s     rG   rr   zItest_alias_drift_detected_when_legacy_and_new_disagree.<locals>.<genexpr>  s     0a}!0r~   r   ru   rv   )rH   r   rK   rB   r   rV   r   rX   rY   rZ   r[   r\   r]   ru   )r   rz   r   r`   r   r   r   s          rG   6test_alias_drift_detected_when_legacy_and_new_disagreer     s     
C!9!H!H!N!NC$(C ! %HB6A6AAAAAAAAArAAArAAAAAA040030000000003000300000000000000rF   c            	        t        ddddddd      } t        t        j                  j                  d	t
        j                  j                  t        j                  j                  d
      }t        | |      }|d   }t        j                  }|j                  }||k(  }|st        j                  d|fd||f      t        j                  |      dt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      t        j                  |      dz  }dd|iz  }t!        t        j"                  |            dx}x}x}}|d   }t
        j                  }|j                  }||k(  }|st        j                  d|fd||f      t        j                  |      dt        j                         v st        j                  t
              rt        j                  t
              ndt        j                  |      t        j                  |      dz  }dd|iz  }t!        t        j"                  |            dx}x}x}}|d   }t        j                  }|j                  }||k(  }|st        j                  d|fd||f      t        j                  |      dt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      t        j                  |      dz  }dd|iz  }t!        t        j"                  |            dx}x}x}}t%        |      }g }	||	k(  }|st        j                  d|fd||	f      dt        j                         v st        j                  t$              rt        j                  t$              nddt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      t        j                  |	      dz  }
dd|
iz  }t!        t        j"                  |            dx}x}}	y) zkREGISTER_FAILED outcome must produce delivery=UNDELIVERED +
    receipt=NOT_APPLICABLE (no contradictions).ztask-2635+1-failr&   r   r   r8   r9   r   r   z%cokacdir exit=2 stderr=daemon offliner   )r   errorr   r   r   r+   rN   )zR%(py1)s == %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.REGISTER_FAILED
}.value
}r   r   r   r   Nr,   )zN%(py1)s == %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.UNDELIVERED
}.value
}r   r-   )zQ%(py1)s == %(py7)s
{%(py7)s = %(py5)s
{%(py5)s = %(py3)s.NOT_APPLICABLE
}.value
}r   r   r   r   r   r   r   )r
   r   r   rL   rB   r   rf   r   rg   r   rV   rW   r[   rX   rY   rZ   r\   r]   r   )r   r   r   r   r   r   r_   r   r   r   r   r   s               rG   /test_failure_path_registrar_axes_are_consistentr     s    ""5#!"]
	C 
'77==5.::@@-<<BB
B 2#r:F./a3K3[3[a3[3a3aa/3aaaaa/3aaaa/aaaaaa3Kaaa3Kaaa3[aaa3aaaaaaaa,-Y1G1S1SY1S1Y1YY-1YYYYY-1YYYY-YYYYYY1GYYY1GYYY1SYYY1YYYYYYYY,-\1G1V1V\1V1\1\\-1\\\\\-1\\\\-\\\\\\1G\\\1G\\\1V\\\1\\\\\\\\'/525/25555/2555555'555'555555555555/55525555555rF   )returndict)C__doc__
__future__r   builtinsrX   _pytest.assertion.rewrite	assertionrewriterV   r   syspathlibr   pyteststrr   resolveparents_WORKTREE_ROOTpathremoveinsertlistmodules_mod
startswithgetattr_cachedr   utils.anu_callback_registrarr
   r   r   utils.callback_envelope_schemar   r   r   r   r   r   r   r   r   EXISTING_SCENARIOSNEW_SCENARIOSALL_SCENARIOSrH   rc   rh   rl   r   r   r   r   r   r   r   r   markparametrizer   r   r   r   r   r   r   rE   rF   rG   <module>r     s'  $ #    
  
 T(^++-55a8988~-!'HHOOA~& (DzT__[9TW_PTP_P_`hPi#++d+Z<B(KKOOD$'	( 
	 	 	 	N$$Q'$%   #]2F4*O	$?&? 	?> ]3 4 ]3
 4
* ]3. 4.W4$^N
16rF   