import html,json
from pathlib import Path
R=Path(__file__).resolve().parents[1];O=R/'results/r102';rows=json.loads((O/'results.json').read_text())['records'];methods=('uniform','variance','uniform_first','variance_first');tables=[]
for split in ('development','holdout_source_fields'):
 for cond in ('separated','crossing','near','partial'):
  a=[x for x in rows if x['split']==split and x['condition']==cond];vals=[sum(x['scores'][k]['30']['0.5']['matched'] for x in a) for k in methods];tables.append(f'<tr><td>{html.escape(split)}</td><td>{cond}</td>'+''.join(f'<td>{v}/4</td>' for v in vals)+'</tr>')
cards=[]
for r in rows:
 vals=[r['scores'][k]['30']['0.5']['matched'] for k in methods];cards.append(f'<section><h2>Pair {r["pair"]}: {html.escape(r["condition"])}</h2><p>Top 30: uniform / variance / uniform-first / variance-first = {" / ".join(map(str,vals))} of 2; {len(r["top30_cross_stream_iou08"])} cross-stream candidate pairs above 0.8 IoU among each source stream’s top 30.</p><a href="{r["panel"]}"><img loading="lazy" src="{r["panel"]}" alt="Source visible supports and original and interleaved candidate streams"></a><p><a href="/results/l75/{html.escape(r["source_image"])}">Source composite</a> · <a href="/results/l88/{html.escape(r["uniform_archive"])}">Uniform masks</a> · <a href="/results/l89/{html.escape(r["variance_archive"])}">Variance masks</a></p></section>')
(O/'index.html').write_text('''<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>R102 tile stream union</title><style>body{font:16px/1.5 system-ui;color:#18342f;max-width:1200px;margin:2em auto;padding:0 1em}a{color:#006b59}img{width:100%}table{border-collapse:collapse}td,th{border:1px solid #bbc;padding:.4em}.warn{background:#fff2d6;padding:1em}section{border-top:1px solid #ccd}</style><a href="/results/board.html">Research board</a> · <a href="/results/l88/">Uniform tiles</a> · <a href="/results/l89/">Variance-guided tiles</a><h1>R102: Combining tiled proposal streams</h1><p class="warn">Previously viewed artificial composite scenes; historical holdout labels do not imply untouched or biologically independent examples. Background references are incomplete. This is not a test of real severe overlap, false positives, species accuracy or human-level segmentation.</p><p>Compare retained L88 uniform-point and L89 variance-point masks with a reference-free interleaving of both streams, starting with either stream. Keep every retained mask, including overlapping alternatives. Each displayed mask counts toward the same review budget; the first 30 interleaved slots contain at most 15 from either source.</p><table><tr><th>Previous split</th><th>Scene</th><th>Uniform top 30</th><th>Variance top 30</th><th>Uniform-first top 30</th><th>Variance-first top 30</th></tr>'''+''.join(tables)+'''</table><p>Values are one-to-one matches to four inserted visible supports at IoU ≥0.5. The hard former-holdout crossings remain 0/4 and 0/2 complete pairs at top 30 under all four orders. Mixed streams restore the one development-partial support missed by variance alone, but the uniform stream already matched it; they also reduce development-near recovery from 4/4 for either single stream to 2/4. These small, repeated development cases do not establish a practical benefit.</p><p>The full mixed retained pools match 3/4 former-holdout crossing supports (uniform 2/4, variance 3/4); before each method's own filtering, raw candidates have broader coverage. Combining both methods uses <strong>512 prompts and 32 crop encodings per field</strong>, twice each single stream, even though this study reused cached outputs. Across all fields there are 183 cross-stream pairs at IoU ≥0.8 within each original stream's top 30. These are geometric overlap links, not proof of duplicates or false positives; preserving both helps avoid silently deciding identity but increases candidate burden.</p><p>All 16 source/archive hashes, source orders, interleaved orders, budget scores and cross-stream overlap links were reconstructed. Verification uses the shared matcher and did not repeat inference. Original masks, crop coordinates, native pixels and prior suppression aliases remain accessible.</p><p><a href="protocol.json">Protocol</a> · <a href="results.json">Rankings, scores and links</a> · <a href="verify.log">Verification</a> · <a href="/research/R102.md">Research note</a></p>'''+''.join(cards)+'</html>')
