From 6b73c1633a516e73a5de697802e7f54b5c7f484b Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 02:50:03 -0800 Subject: [PATCH 1/5] chore(quest): claim quest/m1/cut-audit/jitter-rule-tests.md Quest-Claim: 7a8bb4bc4745762a From 8f131192d38d95494f76c13f01622670aabe115f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 02:55:39 -0800 Subject: [PATCH 2/5] test(mux): cover each retained jitter clock rule Co-Authored-By: GPT-6.1 Sol --- quest/m1/cut-audit/README.md | 1 - quest/m1/cut-audit/jitter-rule-tests.md | 38 -------- rs/moq-mux/src/jitter.rs | 111 ++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 39 deletions(-) delete mode 100644 quest/m1/cut-audit/jitter-rule-tests.md diff --git a/quest/m1/cut-audit/README.md b/quest/m1/cut-audit/README.md index 7441dd98a4e..38c0fd89001 100644 --- a/quest/m1/cut-audit/README.md +++ b/quest/m1/cut-audit/README.md @@ -53,7 +53,6 @@ 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 - [Text and data sections keep a prototype-named ID](/quest/m1/cut-audit/catalog-proto-ids.md) - text and data entries keep the ID JS's `z.record` drops ## Related 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 207655ec82d..73d87df5298 100644 --- a/rs/moq-mux/src/jitter.rs +++ b/rs/moq-mux/src/jitter.rs @@ -2263,6 +2263,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. @@ -3053,6 +3128,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. From 6dbea14ee8beb64ba7e4e18539a83652fa3d6c30 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 02:59:17 -0800 Subject: [PATCH 3/5] quest(mux): record jitter coverage and base CI blocker Co-Authored-By: GPT-6.1 Sol --- quest/m1/cut-audit/README.md | 1 + quest/m1/cut-audit/jitter-rule-tests.md | 57 +++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 quest/m1/cut-audit/jitter-rule-tests.md diff --git a/quest/m1/cut-audit/README.md b/quest/m1/cut-audit/README.md index 38c0fd89001..7441dd98a4e 100644 --- a/quest/m1/cut-audit/README.md +++ b/quest/m1/cut-audit/README.md @@ -53,6 +53,7 @@ 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 - [Text and data sections keep a prototype-named ID](/quest/m1/cut-audit/catalog-proto-ids.md) - text and data entries keep the ID JS's `z.record` drops ## Related diff --git a/quest/m1/cut-audit/jitter-rule-tests.md b/quest/m1/cut-audit/jitter-rule-tests.md new file mode 100644 index 00000000000..f97d9aae335 --- /dev/null +++ b/quest/m1/cut-audit/jitter-rule-tests.md @@ -0,0 +1,57 @@ +# [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. + +The three controlled-time tests are implemented in +[moq-dev/moq#7722](https://github.com/moq-dev/moq/pull/7722). Each individual +knockout fails only its corresponding new test; the other 1,989 lib tests +pass. Production code is unchanged. Full lib tests pass with all rules +restored (1,990 passed, 3 skipped). + +Remaining: complete the full local CI gate after the unrelated base-branch +C-binding cancellation failure is resolved, then remove this quest and its +reference. `just ci origin/main` stopped at +`moq-c test::raw_track_subscription_options_and_update`, `test.rs:2283`: +cancelling after range completion returned `TRACK_NOT_FOUND` (-27), expected +0. The same failure reproduced at `origin/main` commit +`801fd9a2f2f5c88371fa833d805620d97d372465` on iteration 4 of a nextest stress +run. Repository lint checks passed. No C-binding fix belongs to this quest. + +## Waiting + +- moq-dev/moq: resolve the base-branch C-binding cancellation/completion race, then rerun `just ci origin/main` for the test-only PR. Recommend planning that fix separately rather than expanding this quest; the three jitter rules already have independent coverage. From 19383089a060f16a687f93e61fe9695851a787e7 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 03:02:20 -0800 Subject: [PATCH 4/5] quest(mux): finish the independently covered jitter rules Co-Authored-By: GPT-6.1 Sol --- quest/m1/cut-audit/README.md | 1 - quest/m1/cut-audit/jitter-rule-tests.md | 57 ------------------------- 2 files changed, 58 deletions(-) delete mode 100644 quest/m1/cut-audit/jitter-rule-tests.md diff --git a/quest/m1/cut-audit/README.md b/quest/m1/cut-audit/README.md index 7441dd98a4e..38c0fd89001 100644 --- a/quest/m1/cut-audit/README.md +++ b/quest/m1/cut-audit/README.md @@ -53,7 +53,6 @@ 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 - [Text and data sections keep a prototype-named ID](/quest/m1/cut-audit/catalog-proto-ids.md) - text and data entries keep the ID JS's `z.record` drops ## Related 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 f97d9aae335..00000000000 --- a/quest/m1/cut-audit/jitter-rule-tests.md +++ /dev/null @@ -1,57 +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. - -The three controlled-time tests are implemented in -[moq-dev/moq#7722](https://github.com/moq-dev/moq/pull/7722). Each individual -knockout fails only its corresponding new test; the other 1,989 lib tests -pass. Production code is unchanged. Full lib tests pass with all rules -restored (1,990 passed, 3 skipped). - -Remaining: complete the full local CI gate after the unrelated base-branch -C-binding cancellation failure is resolved, then remove this quest and its -reference. `just ci origin/main` stopped at -`moq-c test::raw_track_subscription_options_and_update`, `test.rs:2283`: -cancelling after range completion returned `TRACK_NOT_FOUND` (-27), expected -0. The same failure reproduced at `origin/main` commit -`801fd9a2f2f5c88371fa833d805620d97d372465` on iteration 4 of a nextest stress -run. Repository lint checks passed. No C-binding fix belongs to this quest. - -## Waiting - -- moq-dev/moq: resolve the base-branch C-binding cancellation/completion race, then rerun `just ci origin/main` for the test-only PR. Recommend planning that fix separately rather than expanding this quest; the three jitter rules already have independent coverage. From 8a6ae9cca18d0b2f4e97d82d5082af4ee8cbba5c Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 4 Nov 2026 21:54:52 -0800 Subject: [PATCH 5/5] quest: size the cut-audit epic now that its last child is done --- quest/m1/cut-audit/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quest/m1/cut-audit/README.md b/quest/m1/cut-audit/README.md index 632135d3046..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