
    UHj                       d Z ddlmZ 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	 ddl
mZ ej                  j                  d e e	e      j!                         j"                               ddlmZmZmZ ddlmZ  e	e      j!                         j0                  d   Zed	z  Zd
ZdZdZdZdZddhZ h dZ!h dZ"g dZ#g dZ$dddddddddgZ%ddddd d!Z&d>d"Z'd>d#Z(d?d$Z)d?d%Z*d@d&Z+dAd'Z,dBd(Z-dCd)Z.dDd*Z/dEd+Z0dFd,Z1dGd-Z2dHd.Z3dId/Z4dJd0Z5dKd1Z6	 	 	 	 	 	 	 	 	 	 	 	 dLd2Z7dMd3Z8dNd4Z9	 	 	 	 	 	 	 	 	 	 	 	 	 	 dOd5Z:	 	 	 	 	 	 	 	 	 	 	 	 dPd6Z;dQd7Z<	 	 dR	 	 	 	 	 	 	 dSd8Z=dTd9Z>dTd:Z?efdUd;Z@dVd<ZAeBd=k(  r eA        yy)WzISummarize descriptor scripts reached by save-selector opcode 0x20 mode 0.    )annotationsN)Path)Any)find_cns_stringsread_sectionsva_to_offset)GENERAL_HANDLER_NOTES   outmap1_01amap2_02di-D    `         >               >   (   @   A   B   C   D   )zruntime-active-orderz-descriptor-script-field-map-or-frontier-proofz!descriptor-script-gate-base-proofzstrict-source-hotspot)zDruntime active order/count selecting the current descriptor+4 scriptzFfield-map/frontier/encoded route-target evidence in descriptor scriptszSdescriptor script reader/writer hitting gate offsets 0xe8/0xea with a specific basez:strict map1_01a source hotspot or equivalent route triggerHwanse2.exez:descriptor table, script dword, CNS, and gate-offset scans)pathdescriptionz7out/save_selector_opcode20_slot_descriptor_writers.jsonz5descriptor table and runtime active-order writer pathz2out/save_selector_current_root_frontier_paths.jsonzPcurrent frontier/root/source/target reference addresses for encoded-target scansiT i*T i+T iD+T i+T )currentRootfrontierLeaffrontierReadersourceRecordtargetRecordc                    d| dS )N0x08x values    P/home/exedev/hwanse/tools/summarize_save_selector_opcode20_descriptor_scripts.pyhex32r+   :       c{    c                    d| dS )Nr%   02xr'   r(   s    r*   hex8r0   >   r,   r-   c                    | dz  r| dz
  S | S )Ni   i   r'   r(   s    r*   sign16r2   B   s    #fn57?7%7r-   c                    | dz  r| dz
  S | S )Nl        l        r'   r(   s    r*   sign32r4   F   s    "'*"45;?%?r-   c                p    | j                         s|S t        j                  | j                  d            S )Nutf-8encoding)existsjsonloads	read_text)r   fallbacks     r*   	load_jsonr>   J   s*    ;;=::dnngn677r-   c                "    | rt        | d      S d S )Nr   )intr(   s    r*   	parse_hexrA   P   s    "3ub>,,r-   c                v    t        ||      }||dz   t        |       kD  ry t        j                  d| |      d   S )N   z<Ir   )r   lenstructunpack_from)exesectionsvaoffsets       r*   dword_atrK   T   s?    (B'F~!c#h.dC033r-   c                    t        | |      d uS )N)r   )rH   r)   s     r*   is_pointer_dwordrM   [   s    %(44r-   c                    |j                  d      r|j                  d      ry t        | ||dz         }t        |      ||d d |d|ddS d dS )Nmapmap_rC   r%   04x)recordVaHexfilenamerO   
sceneIdHex)
startswithrK   r+   )rG   rH   row_vanamescene_ids        r*   field_record_for_cnsrZ   _   sm    ??5!T__V%<Xvz2HV}CRy-5-A8C.)	  HL	 r-   c                0    dddddj                  | d      S )NfillBranchStateTablereadSelectedStateAndBranchselectActiveStateSlotselectMatchingRuntimeSlot)r   r   r   r   otherget)opcodes    r*   selection_operationrd   k   s&    $*%)	
 
c&'r-   c                    | dk(  rdS dS )Nr   primaryBranchStatesecondaryBranchStater'   )stream_plus_1s    r*   state_tableri   t   s    #0A#5Q;QQr-   c                    t        | j                               D cg c]  \  }}|t        |      |d c}}S c c}}w )N)r)   valueHexcount)sorteditemsr0   countsr)   rl   s      r*   histogram_rowsrq   x   sD     #6<<>2 E5	 U	
  s   :c                l    t        | j                               D cg c]
  \  }}||d c}}S c c}}w )N)r)   rl   )rm   rn   ro   s      r*   string_histogram_rowsrs      s=     #6<<>2
 E5 	
  s   0c                    i }| D ]H  }|D ]A  }|j                  d      }||j                  |d      |j                  d      xs dz   ||<   C J t        |      S )Nr)   r   rl   )rb   rs   )
histogramsrp   	histogramrowr)   s        r*   merge_string_histogramsrx      ss    F K	 	KCGGG$E}"JJua0CGGG4D4IJF5M		KK !((r-   c                    | dk(  r'|dk(  ry|dk(  rdt        |       S dt        |       S | dk(  ry| d	k(  rd
t        |       S | dk(  ry| dk(  rdt        |       S y)Nr   r   z!context-f2-runtime-object-pointerr
   zstream2-object-pointer-z unsupported-object-pointer-mode-r   zglobal-selection-bufferr   z
slot-base-r   zsave-runtime-block-baser   zsaved-pointer-table-unknown-context-a8-source)r0   )rc   rh   stream_plus_2s      r*   context_a8_operand_sourcer|      s    ~D 6D ,T--@,ABB1$}2E1FGG~(~D/011~(~%d=&9%:;;&r-   c                    h d}ddh}g }t        | j                               D ]4  \  }}||v rd}n	||v rd}nd}|j                  ||t        |      |d       6 |S )N>   r   r    r!   r"   r#   currentroute-recordroute-context)labelrI   vaHexgroup)rm   rn   appendr+   )frontier_refscurrent_labelsroute_record_labelsrowsr   rI   r   s          r*   frontier_ref_targetsr      s    FN)>:DM//12 	rN"E))"E#E2Y	
 	 Kr-   c                b   d|dz  d fdt        |dz        | dz   fdt        |      | dz   fg}g }|D ]{  \  }}}	|D ]p  }
|
d   }|dk(  r	||dz  k(  }n|	d uxr |	|z   |k(  }|s'|j                  ||t        |       t        |      |t        |dz        t        |      |
d	   |
d
   ddd       r } |S )Nz	abs16-lowi  zsigned-rel16-site-plus2   zsigned-rel32-site-plus4rC   rI   l    r   r   blockedF)slotindex	siteVaHexrk   kind	scalarHex	targetHextargetLabeltargetGrouppromotionStatuspromotesRouteExecution)r2   r4   r   r+   )rW   r)   targetsr   	slot_namevaluesr   r   scalarrel_basetarget	target_vamatchess                r*   encoded_target_rows_for_dwordr      s    
efnd+	"F56>$:FQJG	"F5M6A:>F
 D"( fh 	FtI{" Y%78"$.Q8f3D	3QKK!"6]!%L"6J#67"9-%g%g#,*/ 	, Kr-   c                   i }i }i }| D ]  }|j                  d      }|j                  d      }|j                  d      }|r|j                  |d      dz   ||<   |r|j                  |d      dz   ||<   |sm|j                  |d      dz   ||<    | D cg c]  }|j                  d      dv r| }}| D cg c]  }|j                  d      dk(  r| }	}| rdnd	t        |       t        |      t        |	      dt        t        |j	                                     t        t        |j	                                     t        t        |j	                                     | d d
 dd
S c c}w c c}w )Nr   r   r   r   r
   >   r~   r   r   ;descriptor-script-encoded-route-target-scalars-nonpromoting5no-encoded-route-target-scalars-in-descriptor-scripts   r   
classificationrawScalarCandidateCount!routeProofRawScalarCandidateCount#routeContextRawScalarCandidateCountpromotingCandidateCounttargetGroupCountstargetLabelCounts
kindCounts
sampleRowsr   )rb   rD   dictrm   rn   )
r   group_countslabel_countskind_countsrw   r   r   r   route_proof_rowsroute_context_rowss
             r*   encoded_target_summaryr      s   #%L#%L"$K 	=&&wwv"."2"25!"<q"@L"."2"25!"<q"@L +a 81 <K	= 77=!%@@ 	 
 77=!_4 	   JH#&t9-01A-B/23E/F#$!&););)=">?!&););)=">?6+"3"3"5673Bi$ s   E$6E)c                   t        d | D              }t        d | D              }t        d | D              }t        d | D              }i }i }i }g }| D ]  }	|	j                  d      xs i j                         D ]  \  }
}|j                  |
d      |z   ||
<    |	j                  d      xs i j                         D ]  \  }
}|j                  |
d      |z   ||
<    |	j                  d      xs i j                         D ]  \  }
}|j                  |
d      |z   ||
<    t        |      d	k  s|j	                  |	j                  d
      xs g d d	t        |      z
           |rdnd||||t        t        |j                                     t        t        |j                                     t        t        |j                                     |dd
S )Nc              3  F   K   | ]  }|j                  d       xs d  yw)r   r   Nra   .0scans     r*   	<genexpr>z-merge_encoded_target_scans.<locals>.<genexpr>  s"     ODHH67<1<O   !c              3  F   K   | ]  }|j                  d       xs d  yw)r   r   Nra   r   s     r*   r   z-merge_encoded_target_scans.<locals>.<genexpr>  s#     aSWDHH%HINQNar   c              3  F   K   | ]  }|j                  d       xs d  yw)r   r   Nra   r   s     r*   r   z-merge_encoded_target_scans.<locals>.<genexpr>  s$     eW[dhh'LMRQRRer   c              3  F   K   | ]  }|j                  d       xs d  yw)r   r   Nra   r   s     r*   r   z-merge_encoded_target_scans.<locals>.<genexpr>  s"     Ut$((#<=BBUr   r   r   r   r   r   r   r   r   r   r   )sumrb   rn   rD   extendr   rm   )scans	raw_countroute_proof_countroute_context_countpromoting_countr   r   r   sample_rowsr   keyrl   s               r*   merge_encoded_target_scansr     s   OOOIa[`aae_deeUuUUO#%L#%L"$KK W88$78>BEEG 	AJC , 0 0a 85 @L	A88$78>BEEG 	AJC , 0 0a 85 @L	A88L17R>>@ 	?JC*sA6>K	?{b  6 <">TrCDT?TUVW  JH#,->/B#2!&););)=">?!&););)=">?6+"3"3"567!$ r-   c                   ||i d|dd dddg dg ddddd	g d
ddddg dg dddddddg dg i dg dddddddddddg dg dg dd dd dd dd d t        g       d!d"d#dd$dddi i i g d%S g }g }g }g }	g }
d}i }d}g }d}d}i }i }i }i }g }g }|j                         D ci c]  \  }}||
 }}}t        |      }t        t              D ]  }||d&z  z   }t        | ||      }| n|d'z  }|d(z	  d'z  }|d)z	  d'z  }d } |t        v r|d*z  }|j                  |d      d*z   ||<   |t        v }!|t        |      t        |      t        |      t        |      t        |      t        |      |d+v |d,k(  |!d-
}"|!r%|j                  |"       |"d.   r|d*z  }|"d/   r|d*z  }|t        v r|j                  |d      d*z   ||<   t        j                  |i       }#|#j                  d0      xs d1}$t!        ||      }%t#        |#j                  d2            }&|t        |      t        |      t        |      t        |      t        |      t        |d3z	  d'z        |#j                  d4      xs d1|&|$|&rt%        |||      nd |#j                  d5      xs d6|%|%rd7nd8d9}'|j                  |'       |'d2   rS|j                  |$d      d*z   ||$<   |%s9|j                  |$d      d*z   ||$<   |'d:   xs d;}(|j                  |(d      d*z   ||(<   t'        |      d<k  r|j                  t)        |'             ||v rb||   })|)|vr|j                  |)       |t        |      t        |      |)d=} t+        | |||)      }*|*r0|j                  |*       d>| d?<   |*d@   | d@<   nt-        ||      |d*z  }||v rC|t        |      t        |      ||   dA}+|j                  |+       | t)        |+      } n||   | dB<   t/        |||||      },|	j1                  |,       |,r@| >|t        |      t        |      t'        |,      t3        |,D +ch c]  }+|+dC   	 c}+      dD} n1|,r/| -t'        |,      | dE<   t3        |,D +ch c]  }+|+dC   	 c}+      | dF<   | |
j                  |         t        |	      }-i d|dt        |      dt        d|d|dt'        |      d|d	|d
t'        |      d|dt5        |      d|d|d|dt7        |j9                               dt5        |      d|i d|dt7        dG |D              dt7        dH |D              dt7        |j9                               dt7        dI |D              dt7        |j9                               dt;        |      dt;        |      dt;        |      d|r|dJ   nd dt=        dK t?        |      D        d       dt=        dL t?        |      D        d       dt=        dM t?        |      D        d       d |-d!|-dN   d#|-dO   d$|-dP   |-dQ   |-dR   |-dS   |-dT   |-dU   |
d dV d%S c c}}w c c}+w c c}+w )WNr   scriptVaHexscannedDwordCountr   	linkedCnsfieldRecordsfieldRecordCountpointerDwordCountcurrentFrontierDirectRefscurrentFrontierDirectRefCountselectionOpcodeCountselectionOffsetHistogramgateSelectionRowsgateWriterCountgateReaderCountbaseSetterOpcodeCountbaseSetterOpcodeHistogrambaseSetterSampleRowsbaseSetterRowsbaseSetterPointerLikeCountbaseSetterNonPointerCountcontextA8SetterRowCount"contextA8PointerLikeSetterRowCount!contextA8NonPointerSetterRowCount contextA8BaseExpressionHistogram*contextA8NonPointerBaseExpressionHistogram)contextA8NonPointerOperandSourceHistogramlastBaseSetterRowlastContextA8SetterRowlastNonPointerBaseSetterRow lastNonPointerContextA8SetterRowencodedTargetScanencodedTargetClassificationr   $encodedTargetRawScalarCandidateCount.encodedTargetRouteProofRawScalarCandidateCount)0encodedTargetRouteContextRawScalarCandidateCount$encodedTargetPromotingCandidateCountencodedTargetGroupCountsencodedTargetLabelCountsencodedTargetKindCountsinterestingRowsrC         r   r
   >   r   r   r   )
