
    7,Jj                       d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	  ee
      j                         j                  d   Zedz  Zdg d	d
dg dd
dg dd
dg dd
dg dd
dg dd
dg dd
dg dd
dg dd
dg dd
dg dd
gZdd d!d"d#d$Zd-d%Z	 d.	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d/d&Zd0d'Zd0d(Zefd1d)Zd2d*Zd3d+Zed,k(  r e        yy)4zGConsolidate current-selector leaf selection and wrapper execution gaps.    )annotationsN)Path)Any   outz)out/save_selector_leaf_table_context.json)selectorrootHexrootTablePointerHex%frontierLeafRefIsDirectRootTableEntryruntimeSelectionProvenpromotionStatus)pathfieldsz0out/save_selector_leaf_table_global_context.json)selectorTableCountfieldEntryRowCountcurrentSelectorRoutePairIndicescurrentFrontierLeafOnlyNegativez1out/save_selector_wrapper_descriptor_context.json)wrapperDescriptorHexwrapperEntryHexwrapperChildPointerHexwrapperRefBeforeCurrentRootcurrentRootReferencesWrapperwrapperEntryPromotingRefCountz4out/save_selector_route_pair_descriptor_context.json)currentRoutePairDescriptorCount!currentRoutePairDescriptorIndices0currentRoutePairCorrectedTraceReachesReaderCountreaderBearingCurrentEntryCountreaderBearingNegativeEntryCountz0out/save_selector_opcode07_indexed_pointers.json)opcode07IndexModerowCountselectedWrapperEntrySlotCount selectedLeafTableWindowSlotCount!selectedCurrentRootEntrySlotCount"selectedNegativeRootEntrySlotCountdirectFrontierTargetCountz2out/save_selector_opcode08_activation_windows.json))sourceOrPredecessorOpcode08ActivatorCount+sourceOrPredecessorCurrentRootProducerCount,sourceOrPredecessorCurrentRangeProducerCount(currentInternalCurrentRangeProducerCountz2out/save_selector_opcode09_pointer_collisions.json)#sourceOrPredecessorOpcode09RowCount,sourceOrPredecessorSupportedOpcode09RowCount2sourceOrPredecessorUnsupportedModeOpcode09RowCount)sourceOrPredecessorCurrentRangeStoreCountz2out/save_selector_selected_root_execution_gap.json)selectedRootExecutionRefFoundr   diagnosticExclusionGateevidenceRefsevidenceRefCountz2out/save_selector_current_root_frontier_paths.json)strictHotspotFoundfrontierClusterClassfrontierClusterEventCountfrontierClusterSelectorRefCountz*out/save_selector_merge_execution_gap.json) selectorMergeExecutionProofFoundselectorMergeGapOpenr   z5out/save_selector_route_pair_entry_execution_gap.json)rootTableDirectRefContextroutePairEntryExecutionProven%correctedTraceNormalSelectionGapFoundremainingProofszNselected-root execution reaching current selector 2:0 on the normal route pathzQhigher-level table/index path selecting current entries 6/8 or negative entry -12zGnormal-route wrapper 0x00542a04 execution into frontier leaf 0x00542ae8zlcomplete current selector leaf execution proof tying selected root, leaf selection, and wrapper/reader tracez?strict map1_01a source coordinate or hotspot linked to map2_02d)selected-root-executioncurrent-leaf-selectionwrapper-executioncurrent-selector-leaf-executionstrict-hotspotc                B    dj                  d | xs g D              xs dS )N,c              3  2   K   | ]  }t        |        y wN)str).0values     J/home/exedev/hwanse/tools/summarize_save_selector_wrapper_execution_gap.py	<genexpr>zcsv.<locals>.<genexpr>   s     95CJ9s   -)join)valuess    rH   csvrM      s     889FLb99@S@    c           %        |
xs i }
| j                  d      xs |j                  d      xs d}| j                  d      xs |j                  d      }| j                  d      xs |j                  d      }| j                  d      xs |j                  d      }| j                  d      xs |j                  d      }|j                  d      }|j                  d      }|j                  d	      }| j                  d
      xs g D cg c]  }|j                  d      du r| }}|j                  d      xs d}|j                  d      xs |j                  d      xs d}|dkD  xr ||k(  }|j                  d      dk(  xrV |j                  d      dk(  xr@ |j                  d      dk(  xr* |j                  d      dk(  xr |j                  d      dk(  }|j                  d      du }|j                  d      du }|j                  d      xs g }|j                  d      xs d}t        d |D              }t        d |D              }|D cg c]g  }|j                  d      dk(  rQ|j                  d       d |j                  d!       d"|j                  d#      xs d$ d |j                  d%      xs d$ i }}|j                  d&      d'k(  xr |d'k(  } |j                  d(      dk(  xr |j                  d&      d'k(  xr |}!|j                  d)      du xs | j                  d*      du }"|j                  d+      dk(  xr |j                  d,      d'k(  }#| j                  d-      du xs( |j                  d-      du xs |j                  d.      du }$|j                  d(d      dkD  xs |j                  d      du xs | xr |"}%|$xs | xs |"}&|j                  d.      du }'|'xr
 |&xr |%xs |}(| j                  d/      du xs( |j                  d/      du xs |j                  d/      du })|	j                  d0      du }*|j                  d1      xs i }+|+j                  d2      du },|,r^|+j                  d3      xs ddkD  rF|+j                  d4      d5k(  r2|+j                  d6      xs ddk(  r|+j                  d7      xs ddk(  rd8n|,rd9nd:}-|j                  d;      xs g }.|j                  d<      du }/|j                  d=      xs d}0|j                  d>      xs d}1|j                  d?      xs d}2|0|1z   |2z   }3|
