Skip to content

fix: make Chaptarr book requests converge safely - #3

Merged
elbrielle merged 1 commit into
mainfrom
claude/sweet-carson-g5599o
Jul 16, 2026
Merged

elbrielle merged 1 commit into
mainfrom
claude/sweet-carson-g5599o

Conversation

@elbrielle

@elbrielle elbrielle commented Jul 16, 2026 •

Copy link
Copy Markdown
Owner

What this fixes

The July 15 Robin Hobb request exposed a false-success path. While Chaptarr was still importing the new author's large catalog, the bot selected a Farseer collection row, wrote monitor state too early, and queued a search that completed with no results. The catalog import later removed the partial monitor state, but Discord had already reported success.

This change makes a request succeed only after Chaptarr has settled, the exact work and requested format have been selected, every write has survived a read-back, and BookSearch has returned a valid acknowledgement.

Safe request sequence

  1. Wait for three stable command, book-list, and matching-edition snapshots before any existing-author mutation, after a new-author add, after adding a missing work, and after a bot-issued RefreshAuthor.
  2. Resolve duplicate local pockets by stable work identity and usable requested-format editions.
  3. Treat /edition?bookId=... and its explicit format as authoritative. Physical editions cannot satisfy audiobook requests.
  4. Select one edition with a full-book PUT, monitor the book through /book/monitor, then read both resources back.
  5. Require top-level monitoring, the explicit requested-format monitor flag, and exactly the chosen requested-format edition.
  6. Queue BookSearch only after that read-back and require a known successful command acknowledgement before Discord reports success.

Partial states are repairable on retry. Available files, grabs, an exact active search, and a recent valid acknowledgement in the same process prevent immediate duplicates—even if an import tail has cleared the monitor flags. After a restart or a completed zero-result search, an explicit retry may intentionally start one fresh search.

This remains a one-work-per-interaction flow. Clear bundle, trilogy, omnibus, box-set, complete-series, and numbered multi-book results fail before any request mutation and tell the user to choose individual titles. Automatic series expansion is a separate feature.

Verification

  • 89 Rust tests pass, including exact mock API sequences for new authors, existing authors, duplicate pockets, changing edition imports, strict read-back, malformed search acknowledgements, retry repair, and concurrent requests.
  • cargo fmt --all -- --check passes.
  • Clippy passes with warnings denied using the same flags as CI.
  • git diff --check passes.

Exact candidate staging

  • GitHub run 29476523539 passed Nix checks, Clippy, the Docker build, and the exact-image startup smoke test.
  • The PR merge candidate 52ace348 has the same Git tree as source commit 5683f39.
  • The downloaded archive checksum and its complete OCI digest chain passed verification.
  • That exact image passed Moonrock's no-Discord preflight against both Seerr paths and Chaptarr 0.9.720.0, then replaced only the Doplarr container.
  • Runtime is healthy with all four backends, Discord connected, zero restarts, and the existing non-root/read-only hardening intact.

No production-family book request was invented for testing. The PR remains draft until an intentionally chosen new-author request passes the live mutation checklist in docs/chaptarr/RELEASE_CHECKLIST.md.

@elbrielle
elbrielle force-pushed the claude/sweet-carson-g5599o branch from fff63a0 to 5683f39 Compare July 16, 2026 06:22
@elbrielle elbrielle changed the title fix: verify monitoring, editions, and catalog settle before Chaptarr success fix: make Chaptarr book requests converge safely Jul 16, 2026
@elbrielle
elbrielle marked this pull request as ready for review July 16, 2026 16:51
@elbrielle
elbrielle merged commit 2ae7e59 into main Jul 16, 2026
4 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