Compare commits

...

4 Commits

Author SHA1 Message Date
codex-bot 1e5237fe19 Preserve match candidate evidence when papers merge
Metadata integrity checks / metadata (push) Waiting to run
2026-11-26 01:41:40 +08:00
Zayden-Jung b03a8bc5fc Merge pull request '记录 NeurIPS 录用、跨会投稿历史与 MotiFlow 去重' (#95) from codex/neurips-posting-history-reconciliation into main
Metadata integrity checks / metadata (push) Successful in 1h38m15s
Reviewed-on: #95
2026-11-25 14:55:41 +00:00
Zayden-Jung 67d4cd46ff Merge pull request '扩展全库审计的标题与署名候选覆盖' (#98) from codex/extended-identity-audit into main
Metadata integrity checks / metadata (push) Has been cancelled
Reviewed-on: #98
2026-11-25 14:53:37 +00:00
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
6 changed files with 174 additions and 15 deletions
+4 -1
View File
@@ -7,12 +7,15 @@
```bash
paper-atlas audit global-identity \
--pg-service foundry-research --pg-schema research \
--extended-titles \
--scratch-root /data/paper-index/validation \
--candidate-output /data/paper-index/validation/identity-candidates-2026-11-22.jsonl \
> /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` 核对拒稿、撤稿、后续录用和来源链接。需要合并候选时先确认论文版本关系并保存投稿、决定、标签及来源证据,再按已授权的流程操作。新一批导入完成后更新快照和审计报告。
+36 -12
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)
with connection.connection.cursor(name='paper_atlas_global_identity_scan') as titles:
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):
batch = []
for row in rows:
@@ -117,7 +118,7 @@ def _stage_titles(connection, scratch):
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,
exact_title_and_roster_papers=0, near_title_and_roster_pairs=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('''
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})
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('''
SELECT authors,title_key,id FROM titles WHERE authors IS NOT NULL AND length(title_key)>=25
ORDER BY authors,title_key,id''')
@@ -142,29 +157,34 @@ def _candidates(scratch, output):
size = 0
for _, title, paper_id in group:
size += 1
if size <= ROSTER_GROUP_LIMIT:
if extended_titles or size <= ROSTER_GROUP_LIMIT:
entries.append((title,paper_id))
if size > ROSTER_GROUP_LIMIT:
oversized = size > ROSTER_GROUP_LIMIT
if oversized:
counts['oversized_rosters'] += 1
counts['papers_in_oversized_rosters'] += size
emit({'kind':'oversized_roster','size':size,'sample_paper_ids':[p for _,p in entries[:5]]})
continue
if not extended_titles:
emit({'kind':'oversized_roster','size':size,'sample_paper_ids':[p for _,p in entries[:5]]})
continue
for (left,left_id),(right,right_id) in combinations(entries,2):
if left==right or 2*min(len(left),len(right))/(len(left)+len(right)) < TITLE_SCORE:
continue
matcher = SequenceMatcher(None,left,right,autojunk=False)
if matcher.quick_ratio()>=TITLE_SCORE and (score:=matcher.ratio())>=TITLE_SCORE:
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)})
return dict(counts)
def report(connection, scratch_root, candidates):
def report(connection, scratch_root, candidates, *, extended_titles=False):
transaction = dict(connection.execute('''
SELECT current_database() AS database,current_schema() AS schema,
current_setting('transaction_read_only') AS read_only,
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':
raise ValueError('A read-only repeatable-read snapshot is required')
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:
scratch.execute('PRAGMA temp_store=FILE')
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,
'candidate_counts':candidate_counts,'edition_sources':coverage,'search':search,
'candidate_rules':{'minimum_normalized_title_length':25,'near_title_score':TITLE_SCORE,
'max_papers_per_near_title_author_group':ROSTER_GROUP_LIMIT,
'requires_exact_normalized_author_set':True},
'max_papers_per_near_title_author_group':None if extended_titles else ROSTER_GROUP_LIMIT,
'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}
@@ -192,8 +214,10 @@ def main(argv=None, *, prog=None):
parser.add_argument('--pg-schema')
parser.add_argument('--scratch-root',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)
with closing(ReadConnection(args.pg_service,args.pg_schema)) as connection:
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))
+39 -2
View File
@@ -28,6 +28,23 @@ def author_keys(authors):
return result
def _candidate_observations(score, evidence, status):
try:
payload = json.loads(evidence)
except ValueError:
payload = None
if isinstance(payload, dict) and set(payload) == {'reattached_observations'}:
rows = payload['reattached_observations']
if isinstance(rows, list) and rows and all(
isinstance(row, list) and len(row) == 3
and (row[0] is None or isinstance(row[0], (int, float)))
and isinstance(row[1], str) and isinstance(row[2], str)
for row in rows
):
return [tuple(row) for row in rows]
return [(score, evidence, status)]
class Store:
def __init__(self,path):
require_sqlite_writable(path)
@@ -69,8 +86,28 @@ class Store:
for left,right,method,score,evidence,status in candidates:
left = target if left == other else left
right = target if right == other else right
if left != right:
c.execute('INSERT INTO match_candidates VALUES(?,?,?,?,?,?) ON CONFLICT DO NOTHING',(min(left,right),max(left,right),method,score,evidence,status))
if left == right:
continue
key = (min(left, right), max(left, right), method)
inserted = c.execute(
'INSERT INTO match_candidates VALUES(?,?,?,?,?,?) ON CONFLICT DO NOTHING',
(*key, score, evidence, status),
)
if inserted.rowcount:
continue
current = c.execute(
'SELECT score,evidence_json,status FROM match_candidates '
'WHERE left_paper_id=? AND right_paper_id=? AND method=?',
key,
).fetchone()
existing = _candidate_observations(*current)
combined = list(dict.fromkeys(existing + _candidate_observations(score, evidence, status)))
if combined != existing:
c.execute(
'UPDATE match_candidates SET evidence_json=? '
'WHERE left_paper_id=? AND right_paper_id=? AND method=?',
(json.dumps({'reattached_observations': combined}, ensure_ascii=False), *key),
)
c.execute('DELETE FROM papers WHERE id=?',(other,))
def record(self,source,external_id,url,title,abstract,authors,identifiers=None,metadata=None,published=None):
+30
View File
@@ -52,6 +52,36 @@ class GlobalIdentityCandidatesTest(unittest.TestCase):
global_identity._author_fingerprint(records))
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):
connection = Mock()
+34
View File
@@ -97,6 +97,40 @@ class StoreTests(unittest.TestCase):
self.assertIsNotNone(self.store.conn.execute('SELECT 1 FROM papers WHERE id=?',(unrelated,)).fetchone())
self.assertEqual(self.store.conn.execute('SELECT count(*) FROM paper_merges').fetchone()[0],1)
def test_merge_preserves_colliding_candidate_observations(self):
first, _ = self.record('arxiv', '2601.00001', authors=['First Author'])
second, _ = self.record('pmlr', 'v1/second', authors=['Second Author'])
third, _ = self.record('acl', '2026.acl.1', authors=['Third Author'])
related, _ = self.record('arxiv', '2601.00002', authors=['Related Author'])
db = self.store.conn
method = 'exact_title_unconfirmed'
original = (None, '{"title":"Conference title"}', 'pending')
incoming = (0.98, '{"title":"Preprint title"}', 'pending')
for paper, observation in ((first, original), (second, incoming), (third, incoming)):
left, right = sorted((paper, related))
db.execute(
'INSERT INTO match_candidates VALUES(?,?,?,?,?,?) '
'ON CONFLICT(left_paper_id,right_paper_id,method) DO UPDATE SET '
'score=excluded.score,evidence_json=excluded.evidence_json,status=excluded.status',
(left, right, method, *observation),
)
self.store.merge(first, second, 'confirmed publication version')
self.store.merge(first, third, 'confirmed additional source')
rows = db.execute(
'SELECT left_paper_id,right_paper_id,score,evidence_json,status '
'FROM match_candidates WHERE method=?',
(method,),
).fetchall()
[(left, right, score, evidence, status)] = rows
self.assertEqual((left, right, score, status), (first, related, None, 'pending'))
self.assertEqual(
json.loads(evidence)['reattached_observations'],
[list(original), list(incoming)],
)
self.assertEqual(db.execute('PRAGMA foreign_key_check').fetchall(), [])
def test_manifest_count_mismatch_rolls_back_records(self):
path=Path(self.tmp.name)/'source.jsonl'
path.write_text(json.dumps({'source':'pmlr','external_id':'v1/paper','url':'https://example.org/paper','title':'Paper','abstract':'Abstract','authors':[],'venue':'ICML','year':2023,'track':'main','status':'accepted'})+'\n')
+31
View File
@@ -66,6 +66,37 @@ class PostgreSQLIngestionTests(unittest.TestCase):
def store(self):
return open_store(pg_service=self.service, pg_schema=self.schema)
def test_merge_preserves_colliding_candidate_evidence(self):
store = self.store()
with closing(store.conn) as db, db:
ids = [
store.record('fixture', key, 'https://example.org/' + key, title, None, ['Author'])[0]
for key, title in (
('preprint', 'Preprint'),
('proceedings', 'Proceedings version'),
('related', 'Related work'),
)
]
first, second, related = ids
expected = [
(None, '{"title":"Preprint"}', 'pending'),
(0.75, '{"title":"Proceedings version"}', 'pending'),
]
for paper, observation in zip((first, second), expected):
db.execute(
'INSERT INTO match_candidates VALUES(?,?,?,?,?,?)',
(paper, related, 'exact_title_unconfirmed', *observation),
)
store.merge(first, second, 'confirmed publication version')
row = db.execute(
'SELECT left_paper_id,right_paper_id,evidence_json FROM match_candidates',
).fetchone()
self.assertEqual(row[:2], (first, related))
self.assertEqual(
json.loads(row[2])['reattached_observations'],
[list(observation) for observation in expected],
)
def row(self, source='openreview_snapshot', external='forumNew1', status='rejected', year=2025, venue='ICLR'):
return {'source': source, 'external_id': external, 'url': 'https://example.org/' + external,
'venue': venue, 'year': year, 'track': 'main', 'status': status,