j                  d@      xs i }4|4j                  dA      xs dB}5|xr  |#xr |/xr |xr |3dk(  xr |$ xr |% xr |' }6|6rdCndD}7|(r|)r|*rdEndF}8g }9|'s|9j                  dG       |&s|9j                  dH       |%s|9j                  dI       |(s|9j                  dJ       |)s|9j                  dK       |9D :cg c]  }:t        j                  |:|:       };}:|9 }<dL|rdMndNdO| dP| dQt	        |       dRt        |j                  dS             dTdU|rdVndWdX| dY| dZ| d[|j                  d\       d]| d^| dTd_|!r|rd`ndDda|j                  d&       db|j                  dc       dd| de| df| dgdhj                  |      xs d$ di|j                  d(       dj|j                  d       dTdk|/rdlndmdn|j                  do       dp|j                  dq       dr|j                  ds       d |j                  dt       dut        |.       dv|/ dTdw|5dx|4j                  dy       dz|4j                  d{       d |4j                  d|       d}|4j                  d~       d|4j                  d       d|4j                  d       d|4j                  d       d|4j                  d       d|4j                  d       dTd|rdndd| d| d|j                  d       d|# dTd|rdndd|j                  d       d|j                  d       d|j                  d       d|j                  d       d|j                  d       d|j                  d       dTd|0s|1sdndd|j                  d       d|0 d|1 d|j                  d       d|j                  d       d|j                  d       dTd|2dk(  rdndd|j                  d       d|j                  d       d|j                  d       ddhj                  |j                  d      xs g       xs d$ d|2 d|3 dTd|7d| d|# d|/ d| d|3 d|$ d|% d|' dTdG|'sdndd|' d|$ d|j                  d«       d|j                  dë       dTd|-d|+j                  dƫ       dt        |+j                  dȫ             d|+j                  dʫ       d|+j                  d̫       d|+j                  d3       d|+j                  d4       d|+j                  dЫ       d|+j                  d6       d|+j                  dҫ       d|+j                  d7       d|+j                  dԫ       d|, dTdK|)sdndd|) d|j                  d٫       d|j                  d۫       d|j                  dݫ       dTg}=d}>i d|j                  d߫      xs dd|j                  d      xs dd|d|d|dy| j                  dy      d|j                  d      dt	        |      d|d|d|d|d	|d\|j                  d\      d|d|j                  d      d&|j                  d&      i dc|j                  dc      d|d|d|d|d| d(|j                  d(      d)|"d|j                  do      d|j                  dq      d|j                  ds      d|j                  dt      d|.d|j                  d      d|j                  d      d|/d@|4i d|5d|4j                  d{      d|4j                  d|      d|4j                  d~      xs i d|4j                  d      d|4j                  d      d|4j                  d      d|4j                  d      d|4j                  d      d|dS|j                  dS      xs g d|d|d|j                  d      d+|j                  d+      d,|j                  d,      d|j                  d      xs g i d|#d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d |d|j                  d      d|0d|1d|j                  d      d|j                  d      d|j                  d      d|2d|j                  d      i d	|j                  d      d
|j                  d      xs g d|j                  d      d|3d|6d|7d|-d|,d|+j                  dƫ      d|+j                  dȫ      xs g d|+j                  dʫ      du d|+j                  d      d|+j                  d̫      d|+j                  d3      d|+j                  d4      d|+j                  dЫ      d|+j                  d6      i d|+j                  dҫ      d|+j                  d7      d|+j                  dԫ      d.|'d|<d |9d!|;d-|$d"|&d#|%d$|(d0|*d/|)d%|8d&|=d't        d(t	        t              g d)|>d*S c c}w c c}w c c}:w (+  Nr   z2:0r	   r
   frontierLeafHexfrontierReaderHexr   r   r   	tableRowsinsideRootTableWindowTr   r   r   'currentRoutePairTraceReachesReaderCountr!   r"   r#   r$   r%   r   r   FwrapperEntryRefs'wrapperEntryCurrentRootEntryRunRefCountc              3  n   K   | ]-  }|j                  d       dk(  r|j                  d      du rd / yw)referenceRole"opcode-0x5a-mode0-fallthrough-wordpromotesWrapperSelectionFr   NgetrF   rows     rH   rI   z build_summary.<locals>.<genexpr>   s<      777?#'KKGG./58 	
