Files
paper-atlas/paper_atlas/collectors/icdm2026.py
T
codex-bot 2f1b5c959a
Metadata integrity checks / metadata (push) Successful in 3m11s
feat: collect frozen ICDM2026 program with source track evidence
2026-11-17 18:11:42 +08:00

192 lines
11 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Frozen ICDM2026 in-person program, with explicit source track evidence."""
import argparse
from collections import Counter
from datetime import datetime
import hashlib
import json
from pathlib import Path
import re
from paper_atlas.io.html import Document, Node, clean
SOURCE = 'icdm_program'
SNAPSHOT = 'remaining2026-official-leads-v1'
MANIFEST_SHA = '0e13313d94e3bff17f071d3a1384f6ed83ece156239fe5bc4633cc7a34fb8e04'
PROGRAM = 'https://icdm2026.neu.edu.cn/DetailedSessions/list.htm'
PAGES = {
'detailed-sessions': PROGRAM,
'research-policy': 'https://icdm2026.neu.edu.cn/CallforResearchTrack/list.htm',
'applied-policy': 'https://icdm2026.neu.edu.cn/CallforAppliedTrack/list.htm',
}
def digest(raw):
return hashlib.sha256(raw).hexdigest()
def one(items):
if len(items) != 1:
raise ValueError('Expected exactly one reviewed field')
return items[0]
def has_class(node, name):
return name in node.attrs.get('class', '').split()
def field(node, name):
return clean(one([n for n in node.walk() if has_class(n, name)]).text())
def load_snapshot(root):
root = Path(root); folder = root/SNAPSHOT; manifest = folder/'manifest.json'
if root.is_symlink() or folder.is_symlink() or manifest.is_symlink() or manifest.stat().st_size > 256*1024:
raise ValueError('Unsafe source manifest')
raw = manifest.read_bytes()
if digest(raw) != MANIFEST_SHA:
raise ValueError('Frozen manifest hash changed')
data = json.loads(raw)
if data['status'] != 'research_completed_not_coverage_approval' or data['year'] != 2026:
raise ValueError('Wrong source edition or incomplete research run')
receipts = [r for r in data['entries'] if r['venue'] == 'ICDM']
if len(receipts) != 3 or {r['label'] for r in receipts} != PAGES.keys():
raise ValueError('Incomplete ICDM source set')
files = {'manifest.json': raw}; indexed = {}
for receipt in receipts:
filename = receipt['file']; path = folder/filename
if Path(filename).name != filename or path.is_symlink() or path.stat().st_size > 8*1024**2:
raise ValueError('Unsafe source file')
body = path.read_bytes()
if (receipt['url'] != PAGES[receipt['label']] or receipt['final_url'] != receipt['url']
or receipt['http_status'] != 200 or receipt['bytes'] != len(body)
or receipt['sha256'] != digest(body)
or not receipt['content_type'].lower().startswith('text/html')
or datetime.fromisoformat(receipt['at']).utcoffset() is None):
raise ValueError('Source receipt/body mismatch')
if filename in files:
raise ValueError('Repeated source filename')
files[filename] = body; indexed[receipt['label']] = receipt
return indexed, files
def parse_program(raw):
doc = Document(raw.decode('utf-8'))
main = one([n for n in doc.root.walk() if n.tag == 'main' and n.attrs.get('id') == 'session-details'])
text = clean(main.text())
if ('IEEE ICDM 2026' not in text or 'November 13–15, 2026' not in text
or 'In-person session presentation list.' not in text or '34 sessions · 324 papers' not in text):
raise ValueError('Wrong edition or unreviewed program scope')
sessions = [n for n in main.walk() if n.tag == 'details' and has_class(n, 'sd-session')]
expected = {f'L{i}' for i in range(1, 21)} | {f'S{i}' for i in range(1, 15)}
if len(sessions) != 34 or {n.attrs.get('data-session-id') for n in sessions} != expected:
raise ValueError('Incomplete or repeated session census')
records = []; seen = set()
for session in sessions:
sid = session.attrs['data-session-id']; track = session.attrs.get('data-track')
form = session.attrs.get('data-format')
if (session.attrs.get('id') != sid or track not in ('research', 'applied')
or form not in ('long', 'short')):
raise ValueError('Invalid session ID, track or presentation label')
label = 'Research Track' if track == 'research' else 'Applied Track'
if field(session, 'sd-track') != label:
raise ValueError('Visible track and source attribute disagree')
count = re.fullmatch(r'(Long|Short) · ([1-9][0-9]*) papers', field(session, 'sd-format'))
if count is None or count[1].lower() != form:
raise ValueError('Visible presentation label disagrees')
rows = [n for n in session.walk() if n.tag == 'tr' and 'data-paper-id' in n.attrs]
if len(rows) != int(count[2]):
raise ValueError('Session paper count changed')
note = field(session, 'sd-table-note')
if not note.startswith(f'{form.title()} Presentation ({len(rows)} papers) · '):
raise ValueError('Unreviewed presentation-note semantics')
context = {'id': sid, 'track_literal': track, 'presentation_literal': form,
'title': field(session, 'sd-session-title'),
'time_literal': field(session, 'sd-session-time'), 'room_literal': field(session, 'sd-room')}
for row in rows:
pid = row.attrs['data-paper-id']
cells = [n for n in row.children if isinstance(n, Node) and n.tag in ('th', 'td')]
if (not re.fullmatch(r'DM[1-9][0-9]*', pid) or pid in seen
or row.attrs.get('id') != 'paper-'+pid or len(cells) != 4
or [clean(n.text()) for n in cells] != [field(row, k) for k in
('sd-time', 'sd-paper-id', 'sd-paper-title', 'sd-authors')]
or field(row, 'sd-paper-id') != pid):
raise ValueError('Repeated/malformed program paper identity or cells')
seen.add(pid)
title = field(row, 'sd-paper-title'); authors_literal = field(row, 'sd-authors')
authors = [name.strip() for name in authors_literal.split(';')]
if not title or any(not name for name in authors):
raise ValueError('Missing program title or author')
records.append({'paper_id_literal': pid, 'title': title, 'authors_literal': authors_literal,
'source_reported_authors': authors, 'time_literal': field(row, 'sd-time'),
'session': context.copy(), 'source_position': len(records)+1})
if (len(records) != 324 or len([n for n in main.walk() if 'data-paper-id' in n.attrs]) != 324
or Counter(r['session']['track_literal'] for r in records) != {'research': 241, 'applied': 83}
or Counter(r['session']['presentation_literal'] for r in records) != {'long': 168, 'short': 156}):
raise ValueError('Incomplete reviewed paper/track/presentation census')
return records
def collect(out, *, snapshots):
out = Path(out)
if out.exists():
raise ValueError('Output exists; inspect previous operation before retrying')
receipts, files = load_snapshot(snapshots)
program = receipts['detailed-sessions']; observations = parse_program(files[program['file']])
out.mkdir(parents=True)
try:
evidence = []; directory = out/'evidence'; directory.mkdir()
for name, raw in files.items():
rel = 'evidence/'+digest(raw)+Path(name).suffix; (out/rel).write_bytes(raw)
evidence.append({'file': name, 'output_file': rel, 'sha256': digest(raw)})
outputs = []
for track in ('research', 'applied'):
rows = []
for item in observations:
if item['session']['track_literal'] != track:
continue
pid = item['paper_id_literal']; url = PROGRAM+'#paper-'+pid
rows.append({'source': SOURCE, 'external_id': '2026/'+pid, 'url': url,
'title': item['title'], 'authors': item['source_reported_authors'], 'abstract': None,
'venue': 'ICDM', 'year': 2026, 'track': track, 'status': 'accepted',
'identifiers': {}, 'submission_identifiers': [], 'observed_at': program['at'],
'evidence_url': url,
'raw_decision': 'Listed in official ICDM2026 in-person '+track+' program; not an original signed decision or verified publisher record.',
'tags': [{'namespace': SOURCE+':session_track', 'value': track},
{'namespace': SOURCE+':presentation', 'value': item['session']['presentation_literal']}],
'metadata': {'program_fields': item, 'program_receipt': program,
'original_decision_signature_verified': False,
'program_id_scope': 'Source program locator only; not asserted original submission ID or publication DOI.',
'author_scope': 'Source-reported program names; no publisher completeness or person alias assertion.',
'abstract_availability': 'No abstracts in this frozen program table.',
'track_evidence': 'Explicit data-track attribute agrees with visible session label; not inferred from topic.',
'paper_type': None,
'scope': 'In-person program only; excludes other program sections. Long/short describe presentation format. Requires work/version and publication review before import.'}})
path = out/f'icdm-program-2026-{track}.jsonl'
payload = ''.join(json.dumps(row, ensure_ascii=False)+'\n' for row in rows).encode(); path.write_bytes(payload)
manifest = {'source': SOURCE, 'parser_version': 1, 'venue': 'ICDM', 'year': 2026,
'track': track, 'count': len(rows), 'file': str(path), 'file_sha256': digest(payload),
'list_url': PROGRAM, 'status': 'partial', 'missing_abstract_count': len(rows),
'source_expected_count': len(rows), 'scope': 'Frozen in-person program section, not all accepted/published papers.'}
path.with_suffix('.manifest.json').write_text(json.dumps(manifest, indent=2)+'\n'); outputs.append(manifest)
report = {'status': 'collected_pending_identity_review', 'records': 324, 'sessions': 34,
'files': outputs, 'track_counts': {'research': 241, 'applied': 83},
'presentation_counts': {'long': 168, 'short': 156}, 'missing_abstract_count': 324,
'evidence': evidence, 'public_rejected_metadata': 'unknown_no_public_export_verified',
'negative_policy_scope': 'Research triple-blind and applied single-blind concern review-time visibility; neither proves final public decision coverage.',
'database_written': False, 'network_requests': 0, 'pdfs_downloaded': False,
'scope': 'In-person program observations only. No work merge, inferred author alias, publication identity, original signed decision or final whole-database audit.'}
temporary = out/'collection-report.json.part'; temporary.write_text(json.dumps(report, indent=2)+'\n')
temporary.replace(out/'collection-report.json')
return report
except Exception as error:
(out/'failed.json').write_text(json.dumps({'status': 'failed', '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('--snapshots', required=True, type=Path)
parser.add_argument('--out', required=True, type=Path)
args = parser.parse_args(argv)
print(json.dumps(collect(args.out, snapshots=args.snapshots), ensure_ascii=False))