
    4j=                    &   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ZddlmZ ddlZ ee      j!                         j"                  j"                  j"                  Z ee      ej(                  v r!ej(                  j+                   ee             ej(                  j-                  d ee             ddlmZ ddlmZ ddlmZmZmZmZ ddl m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& dd	l'm(Z(m)Z)m*Z* dd
l+m,Z,  e
jZ                  edz  j]                  d            Z/e/d   Z0e/d   Z1edz  Z2ee/d   z  Z3e/d   Z4d*dZ5d+dZ6d,dZ7dddddZ8d Z9d Z:d Z;d Z<d Z=ej|                  j                  dg d      d         Z@d! ZAd" ZBd# ZCd$ ZDd% ZEd& ZFd' ZGd( ZHd) ZIy)-u  tests/regression/test_runtime_event_enactor_2553plus55.py

task-2553+55 — PROPOSAL_TO_BOUNDED_ENACTOR_FOR_RUNTIME_EVENT_LOOP regression.

Spec: memory/tasks/task-2553+55.md
(sha256 958b7a3081f3ecbcfe57c89bbda27523a8565c3d7413e0903a1deee525435a21).

회장 §5 필수 regression 1~15 — 실 entrypoint 직접 호출 (mock-only FAIL):

  1  all-settled consolidated_summary proposal -> additive closeout enact PASS
  2  same proposal 재처리 -> idempotent skip
  3  unauthorized dispatch candidate -> proposal only
  4  authorized ANU-key dispatch candidate -> dispatch-ready, no execution
  5  merge/PR/credential proposal -> blocked
  6  dead-man/fixed-time/fallback trigger source -> FAIL
  7  fallback pending + all-settled -> closeout allowed
  8  self-chain proposal -> rejected
  9  non-ANU collector proposal -> rejected
  10 registry/quarantine mismatch -> HOLD-routed
  11 enactor result schema valid
  12 +54 runtime event loop regression 무회귀 (direct entrypoint)
  13 +49 owner-key guard 무회귀 (direct entrypoint)
  14 no credential exposure (executor self key never surfaced)
  15 existing task-2553 artifacts 수정 0

100% offline — ZERO network / git mutation / cron / dispatch / cokacdir /
subprocess. The real +44 ledger and every existing task-2553 artifact is
consumed READ-ONLY (sha256 asserted unchanged); the Track A additive
closeout is written ONLY into an isolated tmp workspace_root here.
    )annotationsN)Path)Callback4TupleRegistry)validate_callback_owner_runtime)ACTION_BLOCKEDACTION_DISPATCH_READYACTION_HOLD_ROUTEDACTION_PROPOSAL_ONLY)CLOSEOUT_ARTIFACT_SCHEMAENACTOR_ENACTEDENACTOR_FORBIDDEN_TRIGGERENACTOR_IDEMPOTENT_SKIPRuntimeEventEnactorenactor_result_envelope)LOOP_ALL_SETTLED	BatchSpecRuntimeEventLoop)guard_self_collector_sessionz<memory/fixtures/runtime_event_proposal_all_settled_2553.jsonutf-8encodinganu_keyexecutor_self_keyz)memory/events/callback_4tuple_index.jsonlreal_loop_result_pathcloseout_targetc                d    t        j                  | j                               j                         S )N)hashlibsha256
read_bytes	hexdigest)ps    M/home/jay/workspace/tests/regression/test_runtime_event_enactor_2553plus55.py_sha256_pathr#   W   s     >>!,,.)3355    c                B    t        t        gt        t        |             S )N)anu_keysr   workspace_root)r   ANU_KEYSELF_KEYstr)roots    r"   _enactorr,   [   s    "4y r$   c                     d fd}|S )Nc                    | z  }|j                   j                  dd       |j                  t        j                  |dd      d       || <   y )NT)parentsexist_okF)ensure_ascii	sort_keysr   r   )parentmkdir
write_textjsondumps)relpayloadr!   r+   sinks      r"   _wz_tmp_writer.<locals>._wd   sO    3J	td3	JJwUdC 	 	
 S	r$   )r8   r*   r9   dictreturnNone )r+   r:   r;   s   `` r"   _tmp_writerr@   c   s     Ir$   r?   consolidateddispatchquarantinedc                F    dt        |       t        |      t        |      dS )Nzruntime_event_loop_result.v1)schemaconsolidated_summary_candidatesdispatch_candidatesquarantined_events)listrA   s      r"   _wraprK   p   s&    0+/+=#H~";/	 r$   c                   i }t        |       }|j                  t        d   t        | |      d      }|j                  }|t
        k(  }|st        j                  d|fd|t
        f      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      dt        j                         v st        j                  t
              rt        j                  t
              nddz  }d	d
