
    2Ƃj                        d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	m
Z
 ddlmZmZ  e
d      ZddZdd	Zdd
Zedk(  r e e             y)z4Fail-closed strict-rerun and cleanup retention gate.    )annotationsN)Path)CallableTypeVarRetentionErrorverifyTc                @    | t        d      t        |         |       S )NzHimmutable retention proof is required before strict rehearsal or cleanupr   )proofactions     strict_rerun_controller.pyretention_gatedr      s!    }ghh
5M8O    c                     t        j                         } | j                  dd       | j                  dt               | S )Nmode)zstrict-rehearsal-preflightzcleanup-preflight)choicesz--retention-proof)type)argparseArgumentParseradd_argumentr   )ps    r   parserr      s7    !ANN6#VNWNN&TN2Hr   c                 \   t               j                         	 t        j                  fd      } t	        t        j                  | dd             y# t        t        t        t        t        t
        j                  f$ r(}t	        d| t        j                         Y d }~yd }~ww xY w)	Nc                 (    dd j                   dddS )Nz%task26-strict-rerun-retention-gate-v1READYTF)schemastatusr   retention_verifiedcleanup_replay_permitted)r   )argss   r   <lambda>zmain.<locals>.<lambda>"   s    =II"&(-@
r   T),:)	sort_keys
separatorsr   z	BLOCKED: )file   )r   
parse_argsr   retention_proofprintjsondumpsr   OSError
ValueErrorKeyError	TypeErrorJSONDecodeErrorsysstderr)resultexcr!   s     @r   mainr7      s    8 D !5!5 8
  	djj4JGHGZ9dFZFZ[ 	#cjj1s   :A -B+B&&B+__main__)r   zPath | Noner   zCallable[[], T]returnr
   )r9   zargparse.ArgumentParser)r9   int)__doc__
__future__r   r   r,   r3   pathlibr   typingr   r   retention_controlr   r	   r
   r   r   r7   __name__
SystemExit r   r   <module>rC      sQ    : "   
  $ 4CL" z
TV
 r   