r   r   rk   	opcodeHex	operation
stateTableselectionBufferOffsetHexwritesSelectionBufferreadsSelectionBufferisGateOffsetr   r   baseExpressionunknownwritesContextA8r   rX   evidenceVaHex-z pointer-dword-low-byte-collisionznon-pointer-opcode-shaped-row)r   r   rk   r   streamPlus1HexstreamPlus2HexstreamPlus3HexhandlerNamer   r   contextA8OperandSourcehandlerEvidenceVaHexisPointerDwordshapeClassificationr  rz   r   )r   r   rk   cnsTfieldMapRecordStartrU   )r   r   rk   r   currentFrontierTargetr   )r   r   rk   encodedTargetHitCountencodedTargetLabelsr
  r  c              3  ,   K   | ]  }|d    s	d  ywr  r
   Nr'   r   rw   s     r*   r   z!script_summary.<locals>.<genexpr>  s     )a3O_K`!)a   
c              3  ,   K   | ]  }|d    r	d  ywr  r'   r  s     r*   r   z!script_summary.<locals>.<genexpr>  s     (dscRbNc(dr  c              3  8   K   | ]  }|d    s	|d   sd  yw)r   r  r
   Nr'   r  s     r*   r   z!script_summary.<locals>.<genexpr>  s%      2
