feat: inspect EPUB colophon to resolve low-confidence mis-seeds#4
Merged
Conversation
When `resolve` lands below the confidence gate (or returns no match), inspect the book's own EPUB and re-adjudicate with two extra signals: - OPF `dc:identifier` ISBN — a real ISBN that resolves to a same-author Hardcover book heals deterministically, no LLM (source=epub-opf). - Colophon / copyright page text folded into the Haiku prompt (source=epub-colophon); the printed print-ISBN there often matches Hardcover's canonical edition better than the OPF ebook ISBN. Only below-threshold books pay for the file I/O. Gated on COLOPHON_BOOKS_ROOT (the host path the library mounts from); unset leaves the feature off. New: colophon/epub.py (stdlib-only extraction), hardcover.book_by_isbn (Typesense-based, avoids the 403-restricted Hasura isbn filter), and grimmory.epub_path (read-only DB -> host path). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
resolveonly sees a mis-seed's title + author. When Hardcover search + Haiku can't confidently pick the same work, the book is left flagged — yet the file itself usually carries the answer: the OPFdc:identifierISBN and the colophon / copyright page.This adds a below-threshold escalation: when the normal title+author pass lands under the confidence gate (or returns no match), inspect the book's own EPUB and re-adjudicate with two extra signals.
source=epub-opf, no LLM). A realdc:identifierISBN that resolves to a same-author Hardcover book is healed directly at conf 0.97. ISBNs are edition-unique, so this is high-trust.source=epub-colophon). The printed print ISBN there often matches Hardcover's canonical edition better than the OPF ebook ISBN.Only below-threshold books pay for the file I/O; the common path is untouched. Measured marginal cost of the colophon read: ~300 input tokens, ~1.3 s, well under a cent per book.
New surface:
colophon/epub.py— stdlib-only, read-only EPUB extraction (OPF ISBNs + best-guess colophon page).hardcover.book_by_isbn— ISBN → book via the Typesensesearch(the broad Hasuraeditions(where:{isbn_13})filter is 403-restricted on this key tier).grimmory.epub_path— read-only DB → host path, gated on the newCOLOPHON_BOOKS_ROOT.Activation (not automatic):
COLOPHON_BOOKS_ROOT⇒ feature off (default). Set it to the host library root to enable.resolve --forceto get inspected; new mis-seeds get it on first encounter.Checklist
chosen_idagainst the candidate set; every write still loggedpython -m compileall colophonpasses (ruff not installed locally → deferred to CI)README.md/CHANGELOG.mdNotes / test output
Live read-only validation (real server + real files, no
--apply, no writes):Tests:
python -m unittest discover -s tests -v→ 27 passed (7 newepub.py, 3 new escalation-glue).🤖 Generated with Claude Code