
    dSLjyC                        d Z ddlm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dd	Zdd
ZddZddZddZddZddZedk(  r e        yy)aI  Consolidate the selector address-predecessor bridge decision.

The 10:0 -> 2:0 address-adjacent block was tempting because it contains many
current-range pointers.  This report keeps that evidence visible while making
the promotion boundary explicit: those references are data/resource adjacency,
not live route execution proof.
    )annotationsN)Path)Any   outwebc                    	 t        j                  t        | z  j                  d            }t        |t              r|S i S # t        $ r i cY S w xY w)Nutf-8encoding)jsonloadsOUT	read_textFileNotFoundError
isinstancedict)namedatas     9tools/build_selector_address_predecessor_bridge_review.py	load_jsonr      sS    zz3:00'0BC dD)41r1  	s   ,A AAc                V    t        j                  | dd      S t        |       d      S )N T)quote)htmlescapestr)values    r   hr      s%    ;;U]r$GGE
$GG    c                v    | j                  d      rd| z   S | j                  d      r| j                  d      S | S )Nzout/z../zweb/)
startswithremoveprefix)paths    r   linkr%   "   s:    vt|v  ((Kr    c                V    | r't        | d   t              r| d   j                  d      S y )Nr   role)r   r   get)refss    r   first_ref_roler*   *   s(    
47D)Aw{{6""r    c                 T   t        d      } t        d      }t        d      }t        d      }t        d      }t        d      }t        d      }|j                  d      }t        |t              r|ni }|j                  d	      }t        |t              r|ni }|j                  d
      }	t        |	t              r|	ng }	|j                  d      }