S1B-CL\H]A2
   
c              3  ,   K   | ]  }|d    s	|  yw)r   Nr'   r  s     r*   r   z!script_summary.<locals>.<genexpr>  s     QS#>O:PSQr  c              3  ,   K   | ]  }|d    r	|  yw)r  Nr'   r  s     r*   r   z!script_summary.<locals>.<genexpr>  s     TScBR>SSTr  c              3  8   K   | ]  }|d    s	|d   r|  yw)r   r  Nr'   r  s     r*   r   z!script_summary.<locals>.<genexpr>  s!     oS#>O:PY\]mYnSor  r   r   r   r   r   r   r   r   0   ) r   rn   r   rangeSCRIPT_SCAN_DWORDSrK   SELECTION_OPCODESrb   GATE_OFFSETSr+   r0   rd   ri   r   BASE_SETTER_OPCODESr	   rM   boolr|   rD   r   rZ   r   r   r   rm   rq   r   r   rs   nextreversed).rG   rH   strings	script_var   r   
linked_cnsfield_recordsfrontier_hitsencoded_rowsinteresting_rowspointer_countselection_offset_countsselection_opcode_countgate_selection_rowsgate_writer_countgate_reader_countbase_setter_countscontext_a8_base_counts"context_a8_non_pointer_base_counts%context_a8_non_pointer_operand_countsbase_setter_sample_rowsbase_setter_rowsr   r)   frontier_by_vaencoded_targetsr   rW   rc   rh   r{   rw   is_gate_offsetselection_rownotebase_expressionpointer_likewrites_context_a8base_setter_rowoperand_sourcerX   field_recordhitencoded_hitsencoded_scans.                                                 r*   script_summaryrA  0  s	    )
I)
4)
  )
 	)

 B)
 )
  )
 ()
 ,Q)
 #A)
 ')
  )
 q)
 q)
 $Q)
  (!)
" #B#)
$ b%)
& )!')
( ())
* &q+)
, 1!-)
. 0/)
0 /1)
2 9"3)
4 85)
6  7)
8 %d9)
: *4;)
< /=)
>  !7!;?)
@ *+bA)
B 3AC)
D =aE)
F AB45(*(*')!Q)
 )	
V JMMLM.0)+-/9;&<>) 7D7J7J7LM|ueeUlMNM*=9O)* t)UQY&h/=!t+",%)&&"a'"5L5P5PQ^`a5bef5f#M2*l:Nv!%L!&\08)-8,0,?)/<)?(.$ .M #**=9 !89%*% !78%*%(();)?)?)JQ)Nv&(,,VR8D"hh'78EIO+He<L $TXX.?%@ Av!%L!&\"&}"5"&}"5"&t';"<#xx/<9#4"1 ) .fm]S.2(,(A(HS".MY'I_~#O& ##O401:P:T:TUdfg:hkl:l&7#:>>PQRUVV 7G &55M%N%mRmN=AA.RSTWXX :.I *+b0'..tO/DEG5>D:%!!$'v!%L	C 0XvtLL$$\2-1)*$0$>L!(E*6QMN"v!%L(/	C   %{3i/=e/D+,4VUOUZ\efL)CKv!%L),\):'-\.Zcs=/A.Z'[C co+.|+<C'()/|0\]1C0\)]C%&?##C(it)l *,7L4	4uY'4 	/4 	Z	4
 	4 	C.4 	]4 	$]4 	(]);4 	 64 	#N3J$K4 	04 	,4 	,4 	 %7%>%>%@!A4  	$^4F%G!4" 	 7#4$ 	*%4& 	%c)a7G)a&a'4( 	$S(d6F(d%d)4* 	"3'='D'D'F#G+4, 	-c 2
)2
 /
-42 	,S1S1Z1Z1\-]344 	+,ABX,Y546 	56KLn6o748 	45JKp5q94: 	5E-b14;4< 	!$QH%56Q#
=4D 	&tTH%56T(
E4L 	+DoH%56o-
M4T 	\U4V 	&|4D'EW4X 	/=V0WY4Z 	9,Gj:k[4\ =IIn<o0<=V0W$01D$E$01D$E#/#=+CR0g4 4s N^ /[ 1]s   4YY3Y
c                   |j                  d      xs g }g }t        t              D ]@  t        fd|D        i       }t	        |j                  d            xs t
        dz  z   }t	        |j                  d            xs t        | ||      }	t	        |j                  d            xs |	rt        | ||	      nd }
t	        |j                  d            xs |	rt        | ||	dz         nd }t	        |j                  d            xs |	rt        | ||	d	z         nd }t        | |||
d
|      t        | |||d|      t        | |||d|      g}|j                  i ddt        |      d|	t        |	      nd d|
t        |
      nd d|t        |      nd d|t        |      nd d|d|d   d   d|d   d   d|d   d   d|d   d   d|d   d   d|d   d   d|d   d   d|d   d   d |d   d!   d"|d   d#   |d   d$   |d   d%   |d   d&   |d   d'   |d   d(   |d   d)   |d   d*   |d   d+   |d   d,   |d   d-   |d   d.   |d   d/   |d   d0   d1       C |S )2NdescriptorRowsc              3  L   K   | ]  }|j                  d       k(  s|  yw)r   Nra   )r   rw   r   s     r*   r   z"descriptor_rows.<locals>.<genexpr>0  s!     S39IU9R3Ss   $$
entryVaHexrC   descriptorVaHexscript0VaHexscript4VaHexscript8VaHexr   script+0script+4script+8r   scriptsscript0LinkedCnsr   r   script4LinkedCnsr
   script4FieldRecordCountr   $script4CurrentFrontierDirectRefCountr   script4SelectionOpcodeCountr   script4BaseSetterOpcodeCountr   !script4BaseSetterPointerLikeCountr    script4BaseSetterNonPointerCountr   script4ContextA8SetterRowCountr   )script4ContextA8PointerLikeSetterRowCountr   r   r   r   r   r   r   r   r   r   r   r   r   r   )(script4ContextA8NonPointerSetterRowCount0script4ContextA8NonPointerOperandSourceHistogramscript4LastBaseSetterRowscript4LastContextA8SetterRow"script4LastNonPointerBaseSetterRow'script4LastNonPointerContextA8SetterRowscript4GateWriterCountscript4GateReaderCount+script4EncodedTargetRawScalarCandidateCount5script4EncodedTargetRouteProofRawScalarCandidateCount7script4EncodedTargetRouteContextRawScalarCandidateCount+script4EncodedTargetPromotingCandidateCount"script4EncodedTargetClassification)