7s   35c              3     K   | ]@  }|j                  d       dk(  r*|j                  d      du r|j                  d      du rd B yw)rX   rY   fallthroughWordHandlerIsCodeF$fallthroughWordCanJumpToDwordAtPlus4r   Nr[   r]   s     rH   rI   z build_summary.<locals>.<genexpr>   sN      777?#'KKGG23u<GG:;uD	 	
7s   AArX   rY   fallthroughWordValueHex/fallthroughWordOpcodeHexz->fallthroughWordHandlerHexrJ   fallthroughWordHandlerSectionwrapperEntryRefCountr   r    frontierLeafDirectCurrentRootRefr   r   r   r   r.   r2   r6   r/   &excludedFromSelectedRootExecutionProof"leftStabilityRouteSelectorHitCount$leftStabilityRouteHitReproducibilityznot-reproduced)leftStabilityRecheckRouteSelectorHitCount+leftActiveOrderRecheckRouteSelectorHitCountzdiagnostic-only-not-reproducedzdiagnostic-onlyznot-availabler   r   r'   r(   r-   r8   statusunknownz*corrected-trace-not-normal-selection-proofopenzready-for-reviewblockedr<   r=   r>   r?   r@   zcurrent-root-table-windowzroute-pair-descriptors-presentzroute-pair-descriptors-missingzroot=z; table=z; insideRootRows=z; routePairIndices=r   )kindrn   detailznegative-wrapper-entryzoutside-current-root-runzinside-current-root-runzwrapperEntry=z
; wrapper=z; child=z; childIsFrontier=wrapperChildIsFrontierLeafz; frontierLeaf=z	; reader=zwrapper-reference-contextznon-promotingzwrapperEntryRefs=z; currentRootRangeRefs=$wrapperEntryCurrentRootRangeRefCountz; currentRootEntryRunRefs=z; opcode5aFallthroughRefs=z; fallthroughNonCodeRefs=z; fallthroughHandlers=rB   z; promotingRefs=z; currentRootReferencesWrapper=zglobal-leaf-table-contextzfrontier-leaf-negative-onlyzfrontier-leaf-nonnegative-openzselectorTables=r   z; fieldEntries=r   z; negative/nonNegative=negativeFieldEntryRowCountnonNegativeFieldEntryRowCountz; currentRoutePairIdx=z; frontierLeafOnlyNegative=zroot-table-direct-ref-contextztableWindow=tableWindowHexz; tableRefs=tableWindowRefCounttableWindowTextRefCountz; sections=tableWindowSectionCountsz; routeEntryTextRefs=routeEntryAddressTextRefCountz; routeLeafTextRefs=routeLeafValueTextRefCountz; frontierLeafTextRefs=frontierLeafValueTextRefCountz; frontierReaderTextRefs=frontierReaderValueTextRefCountz; frontierReaderRefs=frontierReaderValueRefCountzroute-pair-reader-tracezcorrected-trace-onlyznot-groundedzroutePairDescriptors=z; correctedReaderHits=z; geometryExitHits=$currentRoutePairGeometryExitHitCountz; readerNegativeOnly=zopcode07-leaf-selectionabsentpresentz	rowCount=r    z; indexMode=r   z; selectedWrapper=z; selectedLeafWindow=z; selectedNegative=z; directFrontier=z&opcode08-source-predecessor-activationzcurrent-producer-absentzcurrent-producer-presentzactivators=r&   z; currentRoot=z; currentRange=z; ownRange=(sourceOrPredecessorOwnRangeProducerCountz; scriptScalar=,sourceOrPredecessorScriptScalarProducerCountz; currentInternalRange=r)   z!opcode09-source-predecessor-storezcurrent-store-absentzcurrent-store-presentzrows=r*   z; supported=r+   z; unsupported=r,   z; unsupportedModes=&sourceOrPredecessorUnsupportedModesHexz; currentRangeStores=z; sourcePredCurrentProducers=z$corrected-trace-normal-selection-gapzroutePairReaderTraceGrounded=z; frontierLeafNegativeOnly=z; opcode07SelectionAbsent=z; runtimeSelection=z; wrapperExec=z; selectedRootRef=missingprovenzselectedRootExecutionRefFound=z; runtimeSelectionProven=z; selectedPointerGlobal=selectedPointerGlobalHexcurrentRootHexzconstructed-diagnostic-recheckzruntimePoll=runtimePollSampleCountz
 observed=runtimePollObservedSelectorsz route=+observedCurrentThenFollowupInDiagnosticPollz; leftStability=leftStabilitySampleCountz routeHits=z repro=z; leftRecheck=leftStabilityRecheckSampleCountz; leftActiveOrder=!leftActiveOrderRecheckSampleCountz activeOrderCount=,leftActiveOrderRecheckActiveOrderCountValuesz; excluded=foundzstrictHotspotFound=z; frontierClusterClass=r3   z; frontierClusterEventCount=r4   z"; frontierClusterSelectorRefCount=r5   a  Current selector 2:0 contains route-pair descriptors and corrected traces from entries 6 and 8 reach the frontier reader, but this is still table/control-flow shape rather than execution proof. The reader-bearing wrapper lives at negative entry -12 before the current root table pointer, opcode 0x07 does not select the wrapper, leaf table window, negative entry, frontier leaf, or reader, source/predecessor opcode 0x08/0x09 rows do not produce the current selector root/range, and no runtime selected-root proof or strict source hotspot is present. The global leaf-table scan also keeps the frontier reader-bearing leaf negative-only, so entries 6 and 8 remain corrected-trace candidates rather than normal-selection proof; this contradiction is tracked as a separate corrected-trace normal-selection gap. The constructed selector 2:0 diagnostic is also excluded from wrapper proof because its left-route hit is not reproduced and the active-order recheck stays at a zero count.sourcemap1_01atargetmap2_02dcurrentRootEntryRunHexinsideCurrentRootEntryCount'wrapperEntryOpcode5aFallthroughRefCount&wrapperEntryFallthroughNonCodeRefCount'wrapperEntryFallthroughHandlerSummaries(wrapperEntryOnlyRefIsOpcode5aFallthroughglobalSelectorTableCountglobalFieldEntryRowCount globalNegativeFieldEntryRowCount#globalNonNegativeFieldEntryRowCount%globalCurrentSelectorRoutePairIndices.globalCurrentSelectorNegativeRoutePairRowCount(currentSelectorNegativeRoutePairRowCount1globalCurrentSelectorNonNegativeRoutePairRowCount+currentSelectorNonNegativeRoutePairRowCount%globalCurrentFrontierLeafOnlyNegativerootTableDirectRefStatusrootTableWindowDirectRefCount!rootTableWindowDirectTextRefCount%rootTableWindowDirectRefSectionCounts&rootTableRouteEntryAddressTextRefCount#rootTableRouteLeafValueTextRefCount&rootTableFrontierLeafValueTextRefCount(rootTableFrontierReaderValueTextRefCount$rootTableFrontierReaderValueRefCountroutePairReaderTraceGroundedreaderBearingNegativeIndicesreaderBearingNegativeOnlyopcode07RowCountopcode07LeafSelectionAbsent)opcode08SourceOrPredecessorActivatorCount3opcode08SourceOrPredecessorCurrentRootProducerCount4opcode08SourceOrPredecessorCurrentRangeProducerCount0opcode08SourceOrPredecessorOwnRangeProducerCount4opcode08SourceOrPredecessorScriptScalarProducerCount0opcode08CurrentInternalCurrentRangeProducerCount1opcode09SourceOrPredecessorCurrentRangeStoreCount4opcode09SourceOrPredecessorSupportedOpcode09RowCount:opcode09SourceOrPredecessorUnsupportedModeOpcode09RowCount.opcode09SourceOrPredecessorUnsupportedModesHex3opcode09SourceOrPredecessorPointerCollisionRowCount+sourceOrPredecessorPointerCollisionRowCount'sourceOrPredecessorCurrentProducerCountr:   &correctedTraceNormalSelectionGapStatus'constructedDiagnosticWrapperProofStatus-constructedDiagnosticExcludedFromWrapperProof'constructedDiagnosticRuntimeSampleCount&constructedDiagnosticObservedSelectors)constructedDiagnosticReachedRouteSelector%constructedDiagnosticFollowupSelectorfollowupSelector-constructedDiagnosticLeftStabilitySampleCount7constructedDiagnosticLeftStabilityRouteSelectorHitCount1constructedDiagnosticLeftStabilityReproducibility4constructedDiagnosticLeftStabilityRecheckSampleCount>constructedDiagnosticLeftStabilityRecheckRouteSelectorHitCount6constructedDiagnosticLeftActiveOrderRecheckSampleCount@constructedDiagnosticLeftActiveOrderRecheckRouteSelectorHitCountAconstructedDiagnosticLeftActiveOrderRecheckActiveOrderCountValues
