Skip to content

Write the loader's repeated pieces once: log collecting, the check tables, author resolution, record accessors - #144

Merged
handrews merged 1 commit into
mainfrom
claude/phylogenetics-code-review-55ca0c
Oct 22, 2026
Merged

handrews merged 1 commit into
mainfrom
claude/phylogenetics-code-review-55ca0c

Conversation

@handrews

Copy link
Copy Markdown
Owner

"Collect the package logger's records for a block" was written five times: the loader's error counter, two handler classes in the scripts, one in the test fixtures and a stream handler in the test support. One collecting() in load.py yields a Collector with the records, the errors and the warning set; load counts from it, the claims script holds and replays through it (the one place that still swaps handlers), the expected-warnings script and the fixtures read it.

The per-node integrity checks were listed by hand in three places, so a check added to the loader could be forgotten by the draft checker. phylohist/loader/checks.py holds the file, material, nomenclature and draft tables over one per-node scope; load.py and check_draft.py iterate them, draft_nulls moves beside null_material, the two source_years become one rule, and a contract test holds the draft's tables to the loader's but for the three checks only a draft needs. The loader's output is unchanged; the drafts' is too.

Author keys were resolved by three loops that differed on et al. and on a capitalised surname; resolve_authors in research.py serves the authorities, the sources and the aliases with each one's own wording, and the warning for a capitalised author whose key form is registered now names the record it is on. implied_rank and
Authority.qualified_keys replace the three spellings of "species if lower-case, else genus" and the two key-expectation cores.

load.py and claims.py read the records through accessors (declared_rank, pages, illustrations, cited_as, designation, homonym, original_parent, lang, status on Taxon; author_keys and citation_fields on Source) in place of _data, and an alias shares its target's record outright. Gone, with no reader: Source.count and title, _editors, the month and day of a publication date, Tree.is_new, bracket_end and _type_index, Section.notes, Authority._ex and _disambiguator.

The claims, the names index and the expected warnings are untouched.

…bles, author resolution, record accessors

"Collect the package logger's records for a block" was written five
times: the loader's error counter, two handler classes in the scripts,
one in the test fixtures and a stream handler in the test support. One
`collecting()` in `load.py` yields a `Collector` with the records, the
errors and the warning set; `load` counts from it, the claims script
holds and replays through it (the one place that still swaps handlers),
the expected-warnings script and the fixtures read it.

The per-node integrity checks were listed by hand in three places, so a
check added to the loader could be forgotten by the draft checker.
`phylohist/loader/checks.py` holds the file, material, nomenclature and
draft tables over one per-node scope; `load.py` and `check_draft.py`
iterate them, `draft_nulls` moves beside `null_material`, the two
`source_year`s become one rule, and a contract test holds the draft's
tables to the loader's but for the three checks only a draft needs. The
loader's output is unchanged; the drafts' is too.

Author keys were resolved by three loops that differed on `et al.` and
on a capitalised surname; `resolve_authors` in `research.py` serves the
authorities, the sources and the aliases with each one's own wording,
and the warning for a capitalised author whose key form is registered
now names the record it is on. `implied_rank` and
`Authority.qualified_keys` replace the three spellings of "species if
lower-case, else genus" and the two key-expectation cores.

`load.py` and `claims.py` read the records through accessors
(`declared_rank`, `pages`, `illustrations`, `cited_as`, `designation`,
`homonym`, `original_parent`, `lang`, `status` on `Taxon`; `author_keys`
and `citation_fields` on `Source`) in place of `_data`, and an alias
shares its target's record outright. Gone, with no reader: `Source.count`
and `title`, `_editors`, the month and day of a publication date,
`Tree.is_new`, `bracket_end` and `_type_index`, `Section.notes`,
`Authority._ex` and `_disambiguator`.

The claims, the names index and the expected warnings are untouched.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@handrews
handrews merged commit 03fe576 into main Oct 22, 2026
5 checks passed
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.

1 participant