|iz  }t        t        j                  |            d x}}|j                  }d}||k(  }|st        j                  d|fd||f      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}}|j                  }d}||u }|st        j                  d|fd||f      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         |v }|st        j                  d|fdt         |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dz  }dd|iz  }t        t        j                  |            d }|t            }|d   }|t"        k(  }|st        j                  d|fd|t"        f      t        j                  |      dt        j                         v st        j                  t"              rt        j                  t"              nddz  }dd|iz  }	t        t        j                  |	            d 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}||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'   }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(   }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)   }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*   }d}||u }|slt        j                  d|fd%||f      t        j                  |      t        j                  |      d#z  }d	d
|iz  }t        t        j                  |            d x}x}}| t         z  }|j$                  } |       }|sd+d,t        j                         v st        j                  |       rt        j                  |       nd,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}x}}y ).Nall_settled_loop_result2026-05-18 22:10 KSTartifact_writergenerated_at_kst==z/%(py2)s
{%(py2)s = %(py0)s.verdict
} == %(py4)sresr   py0py2py4assert %(py6)spy6   z5%(py2)s
{%(py2)s = %(py0)s.enacted_count
} == %(py5)srW   rX   py5assert %(py7)spy7Fis)z6%(py2)s
{%(py2)s = %(py0)s.hold_for_chair
} is %(py5)sinz%(py0)s in %(py2)sCLOSEOUT_TARGETr:   rW   rX   assert %(py4)srY   rF   z%(py1)s == %(py3)sr   py1py3assert %(py5)sr_   	authoritynonez%(py1)s == %(py4)srl   rY   auto_executedz%(py1)s is %(py4)scloseoutmergeprbranch_writerC   Nassert %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = (%(py0)s / %(py1)s).is_file
}()
}tmp_pathrW   rl   rY   r[   )r,   enactFIXr@   verdictr   
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationenacted_counthold_for_chairrg   r   is_file)rz   r:   erU   @py_assert1@py_assert3@py_format5@py_format7@py_assert4@py_format6@py_format8@py_format3art@py_assert0@py_assert2@py_format4@py_assert5s                    r"   -test_01_all_settled_additive_closeout_enactedr   z   s   DA
''%&#Hd3/  C
 ;;);/))));/))))))3)))3)));))))))/)))/)))))))!!!!!!!!!!!!3!!!3!!!!!!!!!!!!!&&&&&&&&&&&&3&&&3&&&&&&&&&&&&&d""""?d""""""?"""?""""""d"""d"""""""

Cx=4=44444=4444=444444444444444444{%v%v%%%%v%%%%%%v%%%%%%%(5(5((((5((((((5(((((((z?7#,u,#u,,,,#u,,,#,,,u,,,,,,,z?4 )E) E)))) E))) )))E)))))))z?>*3e3*e3333*e333*333e3333333z?:&/%/&%////&%///&///%///////&1&//1/11111111H111H111111111111/1111111111r$   c                   i }t        |       }t        | |      }|j                  t        d   |d      }t	        | t
        z        }|j                  t        d   |d      }|j                  }|t        k(  }|st        j                  d|fd|t        f      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      dt        j                         v st        j                  t              rt        j                  t              nddz  }	d	d
|	iz  }
t        t        j                  |
            d x}}|j                  }|t         k(  }|st        j                  d|fd|t         f      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      dt        j                         v st        j                  t               rt        j                  t               nddz  }	d	d
|	iz  }
t        t        j                  |
            d x}}|j"                  }d}||k(  }|st        j                  d|fd||f      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}}|j$                  }d}||k\  }|st        j                  d|fd||f      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
        z  }t	        |      }||k(  }|slt        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dt        j                         v st        j                  t
              rt        j                  t
              ndt        j                  |      dt        j                         v st        j                  |      rt        j                  |      nddz  }dd|iz  }t        t        j                  |            d x}x}}y )NrM   rN   rO   rR   rT   r1r   rV   rZ   r[   r2r   r   r]   r^   r`   ra   r\   )>=)z=%(py2)s
{%(py2)s = %(py0)s.idempotent_skip_count
} >= %(py5)s)z<%(py5)s
{%(py5)s = %(py0)s((%(py1)s / %(py2)s))
} == %(py7)sr#   rz   rg   pre)rW   rl   rX   r_   ra   assert %(py9)spy9)r,   r@   r|   r}   r#   rg   r~   r   r   r   r   r   r   r   r   r   r   r   idempotent_skip_count)rz   r:   r   wr   r   r   r   r   r   r   r   r   r   @py_assert6@py_format10s                   r"   $test_02_idempotent_skip_on_reprocessr      s   DAHd#A	
%&/ 
 
B
 x/1
2C	
%&/ 
 
B
 ::(:((((:((((((2(((2(((:((((((((((((((((::0:00000:000000020002000:000000000000000000 q q    q      2   2      q       ##(q(#q((((#q((((((2(((2(((#(((q((((((( ?2:<23:3s::::3s::::::<:::<:::::::::::::::?:::?:::3::::::s:::s:::::::r$   c                |   t        |       j                  t        t        d   g      d      }|j                  d   }|d   }|t
        k(  }|st        j                  d|fd|t
        f      t        j                  |      d	t        j                         v st        j                  t
              rt        j                  t
              nd	d
z  }dd|iz  }t        t        j                  |            d 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   }d}||u }|slt        j                  d|fd||f      t        j                  |      t        j                  |      dz  }dd|iz  }	t        t        j                  |	            d x}x}}|j                  }
d}|
|k(  }|st        j                  d|fd|
|f      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 )Nunauthorized_dispatch_candidaterC   xrQ   r   actionrR   rj   r
   rk   rn   r_   
authorizedFrb   rt   rr   rZ   r[   enactedr]   rU   r^   r`   ra   )r,   r|   rK   r}   recordsr
   r   r   r   r   r   r   r   r   r   rz   rU   recr   r   r   r   r   r   r   r   r   r   s                r"   +test_03_unauthorized_dispatch_proposal_onlyr      s   
8

"
"=>?@ # C ++a.Cx=0=00000=0000=000000000000000000|%%%%%%%%%%%%%%%%%%%y>"U">U"""">U""">"""U"""""""!!!!!!!!!!!!3!!!3!!!!!!!!!!!!!r$   c                   t        |       j                  t        t        d   g      dd      }|j                  d   }|d   }|t
        k(  }|st        j                  d|fd	|t
        f      t        j                  |      d
t        j                         v st        j                  t
              rt        j                  t
              nd
dz  }dd|iz  }t        t        j                  |            d 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   }d}||u }|slt        j                  d|fd||f      t        j                  |      t        j                  |      dz  }dd|iz  }	t        t        j                  |	            d x}x}}|j                  }
d}|
|k(  }|st        j                  d|fd|
|f      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}}|j                  }
d}|
|k(  }|st        j                  d|fd|
|f      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 )Nauthorized_dispatch_candidater   Fr   )allow_actual_dispatchrQ   r   r   rR   rj   r   rk   rn   r_   r   Trb   rt   rr   rZ   r[   r   r\   z<%(py2)s
{%(py2)s = %(py0)s.dispatch_ready_count
} == %(py5)srU   r^   r`   ra   r]   )r,   r|   rK   r}   r   r   r   r   r   r   r   r   r   r   dispatch_ready_countr   r   s                r"   .test_04_authorized_dispatch_ready_no_executionr      s'   
8

"
";<=># # C
 ++a.Cx=1=11111=1111=111111111111111111|$$$$$$$$$$$$$$$$$$$y>"U">U"""">U""">"""U"""""""##(q(#q((((#q((((((3(((3(((#(((q(((((((!!!!!!!!!!!!3!!!3!!!!!!!!!!!!!r$   c                |   t        |       j                  t        t        d   g      d      }|j                  d   }|d   }|t
        k(  }|st        j                  d|fd|t
        f      t        j                  |      d	t        j                         v st        j                  t
              rt        j                  t
              nd	d
z  }dd|iz  }t        t        j                  |            d 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   }d}||u }|slt        j                  d|fd||f      t        j                  |      t        j                  |      dz  }dd|iz  }	t        t        j                  |	            d x}x}}|j                  }
d}|
|k(  }|st        j                  d|fd|
|f      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 )Nmerge_pr_credential_candidater   r   r   r   r   rR   rj   r   rk   rn   r_   r   Frb   rt   rr   rZ   r[   r   r\   )z5%(py2)s
{%(py2)s = %(py0)s.blocked_count
} == %(py5)srU   r^   r`   ra   )r,   r|   rK   r}   r   r   r   r   r   r   r   r   r   r   blocked_countr   s                r"   #test_05_merge_pr_credential_blockedr      s   
8

"
";<=> # C ++a.Cx=*=N****=N***=******N***N*******|%%%%%%%%%%%%%%%%%%%y>"U">U"""">U""">"""U"""""""!!!!!!!!!!!!3!!!3!!!!!!!!!!!!!r$   bad)fixed_time_gatedead_man_fallbackfallback_progressc                
   t        |       j                  t        d   |t        | i       d      }|j                  }|t
        k(  }|st        j                  d|fd|t
        f      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      dt        j                         v st        j                  t
              rt        j                  t
              nddz  }d	d
|iz  }t        t        j                  |            d x}}|j                  }d}||u }|st        j                  d|fd||f      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}}|j                  }d }||u }|st        j                  d|fd||f      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}}|j                   }d}||k(  }|st        j                  d|fd||f      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}}|j"                  }g }||k(  }|st        j                  d|fd||f      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$        z  }
|
j&                  } |       }| }|sddt        j                         v st        j                  |       rt        j                  |       nd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}
x}x}}y )NrM   r   )progress_trigger_sourcerP   rQ   rR   rT   rU   r   rV   rZ   r[   Frb   z*%(py2)s
{%(py2)s = %(py0)s.ok
} is %(py5)sr^   r`   ra   )z8%(py2)s
{%(py2)s = %(py0)s.progress_trigger
} is %(py5)sr   r]   )z/%(py2)s
{%(py2)s = %(py0)s.records
} == %(py5)szQassert not %(py6)s
{%(py6)s = %(py4)s
{%(py4)s = (%(py0)s / %(py1)s).exists
}()
}rz   rg   r{   )r,   r|   r}   r@   r~   r   r   r   r   r   r   r   r   r   okprogress_triggerr   r   rg   exists)rz   r   rU   r   r   r   r   r   r   r   r   r   @py_assert7s                r"   'test_06_forbidden_progress_trigger_failr      s    8

"
"%& ##Hb1	 # C ;;3;333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3333333366U6U?6U336U'4'4''''4''''''3'''3''''''4'''''''!!!!!!!!!!!!3!!!3!!!!!!!!!!!!!;;";";"33;"?*4*224244444444444444444444?444?44424444444444r$   c                   t        j                  t        j                  t        d               }d|d   d<   i }t	        |       j                  |t        | |      d      }|j                  }|t        k(  }|st        j                  d|fd|t        f      d	t        j                         v st        j                  |      rt        j                  |      nd	t        j                  |      d
t        j                         v st        j                  t              rt        j                  t              nd
dz  }dd|iz  }t        t        j                   |            d x}}|j"                  }d}||k(  }|st        j                  d|fd||f      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$        |v }|st        j                  d|fdt$        |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dz  }dd|iz  }t        t        j                   |            d }y )NrM   Tresultfallback_pending_non_blockingr   rO   rR   rT   rU   r   rV   rZ   r[   r\   r]   r^   r`   ra   rd   rf   rg   r:   rh   ri   rY   )r6   loadsr7   r}   r,   r|   r@   r~   r   r   r   r   r   r   r   r   r   r   rg   )rz   lrr:   rU   r   r   r   r   r   r   r   r   s               r"   )test_07_fallback_pending_closeout_allowedr      s   	DJJs#<=>	?B48BxL01D
8

"
"
#Hd3 # C ;;);/))));/))))))3)))3)));))))))/)))/)))))))!!!!!!!!!!!!3!!!3!!!!!!!!!!!!!d""""?d""""""?"""?""""""d"""d"""""""r$   c                :   t        |       j                  t        t        d   g      d      }|j                  d   }|d   }|t
        k(  }|st        j                  d|fd|t
        f      t        j                  |      d	t        j                         v st        j                  t
              rt        j                  t
              nd	d
z  }dd|iz  }t        t        j                  |            d 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   d   }
g }d }|
|u}|}|r|
d   }d}||k(  }|}|s+t        j                  d|fd|
|f      dt        j                         v st        j                  |
      rt        j                  |
      ndt        j                  |      dz  }dd|iz  }|j                  |       |r_t        j                  dfdf      t        j                  |      t        j                  |      dz  }d d!|iz  }|j                  |       t        j                  |d      i z  }d"d#|iz  }t        t        j                  |            d x}x}x}x}x}x}}|j                   }d}||k(  }|st        j                  d|fd$||f      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 )(Nself_chain_dispatch_candidater   r   r   r   r   rR   rj   r
   rk   rn   r_   r   Frb   rt   rr   rZ   r[   decision
self_guardr~   FAIL)is not)z%(py2)s is not %(py5)ssg)rX   r_   z%(py7)sra   )z%(py10)s == %(py13)s)py10py13z%(py15)spy15zassert %(py18)spy18r]   rU   r^   r`   )r,   r|   rK   r}   r   r
   r   r   r   r   r   r   r   r   append_format_boolopr   )rz   rU   r   r   r   r   r   r   r   r   r   r   r   @py_assert9@py_assert12@py_assert11r   @py_format14@py_format16@py_format17@py_format19s                        r"   test_08_self_chain_rejectedr      s+   
8

"
";<=> # C ++a.Cx=0=00000=0000=000000000000000000|%%%%%%%%%%%%%%%%%%%	Z	&B5T52T>5bm5v5mv555552T55555525552555T5555555mv555m555v55555555555555!!!!!!!!!!!!3!!!3!!!!!!!!!!!!!r$   c                   t        |       j                  t        t        d   g      d      }|j                  d   }|d   }|t
        k(  }|st        j                  d|fd|t
        f      t        j                  |      d	t        j                         v st        j                  t
              rt        j                  t
              nd	d
z  }dd|iz  }t        t        j                  |            d 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}}|j                  }
d}|
|k(  }|st        j                  d|fd|
|f      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}}|j                  }
d}|
|k(  }|st        j                  d|fd|
|f      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 )Nnon_anu_dispatch_candidater   r   r   r   r   rR   rj   r
   rk   rn   r_   r   Frb   rt   rr   rZ   r[   r]   rU   r^   r`   ra   r   )r,   r|   rK   r}   r   r
   r   r   r   r   r   r   r   r   r   r   r   s                r"   test_09_non_anu_rejectedr     s   
8

"
"89:; # C ++a.Cx=0=00000=0000=000000000000000000|%%%%%%%%%%%%%%%%%%%!!!!!!!!!!!!3!!!3!!!!!!!!!!!!!##(q(#q((((#q((((((3(((3(((#(((q(((((((r$   c                   t         d   d   }t        |       j                  t        |      d      }|j                  }t        |      }||k(  }|s7t        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      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                  |      dz  }dd|iz  }t        t        j                  |            d x}x}}|j                  D ]  }|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        k(  }
|
st        j                  d|
fd|	t        f      t        j                  |	      dt        j                         v st        j                  t              rt        j                  t              nddz  }dd|iz  }t        t        j                  |            d 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}
} y )N#quarantined_hold_packet_loop_resultrI   )rD   r   r   rR   )zW%(py2)s
{%(py2)s = %(py0)s.hold_routed_count
} == %(py7)s
{%(py7)s = %(py4)s(%(py5)s)
}rU   lenq)rW   rX   rY   r_   ra   r   r   proposal_typehold_packetrq   rr   rZ   r[   r   rj   r	   rk   rn   r_   r   Frb   rt   )r}   r,   r|   rK   hold_routed_countr   r   r   r   r   r   r   r   r   r   r	   )rz   r   rU   r   r   r   r   r   r   r   r   r   r   r   r   s                  r"   test_10_quarantine_hold_routedr     s   123GHA
8

"
"!s # C   *CF* F**** F******3***3*** ******C***C************F*******{{ '?#4}4#}4444#}444#444}44444448}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9~&&~&&&&~&&&~&&&&&&&&&&'r$   c                F   dd l }t        j                  t        dz  j	                  d            }i }t        |       j                  t        d   t        | |      d      }|j                  |j                         |       t        |d      }|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}||u }|slt        j                  d|fd||f      t        j                  |      t        j                  |      dz  }	dd|	iz  }
t        t        j                   |
            d x}x}}|j                  |d   |       y )Nr   z0schemas/runtime_event_enactor_result.schema.jsonr   r   rM   rN   rO   r   rF   ztask-2553+55.enactor-result.v1rR   rq   rr   rZ   r[   rs   Frb   rt   r   )
jsonschemar6   r   	WORKSPACE	read_textr,   r|   r}   r@   validateto_jsonr   r   r   r   r   r   )rz   r   rF   r:   rU   envr   r   r   r   r   s              r"   #test_11_enactor_result_schema_validr   !  s<   ZZJJ
)W)
%F
 D
8

"
"%&#Hd3/ # C
 v.
!#8N
OCx=<<<=<<<<<=<<<<=<<<<<<<<<<<(5(5((((5((((((5(((((((Hv.r$   c                F   t        t              }t        t              }t        |t        g      j                  t        dg d      g      }|j                  }|t        k(  }|st        j                  d|fd|t        f      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      d	t        j                         v st        j                  t              rt        j                  t              nd	d
z  }dd|iz  }t        t        j                   |            d x}}|j"                  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}	}t        t              }	|	|k(  }
|
s+t        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                  t              rt        j                  t              ndt        j                  |	      dt        j                         v st        j                  |      rt        j                  |      nddz  }dd|iz  }t        t        j                   |            d x}	}
y )N)r&   z0batch-task-2553-3track-normal-collector-50-51-52))zTRACK 1ztask-2553+50)zTRACK 2ztask-2553+51)zTRACK 3ztask-2553+52)batch_idexpected_tracks)batchesrR   rT   rU   r   rV   rZ   r[   r   all_authoritative_passTrb   rt   rr   z0%(py3)s
{%(py3)s = %(py0)s(%(py1)s)
} == %(py5)sr#   REAL_LEDGERr   rW   rl   rm   r_   r`   ra   )r#   r   r   r   r(   runr   r~   r   r   r   r   r   r   r   r   r   batch_results)rz   r   regrU   r   r   r   r   r   r   r   r   r   s                r"   !test_12_plus54_loop_no_regressionr   7  s   
{
#C
 
-C
3'
3
7
7F!		
 8 C ;;*;*****;*******3***3***;******************Q 89ATA9TAAAA9TAAA9AAATAAAAAAA$+$++++$++++++<+++<++++++++++++$++++++++++++++++r$   c                   t        t        t        d      }|j                  }d}||u }|st        j                  d|fd||f      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}}|j                  }d
}||k(  }|st        j                  d|fd||f      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        dt        t        t        ddt        z   d dt        gd
      }|j                  }d}||u }|st        j                  d|fd||f      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}}|j                  }d}||k7  }|st        j                  d|fd||f      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 )NANU)executor_keycollector_keycollector_roleFrb   r   gr^   r`   ra   SELF_COLLECTOR_FORBIDDENrR   )z6%(py2)s
{%(py2)s = %(py0)s.classification
} == %(py5)sztask-2553+55-reg13zself:zDG-reg13T)
task_idr  r  collector_owner_keyr  normal_collector_cron_idfallback_callback_cron_iddispatch_cron_idr&   no_fallback)z<%(py2)s
{%(py2)s = %(py0)s.registration_allowed
} is %(py5)svPASS)!=)z/%(py2)s
{%(py2)s = %(py0)s.verdict
} != %(py5)s)r   r)   r   r   r   r   r   r   r   r   r   classificationr   r(   registration_allowedr~   )rz   r  r   r   r   r   r   r  s           r"   ,test_13_plus49_owner_key_guard_no_regressionr  O  s	   $	A
 44545=4511459999999999999991999199999999999999'$$!(8!3"&#	A !!*U*!U****!U******1***1***!***U*******9999119r$   c                .   i }t        |       }|j                  t        d   t        | |      d      }t	        j
                  |j                               t	        j
                  t        |            z   }t        |v}|st        j                  d|fdt        |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dz  }d	d
|iz  }t        t        j                   |            d }t        j
                  }|j"                  }	i }
 |	t$        |
      } ||      }t        |v}|st        j                  d|fdt        |f      dt        j                         v st        j                  t              rt        j                  t              nddt        j                         v st        j                  t              rt        j                  t              ndt        j                  |      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |	      dt        j                         v st        j                  t$              rt        j                  t$              ndt        j                  |
      t        j                  |      t        j                  |      d	z  }dd|iz  }t        t        j                   |            d x}x}x}	x}
x}}|j                  t'        t        d   g      d      }|j(                  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}}y )NrM   r   rO   )not in)z%(py0)s not in %(py2)sr)   blobrh   ri   rY   )z%(py0)s not in %(py14)s
{%(py14)s = %(py4)s
{%(py4)s = %(py2)s.dumps
}(%(py12)s
{%(py12)s = %(py7)s
{%(py7)s = %(py5)s.get
}(%(py8)s, %(py10)s)
})
}r6   r:   rg   )	rW   rX   rY   r_   ra   py8r   py12py14zassert %(py16)spy16r   r   r   r   r   Frb   rt   rr   rZ   r[   )r,   r|   r}   r@   r6   r7   r   r   r)   r   r   r   r   r   r   r   r   getrg   rK   r   )rz   r:   r   rU   r  r   r   r   r   r   r   r   @py_assert13@py_format15r   scr   r   r   s                      r"   test_14_no_credential_exposurer  j  sg   DA
''%&#Hd3  C
 ::ckkm$tzz$( D 4848844::DdhhDDh&CD:&CDD8DDDDD8DDDDDDD8DDD8DDDDDD4DDD4DDD:DDDDDDdDDDdDDDhDDDDDDDDDDDDDDD&CDDDDDDDDDDDD	
;<=> 
 
B ::a=&/%/&%////&%///&///%///////r$   c                X   t         t        t        dz  t        dz  t        dz  t        dz  g}|D ci c]  }|j                         s|t	        |      ! }}t        t
        z  }|j                         rt	        |      nd }i }t        |       }|j                  t        j                  t        j                  d            t        | |      d       |j                         D ]Y  \  }}t	        |      }	|	|k(  }
|
s<t        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$                  |	      dt        j                          v st        j"                  |      rt        j$                  |      nddz  }t        j&                  | d      dz   d|iz  }t)        t        j*                  |            d x}	}
\ | t
        z  }	|	j                  } |       }|sddt        j                          v st        j"                  |       rt        j$                  |       nd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}	x}}|j                         rt	        |      nd }||k(  }|st        j                  d	|fd||f      dt        j                          v st        j"                  |      rt        j$                  |      nddt        j                          v st        j"                  |      rt        j$                  |      nddz  }dd|iz  }t)        t        j*                  |            d }y c c}w )Nz&memory/events/task-2553+53.result.jsonz&memory/events/task-2553+54.result.jsonz"anu_v3/callback_4tuple_registry.pyzanu_v3/runtime_event_loop.pyr   r   rN   rO   rR   r   r#   r!   hr   z mutatedz
>assert %(py7)sra   ry   rz   rg   r{   )z%(py0)s == %(py2)sreal_closeout_postreal_closeout_prerh   ri   rY   )r   REAL_LOOP_RESULTr   r   r#   rg   r,   r|   r6   r   r   r@   itemsr   r   r   r   r   r   _format_assertmsgr   r   )rz   watchedr!   r   real_closeoutr#  r:   r   r!  r   r   r   r   r   r   r   r"  r   r   r   s                       r"    test_15_existing_artifacts_byte0r)    s   <<<<8822G (/
>!!))+1l1o
>C
>/M'4'<'<'>]#D  DAGG

#--w-?@#Hd3/   		 41A3!#333!333333|333|333333A333A333333333!333!3333s(^33333334&1&//1/11111111H111H111111111111/1111111111'4'<'<'>]#D  !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+ ?s   P'P')r!   r   r=   r*   )r+   r   r=   r   )r+   r   r:   r<   )J__doc__
__future__r   builtinsr   _pytest.assertion.rewrite	assertionrewriter   r   r6   syspathlibr   pytest__file__resolver3   r   r*   pathremoveinsertanu_v3.callback_4tuple_registryr   anu_v3.callback_owner_validatorr   "anu_v3.proposal_authorization_gater   r   r	   r
   anu_v3.runtime_event_enactorr   r   r   r   r   r   anu_v3.runtime_event_loopr   r   r   anu_v3.self_collector_guardr   r   r   r}   r(   r)   r   r$  rg   r#   r,   r@   rK   r   r   r   r   r   markparametrizer   r   r   r   r   r   r   r  r  r)  r?   r$   r"   <module>r@     s  < #     
  N""$++2299	y>SXXHHOOC	N# 3y> "   
 djj
H	Iii!	 i."#EEs#:;; '(6
 rr 22;0	""	" 	H55"#"
"	)	'/,,06003r$   