rb   r  DESCRIPTOR_LIMITr  rA   DESCRIPTOR_TABLE_VArK   rA  r   r+   )rG   rH   r   r   descriptor_writerswriter_rowsr   
writer_rowentry_va
descriptorscript0script4script8rM  r   s                 @r*   descriptor_rowsro  &  s    %(()9:@bKD'( 1S+SUWX
Z^^L9:]>QTY\]T]>]z~~.?@AfXcS[]eEf
JNN>:;|gqhXb@cw{JNN>:;  AkuhXbefXf@g{JNN>:;  AkuhXbefXf@g{3'7JV3'7JV3'7JV

 	 %
U%
%/%
 J4JuZ0PT%
 g.AE'Nt	%

 g.AE'Nt%
 g.AE'Nt%
 w%
 
; 7%
 
; 7%
 &wqz2D'E%
 3GAJ?^4_%
 *71:6L+M%
 +GAJ7N,O%
 0<X1Y%
 /
;V0W%
  -gaj9R.S!%
" 8Dh9i#%
$ 9@
Cf8g@G
;A )0
3F(G-4QZ8P-Q29!*=Z2[7>qzBd7e&-aj1B&C&-aj1B&C;B1:Fl;mELQZ@F HOqzBH <C1:Fl;m29!*=Z2[I%
 %	1d Kr-   c                   t        t              }t        | j                  d            }|||d<   | j                  d      xs g D ]  }|j                  d      st        |j                  d            }|||d<   |j                  d      xs g }|j                  d      xs g }|rt        |d	         }|||d
<   |rt        |d	         }|||d<    |S  |S )NrootHexr   leafRowstraceContainsFrontierReaderleafPointerHexr    sourceRecordRefstargetRecordRefsr   r"   r#   )r   DEFAULT_FRONTIER_REFSrA   rb   )	current_root_frontier_pathsrefsrootleafleaf_vasource_refstarget_refs	source_var   s	            r*   frontier_refs_from_summaryr  d  s    %&D044Y?@D"]+//
;Ar 8812)9 :;G"'.^$((#56<"K((#56<"K%k!n5	(+4D(%k!n5	(+4D(K!  Kr-   c                \   t        |       }t        | |      }||nt        t        dz  i       }||nt        t        dz  i       }t	        |      }t        | ||||      }t        d |D              }t        d |D              }t        d |D              }	t        d |D              }
t        |D cg c]  }|d   D ]  }|d   d	k(  r|d
     c}}      }t        |D cg c]  }|d   D ]  }|d
   	  c}}      }t        d |D              }t        d |D              }t        d |D              }t        d |D              }t        d |D              }t        d |D              }t        d |D              }t        d |D              }i }i }i }i }t        |D cg c]  }|d   D ]  }|d   d	k(  r|d     c}}      }t        |D cg c]  }|d   D ]  }|d   	  c}}      }|D ]  }t        d |d   D              }|d   D ]"  }|d   }|j                  |d      |d   z   ||<   $ |d   D ]"  }|d   }|j                  |d      |d   z   ||<   $ |d   } | r| d   }|j                  |d      dz   ||<   |d   }!|!s|!d   }|j                  |d      dz   ||<    t        d |D              }"t        d |D              }#t        d  |D              }$t        d! |D              }%g }&d"D ]  }'|D cg c]  }|d   D ]  }|d   |'k(  s|  }(}}|&j                  |'t        |(      t        d# |(D              t        d$ |(D              t        d% |(D              t        d& |(D              t        d' |(D              t        d( |(D              t        d) |(D              t        d* |(D              t        d+ |(D              t        d, |(D              d-        d.})i d/t        d0t        d1|j                  d1      xs t        t               d2t        |      d3t"        d4|j%                         D *ci c]  \  }*}|*t        |       c}}*d5|d6|d7|d8|d9|d:   d;|d<   d=|d>   d?|d@   dA|dB   dC|dD   dE|dF   i dG|dH   dI|	dJ|
dK|dL|d:   dM|d<   dN|d>   dO|d@   dP|dB   dQ|dD   dR|dF   dS|dH   dT|dU|dV|dW|dX|i dY|dZ|d[|d\t'        |      d]t'        |      d^|d_t'        |      d`t'        |      da|dbt)        t*              D cg c]  }t-        |       c}dc|"dd|#de|$df|%dg|&dhdidjdidkdldmdidit.        t0        t2        t        t2              dm|)dnS c c}}w c c}}w c c}}w c c}}w c c}}w c c}}*w c c}w )oN3save_selector_opcode20_slot_descriptor_writers.json.save_selector_current_root_frontier_paths.jsonc              3  &   K   | ]	  }|d      yw)rP  Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s     Mc";<M   c              3  &   K   | ]	  }|d      yw)rQ  Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s     $aUXS)O%P$ar  c              3  :   K   | ]  }|d    D ]	  }|d      yw)rM  r   Nr'   r   rw   scripts      r*   r   z build_summary.<locals>.<genexpr>  s*     bSVW`Sab&!34b4b   c              3  :   K   | ]  }|d    D ]	  }|d      yw)rM  r   Nr'   r  s      r*   r   z build_summary.<locals>.<genexpr>  s+      vSgjktgu v]c(G!H v!H vr  rM  r   rK  r   c              3  &   K   | ]	  }|d      yw)rR  Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s     (\PS-J)K(\r  c              3  :   K   | ]  }|d    D ]	  }|d      yw)rM  r   Nr'   r  s      r*   r   z build_summary.<locals>.<genexpr>  s+     $qbefobp$qX^V,B%C$q%C$qr  c              3  &   K   | ]	  }|d      yw)rS  Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s     #XCC(F$G#Xr  c              3  &   K   | ]	  }|d      yw)rT  Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s     0j^a5X1Y0jr  c              3  &   K   | ]	  }|d      yw)rU  Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s     /h\_4V0W/hr  c              3  &   K   | ]	  }|d      yw)rV  Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s     )`TW#.N*O)`r  c              3  &   K   | ]	  }|d      yw)rW  Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s     6xlos;f7g6xr  c              3  &   K   | ]	  }|d      yw)rX  Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s     5vjmc:d6e5vr  r   c              3  2   K   | ]  }|d    dk(  s|  yw)r   rK  Nr'   r   r  s     r*   r   z build_summary.<locals>.<genexpr>  s     [&fVnPZ>Zv[s   r   r)   r   rl   r   r[  r   r
   r]  c              3  &   K   | ]	  }|d      yw)r^  Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>       #RcC(@$A#Rr  c              3  &   K   | ]	  }|d      yw)r_  Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  r  r  c              3  :   K   | ]  }|d    D ]	  }|d      yw)rM  r   Nr'   r  s      r*   r   z build_summary.<locals>.<genexpr>  *     gcX[\eXfgf'8 9g 9gr  c              3  :   K   | ]  }|d    D ]	  }|d      yw)rM  r   Nr'   r  s      r*   r   z build_summary.<locals>.<genexpr>  r  r  )rJ  rK  rL  c              3  &   K   | ]	  }|d      yw)r   Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s     #Z6F+=$>#Zr  c              3  &   K   | ]	  }|d      yw)r   Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s     0t]c8W1X0tr  c              3  &   K   | ]	  }|d      yw)r   Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>        8CI=>8r  c              3  &   K   | ]	  }|d      yw)r   Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s      BMSGHBr  c              3  &   K   | ]	  }|d      yw)r   Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  r  r  c              3  &   K   | ]	  }|d      yw)r   Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s     'b6/E(F'br  c              3  &   K   | ]	  }|d      yw)r   Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>       "X6*;#<"Xr  c              3  &   K   | ]	  }|d      yw)r   Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  r  r  c              3  &   K   | ]	  }|d      yw)r   Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s     *hQW62K+L*hr  c              3  &   K   | ]	  }|d      yw)r   Nr'   r  s     r*   r   z build_summary.<locals>.<genexpr>  s      5@F:;5r  )r   scriptCountr   r   r   r   r   r   r   r   r   r   a  The descriptor table reached by opcode 0x20 mode 0 resolves to character, battle, or object scripts, not field-map transition records. In the scanned descriptor+4 scripts there are zero field-map CNS records and zero direct or encoded-scalar references to the current map1_01a frontier leaf/reader/source/target addresses. They do contain base-selector opcode-shaped rows, but most 0x28/0x40/0x44 rows are pointer dwords whose low byte merely collides with a handler opcode. The non-pointer context+0xa8 setter-shaped rows are only 0x42 mode-0 context+0xf2 runtime object selection, not a fixed route/gate base or gate-specific setup. None of the descriptor+4 selection-buffer reader/writer rows targets gate offsets 0xe8 or 0xea, and the same gate-offset count is zero across descriptor+0, descriptor+4, and descriptor+8 scripts. So a specific gate base is not proven. This descriptor path therefore does not promote map1_01a -> map2_02d; runtime active order/count and strict hotspot evidence are still required.sourcer   descriptorTableVaHexdescriptorRowCountscriptScanDwordCountfrontierRefsrC  rP  rQ  script4EncodedTargetScanrd  r   r`  r   ra  r   rb  r   rc  r   script4EncodedTargetGroupCountsr   script4EncodedTargetLabelCountsr   script4EncodedTargetKindCountsr   allScriptFieldRecordCount&allScriptCurrentFrontierDirectRefCountallScriptEncodedTargetScan$allScriptEncodedTargetClassification-allScriptEncodedTargetRawScalarCandidateCount7allScriptEncodedTargetRouteProofRawScalarCandidateCount9allScriptEncodedTargetRouteContextRawScalarCandidateCount-allScriptEncodedTargetPromotingCandidateCount!allScriptEncodedTargetGroupCounts!allScriptEncodedTargetLabelCounts allScriptEncodedTargetKindCountsrR  allScriptSelectionOpcodeCountrS  rT  rU  rV  rW  rX  'script4ContextA8BaseExpressionHistogram1script4ContextA8NonPointerBaseExpressionHistogramrY  +script4LastContextA8BaseExpressionHistogram5script4LastNonPointerContextA8BaseExpressionHistogram2allScriptContextA8NonPointerOperandSourceHistogramgateOffsetsHexr^  r_  allScriptGateWriterCountallScriptGateReaderCountscriptSlotAggregateRowsscript4SpecificGateBaseProvenF allScriptsSpecificGateBaseProvenz character/battle/object-resourceTr   )descriptorScriptClassruntimeActiveOrderRequiredcontrolPathProofStatus