t        |
t              r|
ng }
|j                  d      d|j                  d      |j                  dg       d|j                  d      d|j                  d      |j                  dg       d|j                  d      d|j                  d      |j                  d      |j                  dg       d|j                  d      d|j                  d      |j                  dg       dg}|j                  d      }t        |t              r|ng }|j                  d       }t        |t              r|ng }d!| j                  d"d#      d#kD  | j                  d"d#      d$d%t        |      d&k7  t        |      xs d'd$d(t        |j                  d)            |j                  d*      xs i j                  d+d#      d$d,t        |j                  d-            |j                  d-      d$d.t        |j                  d/            |j                  d/      d$d0|j                  d1d#      d#kD  |j                  d1d#      d$d2t        |j                  d3            |j                  d3      d$g}t        d4 |D              }d5}i d|j                  d      d|j                  d      d|j                  d      d|j                  d      d6|j                  d6      d7|j                  d7      d"| j                  d"d#      d8| j                  d8d#      d9t        |      d:|j                  d*      xs i j                  d+d#      d3|j                  d3      d;t        |j                  d-            xr< t        d< |j                         D              xr t        |j                  d/            d=|j                  d1d#      d>| j                  d>      d?|d@dAdB|}dCdDg dE||| j                  dFi       ||d dG ||	|
|j                  dH      |j                  d-      ||j                  d/      |j                  dI      |j                  dJ      dK|j                  dL      |j                  dM      |j                  d1      |j                  dN      dOdPt        t        |j                  dQ      t              r|j                  dQg       ng       idRS )SNz&selector_root_preentry_ref_review.jsonz.save_selector_address_predecessor_context.jsonz*save_selector_predecessor_bridge_refs.jsonz*save_selector_predecessor_route_order.jsonz7save_selector_predecessor_fill_execution_order_gap.jsonz4save_selector_predecessor_descriptor_bridge_gap.jsonz#selector_root_structure_review.jsonfillEntryCandidateScandirectFillSiteRefCountsfailedGatesremainingProofssourceSelectorzsource selectorsourceRootHex
sourceMaps)selectorr'   rootHexmapslogicalPredecessorSelectorzlogical predecessorlogicalPredecessorRootHexlogicalPredecessorMapsaddressPredecessorSelectorzaddress predecessoraddressPredecessorRootHexaddressPredecessorRangeHexaddressPredecessorMaps)r3   r'   r4   rangeHexr5   currentSelectorzcurrent selectorcurrentRootHexcurrentMaps#addressPredecessorToCurrentRootRefs0addressPredecessorCurrentRootRefFollowingStringsz-source/predecessor aligned current-range refs)sourceOrPredecessorToCurrentRangeRefCountr   )r   passedevidencez<address predecessor exact current-root ref is execution edgez(current-selector-row-selected-root-entrynonez2logical predecessor -> current direct dword bridgeforwardExecutionBridgeFoundpredecessorToCurrenthitCountz0predecessor fill sites reachable from root entry)rootEntryFixedTraversalFillSitesReachablez&predecessor fill entry candidate foundentryCandidateFoundz0descriptor closure contains route execution edge+descriptorEdgeRouteExecutionTargetEdgeCountzroute order provenrouteOrderProvenc              3  &   K   | ]	  }|d      yw)rD   N ).0gates     r   	<genexpr>zbuild.<locals>.<genexpr>   s     4d4>4s   zuaddress-predecessor selector 10:0 is target-side resource/data adjacency only; do not promote it as a route producer.0addressPredecessorEqualsLogicalPredecessorMapSet)currentEqualsAddressPredecessorPlusSource(addressPredecessorToCurrentRangeRefCount'addressPredecessorToCurrentRootRefCountpredecessorToCurrentHitCountfillExecutionProvenc              3  @   K   | ]  }t        |xs d       d kD    yw)r   N)intrP   r   s     r   rR   zbuild.<locals>.<genexpr>   s     QEJQ!#Qs   !descriptorRouteExecutionEdgeCount0addressPredecessorBridgeRouteExecutionProofFoundpromotedRouteProofbridgeContextClassificationz+context-only-target-side-resource-adjacencydecisionr   z1hwanse-selector-address-predecessor-bridge-review)z*out/selector_root_preentry_ref_review.jsonz'out/selector_root_structure_review.jsonz2out/save_selector_address_predecessor_context.jsonz.out/save_selector_predecessor_bridge_refs.jsonz.out/save_selector_predecessor_route_order.jsonz;out/save_selector_predecessor_fill_execution_order_gap.jsonz8out/save_selector_predecessor_descriptor_bridge_gap.json,addressPredecessorBridgeClassificationCounts(   "localFillTraceReachesCurrentReaderlocalFillTraceStopReasonlocalFillTraceStopHex)rc   rJ   r-   rK   rd   re   %descriptorEdgeRejectionClassification'descriptorEdgeDescriptorTargetEdgeCount#descriptorEdgeAllTargetSectionsData)classificationdescriptorTargetEdgeCountrouteExecutionTargetEdgeCountallTargetSectionsDatarootReviewCountrootReviews)versionkindsourceArtifactssummaryselectorMapSetsclassificationCountsexactCurrentRootRefsfollowingResourceStringsdecisionGatesrouteOrderFailedGatesrouteOrderRemainingProofsfillGapdescriptorGapstructureContext)r   r(   r   r   listr*   boolalllenanyvalues)preentryctxbridgeroute_orderfill_gapdescriptor_gap	structurefill_entry_scandirect_fill_ref_countsfailed_gatesremaining_proofsselector_map_setsexact_root_refsfollowing_stringsgatespromotedr`   rr   s                     r   buildr   0   s,   ABH
D
ECCDFHIKRSHUVN?@Ill#;<O)3OT)JoPRO%\\*CD7ABXZ^7_3eg??=1L#-lD#A<rL"'89+56F+M'SU  01%ww/GGL"-		
  <=)ww:;GG4b9		
  <=)ww:; <=GG4b9	
  12&ww/0GGM2.		
)8 ggCDO)3OT)JoPRO RS-78I4-P)VX Dll#NPQRUVV %PRST	
 S$_59cc&7A6	
 I6::&CDE$:;ArFFzSTU	
 G8<<(STU %PQ	
 =?../DEF'++,AB	
 G$(()VXYZ]^^&**+XZ[\	
 );??+=>?#(:;	
?$EL 4e44H	1 
$cgg.J&K#SWW-H%I 	377#45 	#''"23	
 	;CGG>=
 	4SWW=h5i 	4X\\76
 	3HLL65
 	233G  	'4J)K)Qr(V(VWacd(e!" 	KOO,>?#$ 	tHLL1\$]^  =Q1G1N1N1PQQ =$$%:;<)* 	,^-?-?@mop-q+, 	;HLL>=
-2 	h34 	&'T56 	H7G> C
 , (-[]_ ` /$5cr$:!-%52:,,?c2d9A;: (>#2#6#67L#M(05O(P%-\\2I%J	
 -001XY)7););<e)f-;-?-?@m-n%3%7%78]%^	
 szR[R_R_`mRnptGu9==#C{}~
I' 'r    c                   | d   }dj                  d |j                         D              }dj                  d | d   D              }dj                  d t        | d   j                               D              }dj                  d | d	   D              }dj                  d
 | d   D              }dj                  d | d   D              }dj                  d | d   D              }dj                  d | d   D              }	dj                  d | d   D              }
