184 lines
11 KiB
Python
184 lines
11 KiB
Python
"""Frozen CoRL 2026 official program joined to attributed public archive metadata."""
|
|
import argparse
|
|
from collections import Counter
|
|
from datetime import datetime
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import re
|
|
import unicodedata
|
|
from urllib.parse import parse_qs, urlsplit
|
|
|
|
from paper_atlas.io.html import Document, clean
|
|
|
|
SOURCE = 'corl_program_archive'
|
|
OFFICIAL = 'https://2026.corl.org/program/accepted-papers'
|
|
REVISION = '75b3f7a04b3a77c454540fe2506bfa615b8e038e'
|
|
ARCHIVE = f'https://raw.githubusercontent.com/gisbi-kim/conference-explorers/{REVISION}/corl2026/data.json'
|
|
OFFICIAL_SHA = '3f026639c1a777b0b5fbd132e1935a27cdd519ca0a04e60ca3b650a3bc7eaef4'
|
|
FILTERED_SHA = '6e6d7ecd57ee139c61283188fec39ebe9dc7f5c30ec14c8c5839d1277b03a588'
|
|
RAW_SHA = '1e96ed2dffcd96c2584a7ba020201c831e49ae1a69eae3ef1553fd5a34802810'
|
|
BLOB = '322eeef71126b85e13a98fdce9c73fac81934d3f'
|
|
FIELDS = {'id', 'title', 'openreview', 'poster_session', 'poster_day', 'poster_date',
|
|
'poster_time', 'poster_venue', 'poster_number', 'index', 'presentation_type',
|
|
'arxiv', 'matched_title', 'abstract', 'metadata_source', 'author_source',
|
|
'abstract_source', 'identity_note', 'authors', 'openreview_updated', 'metadata_checked'}
|
|
|
|
|
|
def digest(raw):
|
|
return hashlib.sha256(raw).hexdigest()
|
|
|
|
|
|
def comparable(text):
|
|
return ''.join(c for c in unicodedata.normalize('NFKD', text).casefold() if c.isalnum())
|
|
|
|
|
|
def forum_id(url):
|
|
if not isinstance(url, str):
|
|
raise ValueError('Forum URL must be text')
|
|
u = urlsplit(url); q = parse_qs(u.query, keep_blank_values=True)
|
|
if (u.scheme != 'https' or u.netloc != 'openreview.net' or u.path != '/forum'
|
|
or u.fragment or set(q) != {'id'} or len(q['id']) != 1
|
|
or not re.fullmatch(r'[A-Za-z0-9_-]{8,32}', q['id'][0])):
|
|
raise ValueError('Invalid original forum identity')
|
|
return q['id'][0]
|
|
|
|
|
|
def parse_program(raw):
|
|
embeds = [n.attrs['data-code'] for n in Document(raw).root.walk() if 'data-code' in n.attrs]
|
|
if len(embeds) != 1:
|
|
raise ValueError('Expected one official embedded program')
|
|
doc = Document(embeds[0]); nodes = list(doc.root.walk())
|
|
if [clean(n.text()) for n in nodes if n.tag == 'h1'] != ['CoRL 2026 Accepted Papers']:
|
|
raise ValueError('Unexpected program edition')
|
|
summary = [clean(n.text()) for n in nodes if n.tag == 'p' and n.attrs.get('class') == 'sub']
|
|
if len(summary) != 1 or not summary[0].startswith('687 accepted papers · 21 orals · 72 spotlights · 687 posters'):
|
|
raise ValueError('Reviewed program census changed')
|
|
papers = {}; sessions = {}; occurrences = []
|
|
for section in (n for n in nodes if n.tag == 'section' and 'session' in n.attrs.get('class', '').split()):
|
|
sid = section.attrs.get('data-sess', section.attrs.get('id'))
|
|
if not isinstance(sid, str) or not re.fullmatch(r'(?:O[1-7]|S[1-8]|post-p[1-3])', sid) or sid in sessions:
|
|
raise ValueError('Unexpected or repeated presentation session')
|
|
kind = 'oral' if sid.startswith('O') else 'spotlight' if sid.startswith('S') else 'poster'
|
|
headings = [clean(n.text()) for n in section.walk() if n.tag == 'h3']
|
|
if len(headings) != 1:
|
|
raise ValueError('Ambiguous session heading')
|
|
sessions[sid] = {'kind': kind, 'heading': headings[0]}
|
|
seen = set()
|
|
for link in (n for n in section.walk() if n.tag == 'a' and 'openreview.net' in n.attrs.get('href', '')):
|
|
fid = forum_id(link.attrs['href']); title = clean(link.text())
|
|
if fid in seen or not title:
|
|
raise ValueError('Repeated or empty paper in session')
|
|
seen.add(fid)
|
|
paper = papers.setdefault(fid, {'title': title, 'presentations': []})
|
|
if paper['title'] != title:
|
|
raise ValueError('Conflicting official titles share a forum')
|
|
event = {'session_id': sid, **sessions[sid]}
|
|
paper['presentations'].append(event); occurrences.append((fid, sid, kind))
|
|
counts = Counter(kind for _, _, kind in occurrences)
|
|
if len(papers) != 687 or len(sessions) != 18 or counts != {'poster': 687, 'oral': 21, 'spotlight': 72}:
|
|
raise ValueError('Incomplete official program')
|
|
for paper in papers.values():
|
|
kinds = Counter(p['kind'] for p in paper['presentations'])
|
|
if kinds['poster'] != 1 or len(paper['presentations']) not in (1, 2):
|
|
raise ValueError('Invalid poster/talk multiplicity')
|
|
return papers
|
|
|
|
|
|
def join_metadata(program, archive):
|
|
if (archive.get('repository') != 'gisbi-kim/conference-explorers'
|
|
or archive.get('revision') != REVISION or archive.get('source_url') != ARCHIVE
|
|
or archive.get('source_data_sha256') != RAW_SHA or archive.get('source_git_blob_sha1') != BLOB
|
|
or not isinstance(archive.get('papers'), list)):
|
|
raise ValueError('Unpinned public metadata provenance')
|
|
indexed = {}
|
|
for row in archive['papers']:
|
|
if not isinstance(row, dict) or set(row) - FIELDS:
|
|
raise ValueError('Unexpected metadata/profile fields')
|
|
fid = forum_id(row.get('openreview'))
|
|
if fid != row.get('id') or fid in indexed:
|
|
raise ValueError('Repeated or mismatched archive forum')
|
|
if any(forum_id(row.get(key)) != fid for key in ('metadata_source', 'author_source', 'abstract_source')):
|
|
raise ValueError('Field source belongs to another submission')
|
|
if (not isinstance(row.get('title'), str) or not row['title'].strip()
|
|
or not isinstance(row.get('abstract'), str) or not row['abstract'].strip()
|
|
or not isinstance(row.get('authors'), list) or not row['authors']
|
|
or any(not isinstance(a, str) or not a.strip() or '@' in a or 'anonymous' in a.casefold() for a in row['authors'])):
|
|
raise ValueError('Incomplete scholarly metadata')
|
|
indexed[fid] = row
|
|
if set(indexed) != set(program):
|
|
raise ValueError('Official and archive forum sets differ')
|
|
return indexed
|
|
|
|
|
|
def collect(out, *, official_snapshots, archive_snapshots):
|
|
out = Path(out)
|
|
if out.exists():
|
|
raise ValueError('Output exists; inspect previous operation before retrying')
|
|
out.mkdir(parents=True)
|
|
try:
|
|
official_root = Path(official_snapshots); archive_root = Path(archive_snapshots)
|
|
official = official_root/'accepted.html'; filtered = archive_root/'explorer-paper-metadata-filtered-v1.json'
|
|
if official.is_symlink() or filtered.is_symlink():
|
|
raise ValueError('Snapshot symlinks rejected')
|
|
raw = official.read_bytes(); data = filtered.read_bytes()
|
|
if len(raw) > 8*1024**2 or len(data) > 8*1024**2 or digest(raw) != OFFICIAL_SHA or digest(data) != FILTERED_SHA:
|
|
raise ValueError('Reviewed snapshot hash changed')
|
|
receipts = json.loads((official_root/'research.json').read_bytes())['receipts']
|
|
matches = [r for r in receipts if r.get('url') == OFFICIAL]
|
|
if len(matches) != 1:
|
|
raise ValueError('Missing official source receipt')
|
|
receipt = matches[0]; observed = receipt['at']
|
|
if (receipt.get('final_url') != OFFICIAL or receipt['http_status'] != 200
|
|
or receipt['sha256'] != digest(raw) or receipt['bytes'] != len(raw)
|
|
or datetime.fromisoformat(observed.replace('Z', '+00:00')).utcoffset() is None):
|
|
raise ValueError('Invalid official receipt')
|
|
program = parse_program(raw.decode('utf-8')); archive = json.loads(data); indexed = join_metadata(program, archive)
|
|
evidence = out/'evidence'; evidence.mkdir()
|
|
sources = {}
|
|
for body, suffix, url, name in [(raw, 'html', OFFICIAL, 'program'), (data, 'json', ARCHIVE, 'archive')]:
|
|
rel = f'evidence/{digest(body)}.{suffix}'; (out/rel).write_bytes(body)
|
|
sources[name] = {'file': rel, 'sha256': digest(body), 'url': url}
|
|
rows = []; variants = []
|
|
for fid in sorted(program):
|
|
p = program[fid]; a = indexed[fid]; variant = comparable(p['title']) != comparable(a['title'])
|
|
if variant: variants.append({'forum': fid, 'official_title': p['title'], 'archive_title': a['title']})
|
|
rows.append({'source': SOURCE, 'external_id': f'2026/{fid}', 'url': a['openreview'],
|
|
'title': a['title'], 'authors': a['authors'], 'abstract': a['abstract'],
|
|
'identifiers': {'openreview': fid}, 'submission_identifiers': [{'scheme': 'openreview', 'value': fid}],
|
|
'venue': 'CoRL', 'year': 2026, 'track': 'main', 'status': 'accepted',
|
|
'raw_decision': 'listed in official CoRL 2026 accepted program', 'evidence_url': OFFICIAL,
|
|
'observed_at': observed, 'tags': [], 'metadata': {
|
|
'official_program': p, 'archive_fields': a, 'title_variant_requires_review': variant,
|
|
'source_evidence': sources, 'archive_revision': REVISION,
|
|
'field_provenance': {k: a[k] for k in ('metadata_source', 'author_source', 'abstract_source')},
|
|
'original_decision_signature_verified': False,
|
|
'scope': 'Acceptance from official forum listing; title/authors/abstract are curator snapshot versions, not live original metadata. arXiv links remain unapproved candidates. No reject inference or person aliases.'}})
|
|
if len(variants) != 34:
|
|
raise ValueError('Reviewed title-variant census changed')
|
|
path = out/'corl-program-archive-2026-main.jsonl'
|
|
payload = ''.join(json.dumps(r, ensure_ascii=False)+'\n' for r in rows).encode(); path.write_bytes(payload)
|
|
manifest = {'source': SOURCE, 'parser_version': 1, 'venue': 'CoRL', 'year': 2026, 'track': 'main',
|
|
'count': len(rows), 'file': str(path), 'file_sha256': digest(payload), 'list_url': OFFICIAL,
|
|
'status': 'partial', 'missing_abstract_count': 0}
|
|
path.with_suffix('.manifest.json').write_text(json.dumps(manifest, indent=2)+'\n')
|
|
report = {'status': 'collected_pending_identity_review', 'records': len(rows), 'presentations': 780,
|
|
'files': [manifest], 'title_variants': variants, 'source_evidence': sources,
|
|
'database_written': False, 'pdfs_downloaded': False, 'public_rejected_availability': 'unknown',
|
|
'scope': 'Source collection only; requires identity and metadata-version review before import; no exhaustive deduplication or rejected-set claim.'}
|
|
part = out/'collection-report.json.part'; part.write_text(json.dumps(report, ensure_ascii=False, indent=2)+'\n'); part.replace(out/'collection-report.json')
|
|
return report
|
|
except Exception as error:
|
|
(out/'failed.json').write_text(json.dumps({'status': 'failed_not_complete', 'error_type': type(error).__name__, 'database_written': False})+'\n')
|
|
raise
|
|
|
|
|
|
def main(argv=None, *, prog=None):
|
|
parser = argparse.ArgumentParser(prog=prog, description=__doc__)
|
|
parser.add_argument('--out', type=Path, required=True)
|
|
parser.add_argument('--official-snapshots', type=Path, required=True)
|
|
parser.add_argument('--archive-snapshots', type=Path, required=True)
|
|
args = parser.parse_args(argv)
|
|
report = collect(args.out, official_snapshots=args.official_snapshots, archive_snapshots=args.archive_snapshots)
|
|
print(json.dumps({'status': report['status'], 'records': report['records'], 'database_written': False}))
|