proofFound"opcode20DescriptorScriptProofFound%failedOpcode20DescriptorScriptGateIdsmissingEvidenceevidenceRefsevidenceRefCountr   
conclusion)r   r   r>   OUTr  ro  r   r   rx   r  rb   r   rD   SOURCETARGETr+   rf  r  rn   rs   rm   r  r0   *FAILED_OPCODE20_DESCRIPTOR_SCRIPT_GATE_IDS+OPCODE20_DESCRIPTOR_SCRIPT_MISSING_EVIDENCE(OPCODE20_DESCRIPTOR_SCRIPT_EVIDENCE_REFS)+rG   rg  rx  rH   r   r   r   script4_field_countscript4_frontier_ref_countall_field_countall_frontier_ref_countrw   r  script4_encoded_scanall_encoded_scanscript4_selection_opcode_countall_selection_opcode_countscript4_base_setter_count&script4_base_setter_pointer_like_count%script4_base_setter_non_pointer_countscript4_context_a8_setter_count,script4_context_a8_pointer_like_setter_count+script4_context_a8_non_pointer_setter_countscript4_context_a8_base_counts*script4_context_a8_non_pointer_base_counts#script4_last_context_a8_base_counts/script4_last_non_pointer_context_a8_base_counts0script4_context_a8_non_pointer_operand_histogram3all_script_context_a8_non_pointer_operand_histogramrm  histogram_rowr)   last_contextlast_non_pointer_contextscript4_gate_writer_countscript4_gate_reader_countall_gate_writer_countall_gate_reader_countscript_slot_aggregate_rowsr   slot_scriptsr  r   s+                                              r*   build_summaryr  |  sU	   
 S!HsH-G ) 	sRRTVW  '2 	$sMMrR  
 //JKM3'=BTUDMMM!$$a\`$a!abbbO  vTX vv57)n7 &>Z' 	"#7#7  23)n3  	"#3#3 
 &)(\W[(\%\"!$$qt$q!q ##XSW#X X-00jei0j-j*,//hcg/h,h)&))`[_)`&`#366xsw6x3x0255vqu5v2v/57"AC.:<'FH37NP)nP &>Z' 	:;P;P 84 ;RS)nS  	:;S;S ;7
  [C	N[[$%GH 	zM!'*E4R4V4VW\^_4`cpqxcy4y*51	z %%QR 	M!'*E:>>uaH=Y`Kaa 7u=	
 :; !12E9\9`9`afhi9jmn9n/6#&'P#Q #,-=>E?CCE1MPQQ <EB#( !$#RT#R R ##RT#R RgTgggTgg!#4 *.f3S^f6vV\~aeOefff"))|, ##Z\#Z Z-00tgs0t-t47 8MY8 5 ?B BWcB ? 58 8MY8 5 %('bUa'b$b""X<"XX""X<"XX'**h[g*h'h14 5JV5 2%+
 	2	6 I&I&I 	 2 6 67M N lRWXkRlI 	c$i	I
 	 2I 	ATATAVWe,WI 	$I 	"#6I 	/0JI 	#$8I 	-.BCS.TI 	67KLe7fI 	@AU/B
I  	BCW1D
!I& 	67KLe7f'I( 	*+?@S+T)I* 	*+?@S+T+I, 	)*>|*L-I. 	$_/I0 	12H1I2 	%&63I4 	/0@AQ0R5I6 	89IJc9d7I8 	BCS/D
9I> 	DEU1F
?ID 	89IJc9dEIF 	,-=>Q-RGIH 	,-=>Q-RIIJ 	+,<\,JKIL 	&'EMIN 	()COIP 	'(AQIR 	,-SSIT 	+,QUIV 	)*IWIX 	45aYIZ 	34_[I\ 	23HIg3h]I^ 	<=RS}=~_I` 	;<laIb 	67LMp7qcId 	@AV;B
eIj 	=>qkIl 	F<4HI54;ImIn 	!";oIp 	!";qIr 	#$9sIt 	#$9uIv 	"#=wIx 	(yIz 	+E{I| "D&*"+.31[F@ HI$ QI IC73"PS> gV X` Js0   2V
"V
"V
V
=VV V#
2V)
c                 r	   dj                  d | d   D              xs d}g ddd| d    d	| d
    d| d    dd| d    d| d    dd| d    d| d    d| d    d| d    d| d    d| d    d	d| d     d!| d"    d#| d$    d%| d&    d'| d(    d)| d*    d+| d,    d-| d.| d/    d0dj                  | d1          d2| d3    d0dj                  | d1          d4| d5    d6dj                  | d1          d2| d7    d6dj                  | d1          d4| d8    d9| d:    d;| d<    d=| d>    d?| d@    d| dA    d| dB    d| dC    d	dD| dE    dF| dG    dH| dI    ddJ| dK    ddL| dM    dd| dN   ddOd}|j                  dP | dQ   D               |j                  g dR       |j                  dS | dT   D               |j                  g dU       |j                  dV | dW   D               |j                  g dX       | dY   j                         D ]  \  }}|j                  dZ| d[| d\        |j                  g d]       | d^   D ]\  }|j                  dZ|d_    d`|da    d`|db    d`|dc    d`|dd    de|df    de|dg    d`|dh    d`|di    d`|dj    d`|dk    d`|dl    dm       ^ |j                  g dn       | do   D ci c]  }|dp   |dq    }}| dr   D ci c]  }|dp   |dq    }}| ds   D ci c]  }|dp   |dq    }}| dt   D ]b  }|j                  du|dp    dv|dq    d`|j	                  |dp   dw       d`|j	                  |dp   dw       d`|j	                  |dp   dw       dm       d |j                  g dx       | d   D ]   }|j                  du|dp    dv|dq    dm       " |j                  g dy       | dz   D ]  }|d{   }	|	r|	d|   nd}
