Skip to content

Make the quality profile cutoff a ceiling, not just a stopping point - #17

Merged
kalebbroo merged 1 commit into
mainfrom
fix/quality-profile-ceiling
Aug 9, 2026
Merged

Make the quality profile cutoff a ceiling, not just a stopping point#17
kalebbroo merged 1 commit into
mainfrom
fix/quality-profile-ceiling

Conversation

@kalebbroo

Copy link
Copy Markdown
Owner

Live bug, caught during the House of the Dragon upgrade test in PR #16: a request targeting 1080p grabbed a 2160p.MAX.WEB-DL.DV.HDR release instead.

Root cause, confirmed against the live DB: every seeded profile (Any, HD-1080p, Ultra-HD) marks every tier from its floor up through 8K as allowed: true in ItemsJson. That list only ever existed to gate the floor ("nothing below 720p"), but ReleaseEvaluator scores a candidate's rank in that allowed list (Profile rank" = r * 100, the dominant score term) and accepts anything allowed — so a 2160p release, ranked far above 1080p, always won when one was available. The CutoffQualityDefinitionId was only ever consulted to decide whether to keep searching, never to cap what gets accepted.

Fix

ReleaseEvaluator.Evaluate now ranks the profile's cutoff the same way it ranks a candidate's own tier and rejects anything strictly above it (RejectionReason.AboveCutoff) — a hard ceiling, matching "give me 1080p" as meaning exactly that, not "1080p or better." The existing relaxation path (nothing at target found after repeated empty searches) still admits above-cutoff releases, same as it already does for below-floor ones — something is better than nothing once the target has genuinely been exhausted.

Verification

  • Two new tests pin this exactly, using the same "allow everything above floor" profile shape the real seeded profiles use, so it can't regress silently: Rejects_a_tier_above_the_profiles_cutoff, Relaxing_admits_a_tier_above_cutoff_when_nothing_at_target_was_found.
  • 125/125 tests pass (123 existing + 2 new), full solution build clean.

Not addressed here: the House of the Dragon request currently sits on the Any profile (which allows everything, a migration-era catch-all), not a profile actually scoped to 1080p. That's a separate seeding/assignment question — this PR fixes the evaluator so that whatever profile a request is on, its cutoff is respected as a ceiling.

Live symptom: an upgrade request set to 1080p grabbed a 2160p release
instead. Root cause: every seeded quality profile (Any, HD-1080p,
Ultra-HD) marks every tier from its floor up through 8K as "allowed" —
that list only ever existed to gate the floor. ReleaseEvaluator scored
a release's rank in that allowed list, so a higher tier always scored
higher and won, regardless of the profile's cutoff. Nothing ever said
no to going above what was actually requested.

A user who picks "1080p" means exactly that — bigger files, more
bandwidth, and playback devices that may not handle 4K weren't asked
for.

ReleaseEvaluator now ranks the profile's cutoff the same way it ranks
a candidate's own tier, and rejects anything strictly above it with a
new AboveCutoff rejection reason. The one exception is the existing
relaxation path: once repeated empty searches have found nothing AT
the target, something above it is better than nothing, matching how
below-floor relaxation already works.

Added two tests pinning the behavior (reject above cutoff; relaxation
still admits it) using the same "allow everything above floor" profile
shape the seeded production profiles use, so this doesn't regress
silently. 125/125 tests pass, build clean.
@kalebbroo
kalebbroo merged commit edaf2fe into main Aug 9, 2026
2 checks passed
@kalebbroo
kalebbroo deleted the fix/quality-profile-ceiling branch August 9, 2026 01:22
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