fix(ingest): D-04 bibkey heuristic + D-05a/b/c regression tests + __main__ #9

Merged
user2595 merged 1 commits from fix/d04-d05-ingest-fixes into main 2026-06-15 01:07:36 +00:00
Owner

Summary

Fixes four open audit findings from audits/2026-06-15-findings-verify.md in one pass.

D-04 — Bibkey auto-generation heuristic (low)

  • _make_bibkey(paper) in codex/ingest.py: ConcatSurnames + Year, ≤ 3 authors full list, > 3 → FirstEtAlYear
  • Applied in ingest_paper when paper.bibkey is None
  • ON CONFLICT: bibkey = COALESCE(papers.bibkey, EXCLUDED.bibkey) — preserves manual overrides, fills NULL on re-ingest

D-05b — codex/__main__.py missing (med)

  • New file codex/__main__.py calling app() from cli.py
  • python -m codex --help now works without uv run

D-05c — Regression test encodes old FK behavior (med)

  • test_ingest.py:75: variable renamed to raw_api_citations (reflects what OpenAlex actually returns: citing_id=openalex_id)
  • Added assertion: inserted_rows[0][0] == paper.id — verifies the citing_id rewrite in ingest.py:184 is preserved

D-05a — Entry-point smoke test (high, proxy)

  • TestEntryPoint.test_python_m_codex_help in tests/cli/test_cli.py: runs sys.executable -m codex --help via subprocess, exits 0, contains "Usage"
  • Covers the non-uv run entry path (D-05a spirit — no CI config exists yet)

Test results

253 passed, 7 warnings  ✓
ruff check . — All checks passed  ✓
mypy codex/ — Success: no issues found in 23 source files  ✓
## Summary Fixes four open audit findings from `audits/2026-06-15-findings-verify.md` in one pass. ## D-04 — Bibkey auto-generation heuristic (low) - `_make_bibkey(paper)` in `codex/ingest.py`: `ConcatSurnames + Year`, ≤ 3 authors full list, > 3 → `FirstEtAlYear` - Applied in `ingest_paper` when `paper.bibkey is None` - ON CONFLICT: `bibkey = COALESCE(papers.bibkey, EXCLUDED.bibkey)` — preserves manual overrides, fills NULL on re-ingest ## D-05b — `codex/__main__.py` missing (med) - New file `codex/__main__.py` calling `app()` from `cli.py` - `python -m codex --help` now works without `uv run` ## D-05c — Regression test encodes old FK behavior (med) - `test_ingest.py:75`: variable renamed to `raw_api_citations` (reflects what OpenAlex actually returns: `citing_id=openalex_id`) - Added assertion: `inserted_rows[0][0] == paper.id` — verifies the citing_id rewrite in `ingest.py:184` is preserved ## D-05a — Entry-point smoke test (high, proxy) - `TestEntryPoint.test_python_m_codex_help` in `tests/cli/test_cli.py`: runs `sys.executable -m codex --help` via subprocess, exits 0, contains "Usage" - Covers the non-`uv run` entry path (D-05a spirit — no CI config exists yet) ## Test results ``` 253 passed, 7 warnings ✓ ruff check . — All checks passed ✓ mypy codex/ — Success: no issues found in 23 source files ✓ ```
user2595 added 1 commit 2026-06-15 01:07:24 +00:00
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>
user2595 merged commit 1a9afb4433 into main 2026-06-15 01:07:36 +00:00
user2595 deleted branch fix/d04-d05-ingest-fixes 2026-06-15 01:07:36 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: user2595/codex-py#9
No description provided.