|j                  dZ|d}    d[|d~    dvdj                  |d         xs d d`dj                  |d         xs d d`|d    d`|d    d`|d    de|d    de|d    d`|d*    d`|d,    d[|
 dv|d3    d`|d5    dm        |j                  d       dj                  |      S c c}w c c}w c c}w )N, c              3  6   K   | ]  }|d     d|d      ywr)   :rl   Nr'   r  s     r*   r   zmarkdown.<locals>.<genexpr>A  +      , w<.#g,(,   rY  r   z.# Save Selector Opcode 0x20 Descriptor Scripts z	- route: r  z -> r   z- descriptor table: `r  `z- descriptor rows: r  z- scan window per script: r  z dwordsz&- descriptor+4 field-map CNS records: rP  z-- descriptor+4 current frontier direct refs: rQ  z-- descriptor+4 encoded route-target scalars: r`  z / ra  rc  z (rd  )z4- descriptor+4 selection-buffer opcode-shaped rows: rR  z=- all descriptor-script selection-buffer opcode-shaped rows: r  z/- descriptor+4 base-setter opcode-shaped rows: rS  z.- descriptor+4 base-setter pointer-like rows: rT  z-- descriptor+4 base-setter non-pointer rows: rU  z0- descriptor+4 context+0xa8 setter-shaped rows: rV  z<- descriptor+4 context+0xa8 non-pointer setter-shaped rows: rX  z9- descriptor+4 non-pointer context+0xa8 operand sources: z*- descriptor+4 specific gate base proven: r  z- descriptor+4 gate `r  z` writers: r^  z` readers: r_  z- all descriptor-script gate `r  r  z3- all descriptor-script specific gate base proven: r  z/- all descriptor-script field-map CNS records: r  z6- all descriptor-script current frontier direct refs: r  z6- all descriptor-script encoded route-target scalars: r  r  r  r  z- script class: r  z!- runtime active order required: r  z- proofFound: `r  z'- opcode20DescriptorScriptProofFound: `r  z- promotion status: `r   r  z## Failed Gatesc              3  (   K   | ]
  }d | d  yw)- `r  Nr'   r   items     r*   r   zmarkdown.<locals>.<genexpr>s  s     \43tfA\s   r  )r  z## Missing Evidencer  c              3  &   K   | ]	  }d |   yw)z- Nr'   r  s     r*   r   zmarkdown.<locals>.<genexpr>y  s     D2dVDr  r  )r  z## Evidence Refsr  c              3  8   K   | ]  }d |d    d|d      yw)r  r   z`: r   Nr'   r  s     r*   r   zmarkdown.<locals>.<genexpr>  s/       c&k]#c-012s   r  )r  z## Current Frontier Refsr  z| label | VA |z| --- | --- |r  z| z | `z` |)r  z## Script Slot Aggregater  z| slot | scripts | field maps | frontier refs | encoded raw/proof/promoting | selection opcodes | gate writers | gate readers | context+0xa8 setters | non-pointer context+0xa8 setters |zF| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |r  r   z | r  r   r   r   /r   r   r   r   r   r   r   z |)r  z&## Descriptor+4 Context Base Histogramr  z| base expression | shaped row count | non-pointer row count | last-shaped descriptor count | last-non-pointer descriptor count |z#| --- | ---: | ---: | ---: | ---: |r  r)   rl   r  r  r  z| `z` | r   )r  z8## Descriptor+4 Non-Pointer Context+0xa8 Operand Sourcesr  z| operand source | row count |z| --- | ---: |)r  z## Descriptor Rowsr  a4  | index | descriptor | script+0 CNS | script+4 CNS | script+4 field maps | script+4 frontier refs | script+4 encoded raw/proof/promoting | script+4 context+0xa8 setters | script+4 non-pointer context+0xa8 setters | script+4 last non-pointer context+0xa8 base | script+4 gate writers | script+4 gate readers |zQ| ---: | --- | --- | --- | ---: | ---: | ---: | ---: | ---: | --- | ---: | ---: |rC  r]  r   r   rF  rN  rO  
)joinr   rn   r   rb   )summarynon_pointer_operand_sourceslinesr   r)   rw   last_countsnon_pointer_countslast_non_pointer_countsr  last_context_texts              r*   markdownr  @  s   "&)) ,MN, # # 
  -8-
