From c40ac0744bb299de9936df556e91843ac0034c53 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 29 Oct 2026 22:53:19 -0700 Subject: [PATCH 1/5] chore(quest): claim quest/m1/subscribe-ranges/lite.md Quest-Claim: 42e0d0d161cfca46 From 431e0e233bb7a42ca5808c41e989375b94546b7a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 29 Oct 2026 23:29:41 -0700 Subject: [PATCH 2/5] feat(net): a cold moq-transport copy resolves relative anchors from its live join A moq-transport copy that cannot settle a relative anchor from its cache joins live instead of refusing it, and resolves the anchor once the Largest Object or a newer group names the live edge. The resolved bounds go upstream as an absolute update. Time anchors the cache cannot settle stay refused. Rewrites quest/m1/subscribe-ranges/lite.md to the remaining range fill. Co-Authored-By: Claude Opus 5.5 --- doc/concept/moq-lite.md | 5 +- quest/m1/lite07-finalize.md | 2 +- quest/m1/subscribe-ranges/README.md | 4 +- quest/m1/subscribe-ranges/lite.md | 22 +------- rs/moq-net/src/ietf/subscriber.rs | 53 +++++++++++++++++-- rs/moq-net/src/model/subscription.rs | 5 +- rs/moq-net/src/model/track.rs | 10 ++-- rs/moq-net/tests/integration/range_anchors.rs | 14 +++-- 8 files changed, 77 insertions(+), 38 deletions(-) diff --git a/doc/concept/moq-lite.md b/doc/concept/moq-lite.md index dcdddcb45db..16aa831bbfc 100644 --- a/doc/concept/moq-lite.md +++ b/doc/concept/moq-lite.md @@ -300,8 +300,9 @@ moq-lite-07 carries range by range and older wire versions as the single span covering them. A relative or time anchor resolves on the hop that publishes the track, and over moq-lite-07, which carries a relative or time start upstream and reports the live edge and media time, so a copy resolves the ends itself. A Rust -moq-transport copy accepts anchors its cache can already -resolve and sends group bounds upstream; it refuses an unknown time end. Older +moq-transport copy resolves a relative anchor from the Largest Object its live join +reports, accepts time anchors its cache can already resolve, and sends group bounds +upstream; it refuses any other time anchor. Older moq-lite versions accept absolute anchors but refuse time anchors and relative anchors other than the live and default starts. An untimed track refuses a time anchor. At the live edge, a time end diff --git a/quest/m1/lite07-finalize.md b/quest/m1/lite07-finalize.md index 0ce44d7c2ef..73feed0da6b 100644 --- a/quest/m1/lite07-finalize.md +++ b/quest/m1/lite07-finalize.md @@ -103,7 +103,7 @@ timestamp bound in [#6168](https://github.com/moq-dev/moq/pull/6168). - [Routes and announces](/quest/m1/cluster-routing/routes.md) - lite-07 carries the route layer: ROUTE per origin node and path-less ANNOUNCE, with the hop list gone - [Drop set](/quest/m1/drop-set.md) - lite-07's SUBSCRIBE_DROP carries `Max Age`, so a widening re-offers groups reported dropped -- [Lite-07 ranges](/quest/m1/subscribe-ranges/lite.md) - a relay fills a lite-07 upstream through the subscription, and moq-transport carries the anchors it can +- [Lite-07 ranges](/quest/m1/subscribe-ranges/lite.md) - a relay fills a lite-07 upstream through the subscription - [JS ranges](/quest/m1/subscribe-ranges/js.md) - JS speaks lite-07 ranges - [Remove FETCH from lite-07](/quest/m1/subscribe-ranges/lite07-fetch.md) - lite FETCH is gone from lite-07, in Rust and JS - [Lite-07 by start](/quest/m1/time-addressing/lite07.md) - lite-07 carries group starts, previous-start links, GROUP_END, and time bounds instead of sequence numbers diff --git a/quest/m1/subscribe-ranges/README.md b/quest/m1/subscribe-ranges/README.md index 7d772940a18..cb5bf2c16d6 100644 --- a/quest/m1/subscribe-ranges/README.md +++ b/quest/m1/subscribe-ranges/README.md @@ -65,8 +65,8 @@ relay bounds a sparse FETCH only if the model can request ranges: still caps every range, so `Absolute(0)..` means everything not stale. A relay that cannot resolve a relative end locally forwards it upstream as relative over lite-07; a moq-transport bridge resolves it to an absolute - Group ID first ([Lite-07 ranges](/quest/m1/subscribe-ranges/lite.md), - decided 2026-10-27). + Group ID first, from its cache or the Largest Object of a live join + (decided 2026-10-27). - **Time ends** (maintainer, 2026-10-17, for DVR seek in the [archive line](/quest/m1/archive/README.md)). A range end may also be `Time(pts)`, in the track's timescale. Whoever holds the track resolves it: diff --git a/quest/m1/subscribe-ranges/lite.md b/quest/m1/subscribe-ranges/lite.md index 6542adca8b3..8ed65d2d990 100644 --- a/quest/m1/subscribe-ranges/lite.md +++ b/quest/m1/subscribe-ranges/lite.md @@ -2,8 +2,7 @@ ## Goal -A relay fills a lite-07 upstream by subscribing to the missing ranges. Older -wires and moq-transport carry the anchors they can, and refuse only the rest. FETCH stays on lite-07 until +A relay fills a lite-07 upstream by subscribing to the missing ranges. FETCH stays on lite-07 until [Remove FETCH from lite-07](/quest/m1/subscribe-ranges/lite07-fetch.md) removes it from both implementations. @@ -51,25 +50,6 @@ resolve no SUBSCRIBE_START, so a FIN overtaking them leaves the receiver no owed range to wait on. Datagram fills need the receiver told what is owed first. -### moq-transport anchors - -Decided 2026-10-27 (maintainer): a bridge never sends a relative anchor to -moq-transport. It resolves `Relative(n)` to an absolute Group ID, from its -cache or the live edge, before sending, replacing the planned mapping of -`Relative(n)..` onto draft-22's `Filter::Relative(n + 1)` and draft 18's -relative joining FETCH. Reason: both count back by Group ID arithmetic, which -breaks once [time addressing](/quest/m1/time-addressing/model.md) makes legacy -Group IDs sparse start ticks. A range with a bounded end -resolves both bounds against the Largest Object and goes upstream as an -absolute range. Live keeps today's join (`ietf::subscriber::subscribe_join`). A copy already -resolves what its cache settles (`ResolvedRanges`, from -[moq-dev/moq#6815](https://github.com/moq-dev/moq/pull/6815)) and refuses the -rest (`anchored_cached`); what remains is a cold copy resolving `Relative(n)` -from the Largest Object of a live join instead of refusing it. -Each mapping that makes a wire carry an anchor lifts that wire's -`Unsupported` refusal for it, and extends the per-wire table in -`rs/moq-net/tests/integration/range_anchors.rs`. - Update `drafts/draft-lcurley-moq-lite.md` with each wire change here. Run `just drafts check` and `just test interop --all`. diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index efd07df5355..5da41d0db14 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -2947,8 +2947,14 @@ impl Subscriber { None => Ok(subscription), }) .transpose(); + // A relative anchor the copy cannot settle yet counts back from the Largest Object, so + // the live join that names it goes first and the answer resolves the anchor. No Group ID + // arithmetic spells it upstream. A time anchor names no group the answer settles. + let deferred = matches!(subscription, Err(Error::Unsupported)) + && target.subscription().is_some_and(|subscription| !has_time(&subscription)); let subscription = match subscription { Ok(subscription) => subscription, + Err(_) if deferred => None, Err(err) => { target.fail(err); return None; @@ -3494,6 +3500,13 @@ impl Subscriber { let mut priority = priority; let mut sent_bounds = (start, subscription.as_ref().and_then(|subscription| subscription.end())); let mut wanted_bounds = Ok(sent_bounds); + // A deferred relative anchor, until the copy learns the live edge it counts back from. + // The bounds it then resolves to go upstream as an update, absolute like any other. + let mut unsettled = match deferred { + true => track.subscription(), + false => None, + }; + let mut edge = track.consume(); // REQUEST_UPDATEs sent and not yet answered. let unanswered = AtomicU64::new(0); @@ -3565,16 +3578,30 @@ impl Subscriber { subscribed = subscription .as_ref() .is_some_and(|subscription| !subscription.ranges.is_empty()); + unsettled = None; if let Some(subscription) = subscription { priority = subscription.priority; - wanted_bounds = resolved - .resolve(&track, &subscription) - .map(|subscription| wire_bounds(&subscription)); + match settle_bounds(&mut resolved, &track, &subscription) { + Ok(Some(bounds)) => wanted_bounds = Ok(bounds), + Ok(None) => unsettled = Some(subscription.clone()), + Err(err) => wanted_bounds = Err(err), + } if max_age_supported { wanted_max_age = Some(super::max_age::millis(subscription.budget())); } } } + if let Some(subscription) = &unsettled { + while let Poll::Ready(Some(_)) = edge.poll_largest(waiter) {} + match settle_bounds(&mut resolved, &track, subscription) { + Ok(Some(bounds)) => { + wanted_bounds = Ok(bounds); + unsettled = None; + } + Ok(None) => {} + Err(err) => return Poll::Ready(End::Invalid(err)), + } + } loop { match demand.poll_wanted_changed(waiter) { Poll::Ready(Ok(next)) => wanted = next, @@ -12003,6 +12030,26 @@ impl ResolvedRanges { } } +/// The wire bounds `subscription` resolves to, `None` while a relative anchor still waits +/// for the live edge it counts back from. +fn settle_bounds( + resolved: &mut ResolvedRanges, + track: &track::Producer, + subscription: &track::Subscription, +) -> Result, Option)>, Error> { + match resolved.resolve(track, subscription) { + Ok(subscription) => Ok(Some(wire_bounds(&subscription))), + Err(Error::Unsupported) if !has_time(subscription) => Ok(None), + Err(err) => Err(err), + } +} + +fn has_time(subscription: &track::Subscription) -> bool { + subscription.ranges.iter().any(|range| { + matches!(range.start, track::Anchor::Time(_)) || matches!(range.end, Some(track::Anchor::Time(_))) + }) +} + fn needs_resolution(subscription: &track::Subscription) -> bool { subscription.ranges.iter().any(|range| { let start = match range.start { diff --git a/rs/moq-net/src/model/subscription.rs b/rs/moq-net/src/model/subscription.rs index 1fe7d5ebc6e..2edda6dea91 100644 --- a/rs/moq-net/src/model/subscription.rs +++ b/rs/moq-net/src/model/subscription.rs @@ -121,8 +121,9 @@ pub enum Order { /// it answers, never from the groups an ended feed left in its cache. /// /// Over moq-lite-07, a copy resolves them from the reported live edge and media time. -/// A Rust moq-transport copy accepts anchors its cache can already resolve, translating -/// them to group bounds upstream; an unknown time end is refused. Older moq-lite versions +/// A Rust moq-transport copy resolves a relative anchor from the Largest Object its live +/// join reports, and accepts time anchors its cache can already resolve, translating both +/// to group bounds upstream; any other time anchor is refused. Older moq-lite versions /// accept absolute anchors but refuse time anchors and relative anchors other /// than [`Range::live`] and [`Range::oldest`] with [`Error::Unsupported`](crate::Error::Unsupported) /// rather than guess from a partial copy. diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index a60081f0023..3bb169379b6 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -446,7 +446,8 @@ pub(crate) struct TrackState { // Whether a received copy's wire tells it what relative and time anchors resolve // against, so they resolve here as at the publisher. anchored: bool, - // This copy can translate only anchors its cache has already settled. + // This copy can translate only time anchors its cache has already settled. A relative one + // waits for the live edge its wire reports, as on an `anchored` copy. cached_anchors: bool, // Whether readers ask no fills below `start_sequence`: its publisher resolved it from the // budget, but neither this copy's timestamps nor a fill can judge an older group against @@ -3311,7 +3312,8 @@ impl Producer { } } - /// Let readers use only anchors this cache can already translate to group bounds. + /// Let readers use only time anchors this cache can already translate to group bounds. A + /// relative anchor counts back from the live edge the wire reports, once it does. #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn anchored_cached(&self) { if let Ok(mut state) = self.modify() { @@ -6970,9 +6972,9 @@ impl Control { } } -/// A group-only wire refuses an unresolved anchor before changing shared demand. +/// A group-only wire refuses an unresolved time anchor before changing shared demand. fn refuse_cached_anchors(state: &TrackState, subscription: &Subscription) -> Result<()> { - if state.cached_anchors && subscription.ranges.iter().any(|range| !range.is_wire()) { + if state.cached_anchors && subscription.has_time() { let window = Window::new(&subscription.ranges, state.latest_live(), state)?; if !window.is_settled() { return Err(Error::Unsupported); diff --git a/rs/moq-net/tests/integration/range_anchors.rs b/rs/moq-net/tests/integration/range_anchors.rs index 5d09630c418..93903a32b7e 100644 --- a/rs/moq-net/tests/integration/range_anchors.rs +++ b/rs/moq-net/tests/integration/range_anchors.rs @@ -2,8 +2,9 @@ //! A range anchored relative to the latest group or at a presentation time resolves where //! the track is held, and on a copy received over a wire that tells it enough to resolve -//! the anchor the same way. A copy received over any other wire refuses the anchor instead -//! of resolving it against the part of the track it happens to hold. +//! the anchor the same way. A moq-transport copy resolves a relative anchor from the +//! Largest Object its live join reports. A copy received over any other wire refuses the +//! anchor instead of resolving it against the part of the track it happens to hold. use crate::support; @@ -128,8 +129,15 @@ async fn each_wire_refuses_only_the_anchors_it_drops() { Some("moq-lite-03" | "moq-lite-04" | "moq-lite-05" | "moq-lite-06") ); for (range, held) in anchored() { - let result = read(version, range).await; + let mut result = read(version, range).await; let time = matches!(range.start, Anchor::Time(_)) || matches!(range.end, Some(Anchor::Time(_))); + // A moq-transport copy joins live and resolves a relative anchor from the Largest + // Object, so the groups below it arrive as fills, after the live one. + let transport = matches!(version, Some(version) if version.starts_with("moq-transport")); + let carried = carried || (transport && !time); + if transport && let Ok(read) = &mut result { + read.sort_unstable(); + } match (&result, time && !timed, carried) { (Err(Error::TimestampMismatch), true, _) => {} (Err(Error::Unsupported), false, false) => {} From d2837747d55952ec6fe16e3094abc805a54a7bad Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 29 Oct 2026 23:34:21 -0700 Subject: [PATCH 3/5] style: rustfmt Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/ietf/subscriber.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index 5da41d0db14..e84a96a694b 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -2951,7 +2951,9 @@ impl Subscriber { // the live join that names it goes first and the answer resolves the anchor. No Group ID // arithmetic spells it upstream. A time anchor names no group the answer settles. let deferred = matches!(subscription, Err(Error::Unsupported)) - && target.subscription().is_some_and(|subscription| !has_time(&subscription)); + && target + .subscription() + .is_some_and(|subscription| !has_time(&subscription)); let subscription = match subscription { Ok(subscription) => subscription, Err(_) if deferred => None, @@ -12045,9 +12047,10 @@ fn settle_bounds( } fn has_time(subscription: &track::Subscription) -> bool { - subscription.ranges.iter().any(|range| { - matches!(range.start, track::Anchor::Time(_)) || matches!(range.end, Some(track::Anchor::Time(_))) - }) + subscription + .ranges + .iter() + .any(|range| matches!(range.start, track::Anchor::Time(_)) || matches!(range.end, Some(track::Anchor::Time(_)))) } fn needs_resolution(subscription: &track::Subscription) -> bool { From f05cbbdad001841936a7d7472669ea7a5d396c68 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 29 Oct 2026 23:40:42 -0700 Subject: [PATCH 4/5] refactor(net): name the wire bounds type Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/ietf/subscriber.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index e84a96a694b..273824f191e 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -12038,7 +12038,7 @@ fn settle_bounds( resolved: &mut ResolvedRanges, track: &track::Producer, subscription: &track::Subscription, -) -> Result, Option)>, Error> { +) -> Result, Error> { match resolved.resolve(track, subscription) { Ok(subscription) => Ok(Some(wire_bounds(&subscription))), Err(Error::Unsupported) if !has_time(subscription) => Ok(None), @@ -12064,8 +12064,11 @@ fn needs_resolution(subscription: &track::Subscription) -> bool { }) } +/// A subscription's single wire span: its start and exclusive end group, each open when `None`. +type WireBounds = (Option, Option); + /// The single wire span covers mixed absolute/live starts from group zero. -fn wire_bounds(subscription: &track::Subscription) -> (Option, Option) { +fn wire_bounds(subscription: &track::Subscription) -> WireBounds { let start = subscription.start().or_else(|| { subscription .ranges From 809095c150568af26c6a2377c188867ca5f210c5 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 30 Oct 2026 00:49:37 -0700 Subject: [PATCH 5/5] fix(net): count a deferred relative anchor back from the answered Largest A live join's Largest becomes the copy's live edge, and the deferred upstream bounds resolve before the alias admits any data stream, so a newer group landing first cannot move either resolution. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/ietf/subscriber.rs | 29 ++++++++++++++++++++++------ rs/moq-net/src/model/track.rs | 32 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index 273824f191e..b29e606e99c 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -3432,6 +3432,11 @@ impl Subscriber { // the group carries over: its first frame is the edge a reader can count on. if let Some(largest) = largest { track.report_object(largest.group, largest.object); + // A live join's Largest is where its feed is, which a relative anchor counts back + // from even when a newer group lands before the joined one. + if live { + track.report_edge(largest.group); + } } // A live join starts at the publisher's edge; an absolute one where it asked. With // no Largest the join skips nothing, so every group is owed: a lower one's stream @@ -3443,6 +3448,14 @@ impl Subscriber { if let Some(staged) = staged { staged.commit(); } + // Resolved while the answer's Largest is still the live edge: no data stream reaches + // the copy before its alias is bound below. + let settled = match deferred { + true => track + .subscription() + .map(|subscription| (settle_bounds(&mut resolved, &track, &subscription), subscription)), + false => None, + }; let mut fetching: Option = None; { let mut state = self.state.lock(); @@ -3502,12 +3515,16 @@ impl Subscriber { let mut priority = priority; let mut sent_bounds = (start, subscription.as_ref().and_then(|subscription| subscription.end())); let mut wanted_bounds = Ok(sent_bounds); - // A deferred relative anchor, until the copy learns the live edge it counts back from. - // The bounds it then resolves to go upstream as an update, absolute like any other. - let mut unsettled = match deferred { - true => track.subscription(), - false => None, - }; + // A deferred relative anchor, until the copy learns the live edge it counts back from: + // an answer with no Largest leaves it to the first group. The bounds it then resolves + // to go upstream as an update, absolute like any other. + let mut unsettled = None; + match settled { + Some((Ok(Some(bounds)), _)) => wanted_bounds = Ok(bounds), + Some((Ok(None), subscription)) => unsettled = Some(subscription), + Some((Err(err), _)) => wanted_bounds = Err(err), + None => {} + } let mut edge = track.consume(); // REQUEST_UPDATEs sent and not yet answered. let unanswered = AtomicU64::new(0); diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index 3bb169379b6..8b9cd4753a5 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -3380,6 +3380,18 @@ impl Producer { } } + /// The live feed's route answered that it reaches `group`: a relative start counts back + /// from it, rather than from whichever group lands first. A no-op unless live. + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] + pub(crate) fn report_edge(&self, group: u64) { + if let Ok(mut state) = self.modify() + && let Feed::Live { first, edge } = &mut state.feed + { + *edge = (*edge).max(Some(group)); + first.get_or_insert(group); + } + } + /// Record the upstream Object ID separately from the frame ordinal readers count. #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) fn report_object(&self, group: u64, object: u64) { @@ -9017,6 +9029,26 @@ mod test { assert_eq!(ready_groups(&mut reader), vec![5]); } + /// A live join's answer anchors a relative start where it says the feed is, both for the + /// copy's readers and for the bounds sent upstream, even once a newer group lands before + /// the one it named. + #[test] + fn a_relative_start_counts_from_the_answered_edge() { + let producer = track_producer("test", Info::default()); + let back = Range { + start: super::super::subscription::Anchor::Relative(2), + end: None, + }; + let mut reader = producer.subscribe(replay().with_ranges([back])); + producer.report_edge(4); + let upstream = producer.resolve_subscription(&replay().with_ranges([back])).unwrap(); + assert_eq!(upstream.start(), Some(2), "the answer resolves the upstream bounds"); + + framed(&producer, 5, 1).finish().unwrap(); + assert_eq!(ready_groups(&mut reader), vec![5]); + assert_eq!(reader.floor(), Some(2), "the answer anchors the start"); + } + /// An idle copy forgets the edge its previous feed answered with, which only a datagram /// it dropped showed: when it ends without going live, a relative start counts back /// from its newest cached group.