diff --git a/quest/m1/cut-audit/README.md b/quest/m1/cut-audit/README.md index a604c998485..dca7f048b3e 100644 --- a/quest/m1/cut-audit/README.md +++ b/quest/m1/cut-audit/README.md @@ -1,4 +1,4 @@ -# Pre-cut audit findings +# [S] Pre-cut audit findings ## Goal @@ -53,10 +53,6 @@ drafts 14-17 removal (since landed), and [buffered playback](/quest/m1/buffered-ascending.md). The audit recommends leaving JS-only redesigns of `js/net` to [rs2ts](/quest/m2/rs2ts-js.md). -## Required - -- [Each export-clock rule kept by the jitter audit has its own test](/quest/m1/cut-audit/jitter-rule-tests.md) - `stale`, `unheard_lag`, and the horizon shift in `rs/moq-mux/src/jitter.rs` each have a test that fails when that rule alone is removed - ## Related - [Announce interest streams share one route table](/quest/m2/announce-interest-memory.md) - the audit's inherited announce memory finding diff --git a/quest/m1/cut-audit/jitter-rule-tests.md b/quest/m1/cut-audit/jitter-rule-tests.md deleted file mode 100644 index 51c1f12b026..00000000000 --- a/quest/m1/cut-audit/jitter-rule-tests.md +++ /dev/null @@ -1,38 +0,0 @@ -# [S] Each export-clock rule kept by the jitter audit has its own test - -## Goal - -`stale`, `unheard_lag`, and the horizon shift in `rs/moq-mux/src/jitter.rs` -each have a test that fails when that rule alone is removed. Today the -`moq-mux` suite passes with any one of them knocked out. No rule's behavior -changes. - -## Plan - -Decided 2026-10-31 (user, /quest-plan of the follow-ups from the 2026-10-31 -/quest-complete run), from -[moq-dev/moq#7412](https://github.com/moq-dev/moq/pull/7412). - -Milestone: ✅ m1. Not chosen: m2. - -[moq-dev/moq#7412](https://github.com/moq-dev/moq/pull/7412)'s knockout measurement kept these rules because each guards behavior -admission does not provide, but none has a test of its own: - -- `stale` (`judge`, `queue` at `jitter.rs:992`, `:1025`, at be39188000): - drops a frame that arrived before its deadline but was read after it. - Test that such a frame never goes out past its deadline. -- `unheard_lag` (`jitter.rs:955`, `:1291`) and the horizon shift - (`jitter.rs:970`, `:1041`): both keep a new generation behind a track sent - later than the anchor, and in the tests each covers for the other - (removing both fails `a_track_crossing_after_the_new_clock_keeps_its_lead` - and one more). Find an input where only one applies for each, such as a - track never heard during acquisition versus one heard but queued past the - horizon. - -Rerun the knockouts the way [moq-dev/moq#7412](https://github.com/moq-dev/moq/pull/7412) did (one lib run per rule removed) and -record in the PR which new test fails for each. If a rule turns out to have -no case only it covers, stop and report rather than delete it. - -[moq-dev/moq#7412](https://github.com/moq-dev/moq/pull/7412) (merged) removed the `leapt` arm from the same file. - -Public API: none (`jitter` is crate-private). Wire: none. diff --git a/rs/moq-mux/src/jitter.rs b/rs/moq-mux/src/jitter.rs index df593cc6f26..00209a8c89d 100644 --- a/rs/moq-mux/src/jitter.rs +++ b/rs/moq-mux/src/jitter.rs @@ -2342,6 +2342,81 @@ mod tests { assert_eq!(buffer.dropped(), 0); } + /// Once the old horizon has drained, a restart still preserves the lead of a track it + /// has not heard yet, so that track keeps the delay when it crosses later. + #[tokio::test(start_paused = true)] + async fn a_restart_without_an_old_tail_keeps_an_unheard_tracks_delay() { + let start = kio::clock::now(); + let mut buffer = Buffer::new(DELAY); + buffer.expect([1, 2]); + buffer.push(1, arrival(start, 300, "v300")).unwrap(); + buffer.push(2, arrival(start, 0, "a0")).unwrap(); + tokio::time::advance(DELAY).await; + assert_eq!(released(&mut buffer), [("a0", 0)]); + tokio::time::advance(Duration::from_millis(300)).await; + assert_eq!(released(&mut buffer), [("v300", 0)]); + assert!(buffer.is_empty()); + + let resume = start + Duration::from_secs(1); + tokio::time::advance(resume - kio::clock::now()).await; + buffer.push(1, after(1, arrival(resume, 5_000, "v5000"))).unwrap(); + tokio::time::advance(DELAY).await; + assert!(due(&mut buffer).is_empty(), "video must wait for the later-sent audio"); + tokio::time::advance(Duration::from_millis(200)).await; + let now = kio::clock::now(); + assert_eq!( + buffer.push(2, after(1, arrival(now, 5_000, "a5000"))).unwrap(), + Push::Queued + ); + assert!(due(&mut buffer).is_empty()); + tokio::time::advance(DELAY - Duration::from_nanos(1)).await; + assert!(due(&mut buffer).is_empty()); + tokio::time::advance(Duration::from_nanos(1)).await; + assert_eq!(released(&mut buffer), [("v5000", 1), ("a5000", 1)]); + assert_eq!((buffer.dropped(), buffer.trimmed()), (0, 0)); + } + + /// Hearing every expected track removes the unheard lag, but the new clock must still + /// follow deadlines already queued on the old generation, including its future tail. + #[tokio::test(start_paused = true)] + async fn a_restart_hearing_every_track_keeps_deadlines_after_the_old_tail() { + let start = kio::clock::now(); + let mut buffer = Buffer::new(DELAY); + buffer.expect([1, 2]); + buffer.push(1, arrival(start, 300, "v300")).unwrap(); + buffer.push(2, arrival(start, 0, "a0")).unwrap(); + tokio::time::advance(DELAY).await; + assert_eq!(released(&mut buffer), [("a0", 0)]); + let now = kio::clock::now(); + buffer.push(1, arrival(now, 400, "v400")).unwrap(); + assert!( + !buffer.full(&1, &kio::Waiter::noop()), + "the video's lead admits the restart" + ); + for (track, item) in [(1, "v5000"), (2, "a5000")] { + buffer.push(track, after(1, arrival(now, 5_000, item))).unwrap(); + } + tokio::time::advance(DELAY).await; + assert!(due(&mut buffer).is_empty()); + let tail = start + Duration::from_millis(500); + assert_eq!( + buffer.at(1, ms(5_000)), + Some(tail), + "the export clock follows the queued tail" + ); + tokio::time::advance(Duration::from_millis(200)).await; + assert_eq!(released(&mut buffer), [("v300", 0)]); + tokio::time::advance(DELAY - Duration::from_nanos(1)).await; + assert!(due(&mut buffer).is_empty()); + tokio::time::advance(Duration::from_nanos(1)).await; + let mut out = Vec::new(); + while let Poll::Ready(ready) = buffer.poll_next(&kio::Waiter::noop()) { + out.push((ready.item, ready.generation, ready.deadline)); + } + assert_eq!(out, [("v400", 0, tail), ("v5000", 1, tail), ("a5000", 1, tail)]); + assert_eq!((buffer.dropped(), buffer.trimmed()), (0, 0)); + } + /// Two tracks every 100 ms of decode time for `steps` frames, the audio sent more than two /// delays behind the video and running `tail` frames past it, then a restart onto a /// timeline 15 seconds on: each released frame's generation, and how many were dropped. @@ -3132,6 +3207,42 @@ mod tests { assert_eq!(buffer.trimmed(), 6); } + /// Arrival before the deadline does not rescue an acquisition frame read after it. + /// Reading exactly at the deadline still keeps it. + #[tokio::test(start_paused = true)] + async fn acquisition_drops_timely_arrivals_only_when_read_past_their_deadline() { + for decode in [99, 100, 101] { + let start = kio::clock::now(); + let mut buffer = Buffer::new(DELAY); + tokio::time::advance(DELAY).await; + let read = kio::clock::now(); + buffer + .push( + 1, + Arrival { + read, + ..arrival(start, decode, "cached") + }, + ) + .unwrap(); + // This freshest frame puts the cached frame's deadline at start + decode ms. + buffer.push(1, arrival(read, 200, "fresh")).unwrap(); + tokio::time::advance(DELAY).await; + let expected = if decode < 100 { + vec!["fresh"] + } else { + vec!["cached", "fresh"] + }; + assert_eq!( + due(&mut buffer), + expected, + "cached deadline at {decode} ms, read at 100 ms" + ); + assert_eq!((buffer.dropped(), buffer.trimmed()), (0, u64::from(decode < 100))); + assert!(buffer.is_empty()); + } + } + /// A start group its source cuts short before anything of it went out still goes out, from /// its sync frame, ahead of the hole: a path narrower than the media cuts every group, so a /// track waiting for a whole one might never start. Nothing is trimmed.