proofFoundfailedWrapperGateIdsmissingEvidencecurrentLeafSelectionProofFoundwrapperExecutionProofFound&currentSelectorLeafExecutionProofFoundr   evidencer0   r1   )zSprove selected-root execution reaches current selector 2:0 on the normal route pathzWdecode the higher-level table/index path that selects entries 6/8 or negative entry -12zYprove wrapper 0x00542a04 executes into frontier leaf 0x00542ae8 in normal route executionzFfind a strict map1_01a source coordinate or hotspot linked to map2_02d)r;   
conclusion)r\   sumappend WRAPPER_MISSING_EVIDENCE_BY_GATElenrM   rK   EVIDENCE_REFS)?leaf_table_contextleaf_table_global_contextwrapper_descriptor_contextroute_pair_descriptor_contextopcode07_indexed_pointersopcode08_activation_windowsopcode09_pointer_collisionsselected_root_execution_gapcurrent_root_frontier_pathsmerge_execution_gaproute_pair_entry_execution_gapr   root_hexroot_table_pointerfrontier_leaffrontier_readerwrapper_descriptorwrapper_entrywrapper_childr^   inside_root_rows#current_route_pair_descriptor_countcorrected_reader_count route_pair_reader_trace_groundedopcode07_selection_absentwrapper_before_current_rootwrapper_not_in_current_rootwrapper_entry_refs.wrapper_entry_current_root_entry_run_ref_count,wrapper_entry_opcode5a_fallthrough_ref_count,wrapper_entry_fallthrough_non_code_ref_count+wrapper_entry_fallthrough_handler_summaries.wrapper_entry_only_ref_is_opcode5a_fallthroughwrapper_non_promoting_refs%frontier_leaf_direct_current_root_refreader_negative_onlyruntime_selection_provenwrapper_execution_proof_found"current_leaf_selection_proof_found!selected_root_execution_ref_found+current_selector_leaf_execution_proof_foundstrict_hotspot_found$selector_merge_execution_proof_founddiagnostic_exclusion_gateconstructed_diagnostic_excludedconstructed_diagnostic_status!global_current_route_pair_indices*global_current_frontier_leaf_only_negative"opcode08_source_current_root_count#opcode08_source_current_range_count#opcode09_source_current_range_count,source_or_predecessor_current_producer_countroot_table_direct_ref_contextroot_table_direct_ref_status*corrected_trace_normal_selection_gap_found+corrected_trace_normal_selection_gap_statuspromotion_statusfailed_wrapper_gate_idsgate_idmissing_evidenceproof_foundr   r   s?                                                                  rH   build_summaryr     s    &D%Ir"!%%j1k5R5V5VWa5bkfkH!%%i0`4Q4U4UV_4`H+//0EF JgJkJkK '**+<=rA[A_A_`qArM(,,-@A E_EcEcFO 4778NO.223DEM.223KLM &))+6<"77*+t3 	 
 +H*K*KLm*n*srs'%))*\] 	(,,-VW	  	,a/ 	J"&II %
 	"%%&EF!K 	L%))*LMQRR	L%))*MNRSS	L &))*NOSTT	L &))*EF!K  #="@"@A^"_cg"g"<"@"@A_"`di"i3778JKQr"&&'PQVUV 3 47 7%7 40 47 7%7 40 &3 77?#'KK ww012!CGG<V4W3X45<=78?C@B3/ 3 	#&&'=>!C 	>8A= 3
 	#&&'FG1L 	(&**+ABaG	('  	#&&'IJdR 	S!!"IJdR *
 	&))*JKqP 	V)--.OPTUU 
 	78D@ 	T(,,-EF$N	T&**+JKtS  	#&&'FJQN 	U%))*HITQ	U))S.S " 	! 	1((	10 '
 )D(G(GHg(hlp(p%) 	P.	P*N.N 0 	34< 	I(,,-ABdJ	I&**+?@DH 
 ,?+B+BCe+fjn+n( ; ? ?@Y Z `^`!%%&NOSWW $
 +&**+OPUTUYZZ%))*PQUee&**+VW\[\abb&**+XY^]^cdd 	) +  " )B(E(EFg(h(nln%!%%&GHDP / 	$''(UV[Z[ ' 	$''(VW\[\ ( 	$''(STYXY ( 	+
-	.
-	. 1
 %C$F$FGb$c$igi!#@#D#DX#N#[R[ ( 	2 	26	2 &	2 9A=		2
 )(	2 .-	2 21 / 6 	5 0 7 0 	   !,&&'@A-&&'?@(&&':;6&&'HI&&'78 / 	),,Wg>  .-K 02 71z*<)= >""%&6"7!8 9$$'(E(I(IJm(n$o#pr
	
 -4O0Unj9K8L M&'9:T:X:XYu:v9w x  -i7HJ		
 0)CHcoio#$>$B$BCY$Z#[ \((B(F(FGm(n'o p++Y*Z [++W*X Y**V)W X''*xx0['\'c`c&d e!!;!?!?@_!` a b00J0N0NOm0n/oq		
 09 41!";"?"?@T"U!V W  9 = =>R ST U(,001MNOq,001PQR S''*+L'M&N O,,V+WY	
  42<@@AQRS T:>>?TUVVW0445NOP Q9==>XYZ [&&C&G&GHg&h%i j%%B%F%FGc%d$e f((E(I(IJi(j'k l**G*K*KLm*n)o p&&C&G&GHe&f%gi		
  .0P,Vd'(K'L M''=&> ?$$A$E$EFl$m#n o&&:%;=			
 .";h599*EF G6::;NOP Q##<#@#@A`#a"b c&&?&C&CDf&g%h i$$=$A$ABf$g#h i"";"?"?@["\!]_		
 =6:] 0+9==>ijk lAB C  CD E7;;<fgh i  ; ? ?@n op q(.223]^_a	
  82a7 -(3778]^_ `8<<=klm n:>>?stu v$887;;<dekiklspst u&&I%J K..Z-[]	
  ;A/0P/Q R&&:%; <,,V+W X++D*E F..Z-[ \$$<#= ><= >##D"EG		
 .'Hih01R0S T**B)C D))D)H)HIc)d(e f:>>?OPQS			
 538<<=UVW X 9 = =>\ ]^_ `2667def g!!:!>!>?Y!Z [ \6::;_`a b2667]^_ `8<<=^_` a6::;fgh i##<#@#@Ad#e"f g6::;hij k$$=$A$ABp$q#r s;<>		
& %';i%&:%; <((C(G(GH^(_'` a--H-L-LMh-i,j k33N3R3RSt3u2vx			
iHV		q l-11(;Izl-11(;Izl 	Hl 	8	l
 	1l 	,001ABl 	!"<"@"@AY"Zl 	&s+;'<l 	=l 	_l 	 2l 	=l 	!-l 	%&@&D&DEa&bl 	&'Bl  	'(B(F(FGe(f!l" 	 : > >?U V#l$ 	/0J0N0N21
%l* 	23a+l, 	23_-l. 	12^/l0 	23^1l2 	34b3l4 	()C)G)GHg)h5l6 	+,Q7l8 	#$=$A$ABV$W9l: 	#$=$A$ABV$W;l< 	+,E,I,IJf,g=l> 	./H/L/L+0
?lD 	01RElF 	9:S:W:W6;
GlL 	<=V=Z=Z9>
MlR 	01[SlT 	$%BUlV 	#$@WlX 	()F)J)JK`)aYlZ 	,-J-N-NOh-i[l\ 	01N1R1R&2
 2 cld 	12O2S2S+3
elj 	./L/P/P(0
klp 	12O2S2S+3
qlv 	34Q4U4U-5
wl| 	/0M0Q0Q)1
}lB 	*+NClD 	,-J-N-N/.
 . KlL 	;<RMlN 	'(HOlP 	/0M0Q0Q21
QlV 	)*G*K*KLl*mWlX 	*+H+L+LMn+oYlZ 	'(E(I(IJh(i(omo[l\ 	$%9]l^ 	6::;NO_l` 	599*Ealb 	()B)F)FGf)gcld 	+,E,I,IJl,melf 	,-F-J-JKn-oglh 	-.G.K.KLp.qilj 	$%>%B%BC^%_kll 	&'@mln 	45P5T5T76
olt 	>?aulv 	?@cwlx 	;<W<[<[6=
yl~ 	?@[@_@_:A
lD 	;<W<[<[6=
ElJ 	<=`KlL 	?@[@_@_:A
MlR 	EFaFeFe@G
SlX 	9:U:Y:Y4;
 ; _l` 	>?Z?^?^9@
alf 	23_glh 	01[ilj 	12]kll 	23Pmln 	89Xolp 	23L3P3PQi3jqlr 	12K2O2OPn2o2ususlt 	45N5R5R96
 6ul| 	01J1N1NOa1b}l~ 	89R9V9V&:
lD 	BC\C`C`0D
ElJ 	<=V=Z=Z2>
KlP 	?@Y@]@]-A
QlV 	IJcJgJg7K
Wl\ 	AB[B_B_/C
]lb 	KLeLiLi9M
clh 	LMfMjMj:N
iln 	()Jolp 	kqlr 	 7slt 	+ulv 	!":wlx 	)*Lylz 	%&C{l| 	12]}l~ 	+,Pl@ 	2AlB 	+ClD 	HElF 	GlH 	C.IlJ
 !Wl l{
R3rs   	~5A,~:	~?c           
        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$    d%t        | d&          d'| d(    d)| d*    d+| d,    d-t        | d.          d/| d0    d1| d2    d+| d3    d4| d5    d+| d6    d+| d7    d+| d8    d9| d:    dd;| d<    d=t        | d>          d?| d@    dAt        | dB          dC| dD    dE| dF    d+| dG    dH| dI    dJ| dK    dL| dM    ddN| dO    dP| dQ    ddR| dS    dT| dU    dVt        | dW          dXdY| dZ    d+| d[    d\| d]    d^| d_    d`| da    db| dc    dd| de    dft        | j                  dg             ddht        | j                  di      xs g        dj| dk    dl| dm    dn| do    dp| dq    dr| ds    dt| du    dddvd| j                  di      xs g D cg c]  }dw| 	 c}ddxddydz}| d{   D ]&  }|j                  d||d}    d~|d    d~|d    d       ( |j	                  g d       | j                  d      xs g D ]@  }dj                  |j                  d      xs g       }|j                  d|d    d|        B |j	                  g d       |j	                  d | d   D               |j                  d       dj                  |      S c c}w )Nz%# Save Selector Wrapper Execution Gap r   z
- route: `r    -> r   `z- selector: `r   z` root `r	   z- root table pointer: `r
   z- current root entry run: `r   z- wrapper entry: `r   z- wrapper descriptor: `r   z - wrapper child/frontier leaf: `r   z` / `rP   z- frontier reader: `rQ   z#- wrapper ref before current root: r   z#- current root references wrapper: r   z-- wrapper entry current-root entry-run refs: rV   z+- wrapper entry opcode5a fallthrough refs: r   z+- wrapper entry fallthrough non-code refs: r   z&- wrapper entry fallthrough handlers: r   z - wrapper entry promoting refs: r   z9- global leaf table field entries negative/non-negative: r   z / r   z.- global current selector route-pair indices: r   z.- global current frontier leaf only negative: r   z$- root table direct refs/text refs: r   r   zM- root table route-entry/route-leaf/frontier-leaf/frontier-reader text refs: r   r   r   r   z!- root table direct ref status: `r   z)- frontier leaf direct current-root ref: rh   z!- route-pair descriptor indices: r   z$- corrected route-pair reader hits: r   z#- reader-bearing negative indices: r   z"- opcode07 leaf selection absent: r   z<- opcode08 source/predecessor current root/range producers: r   r   z4- opcode09 source/predecessor current-range stores: r   z-- source/predecessor current producer count: r   z)- corrected trace normal-selection gap: `r   z.- corrected trace normal-selection gap found: r:   z0- constructed diagnostic wrapper proof status: `r   z,- constructed diagnostic runtime route hit: r    (r   z samples; observed r   )z<- constructed diagnostic left stability/recheck route hits: r   r   z4- constructed diagnostic left active-order recheck: r   z route hits; count r   z6- constructed diagnostic excluded from wrapper proof: r   z%- selected-root execution ref found: r.   z- proof found: r   z- failed wrapper gates: `r   z- missing evidence count: r   z&- current leaf selection proof found: r   z!- wrapper execution proof found: r   z/- current selector leaf execution proof found: r   z- strict hotspot found: r2   z- evidence refs: r1   z- promotion status: `r   z## Missing Evidence- z## Evidencez| kind | status | detail |z| --- | --- | --- |r   z| rr   z | rn   rs   z |)r  z## Evidence Refsr  r0   , r   z- `r   z`: )r  z## Remaining Proofsr  c              3  &   K   | ]	  }d |   yw)r!  N rF   items     rH   rI   zmarkdown.<locals>.<genexpr>  s     D2dVDs   r;   
)rM   r\   r   r   extendrK   )summaryr&  linesr^   refr   s         rH   markdownr,    s/   @/@
@ 	@ 		@
 WX&'tGH,=+>a@@ 
+,HWY5G4HJ@ "'*?"@!AC@ &g.F&G%HJ@ W%678:@ "'*@"A!B!D@ +73K+L*MUSZ[lSmRnnop@ w':;<A>@ .g6S.T-UV@ .g6T.U-VW@ 8@i8j7kl@  6g>g6h5ij!@" 6g>f6g5hi#@$ 1W=f5g1h0ij%@& +73R+S*TU'@( DGLnDoCppst{  }b  uc  td  	e)@* 9WEl=m9n8op+@, 9Ah9i8jk-@. /w7V/W.XX[\c  eH  ]I  \J  	K/@0 X;<
=S89
:#;<
=S=>
?		A1@: ,G4N,O+PPQR;@< 4G<^4_3`a=@> ,C8[0\,]+^_?@@ /w7i/j.klA@B .c':X2Y.Z-[\C@D -W5R-S,TUE@F Gw  PE  HF  GG  GJ  KR  SI  KJ  JK  	LG@H ?wGz?{>|}I@J 8@i8j7klK@L 4G<d4e3ffghM@N 9Ah9i8jkO@P ;7Cl;m:nnopQ@R 7w?j7k6llnov  xa  pb  oc  cv  wz  {B  Ck  {l  wm  vn  no  	pS@T Gw  PI  HJ  GK  KN  OV  WW  OX  NY  	ZU@V ?w  HJ  @K  ?L  L_  `g  hk  `l  _m  	nW@X AIxAy@z{Y@Z 08W0X/YZ[@\ ',/01]@^ $C4J(K$L#MQO_@` %S5F)G)M2%N$OPa@b 19Y1Z0[\c@d ,G4P,Q+RSe@f :'Bj:k9lmg@h #7+?#@"ABi@j G$6789k@l  (9 :;1=m@n 	o@p 	q@r 	s@t #*++.?"@"FB	G$Btf+	Gu@v 	w@x 	y@z 	{@| 	%}@~ 	@EB z" Or#f+c#h-CM?"MNO	LL-.{{>*0b 53778,23s3v;-s6(345 
LL01	LLD1B)CDD	LL99U! 
Hs   Mc           '        dj                  d | d   D              }dj                  d | d   D              }dj                  d | j                  d      xs g D              }dj                  d | j                  d	      xs g D              }dj                  d
dddddddddt        j                  | d          ddt        j                  | d          dt        j                  | d          dt        j                  t	        | d                dt        j                  t	        | d                dt        j                  t	        | d                d d!t        j                  t	        | d"                d#t        j                  t	        | d$                d%t        j                  t	        | d&                d't        j                  t	        | d(                d 	d)| d*    d+| d,    d-| d.    d/t        j                  t        | d0                d1| d2    d3d4| d5    d6| d7    d8| d9    d:| d;    d:| d<    d:| d=    d>t        j                  t	        | d?                d d@| dA    d:| dB    dC| dD    dE| dF    d3	dGt        j                  t	        | dH                dI| dJ    dK| dL    dM| dN    dO| dP    d3dQt        j                  t	        | dR                dS| dT    d+| dU    dVt        j                  t        | dW                dX| dY    d:| dZ    d[| d\    d]t        j                  t	        | d^                d_| d`    d3da| db    dc| dP    dd| de    df| dg    dht        j                  t        | j                  di                   djt        | j                  d      xs g        dkt        j                  | dl          d dm| dn    d3dodp| dqdrds| dtdudp| dqdvdp| dqdwdxdyg      S )zNr'  c           
   3     K   | ]R  }d t        j                  |d          dt        j                  |d          dt        j                  |d          d T yw)z<tr><td>rr   z	</td><td>rn   rs   z
</td></tr>Nhtmlescaper]   s     rH   rI   zhtml_page.<locals>.<genexpr>  sg       	{{3v;'( ){{3x=)* +{{3x=)* +	s   AAr   c              3  N   K   | ]  }d t        j                  |       d  ywz<li></li>Nr/  r%  s     rH   rI   zhtml_page.<locals>.<genexpr>  s#     cd4;;t#4"5U;c   #%r;   c              3  N   K   | ]  }d t        j                  |       d  ywr3  r/  r%  s     rH   rI   zhtml_page.<locals>.<genexpr>  s(      ,0$t{{4 !'r5  r   c              3     K   | ]h  }d t        j                  |j                  d      xs d       dt        j                  dj                  |j                  d      xs g              d j yw)z
<li><code>r   r  z	</code>: r"  r   r4  N)r0  r1  r\   rK   )rF   r+  s     rH   rI   zhtml_page.<locals>.<genexpr>  sf      #
 		SWWV_234I;;tyy!2!8b9:
;	#s   A.A0r0   z<!doctype html>z<html lang="en">z<head>z  <meta charset="utf-8">z4  <title>Save Selector Wrapper Execution Gap</title>a    <style>body{font-family:system-ui,sans-serif;margin:24px;line-height:1.45;max-width:1200px}table{border-collapse:collapse;width:100%;margin:16px 0}td,th{border:1px solid #ddd;padding:6px 8px;text-align:left;vertical-align:top}th{background:#f5f5f5}code{white-space:nowrap}</style>z</head>z<body>z.  <h1>Save Selector Wrapper Execution Gap</h1>z  <p>r   z</p>z  <p><b>Route:</b> <code>r   r  r   z</code>; selector <code>r   z</code>; root <code>r	   z</code>; table <code>r
   z</code>.</p>z!  <p><b>Wrapper:</b> entry <code>r   z</code>; descriptor <code>r   z</code>; child <code>r   z</code>; frontier reader <code>rQ   z-  <p><b>Global leaf table:</b> field entries r   r  r   z negative / r   zA non-negative); global current selector route-pair indices <code>r   z5</code>; global current frontier leaf only negative: r   z.</p>z$  <p><b>Root table direct refs:</b> r   z refs / r   zK text refs; route-entry/route-leaf/frontier-leaf/frontier-reader text refs r   rc   r   r   r   z; status <code>r   zF  <p><b>Source/predecessor producers:</b> opcode08 current root/range r   r   z ; opcode09 current-range stores r   z,; source/predecessor current producer count r   z8  <p><b>corrected trace normal-selection gap:</b> <code>r   z*</code>; route-pair reader trace grounded r   z, reader negative-only r   z, runtime selection r   z, wrapper proof r   z^  <p><b>Constructed diagnostic recheck:</b> constructed diagnostic wrapper proof status <code>r   z</code>; runtime route hit r   r   z samples, observed <code>r   zC</code>); constructed diagnostic left stability/recheck route hits r   r   z>; constructed diagnostic left active-order recheck route hits r   z with count <code>r   z%</code>; excluded from wrapper proof r   z)  <p>current leaf selection proof found: r   z!; wrapper execution proof found: z/; current selector leaf execution proof found: r   z; proof found: r   z; failed wrapper gates: <code>r   z!</code>; missing evidence count: z; promotion status: <code>r   z  <p><b>Evidence refs:</b> r1   z  <h2>Missing Evidence</h2>z  <ul>z</ul>z  <h2>Evidence</h2>zS  <table><thead><tr><th>kind</th><th>status</th><th>detail</th></tr></thead><tbody>z</tbody></table>z  <h2>Evidence Refs</h2>z  <h2>Remaining Proofs</h2>z</body>z</html>r  )rK   r\   r0  r1  rE   rM   r   )r)  evidence_rowsproof_itemsmissing_itemsevidence_ref_itemss        rH   	html_pager<    s   II  :& M ))cPaHbccKII 4;KK@Q4R4XVX M  #
 ;;~.4"#  99&B i<DKK 567t<WX%678T[[QYIZ=[<\ ]""&++c'*2E.F"G!H I"kk#gi.@*ABC D#{{3w7L/M+NOPP\	^#{{3w7H/I+JKL M$$(KKG<R4S0T$U#V W#{{3w7O/P+QRS T))-SAT9U5V)W(XXd	f!!()C!D E F>?@@AB CS1X)Y%Z[\ ]?BCDEK 7:;<H>?@ ARCDEQ@AB!CDEQEFG HS1K)L%MNO|	]/PQRRSQRS T1NOP Q=DEFeMS1Y)Z%[\] ^44;<Z4[3\ ]((/0K(L'M N%%,-E%F$G H!!()E!F GuNS1Z)[%\]^ _%%,-X%Y$Z [EFG HS1Y)Z%[\] ^LTUVVW[\] ^O]^_ `$$(KKG<  5A  1B  %C  $D D//67f/g.hhmo <;<= >2789 :@CDE F <() *S5K)L%MNO P+w{{#45;<= >W->%?@AO *'2D*E)FeL)]O5)!aboap  qA  B&'(.)[M'Wl	
