Use policy scoring weights in release search #74

Merged
naps62-yolo merged 3 commits from issue/68-core-scoring-wire into main 2026-08-22 22:12:18 +01:00
Showing only changes of commit 68e404ed07 - Show all commits
+55 -2
View File
@@ -490,8 +490,12 @@ fn classify(
Candidate::PreGrab(&parsed),
release.size.unwrap_or_default(),
naps62-yolo marked this conversation as resolved
Review

release.size.unwrap_or_default() turns an unknown size into 0 bytes, and the size term then interpolates up from the band floor: with the seeded weights and the 2160p band that is 1000 * (0 - 8GiB) / 14GiB = -571, where the old local score() returned a neutral 0 for None.

The floor rule abstains when the size is unknown (crates/arr-core/src/policy.rs:226 needs Some(size)), so a sizeless release stays eligible but now sorts near the bottom of the eligible bucket.

Apply the size term only when the size is known — skip the size component for None rather than scoring it as a zero-byte file.

`release.size.unwrap_or_default()` turns an unknown size into 0 bytes, and the size term then interpolates up from the band floor: with the seeded weights and the 2160p band that is `1000 * (0 - 8GiB) / 14GiB = -571`, where the old local `score()` returned a neutral 0 for `None`. The floor rule abstains when the size is unknown (`crates/arr-core/src/policy.rs:226` needs `Some(size)`), so a sizeless release stays eligible but now sorts near the bottom of the eligible bucket. Apply the size term only when the size is known — skip the size component for `None` rather than scoring it as a zero-byte file. <!-- agent-meta: {"model":"claude-opus-5","session":"298dcd6d"} -->
release.seeders.unwrap_or_default(),
)
.total;
);
let score = if release.size.is_some() {
score.total
} else {
score.source.saturating_add(score.seeders)
};
Ok(ClassifiedRelease {
indexer_id: release.indexer_id,
guid: release.guid,
@@ -765,6 +769,55 @@ mod tests {
);
}
#[test]
fn releases_without_sizes_skip_the_size_score() {
let policy = Policy {
id: PolicyId(1),
name: "test".into(),
required_audio: RequiredAudio::OriginalLanguage,
dub_blacklist: Vec::new(),
hdr_rules: HdrRules {
rejected_dolby_vision_profiles: Vec::new(),
},
size_bands: std::collections::BTreeMap::from([(
Resolution::R2160p,
SizeBand {
floor_bytes: gib(8),
target_bytes: gib(22),
penalty_points_per_gib_over: 60,
},
)]),
resolution_preference: vec![Resolution::R2160p],
source_weights: std::collections::BTreeMap::from([(Source::WebDl, 2)]),
score_weights: ScoreWeights::default(),
};
let release = SearchRelease {
indexer_id: 1,
guid: "release".into(),
name: "Dune.Part.Two.2024.2160p.WEB-DL".into(),
size: None,
seeders: Some(8),
publish_date: None,
download_url: "https://tracker/release".into(),
};
let parsed = arr_parse::parse(&release.name);
let core_score = score(&policy, Candidate::PreGrab(&parsed), 0, 8);
let classified = classify(
release,
&policy,
&MovieOverrides::default(),
&Language::Other("en".into()),
)
.expect("classified release");
assert_eq!(
classified.score,
core_score.source.saturating_add(core_score.seeders)
);
assert_ne!(classified.score, core_score.total);
}
#[test]
fn manual_inputs_skip_title_upstreams() {
assert!(matches!(