"""Publish the published sampling-metadata join and conservative exposure audit."""
import html,json
from pathlib import Path
R=Path(__file__).resolve().parents[1];O=R/'results/r112/ude-sampling-metadata';p=json.loads((O/'parse-report.json').read_text());g=json.loads((O/'group-audit.json').read_text());c=json.loads((O/'site-components.json').read_text());i=json.loads((O/'site-impact.json').read_text());ledger=json.loads((O/'exposure-report.json').read_text());e=html.escape;table=''.join('<tr><th>'+e(k)+'</th><td>'+str(v)+'</td><td>'+str(ledger['component_counts'].get(k,0))+'</td></tr>' for k,v in ledger['status_counts'].items());page='''<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>UDE sample and location provenance</title><style>body{font:16px/1.55 system-ui;background:#f4f6f0;color:#193b37;margin:0}main{max-width:1050px;margin:auto;padding:24px}a{color:#096c58}.notice,section{background:white;border:1px solid #cddbd2;padding:16px;margin:14px 0}.notice{border-left:5px solid #bc851b}table{border-collapse:collapse;display:block;overflow:auto}td,th{border:1px solid #cddbd2;padding:8px;text-align:left}code{overflow-wrap:anywhere}</style><main><nav><a href="/results/r112/">Synthetic training</a></nav><h1>UDE sample and location provenance</h1><p class="notice"><strong>Earlier comparison is not location-independent.</strong> Using a conservative, transitive grouping of shared site codes or matching coordinates, '''+str(i['counts']['shared_location_components'])+''' location groups contain sources from both sides of the earlier local synthetic split. '''+str(i['counts']['comparison_placements_in_shared_components'])+''' of its '''+str(i['counts']['comparison_scene_placements'])+''' comparison placements used a source in those shared groups. Shared location does not prove the same specimen or sample; different groups do not prove independence.</p><section><h2>Published sampling metadata</h2><p>The <a href="https://doi.org/10.1093/gigascience/giae087">UDE dataset paper</a> describes taxonomic identification and review by its annotators and supplies a supplementary workbook of slide and sampling metadata. The UDE archive contains source-labeled crops and rough shapes, not validated instance masks. Our joins and the transfer of those taxon concepts to Academy specimens still require independent review.</p><p>The workbook contains '''+str(p['workbook_rows'])+''' slide records. Exact, normalized filename matching links '''+str(p['matched_keys'])+''' of '''+str(p['ude_distinct_slide_keys'])+''' slide names in the UDE image metadata; one source slide containing one crop does not match and is quarantined. No fuzzy name was substituted. There are two site codes with both train and comparison crops in the prior 442-source local split; their recorded dates differ. Grouping by site code or six-decimal coordinates yields '''+str(c['component_count'])+''' conservative location components across the workbook. Coordinates may merge unrelated experiments or miss related sites.</p><p><a href="slide-metadata.csv">Parsed slide table</a> · <a href="parse-report.json">Join check and unresolved filename</a> · <a href="group-audit.json">Earlier split audit</a> · <a href="site-components.json">Location components</a> · <a href="site-impact.json">Prior comparison impact</a></p></section><section><h2>Conservative exposure ledger</h2><p>The ledger assigns all 83,570 source metadata rows to site-level categories. It is based on eight known prior selection manifests, not a complete proof of every previous image access. All source images, labels and instance masks still need appropriate checks before training or evaluation.</p><table><tr><th>Status</th><th>Image metadata rows</th><th>Location components</th></tr>'''+table+'''</table><p><code>legacy_reserved_conflict</code> groups contain a prior test-candidate selection and previously used development material. They are excluded from new training, but cannot be claimed location-independent. The three <code>candidate_unseen_location</code> groups have no selected images in the eight audited manifests; prior exposure elsewhere is not ruled out. Their 906 records contain only two species-named images, so they do not provide a useful broad species benchmark. The unmatched slide is quarantined. This ledger is a guard for future work, not an approved train/test split.</p><p><a href="candidate-exposure-scan.json">Limited prior-ID search</a> · <a href="remote-directory.json">Public ZIP directory check</a> · <a href="archive-integration.json">Archive integration checks</a> · <a href="exposure-report.json">Exposure audit and policy</a> · <a href="exposure-ledger.csv">All metadata rows and statuses</a></p></section><section><h2>Full archive transfer</h2><p>The public <a href="https://zenodo.org/records/10410655">UDE archive</a> download was started to build a larger source pool. A partial archive must not be used for training. A local watcher can verify the published checksum once all expected bytes are present.</p><p id="status">Reading local progress…</p><p><small>File growth is an observation, not proof that the network process is live. The page may lag by 15 seconds. If a progress record is unavailable, the transfer status is unknown.</small></p><p><a href="download-progress.json">Progress record</a> · <a href="archive-verification.json">Final archive verification, when available</a></p></section><script>async function refresh(){const el=document.getElementById('status');try{const r=await fetch('download-progress.json?ts='+Date.now(),{cache:'no-store'});if(!r.ok)throw Error('unavailable');const p=await r.json();const pct=(100*p.bytes_observed/p.expected_bytes).toFixed(1);el.textContent=p.phase+' — '+(p.bytes_observed/1e6).toFixed(1)+' / '+(p.expected_bytes/1e6).toFixed(1)+' MB ('+pct+'%); observed '+p.updated_utc;}catch(e){el.textContent='Progress record unavailable; transfer status is unknown.'}}refresh();setInterval(refresh,15000)</script></main></html>''';(O/'index.html').write_text(page);print('published sampling and exposure report')
