
    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edz  Zed	z  Zed
z  Zedz  Zedz  Zedz  Zedz  Zedz  ZdZdZdZdZg dZg dZdg dddg dddg dddg dddg ddd d!d"gdd#g d$dd%g d&dgZd@d'ZdAd(ZdBd)Z dCd*Z!dDd+Z"dEd,Z#dFd-Z$dGd.Z%dHd/Z&dId0Z'	 	 	 	 	 	 dJd1Z(dKd2Z)dLd3Z*dMd4Z+dNd5Z,	 	 	 	 	 	 dOd6Z-	 	 	 	 	 	 	 	 	 	 dPd7Z.dQd8Z/dQd9Z0	 	 	 	 	 	 	 	 dR	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dSd:Z1dTd;Z2dTd<Z3edfdUd=Z4dVd>Z5e6d?k(  r e5        yy)WzTSummarize source-save load-only evidence against source-exit runtime proof attempts.    )annotationsN)Path)Any   outz@runtime_selected_pointer_source_savedata_load_variants_poll.jsonzBruntime_selected_pointer_source_savedata_load_coordinate_poll.jsonzJruntime_selected_pointer_source_exit_branch_state_load_confirmed_poll.jsonzBruntime_selected_pointer_source_exit_adaptive_coordinate_poll.jsonzCruntime_selected_pointer_source_exit_adaptive_trail_start_poll.jsonz!save_selector_mapset_aliases.jsonz(save_selector_scene_adjacency_index.jsonz0save_selector_global_selected_pointer_paths.jsonmap1_01amap2_02dz0:02:0)zstrict-source-hotspotzselected-root-executionz'route-selector-current-root-observationz!source-exit-candidate-observationzroute-promotion-evidence)z<strict map1_01a source hotspot or equivalent runtime triggerzDselected-root/current-root execution while the source-save path runszVruntime source-ready path reaching selector 2:0/current root instead of selector 48:13zUcandidate/outside exit coordinate or actor/trail observation for map1_01a -> map2_02dz<route-promotion evidence linking the source save to map2_02dzDout/runtime_selected_pointer_source_savedata_load_variants_poll.json)observedSelectorsobservedPublicSaveSelectorssampleCount)pathfieldszFout/runtime_selected_pointer_source_savedata_load_coordinate_poll.json)r   sourceStartTileObservedr   zNout/runtime_selected_pointer_source_exit_branch_state_load_confirmed_poll.json)r   sourceExitAnalysisr   zFout/runtime_selected_pointer_source_exit_adaptive_coordinate_poll.json)classificationsourceReadyCountcandidateObservedoutsideObservedr   zGout/runtime_selected_pointer_source_exit_adaptive_trail_start_poll.jsonz%out/save_selector_mapset_aliases.jsonaliasGroups	selectorsz,out/save_selector_scene_adjacency_index.json)rowsselectorAdjacencyOnlyPairCountstrictEventBackedCountz4out/save_selector_global_selected_pointer_paths.json)selectedPointerGlobalHexopcode07Countopcode08Countopcode09Countc                 h    t         D  cg c]  } t        | d   z  j                         r|   c} S c c} w )Nr   ).RUNTIME_SOURCE_SAVE_LOAD_VARIANT_EVIDENCE_REFSROOTexists)refs    O/home/exedev/hwanse/tools/summarize_runtime_source_save_load_variant_context.pyexisting_evidence_refsr%   L   s:     B3v;&&( 	  s   #/c                B    dj                  d | xs g D              xs dS )N,c              3  2   K   | ]  }t        |        y wNstr.0values     r$   	<genexpr>zlist_text.<locals>.<genexpr>U   s     95CJ9   -)join)valuess    r$   	list_textr4   T   s     889FLb99@S@    c                :    t        j                  | xs i dd      S )NT)r'   :)	sort_keys
separators)jsondumps)r.   s    r$   compact_jsonr<   X   s    ::ekrTjIIr5   c                p    | j                         r%t        j                  | j                  d            S i S )Nutf-8encoding)r"   r:   loads	read_text)r   s    r$   	load_jsonrC   \   s)    ;?;;=4::dnngn67PbPr5   c           	        g }| j                  d      xs g D ]i  }t        |t              s|j                  |j                  d      |j                  d      |j                  d      |j                  d      xs g d       k |S )NuniqueSelectorContextsselectorcountrootHex	fieldMaps)rF   rG   rH   rI   )get
isinstancedictappend)rowr   items      r$   selector_count_rowsrP   `   s    D017R $%,XXg&xx	*+.4"	
 	 Kr5   c                   |sg S t               }t        |       D ]B  }|j                  d      |k(  s|j                  d |j                  d      xs g D               D | j                  d      xs g D ]W  }|j                  d      xs i }|j                  d      |k(  s-|j                  d |j                  d      xs g D               Y t	        |      S )NrF   c              3  2   K   | ]  }t        |        y wr)   r*   r,   s     r$   r/   z*field_maps_for_selector.<locals>.<genexpr>t   s     LuE
Lr0   rI   eventsselectorContextc              3  2   K   | ]  }t        |        y wr)   r*   r,   s     r$   r/   z*field_maps_for_selector.<locals>.<genexpr>x   s     OuE
Or0   )setrP   rJ   updatesorted)rN   rF   mapsrO   eventcontexts         r$   field_maps_for_selectorr\   n   s    	UD#C( M88J8+KKL0E0KLLM "(b P))-.4";;z"h.KKOK0H0NBOOP $<r5   c                   g }| j                  d      xs g D ]P  }|j                  d      xs i }|j                  d      }|s,|r	|d   |k7  s7|j                  t        |             R |r|S |D cg c]  }t        |       c}S c c}w )NrS   rT   rF   )rJ   rM   r+   )rN   fallback_selectorsr   rZ   r[   rF   s         r$   selector_event_pathr`   |   s    D"(b '))-.4";;z*TT"X%9KKH&	'
 *<=hCM===s   3Bc                ,    | D ]  }|t         k7  s|c S  y r)   )SOURCE_SELECTOR)r   rF   s     r$   first_non_source_selectorrc      s#     &O r5   c                   | D cg c];  }t        |j                  d      t              rt        |j                  d            = }}| D cg c];  }t        |j                  d      t              rt        |j                  d            = }}t        d | D              }|rt	        |      nd |rt        |      nd |rt	        |      nd |rt        |      |dS d |dS c c}w c c}w )Nxyc              3     K   | ]A  }t        |j                  d       t              r t        |j                  d       xs d       C yw)rG   r   N)rK   rJ   intr-   pairs     r$   r/   z camera_extent.<locals>.<genexpr>   s>      dhhw'- 	DHHW"#s   AA	)minXmaxXminYmaxYr   )rK   rJ   rh   summinmax)camera_pairsrj   xsystotal_counts        r$   camera_extentrv      s     !