n nrN   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_wrapper_execution_gap.jsonF   )ensure_asciiindentr'  utf-8encoding(save_selector_wrapper_execution_gap.html)mkdir
write_textjsondumpsr<  )r)  out_dirs     rH   write_outputsrL    sf    MM$M.99EE

7q9D@ F  99EEiPWFXcjEkrN   c                L    t        j                  | j                  d            S )NrC  rD  )rI  loads	read_text)r   s    rH   	load_jsonrP    s    ::dnngn677rN   c                 h   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
        d
z         | j                  dt        t
        dz         | j                  dt        t
        dz         | j                  dt        t
        dz         | j                  dt        t
        dz         | j                  dt        t
        dz         | j                  dt        t
        dz         | j                  dt        t
        dz         | j                  dt        t
               | j                         }t        t        |j                        t        |j                        t        |j                        t        |j                        t        |j                        t        |j                        t        |j                        t        |j                         t        |j"                        t        |j$                        t        |j&                              }t)        ||j*                         t-        d|j*                  dz          y )N)descriptionz--leaf-table-contextz%save_selector_leaf_table_context.json)typedefaultz--leaf-table-global-contextz,save_selector_leaf_table_global_context.jsonz--wrapper-descriptor-contextz-save_selector_wrapper_descriptor_context.jsonz--route-pair-descriptor-contextz0save_selector_route_pair_descriptor_context.jsonz--opcode07-indexed-pointersz,save_selector_opcode07_indexed_pointers.jsonz--opcode08-activation-windowsz.save_selector_opcode08_activation_windows.jsonz--opcode09-pointer-collisionsz.save_selector_opcode09_pointer_collisions.jsonz--selected-root-execution-gapz.save_selector_selected_root_execution_gap.jsonz--current-root-frontier-pathsz.save_selector_current_root_frontier_paths.jsonz--merge-execution-gapz&save_selector_merge_execution_gap.jsonz --route-pair-entry-execution-gapz1save_selector_route_pair_entry_execution_gap.jsonz	--out-dirz(wrote selector wrapper execution gap -> rF  )argparseArgumentParser__doc__add_argumentr   OUT
