From d5b0eb61a42d84cd98b6e799565661f0973a0790 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 21 Nov 2026 10:41:10 -0800 Subject: [PATCH 1/2] fix(moq-net): a live join answered with no Largest sends no from-oldest update A relay's moq-transport publisher subscribes an empty copy as a live join, then asks it from group 0 once it finds no group. The upstream SUBSCRIBE already went out as that live join, and since #9265 the copy's subscriber read the from-oldest start as a widening and sent a REQUEST_UPDATE. A publisher without REQUEST_UPDATE support, such as cloudflare/moq-rs, ends the subscription over it. A live join answered with no Largest began at group 0, so `joined` records group 0 and a start at the joined group keeps the live join. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/ietf/subscriber.rs | 69 +++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 9 deletions(-) diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index 174e57c405a..10cfa2a62c9 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -3886,8 +3886,8 @@ struct Established { priority: i8, sent_bounds: WireBounds, wanted_bounds: WireBounds, - /// The group a live join started at: the Largest its SUBSCRIBE_OK named. `None` for a - /// SUBSCRIBE with a start, or one answered with no Largest. + /// The group a live join started at: the Largest its SUBSCRIBE_OK named, or group 0 when + /// it named none, since the publisher had nothing yet. `None` for a SUBSCRIBE with a start. joined: Option, /// REQUEST_UPDATEs sent and not yet answered. unanswered: u64, @@ -4644,9 +4644,7 @@ impl SubscribeOnce { false => None, }; - let joined = largest - .filter(|_| plan.live && plan.start.is_none()) - .map(|largest| largest.group); + let joined = (plan.live && plan.start.is_none()).then(|| largest.map_or(0, |largest| largest.group)); let sent_bounds = ( plan.start, plan.subscription.as_ref().and_then(|subscription| subscription.end()), @@ -14472,10 +14470,14 @@ type WireBounds = (Option, Option); /// The single wire span covering `subscription`'s ranges: mixed starts and ranges without one /// from group zero. A range with no start and a stated Min Age is the live join, which started /// at the group it `joined`: one that holds every start keeps the live join, so a reader -/// adding a range the join already delivers widens nothing. +/// adding a range the join already delivers widens nothing. So does a start at that group, as +/// a from-oldest start on a join that began at group 0. fn wire_bounds(subscription: &track::Subscription, joined: Option) -> WireBounds { let end = subscription.end(); - if let Some(start) = subscription.start() { + let start = subscription.start(); + if let Some(start) = start + && joined != Some(start) + { return (Some(start), end); } let first = subscription @@ -14484,8 +14486,9 @@ fn wire_bounds(subscription: &track::Subscription, joined: Option) -> WireB .filter(|range| !range.is_empty()) .filter_map(|range| range.start) .min(); - let covered = - subscription.delay.min.is_some() && joined.is_some_and(|joined| first.is_none_or(|first| first >= joined)); + // A range with no start and no Min Age reaches back to the oldest group, which no join holds. + let live = subscription.delay.min.is_some() || start.is_some(); + let covered = live && joined.is_some_and(|joined| first.is_none_or(|first| first >= joined)); let start = match covered { true => None, false => first.map(|_| 0), @@ -14635,6 +14638,27 @@ mod filter_tests { assert_eq!(wire_bounds(&live(None, 19), joined), (Some(0), None)); } + /// A start at the group the live join began keeps the join: a from-oldest reader on a join + /// answered with no Largest, which began at group 0, sends no update. Any other start, or + /// that start beside a range reaching back to the oldest group, still bounds the span. + #[test] + fn a_start_at_the_joined_group_keeps_the_live_join() { + let from = |start: u64| track::Subscription::default().with_start(Some(start)); + assert_eq!(wire_bounds(&from(0), Some(0)), (None, None)); + assert_eq!(wire_bounds(&from(10), Some(10)), (None, None)); + assert_eq!(wire_bounds(&from(0), Some(10)), (Some(0), None)); + assert_eq!(wire_bounds(&from(12), Some(10)), (Some(12), None)); + assert_eq!(wire_bounds(&from(0), None), (Some(0), None)); + let oldest = track::Subscription::default().with_ranges([ + track::Range::default(), + track::Range { + start: Some(0), + end: None, + }, + ]); + assert_eq!(wire_bounds(&oldest, Some(0)), (Some(0), None)); + } + /// The live join is the draft's own: the subscription starts after the live edge and a /// `StartGroup=1` fill covers the current group's head, so every object arrives exactly /// once and the group still starts at a decodable point. @@ -19543,6 +19567,33 @@ mod new_group_tests { relay.serving.abort(); } + /// A live join answered with no Largest began at group 0, so a reader that then asks from + /// the oldest group, as a moq-transport SUBSCRIBE on an empty copy does once it finds no + /// group, sends no REQUEST_UPDATE. A publisher without REQUEST_UPDATE support would end + /// the subscription over it. + #[kio::test] + async fn a_from_oldest_reader_on_an_empty_join_sends_no_update() { + let (mut relay, mut first) = relay().await; + let (mut stream, _) = relay.accept().await; + stream.writer.varint(ietf::SubscribeOk::ID).await.unwrap(); + stream + .writer + .encode(&ietf::SubscribeOk { + track_alias: 7, + largest: None, + properties: Default::default(), + }) + .await + .unwrap(); + settle().await; + + first + .update(track::Subscription::default().with_start(Some(0))) + .unwrap(); + quiet(&mut stream).await; + relay.serving.abort(); + } + /// An identified fill keeps ownership until its head is handed off. A fill with no /// header can instead be superseded, since a reset may have discarded that header. #[kio::test] From 11b33280635bd0a86e005bbcf09fcb4a0329f8e8 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 22 Nov 2026 17:30:06 -0800 Subject: [PATCH 2/2] test(net): an oldest range on a join at group 0 needs a reaching budget Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/ietf/subscriber.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index 13bc4089cf2..05fe4037b0a 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -14710,7 +14710,9 @@ mod filter_tests { assert_eq!(wire_bounds(&from(12), Some(10)), (Some(12), None)); assert_eq!(wire_bounds(&from(0), None), (Some(0), None)); // A range from the oldest group reaches no further back than a join that began at group 0. - let oldest = track::Subscription::default().with_ranges([track::Range::from(track::Start::Oldest)]); + let oldest = track::Subscription::default() + .with_ranges([track::Range::from(track::Start::Oldest)]) + .with_delay(track::Delay::default().with_max(None)); assert_eq!(wire_bounds(&oldest, Some(0)), (None, None)); assert_eq!(wire_bounds(&oldest, Some(10)), (Some(0), None)); }