dhhsmS) 	DHHSM
B 
 !
dhhsmS) 	DHHSM
B 

    K B4B4B4B"  $(" 


s   A CA C#c           	        | j                  d      xs g D cg c].  }t        |t              r|j                  d      n
t        |      0 }}t	        | |      }t        |      }| j                  d      xs g }i d| j                  d      d| j                  d      d| j                  d      d| j                  d      d| j                  d      d	| j                  d	      d
| j                  d
      d|dt        |       d|d|dt        | |      d|dt        |      d| j                  d      d| j                  d      d| j                  d      xs g | j                  d      xs g | j                  d      xs g | j                  d      xs g | j                  d      | j                  d      | j                  d      dS c c}w )NrE   rF   cameraPairsnamecandidateNameattemptsourceReadypathExecutedr   pathStepCountr   selectorCountsselectorPathfirstNonSourceSelectorfirstNonSourceFieldMapscameraExtentcameraCandidateObservedcameraOutsideObservedactorCandidateSlotstrailCandidateSlotsactorOutsideSlotstrailOutsideSlotsrouteSelectorHitCountcurrentRootHitCountbranchStateAllZero)r   r   r   r   r   r   )	rJ   rK   rL   r+   r`   rc   rP   r\   rv   )rN   rO   r   selector_path
non_sourcerr   s         r$   summarize_adaptive_rowr      s%    GG45; !+4 6CIEI  (Y7M*=9J77=)/RL1 	3779% 	sww}-	
 	/ 	sww}- 	1 	Y 	-c2 	 	!* 	"#:3
#K 	| 	l3 	"377+D#E  	 )@!A!" 	sww'<=C#$  #ww'<=C WW%89?R WW%89?R!$)@!A"ww'<=!gg&:;/ s   3Gc                &   g }d| fd|ffD ]Q  \  }}|D ]G  }|j                  d      s|j                  d      s't        |      }||d<   |j                  |       I S i i }g }d}	d}
|D ])  }|j                  d      }|r[j                  |d      dz   |<   |j                  |t	                     j                  d	 |j                  d
      xs g D               |j                  |j                  d      xs g        |j                  d      s|j                  d      r|	dz  }	|j                  d      sW|j                  d      sF|j                  d      s5|j                  d      s$|j                  d      s|j                  d      s%|
dz  }
, d }rt        fd      d   }t        |xr  |	dk(  xr |
dk(  xr t        d |D                    }t        dt        |      t        d |D              t        d |D              |D cg c]  }|j                  d       c}||r#t        |j                  |t	                           ng |	|
||r|dk(  rdndt        |      |D cg c]  }|j                  d      |j                  d      |j                  d      |j                  d      |j                  d      |j                  d
      |j                  d       |j                  d      |j                  d      t        |j                  d      xs] |j                  d      xsJ |j                  d      xs7 |j                  d      xs$ |j                  d      xs |j                  d            d!
 c}d"S c c}w c c}w )#NadaptiveExitadaptiveTrailStartr|   r}   familyr   r   r   c              3  2   K   | ]  }t        |        y wr)   r*   r,   s     r$   r/   z(summarize_ready_paths.<locals>.<genexpr>   s      K$E
Kr0   r   rx   r   r   r   r   r   r   r   r   c                    |     | fS r)    )rF   first_non_source_countss    r$   <lambda>z'summarize_ready_paths.<locals>.<lambda>   s    #:8#D"Dh!O r5   )keyc              3  >   K   | ]  }|j                  d         yw)r   NrJ   r-   rN   s     r$   r/   z(summarize_ready_paths.<locals>.<genexpr>   s     Hc01Hs   r
   c              3  J   K   | ]  }|j                  d       dk(  sd  yw)r   r   r   Nr   r   s     r$   r/   z(summarize_ready_paths.<locals>.<genexpr>   s!     %eCARVdAda%e   ##c              3  J   K   | ]  }|j                  d       dk(  sd  yw)r   r   r   Nr   r   s     r$   r/   z(summarize_ready_paths.<locals>.<genexpr>   s!     *pcgghFW[oFo1*pr   ry   z48:13z9source-ready-path-diverts-to-48:13-before-exit-candidatesz(source-ready-path-diversion-unclassifiedrz   r   r   )
r   ry   rz   r   r   r   r   r   r   candidateOrOutsideObserved)sourceSelectortargetSelectorreadyPathCountadaptiveReadyPathCountadaptiveTrailReadyPathCountreadyPathNamesfirstNonSourceSelectorCountsdominantNonRouteSelectordominantNonRouteFieldMapsrouteOrCurrentReadyPathCount candidateOrOutsideReadyPathCount%allReadyPathsDivertToNonRouteSelectordiversionClassificationr   r   )rJ   rL   rM   
setdefaultrV   rW   extendrX   boolallrb   lenro   rv   )adaptive_rowsadaptive_trail_rows
ready_rowsr   r   rN   taggedfirst_non_source_field_mapsrr   route_or_current_countcandidate_or_outside_countrF   dominant_selector
all_divertr   s                 @r$   summarize_ready_pathsr      s    (*J(-8;OQd:ef * 	*Cww}%#''.*Ac#)x !!&)		** /179)+L!" ,77340G0K0KHVW0X[\0\#H-'228SUCJJ K(+0I(J(PbK  	CGGM28b977*+sww7L/M"a'"GG-.ww./ww,-ww,-ww*+ww*+&!+&%,& "#O
   	I"a'	I&!+	I HZHH	J *j/"%%e:%e"e'**p
*p'p6@As3776?A(?$5 &,,G,K,KL]_b_d,e%f(>,F1;+w6 $_7%l3* ")
( % ''(+!$!9 # 7*-''2J*K+.773L+M # 7),1H)I'*ww/D'E.2GG56 4ww674ww454 ww454 ww23	4
 ww23/
') ) B
s   N	0DN c                :    syt        fd| xs g D              S )NFc              3  :   K   | ]  }t        |      k(    y wr)   r*   )r-   r.   rF   s     r$   r/   z#selector_matches.<locals>.<genexpr>)  s     @%s5zX%@s   )any)r3   rF   s    `r$   selector_matchesr   &  s    @6<R@@@r5   c                   si S | j                  d      xs g D ]/  }|j                  d      xs g }t        fd|D              s-|c S  | j                  d      xs i }|j                  d      xs g }t        fd|D              r|S i S )NduplicateGroupsaliasesc              3  h   K   | ])  }t        |t              s|j                  d       k(   + ywrF   NrK   rL   rJ   r-   aliasrF   s     r$   r/   z#find_alias_group.<locals>.<genexpr>1  s*     aUTY[_I`uyy$0a   22targetAliasGroupc              3  h   K   | ])  }t        |t              s|j                  d       k(   + ywr   r   r   s     r$   r/   z#find_alias_group.<locals>.<genexpr>5  s*     
]ZPUW[E\599Z H,
]r   )rJ   r   )mapset_aliasesrF   groupr   target_groups    `   r$   find_alias_groupr   ,  s    	##$56<" ))I&,"agaaL "%%&89?RLy)/RG

]'
]]Ir5   c                    | j                  d      xs g D ]+  }t        |t              s|j                  d      |k(  s)|c S  i S )Nr   rF   )rJ   rK   rL   )alias_grouprF   r   s      r$   	alias_rowr   :  sE    +1r eT"uyy'<'HL Ir5   c                T   g }| j                  d      xs g D ]  }t        |j                  d      |      s |j                  |j                  d      |j                  d      |j                  d      |j                  d      xs g |j                  d      xs g |j                  d      xs g |j                  d      xs g t        |j                  d	            t        |j                  d
            t        |j                  d            |j                  d      d        |S )NpairRowsr   sourcetargetoccurrenceCountleafPointerssourceRecordstargetRecordsstrictEventBackedconfirmedReviewBackedselectorAdjacencyOnlyr   )r   r   r   r   r   r   r   r   r   r   r   )rJ   r   rM   r   )scene_adjacencyrF   r   rN   s       r$   scene_adjacency_rowsr   A  s    !#D"":.4" CGGK0(;KK''(+''(+#&77+<#= WW[17R # 7 =2!$!9!?R!$!9!?R%)#''2E*F%G)-cgg6M.N)O)-cgg6M.N)O"%''*:";  Kr5   c                .   |si S | j                  d      xs g D ]w  }t        |j                  d      |      s i d|j                  d      d|j                  d      xs g d|j                  d      d|j                  d      d|j                  d      dt        |j                  d            d|j                  d      xs g d	|j                  d	      d
|j                  d
      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      ic S  i S )NselectorRootScansselectorLabelsprimarySelectorrH   rangeHexsectionisCurrentRootrI   fieldMapCountr   r   r   opcode07SelectsCurrentRootCount opcode07SelectsCurrentRangeCountopcode09StoresCurrentRootCountopcode09StoresCurrentRangeCount'opcode08NearestCurrentRootProducerCount(opcode08NearestCurrentRangeProducerCountpromotingCandidateCount)rJ   r   r   )selected_pointer_pathsrF   rN   s      r$   selected_pointer_path_forr   U  s    	%))*=>D" CGG$45x@!377+<#= #''*:";"Ar 3779- CGGJ/	
 3779-  cggo&>!? SWW[17R  !9  !9  !9  !9 2377;\3] 3CGG<^4_ 1#'':Z2[ 2377;\3]  :377=<!& ;CGG>=', *3773L+M- 4 Ir5   c                L   | j                  d      }| j                  d      xs g }t        ||      }t        ||      }|j                  d      xs g D cg c]4  }t        |t              r"|j                  d      r|j                  d      6 }	}t        ||      }
t        ||      t        d |
D              }t        d |
D              }t        d |
D              }t        |j                  d            xs t        |v }t        |j                  d	            xs t        |v }t        fd
dD              }t        |t        k(  xs% |xr |xs |xs |xs |xs |j                  d            }|r|s|t        |
      k(  r|s|sd}nd}i dt        dt        d|d|d|d|t        k(  d|t        t        hv d|d|d|	d|j                  d      xs |d|j                  d      d|j                  d      d|j                  d      d|j                  d       d!t        |j                  d            d"t        |j                  d	            |
t        |
      |||t              |t        |j                  d            ||dk(  rd#d%S d$d%S c c}w )&Nr   r   r   rF   c              3  D   K   | ]  }|j                  d       sd  yw)r   r   Nr   r   s     r$   r/   z-diversion_selector_context.<locals>.<genexpr>  s     SScgg>Q6RqS     c              3  D   K   | ]  }|j                  d       sd  yw)r   r   Nr   r   s     r$   r/   z-diversion_selector_context.<locals>.<genexpr>  s     ZAX9Y!Zr   c              3  D   K   | ]  }|j                  d       sd  yw)r   r   Nr   r   s     r$   r/   z-diversion_selector_context.<locals>.<genexpr>  s     ^CSWWE\=]a^r   containsSourcecontainsTargetc              3  Z   K   | ]"  }t        j                  |      xs d        $ yw)r   N)rh   rJ   )r-   r   selected_paths     r$   r/   z-diversion_selector_context.<locals>.<genexpr>  s.      & 	Mc"'a(&s   (+)r   r   r   r   r   r   r   selectedRootExecutionRefFoundz!non-route-selector-adjacency-onlyz'diversion-selector-context-unclassifiedr   r   rI   r   selectorEqualsTargetSelectorselectorInRoutePaircontainsSourceMapcontainsTargetMapaliasGroupSelectorsaliasGroupFieldMapsaliasRootHexrH   aliasRootAddressOrderIndexrootAddressOrderIndexaliasSelectedPointerEntryHexselectedPointerEntryHexaliasFillCount	fillCountaliasContainsSourcealiasContainsTargeta*  Source-ready paths leave public selector 0:0 through selector 48:13, which belongs to the map2_04l/map2_05e scene-list alias group. That selector has selector-adjacency-only rows and no map1_01a/map2_02d route-pair, strict event, confirmed review, current-root, or selected-root promotion evidence.zNThe diversion selector context did not match the known non-route-only pattern.)sceneAdjacencyRowssceneAdjacencyRowCount#sceneAdjacencySelectorOnlyPairCount$sceneAdjacencyStrictEventBackedCount(sceneAdjacencyConfirmedReviewBackedCountselectedPointerPathselectedPointerPathFound.selectedPointerPathSelectsOrStoresCurrentCountr   routePromotionEvidenceFound
conclusion)rJ   r   r   rK   rL   r   r   ro   r   
SOURCE_MAP
TARGET_MAPTARGET_SELECTORr   rb   )ready_path_summaryr   r   r   rF   
field_mapsr   r   rN   r   adjacency_rowsstrict_countconfirmed_countselector_only_countcontains_sourcecontains_targetselected_path_current_countroute_promotion_foundr   r   s                      @r$   diversion_selector_contextr!  x  sK    "%%&@AH#''(CDJJ">8<Kk8,E ??9-3c4 SWWZ%8 	
G 
 */8DN-.DhOMSNSSLZ~ZZO^>^^;??+;<=YzAYO;??+;<=YzAYO"% &
& # !O# 	G.	G	G 	G '		G
 "%%&EF 	%3~#66<B$/$/$ 	H$ 	Z	$
 	.$ 	'O(C$ 	xO_+MM$ 	_$ 	_$ 	w$ 	{{;Iz$ 			),$ 	%eii0G&H$ 	'		2K(L$ 	%))K0$  	tKOO4D$EF!$" 	tKOO4D$EF#$$ -"%n"5/B0<4C,$($7:U)-.D.H.HIh.i)j'< @@";$ $F ^G$ $Us   9J!c                   g }| j                  d      xs g D ]  }|j                  d      xs g D cg c].  }t        |t              r|j                  d      n
t        |      0 }}|j	                  |j                  d      |j                  d      |t
        |v |j                  d      |j                  d      d        |S c c}w )	Nr   rE   rF   ry   r   r   r   )ry   r   r   sourceSelectorObservedr   r   )rJ   rK   rL   r+   rM   rb   )summaryr   rN   rO   r   s        r$   selector_rowsr%    s    D{{6"(b   89?R
 %/tT$:DHHZ D	I
	 
 	GGFO77=1"&5&B%(WW-D%E#&77+@#A
 	 K
s   3Cc                   | j                  d      xs i j                  d      xs g D cg c]B  }|j                  d      |j                  d      |j                  d      xs g D cg c].  }t        |t              r|j                  d      n
t        |      0 c}|j                  d      |j                  d      |j                  d	      |j                  d
      |j                  d      |j                  d      xs g |j                  d      xs g |j                  d      xs g |j                  d      xs g |j                  d      |j                  d      |j                  d      dE c}}S c c}w c c}}w )Nr   r   ry   r   r   rF   candidateTileoutsideTilecandidateSider   r   r   r   r   r   r   r   r   )ry   r   r   r'  r(  r)  r   r   r   r   r   r   r   r   r   )rJ   rK   rL   r+   )r$  rN   rO   s      r$   exit_candidate_rowsr*    sX   , KK 45;@@HNB+ * ' GGFO77=1  GGK06B )34(>$CIM !WW_577=1 WW_5'*ww/H'I%(WW-D%E#&77+@#A#GR#&77+@#A#GR!$)<!=!C!$)<!=!C%(WW-D%E#&77+@#A"%''*>"?%	
 	s   =E=)3E8CE=8E=c                j   | xs i } |xs i }|xs i }|xs i }|xs i }|xs i }|xs i }|xs i }t        |       }|j                  d      xs i }	t        |      }
t        | j                  d      xs g v }t	        |	j                  d            }t	        |	j                  d            }t        |j                  d      xs g v }t	        |j                  d            }t	        |j                  d            }t	        |j                  d            }t	        |j                  d            }t	        |j                  d            }t	        |j                  d            }t	        |j                  d      xs |j                  d            }t	        |j                  d      xs |j                  d            }t	        |j                  d	      xs |j                  d	            }|j                  d
      xs g D cg c]  }t        |       }}|j                  d
      xs g D cg c]  }t        |       }}t        ||      }t        ||||      }|s|s|s|rd}d}n5|r	|s|sd}d}n*|r	|r|sd}d}n|r|sd}d}n|r	|s|rd}d}n|rd}d}nd}d}|dk(  }t               } i dt        dt        dt        d|d|dk7  rdndd|d |d!|rg nt        d"|rg nt        d#| d$t        |       d%d&| j                  d'      | j                  d(      | j                  d)      xs g | j                  d*      xs g | j                  d      xs g |t	        | j                  d            t	        | j                  d            |d+
d,d-|j                  d'      |j                  d(      |j                  d)      xs g |j                  d*      xs g |j                  d      xs g |	j                  d      ||t	        |j                  d            t	        |j                  d            |	j                  d
      xs g d.d/i d0d1d2|j                  d2      xs g d'|j                  d'      d(|j                  d(      d)|j                  d)      xs g d*|j                  d*      xs g d|j                  d      xs g d3|d|d|dt	        |j                  d4      xs i j                  d5            d	t	        |j                  d4      xs i j                  d6            d7t	        |j                  d4      xs i j                  d8            d9t	        |j                  d4      xs i j                  d:            d
t        |      d;|
d<d=|j                  d'      |j                  d(      |j                  d>      |j                  d      |j                  d)      xs g |j                  d      t	        |j                  d            t	        |j                  d	            |||d?d@dA|j                  d'      |j                  d(      |j                  d>      |j                  d      |j                  dB      xs i |j                  dC      |j                  dD      |j                  d)      xs g |j                  d      t	        |j                  d            t	        |j                  d	            |||dEdF||dG|xs |xs |xs
 |xs |xs ||dk(  |dHS c c}w c c}w )INsourceLoadCoordinateAnalysisr   r#  r   anyReachedRouteSelectorContextanyReachedCurrentRootr   r   r   r   zroute-observedzGThe adaptive source exit poll observed the route selector/current root.z#source-ready-adaptive-exit-no-routea  The source save can load selector 0:0 with camera tile 0,2. Adaptive exit probes caught source-ready attempts from both the camera-derived start and the observed trail0 start before executing routeAssist paths. Those source-ready paths still observed no routeAssist exit coordinate, selector 2:0, or current root. The source save is therefore useful as source-load/start-coordinate context, not as strict exit-hotspot or selected-root execution proof.z>source-start-coordinate-observed-exit-path-source-not-observeda  A bounded load-menu variant can observe public selector 0:0 together with the source camera tile 0,2. However, the coordinate/branch-state exit-path poll with the same source save remains in selector 50:0 and does not observe any routeAssist exit coordinate, selector 2:0, or the current root. The source save is therefore useful as source-load/start-coordinate context, not as strict exit-hotspot or selected-root execution proof.z7load-only-source-observed-exit-path-source-not-observedal  A bounded load-menu variant can observe public selector 0:0, but the coordinate/branch-state exit-path poll with the same source save remains in selector 50:0 and does not observe map1_01a coordinates, selector 2:0, or the current root. The source save is therefore useful as loadability context only, not as strict source-hotspot or selected-root execution proof.z>The source exit poll observed the route selector/current root.zsource-observed-exit-nonroutez}The source exit poll observed public selector 0:0, but did not reach selector 2:0/current root or a strict source coordinate.z source-not-observed-in-exit-pathzgThe source exit poll did not observe public selector 0:0; no route evidence is available from this run.	sourceMap	targetMapsourceSaveSelectorr   promotionStatusblocked	candidate
proofFound&runtimeSourceSaveLoadVariantProofFound)failedRuntimeSourceSaveLoadVariantGateIdsmissingEvidenceevidenceRefsevidenceRefCountloadVariant;runtime_selected_pointer_source_savedata_load_variants_pollr   sequenceCountr   publicSaveSelectors)
r   r   r=  r   r>  r   sourceSaveObservedr-  r.  r   coordinateLoad=runtime_selected_pointer_source_savedata_load_coordinate_poll)r   r   r=  r   r>  r   analysisClassificationr?  r   r-  r.  r   exitPathr   Eruntime_selected_pointer_source_exit_branch_state_load_confirmed_poll
loadPrefixr?  r   anyCandidateObservedanyOutsideObservedactorOrTrailCandidateObserved anyActorOrTrailCandidateObservedactorOrTrailOutsideObservedanyActorOrTrailOutsideObservedcandidateRowsr   =runtime_selected_pointer_source_exit_adaptive_coordinate_pollcandidatePlanCount)r   r   r=  rN  r   r   r   r   r   r-  r.  r   r   >runtime_selected_pointer_source_exit_adaptive_trail_start_pollsourceStartTilesourceStartOriginsourceReadyWatchKey)r   r   r=  rN  r   rP  rQ  rR  r   r   r   r   r-  r.  r   readyPathSummaryF)diversionSelectorContextstrictSourceHotspotProofFoundselectedRootExecutionProofFoundr  r  )r%  rJ   r*  rb   r   r   r   r!  r%   r  r  0FAILED_RUNTIME_SOURCE_SAVE_LOAD_VARIANT_GATE_IDS1RUNTIME_SOURCE_SAVE_LOAD_VARIANT_MISSING_EVIDENCEr   )!load_variant_pollload_coordinate_pollload_confirmed_exit_polladaptive_exit_polladaptive_trail_start_pollr   r   r   load_variant_rowscoordinate_analysis	exit_rowsload_variant_observedcoordinate_source_observedcoordinate_start_observedexit_observed	route_hitcurrent_hitadaptive_route_hitadaptive_current_hitadaptive_trail_route_hitadaptive_trail_current_hitadaptive_source_readyadaptive_candidateadaptive_outsiderN   r   r   r  diversion_contextr   r  proof_foundevidence_refss!                                    r$   build_summaryrq    s    */R/527=2+1r 9 ?R#)rN%+O39r%&78.223QRXVX#$<=I+0A0E0EFc0d0jhjk!%&9&=&=>V&W!X $%8%<%<=V%W X#(@(D(DEb(c(igijM-112RSTI/334KLMK0445UVW 2 6 67N OP#$=$A$ABb$cd!%&?&C&CD[&\!] !3!7!78J!K  "AOhOlOlm  PA  B0445HIMfMjMjk~M  A.223DEyIbIfIfgxIyz<N<R<RSY<Z<`^`aS+C0aMaB[B_B_`fBgBmkmn31#6nn.}>QR2	 15MQk)^
	'9BR>= 	 
