From 067137536ae7bf23251d6f30cdb4e938a2cdb720 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 19 Nov 2026 00:56:50 -0800 Subject: [PATCH 1/2] chore(quest): claim quest/m1/lite07-idle-oldest.md Quest-Claim: dbe145a0a972ba1f From 309f7b520b4f3de4ce4b12a6bba9584e30c93550 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 19 Nov 2026 01:29:19 -0800 Subject: [PATCH 2/2] fix(moq-net): a live viewer's fresh lite-07 copy asks only for the live edge An idle copy that cached no group rewrote the subscriber's ranges with no start, which since #8638 means Oldest, so a Range::live() viewer asked its upstream for every group the max age allows. Only a copy with a cached group rewrites the start now. Co-Authored-By: Claude Opus 5.5 --- quest/m1/lite07-idle-oldest.md | 25 ---------- rs/moq-net/src/lite/subscriber.rs | 14 +++--- .../tests/integration/subscribe_ranges.rs | 48 +++++++++++++++++++ 3 files changed, 55 insertions(+), 32 deletions(-) delete mode 100644 quest/m1/lite07-idle-oldest.md diff --git a/quest/m1/lite07-idle-oldest.md b/quest/m1/lite07-idle-oldest.md deleted file mode 100644 index fd1940f900f..00000000000 --- a/quest/m1/lite07-idle-oldest.md +++ /dev/null @@ -1,25 +0,0 @@ -# [S] A live viewer's fresh lite-07 copy asks only for the live edge - -## Goal - -A relay or client opening a lite-07 subscription for a viewer that asks only -for the live edge (`Range::live()`) asks its upstream for the live edge, not -for every group from the oldest the max age allows. - -## Plan - -Seen while testing the [range union fix](https://github.com/moq-dev/moq/pull/9045); -reproduce first. `TrackServe::wire_request` in `rs/moq-net/src/lite/subscriber.rs` -treats a copy whose demand is only open live or oldest ranges as idle and asks -from `producer.idle_newest()`. For a copy that never cached a group that is -`None`, and `Subscription::with_start(None)` turns the ranges into -`Range::span(None, None)`, which since -[moq-dev/moq#8638](https://github.com/moq-dev/moq/pull/8638) starts at -`Anchor::Oldest`. A publisher then saw `Oldest..` for a viewer through a relay -that asked for `Range::live()` alone, on a track whose max age is unlimited: -every group it holds. - -Recommended: only an idle copy that cached a group rewrites the start; one -with none keeps the subscriber's own ranges. Test: a `Range::live()` viewer -through a lite-07 relay, asserting the publisher's demand stays `Relative(0)..`. -Check the JS subscriber for the same rewrite. diff --git a/rs/moq-net/src/lite/subscriber.rs b/rs/moq-net/src/lite/subscriber.rs index 2077eb05beb..4abb3ca4f1f 100644 --- a/rs/moq-net/src/lite/subscriber.rs +++ b/rs/moq-net/src/lite/subscriber.rs @@ -10698,7 +10698,7 @@ impl TrackServe { (None, Sub::Active(active)) if !fills.is_empty() => active.demand.clone(), (pref, _) => pref, }; - let request = self.wire_request(pref, opening, producer.idle_newest()); + let request = self.wire_request(pref, producer.idle_newest().filter(|_| opening)); // The demand's ranges and the fills' groups, widened together until they fit. let (request, groups) = match ranged { true => { @@ -10865,12 +10865,11 @@ impl TrackServe { /// What a SUBSCRIBE carries for the demand `pref`: the subscription and its ranges, or /// `None` when it asks for nothing. /// - /// `opening` when this opens a subscription for a copy whose newest cached group, while - /// idle, is `newest`. + /// `newest` when this opens a subscription for a copy whose newest cached group, while + /// idle, is that group. fn wire_request( &self, pref: Option, - opening: bool, newest: Option, ) -> Option<(Subscription, Vec)> { // An empty half-open range asks for nothing, and the wire cannot say that: its @@ -10890,14 +10889,15 @@ impl TrackServe { // the subscriber has no start of its own: a quiet track (a catalog) sends // that group again, which says the cache is current. A lite-07 list keeps // any range of its own, so only one asking just for the live or oldest group - // counts. + // counts. A copy that cached nothing keeps the subscriber's ranges: no start + // would widen a live viewer's ask to every group from the oldest. let idle = subscription.start().is_none() && (!ranged || subscription .ranges .iter() .all(|range| range.end.is_none() && matches!(range.start, Anchor::Oldest | Anchor::Relative(0)))); - if opening && idle { + if let Some(newest) = newest.filter(|_| idle) { subscription = subscription.with_start(newest); } wire_ranges(&subscription).map(|ranges| (subscription, ranges)) @@ -10907,7 +10907,7 @@ impl TrackServe { /// registered with its copy pending. `None` when it asks for nothing. fn pipeline(&self, pref: Subscription) -> Result, Error> { // A copy not accepted yet caches nothing. - let Some((subscription, ranges)) = self.wire_request(Some(pref.clone()), true, None) else { + let Some((subscription, ranges)) = self.wire_request(Some(pref.clone()), None) else { return Ok(None); }; let ranges = match self.subscriber.version.has_ranges() { diff --git a/rs/moq-net/tests/integration/subscribe_ranges.rs b/rs/moq-net/tests/integration/subscribe_ranges.rs index 66523b69ed3..ef62cda2e4f 100644 --- a/rs/moq-net/tests/integration/subscribe_ranges.rs +++ b/rs/moq-net/tests/integration/subscribe_ranges.rs @@ -180,6 +180,54 @@ async fn sparse_ranges_reach_the_publisher_on_lite07() { } } +/// A live viewer's fresh lite-07 copy, cached nothing yet, asks its upstream for the live +/// edge, not every group from the oldest, directly or through a relay. +#[kio::test] +async fn a_live_viewer_asks_lite07_upstream_for_the_live_edge() { + let version: Version = "moq-lite-07-wip".parse().unwrap(); + for relay in [false, true] { + let publisher = produce_origin(1); + let broadcast = publisher + .route("bcast", moq_net::origin::RouteOptions::hidden()) + .unwrap(); + let track = broadcast.broadcast().create_track("quiet", timed()).unwrap(); + broadcast.announce().unwrap(); + + let relay_origin = produce_origin(2); + let subscriber = produce_origin(3); + let mut sessions = Vec::new(); + if relay { + let mut options = MockConnectOptions::new(version); + options.server_publish = Some(publisher.consume()); + options.client_subscribe = Some(relay_origin.clone()); + sessions.push(connect_mock(options).await); + } + let mut options = MockConnectOptions::new(version); + options.server_publish = Some(match relay { + true => relay_origin.consume(), + false => publisher.consume(), + }); + options.client_subscribe = Some(subscriber.clone()); + sessions.push(connect_mock(options).await); + + let consumer = subscriber.consume(); + let remote = kio::clock::timeout(TIMEOUT, consumer.follow("bcast", None).unwrap().available()) + .await + .expect("resolve timeout") + .expect("broadcast resolves") + .unwrap(); + + let _live = subscribe(&remote, Subscription::default().with_ranges([Range::live()])).await; + kio::clock::timeout(TIMEOUT, crate::support::wanted(track.demand())) + .await + .expect("no subscriber appeared") + .unwrap(); + let asked = track.subscription().expect("the publisher holds the demand").ranges; + assert_eq!(asked, [Range::live()], "relay={relay}"); + drop((track, sessions, relay_origin, subscriber, broadcast, publisher)); + } +} + /// A subscriber from group 4 merged with a live one doesn't floor the shared subscription /// at 4: the live one still gets group 3. #[kio::test]