Skip to content

Reading lists find every volume of a series name (#1053) - #1054

Merged
ajslater merged 1 commit into
developfrom
claude/issue-1053-volume-start-year-1dcba4
Nov 25, 2026
Merged

ajslater merged 1 commit into
developfrom
claude/issue-1053-volume-start-year-1dcba4

Conversation

@ajslater

Copy link
Copy Markdown
Owner

Fixes #1053: reading lists missed every volume of a series name after the first.

Root cause. A codex Series is a name. A comicbox series is one volume run. The importer folded every volume's series.start_year into one Series.start_year, and comic_references stamped that year on every comic. comicbox treats the start year as the volume's identity, so Batman (2011) #1 read as a 1940-volume comic.

What changed

Part 1: a start year per volume

  • New Volume.start_year. The importer fills it from each comic's series.start_year: the earliest in a batch, the last non-null across batches, the same merge the series uses. A comic with no Volume tag gives its year to the null volume.
  • comic_references now emits volume__start_year. It emits series ids only for a series with one volume; the multi-volume series are found in one extra query per batch.
  • Migration 0062 (self-contained, _0062_volume_start_years.py):
    • Backfills a series' only volume, except a volume named for a different year.
    • Rewrites stale references with the plan's three rules and drops folded series ids from references codex built.
    • Clears non-manual exact_name/normalized_name/mapping/series_id matches in multi-volume series so they get matched again.
    • Sets a new Timestamp key VY to pending.
  • One-time fill-in. I found no existing mechanism for one-time post-migration work. The nearest is the state-derived startup check queue_unstamped_tags_sync, but a state check would fire again on every start for volumes whose comics carry no start year. So the migration leaves a marker. At the librarian's next start, queue_volume_start_years queues a ForceUpdateComicsTask for the lowest live comic of each yearless volume of a multi-volume series, queues a full ReadingListRematchTask, and clears the marker.
  • Rematch after the re-read. A forced re-read that only learns a volume's year changes no comic row, so counts.comic stays 0 and _queue_rematch never fired (checked in a test). The importer now counts volume start-year changes (Counts.volume_years), and _queue_rematch fires on those too.
  • Restore runs rules 1 and 3 over the references it restores (volume_years.unfold_reference).

Part 2: codex's own tiers

  • _pick flags review when the best comics' volumes conflict, using comicbox's any_conflict over discriminators(candidates[pk]). One run filed under both "v2" and "(2011)" does not conflict.
  • The mapping and series-id tiers look up the issue per volume. They keep the volumes that agree with the entry (or all of them if none agree), then the volumes with the same cover year, else within one year, else all. They flag review when conflicting volumes remain.
  • series_key uses discriminators(reference).year, which removes codex's copied YEAR_LIKE_VOLUME.

Reproduction (the issue's CBL through import_document, one Series "Batman" with volumes 1940/2011/2016)

Before (develop's matcher and references):

<Book Series="Batman" Number="1" Volume="1940" Year="1940"/>   -> Batman (1940) #1   exact_name
<Book Series="Batman" Number="1" Volume="2011" Year="2011"/>   -> missing
<Book Series="Batman" Number="1" Volume="2016" Year="2016"/>   -> missing
<Book Series="Batman" Number="1" Year="2016"/>                 -> Batman (2016) #1   exact_name
<Book Series="Batman" Number="1" Volume="2011"/>               -> missing
<Book Series="Batman" Number="1" Volume="1940"/>               -> Batman (1940) #1   exact_name
<Book Series="Batman" Number="1" Volume="2025" Year="2025"/>   -> missing

After:

<Book Series="Batman" Number="1" Volume="1940" Year="1940"/>   -> Batman (1940) #1   exact_name   review=False
<Book Series="Batman" Number="1" Volume="2011" Year="2011"/>   -> Batman (2011) #1   exact_name   review=False
<Book Series="Batman" Number="1" Volume="2016" Year="2016"/>   -> Batman (2016) #1   exact_name   review=False
<Book Series="Batman" Number="1" Year="2016"/>                 -> Batman (2016) #1   exact_name   review=False
<Book Series="Batman" Number="1" Volume="2011"/>               -> Batman (2011) #1   exact_name   review=False
<Book Series="Batman" Number="1" Volume="1940"/>               -> Batman (1940) #1   exact_name   review=False
<Book Series="Batman" Number="1" Volume="2025" Year="2025"/>   -> missing            -            review=False

Gates

Develop was merged first (nothing new). make fix passes with no changes to files outside this PR. make lint passes with 0 errors and 0 warnings. make ty passes. make test (no dev server running) passes: pytest 2879 passed, 2 skipped; vitest 1462 passed. All 16 new matcher, combine and export tests and the restore test fail on develop's code.

Known limits

  • A Volume row that holds two runs still follows import order. This covers comics with no Volume tag from two runs, and two Metron series that share a name and volume number. Disagreeing proposals are not stored as null, as decided.
  • A copied Metron entry for the volume whose year was the series' loses its start year under rule 2, as accepted. It keeps its volume number and cover year.
  • Until the one-time re-read finishes, Metron-numbered volumes of a multi-volume series match only entries that have a cover year. Year-named volumes match right away.
  • The re-read marker is cleared when the work is queued, not when it finishes. If Codex stops before the re-read runs, it is not retried. Force Update on a series records each volume's year.
  • Series.identifier is still one per name. A per-volume identifier is deferred.

Not built / not verified

  • Not built: the plan's optional Part 2 item (run match_comics first for mapped entries). It needs a second, per-series match_comics pass with renamed candidates, which is not small.
  • Not built: the plan's separate NEWS hint about Force Update. The hand-off asked for one NEWS line.
  • Not verified: the migration and the startup re-read on a real upgraded library. They are covered by tests on seeded databases only.
  • Not verified: the forced re-read, tested with comicbox.yaml archives only, not MetronInfo or ComicInfo files.

🤖 Generated with Claude Code

A codex Series is a name, a comicbox series is one volume run, and the
importer folded every volume's start year into one Series.start_year,
which comic_references stamped on every comic. comicbox treats a start
year as the volume's identity, so Batman (2011) #1 read as a 1940-volume
comic and every later volume went missing.

- Volume.start_year, fed by the importer from each comic's
  series.start_year (earliest in a batch, last non-null across batches,
  as for the series). comic_references uses it, and gives series ids only
  for a series with one volume.
- Migration 0062: backfill a series' only volume; rewrite codex-built
  references by the three rules (a year-like volume that contradicts the
  start year; a linked hand or tagged entry takes its volume's year; an
  unlinked one loses a same-named multi-volume series' year), dropping
  folded series ids; clear non-manual name, mapping and series-id matches
  in multi-volume series; mark a one-time re-read pending.
- The librarian, at its first start after 0062, force-reads the lowest
  live comic of each yearless volume of a multi-volume series and queues
  a full rematch. An import that changes a volume's start year now queues
  a rematch too, since such a re-read changes no comic row.
- Restore unfolds references from a dump made before 0062.
- Matcher: review flag when the best comics' volumes conflict (comicbox's
  any_conflict); the mapping and series-id tiers look per volume, keep the
  volumes that agree with the entry, then those of its cover year (exact,
  then within one), and flag review when conflicting volumes remain.
  series_key uses comicbox's discriminators.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ajslater
ajslater merged commit 42c933c into develop Nov 25, 2026
9 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