Skip to content

fix: automatic search skips releases too small for the book's runtime - #479

Merged
kikootwo merged 2 commits into
mainfrom
reland/311-size-floor
Oct 27, 2026
Merged

kikootwo merged 2 commits into
mainfrom
reland/311-size-floor

Conversation

@kikootwo

@kikootwo kikootwo commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Replaces #311

What changed

  • rankTorrents() (src/lib/utils/ranking-algorithm.ts) takes an opt-in minMBPerMinute option. When the book's runtime is known, results smaller than minMBPerMinute MB per minute of runtime are dropped before scoring, next to the existing 20 MB filter. With no runtime, nothing changes.
  • New constant AUTO_SEARCH_MIN_MB_PER_MINUTE = 0.15 (about 21 kbps). Only the automatic search processor (src/lib/processors/search-indexers.processor.ts) passes it. Every automatic path runs through that processor: request create, approve, watched lists, RSS matches, the retry jobs and the admin re-search. Interactive search (requests/[id]/interactive-search and audiobooks/search-torrents) does not set it, so it still lists undersized results.
  • The processor's Filtered out N results < 20 MB log line adds or < 0.15 MB/min only when a runtime is known.
  • Docs: documentation/phase3/ranking-algorithm.md (Pre-filters, the interface, a Fixed Reject undersized releases in automatic search #311 line).

Why

A Usenet post often splits an audiobook into one file per chapter, and an indexer can list each file as its own result. One such file, 57 MB for a book with a 1182-minute runtime (0.05 MB per minute), names the title and author exactly and gets full availability points as an NZB. Size against runtime is worth only 15 of the 100 base points, so the file still scored well over the 50-point threshold. Automatic search grabbed it and imported a 20-minute fragment as the whole book.

The floor sits at 0.15 MB per minute because complete releases have been seen as low as 0.21 MB per minute (about 29 kbps), and those must still be grabbed, while chapter-file grabs sit near 0.05.

Evidence

  • New tests/utils/ranking-size-floor.test.ts runs the real rankTorrents(): with the floor, the 57 MB file for a 1182-minute book is dropped and a complete release at 0.21 MB per minute is kept; with no runtime, or with the option unset (interactive), both are kept; the 20 MB filter still applies.
  • New tests/processors/search-indexers-size-floor.test.ts runs the real processor and ranker with a known runtime: given only the 57 MB file it queues no download and marks the request awaiting_search; given the file and a full release it grabs the full release and leaves the file out of the fallbacks; with no runtime it still grabs the file. It also checks the log line names the floor only when a runtime is known.
  • The two interactive route tests (tests/api/requests-actions.routes.test.ts, tests/api/audiobooks-search.routes.test.ts) now assert the ranking options carry no minMBPerMinute.
  • With main's ranking-algorithm.ts and search-indexers.processor.ts (d72326a) and this branch's four test files: 5 failed, 35 passed, all on an assertion (the 57 MB file is ranked and grabbed; the constant does not exist). On this branch: 40/40 pass.
  • Ranking oracle and right-books suites (ranking-oracle-223, ranking-right-books-223, ranking-non-latin): 405/405 pass, no result changes. The oracle scores without a runtime, and the right-books fixtures sit at 1.0 MB per minute.

Checks

  • Unit tests for the changed code (vitest related on ranking-algorithm.ts and search-indexers.processor.ts, plus the new and oracle test files): PASS, 84 files, 1723/1723
  • Type check and lint: PASS (tsc --noEmit clean; ESLint reports nothing new in the 6 touched files compared with main)
  • No image build or E2E run: the change is in src/lib only
  • Full unit suite: PR Tests (CI)

Risk and rollback

  • A complete release under about 21 kbps (0.15 MB per minute), such as a 16 or 20 kbps encode, is no longer grabbed automatically when the runtime is known; 24 kbps and up still are. Interactive search still shows it, so it can be picked by hand.
  • Only automatic search changes, and only when the book's runtime is known (from Audnexus). Without one, results are filtered and scored as before.
  • A wrong runtime (far longer than the release) could drop a correct release. The request then stays in awaiting_search and interactive search still lists the release.
  • Rollback: revert this PR. Nothing is stored, so nothing needs undoing.

Release note

🤖 Generated with Claude Code

kikootwo and others added 2 commits October 27, 2026 04:11
Automatic search only dropped results under 20 MB, so one chapter file of
a multi-file Usenet post (57 MB for a 1182-minute book) could clear the
50-point threshold and be imported as the whole book.

rankTorrents gets an opt-in minMBPerMinute option: with a known runtime,
results under that many MB per minute are dropped next to the 20 MB filter.
The automatic search processor sets it to 0.15 (about 21 kbps); interactive
search does not, so it still lists everything. No runtime: no change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: H0tChicken <seanwilliams1375@gmail.com>
@kikootwo
kikootwo marked this pull request as ready for review October 27, 2026 08:28
@kikootwo
kikootwo merged commit 82f06a7 into main Oct 27, 2026
1 check passed
@kikootwo
kikootwo deleted the reland/311-size-floor branch October 27, 2026 08:32
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