- GH%&d78+<*=>-  (> ?@B	-
 g&:;<=- %W-C%D$EWM- 19R1S0TU- 8@f8g7hi- 8@A
B#JK
LC@A
B C89:!		=- ?wGd?e>fg- HPoHpGqr-  :'B`:a9bc!-" 9Ad9e8fg#-$ 8@b8c7de%-& ;7Cc;d:ef'-( GwOyGzF{|)-* DD_C`a+-, 5W=\5]4^_--.  		'2B*C DE[QXYqQrPst/-0  		'2B*C DE[QXYqQrPst1-2 )7;K3L)M(NkZab|Z}Y~3-4 )7;K3L)M(NkZab|Z}Y~5-6 >gFh>i=jk7-8 :'B]:^9_`9-: AIqAr@st;-< ABC
DCLM
NcBC
D E:;<A		?=-F 7#:;<=G-H ,G4P,Q+RSI-J ',/02K-L 2':^2_1``abM-N  (9 :;1=O-P 	Q-R 	S-T 	U-V 	W-X 	Y-E\ 
LL\73Z+[\\	LL  
 
LLD1B)CDD	LL  
 
LL >*  
LL    /557 1ur%UG3/01	LL   01 

VS]!3 4C<N8O7PPS234C9:;1CDEQ9:;3)*+3$%&c#.?*@)A,-.c#6Y2Z1[[]_		


 
LL   HI 	Gc'l"K  NO 	Gc'l"  RS 	Gc'l"  @A 
#g,tCL>5G5K5KCPWLZ[5\4]]`s7|Q/04K4O4OPST[P\^_4`3aace	


 
LL   IJ ?s3w<.S\N"=>?	LL   '( 
DE>JL)9:PSWd3'8#9":$yy/018S9yy/018S9,-.c#6\2]1^^a@AB!JKLA@AB#345S=g9h8i j!"$+,-S5M1N0Or	S	

 
LL99Ucs   +R*R/R4c                
   dj                  d | d   D              xs d}| d   j                         D cg c]4  \  }}dt        j                  |       dt        j                  |       d6 }}}g }| d	   D ]T  d
   }|r|d   nd}|j	                  dj                  g dd    dt        j                  d   xs d       dt        j                  d   xs d       dt        j                  dj                  d         xs d       dt        j                  d   xs d       dt        j                  dj                  d         xs d       dd    dd    dd    dd    dd    dd    dd    dt        j                  |       dd    dd    d              W | d!   D cg c]o  d"t        j                  d#          dd$    dt        fd%| d&   D        d'       dt        fd(| d)   D        d'       dt        fd*| d+   D        d'       d q }	}| d   D cg c]$  }d"t        j                  |d#          d|d$    d & }
}| d,   D cg c]`  }dt        j                  |d-          d|d.    d|d/    d|d0    d|d1    d|d2    d|d3    d|d4    d|d5    d|d6    d|d7    d|d8    d b }}dj                  d9 | d:   D              }dj                  d; | d<   D              }dj                  d= | d>   D              }d?j                  g d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdj                  g dTt        j                  | dU          dVt        j                  | dW          dXt        j                  | dY          dZ| d[    d\| d    d]| d    d^| d_    d`| da    db| d    dc| d    ddt        j                  |       de| df    dg| d    dh| d    di| dj    dk| dl    dm| dn    dot        j                  t        | dp                dqt        j                  | dr          ds      dt| d    d| d    d| d    dut        j                  | dv          dw| dx    d| dy    d| dz    dut        j                  | d{          d|d}t        j                  | d~          ddd| ddd| ddd| ddd|ddd|ddd|	ddd|
ddd|dddd      S c c}}w c c}w c c}w c c}w )Nr  c              3  6   K   | ]  }|d     d|d      ywr  r'   r  s     r*   r   zhtml_page.<locals>.<genexpr>  r  r  rY  r   r  z<tr><td>z</td><td><code>z</code></td></tr>rC  r]  r   r  r   rF  z</code></td><td><code>rG  z</code></td><td>rN  rH  rO  z	</td><td>rP  rQ  r`  r  ra  rc  rV  rX  r^  r_  z
</td></tr>r  z<tr><td><code>r)   rl   c              3  @   K   | ]  }|d    d    k(  s|d     ywr)   rl   Nr'   )r   nprw   s     r*   r   zhtml_page.<locals>.<genexpr>  s@       Loqryoz  B  CJ  K  pKG  L   
r  r   c              3  @   K   | ]  }|d    d    k(  s|d     ywr  r'   r   lastrw   s     r*   r   zhtml_page.<locals>.<genexpr>  s@       L4mqrymz  B  CJ  K  nKg  Lr  r  c              3  @   K   | ]  }|d    d    k(  s|d     ywr  r'   r  s     r*   r   zhtml_page.<locals>.<genexpr>   sH       V4w{  }D  xE  IL  MT  IU  xUg  Vr  r  r  r   r  r   r   r   r   r   r   r   r   r   r   c              3  N   K   | ]  }d t        j                  |       d  yw)
<li><code>z</code></li>Nhtmlescaper  s     r*   r   zhtml_page.<locals>.<genexpr>  s+       T[[&'|4   #%r  c              3  N   K   | ]  }d t        j                  |       d  yw)z<li></li>Nr  r  s     r*   r   zhtml_page.<locals>.<genexpr>  s+       t{{4 !'r!  r  c              3     K   | ]9  }d t        j                  |d          dt        j                  |d          d ; yw)r  r   z	</code>: r   r#  Nr  r  s     r*   r   zhtml_page.<locals>.<genexpr>!  sE       T[[V-.iCDV8W7XX]^s   ?Ar  r  z<!doctype html>z<html lang="en">z<head>z  <meta charset="utf-8">zF  <meta name="viewport" content="width=device-width, initial-scale=1">z=  <title>Save Selector Opcode 0x20 Descriptor Scripts</title>z	  <style>zg    :root { color-scheme: dark; font-family: system-ui, sans-serif; background: #101010; color: #eee; }z&    body { margin: 0; padding: 24px; }z,    h1 { margin: 0 0 8px; font-size: 24px; }z/    h2 { margin: 24px 0 8px; font-size: 18px; }z<    p { max-width: 1120px; color: #bbb; line-height: 1.45; }z[    table { width: 100%; border-collapse: collapse; margin: 12px 0 20px; font-size: 13px; }zi    th, td { border-bottom: 1px solid #303030; padding: 7px 8px; text-align: left; vertical-align: top; }zF    th { position: sticky; top: 0; background: #181818; color: #ddd; }z    code { color: #d7f0ff; }z
  </style>z</head>z<body>z7  <h1>Save Selector Opcode 0x20 Descriptor Scripts</h1>z  <p>route r  z -&gt; r   z; descriptor table <code>r  z</code>; descriptor rows r  z%; descriptor+4 field-map CNS records z,; descriptor+4 current frontier direct refs z3; descriptor+4 selection-buffer opcode-shaped rows rR  z<; all descriptor-script selection-buffer opcode-shaped rows r  z/; descriptor+4 context+0xa8 setter-shaped rows z;; descriptor+4 context+0xa8 non-pointer setter-shaped rows z8; descriptor+4 non-pointer context+0xa8 operand sources z); descriptor+4 specific gate base proven r  z; descriptor+4 gate writers z; descriptor+4 gate readers z%; all descriptor-script gate writers r  z%; all descriptor-script gate readers r  z2; all descriptor-script specific gate base proven r  z; proofFound <code>r  z </code>; promotion status <code>r   z</code>.</p>z/  <p>descriptor+4 encoded route-target scalars z (<code>rd  z=</code>); all descriptor-script encoded route-target scalars r  r  r  r  z</code>).</p>z  <p>r  z</p>z  <h2>Failed Gates</h2>z  <ul>z</ul>z  <h2>Missing Evidence</h2>z  <h2>Evidence Refs</h2>z   <h2>Current Frontier Refs</h2>zA  <table><thead><tr><th>label</th><th>VA</th></tr></thead><tbody>z  </tbody></table>z   <h2>Script Slot Aggregate</h2>a    <table><thead><tr><th>slot</th><th>scripts</th><th>field maps</th><th>frontier refs</th><th>encoded raw/proof/promoting</th><th>selection opcodes</th><th>gate writers</th><th>gate readers</th><th>context+0xa8 setters</th><th>non-pointer context+0xa8 setters</th></tr></thead><tbody>z.  <h2>Descriptor+4 Context Base Histogram</h2>z  <table><thead><tr><th>base expression</th><th>shaped row count</th><th>non-pointer row count</th><th>last-shaped descriptor count</th><th>last-non-pointer descriptor count</th></tr></thead><tbody>z@  <h2>Descriptor+4 Non-Pointer Context+0xa8 Operand Sources</h2>zQ  <table><thead><tr><th>operand source</th><th>row count</th></tr></thead><tbody>z  <h2>Descriptor Rows</h2>a    <table><thead><tr><th>index</th><th>descriptor</th><th>script+0</th><th>script+0 CNS</th><th>script+4</th><th>script+4 CNS</th><th>script+4 field maps</th><th>script+4 frontier refs</th><th>script+4 encoded raw/proof/promoting</th><th>script+4 context+0xa8 setters</th><th>script+4 non-pointer context+0xa8 setters</th><th>script+4 last non-pointer context+0xa8 base</th><th>script+4 gate writers</th><th>script+4 gate readers</th></tr></thead><tbody>z</body>z</html>)r	  rn   r  r   r   r  str)r
  r  r   r)   frontier_rowsdescriptor_rows_htmlr  r  rw   base_histogram_rowsnon_pointer_operand_source_rowsslot_aggregate_rowsfailed_gatesmissing_evidenceevidence_refss           `      r*   	html_pager.    s   "&)) ,MN, # # 
   $N399;E5 4;;u%&odkk%6H5IIZ[M  '( 
DE>JL)9:PS##   w<.!S):%;%BsCDE S%8%?C@AB ;;tyy-?)@AHSIJ	K	
 S%8%?C@A
B ;;tyy-?)@AHSIJK 0123 =>?@ DEF GH JKL MN @ABC 789: ABCD %6789 /012  /01! 2!	

> DE	  T[[W67 8w<. !  Lw7j/k  L  NO  P  Q Q  L7;h3i  L  NO  P  Q Q  V7;r3s  V  XY  Z  [  [e	f	 	 MN' S\233CCL>Q[\'# '& 45 	{{3v;'( )=!" #%&' (234 59:;1?@
A56
7 8)*+ ,$%& '$%& ',-. /678 9	 " 77 CD L ww -.  GG >* M 99 === 	= 	#	=
 	Q= 	H= 	= 	r= 	1= 	7= 	:= 	G= 	f= 	t= 	Q=  	'!=" 	#=$ 	%=& 	'=( 	B)=* 	E  	E+  	Edkk'("345  	EW  	ET[[QYIZ=[<\  	E\u  	Evz  wB  wB  CJ  Ka  Cb  wc  vd  	E  d}  	E  ~E  FZ  ~[  }\  	E  \A  	E  BI  Jc  Bd  Ae  	E  eQ  	E  RY  Z@  RA  QB  	E  Bu  	E  v}  ~[  v\  u]  	E  ]Y  	E  Za  bA	  ZB	  YC	  	E  C	r	  	E  s	z	  {	[
  s	\
  r	]
  	E  ]
X  	E  Y`  aK  YL  XM  	E  ME  	E  FJ  FQ  FQ  Rm  Fn  Eo  	E  oX  	E  Y`  a@  YA  XB  	E  B^  	E  _f  g  _@  ^A  	E  A]  	E  ^e  f~  ^  ]@  	E  @e  	E  fm  nH  fI  eJ  	E  Jo  	E  pw  xR  pS  oT  	E  TF  	E  GN  Oq  Gr  Fs  	E  sF  	E  GK  GR  GR  SV  W^  _k  Wl  Sm  Gn  Fo  	E  oO  	E  PT  P[  P[  \c  du  \v  Pw  Ox  	E  xD  	E+=, :'Bo:p9qqrJK
LA@A
B C++g&JKLM N>BC
DALM
NaBC
D E++g&LMNO}	^-=> GL12348?=@ 	"A=B e$C=D 	&E=F !"%(G=H 	#I=J u%K=L 	+M=N 	LO=P 
Q=R 	S=T 	+U=V 	gW=X 
Y=Z 	[=\ 	9]=^ 	Q_=` 
a=b 	c=d 	Ke=f 	\g=h 
)i=j 	k=l 	%m=n 	Po=p 
q=r 	s=t 	u=v 	w=x 	y= = =O8	's   9UA4U)U#	A%U(c                    |j                  dd       |dz  j                  t        j                  | dd      dz   d	       |d
z  j                  t	        |       d	       y )NT)parentsexist_okz.save_selector_opcode20_descriptor_scripts.jsonFr   )ensure_asciiindentr  r6   r7   .save_selector_opcode20_descriptor_scripts.html)mkdir
write_textr:   dumpsr.  )r
  out_dirs     r*   write_outputsr9  e  sf    MM$M.??KK

