fix(ingest): key formulas/figures on papers.id, not filename stem (audit C-10)
extract_formulas/extract_figures derive paper_id from Path(pdf_path).stem, which need not equal papers.id (and won't, given canonical ids). Inserting that stem violated the formulas/figures -> papers(id) FK on rich (.pdf) ingest. The DELETE already used paper.id; the INSERTs now do too. Strengthened the rich-ingest test: the fake formula/figure carry a filename-stem paper_id distinct from papers.id, and the test asserts the inserted rows are keyed on papers.id. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -294,7 +294,10 @@ def ingest_paper(
|
||||
VALUES (%s, %s, %s, %s, %s)
|
||||
""",
|
||||
[
|
||||
(f.paper_id, f.page, f.raw_latex, f.context, f.eq_label)
|
||||
# paper.id, not f.paper_id: the extractor derives its
|
||||
# paper_id from the PDF filename stem, which need not match
|
||||
# papers.id and would violate the FK (audit C-10).
|
||||
(paper.id, f.page, f.raw_latex, f.context, f.eq_label)
|
||||
for f in formulas
|
||||
],
|
||||
)
|
||||
@@ -308,7 +311,8 @@ def ingest_paper(
|
||||
VALUES (%s, %s, %s, %s)
|
||||
""",
|
||||
[
|
||||
(fig.paper_id, fig.page, fig.caption, fig.image_path)
|
||||
# paper.id, not fig.paper_id (filename stem) — see C-10 above.
|
||||
(paper.id, fig.page, fig.caption, fig.image_path)
|
||||
for fig in figures
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user