
    j                        d Z ddlmZ ddlmZ ddlmZ dZdZdZ	dZ
dd	Zdd
ZddZddZddZddZddZdZdZ	 	 	 	 	 	 	 	 ddZddZ ed       G d d             ZddZddZy)u  anu_v3.executor_callback_contract — ANU-side mandatory callback doctrine.

task-2553+32 — restores the executor completion callback mandatory rule on the
ANU side as executable code (§3 lifecycle, §4.2/§4.6/§4.7/§4.8/§4.9, §6.13/14).

Standalone, zero-mutation: imports/edits ZERO tracked module. anu_v3.runtime_
reconcile_checkpoint (+31) is NOT mutated — see the additive sidecar
anu_v3.runtime_reconcile_checkpoint_recovery_layer (§5 additive-only).

NO-CRON note (9-R.1): zero cron register/remove here. This is a doctrine
contract object. +9a/+23/+25 system-sanctioned fallback cancel-on-success is a
separate designed lifecycle transition this module only *asserts is preserved*
(execute 0).
    )annotations)	dataclass)Listz$anu_v3.executor_callback_contract.v1)u   1. ANU 가 봇에 위임u   2. 봇이 작업 수행uR   3. 봇은 완료 직후 ANU 에 normal completion callback cron 발사 (MANDATORY)uh   4. ANU collector 가 결과 회수·검증·Codex audit·ANU-Codex adjudication·loop/next action 판단uO   5. fallback/dead-man callback = normal callback 누락·봇 stuck 대비 safetyu@   6. normal collector 성공 시 fallback cancel-on-success 적용u~   7. runtime registry/checkpoint = callback 누락·cron 꼬임·NO-CRON artifact read-only 복원 보조 계층 (대체 아님)u   registry/checkpoint 가 임의 신규 cron 추가 등록·cron 제거를 하지 않는다는 뜻. executor 가 작업 완료 후 ANU 에 normal completion callback 을 보내지 말라는 뜻이 절대 아님.Tc                      y)uI   §6.13 — the normal completion callback is the PRIMARY completion path.T r       8/home/jay/workspace/anu_v3/executor_callback_contract.pycallback_is_primaryr
   /       r   c                      y)uD   §8 / §6.13 — registry/checkpoint is NEVER the primary mechanism.Fr   r   r   r	   (registry_is_primary_completion_mechanismr   4       r   c                      y)uG   §4.7 / §6.13 — runtime checkpoint is a recovery layer, not primary.Tr   r   r   r	   checkpoint_is_recovery_layerr   9   r   r   c                      y)uG   §4.8 / §6.6 / §6.14 — fallback/dead-man callback is a safety path.Tr   r   r   r	   fallback_is_safety_pathr   >   r   r   c                      y)u  §4.9 / §6.7 — fallback cancel-on-success applies AFTER normal success.

    9-R.1: this is a system-sanctioned designed lifecycle transition
    (+9a/+23/+25 seam + live-verifier 5-cond AND). +32 only asserts the path
    is preserved — it executes ZERO cron remove itself.
    Tr   r   r   r	   .cancel_on_success_applies_after_normal_successr   C   s     r   c                      y)uK   9-R.1 — the +32 executor removes ZERO cron (회장 'cron 제거' 금지).Fr   r   r   r	    plus32_executor_removes_any_cronr   M   r   r   c                      y)uF   §6.5 — the executor's normal callback is NOT a cron-add ban breach.Fr   r   r   r	   2executor_completion_callback_is_cron_add_violationr   R   r   r   RESULT_READY_NO_NORMAL_CALLBACKNORMAL_COLLECTOR_COMPLETEDc                2    |rt         S | s|rt        S t        S )N)r   r   )result_presentdone_presentnormal_callback_registereds      r	   classify_no_normal_callbackr   \   s     "))..**r   c                    | t         k(  S )uD   §6.9 — RESULT_READY_NO_NORMAL_CALLBACK is recovery, not complete.)r   )classifications    r	   is_normal_lifecycle_completer"   f   s    777r   )frozenc                  &    e Zd ZU dZded<   ded<   y)CloseoutAuthorityChecku@   9-R.2 — separate finalization authority from lifecycle signal.bool finalization_authority_escalated'executor_self_lifecycle_outputs_presentN)__name__
__module____qualname____doc____annotations__r   r   r	   r%   r%   l   s    J '+*-11r   r%   c                ~    g }| j                   r|j                  d       | j                  s|j                  d       |S )u   §6.15 — only finalization-authority escalation is a violation.

    Producing the executor's own normal completion callback / result.json /
    report / .done is REQUIRED and is NOT a violation (9-R.2).
    uZ   repository/task-state finalization (closeout 확정) authority escalated -> FAIL (§6.15).zrexecutor self-task lifecycle outputs (normal callback / result.json / report / .done) missing -> REQUIRED (9-R.2).)r'   appendr(   )creasonss     r	   closeout_authority_violationr2   v   sG     G))*	
 44I	
 Nr   c                      	 y)NuZ   executor completion callback = MANDATORY. NO-CRON ≠ executor completion callback 금지.r   r   r   r	   doctrine_verdictr4      s    	;r   N)returnr&   )r   r&   r   r&   r   r&   r5   str)r!   r6   r5   r&   )r0   r%   r5   z	List[str])r5   r6   )r,   
__future__r   dataclassesr   typingr   DOCTRINE_SCHEMALIFECYCLE_NORMAL_STRUCTURENO_CRON_CORRECT_MEANING%EXECUTOR_COMPLETION_CALLBACK_REQUIREDr
   r   r   r   r   r   r   r   r   r   r"   r%   r2   r4   r   r   r	   <module>r>      s    # ! 8
 &  )- %




 #D 9 +++/+MQ++8 $2 2 2(r   