Compare commits

..

2 Commits

Author SHA1 Message Date
codex-bot 168ad8ec4e Extend global audit to author variants and large rosters
Metadata integrity checks / metadata (push) Has been cancelled
2026-11-25 22:44:36 +08:00
Zayden-Jung 7b684e8d4a Merge pull request '更新 NeurIPS 2026 近期 arXiv 对账与逐篇验收' (#94) from codex/neurips-recent-arxiv-coverage into main
Metadata integrity checks / metadata (push) Failing after 23m23s
Reviewed-on: #94
2026-11-25 08:47:09 +00:00
3 changed files with 70 additions and 13 deletions
+4 -1
View File
@@ -7,12 +7,15 @@
```bash ```bash
paper-atlas audit global-identity \ paper-atlas audit global-identity \
--pg-service foundry-research --pg-schema research \ --pg-service foundry-research --pg-schema research \
--extended-titles \
--scratch-root /data/paper-index/validation \ --scratch-root /data/paper-index/validation \
--candidate-output /data/paper-index/validation/identity-candidates-2026-11-22.jsonl \ --candidate-output /data/paper-index/validation/identity-candidates-2026-11-22.jsonl \
> /data/paper-index/validation/identity-report-2026-11-22.json > /data/paper-index/validation/identity-report-2026-11-22.json
``` ```
JSON 报告记录快照时间、论文与缺摘要计数、稳定标识冲突、约束状态、会议年度与轨道的来源覆盖,以及一次实际的全文搜索和执行计划。JSONL 保存同题且规范化作者集合相同的论文组,以及相同作者集合中标题相似度至少为 0.90 的论文对。超过 100 条记录的作者组会列入报告,留作后续逐组核对。缺作者、作者增减或换名的版本需要结合 DOI、论坛或作者说明,使用 `audit source-identities` 和原始来源复核。 JSON 报告记录快照时间、论文与缺摘要计数、稳定标识冲突、约束状态、会议年度与轨道的来源覆盖,以及一次实际的全文搜索和执行计划。JSONL 保存同题且规范化作者集合相同的论文组,以及相同作者集合中标题相似度至少为 0.90 的论文对。全库验收使用 `--extended-titles`,可额外获得同题但署名不同或缺失的候选,以及超过 100 条记录的同作者组中的近似题名候选。由于需要比较这些组的题名,运行时间随组内题名数增加。日常核查省略该参数时,大组只输出规模和样例。
近似题名比较要求规范化作者集合一致。题名与署名均变动的版本,使用 `audit source-identities` 并结合 DOI、论坛、作者说明或原始来源复核。候选仍需核实论文身份和投稿决定的证据。
将报告、候选文件、运行版本与 SHA-256 一起保留。使用 `audit histories` 核对拒稿、撤稿、后续录用和来源链接。需要合并候选时先确认论文版本关系并保存投稿、决定、标签及来源证据,再按已授权的流程操作。新一批导入完成后更新快照和审计报告。 将报告、候选文件、运行版本与 SHA-256 一起保留。使用 `audit histories` 核对拒稿、撤稿、后续录用和来源链接。需要合并候选时先确认论文版本关系并保存投稿、决定、标签及来源证据,再按已授权的流程操作。新一批导入完成后更新快照和审计报告。
+34 -10
View File
@@ -96,7 +96,8 @@ def _stage_titles(connection, scratch):
counts = Counter(papers=0, missing_abstract=0, missing_author_keys=0, invalid_authors_json=0) counts = Counter(papers=0, missing_abstract=0, missing_author_keys=0, invalid_authors_json=0)
with connection.connection.cursor(name='paper_atlas_global_identity_scan') as titles: with connection.connection.cursor(name='paper_atlas_global_identity_scan') as titles:
titles.itersize = 5000 titles.itersize = 5000
titles.execute('SELECT id,title_key,authors_json,abstract IS NULL OR btrim(abstract)=\'\' FROM papers ORDER BY id') # The scratch indexes provide the ordering used by every candidate query.
titles.execute('SELECT id,title_key,authors_json,abstract IS NULL OR btrim(abstract)=\'\' FROM papers')
while rows := titles.fetchmany(5000): while rows := titles.fetchmany(5000):
batch = [] batch = []
for row in rows: for row in rows:
@@ -117,7 +118,7 @@ def _stage_titles(connection, scratch):
return dict(counts) return dict(counts)
def _candidates(scratch, output): def _candidates(scratch, output, *, extended_titles=False):
counts = Counter(exact_title_groups=0, exact_title_and_roster_groups=0, counts = Counter(exact_title_groups=0, exact_title_and_roster_groups=0,
exact_title_and_roster_papers=0, near_title_and_roster_pairs=0, exact_title_and_roster_papers=0, near_title_and_roster_pairs=0,
oversized_rosters=0, papers_in_oversized_rosters=0) oversized_rosters=0, papers_in_oversized_rosters=0)
@@ -134,6 +135,20 @@ def _candidates(scratch, output):
ids = [row[0] for row in scratch.execute(''' ids = [row[0] for row in scratch.execute('''
SELECT id FROM titles WHERE title_key=? AND authors=? ORDER BY id''', (title,roster))] SELECT id FROM titles WHERE title_key=? AND authors=? ORDER BY id''', (title,roster))]
emit({'kind':'exact_title_and_roster','title_key':title,'paper_ids':ids}) emit({'kind':'exact_title_and_roster','title_key':title,'paper_ids':ids})
if extended_titles:
counts['exact_title_with_roster_variation_groups'] = 0
counts['near_title_pairs_in_oversized_rosters'] = 0
for title,roster_count,missing in scratch.execute('''
SELECT title_key,count(DISTINCT authors),count(*)-count(authors)
FROM titles WHERE title_key<>''
GROUP BY title_key HAVING count(*)>1
AND (count(DISTINCT authors)>1 OR count(authors)<count(*))
ORDER BY title_key'''):
ids = [row[0] for row in scratch.execute('''
SELECT id FROM titles WHERE title_key=? ORDER BY id''', (title,))]
counts['exact_title_with_roster_variation_groups'] += 1
emit({'kind':'exact_title_with_roster_variation','title_key':title,'paper_ids':ids,
'distinct_known_rosters':roster_count,'papers_missing_roster':missing})
cursor = scratch.execute(''' cursor = scratch.execute('''
SELECT authors,title_key,id FROM titles WHERE authors IS NOT NULL AND length(title_key)>=25 SELECT authors,title_key,id FROM titles WHERE authors IS NOT NULL AND length(title_key)>=25
ORDER BY authors,title_key,id''') ORDER BY authors,title_key,id''')
@@ -142,11 +157,13 @@ def _candidates(scratch, output):
size = 0 size = 0
for _, title, paper_id in group: for _, title, paper_id in group:
size += 1 size += 1
if size <= ROSTER_GROUP_LIMIT: if extended_titles or size <= ROSTER_GROUP_LIMIT:
entries.append((title,paper_id)) entries.append((title,paper_id))
if size > ROSTER_GROUP_LIMIT: oversized = size > ROSTER_GROUP_LIMIT
if oversized:
counts['oversized_rosters'] += 1 counts['oversized_rosters'] += 1
counts['papers_in_oversized_rosters'] += size counts['papers_in_oversized_rosters'] += size
if not extended_titles:
emit({'kind':'oversized_roster','size':size,'sample_paper_ids':[p for _,p in entries[:5]]}) emit({'kind':'oversized_roster','size':size,'sample_paper_ids':[p for _,p in entries[:5]]})
continue continue
for (left,left_id),(right,right_id) in combinations(entries,2): for (left,left_id),(right,right_id) in combinations(entries,2):
@@ -155,16 +172,19 @@ def _candidates(scratch, output):
matcher = SequenceMatcher(None,left,right,autojunk=False) matcher = SequenceMatcher(None,left,right,autojunk=False)
if matcher.quick_ratio()>=TITLE_SCORE and (score:=matcher.ratio())>=TITLE_SCORE: if matcher.quick_ratio()>=TITLE_SCORE and (score:=matcher.ratio())>=TITLE_SCORE:
counts['near_title_and_roster_pairs'] += 1 counts['near_title_and_roster_pairs'] += 1
if oversized:
counts['near_title_pairs_in_oversized_rosters'] += 1
emit({'kind':'near_title_and_roster','paper_ids':[left_id,right_id],'score':round(score,5)}) emit({'kind':'near_title_and_roster','paper_ids':[left_id,right_id],'score':round(score,5)})
return dict(counts) return dict(counts)
def report(connection, scratch_root, candidates): def report(connection, scratch_root, candidates, *, extended_titles=False):
transaction = dict(connection.execute(''' transaction = dict(connection.execute('''
SELECT current_database() AS database,current_schema() AS schema, SELECT current_database() AS database,current_schema() AS schema,
current_setting('transaction_read_only') AS read_only, current_setting('transaction_read_only') AS read_only,
current_setting('transaction_isolation') AS isolation, current_setting('transaction_isolation') AS isolation,
transaction_timestamp()::text AS snapshot_at''').fetchone()) transaction_timestamp()::text AS snapshot_at,
(SELECT max(id) FROM ingest_runs) AS last_ingest_run''').fetchone())
if transaction['read_only']!='on' or transaction['isolation']!='repeatable read': if transaction['read_only']!='on' or transaction['isolation']!='repeatable read':
raise ValueError('A read-only repeatable-read snapshot is required') raise ValueError('A read-only repeatable-read snapshot is required')
if shutil.disk_usage(scratch_root).free < 2*1024**3: if shutil.disk_usage(scratch_root).free < 2*1024**3:
@@ -177,12 +197,14 @@ def report(connection, scratch_root, candidates):
with closing(sqlite3.connect(Path(directory)/'titles.sqlite')) as scratch: with closing(sqlite3.connect(Path(directory)/'titles.sqlite')) as scratch:
scratch.execute('PRAGMA temp_store=FILE') scratch.execute('PRAGMA temp_store=FILE')
counts = _stage_titles(connection,scratch) counts = _stage_titles(connection,scratch)
candidate_counts = _candidates(scratch,candidates) candidate_counts = _candidates(scratch,candidates,extended_titles=extended_titles)
return {'snapshot':transaction,'papers':counts,'integrity':integrity, return {'snapshot':transaction,'papers':counts,'integrity':integrity,
'candidate_counts':candidate_counts,'edition_sources':coverage,'search':search, 'candidate_counts':candidate_counts,'edition_sources':coverage,'search':search,
'candidate_rules':{'minimum_normalized_title_length':25,'near_title_score':TITLE_SCORE, 'candidate_rules':{'minimum_normalized_title_length':25,'near_title_score':TITLE_SCORE,
'max_papers_per_near_title_author_group':ROSTER_GROUP_LIMIT, 'max_papers_per_near_title_author_group':None if extended_titles else ROSTER_GROUP_LIMIT,
'requires_exact_normalized_author_set':True}, 'includes_exact_title_with_roster_variation':extended_titles,
'requires_exact_normalized_author_set':not extended_titles,
'near_title_requires_exact_normalized_author_set':True},
'canonical_data_changed':False} 'canonical_data_changed':False}
@@ -192,8 +214,10 @@ def main(argv=None, *, prog=None):
parser.add_argument('--pg-schema') parser.add_argument('--pg-schema')
parser.add_argument('--scratch-root',type=Path,required=True) parser.add_argument('--scratch-root',type=Path,required=True)
parser.add_argument('--candidate-output',type=Path,required=True) parser.add_argument('--candidate-output',type=Path,required=True)
parser.add_argument('--extended-titles',action='store_true',
help='同时输出同题不同或缺失署名的候选,并扫描超出默认规模的作者组')
args = parser.parse_args(argv) args = parser.parse_args(argv)
with closing(ReadConnection(args.pg_service,args.pg_schema)) as connection: with closing(ReadConnection(args.pg_service,args.pg_schema)) as connection:
with args.candidate_output.open('x',encoding='utf-8') as candidates: with args.candidate_output.open('x',encoding='utf-8') as candidates:
result = report(connection,args.scratch_root,candidates) result = report(connection,args.scratch_root,candidates,extended_titles=args.extended_titles)
print(json.dumps(result,ensure_ascii=False)) print(json.dumps(result,ensure_ascii=False))
+30
View File
@@ -52,6 +52,36 @@ class GlobalIdentityCandidatesTest(unittest.TestCase):
global_identity._author_fingerprint(records)) global_identity._author_fingerprint(records))
self.assertIsNone(global_identity._author_fingerprint('[]')) self.assertIsNone(global_identity._author_fingerprint('[]'))
def test_extended_titles_include_changed_rosters_and_scan_oversized_rosters(self):
output = io.StringIO()
with sqlite3.connect(':memory:') as scratch:
scratch.execute('CREATE TABLE titles (id INTEGER, title_key TEXT, authors BLOB)')
scratch.executemany('INSERT INTO titles VALUES (?,?,?)', [
(1, 'astronomicaltransientcatalogue', b'first'),
(2, 'astronomicaltransientcatalogues', b'first'),
(3, 'astronomicaltransientcatalogued', b'first'),
(4, 'astronomicaltransientcatalogue', b'second'),
(5, 'astronomicaltransientcatalogue', None),
(6, 'anotherunrelatedarticleheading', None),
(7, 'anotherunrelatedarticleheading', None),
])
with patch.object(global_identity, 'ROSTER_GROUP_LIMIT', 2):
counts = global_identity._candidates(scratch, output, extended_titles=True)
records = [json.loads(row) for row in output.getvalue().splitlines()]
self.assertEqual(counts['oversized_rosters'], 1)
self.assertEqual(counts['near_title_pairs_in_oversized_rosters'], 3)
self.assertEqual(counts['near_title_and_roster_pairs'], 3)
self.assertEqual(counts['exact_title_with_roster_variation_groups'], 2)
self.assertEqual(records[:2], [
{'kind': 'exact_title_with_roster_variation', 'title_key': 'anotherunrelatedarticleheading',
'paper_ids': [6, 7], 'distinct_known_rosters': 0, 'papers_missing_roster': 2},
{'kind': 'exact_title_with_roster_variation', 'title_key': 'astronomicaltransientcatalogue',
'paper_ids': [1, 4, 5], 'distinct_known_rosters': 2, 'papers_missing_roster': 1},
])
self.assertEqual({tuple(sorted(record['paper_ids'])) for record in records[2:]},
{(1, 2), (1, 3), (2, 3)})
def test_doi_pattern_is_bound_as_a_parameter(self): def test_doi_pattern_is_bound_as_a_parameter(self):
connection = Mock() connection = Mock()