$(A-Y 	 
}RM 	 
I)U
	8( 	
 <u 	 !$44K*,MlZlZl 	ol 	.	l
 	:J(J9P[l 	kl 	1+l 	4B#Sl 	B#Tl 	l 	C.l  	S,00?.22?C!2!6!67J!K!Qr#4#8#89N#O#USU+<+@+@A^+_+ece"7.23D3H3HIi3j.k%)*;*?*?@W*X%Y%
!l8 	U/33MB155oF!5!9!9:M!N!TRT#7#;#;<Q#R#XVX+?+C+CDa+b+hfh&9&=&=>N&O"<'@.23G3K3KLl3m.n%)*>*B*BCZ*[%\'++F39r
9lT 	 
]
266|DJ
 377F
 599/J	

  !9!=!=>Q!R!XVX
 "#;#?#?@U#V#\Z\
 *+C+G+GHe+f+ljl
 !-
 -i
 $[
  '?'C'CDX'Y'_]_&d&de{&|!}
 t%=%A%ABV%W%][]$b$bcw$xy
 ,T)--.BCIrNNOqr.
  *4)--.BCIrNNOop,!
& M":;'
( Y)
Ul@ 	U-11-@/33OD"4"8"89M"N0445EF!3!7!78K!L!RPR 2 6 67I J!%&8&<&<=P&Q!R#$6$:$:;L$MN.@%9!
Al\ 	V488G6::?K";"?"?@T"U7;;<LM8<<=NOUSU!:!>!>?R!S#<#@#@AV#W!:!>!>?R!S!YWY 9 = =>P Q!%&?&C&CDW&X!Y#$=$A$ABS$TU.F%?'
]l~ 	.l@ %6). **!* $* (	*
 *'59I'I Wl lm bns    \++\0c           !     t   | j                  d      xs i }| j                  d      xs i }| j                  d      xs i }| j                  d      xs i }| j                  d      xs i }| j                  d      xs i }| j                  d      xs i }|j                  d      xs i }|j                  d	      xs i }	g d
