Skip to content

feat: enrich bare imports + remember the unresolvable#6

Merged
vidaks merged 1 commit into
mainfrom
feat/enrich-stuck-digest
Jun 10, 2026
Merged

feat: enrich bare imports + remember the unresolvable#6
vidaks merged 1 commit into
mainfrom
feat/enrich-stuck-digest

Conversation

@vidaks

@vidaks vidaks commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Problem

Bare watch-imports land with no Hardcover id and grimmory never auto-enriches them, so an external every-30-min sweep re-submitted a REPLACE_MISSING refresh for every un-seeded book. Books that can never match (no/odd ISBN, self-pub/KDP editions Hardcover lacks) stayed un-seeded forever, so the sweep re-poked the same handful indefinitely — tens of metadata refreshes a day on days with zero new books, and no way for the operator to learn which books were hopeless.

Change

Move enrichment into colophon and give it memory.

  • colophon/enrich.py + colophon enrich — read the un-seeded set, submit a REPLACE_MISSING refresh, precondition-gated like every other write (the prior bash loop wrote blind). Dry-run unless --apply.
  • store.enrich_state — each sweep records observations; a book that never seeds is marked stuck after COLOPHON_ENRICH_STUCK_AFTER failed sweeps (default 6 ≈ 3h at the 30-min cadence), dropped from the sweep (the churn stops), and surfaced once in the maintain digest. Seeded/deleted books are pruned.
  • digest — the daily summary lists each stuck book with a UI deep-link (COLOPHON_BOOKSTORE_URL, route /book/<id>, Authelia-gated). No destructive link in email — deletion is the operator's click-through to the UI button. maintain marks a book reported only after a successful email on an --apply run; silence thereafter = keep.

Safety

  • Precondition gate (moveFilesToLibraryPattern=false + saveToOriginalFile=false) now guards the enrich refresh.
  • The LLM is not involved; no new external calls beyond the existing grimmory refresh.

Test plan

  • tests/test_enrich.py (14 cases): counting, stuck threshold, pruning, report-once, dry-run/apply refresh, precondition-abort, URL build, digest render. Stdlib unittest, network-free.
  • Full suite: 56 tests pass; compileall clean.
  • Smoked the dry-run against the live library: drove the real 6-book un-seeded set to stuck at the threshold and confirmed the sweep then submits nothing.

🤖 Generated with Claude Code

Watch-imports arrive with no Hardcover id and the server never auto-enriches
them, so a frequent sweep submits a REPLACE_MISSING refresh to seed them. New
colophon/enrich.py + the `enrich` subcommand (dry-run unless --apply,
precondition-gated like every other write).

The sweep now has memory (new store.enrich_state table): a book that never
seeds (no/odd ISBN, self-pub edition Hardcover lacks) is marked stuck after
COLOPHON_ENRICH_STUCK_AFTER failed sweeps (default 6), dropped from the sweep
so it stops being re-poked every cycle, and surfaced once in the maintain
digest with a UI deep-link (COLOPHON_BOOKSTORE_URL, route /book/<id>) for the
human to delete or keep. maintain marks a book reported only after a successful
email on an --apply run.

Replaces the memory-less external enrich loop that re-refreshed the same
unmatchable books every 30 minutes indefinitely.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vidaks vidaks merged commit 79e21c0 into main Jun 10, 2026
4 checks passed
@vidaks vidaks deleted the feat/enrich-stuck-digest branch June 10, 2026 08:47
vidaks added a commit that referenced this pull request Jul 9, 2026
Watch-imports arrive with no Hardcover id and the server never auto-enriches
them, so a frequent sweep submits a REPLACE_MISSING refresh to seed them. New
colophon/enrich.py + the `enrich` subcommand (dry-run unless --apply,
precondition-gated like every other write).

The sweep now has memory (new store.enrich_state table): a book that never
seeds (no/odd ISBN, self-pub edition Hardcover lacks) is marked stuck after
COLOPHON_ENRICH_STUCK_AFTER failed sweeps (default 6), dropped from the sweep
so it stops being re-poked every cycle, and surfaced once in the maintain
digest with a UI deep-link (COLOPHON_BOOKSTORE_URL, route /book/<id>) for the
human to delete or keep. maintain marks a book reported only after a successful
email on an --apply run.

Replaces the memory-less external enrich loop that re-refreshed the same
unmatchable books every 30 minutes indefinitely.
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