| d   }| d   }dj                  g dt        |j	                  d             dt        |j	                  d             dt        |j	                  d             d| d| d| d| d | d!t        |j	                  d"             d#t        |j	                  d$             d%t        |j	                  d&             d't        |j	                  d(             d)t        |j	                  d*             d+t        |j	                  d,             d-t        |j	                  d.             d/t        |j	                  d0             d1t        |j	                  d2             d3| d4|	 d5|
 d6| d7      S )8Nrr   r   c              3  `   K   | ]&  \  }}|d v rdt        |       dt        |       d ( yw)>   r>   r^   r9   r_   rW   rU   rC   z<div class='card'><b>z
</b><span>z</span></div>Nr   rP   kvs      r   rR   zrender_html.<locals>.<genexpr>   s@      Aq
	
  !vZ!v]Cs   ,.c              3     K   | ]  }d t        |j                  d             dt        |j                  d             dt        |j                  d             dt        dj                  |j                  d      xs g              d		  y
w)<tr><td>r3   	</td><td>r'   z</td><td><code>r4   </code></td><td>z, r5   
</td></tr>N)r   r(   joinrP   rows     r   rR   zrender_html.<locals>.<genexpr>   s       	$%& '!" #swwy)*+ ,3776?0b123 4		s   BBrs   c              3  X   K   | ]"  \  }}d t        |       dt        |       d $ yw)r   r   r   Nr   r   s      r   rR   zrender_html.<locals>.<genexpr>   s3      Aq 1Q4&	!A$z2s   (*rt   c              3     K   | ]s  }d t        |j                  d             dt        |j                  d             dt        |j                  d             dt        |j                  d             d	 u y	w)
z<tr><td><code>refVaHexz</code></td><td><code>targetVaHexr   r'   r   isCurrentSelectorRowPointerr   Nr   r(   r   s     r   rR   zrender_html.<locals>.<genexpr>   s       	swwz*+, -sww}-./ 0!" #6789 :		s   A9A;ru   c              3     K   | ]S  }d t        |d          dt        |d   rdnd       dt        |d          dt        |j                  d             d		 U y
w)r   r   z</td><td class='rD   passfail'>r   rE   r   Nr   r   s     r   rR   zrender_html.<locals>.<genexpr>   st       	V~ #h-V<=R#h-@P?Q R$%& '	s   AArw   c              3  d   K   | ](  }d t        t        |             dt        |       d * yw)z<a class='chip' href='r   z</a>N)r   r%   )rP   r$   s     r   rR   zrender_html.<locals>.<genexpr>  s3       !4:r!D'$?s   .0rq   c              3  :   K   | ]  }d t        |       d  yw)z<code>z</code>Nr   r[   s     r   rR   zrender_html.<locals>.<genexpr>	  s     au&5
'2a   rv   c              3  :   K   | ]  }d t        |       d  ywz<li>z</li>Nr   r[   s     r   rR   zrender_html.<locals>.<genexpr>
  s     WtAeH:U+Wr   rx   c              3  :   K   | ]  }d t        |       d  ywr   r   r[   s     r   rR   zrender_html.<locals>.<genexpr>  s     ^5$qxj.^r   ry   rz   r{   u8	  <!doctype html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Selector Address Predecessor Bridge Review</title>
<style>
  :root { --bg:#f6f7f9; --panel:#fff; --line:#d7dde8; --text:#20242b; --muted:#677080; --bad:#a33a2a; --good:#1d7f48; }
  * { box-sizing:border-box; }
  body { margin:0; background:var(--bg); color:var(--text); font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
  main { width:min(1180px, calc(100vw - 28px)); margin:0 auto; padding:24px 0 40px; }
  h1 { margin:0 0 6px; font-size:28px; }
  h2 { margin:22px 0 8px; font-size:18px; }
  p { margin:0; line-height:1.45; }
  .lead,.muted { color:var(--muted); }
  .decision { margin-top:14px; padding:12px; border:1px solid #efc3bb; background:#fff5f3; border-radius:8px; }
  .cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:10px; margin:16px 0; }
  .card,section { background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:12px; }
  .card b { display:block; color:var(--muted); font-size:12px; }
  .card span { display:block; margin-top:4px; font-weight:700; overflow-wrap:anywhere; }
  table { width:100%; border-collapse:collapse; font-size:13px; }
  th,td { border-top:1px solid var(--line); padding:7px; text-align:left; vertical-align:top; }
  th { color:var(--muted); font-size:12px; }
  code { font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; }
  .pass { color:var(--good); font-weight:700; }
  .fail { color:var(--bad); font-weight:700; }
  .chips { display:flex; flex-wrap:wrap; gap:6px; }
  .chip { display:inline-flex; min-height:30px; align-items:center; padding:5px 9px; border:1px solid var(--line); border-radius:7px; background:#eef2f7; color:var(--text); text-decoration:none; font-size:13px; }
  .resource-list { display:flex; flex-wrap:wrap; gap:6px; }
  .resource-list code { padding:4px 6px; border-radius:5px; background:#eef2f7; }
  .grid2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
  @media (max-width:760px) { main { width:min(100vw - 18px, 1180px); padding-top:16px; } .grid2 { grid-template-columns:1fr; } table { display:block; overflow-x:auto; white-space:nowrap; } }
</style>
<main>
  <h1>Selector Address Predecessor Bridge Review</h1>
  <p class="lead">주소상 선행 selector <code>r9   u"   </code>가 current selector <code>r>   uu   </code>로 이어지는 실행 증거인지 재분류한 요약입니다.</p>
  <div class="decision"><b>결론:</b> r`   z</div>
  <div class="cards">z</div>

  <section>
    <h2>Selector Map Sets</h2>
    <table><thead><tr><th>selector</th><th>role</th><th>root</th><th>maps</th></tr></thead><tbody>z</tbody></table>
  </section>

  <section>
    <h2>Decision Gates</h2>
    <table><thead><tr><th>gate</th><th>passed</th><th>evidence</th></tr></thead><tbody>z</tbody></table>
  </section>

  <div class="grid2">
    <section>
      <h2>Bridge Classifications</h2>
      <table><thead><tr><th>classification</th><th>count</th></tr></thead><tbody>z</tbody></table>
    </section>
    <section>
      <h2>Exact Current Root Refs</h2>
      <table><thead><tr><th>ref</th><th>target</th><th>role</th><th>row pointer</th></tr></thead><tbody>z</tbody></table>
    </section>
  </div>

  <div class="grid2">
    <section>
      <h2>Fill Gap</h2>
      <p class="muted">fill trace reaches current reader: <b>rc   zF</b></p>
      <p class="muted">root traversal reaches fill sites: <b>rJ   z:</b></p>
      <p class="muted">entry candidate found: <b>rK   z,</b></p>
      <p class="muted">stop: <code>re   z</code> rd   zj</p>
    </section>
    <section>
      <h2>Descriptor Gap</h2>
      <p class="muted">classification: <b>ri   z5</b></p>
      <p class="muted">descriptor edges: <b>rj   z:</b></p>
      <p class="muted">route execution edges: <b>rk   z5</b></p>
      <p class="muted">all targets data: <b>rl   zu</b></p>
    </section>
  </div>

  <section>
    <h2>Following Resource Strings</h2>
    <div class="resource-list">zk</div>
  </section>

  <div class="grid2">
    <section>
      <h2>Route Order Failed Gates</h2>
      <ul>zM</ul>
    </section>
    <section>
      <h2>Remaining Proofs</h2>
      <ul>z`</ul>
    </section>
  </div>

  <section>
    <h2>Source Artifacts</h2>
    <div class="chips">z</div>
  </section>
</main>
)r   itemssortedr   r(   )r   scardsmap_rows
class_rowsref_rows	gate_rowslinks	resourcesfailed	remainingr   r   s                r   render_htmlr      s   YAGG GGI E ww  )* H  4 67==?@ J ww  ./ H   ( I GG *+ E aE_@`aaIWWW>U9VWWF^DA\<]^^IIH/*N` ` !3 `B 45QUU;W5X3Y2ZC`B [}C`B ~  @A  @E  @E  FW  @X  ~Y  }ZC`BZ(C`D )*!%%
*;(<'=E`D>E`F WG`FcG`N dlblO`NmXO`X YbWbY`XcRY`d S]Q]e`d^ie`l jrhrm`ls>m`z ?@Mq@r>s=t{`zu>{`| ?@Mx@y>z={}`||2}`~ 34HLLAV4W2X1Y`~Z$`@ %&hll3J&K$L#MA`@ NVA`@ WXX`XdXde  YA  WB  VCA`@C+A`H ,-^-?-?@P-Q+R*SI`HT-I`J ./~/A/AB]/^-_,`K`Ja2K`L 34N4F4FGf4g2h1iM`Lj-M`N ./~/A/ABY/Z-[,\O`N] O`Z !*{[`Z+[`f (g`fg`n +o`no`z w{`z{` `r    c            	     \   t         j                  d       t        j                  d       t               } t         dz  j	                  t        j                  | dd      d       t        d	z  j	                  t        |       d       | d
   }t        d|d    d|d    d|d    d       y )NT)exist_okz/selector_address_predecessor_bridge_review.jsonF),:)ensure_ascii
separatorsr
   r   z/selector_address_predecessor_bridge_review.htmlrr   z2wrote selector address predecessor bridge review (r9   z -> r>   z, promoted=r^   ))	r   mkdirWEBr   
write_textr   dumpsr   print)r   r   s     r   mainr   r  s    IItIIItI7D<<HH

4e
C I  	<<HHD I  	YA		*+,D3D1E0F G*+,A	/r    __main__)r   r   returndict[str, Any])r   r   r   r   )r$   r   r   r   )r)   z	list[Any]r   z
str | None)r   r   )r   r   r   r   )r   None)__doc__
__future__r   r   r   pathlibr   typingr   __file__resolveparentsROOTr   r   r   r   r%   r*   r   r   r   __name__rO   r    r   <module>r      s    #     H~''*
Ul
Ul2HdNXv( zF r    