7q9D@ L  ??KKIV]L^ipKqr-   c                 F   t        j                  t              } | j                  dt        t
        dz         | j                  dt        t        dz         | j                  dt        t        dz         | j                  d	t        t               | j                         }t        |j                  j                         t        |j                  i       t        |j                  i             }t        ||j                         t!        d
|j                  dz          y )N)r   z--exer   )typedefaultz--descriptor-writersr  z--current-root-frontierr  z	--out-dirz6wrote save selector opcode 0x20 descriptor scripts -> r4  )argparseArgumentParser__doc__add_argumentr   ROOTr  
parse_argsr  rG   
read_bytesr>   rg  current_root_frontierr9  r8  print)parserargsr
  s      r*   mainrH  n  s    $$9F
dD=4HI
.T3I~C~
1cL|F|}
$<D$))2.$,,b1G
 '4<<(	B4<<  SC  DC  CD  E  Fr-   __main__)r)   r@   returnr%  )r)   r@   rJ  r@   )r   r   r=   r   rJ  r   )r)   z
str | NonerJ  
int | None)rG   bytesrH   
list[dict]rI   r@   rJ  rK  )rH   rM  r)   r@   rJ  r  )
rG   rL  rH   rM  rW   r@   rX   r%  rJ  dict | None)rc   r@   rJ  r%  )rh   r@   rJ  r%  )rp   zdict[int, int]rJ  rM  )rp   dict[str, int]rJ  rM  )ru   zlist[list[dict]]rJ  rM  )rc   r@   rh   r@   r{   r@   rJ  r%  )r   rO  rJ  rM  )rW   r@   r)   r@   r   rM  r   r@   r   r%  rJ  rM  )r   rM  rJ  r   )r   rM  rJ  r   )rG   rL  rH   rM  r   dict[int, str]r!  rK  r   r%  r   rO  rJ  r   )rG   rL  rH   rM  r   rP  r   rO  rg  r   rJ  rM  )rx  r   rJ  rO  )NN)rG   rL  rg  rN  rx  rN  rJ  r   )r
  r   rJ  r%  )r
  r   r8  r   rJ  None)rJ  rQ  )Cr?  
__future__r   r=  r  r:   rE   syspathlibr   typingr   r   insertr%  __file__resolveparentprobe_exe_scene_tablesr   r   r   2summarize_save_selector_opcode20_nested_base_modesr	   r0  rA  r  r  r  rf  re  r  r  r  r  r  r  r  rw  r+   r0   r2   r4   r>   rA   rK   rM   rZ   rd   ri   rq   rs   rx   r|   r   r   r   r   rA  ro  r  r  r  r.  r9  rH  __name__r'   r-   r*   <module>r]     s   O "     
   3tH~--/667 8 P P T H~''*
Ul		    d|, : . */ + +ghF  XO  PA  Se  f, (   8@8-45	R)'$(### # 	#
 # #L%P!Hs	ss s 	s
 s "s 
sl;	;; ; "	;
 ; ;|4 '+/3A	A#A "-A 
	AHVrIX 25 rF  zF r-   