
    H`jd"                     f   d dl Z d dlZd dlZd dlZd dlmZmZ d dlmZ  ee          	                                j
        d         Zedz  Zd Zd Zd Zd	 Zed
k    rS	  ej         e                       dS # e$ r0Z ede ej                    ej        d           Y dZ[dS dZ[ww xY wdS )    N)datetimetimezone)Path   z log/production-verification.jsonc                     t           | z  }|                                sd S 	 t          j        |                    d                    S # t
          $ r Y d S w xY w)Nutf-8encoding)PROJECTis_filejsonloads	read_text	Exception)relpaths     script/validate-production.pyloadr      se    S=D<<>> tz$..'.::;;;   tts   'A
 

AAc                    t          j                    }|                     d          5 t          fdd          D ]}|                    |           	 d d d            n# 1 swxY w Y   |                                S )Nrbc                  .                          d          S )Ni   )read)handles   r   <lambda>zsha.<locals>.<lambda>   s    &++o">">     r   )hashlibsha256openiterupdate	hexdigest)r   digestblockr   s      @r   shar$      s    ^F	4 !F>>>>DD 	! 	!EMM%    	!! ! ! ! ! ! ! ! ! ! ! ! ! ! ! s   ,A##A'*A'c                     t          j        dddddddddt          |           g
d	d	d	
          }t          j        |j                  S )Nffprobez-verrorz-show_entrieszformat=duration,sizez9stream=index,codec_name,width,height,sample_rate,channelsz-ofr   T)capture_outputtextcheck)
subprocessrunstrr   r   stdout)r   results     r   prober0      sY    ^4/3ITvs4yy T	3 3 3F
 :fm$$$r   c            
         t          j        t          j        t	          t
          dz            dgt
                    } | j        rt          d          t          d          }t          d          }|r|r|	                    d          durt          d	          |	                    d
          }g }dddddddddd	}i }|
                                D ]\  }}t          |          }	||	d ud||<   |	s|                    d|z              9|		                    d          p|		                    d
          }
||                             |		                    d          du |
d           |		                    d          dur|                    d|z              |
|k    r|                    d|z              t          d          pi }t          d          pi }t          d          pi }t          d          pi }t          d          pi }t          d          pi }t          d          pi }t          d          pi }t
          dz  }t
          dz  }t
          dz  }t
          dz  }t
          d z  }t
          d!z  }|	                    d"          d#us|	                    d$          dus|                                r|	                    d%          |                                rt          |          nd k    sN|                                r9|	                    d&          |                                rt          |          nd k    s|	                    d'          dus|	                    d(          |	                    d%          k    s|	                    d)          t          t
          dz            k    s|	                    d*          |                                rt          |          nd k    sP|                                r<|	                    d+          |                                rt          |          nd k    r|                    d,           t          d- |	                    d.g           D             i           }|	                    d          dus|	                    d/          d0k    s|	                    d"          d#us|	                    d$          dus|	                    d1          d2k    s|	                    d3d2          d4k     s|                                r|                                rl|	                    d(          |                                rt          |          nd k    s/|	                    d%          |                                rt          |          nd k    s|	                    d&          |                                rt          |          nd k    s|	                    d          dus|	                    d%          |	                    d%          k    sp|	                    d)          t          t
          dz            k    sA|	                    d*          |                                rt          |          nd k    s|                                r|	                    d+          |                                rt          |          nd k    s|	                    d5          |	                    d(          k    s|	                    d6          |	                    d%          k    s\|	                    d7          t          t
          dz            k    s.|	                    d8          t          t
          dz            k    r|                    d9           |	                    d:i           	                    d          dur|                    d;           |	                    d:i           	                    d          dur|                    d<           |	                    d:i           	                    d=          d#ur|                    d>           |	                    d:i           	                    d=          d#ur|                    d?           |	                    d@i           }|	                    dA          dus|	                    dB          dur|                    dC           t
          dDz  }d }|                                s|                    dE           ni	 t!          |          }|	                    dFg           }dG |D             }dH |D             }t#          |          d4k    st#          |          d4k    sx|d2         	                    dI          dJk    sY|d2         	                    dK          |d2         	                    dL          fdMk    s|d2         	                    dI          dNk    r|                    dO           |	                    d+          t          |          k    r|                    dP           n<# t$          $ r/} |                    dQt	          |           z              Y d } ~ nd } ~ ww xY wt
          dRz                                  s|                    dS           d4| |sdTndU||dD|dV|t'          j        t*          j                                                  dW}!t0          j                            ddX           t0                              t9          j        |!d#dYZ          d[z   d\]           t=          t9          j        |!d         |d^d#_                     |!d         rd2nd4S )`Nz script/validate-workflow-copy.pyfull)cwdz#workflow-copy authority gate failedzscript/project-manifest.jsonzstory/promotion-report.jsonverifiedTz%manifest/promotion missing or invalidspoken_sha256zlog/tts-pronunciation.jsonz log/intro-tts-pronunciation.jsonzlog/tts-verification.jsonzlog/image-generation.jsonzimage/layout-manifest.jsonzlog/intro-render.jsonzlog/footage-job.jsonzlog/final-render.jsonzlog/metadata-verification.json)	pronunciationintro_pronunciationttsimageslayoutintrofootagefinalmetadata)r   presentzmissing_or_invalid_receipt:source_canon_sha256)r4   r@   zreceipt_not_verified:zreceipt_canon_mismatch:zlog/intro-voice.jsonzstory/tts-pronunciation.txtzaudio/intro-voice-source.txtz#audio/intro-voice-pronunciation.txtzaudio/intro-voice.wavz!script/pronunciation-lexicon.jsonzaudio/story-full.wavsemantic_content_changedFreverse_verifiedprojection_sha256lexicon_sha256pronunciation_verifiedsource_sha256pronunciation_receipt_sha256pronunciation_lexicon_sha256output_sha256pronunciation_tts_chainc              3   L   K   | ]}|                     d           dk    |V   dS )sourceaudioNget.0rows     r   	<genexpr>zmain.<locals>.<genexpr>g   s:      llcswwW_O`O`dkOkOkcOkOkOkOkllr   lexiconkindr;   non_lexicon_changesr   replacement_countr   intro_source_sha256intro_pronunciation_sha256"intro_pronunciation_receipt_sha256intro_voice_receipt_sha256intro_pronunciation_tts_chain	visual_qalayout_artwork_visual_qaintro_artwork_visual_qarequired&footage_visual_qa_must_be_not_required$final_visual_qa_must_be_not_requiredserver_verificationmirror_appliedsource_audio_discardedfootage_technical_verificationzoutput/final.mp4final_missingstreamsc                 <    g | ]}|                     d           |S )widthrN   rP   s     r   
