fix(ingest): D-04 bibkey heuristic + D-05a/b/c regression tests + __main__ #9
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/d04-d05-ingest-fixes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes four open audit findings from
audits/2026-06-15-findings-verify.mdin one pass.D-04 — Bibkey auto-generation heuristic (low)
_make_bibkey(paper)incodex/ingest.py:ConcatSurnames + Year, ≤ 3 authors full list, > 3 →FirstEtAlYearingest_paperwhenpaper.bibkey is Nonebibkey = COALESCE(papers.bibkey, EXCLUDED.bibkey)— preserves manual overrides, fills NULL on re-ingestD-05b —
codex/__main__.pymissing (med)codex/__main__.pycallingapp()fromcli.pypython -m codex --helpnow works withoutuv runD-05c — Regression test encodes old FK behavior (med)
test_ingest.py:75: variable renamed toraw_api_citations(reflects what OpenAlex actually returns:citing_id=openalex_id)inserted_rows[0][0] == paper.id— verifies the citing_id rewrite iningest.py:184is preservedD-05a — Entry-point smoke test (high, proxy)
TestEntryPoint.test_python_m_codex_helpintests/cli/test_cli.py: runssys.executable -m codex --helpvia subprocess, exits 0, contains "Usage"uv runentry path (D-05a spirit — no CI config exists yet)Test results
D-04: add _make_bibkey(paper) — ConcatSurnames+Year, ≤3 authors full list, >3 authors FirstEtAlYear. Applied in ingest_paper when paper.bibkey is None. ON CONFLICT now fills NULL bibkeys via COALESCE(papers.bibkey, EXCLUDED.bibkey) while preserving manually-set values. D-05b: add codex/__main__.py so `python -m codex` dispatches to the CLI. D-05c: fix test_ingest.py:75 — rename var to raw_api_citations (the raw OpenAlex payload with citing_id=openalex_id) and add regression assertion: citing_id written to DB must equal paper.id (DOI), not paper.openalex_id. D-05a (proxy): add TestEntryPoint.test_python_m_codex_help — runs `sys.executable -m codex --help` via subprocess, covering the non-uv-run entry path. 253 tests green, ruff+mypy clean. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>