fix(core): stop the size floor condemning a download
ci / web (push) Successful in 1m1s
ci / rust (push) Successful in 2m23s
e2e / e2e (push) Failing after 3m20s

The floor is a selection filter (§5.5): it keeps the ranking from picking
mud while better candidates are still on the table. Once a release is
grabbed there is nothing left to choose between, so a hard fail at import
condemns a file already on disk and blacklists the release under §5.7 —
over a number the indexer gave before the grab. Size is not post-download
evidence either; §5.6 gives ffprobe audio, HDR, codec and duration.

It bit packs hardest. Pre-grab measures a pack by its total over the
season length; import measures each file on its own, so one short episode
condemned the whole release and reopened the season. And §6.3 outlasts the
fix: a blacklisted release stays rejected however the operator later sets
allow_below_floor, with no delete path.

Post-download the floor now waives instead, whatever the overrides say.
The file imports and carries a waiver naming the floor it missed.
This commit is contained in:
Miguel Palhas
2026-08-26 18:34:57 +01:00
parent d3613c6081
commit 58ad90951c
2 changed files with 118 additions and 1 deletions
+58 -1
View File
@@ -237,6 +237,16 @@ impl PolicyRule for SourceRule {
/// automatically and its import is recorded as a §5.7 waiver. This mirrors
/// [`ResolutionRule`], where an override moves a failure between hard and
/// soft and never makes the rule stop applying.
///
/// **The floor only ever rejects pre-grab.** It exists to keep the ranking
/// from picking mud when something better is in the same search (§5.5), and
/// that job is finished once a release is grabbed: at import there is
/// nothing left to choose between, so a hard fail there condemns a file
/// already on disk and blacklists the release under §5.7. Size is also not
/// post-download evidence — §5.6 gives `ffprobe` real audio, HDR, codec and
/// duration, and the size was on the release before the grab. So after
/// download the floor is a soft fail whatever the overrides say: the file
/// imports and carries a waiver naming the floor it missed.
#[derive(Clone, Copy, Debug, Default)]
pub struct SizeRule;
@@ -254,7 +264,10 @@ impl PolicyRule for SizeRule {
context.runtime_minutes,
) {
None => RuleEvaluation::Unknown(RuleKind::Size),
Some(true) if context.overrides.allow_below_floor => {
Some(true)
if context.overrides.allow_below_floor
|| context.candidate.phase() == EvaluationPhase::PostDownload =>
{
RuleEvaluation::SoftFail(Rule::Size)
}
Some(true) => RuleEvaluation::HardFail(Rule::Size),
@@ -752,6 +765,50 @@ mod tests {
);
}
/// The floor is a selection filter (§5.5), so it only rejects while
/// there is still a selection to make. A pack accepted pre-grab on its
/// per-episode average carries episodes that individually fall short;
/// hard-failing them at import blacklists a release the operator chose
/// and reopens every episode, over a number that was known before the
/// grab. Post-download the floor waives instead, with no override.
#[test]
fn below_the_floor_after_download_waives_rather_than_condemning_the_release() {
let policy = banded_policy();
let overrides = TitleOverrides::default();
let claims = claims(Some(ClaimedResolution::P1080), Some(ClaimedSource::WebDl));
// Pre-grab the same size is still a rejection: nothing is on disk
// yet and a better candidate may be one row down.
assert_eq!(
evaluate(
&policy,
&overrides,
&en(),
Candidate::PreGrab(&claims),
Some(1 << 30),
1,
0,
)
.verdict,
Verdict::Rejected(Rule::Size)
);
let media = probed(Resolution::R1080p, Some(Source::WebDl));
assert_eq!(
evaluate(
&policy,
&overrides,
&en(),
Candidate::PostDownload(&media),
Some(1 << 30),
1,
0,
)
.verdict,
Verdict::Waived(Rule::Size)
);
}
#[test]
fn allow_below_floor_says_nothing_about_a_release_that_clears_the_floor() {
let overrides = TitleOverrides {