<listcomp>zmain.<locals>.<listcomp>   s)    AAAc0@0@AcAAAr   c                 <    g | ]}|                     d           |S )sample_raterN   rP   s     r   rk   zmain.<locals>.<listcomp>   s)    GGGc0F0FGcGGGr   
codec_nameh264rj   height)i  i8  aacfinal_codec_dimensions_streamsfinal_hash_mismatchzfinal_probe:zoutput/info.txtmetadata_file_missingpassedfailed)r   r0   )versionr4   statusr@   receiptsr=   issues
checked_at)parentsexist_ok   )ensure_asciiindent
r   r	   )r4   rz   )r   )r+   r,   sys
executabler-   r   
returncodeRuntimeErrorr   rO   itemsappendr    r   r$   nextr0   lenr   r   nowr   utc	isoformatREPORTparentmkdir
write_textr   dumpsprint)"gatemanifest	promotioncanonrz   specsry   namer   datarL   r:   r6   r7   intro_voicer8   r;   r<   r=   pronunciation_pathintro_source_pathintro_projection_pathintro_voice_pathlexicon_path
audio_path	audio_rowfootage_server
final_pathfinal_proberh   videosaudiosexcreports"                                     r   mainr   (   s   >3>3w9[/[+\+\^dekrsssD B@AAA233H233I D9 D	j(A(A(M(MBCCCMM/**EF5A*-.()(4
 
E H[[]] < <	cCyy"%$d2BCC 	MM7$>???/00MDHH_4M4M488J+?+?4+G`fgghhh88Jt++MM1D8999U??MM3d:;;;.//52F566<"MABBHb-..4"K
*
+
+
1rC())/RE)**0bG())/RE #@@"@@#&KK!88@@L11J455UBB/00<<!))++ =011QcQkQkQmQm6wc:L6M6M6Mswxx##%% y-..H\H\H^H^3h3|3D3D3Ddhii77+,,D8877?##}'8'89L'M'MMM77122c'D`:`6a6aaa77122LL`L`LbLb7ls<7H7H7Hhlmm!!## n77?##:;M;M;O;O(YJUYZZ/000ll%8%<%<Y%K%KlllnpqqI
++477""6**g55""#=>>eKK""#566dBB""#899Q>>==,a00144 ((** 5$,,.. 5 ""?33RcRkRkRmRm8w<M8N8N8Nswxx""#677ZoZwZwZyZy  =DC@U<V<V<V  @D  E  E""#344lNbNbNdNd9n\9J9J9Jjnoo??:&&d22??.//3F3J3JK^3_3___??9::c'LnBn>o>ooo??9::T`ThThTjTj?ts<?P?P?Pptuu'')) v???++IYIaIaIcIc0m4D0E0E0Eimnn99*++/B/F/F/W/WWW991226I6M6MNa6b6bbb999::c'LnBn>o>ooo99122c'DZ:Z6[6[[[5666zz+r""&&z22$>>0111yyb!!%%j11==/000{{;##''
335@@>???yyb!!%%j11>><===[[!6;;N*++477>;M;MNf;g;gos;s;s6777--JK 5o&&&&
	5
++K!ooi44GAAWAAAFGGWGGGF6{{a3v;;!#3#3vay}}\7R7RV\7\7\aghiajananovawawy  AB  zC  zG  zG  HP  zQ  zQ  aR  Vb  ab  ab  fl  mn  fo  fs  fs  t@  fA  fA  EJ  fJ  fJ>???yy))S__<<3444 	5 	5 	5MM.3s88344444444	5''0022 /-...f*8\T\$(,{CCX\(B(B(L(L(N(N	 F Mt444
djeAFFFMX_```	$*&"4GGV[
\
\
\]]]z")11)s   #D+j 
k%kk__main__zProduction validation blocked: )file)r   r   r+   r   r   r   pathlibr   __file__resolver|   r   r   r   r$   r0   r   __name__exitr   r   r   stderr r   r   <module>r      sT         



 ' ' ' ' ' ' ' '      
$x..
 
 
"
"
*1
-	5	5    % % %~* ~* ~*B z   555CJGGGG s   A9 9B.>%B))B.