dd| j                  d       d| j                  d       dd| j                  d       dd| j                  d       dd| j                  d       dd| j                  d       d| j                  d       dt        | j                  d             dd| j                  d       dt        |j                  d              dd!t        |j                  d"             dd#t        |j                  d              dd$|j                  d%       d&|j                  d'       d(t        |j                  d              dd)t        |j                  d"             dd*|j                  d+       d&|j                  d,       d-|j                  d.       d/|j                  d+       d&|j                  d,       d0|j                  d.       d1|j                  d+       d&|j                  d,       d2|j                  d3       dd4|j                  d       dd5|j                  d6       d7t        |j                  d8             dd9|j                  d:       d&|j                  d;       d<|j                  d=       d&|j                  d>       d?|j                  d@       d&|j                  dA       d&|j                  dB       dCt        |j                  dD             ddE|j                  dF       d7t        |j                  dG             ddH|	j                  dI       dJ|	j                  dK       dL|	j                  dM       dJ|	j                  dN       d| j                  dO      xs dddPd}
| j                  dQ      xs g D ]  }|
j                  dR|         |
j	                  g dS       | j                  dT      xs g D ]A  }|
j                  dU|j                  dV       dWt        |j                  dX             dY       C |
j	                  ddZdd[dd\|j                  d6       dd]t        |j                  d8             dd^t        |j                  d_             dd`|j                  d;       d&|j                  d=       da|j                  db       d&|j                  dc       d&|j                  dd       d&|j                  de       df|j                  dg       d7|j                  dh       ddi|j                  dj       d<|j                  dk       d<|j                  dl       d<|j                  dm       d<|j                  dn       d<|j                  do       d<|j                  dp       dq|j                  dr       d|j                  dO      xs dddsdtg       |j                  du      xs g D ]  }|
j                  dU|j                  dv       dW|j                  dw       dWt        |j                  dx             dy|j                  dz       d{|j                  d|       d{|j                  d}       d~|j                  d       dY        |
j	                  g d       |j                  d      xs g D ]&  }|j                  d	      xs i }|
j                  dU|j                  d       dW|j                  d       dW|j                  d       dWt        |j                  d             dW|j                  d       dWt        |j                  d             d|j                  dI       dJ|j                  dK       dL|j                  dM       dJ|j                  dN       d{|j                  d       d<|j                  d       d{|j                  d       d       ) |
j	                  g d       |j                  d      xs g D ]  }|
j                  dU|j                  d       dy|j                  d       d~t        |j                  dx             dy|j                  d       d{|j                  d       d<|j                  d       d        |
j	                  g d       |j                  d      xs g D ]  }dj                  d |j                  d      xs g D              }|
j                  dU|j                  d       dy|j                  d       d~t        |j                  dx             dW|xs d dy|j                  d       d<|j                  d       d{|j                  d       d<|j                  d       d{|j                  d      rdnd d        |
j	                  g d       |j                  d      xs g D ]w  }|
j                  dU|j                  d       dy|j                  d       d~t        |j                  dx             dy|j                  d       d<|j                  d       d       y |
j	                  g d       |j                  d      xs g D ]f  }|j                  d      xs i }|j                  d      xs i }t        |j                  d      xs |j                  d            }|
j                  dU|j                  d       dW|j                  d       d|j                  d       d|j                  d       d|j                  d       d|j                  d       d{|j                  d       d~t        |j                  dx             dy|j                  d       d<|j                  d       d{| d{|j                  d       d<|j                  d       d{|j                  d      rdnd d       i |
j	                  g d       |j                  d      xs g D ]  }dj                  d |j                  d      xs g D              }|
j                  dU|j                  d       dy|j                  d       d{|j                  d       d~t        |j                  dx             dW|xs d dy|j                  d       d<|j                  d       d{|j                  d       d<|j                  d       d{|j                  d      rdnd d        |
j	                  g d       |j                  d      xs g D ]8  }dj                  d |j                  d      xs g D              }t        |j                  d      xs |j                  d            }|
j                  dU|j                  d       dy|j                  d       d{|j                  d       d{|j                  d       d~t        |j                  dx             dW|xs d dy|j                  d       d<|j                  d       d{| d{|j                  d       d<|j                  d       d{|j                  d      rdnd d       ; dj                  |
      dz   S )Nr;  r@  rC  r   r   rS  rT  r  r   z*# Runtime Source Save Load Variant Context z
- route: `r/  z` -> `r0  `z- source selector: `r1  z- classification: `r   z- promotion status: `r2  z- proof found: r5  z0- runtime source-save load variant proof found: r6  z2- failed runtime source-save load variant gates: `r7  z- evidence refs: r:  z- load-only selectors: `r   z- load-only public observed: `r   z- coordinate-load selectors: `z)- coordinate-load source/start observed: r?  z / r   z- exit-path selectors: `z- exit-path public observed: `z$- exit-path route/current observed: r-  r.  z- adaptive source-ready rows: r   z#- adaptive route/current observed: z*- adaptive trail-start source-ready rows: z/- adaptive trail-start route/current observed: z- ready path diversion: `r   z- diversion selector context: `z- diversion selector/maps: `rF   z` / `rI   z4- diversion route-pair/source-target/current proof: r   r   /r   r  z3- ready paths / route-current / candidate-outside: r   r   r   z- first non-source selectors: `r   z%- dominant non-route selector/maps: `r   r   z- ready-path camera extent: x=rk   z..rl   z y=rm   rn   r  z## Missing Evidencer8  z- )rs  z## Evidence Refsrs  z| path | fields |z| --- | --- |r9  z| `r   z` | `r   z` |z## Ready Path Diversionz### Diversion Selector Contextz- selector: `z- field maps: `z- map-set aliases: `r   z- contains source/target map: z7- scene adjacency rows/selector-only/strict/confirmed: r  r  r  r  z - selected pointer root/range: `rH   r   z'- selected pointer current/candidates: r   r   r   r   r   r   r   z"- route promotion evidence found: r  zS| source | target | selectors | occurrences | strict | confirmed | classification |z,| --- | --- | --- | ---: | --- | --- | --- |r
  r   r   r   z` | r   z | r   r   z | `)rs  z| family | sequence | candidate | selector path | first non-source | maps | camera extent | route/current | candidate/outside |z7| --- | --- | --- | --- | --- | --- | --- | --- | --- |r   r   ry   rz   r   r   r   z` | x=r   r   r   z |)rs  z## Load-Only Rowsrs  z?| sequence | samples | selectors | source 0:0 | route/current |z | --- | ---: | --- | --- | --- |r   r#  )rs  z## Coordinate Load Rowsrs  z_| sequence | samples | selectors | camera pairs | source/start | route/current | branch state |z,| --- | ---: | --- | --- | --- | --- | --- |z; c              3     K   | ];  }|j                  d        d|j                  d       d |j                  d        = ywre   r'   rf   rG   Nr   ri   s     r$   r/   zmarkdown.<locals>.<genexpr>H  C      !
 xx}oQtxx}oQtxx/@.AB!
   AArx   r1   cameraSourceStartObservedr   zall-zeromixed)rs  z## Exit-Path Rowsrs  z2| sequence | samples | selectors | route/current |z| --- | ---: | --- | --- |)rs  z## Exit Candidatesrs  zy| sequence | candidate | samples | selectors | candidate/outside | actor/trail candidate | route/current | branch state |2| --- | --- | ---: | --- | --- | --- | --- | --- |rL  r'  r(  r   r   re   r'   rf   z` r)  r   r   )rs  z## Adaptive Exit Rowsrs  zs| sequence | source ready | samples | selectors | camera pairs | candidate/outside | route/current | branch state |r|  c              3     K   | ];  }|j                  d        d|j                  d       d |j                  d        = ywrw  r   ri   s     r$   r/   zmarkdown.<locals>.<genexpr>y  rx  ry  r|   )rs  z## Adaptive Trail-Start Rowsrs  z| sequence | source ready | path steps | samples | selectors | camera pairs | candidate/outside | actor/trail candidate | route/current | branch state |z?| --- | --- | ---: | ---: | --- | --- | --- | --- | --- | --- |c              3     K   | ];  }|j                  d        d|j                  d       d |j                  d        = ywrw  r   ri   s     r$   r/   zmarkdown.<locals>.<genexpr>  rx  ry  r~   
)rJ   r4   r<   rM   r   r2   r   )r$  load
coordinate	exit_pathadaptiveadaptive_trailready_paths	diversionr   ready_extentlinesrO   r#   rN   extentrr   r4  outsideactor_trails                      r$   markdownr    s7   ;;}%+D-.4"JJ'-2I{{>*0bH[[!56<"N++017RK67=2IMM"78>BM??>28bL%4%
% W[[-.fW[[5M4NaP% w{{+?@AC	%
 gkk*:;<A>%  ,= >?qA% '++l345% ;7;;Go;p:qr% =Yw{{S~G  >A  =B  BC  	D% GKK(:;<=% #9TXX6I-J#K"LAN% )488<Y3Z)[(\\]^% ):>>BU3V)W(XXYZ% 4JNNCW4X3YY\]g]k]k  mF  ^G  ]H  	I% #9Y]];N-O#P"QQRS%  )9==A^3_)`(aabc!%" /y}}=]/^.__bclcpcp  rI  dJ  cK  	L#%$ )6H)I(JK%%& .hll;[.\-]]`aiamam  oF  bG  aH  	I'%( 5^5G5GHZ5[4\])%* :.:L:LMm:n9oor  tB  tF  tF  G^  t_  s`  	a+%, $KOO4M$N#OqQ-%. *)--8H*I)J!L/%0 'y}}Z'@&AyQZQ^Q^_jQkGlFmmno1%2 ?y}}Mb?c>ddg==,-
.a	>Q0R/SSV==IJ
K	M3%8 >kooN^>_=``cdodsds  uS  eT  dU  UX  Yd  Yh  Yh  iK  YL  XM  	N9%: *,{Ge7f*g)hhij;%< 0@Z0[/\\abklwl{l{  }X  mY  cZ  b[  [\  	]=%> ))9)9&)A(B"\EUEUV\E]D^^abnbrbrsybza{{}  K  O  O  PV  W  ~X  	Y?%@ 	A%B 	L!'RC%D 	E%F 	G%H 	I%EL -.4" "r$[!"	LL   {{>*0b Ts3776?+53778;L1M0NcRST	LL
!
(

	j12!4
)IMM+$>?@B
y7L)MNOqQ
(7J)K(LCPYP]P]^qPrOst
A)--PhBiAjjm==>?
@==?@
A==CD
E	G +=+<+<Y+G*HmN_N_`jNkMllmn
1>?
@?@
A=>
?q>?
@FG
HGH
I67
8	: -Y]];X-Y,Z[
l#)r
]69 < }}128b 
#''(#$E#''(*;)<E)CGGT_L`BaAbbfww()*#cgg6I.J-K3ww./0SWW=M5N4OsT	

 
LL  
 v&," 	
(.B#''(#$E#''&/):%@X?Y Z#''.1235AY9Z8[ \#''";<=> ?F#$Bvzz&'9&:#fjj>P=QQSTZT^T^_eTfSggjww./0#'':O2P1QQTww345R9	
	
 
LL   xx%2 
#''&/"$sww}'=&>d9SWWU`MaCbBccgww/01SWW=T5U4VVWX[X_X_`uXvWwwy{	


 
LL   ~~f%+ 

yy !
.4"!
 
 	#''&/"$sww}'=&>d9SWWU`MaCbBc d#$D1I)J(K1SWWUpMqLrruww./0#'':O2P1QQT WW%9:zHL	


 
LL   }}V$* 
#''&/"$sww}'=&>d9SWWU`MaCbBccgww./0#'':O2P1QQSU	


 
LL   }}_-3 
GGO,2	''-(.B377#89[SWWEZ=[\#''&/"%	c(:';1Y]]3=O<P QC !7;;s#3"4Bsww7O6PPSww}%&d9SWW[5I+J*K4ww012!CGG<S4T3UUXm3sww'>?@#''J_B`Aaad WW%9:zHL	
	
 
LL   ||F#)r 
yy !
.4"!
 
 	#''&/"$sww}'=&>c#''-BXAY Z#''+./0l6Ic5J$ww012!CGG<S4T3UUXww./0#'':O2P1QQT WW%9:zH	L	

 
LL   !!&)/R 
yy !
.4"!
 
 377#89[SWWEZ=[\#''&/"$sww}'=&>c#''/BZA[[^ww}%&d9SWW[5I+J*K5Q]QdadPeeiww012!CGG<S4T3UUXYdXeehww./0#'':O2P1QQT WW%9:zH	L	

 99Ud""r5   c                F    dt        j                  t        |              dS )Na  <!doctype html><meta charset="utf-8"><title>Runtime Source Save Load Variant Context</title><style>body{font-family:sans-serif;line-height:1.4}table{border-collapse:collapse}td,th{border:1px solid #ccc;padding:4px 6px}code{background:#f3f3f3;padding:1px 3px}</style><pre>z</pre>)htmlescaper  )r$  s    r$   	html_pager    s)    	 HW-./v	7r5   c                    |j                  dd       |dz  j                  t        j                  | dd      dz   d	       |:|j                  j                  dd       |j                  t        |       d	       y y )
NT)parentsexist_ok-runtime_source_save_load_variant_context.jsonF   )ensure_asciiindentr  r>   r?   )mkdir
write_textr:   r;   parentr  )r$  out_dirhtml_outs      r$   write_outputsr    s    MM$M.>>JJ