parse_argsr  rP  r   r   r   r   r   r   r   r   r   r   r   rL  rK  print)parserargsr)  s      rH   mainr^    s   $$9F
.T3IpCpq
%DD  
 &EE  
 )HH  
 %DD  
 'FF  
 'FF  
 'FF  
 'FF  
 >>  
 *II  
 $<D$))*$001$112$445$001$223$223$223$223$**+$556G '4<<(	4T\\Dn5n4o
pqrN   __main__)rL   zlist[Any] | NonereturnrE   rD   )r   dictr   ra  r   ra  r   ra  r   ra  r   ra  r   ra  r   ra  r   ra  r   ra  r   zdict | Noner`  ra  )r)  ra  r`  rE   )r)  ra  rK  r   r`  None)r   r   r`  ra  )r`  rb  )rW  
__future__r   rU  r0  rI  pathlibr   typingr   __file__resolver>  ROOTrY  r   r   rM   r  r,  r<  rL  rP  r^  __name__r$  rN   rH   <module>rj     s   M "      H~''*
Ul <

 C
 D

 G
	 C
 E
 E
 E
	 E
 =
 H
Gl` 	Y 	\ 	R	# X$  $A 37cc#c !%c $(	c
  $c "&c "&c "&c "&c c %0c 
cLK\BJ 25 l8ErP zF rN   