From 207265345dc550c6c52d6826dbf87c7b36b7a116 Mon Sep 17 00:00:00 2001 From: Codex Bot Date: Wed, 25 Nov 2026 18:51:50 +0800 Subject: [PATCH] Skip unchanged canonical abstracts when attaching evidence --- paper_atlas/db/store.py | 6 +++++- tests/test_submission_evidence.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/paper_atlas/db/store.py b/paper_atlas/db/store.py index 545c8bb..3e02ac5 100644 --- a/paper_atlas/db/store.py +++ b/paper_atlas/db/store.py @@ -126,7 +126,11 @@ class Store: if old: old_abstract=old[2] or json.loads(old[4]).get('last_known_abstract',{}).get('abstract') c.execute("UPDATE papers SET title=?,abstract=COALESCE(NULLIF(?,''),abstract),title_key=?,authors_json=CASE WHEN ?='[]' THEN authors_json ELSE ? END WHERE id=? AND title=? AND COALESCE(abstract,'')=COALESCE(?,'')",(title,abstract,key,json.dumps(authors,ensure_ascii=False),json.dumps(authors,ensure_ascii=False),paper,old[1],old_abstract)) - c.execute("UPDATE papers SET abstract=CASE WHEN abstract IS NULL OR abstract='' THEN ? ELSE abstract END WHERE id=?",(abstract,paper)) + c.execute("""UPDATE papers SET abstract=? + WHERE id=? AND (abstract IS NULL OR abstract='') + AND NOT (COALESCE(abstract = ?, FALSE) + OR (abstract IS NULL AND CAST(? AS TEXT) IS NULL))""", + (abstract, paper, abstract, abstract)) else: paper = inserted_id(c,'INSERT INTO papers(title,abstract,title_key,authors_json,first_published) VALUES(?,?,?,?,?)',(title,abstract,key,json.dumps(authors,ensure_ascii=False),published)) for scheme,value in ids: diff --git a/tests/test_submission_evidence.py b/tests/test_submission_evidence.py index 85c7e02..61a3164 100644 --- a/tests/test_submission_evidence.py +++ b/tests/test_submission_evidence.py @@ -56,6 +56,28 @@ class SubmissionTests(unittest.TestCase): self.decision(paper,two,'forum2',[('openreview','forum2'),('iclr_number','2')]) self.assertEqual(self.store.conn.execute('SELECT count(*) FROM submissions').fetchone()[0],2) + def test_new_source_only_updates_canonical_abstract_when_it_changes(self): + conn = self.store.conn + conn.execute("""CREATE TRIGGER reject_noop_abstract_update BEFORE UPDATE OF abstract ON papers + WHEN OLD.abstract IS NEW.abstract + BEGIN SELECT RAISE(ABORT, 'unchanged abstract written'); END""") + title = 'An indexed work with several independent records' + ids = {'arxiv': '2601.00002'} + paper, _ = self.store.record('index', 'initial', 'https://example.org/initial', title, None, [], ids) + for name, incoming, expected in ( + ('missing', None, None), + ('empty', '', ''), + ('another-empty', '', ''), + ('missing-again', None, None), + ('publication', 'Canonical abstract', 'Canonical abstract'), + ('conference', 'Conference abstract', 'Canonical abstract'), + ): + with self.subTest(source=name): + linked, record = self.store.record(name, name, 'https://example.org/'+name, title, incoming, [], ids) + self.assertEqual(linked, paper) + self.assertEqual(conn.execute('SELECT abstract FROM papers WHERE id=?', (paper,)).fetchone(), (expected,)) + self.assertEqual(conn.execute('SELECT abstract FROM source_records WHERE id=?', (record,)).fetchone(), (incoming,)) + def test_conflicting_forums_cannot_be_bridged_by_one_submission_number(self): paper,one=self.record('snapshot','realForum',['Jane Doe']) other,two=self.record('snapshot','differentForum',['Other Author']) -- 2.52.0