Skip to content

feat(emit-bibtex): ledger to BibTeX with cache-resolved authors - #44

Merged
brandon-behring merged 2 commits into
mainfrom
feat/43-emit-bibtex
Jul 21, 2026
Merged

feat(emit-bibtex): ledger to BibTeX with cache-resolved authors#44
brandon-behring merged 2 commits into
mainfrom
feat/43-emit-bibtex

Conversation

@brandon-behring

Copy link
Copy Markdown
Owner

Closes #43.

What

emit-bibtex — a deterministic bib_ledger.yml → biblatex .bib transform for manuscript authoring. The ledger authors field is an unusable display string ("Surname et al. (Year)") and the ledgers carry no doi/arxiv_id/year. For arXiv sources the cached /abs/ blob — the same bytes the excerpt anchors point into — retains the Highwire citation_author/citation_title/citation_date/citation_arxiv_id meta tags, from which a real record (full author list, title, year, eprint) is reconstructed.

How

  • scripts/emit_bibtex.py (emit-bibtex): cache-Highwire authors → live arXiv Atom fallback (re-cached via cache_source so it stays byte-anchored; --no-live disables) → ledger display string for the ~26 non-arXiv sources (flagged on stderr for hand-fixing). Dedup by bibkey; reverse-collision notes; --reconcile audit by arXiv id; --seed merge; --no-overwrite. Escapes & % # _ $ only — never braces (the bug in research-kb's bibtex_generator.py).
  • validators/bibtex_out.py: parseable entries, unique keys, author+title present, no escaped-brace corruption.
  • CLI registration + docs/architecture.md auxiliary-producer row + 14 tests.

Notes

  • Re-derives F5's collision count: 0 true bibkey collisions (162 rows → 148 distinct bibkeys → 143 URLs; the 14 "extras" are cross-dossier duplicates of the same URL).
  • Real-data smoke test over the 5 research_vlm_* dossiers: 148 entries, 123 cache-resolved (full author lists, e.g. SigLIP 2's 14 authors), 25 non-arXiv display-string; validators.bibtex_out clean; --reconcile surfaces real key mismatches vs the two existing fleet bibliographies.

Verification

python3 -m pytest tests/test_emit_bibtex.py tests/test_bibtex_out.py tests/test_cli.py -q   # 37 passed
python3 -m pytest -q                                                                        # 554 passed

🤖 Generated with Claude Code

brandon-behring and others added 2 commits July 21, 2026 17:21
The bib_ledger.yml `authors` field is a display string ("Surname et al.
(Year)") and the ledgers carry no doi/arxiv_id/year, so they cannot produce a
real bibliography. For arXiv sources the cached /abs/ blob -- the same bytes the
excerpt anchors point into -- retains the Highwire citation_author/title/date/
arxiv_id tags, from which emit-bibtex reconstructs real biblatex records.

- scripts/emit_bibtex.py (emit-bibtex): cache-Highwire authors, live arXiv Atom
  fallback (re-cached so still anchored; --no-live disables), non-arXiv display
  string kept + flagged on stderr, dedup by bibkey, reverse-collision notes,
  escape & % # _ $ ONLY (never braces), --reconcile audit by arXiv id, --seed
  merge, --no-overwrite.
- validators/bibtex_out.py: parseable entries, unique keys, author+title present,
  no escaped-brace corruption.
- cli.py registration; docs/architecture.md auxiliary-producer row; 14 tests.

Re-derives F5: 0 true bibkey collisions (162 rows -> 148 keys -> 143 URLs; the
14 extras are cross-dossier dupes of the same URL). closes #43.

Generated with Claude Code

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014jpLr4doRxvoh6eBrpGavX
Codex review of the P3 diff; every finding reproduced before fixing.

- validators/bibtex_out.py: brace-balanced parser (parse_entries) replaces the
  \n}-anchored regex -> validates one-line entries, skips @string/@comment,
  detects unbalanced braces, and only counts author/title at a field position
  (a field name inside a value no longer fakes the required field).
- emit_bibtex.py: Highwire content capture backreferences the opening quote
  (apostrophes like O'Connor no longer truncate) + rejects data-name=/data-content=;
  escape \ ~ ^ too (raw ones are TeX commands/active chars); brace-protect an
  author name containing " and " (corporate names no longer split); surname
  particles (van/de/von) join the family name; dedup prefers a cache-resolved
  record over a display-string one regardless of dossier order; usage checks
  (--seed exists, --no-overwrite) run BEFORE the side-effecting emit; reconcile
  indexes by arXiv id as a list so reverse collisions both survive.
- cli.py: type _print_top_help(stream) as TextIO (pre-existing mypy).
- +10 regression tests. Full suite 564 passed.
@brandon-behring
brandon-behring merged commit 9bf4eb0 into main Jul 21, 2026
2 checks passed
@brandon-behring
brandon-behring deleted the feat/43-emit-bibtex branch July 21, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(emit-bibtex): ledger -> BibTeX with cache-resolved authors

1 participant