
    f`j8                        d dl Z 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j        Zedz  Zedz  Zedz  Z ej        dej                  Zd	 Zd
 Zd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   story/story-canon.txtzscript/story-brief.jsonzstory/originality-report.jsonz[^\W_]+c                 r    t          j        |                                                                           S N)hashlibsha256
read_bytes	hexdigest)paths    script/validate-originality.pyshar      s(    >$//++,,66888    c                     t                               t          j        d|                                                     S )NNFC)TOKEN_REfindallunicodedata	normalizecasefold)texts    r   tokensr      s/    K1%>>GGIIJJJr   
   c           	            fdt          t          dt                     z
  dz                       D             S )Nc                 P    h | ]"}d                      ||z                      #S ) )join).0indexitemswidths     r   	<setcomp>zshingles.<locals>.<setcomp>   s3    dddUCHHU5./00dddr   r   r   )rangemaxlen)r"   r#   s   ``r   shinglesr(      sE    dddddeC3u::X]K]`aKaDbDb>c>cddddr   c                  N   t                                           rt                                          st          d          t	          j        t                              d                    } t          |                     d          dk    o\|                     d          dk    oCt          |                     d                    o!t          |                     d	                              }t          t          t                               d                              }g }d
}t          t                                                    D ] }|t          k    s.|                                rt!          j        d|j                  s=t'          d |dz  |dz  fD             d           }|bt          t          |                    d                              }t)          ||z            }|t+          dt)          |                    z  }	t+          ||	          }|                    |j        t/          |          ||	d           t          |                     d                    t          |                     d                    t          |                     d                    o!t          |                     d                    t          |                     d                    t          |                     d                    t          |                     d                    |d}
t1          |
                                          o|dk     }d||rdndt5          t                     dd||
||t7          j        t:          j                                                  d}t@          !                    t	          j"        |dd           d!z   d           tG          t	          j"        |t)          |          ||d"d#                     |rd$ndS )%Nzcanon/brief missingzutf-8)encodingprimary_story_familyu   Thanh mai trúc mãsecondary_story_familyu
   Không cófamily_enginerequired_payoffg        z^\d{3}-c              3   B   K   | ]}|                                 |V  d S r	   )is_file)r    r   s     r   	<genexpr>zmain.<locals>.<genexpr>.   s_        J  Jtz~  {G  {G  {I  {I  Jd  J  J  J  J  J  Jr   r   zstory/spoken-narration.txtr   )projectr   overlap_10gramscurrent_overlap_ratiosettingpremisestory_enginefamily_engine_lockmotifsclimaxending)r5   r6   r7   r9   r:   r;   family_adherencegMb`?passedfailedz_normalized Unicode 10-word shingle comparison; originality inside locked story-family framework)versionverifiedstatussource_canon_sha256method	thresholdworst_current_overlap_ratioauthority_axesprimary_story_family_preservedcomparisons
checked_atF   )ensure_asciiindent
)r@   rH   worst_ratiofamily_preserved)rK   r   )$CANONr0   BRIEFRuntimeErrorjsonloads	read_textboolgetr(   r   sortedPROJECTSiterdirPROJECTis_dirrematchnamenextr'   r&   appendstrallvaluesr   r   nowr   utc	isoformatRECEIPT
write_textdumpsprint)brief	family_okcurrentrH   worst	directoryother	other_setoverlapratioaxesr@   receipts                r   mainrw      s   ==?? 2%--// 20111Ju8899E		())-BB 	/II.//<?	/?++,,	/ ,--..	 I veoowo??@@AAGKEH,,..// 
H 
H	y'7'7'9'9*V_VdAeAe  J  J	4K(KYYuMu'v  J  J  J  LP  Q  Q=VEOOWO$E$EFFGG	g	)**#aW...E5!!y~s5zz^e  AF  G  G  	H  	H  	H  	H		),,--		),,--UYY~6677aDK_A`A`<a<auyy**++uyy**++uyy**++% D 4;;==!!3eemH&4((H"5zzs',*3"l8<00::<< G tz'aHHH4OZabbb	$*(3{;K;K\a  xA  B  B  QV  W  W  W  X  X  X11ar   __main__zOriginality gate blocked: )file)r   )r
   rS   r]   sysr   r   r   pathlibr   __file__resolveparentsr[   parentrY   rP   rQ   rh   compileUNICODEr   r   r   r(   rw   __name__exit	Exceptionexcrk   stderr r   r   <module>r      s     				 



     ' ' ' ' ' ' ' '      
$x..
 
 
"
"
*1
->))++
3
32:j"*--9 9 9K K Ke e e e1  1  1 h z   0300szBBBB s   B% %C*%CC