7q9D@ K  dT:Ig.A r5   c            
        t        j                  t              } | j                  dt        d d       | j                         }t        t              }t        t              }t        t              }t        t              }t        t              }t        t              }t        t              }t        t              }	t        ||||||||	      }
t!        |
t"        |j$                         t'        dt"        dz          y )N)descriptionz
--html-outzHOptional HTML review path. By default only the JSON evidence is written.)typedefaulthelpz2wrote runtime source save load variant context -> r  )argparseArgumentParser__doc__add_argumentr   
parse_argsrC   LOAD_VARIANT_POLLLOAD_COORDINATE_POLLLOAD_CONFIRMED_EXIT_POLLADAPTIVE_EXIT_POLLADAPTIVE_TRAIL_START_POLLMAPSET_ALIASESSCENE_ADJACENCY_INDEXGLOBAL_SELECTED_POINTER_PATHSrq  r  OUTr  print)parserargsrY  rZ  r[  r\  r]  r   r   r   r$  s              r$   mainr    s    $$9F
W	   D!"34$%9:()AB"#56 )*C D~.N 56O&'DE !	G '3.	>sEt?t>u
vwr5   __main__)returnlist[dict[str, Any]])r3   list[Any] | Noner  r+   )r.   objectr  r+   )r   r   r  dict[str, Any])rN   r  r  r  )rN   r  rF   
str | Noner  	list[str])rN   r  r_   r  r  r  )r   r  r  r  )rr   r  r  r  )rN   r  r  r  )r   r  r   r  r  r  )r3   r  rF   r  r  r   )r   r  rF   r  r  r  )r   r  rF   r  r  r  )r   r  rF   r  r  r  )r   r  rF   r  r  r  )
r  r  r   r  r   r  r   r  r  r  )r$  r  r  r  )NNNNNNNN)rY  dict[str, Any] | NonerZ  r  r[  r  r\  r  r]  r  r   r  r   r  r   r  r  r  )r$  r  r  r+   )r$  r  r  r   r  zPath | Noner  None)r  r  )7r  
__future__r   r  r  r:   pathlibr   typingr   __file__resolver  r!   r  r  r  r  r  r  r  r  r  r  r  rb   r  rW  rX  r    r%   r4   r<   rC   rP   r\   r`   rc   rv   r   r   r   r   r   r   r   r!  r%  r*  rq  r  r  r  r  __name__r   r5   r$   <module>r     s   Z "      H~''*
Ul\\ aa !mm __ "gg ::HH  #&X X 

4 05 1 WU
 YQ
 aL
 Yo
 Zo
 8 +.
 ?V
 Ga;!2 .HAJQ	>2 FX'X-X XvA( *    FX&X"X $X +	X
 Xv$6 04266:047;,0-148D,D/D 4D .	D
  5D *D +D 2D DNR#j <?X\ Bx> zF r5   