
    ^jr                        d dl Z d dlZd dlZd dlZd dlmZ  ee                                          j        d         Z	e	dz  Z
e	dz  Ze	dz  Ze	dz  Ze	dz  Ze	d	z  Ze	d
z  Ze	dz  Ze	dz  Ze	dz  Z ej        dej                  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)Path   zstory/chapterszstory/spoken-narration.txtzstory/story-canon.txtzstory/draft-report.jsonzscript/story-brief.jsonzscript/outline.jsonzscript/story-ledger.jsonzscript/identity-registry.jsonzscript/reveal-ledger.jsonzscript/production-plan.jsonu   [^\W_]+(?:['’-][^\W_]+)*c                 r    t          j        |                                                                           S N)hashlibsha256
read_bytes	hexdigest)paths    script/validate-story.pyshar      s(    >$//++,,66888    c                 ~    |D ]}|| v r
| |         c S |                      di           }|D ]}||v r
||         c S d S )N
aggregatesget)reportnamesnamer   s       r   report_valuer      sw        6>>$< L"--J $ $:d#### 4r   c                 :   |                      di           }|                      di           }|                     ||                     |                    }t          |t                    r.|                     d          du p|                     d          du S |du S )NchecksgatesverifiedTpassed)r   
isinstancedict)r   keyr   r   values        r   check_report_gater    %   s    ZZ"%%FJJw##EJJsEIIcNN++E% Lyy$$,K		(0C0Ct0KKD=r   c                  
   t           t          t          t          t          t
          g} d t          dd          D             }| t          t          t          gz   |z   }d |D             }|r%t          dd                    |          z             t          j        t                               d                    }t          j        t                              d                    }t          j        t                              d                    d	                    d
 |D                       dz   }t                              d          }t                              d          }t          t                               |                    }	t%          |d         d                   }
t%          |d         d                   }d | D             }                    di                               d                    dg                     }                    d                    dt          |                              }t)          ddd          }t)          dd          }t)          d          }|                    d          dk    op|                    d          dk    oW|                    d          |                    d          k    o+|                    d          |                    d          k    }d}fd |D             }r.t+          fd!|                                D                       }n-t+          fd"|                                D                       }||k    ||k    |
|	cxk    o|k    nc d#|	d$z  cxk    od%k    nc |                    d&          d'u o|                    d(          d)k    |                    d&          d'u o|                    d*          d'u |                    d&          d'u o                    d+           |d,k    ot          |          d,k    ||	k    |t/          t                    k    |t/          t                    k    |                    d-          d.u t+          |                                          d/}t+          |                                          }||	|
|gt3          |	d$z  d0          t/          t                    t/          t                    d1|||d2}t5          t          j        |d.3                     |rd4ndS )5Nc                 ,    g | ]}t           d |ddz  S )zchapter-02dz.txt)CHAPTERS).0indexs     r   
<listcomp>zmain.<locals>.<listcomp>0   s,    PPP%5e55555PPPr   r      c                     g | ]B}|                                 r|                                j        d k    3t          |          CS )r   )is_filestatst_sizestrr%   r   s     r   r'   zmain.<locals>.<listcomp>2   sA    ```TT\\^^`tyy{{GZ^_G_G_s4yyG_G_G_r   zStory gate missing artifacts: z, utf-8encodingz


c              3   f   K   | ],}|                     d                                           V  -dS )r/   r0   N)	read_textrstripr.   s     r   	<genexpr>zmain.<locals>.<genexpr>8   s<      ZZ4>>7>;;BBDDZZZZZZr   
target_wordsminmaxc                 8    i | ]}|j         t          |          S  )r   r   r.   s     r   
<dictcomp>zmain.<locals>.<dictcomp>>   s"    CCC	3t99CCCr   authority_hasheschapter_rowschapters_detailchapterschapters_present
word_countspoken_word_countaggregate_word_countspoken_sha256narration_sha256canon_sha256primary_story_familyuA   Thiên kim thật–giả / gia đình phản diện / trở vềsecondary_story_familyu   Cưới trước yêu sau)global_coherencecomprehensiondialogueaudiooriginalityrevealprimary_family_adherencesecondary_family_adherenceheadingproduction_marker
whitespaceduplicate_paragraphchapter_count
word_range
exact_joinc                 2    i | ]}|t          |          S r;   )r    )r%   r   r   s     r   r<   zmain.<locals>.<dictcomp>Q   s&    YYYCC*6377YYYr   c              3   P   K   | ] \  }}                     |          |k    V  !d S r   r   )r%   r   digestreport_hashess      r   r5   zmain.<locals>.<genexpr>S   s:      mmLD&m//55?mmmmmmr   c              3      K   | ];\  }}|d v 	                     |                    dd          dz             |k    V  <dS )>   outline.jsonreveal-ledger.jsonidentity-registry.jsonz.json _sha256N)r   replace)r%   r   r[   r   s      r   r5   zmain.<locals>.<genexpr>U   s        T  T^j^bdj  KO  SS  KS  KSfjjgr)B)BY)NOOSYY  KS  KS  KS  KS  T  Tr   (      <   r   Tstate
VOICE_LOCKarchitecture_lockedissues
   promotion_performedF)rX   canon_byte_identicalrW   duration_rangebrief_lockedri   family_authority_lockedreport_verifiedrV   report_word_countreport_spoken_hashreport_canon_hashreport_authority_hashesreport_promotion_unperformedreport_gates   )spokencanon)r   rB   accepted_rangeduration_minutes_at_231_wpmhashesr   rw   )ensure_asciir   )BRIEFOUTLINELEDGERIDENTITYREVEALPLANrangeREPORTSPOKENCANONRuntimeErrorjoinjsonloadsr3   lenWORD_REfindallintr   r   allitemsr   valuesroundprintdumps)	authorityr@   requiredmissingbriefoutlinejoinedry   rz   wordslowhighr=   r>   rV   report_wordsreport_spokenreport_canon	family_okrequired_report_gatesrw   authority_matchr   r   resultr   r\   s                            @@r   mainr   .   s?   64@IPP5B<<PPPHFFE22X=H``X```G R;dii>P>PPQQQJu8899Ej**G*<<==GZ(('(::;;F]]ZZQYZZZZZ]aaFw//FOOWO--E''((E
eN#E*
+
+Cu^$U+,,DCCCCCJJ1266M::nfjj9JB.O.OPPLJJz6::6H#lJ[J[+\+\]]M6IKabbL :LMMM77L		())-pp 	YII.//3NN	YKK.//599=S3T3TT	Y KK011UYY?W5X5XX	  ZYYYCXYYYL TmmmmTdTjTjTlTlmmmmm  T  T  T  Tn~  oE  oE  oG  oG  T  T  T  T  T& %U****d****1111r1111		*--5\%))G:L:LP\:\&{{:66$>m7;;OdCeCeimCm#,!::j11T9V&**XBVBV>V&",DX"1D)U2+s6{{:)SZZ7#2(.

3H(I(IU(RL//1122 F" 6==??##H+',US[!'<'< [[3u::RRAQR$ F 
$*V%
0
0
011111ar   __main__zStory gate blocked: )file)!r   r   resyspathlibr   __file__resolveparentsPROJECTr$   r   r   r   r   r   r   r   r   r   compileUNICODEr   r   r   r    r   __name__exit	Exceptionexcr   stderrr;   r   r   <module>r      s     				 



      
$x..
 
 
"
"
*1
-%%	/	/))	,	,++
)
)	-	-44	.	...
"*2BJ
?
?9 9 9    D  D  D N z   *S**<<<< s   B4 4C)9%C$$C)