
    j_j                        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	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.jsonz!log/story-authority-baseline.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          t          gz   |z   }d |D             }|r%t          dd                    |          z             t          j        t                               d                    }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u ot+          f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                       }i d'||k    d(|	|k    d)||
cxk    o|k    nc d*d+|
d,z  cxk    od-k    nc d.|                    d          du o|                    d/          d0k    d1|                    d          du o|                    d1          du d2|d3|d4                    d          du o                    d5           d6|d7k    ot!          |          d7k    d8||
k    d9|t1          t                    k    d:|t1          t                    k    d;|d<                    d=          d>u d?t+          |                                          }t+          |                                          }||
||gt5          |
d,z  d@          t1          t                    t1          t                    dA|||dB}t7          t          j        |d>C                     |rdDndS )ENc                 ,    g | ]}t           d |ddz  S )zchapter-02dz.txt)CHAPTERS).0indexs     r   
<listcomp>zmain.<locals>.<listcomp>1   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>3   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>:   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   filesr   Tc              3      K   | ]c}                     t          |                    t                              i                                d           t	          |          k    V  ddS )r   N)r   r-   relative_toPROJECTr   )r%   r   baseline_filess     r   r5   zmain.<locals>.<genexpr>B   sz       > > 	3t//88992>>BB8LLPSTXPYPYY> > > > > >r   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_familyu   Thanh mai trúc mãsecondary_story_familyu$   Hào môn / tổng tài / liên hôn)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>X   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>Z   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>\   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]   canon_byte_identicalr\   duration_range(      <   brief_lockedstate
VOICE_LOCKarchitecture_lockedauthority_baseline_unchangedfamily_authority_lockedreport_verifiedissuesr[   
   report_word_countreport_spoken_hashreport_canon_hashreport_authority_hashesreport_promotion_unperformedpromotion_performedFreport_gates   )spokencanon)r   rG   accepted_rangeduration_minutes_at_231_wpmhashesr   r}   )ensure_asciir   )BRIEFOUTLINELEDGERIDENTITYREVEALPLANrangeBASELINEREPORTSPOKENCANONRuntimeErrorjoinjsonloadsr3   lenWORD_REfindallintr   allr   itemsr   valuesroundprintdumps)	authorityrE   requiredmissingbriefoutlinebaselinejoinedr   r   wordslowhighrB   baseline_matchrC   r[   report_wordsreport_spokenreport_canon	family_okrequired_report_gatesr}   authority_matchr   r   resultrA   r   ra   s                              @@@r   mainr   /   sN   64@IPP5B<<PPPHHffe<<xGH``X```G R;dii>P>PPQQQJu8899Ej**G*<<==GZ(('(::;;Fz(,,g,>>??H]]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\\'2..N\\*--5 # > > > >> > > ; ;N JJ1266M::nfjj9JB.O.OPPLJJz6::6H#lJ[J[+\+\]]M6IKabbL :LMMM77L		())-BB 	YII.//3YY	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f& 	cU****d**** 	"1111r1111	
 			*--5\%))G:L:LP\:\ 	w{{:66$>m7;;OdCeCeimCm 	' 	"9 	6::j11T9V&**XBVBV>V 	",DX"1D 	\U2 	ms6{{: 	\SZZ7 	"? 	'

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parentsr@   r$   r   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	.	...88
"*2BJ
?
?9 9 9    K  K  K \ z   *S**<<<< s   B9 9C.>%C))C.