修复DBLP family候选漏采并提供快照恢复命令 #45

Merged
Zayden-Jung merged 1 commits from codex/dblp-ifaamas-discovery into main 2026-11-09 16:46:57 +00:00
7 changed files with 339 additions and 1 deletions
+1
View File
@@ -50,6 +50,7 @@ jobs:
subprocess.run([python,'-I','-B','-m','paper_atlas','collect','cvf','--help'],cwd=outside,check=True)
subprocess.run([python,'-I','-B','-m','paper_atlas','collect','www-archive','--help'],cwd=outside,check=True)
subprocess.run([python,'-I','-B','-m','paper_atlas','collect','aamas-proceedings','--help'],cwd=outside,check=True)
subprocess.run([python,'-I','-B','-m','paper_atlas','collect','dblp-family','--help'],cwd=outside,check=True)
subprocess.run([python,'-I','-B','-m','paper_atlas','collect','aamas-proceedings','--year','2025','--snapshots',str(src/'tests/fixtures/aamas2025'),'--out',str(root/'installed-aamas2025')],cwd=outside,check=True)
subprocess.run([python,'-I','-B','-m','paper_atlas','collect','iclr-archive','--help'],cwd=outside,check=True)
subprocess.run([python,'-I','-B','-m','paper_atlas','collect','acl','--help'],cwd=outside,check=True)
+2
View File
@@ -70,6 +70,8 @@ EWSL、EPS、ECP、EWSP 的[具体前身卷与完整快照要求](docs/coverage/
AAMAS 的[官方论文集采集器](docs/aamas-proceedings.md)支持已核验的 2012、2025 版式,可从缓存或已校验快照采集元数据。2025 年目录含 476 条非 keynote 出版物,保留完整作者和机构,HTML 未提供摘要时留空;发表形式与投稿 track 分开,不根据主题推定主会轨道或研究类型。
旧 DBLP 候选文件可能漏掉新命名空间。`collect dblp-family` 可从已校验的固定压缩快照和完整目录中[恢复指定 family 的原始候选](docs/dblp-family-recovery.md),例如 `ifaamas`;恢复文件保留卷、keynote 和 workshop 等原始条目,需另做来源范围与身份核验。
`paper-atlas collect --help` 查看来源;`paper-atlas import --help` 查看导入方式。完整批次步骤见[使用指南](docs/usage.md)。
共享实例名为 `foundry-postgres`,数据位于 `foundry_data` 库的 `research` schema;其他项目可按权限复用同一组表。库名通过 libpq service 配置、schema 通过 search_path 或 `--pg-schema` 指定,不写死在查询中。PostgreSQL 凭据放在服务器权限为 `0600` 的 libpq service 文件中;命令行只使用服务名称。`paper-atlas maintain postgres --help` 提供迁移入口:先完整核验 21 张业务表,再发布目标 schema。SQLite FTS5 内部表由 PostgreSQL GIN 索引替代。切换后 SQLite 为只读备份;`import records`、`import arxiv` 和 `maintain backfill` 使用 `--pg-service foundry-research` 写入主库,整个写入会话只允许一个协调写入者,会议文件失败时整体回滚并保留失败批次记录。
+37
View File
@@ -0,0 +1,37 @@
# DBLP family 候选恢复
DBLP 的会议命名空间会变化。旧候选过滤器包含 `atal`、`aamas`,遗漏了 `ifaamas`;2026-11-01 固定快照的完整目录实际已有 `conf/ifaamas/2025` 和 `conf/ifaamas/2026`。新目录盘点已把 `ifaamas` 纳入广泛候选范围,已有快照也可按需恢复,无需重新下载或重建完整目录。
## 运行
在已有元数据的服务器运行:
```sh
paper-atlas collect dblp-family \
--archive /data/paper-index/raw/dblp-2026-11-01.xml.gz \
--dtd /data/paper-index/raw/dblp-2023-06-28.dtd \
--catalogue /data/paper-index/collected/dblp/dblp-catalogue.sqlite \
--family ifaamas \
--out /data/paper-index/collected/ifaamas-recovered
```
`--family` 可以重复,但仅接受项目明确列出的候选 family。`--out` 必须尚不存在。同名输出由文件锁防止并发恢复;任务运行中应观测原任务,不能因为日志间隔长就重复启动。完整扫描会定期打印进度。
命令重新验证固定压缩包 SHA256、DTD MD5 与大小,并只读打开目录。目录旁的 `dblp-ai-candidates.manifest.json` 必须属于同一个快照和 DTD,包含完整记录类型计数。旧候选文件不作为完整性依据,也不会被改写。
恢复扫描使用项目原有 XML 流式解析器,仅允许已校验的本地 DTD,不联网读取 XML 实体。最终会比对完整快照的记录总数、逐 family 数量和全部选中卷的原始元数据。全部一致后才原子发布输出目录;失败时不发布半成品,也不覆盖既有文件。排查明确终止的失败任务后,可用尚不存在的输出目录重新运行。
## 输出与后续流程
- `dblp-family-candidates.jsonl`:原始 `inproceedings` 和 `proceedings`,保留书目 key、原始作者、标题、年份、卷引用、出版链接等字段。
- `recovery-manifest.json`:快照、DTD、目录凭据哈希,完整扫描数量、逐 family 数量、选中卷、旧候选文件的已知数量及输出哈希。状态为 `recovered_raw_candidates_pending_scope_review`。
恢复结果没有新增规范化的 `venue`、`track` 或决定标签,也不是 `import records` 的输入队列。`ifaamas` 的整卷可能混有研究论文、扩展摘要、keynote、博士生、演示和 JAAMAS 展示。目录过滤修复不会把这些条目统一标成 main;规范化的范围映射仍需第一方逐栏目证据。
后续先用官方目录核对标题、页码、作者及发表形式,再查数据库稳定标识和候选实体,保留每次投稿、决定和标签来源。只有审核后的新增分区才能原生导入并独立验收;已验收的来源记录不能重放。单个年份有记录不代表逐篇、track、摘要或公开拒稿覆盖完整。
## 2026-11-09 核查实例
对既有固定快照的独立原始元数据恢复发现 `ifaamas` 有 1,122 条出版物候选及 2 卷:2025 年 479 条、2026 年 643 条。2025 年的 479 条标题与起始页均对应官方目录,其中 3 条 keynote 应排除,余下 476 条出版物需逐项处理。该数字包含已经验收的 225 条来源,不是 1,122 篇可新增论文。
此实例说明过滤遗漏的影响,不代表恢复命令已完成生产导入。2026 年仍需核验官方出版清单、栏目、身份及逐次决定;缺少录用记录不能推断为拒稿。最终全库去重、覆盖和查询审计继续单独进行。
+1
View File
@@ -27,6 +27,7 @@ COMMANDS = {
('collect','aamas-proceedings'): ('paper_atlas.collectors.aamas', {}, '按官方目录区分 AAMAS 发表形式和摘要'),
('collect','www-archive'): ('paper_atlas.collectors.www_archive', {}, '核验早期WWW官方档案并分开待核查条目'),
('collect','dblp'): ('paper_atlas.collectors.dblp_records', {}, '核对并整理 DBLP 历史发表记录'),
('collect','dblp-family'): ('paper_atlas.collectors.dblp_recovery', {}, '从固定快照恢复指定 DBLP family 的原始候选'),
('catalogue','dblp'): ('paper_atlas.collectors.dblp', {}, '盘点 DBLP 历史会议目录'),
('import','arxiv'): ('paper_atlas.ingestion.arxiv', {}, '导入 arXiv 元数据 ZIP'),
('import','records'): ('paper_atlas.ingestion.records', {}, '导入核验过的会议文件'),
+1 -1
View File
@@ -20,7 +20,7 @@ DTD_MD5='96e4283e71886dec2173718957293648'
DTD_NAMES={'dblp.dtd','dblp-2023-06-28.dtd'}
RELEASE='https://doi.org/10.4230/dblp.xml.2026-11-01'
# Broad discovery candidates, including historical names; not a venue mapping.
FAMILIES=set('nips icml iclr colm colt aistats uai clear acl emnlp naacl eacl coling conll cvpr iccv eccv aaai ijcai ecai kdd sigir www wsdm recsys cikm icdm sdm ecml pkdd ecmlpkdd icra iros rss corl aips icaps ecp ewsp kr atal aamas icassp interspeech eurospeech icslp ismir miccai fat facct lrec mm mlsys'.split())
FAMILIES=set('nips icml iclr colm colt aistats uai clear acl emnlp naacl eacl coling conll cvpr iccv eccv aaai ijcai ecai kdd sigir www wsdm recsys cikm icdm sdm ecml pkdd ecmlpkdd icra iros rss corl aips icaps ecp ewsp kr atal aamas ifaamas icassp interspeech eurospeech icslp ismir miccai fat facct lrec mm mlsys'.split())
def records(archive,dtd_bytes):
+156
View File
@@ -0,0 +1,156 @@
"""Recover raw family candidates from a pinned snapshot and its existing catalogue.
The old candidate file is not an exhaustive source: earlier discovery filters
can omit an entire namespace. This command checks the complete snapshot and
catalogue, without assigning venues, tracks, acceptance or paper identities.
"""
import argparse
from collections import Counter
from contextlib import closing
import fcntl
import json
from pathlib import Path
import re
import sqlite3
import tempfile
from paper_atlas.collectors.dblp import DTD_MD5, FAMILIES, RELEASE, XML_SHA, family, records
from paper_atlas.db.submissions import timestamp
from paper_atlas.io.snapshots import digest_file
def catalogue_evidence(catalogue, families, expected_sha, expected_dtd_md5):
manifest_path = catalogue.with_name('dblp-ai-candidates.manifest.json')
manifest = json.loads(manifest_path.read_text())
if (manifest.get('snapshot_sha256') != expected_sha
or manifest.get('dtd_md5') != expected_dtd_md5):
raise ValueError('Catalogue belongs to a different snapshot or DTD')
totals = manifest.get('record_types', {})
if (set(totals) != {'proceedings', 'inproceedings'}
or any(type(n) is not int or n < 0 for n in totals.values())
or type(manifest.get('records_scanned')) is not int
or sum(totals.values()) != manifest['records_scanned']):
raise ValueError('Incomplete catalogue record totals')
counts = Counter()
volumes = {}
# The catalogue is evidence, never a writable recovery destination.
with closing(sqlite3.connect(catalogue.resolve().as_uri() + '?mode=ro', uri=True)) as c:
for name in families:
found = c.execute('SELECT record_type,count FROM family_counts WHERE family=?',
(name,)).fetchall()
if not found or not any(n for _, n in found):
raise ValueError('Family absent from complete catalogue: ' + name)
for kind, count in found:
if kind not in totals or type(count) is not int or count < 0:
raise ValueError('Invalid catalogue family count')
counts[(name, kind)] = count
for key, raw in c.execute('SELECT key,metadata_json FROM proceedings WHERE family=?',
(name,)):
row = json.loads(raw)
if (family(key) != name or row.get('key') != key
or row.get('record_type') != 'proceedings'):
raise ValueError('Invalid catalogue proceedings evidence')
volumes[key] = row
if len(volumes) != sum(counts[(name, 'proceedings')] for name in families):
raise ValueError('Catalogue proceedings count differs from volume records')
return manifest, digest_file(manifest_path)['sha256'], counts, volumes
def recover(archive, dtd, catalogue, out, families, *, expected_sha=XML_SHA,
expected_dtd_md5=DTD_MD5):
families = list(families)
if (not families or any(not isinstance(name, str)
or not re.fullmatch(r'[a-z][a-z0-9-]*', name)
or name not in FAMILIES for name in families)):
raise ValueError('Select an explicitly supported discovery family')
families = sorted(set(families))
archive, dtd, catalogue = Path(archive), Path(dtd), Path(catalogue)
output = Path(out).absolute()
if output.exists() or output.is_symlink():
raise ValueError('Recovery output must not already exist')
output.parent.mkdir(parents=True, exist_ok=True)
lock_path = output.parent / ('.' + output.name + '.recovery.lock')
with lock_path.open('a') as lock:
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
if output.exists() or output.is_symlink():
raise ValueError('Recovery output appeared before scan')
actual = digest_file(archive)
if actual['sha256'] != expected_sha:
raise ValueError('DBLP snapshot checksum mismatch')
if dtd.stat().st_size > 128 * 1024 or digest_file(dtd)['md5'] != expected_dtd_md5:
raise ValueError('DBLP DTD checksum mismatch or size limit')
manifest, manifest_sha, expected, volumes = catalogue_evidence(
catalogue, families, expected_sha, expected_dtd_md5)
totals, found = Counter(), Counter()
seen_keys, found_volumes = set(), set()
with tempfile.TemporaryDirectory(prefix='.dblp-family-', dir=output.parent) as tmp:
stage = Path(tmp) / 'recovered'
stage.mkdir()
target = stage / 'dblp-family-candidates.jsonl'
with target.open('w') as stream:
for row in records(archive, dtd.read_bytes()):
totals[row['record_type']] += 1
name = family(row['key'])
if name in families:
if row['key'] in seen_keys:
raise ValueError('Duplicate raw bibliographic key')
seen_keys.add(row['key'])
found[(name, row['record_type'])] += 1
if row['record_type'] == 'proceedings':
if volumes.get(row['key']) != row:
raise ValueError('Raw proceedings differs from catalogue evidence')
found_volumes.add(row['key'])
stream.write(json.dumps(row, ensure_ascii=False) + '\n')
scanned = sum(totals.values())
if scanned % 250000 == 0:
print(json.dumps({'status': 'scanning_raw_family_candidates',
'records_scanned': scanned,
'recovered_records': sum(found.values())}), flush=True)
if (totals != Counter(manifest['record_types'])
or sum(totals.values()) != manifest['records_scanned']):
raise ValueError('Complete snapshot totals differ from catalogue')
if found != expected or found_volumes != volumes.keys():
raise ValueError('Recovered family totals differ from catalogue')
report = {
'format_version': 1, 'source': 'dblp',
'status': 'recovered_raw_candidates_pending_scope_review',
'finished_at': timestamp(), 'source_release': RELEASE,
'snapshot_sha256': actual['sha256'], 'dtd_md5': expected_dtd_md5,
'catalogue_manifest_sha256': manifest_sha, 'families': families,
'records_scanned': sum(totals.values()), 'record_types': dict(totals),
'recovered_records': sum(found.values()),
'recovered_publications': sum(found[(n, 'inproceedings')] for n in families),
'recovered_volumes': len(found_volumes),
'family_counts': [{'family': name, 'record_type': kind, 'count': count}
for (name, kind), count in sorted(found.items())],
'old_candidate_family_counts': {
name: manifest.get('candidate_family_counts', {}).get(name, 0)
for name in families},
'catalogue_volumes': [volumes[k] for k in sorted(volumes)],
'file': str(output / target.name),
'file_sha256': digest_file(target)['sha256'], 'database_written': False,
'note': 'Raw bibliographic candidates, including volume records and possible '
'keynotes/workshops. No venue, track, acceptance or work identity '
'inferred. Requires primary-source scope and identity review; '
'not a normalized import queue. Existing imported sources must '
'not be replayed.',
}
# Deliberately not an import-records sidecar manifest.
(stage / 'recovery-manifest.json').write_text(
json.dumps(report, ensure_ascii=False, indent=2) + '\n')
if output.exists() or output.is_symlink():
raise ValueError('Recovery output appeared during scan')
stage.rename(output)
return report
def main(argv=None, *, prog=None):
parser = argparse.ArgumentParser(prog=prog, description=__doc__)
parser.add_argument('--archive', required=True, type=Path)
parser.add_argument('--dtd', required=True, type=Path)
parser.add_argument('--catalogue', required=True, type=Path)
parser.add_argument('--family', required=True, action='append', choices=sorted(FAMILIES))
parser.add_argument('--out', required=True, type=Path)
args = parser.parse_args(argv)
print(json.dumps(recover(args.archive, args.dtd, args.catalogue, args.out, args.family),
ensure_ascii=False))
+141
View File
@@ -0,0 +1,141 @@
import gzip
import hashlib
import json
from pathlib import Path
import sqlite3
import tempfile
import unittest
from unittest.mock import patch
from paper_atlas.collectors.dblp import catalogue
from paper_atlas.collectors.dblp_recovery import recover
from paper_atlas.collectors.dblp_scope import scope
from paper_atlas.ingestion.records import ingest_file
class DblpRecoveryTests(unittest.TestCase):
def setUp(self):
self.tmp = tempfile.TemporaryDirectory()
self.addCleanup(self.tmp.cleanup)
self.root = Path(self.tmp.name)
self.dtd = self.root / 'dblp.dtd'
self.dtd.write_bytes(b'<!ENTITY eacute "&#233;">')
self.archive = self.root / 'dblp.xml.gz'
# These include a keynote and a workshop, neither a main-paper inference.
body = '''<proceedings key="conf/ifaamas/2025"><title>AAMAS 2025</title><year>2025</year></proceedings>
<inproceedings key="conf/ifaamas/keynote"><author>Ren&eacute;</author><title>Keynote: Agents</title><year>2025</year><booktitle>AAMAS</booktitle><crossref>conf/ifaamas/2025</crossref></inproceedings>
<inproceedings key="conf/ifaamas/paper"><author>Alice Doe</author><title>Research <i>agents</i></title><year>2025</year><booktitle>AAMAS</booktitle><crossref>conf/ifaamas/2025</crossref><ee>https://dl.acm.org/doi/10.5555/3709347.123</ee></inproceedings>
<proceedings key="conf/ifaamas/2025w"><title>AAMAS Workshop</title><year>2025</year></proceedings>
<inproceedings key="conf/ifaamas/workshop"><title>Workshop paper</title><year>2025</year><booktitle>AAMAS Workshop</booktitle><crossref>conf/ifaamas/2025w</crossref></inproceedings>
<inproceedings key="conf/unrelated/other"><title>Other family</title><year>2025</year></inproceedings>'''
with gzip.open(self.archive, 'wb') as stream:
stream.write(('<?xml version="1.0"?><!DOCTYPE dblp SYSTEM "dblp.dtd"><dblp>'
+ body + '</dblp>').encode())
self.sha = hashlib.sha256(self.archive.read_bytes()).hexdigest()
self.md5 = hashlib.md5(self.dtd.read_bytes()).hexdigest()
self.manifest = catalogue(self.archive, self.dtd, self.root / 'catalogue',
self.sha, self.md5)
self.catalogue = Path(self.manifest['catalogue'])
self.manifest_path = self.catalogue.with_name('dblp-ai-candidates.manifest.json')
def run_recovery(self, **kwargs):
options = dict(expected_sha=self.sha, expected_dtd_md5=self.md5)
options.update(kwargs)
return recover(self.archive, self.dtd, self.catalogue, self.root / 'recovered',
['ifaamas'], **options)
def test_fresh_discovery_and_recovery_from_old_candidate_omission(self):
self.assertEqual(self.manifest['candidate_family_counts']['ifaamas'], 3)
# Simulate an older filter without altering its complete catalogue.
manifest = dict(self.manifest)
manifest['candidate_family_counts'] = {}
self.manifest_path.write_text(json.dumps(manifest))
candidate = Path(manifest['file'])
candidate.write_text('old incomplete candidate file\n')
before = {p: p.read_bytes() for p in [self.archive, self.dtd, self.catalogue,
self.manifest_path, candidate]}
with patch('urllib.request.urlopen', side_effect=AssertionError('No network')):
report = self.run_recovery()
rows = [json.loads(line) for line in Path(report['file']).read_text().splitlines()]
self.assertEqual(report['recovered_publications'], 3)
self.assertEqual(report['recovered_volumes'], 2)
self.assertEqual(report['recovered_records'], 5)
self.assertEqual(report['records_scanned'], 6)
self.assertEqual(report['old_candidate_family_counts'], {'ifaamas': 0})
self.assertFalse(report['database_written'])
self.assertEqual(next(r for r in rows if r['key'].endswith('/keynote'))['fields']['author'], ['René'])
self.assertTrue(any(r['key'].endswith('/workshop') for r in rows))
self.assertTrue(all(not ({'source', 'status', 'venue', 'track'} & r.keys()) for r in rows))
publication = next(r for r in rows if r['key'].endswith('/paper'))
volume = next(r for r in rows if r['key'] == 'conf/ifaamas/2025')
self.assertEqual(scope(publication, volume), (None, 'outside_target_family'))
self.assertEqual({p: p.read_bytes() for p in before}, before)
self.assertEqual(hashlib.sha256(Path(report['file']).read_bytes()).hexdigest(),
report['file_sha256'])
# Raw recovery files cannot accidentally enter the normalized writer.
with patch('paper_atlas.ingestion.records.open_store') as writer:
with self.assertRaisesRegex(ValueError, 'source manifest'):
ingest_file(self.root / 'never.sqlite', report['file'])
writer.assert_not_called()
self.assertFalse((self.root / 'never.sqlite').exists())
def test_checksum_mismatch_does_not_publish(self):
for options in [{'expected_sha': '0' * 64}, {'expected_dtd_md5': '0' * 32}]:
with self.subTest(options=options), self.assertRaisesRegex(ValueError, 'checksum'):
self.run_recovery(**options)
self.assertFalse((self.root / 'recovered').exists())
def test_wrong_catalogue_snapshot_and_incomplete_totals_are_rejected(self):
for changes in [{'snapshot_sha256': '0' * 64}, {'dtd_md5': '0' * 32},
{'records_scanned': 99}, {'record_types': {'proceedings': 2}}]:
manifest = {**self.manifest, **changes}
self.manifest_path.write_text(json.dumps(manifest))
with self.subTest(changes=changes), self.assertRaises(ValueError):
self.run_recovery()
self.assertFalse((self.root / 'recovered').exists())
def test_changed_family_count_does_not_publish_partial_result(self):
with sqlite3.connect(self.catalogue) as c:
c.execute("UPDATE family_counts SET count=count+1 WHERE family='ifaamas' AND record_type='inproceedings'")
with self.assertRaisesRegex(ValueError, 'family totals'):
self.run_recovery()
self.assertFalse((self.root / 'recovered').exists())
def test_changed_volume_metadata_is_detected(self):
with sqlite3.connect(self.catalogue) as c:
row = json.loads(c.execute("SELECT metadata_json FROM proceedings WHERE key='conf/ifaamas/2025'").fetchone()[0])
row['fields']['title'] = ['Wrong volume']
c.execute("UPDATE proceedings SET metadata_json=? WHERE key='conf/ifaamas/2025'", (json.dumps(row),))
with self.assertRaisesRegex(ValueError, 'proceedings differs'):
self.run_recovery()
self.assertFalse((self.root / 'recovered').exists())
def test_truncated_gzip_never_publishes(self):
self.archive.write_bytes(self.archive.read_bytes()[:-8])
revised_sha = hashlib.sha256(self.archive.read_bytes()).hexdigest()
self.manifest_path.write_text(json.dumps({**self.manifest, 'snapshot_sha256': revised_sha}))
with self.assertRaises((EOFError, OSError)):
self.run_recovery(expected_sha=revised_sha)
self.assertFalse((self.root / 'recovered').exists())
def test_existing_output_is_preserved_and_unknown_family_is_rejected(self):
out = self.root / 'recovered'
out.mkdir()
sentinel = out / 'keep'
sentinel.write_text('existing')
with self.assertRaisesRegex(ValueError, 'already exist'):
self.run_recovery()
self.assertEqual(sentinel.read_text(), 'existing')
for names in [[], ['../ifaamas'], ['not-a-supported-family'], [None]]:
with self.subTest(names=names), self.assertRaises(ValueError):
recover(self.archive, self.dtd, self.catalogue, self.root / 'other', names)
def test_requested_family_missing_from_catalogue_is_explicit(self):
with self.assertRaisesRegex(ValueError, 'absent from complete catalogue'):
recover(self.archive, self.dtd, self.catalogue, self.root / 'recovered',
['ifaamas', 'icml'], expected_sha=self.sha, expected_dtd_md5=self.md5)
self.assertFalse((self.root / 'recovered').exists())
if __name__ == '__main__':
unittest.main()