feat(radio): add zero-weight selection fallback

cx
This commit is contained in:
vicrodh committed 2026-01-20 15:05:02 -06:00
1 parent eab57dc4cd
commit da1384fbcc
1 file changed
+7 -1
+7 -1
View File
@@ -76,7 +76,13 @@ impl RadioEngine {
}
if total_weight == 0 {
return Err("Radio session exhausted: all candidate weights are zero".to_string());
let chosen = candidates
.first()
.cloned()
.ok_or_else(|| "Radio selection failed: no candidates".to_string())?;
self.db
.mark_played(session_id, session.selection_count, &chosen)?;
return Ok(chosen);
}
let r = Self::splitmix64(session.rng_seed ^ (next_index as u64));