open-standards/wai/http-conformance/falsify/bandwidth-average-floor.patch
Transaction Science 18da795017 wai: falsification of the playlist side (W3-4, W3-5)
Eighteen patches, each breaking one function of the playlist side and naming the
cases that must fail: adjacency (another program date-time, a larger discontinuity
sequence), rendering (parts after EXTINF, layer lines after the URI), bandwidth
rounding, duration rounding, a delta update read, the session-data line before
#EXTM3U, the render digest left out of the signed payload, a receipt under another
name, an unchecked parent, the open segment's parts not read for cids, the integer
log without interpolation, a waiting utility rule, a look-ahead blind to stalls, an
unlabelled figure taken as zero, per-layer bytes as a depth's, and size-blind entry
order. falsify/run.sh builds with http and video_manifest and runs the eleven new
Python mutations. A depth case at 150 kb/s sits between layer boundaries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-06 06:31:05 -04:00

15 lines
829 B
Diff

# must fail: multivariant_playlists_o9_wai_m3u8
# AVERAGE-BANDWIDTH rounded down (hls::bandwidths)
diff --git a/wai/wai-rs/src/http_binding/hls.rs b/wai/wai-rs/src/http_binding/hls.rs
index 2623644b..604ff92b 100644
--- a/wai/wai-rs/src/http_binding/hls.rs
+++ b/wai/wai-rs/src/http_binding/hls.rs
@@ -608,7 +608,7 @@ pub fn bandwidths(objects: &[(u64, u64)]) -> Option<(u64, u64)> {
let rate = |n: u128, d: u128| u64::try_from((8000 * n).div_ceil(d)).unwrap_or(u64::MAX);
let peak = objects.iter().map(|&(n, d)| rate(u128::from(n), u128::from(d))).max()?;
let (sn, sd) = objects.iter().fold((0u128, 0u128), |(a, b), &(n, d)| (a + u128::from(n), b + u128::from(d)));
- Some((peak, rate(sn, sd)))
+ Some((peak, u64::try_from(8000 * sn / sd).unwrap_or(u64::MAX)))
}
/// One variant of `wai.m3u8` (§11.1).