From 5a02b750c79f19f8715c8ccce1865874776e0da5 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Thu, 22 Oct 2026 23:09:29 -0700 Subject: [PATCH 1/9] chore(quest): claim quest/m1/api-audit/ranges-wire.md Quest-Claim: b433680a7d06c53b From 891b3a4630f94a3b7caf7177cff2ed409f6ee310 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Thu, 22 Oct 2026 23:57:26 -0700 Subject: [PATCH 2/9] fix(net): refuse range anchors a session's wire drops A track received over a session resolved a relative or time anchor against the groups it happened to hold, since no wire carries one upstream: it read from the live edge or the wrong groups. Such a copy now refuses them with Error::Unsupported, keeping the live and oldest starts the wire does carry. Subscriber::floor and next_in_range honor set_groups, and the bindings take the subscription max delay as an optional. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EeyiEy5FWz3z44DYZVo7vU --- dart/moq/MIGRATE.md | 11 ++ dart/moq/lib/src/durations.dart | 5 +- dart/moq_ffi/MIGRATE.md | 11 ++ dart/moq_ffi/lib/src/moq.dart | 12 +- doc/concept/moq-lite.md | 8 +- go/wrapper/MIGRATE.md | 11 ++ go/wrapper/moq_test.go | 3 +- go/wrapper/records.go | 8 +- kt/moq/MIGRATE.md | 11 ++ .../kotlin/dev/moq/Durations.kt | 6 +- py/moq-ffi/MIGRATE.md | 11 ++ py/moq-rs/MIGRATE.md | 11 ++ py/moq-rs/moq/_records.py | 8 +- quest/m1/api-audit/README.md | 1 - quest/m1/api-audit/ranges-wire.md | 27 ---- rs/moq-c/MIGRATE.md | 11 ++ rs/moq-c/src/api.rs | 6 +- rs/moq-c/src/test.rs | 8 + rs/moq-ffi/MIGRATE.md | 11 ++ rs/moq-ffi/src/consumer.rs | 16 +- rs/moq-ffi/src/test.rs | 8 +- rs/moq-net/MIGRATE.md | 11 ++ rs/moq-net/src/error.rs | 2 +- rs/moq-net/src/ietf/subscriber.rs | 4 +- rs/moq-net/src/lite/subscriber.rs | 4 +- rs/moq-net/src/model/resume.rs | 7 + rs/moq-net/src/model/subscription.rs | 19 ++- rs/moq-net/src/model/subscription/window.rs | 12 +- rs/moq-net/src/model/track.rs | 65 ++++++-- rs/moq-net/tests/integration/main.rs | 1 + rs/moq-net/tests/integration/range_anchors.rs | 146 ++++++++++++++++++ swift/MIGRATE.md | 11 ++ 32 files changed, 405 insertions(+), 81 deletions(-) delete mode 100644 quest/m1/api-audit/ranges-wire.md create mode 100644 rs/moq-net/tests/integration/range_anchors.rs diff --git a/dart/moq/MIGRATE.md b/dart/moq/MIGRATE.md index 2421cf9d9c8..5bc6bedcd38 100644 --- a/dart/moq/MIGRATE.md +++ b/dart/moq/MIGRATE.md @@ -4,6 +4,17 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Subscription max delay is optional + +`Subscription.maxDelayUs` is `int?` and `Subscription.maxDelay` is `Duration?`, and `null` (the default) keeps moq-net's default of zero, which skips a superseded group at once. +Explicit values are unchanged; code reading them back handles `null`. + +### Relative and time ranges are refused over a session + +No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. +Ask for absolute groups over a session, or resolve the anchor where the track is published. + ### A broadcast reference waits for its sibling's announcement (#6254) Resolving a rendition's `broadcast` reference in the rendition-based subscribes and fetches now waits for a sibling nothing announces yet instead of failing as unroutable, so a late sibling plays once it is announced. diff --git a/dart/moq/lib/src/durations.dart b/dart/moq/lib/src/durations.dart index f6ffdcaa0aa..0738ec44e14 100644 --- a/dart/moq/lib/src/durations.dart +++ b/dart/moq/lib/src/durations.dart @@ -35,8 +35,9 @@ extension BackoffDuration on MoqBackoff { /// Duration views over the subscription knobs. extension SubscriptionDuration on MoqSubscription { - /// Upper bound on buffering before a stalled group is skipped. - Duration get maxDelay => Duration(microseconds: maxDelayUs); + /// Upper bound on buffering before a stalled group is skipped, or null for the default. + Duration? get maxDelay => + maxDelayUs == null ? null : Duration(microseconds: maxDelayUs!); } /// Duration views over the publisher-side track settings. diff --git a/dart/moq_ffi/MIGRATE.md b/dart/moq_ffi/MIGRATE.md index 81942441036..459a46b5404 100644 --- a/dart/moq_ffi/MIGRATE.md +++ b/dart/moq_ffi/MIGRATE.md @@ -4,6 +4,17 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Subscription max delay is optional + +`MoqSubscription.maxDelayUs` is `int?`, and `null` (the default) keeps moq-net's default of zero, which skips a superseded group at once. +Explicit values are unchanged. + +### Relative and time ranges are refused over a session + +No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. +Ask for absolute groups over a session, or resolve the anchor where the track is published. + ### A broadcast reference waits for its sibling's announcement (#6254) Resolving a rendition's `broadcast` reference, through `MoqBroadcastConsumer.resolve` and the rendition-based subscribes and fetches, now waits for a sibling nothing announces yet instead of failing as unroutable, so a late sibling plays once it is announced. diff --git a/dart/moq_ffi/lib/src/moq.dart b/dart/moq_ffi/lib/src/moq.dart index a7f3a9a6bf6..277347dc79f 100644 --- a/dart/moq_ffi/lib/src/moq.dart +++ b/dart/moq_ffi/lib/src/moq.dart @@ -686,12 +686,12 @@ class FfiConverterMoqRange { class MoqSubscription { final int priority; - final int maxDelayUs; + final int? maxDelayUs; final List? ranges; final MoqOrder? order; MoqSubscription({ this.priority = 0, - this.maxDelayUs = 0, + this.maxDelayUs = null, this.ranges = null, this.order = null, }); @@ -709,7 +709,7 @@ class FfiConverterMoqSubscription { ); final priority = priority_lifted.value; new_offset += priority_lifted.bytesRead; - final maxDelayUs_lifted = FfiConverterUInt64.read( + final maxDelayUs_lifted = FfiConverterOptionalUInt64.read( Uint8List.view(buf.buffer, new_offset), ); final maxDelayUs = maxDelayUs_lifted.value; @@ -738,7 +738,7 @@ class FfiConverterMoqSubscription { static RustBuffer lower(MoqSubscription value) { final total_length = FfiConverterInt8.allocationSize(value.priority) + - FfiConverterUInt64.allocationSize(value.maxDelayUs) + + FfiConverterOptionalUInt64.allocationSize(value.maxDelayUs) + FfiConverterOptionalSequenceMoqRange.allocationSize(value.ranges) + FfiConverterOptionalMoqOrder.allocationSize(value.order) + 0; @@ -753,7 +753,7 @@ class FfiConverterMoqSubscription { value.priority, Uint8List.view(buf.buffer, new_offset), ); - new_offset += FfiConverterUInt64.write( + new_offset += FfiConverterOptionalUInt64.write( value.maxDelayUs, Uint8List.view(buf.buffer, new_offset), ); @@ -770,7 +770,7 @@ class FfiConverterMoqSubscription { static int allocationSize(MoqSubscription value) { return FfiConverterInt8.allocationSize(value.priority) + - FfiConverterUInt64.allocationSize(value.maxDelayUs) + + FfiConverterOptionalUInt64.allocationSize(value.maxDelayUs) + FfiConverterOptionalSequenceMoqRange.allocationSize(value.ranges) + FfiConverterOptionalMoqOrder.allocationSize(value.order) + 0; diff --git a/doc/concept/moq-lite.md b/doc/concept/moq-lite.md index de0b9e42508..bb9f1f7daf2 100644 --- a/doc/concept/moq-lite.md +++ b/doc/concept/moq-lite.md @@ -252,9 +252,11 @@ own ranges cover, resolved again whenever it replaces them, even when another subscriber of the same track asked for more. Widening them, including lowering the start, also serves the cached groups they newly cover, never one already served. A relay merges its subscribers' ranges into one upstream request, which -today's wire versions carry as the single span covering them. A time anchor is -resolved from the groups the serving hop holds; upstream it asks for everything -max delay allows, and an untimed track refuses it. At the live edge, a time end +today's wire versions carry as the single span covering them. No wire version +carries a relative or time anchor yet, so beyond the live and default starts they +resolve only on the hop that publishes the track: a subscriber reading over a +session gets them refused as unsupported, and an untimed track refuses a time +anchor. At the live edge, a time end may let one group through before its first frame shows it starts past the end: the first group that has yet to start is handed out without waiting for that frame, and the next one waits on it. A datagram is judged by its own timestamp. diff --git a/go/wrapper/MIGRATE.md b/go/wrapper/MIGRATE.md index b76850ea132..4055d6e6bfb 100644 --- a/go/wrapper/MIGRATE.md +++ b/go/wrapper/MIGRATE.md @@ -4,6 +4,17 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Subscription max delay is optional + +`Subscription.MaxDelay` is `*time.Duration`, and `nil` keeps moq-net's default of zero, which skips a superseded group at once. +Point it at the duration you set before. + +### Relative and time ranges are refused over a session + +No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. +Ask for absolute groups over a session, or resolve the anchor where the track is published. + ### A broadcast reference waits for its sibling's announcement (#6254) Resolving a rendition's `broadcast` reference, through `BroadcastConsumer.Resolve` and the rendition-based subscribes and fetches, now waits for a sibling nothing announces yet instead of failing as unroutable, so a late sibling plays once it is announced. diff --git a/go/wrapper/moq_test.go b/go/wrapper/moq_test.go index 2c458e0bc6d..1ec812a777b 100644 --- a/go/wrapper/moq_test.go +++ b/go/wrapper/moq_test.go @@ -821,8 +821,9 @@ func TestAscendingSubscriptionReadsCachedBacklogOldestFirst(t *testing.T) { } order := moq.OrderAscending + maxDelay := 10 * time.Second consumer, err := track.Consume(&moq.Subscription{ - MaxDelay: 10 * time.Second, + MaxDelay: &maxDelay, Ranges: []moq.Range{{Start: moq.AnchorRelative{Groups: 2}}}, Order: &order, }) diff --git a/go/wrapper/records.go b/go/wrapper/records.go index 8eaec884773..69dbe7e1944 100644 --- a/go/wrapper/records.go +++ b/go/wrapper/records.go @@ -58,19 +58,19 @@ func datagramFromFFI(d *ffi.MoqDatagram) *Datagram { } // Subscription holds subscriber-side delivery preferences: priority, the max delay -// a non-latest group may fall behind before it is skipped (zero skips at once, and it -// caps every range), the ranges of the track to deliver (nil for everything MaxDelay +// a non-latest group may fall behind before it is skipped (nil for moq-net's default of +// zero, which skips at once; it caps every range), the ranges of the track to deliver (nil for everything MaxDelay // still allows, while an empty non-nil slice asks for nothing), and the order the // publisher sends pending groups in (nil for newest first). type Subscription struct { Priority int8 - MaxDelay time.Duration + MaxDelay *time.Duration Ranges []Range Order *Order } func (s Subscription) ffi() (ffi.MoqSubscription, error) { - maxDelay, err := bridge.Duration(s.MaxDelay, "max delay") + maxDelay, err := bridge.OptionalDuration(s.MaxDelay, "max delay") var ranges *[]ffi.MoqRange if s.Ranges != nil { ranges = &s.Ranges diff --git a/kt/moq/MIGRATE.md b/kt/moq/MIGRATE.md index 995d262f220..e9b6813a92a 100644 --- a/kt/moq/MIGRATE.md +++ b/kt/moq/MIGRATE.md @@ -4,6 +4,17 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Subscription max delay is optional + +`Subscription.maxDelayUs` is `ULong?` and `Subscription.maxDelay` is `Duration?`, and `null` (the default) keeps moq-net's default of zero, which skips a superseded group at once. +Explicit values are unchanged; code reading them back handles `null`. + +### Relative and time ranges are refused over a session + +No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. +Ask for absolute groups over a session, or resolve the anchor where the track is published. + ### A broadcast reference waits for its sibling's announcement (#6254) Resolving a rendition's `broadcast` reference in the rendition-based subscribes and fetches now waits for a sibling nothing announces yet instead of failing as unroutable, so a late sibling plays once it is announced. diff --git a/kt/moq/src/jvmAndAndroidMain/kotlin/dev/moq/Durations.kt b/kt/moq/src/jvmAndAndroidMain/kotlin/dev/moq/Durations.kt index 436a92a6717..e58584abbe3 100644 --- a/kt/moq/src/jvmAndAndroidMain/kotlin/dev/moq/Durations.kt +++ b/kt/moq/src/jvmAndAndroidMain/kotlin/dev/moq/Durations.kt @@ -53,9 +53,9 @@ val QuicConfig.idleTimeout: Duration? val QuicConfig.keepAlive: Duration? get() = keepAliveUs?.toLong()?.microseconds -/** Upper bound on buffering before a stalled group is skipped. */ -val Subscription.maxDelay: Duration - get() = maxDelayUs.toLong().microseconds +/** Upper bound on buffering before a stalled group is skipped, or null for the default. */ +val Subscription.maxDelay: Duration? + get() = maxDelayUs?.toLong()?.microseconds /** Maximum age of a non-latest group before the publisher evicts it, or null for the default. */ val TrackInfo.maxAge: Duration? diff --git a/py/moq-ffi/MIGRATE.md b/py/moq-ffi/MIGRATE.md index 44d3a96c07a..838b8b02482 100644 --- a/py/moq-ffi/MIGRATE.md +++ b/py/moq-ffi/MIGRATE.md @@ -4,6 +4,17 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Subscription max delay is optional + +`MoqSubscription.max_delay_us` is `int | None`, and `None` (the default) keeps moq-net's default of zero, which skips a superseded group at once. +Explicit values are unchanged. + +### Relative and time ranges are refused over a session + +No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. +Ask for absolute groups over a session, or resolve the anchor where the track is published. + ### A broadcast reference waits for its sibling's announcement (#6254) Resolving a rendition's `broadcast` reference, through `MoqBroadcastConsumer.resolve()` and the rendition-based subscribes and fetches, now waits for a sibling nothing announces yet instead of failing as unroutable, so a late sibling plays once it is announced. diff --git a/py/moq-rs/MIGRATE.md b/py/moq-rs/MIGRATE.md index b8ec8a192fa..a5d568a9817 100644 --- a/py/moq-rs/MIGRATE.md +++ b/py/moq-rs/MIGRATE.md @@ -4,6 +4,17 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Subscription max delay is optional + +`Subscription.max_delay` is `timedelta | None`, and `None` (the default) keeps moq-net's default of zero, which skips a superseded group at once. +Explicit values are unchanged; code reading `max_delay` back handles `None`. + +### Relative and time ranges are refused over a session + +No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. +Ask for absolute groups over a session, or resolve the anchor where the track is published. + ### A broadcast reference waits for its sibling's announcement (#6254) Resolving a rendition's `broadcast` reference, through `BroadcastConsumer.resolve()` and the rendition-based subscribes and fetches, now waits for a sibling nothing announces yet instead of failing as unroutable, so a late sibling plays once it is announced. diff --git a/py/moq-rs/moq/_records.py b/py/moq-rs/moq/_records.py index f1e4be00755..37eaae20752 100644 --- a/py/moq-rs/moq/_records.py +++ b/py/moq-rs/moq/_records.py @@ -94,21 +94,21 @@ class Subscription: """Subscriber-side delivery preferences, mirroring moq-net's ``track::Subscription``. ``priority`` is in ``-128..=127``, higher first, and defaults to 0, the midpoint. - ``max_delay`` is how far a non-latest group may fall behind before it is skipped; - zero skips at once, and it caps every range. ``ranges`` are the spans of the track to + ``max_delay`` is how far a non-latest group may fall behind before it is skipped, + ``None`` for moq-net's default of zero, which skips at once; it caps every range. ``ranges`` are the spans of the track to deliver, ``None`` for everything ``max_delay`` still allows. ``order`` is which pending group the publisher sends first, ``None`` for newest first. """ priority: int = 0 - max_delay: timedelta = timedelta(0) + max_delay: timedelta | None = None ranges: Sequence[MoqRange] | None = None order: MoqOrder | None = None def _ffi(self) -> MoqSubscription: return MoqSubscription( priority=self.priority, - max_delay_us=_to_us(self.max_delay, "max_delay"), + max_delay_us=_opt_us(self.max_delay, "max_delay"), ranges=None if self.ranges is None else list(self.ranges), order=self.order, ) diff --git a/quest/m1/api-audit/README.md b/quest/m1/api-audit/README.md index a223e5ad187..76786ca40b3 100644 --- a/quest/m1/api-audit/README.md +++ b/quest/m1/api-audit/README.md @@ -81,7 +81,6 @@ Rejected in planning: - [largest is a getter](/quest/m1/api-audit/largest-getter.md) - `track::Producer::largest` is a plain read in Rust and JS, never a shared cursor - [One clean close](/quest/m1/api-audit/clean-close.md) - a clean session close has one spelling and failures are recorded inside moq-net - [Session limits only where needed](/quest/m1/api-audit/session-limits.md) - `session::Limits` keeps only bounds that nothing else enforces, and its documented example compiles -- [Ranges refuse what the wire drops](/quest/m1/api-audit/ranges-wire.md) - relative and time anchors fail loud where a wire cannot carry them, `floor()` honors the subscription, and bindings take an optional max delay - [Derived origins borrow](/quest/m1/api-audit/derived-origin-close.md) - closing a JS `scope()` or `withPreference()` handle releases only that handle - [Binding surface trim](/quest/m1/api-audit/binding-trim.md) - route input is separate from route observation, watch verbs are uniform, and unused binding objects are gone - [Wrapper config names](/quest/m1/api-audit/wrapper-config.md) - Python, Go, and Dart client options use the FFI's names and nesting diff --git a/quest/m1/api-audit/ranges-wire.md b/quest/m1/api-audit/ranges-wire.md deleted file mode 100644 index 179ed5991e0..00000000000 --- a/quest/m1/api-audit/ranges-wire.md +++ /dev/null @@ -1,27 +0,0 @@ -# [S] Ranges refuse what the wire drops - -## Goal - -A subscription range with a relative or time anchor fails loud on a hop -whose upstream wire cannot carry it, instead of silently becoming live. -`floor()` honors `set_groups`, and the bindings take max delay as an -optional duration before their shape freezes. - -## Plan - -Decided 2026-10-22 (API audit). Keep the general range API (the -[subscribe ranges](/quest/m1/subscribe-ranges/README.md) line lands lite-07 -before the cut); fix only what the audit found broken: - -- `Anchor::Relative` and `Anchor::Time` are resolved at the serving hop and - otherwise degrade to live on wires that cannot carry them (published lite - versions, moq-transport without a local resolution). Refuse instead, with - a test on each wire. -- `floor()` ignores `set_groups` (`rs/moq-net/src/model/track.rs`); fix and - test. -- Bindings expose `max_delay_us` with zero meaning the live default; take - `max_delay: Option` (or the binding's optional) like Rust's - `Fetch::max_delay`. moq-hls `history.rs` works around the zero default with - a `(1 << 53) - 1` ms budget; remove that once it can say "unset". - -Public API: moq-ffi and wrappers breaking (max delay). Wire: none. diff --git a/rs/moq-c/MIGRATE.md b/rs/moq-c/MIGRATE.md index 73a236f8faa..54721550a7c 100644 --- a/rs/moq-c/MIGRATE.md +++ b/rs/moq-c/MIGRATE.md @@ -4,6 +4,17 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Subscription max delay is optional + +`moq_subscription.max_delay_us` is read only when the new `max_delay_present` is true, so it is optional: a zeroed struct keeps moq-net's default of zero, which skips a superseded group at once. +Set `max_delay_present = true` wherever you set a nonzero `max_delay_us`. + +### Relative and time ranges are refused over a session + +No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. +Ask for absolute groups over a session, or resolve the anchor where the track is published. + ### A broadcast reference waits for its sibling's announcement (#6254) `moq_consume_video` and `moq_consume_audio` on a rendition whose catalog `broadcast` field names a sibling now wait for a sibling nothing announces yet instead of failing as unroutable, so a late sibling plays once it is announced. diff --git a/rs/moq-c/src/api.rs b/rs/moq-c/src/api.rs index aa7170afaa1..e222f401f4d 100644 --- a/rs/moq-c/src/api.rs +++ b/rs/moq-c/src/api.rs @@ -605,6 +605,8 @@ pub struct moq_subscription { /// Zero skips immediately. Enforced by the publisher's cache and by any local buffering. /// It caps every range. pub max_delay_us: u64, + /// Whether `max_delay_us` is set. When false, moq-net's default applies: zero. + pub max_delay_present: bool, /// The spans of the track to deliver, or NULL for everything `max_delay_us` still /// considers fresh. A non-NULL pointer with `ranges_len` 0 asks for nothing. @@ -703,8 +705,10 @@ pub(crate) unsafe fn parse_subscription( }; let mut out = moq_net::track::Subscription::default() .with_priority(subscription.priority) - .with_max_delay(std::time::Duration::from_micros(subscription.max_delay_us)) .with_order(order); + if subscription.max_delay_present { + out = out.with_max_delay(std::time::Duration::from_micros(subscription.max_delay_us)); + } if !subscription.ranges.is_null() { let ranges = unsafe { std::slice::from_raw_parts(subscription.ranges, subscription.ranges_len) }; let ranges = ranges diff --git a/rs/moq-c/src/test.rs b/rs/moq-c/src/test.rs index d98cc3fe827..802359d7732 100644 --- a/rs/moq-c/src/test.rs +++ b/rs/moq-c/src/test.rs @@ -1393,6 +1393,7 @@ fn publish_track_invalid_broadcast() { let subscription = moq_subscription { priority: 1, max_delay_us: 0, + max_delay_present: false, ranges: std::ptr::null(), ranges_len: 0, order: 0, @@ -1502,6 +1503,7 @@ fn raw_track_publish_consume() { let subscription = moq_subscription { priority: 0, max_delay_us: 1_000_000, + max_delay_present: true, ranges: std::ptr::null(), ranges_len: 0, order: 0, @@ -1724,6 +1726,7 @@ fn raw_track_subscription_options_and_update() { let subscription = moq_subscription { priority: 5, max_delay_us: 25_000, + max_delay_present: true, ranges: ranges.as_ptr(), ranges_len: ranges.len(), order: 0, @@ -1838,6 +1841,7 @@ fn raw_track_time_anchor() { let subscription = moq_subscription { priority: 5, max_delay_us: 1_000_000, + max_delay_present: true, ranges: ranges.as_ptr(), ranges_len: ranges.len(), order: 0, @@ -1938,6 +1942,7 @@ fn raw_track_update_refuses_time_on_untimed() { let update = moq_subscription { priority: 3, max_delay_us: 1_000_000, + max_delay_present: true, ranges: ranges.as_ptr(), ranges_len: ranges.len(), order: 0, @@ -1996,6 +2001,7 @@ fn raw_track_relative_update_counts_from_the_track_edge() { let subscribe = |ranges: &[moq_range]| moq_subscription { priority: 0, max_delay_us: 60_000_000, + max_delay_present: true, ranges: ranges.as_ptr(), ranges_len: ranges.len(), order: 0, @@ -2266,6 +2272,7 @@ fn publish_finish_serves_finished_tracks_until_closed() { let subscription = moq_subscription { priority: 0, max_delay_us: 0, + max_delay_present: false, ranges: std::ptr::null(), ranges_len: 0, order: 0, @@ -5763,6 +5770,7 @@ fn read_raw_frames(consume: u32, name: &[u8], count: usize) -> Vec> { let subscription = moq_subscription { priority: 0, max_delay_us: 1_000_000, + max_delay_present: true, ranges: std::ptr::null(), ranges_len: 0, order: 0, diff --git a/rs/moq-ffi/MIGRATE.md b/rs/moq-ffi/MIGRATE.md index 63a09626841..a3563a77905 100644 --- a/rs/moq-ffi/MIGRATE.md +++ b/rs/moq-ffi/MIGRATE.md @@ -5,6 +5,17 @@ These are the UniFFI names; each language wrapper has its own `MIGRATE.md` in it ## Unreleased +### Subscription max delay is optional + +`MoqSubscription.max_delay_us` is `Option`, and `None` (the default) keeps moq-net's default of zero, which skips a superseded group at once. +Wrap an explicit value in `Some`. + +### Relative and time ranges are refused over a session + +No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. +Ask for absolute groups over a session, or resolve the anchor where the track is published. + ### A broadcast reference waits for its sibling's announcement (#6254) Resolving a rendition's `broadcast` reference, through `MoqBroadcastConsumer::resolve` and the rendition-based subscribes and fetches, now waits for a sibling nothing announces yet instead of failing as unroutable, so a late sibling plays once it is announced. diff --git a/rs/moq-ffi/src/consumer.rs b/rs/moq-ffi/src/consumer.rs index 9300d72effb..fff15e74488 100644 --- a/rs/moq-ffi/src/consumer.rs +++ b/rs/moq-ffi/src/consumer.rs @@ -31,13 +31,14 @@ pub struct MoqSubscription { /// The default 0 is the midpoint. #[uniffi(default = 0)] pub priority: i8, - /// Maximum age of a non-latest group before it is skipped, in microseconds. - /// `0` skips immediately; a larger value tolerates that much reordering. + /// Maximum age of a non-latest group before it is skipped, in microseconds, or null + /// for moq-net's default: `0`, which skips immediately. A larger value tolerates that + /// much reordering. /// /// Enforced both by the publisher's cache (sent on the wire) and by any local /// buffering, such as [`MoqMediaTrackConsumer`]'s jitter buffer. It caps every range. - #[uniffi(default = 0)] - pub max_delay_us: u64, + #[uniffi(default = None)] + pub max_delay_us: Option, /// The spans of the track to deliver, or null for everything `max_delay_us` still /// considers fresh. An empty list asks for nothing. /// @@ -155,9 +156,10 @@ impl TryFrom for moq_net::track::Subscription { type Error = MoqError; fn try_from(s: MoqSubscription) -> Result { - let mut subscription = moq_net::track::Subscription::default() - .with_priority(s.priority) - .with_max_delay(std::time::Duration::from_micros(s.max_delay_us)); + let mut subscription = moq_net::track::Subscription::default().with_priority(s.priority); + if let Some(max_delay) = s.max_delay_us { + subscription = subscription.with_max_delay(std::time::Duration::from_micros(max_delay)); + } if let Some(ranges) = s.ranges { subscription = subscription.with_ranges( ranges diff --git a/rs/moq-ffi/src/test.rs b/rs/moq-ffi/src/test.rs index cb5d8815996..cd4314a95a4 100644 --- a/rs/moq-ffi/src/test.rs +++ b/rs/moq-ffi/src/test.rs @@ -1054,7 +1054,7 @@ async fn raw_track_update_does_not_wait_for_pending_read() { consumer .update(MoqSubscription { priority: 10, - max_delay_us: 25_000, + max_delay_us: Some(25_000), ranges: Some(vec![MoqRange { start: MoqAnchor::Absolute { group: 0, frame: 0 }, end: None, @@ -4403,7 +4403,7 @@ async fn raw_track_update_during_pending_group_still_reads_datagram() { consumer .update(MoqSubscription { priority: 10, - max_delay_us: 25_000, + max_delay_us: Some(25_000), ranges: Some(vec![MoqRange { start: MoqAnchor::Absolute { group: 0, frame: 0 }, end: None, @@ -7287,7 +7287,7 @@ async fn ascending_subscription_reads_a_cached_backlog_oldest_first() { let subscription = MoqSubscription { priority: 0, - max_delay_us: 10_000_000, + max_delay_us: Some(10_000_000), ranges: Some(vec![MoqRange { start: MoqAnchor::Relative { groups: 2 }, end: None, @@ -7521,7 +7521,7 @@ async fn time_anchors_start_at_the_containing_group() { let since = |timestamp_us| MoqSubscription { priority: 0, - max_delay_us: 10_000_000, + max_delay_us: Some(10_000_000), ranges: Some(vec![MoqRange { start: MoqAnchor::Time { timestamp_us }, end: None, diff --git a/rs/moq-net/MIGRATE.md b/rs/moq-net/MIGRATE.md index e16d361e179..56764846745 100644 --- a/rs/moq-net/MIGRATE.md +++ b/rs/moq-net/MIGRATE.md @@ -4,6 +4,17 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Relative and time ranges are refused over a session + +No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with `Error::Unsupported`. +This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. +Ask for absolute groups over a session, or resolve the anchor where the track is published. + +### `Subscriber::floor` and `next_in_range` honor `set_groups` + +Both now return at least the start set by `Subscriber::set_groups`, so a reader waiting on each group in sequence no longer waits on groups the local floor withholds. +Drop any `max` against your own `set_groups` start. + ### IETF whole-group FETCH answers name the requested group ([#6199](https://github.com/moq-dev/moq/issues/6199)) On moq-transport drafts 14 through 19, a whole-group `FETCH_OK` now names `{g, 0}` instead of `{g+1, 0}`. diff --git a/rs/moq-net/src/error.rs b/rs/moq-net/src/error.rs index 0f4f1e052dc..c3548183ad2 100644 --- a/rs/moq-net/src/error.rs +++ b/rs/moq-net/src/error.rs @@ -435,7 +435,7 @@ pub enum Error { #[error("unexpected message")] UnexpectedMessage, - /// The peer asked for a feature this endpoint does not implement. + /// A feature was asked for that this endpoint, or the wire to the peer, does not implement. #[error("unsupported")] Unsupported, diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index e7283473dfb..e222f33f5e3 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -4213,8 +4213,10 @@ where let dynamic = request.dynamic(); // Nothing feeds this copy live: what it caches is fetched, never the live edge. Idle // from the accept, so no reader takes it as live in between. - let track = request.idle().accept(accepted_info(&ok.properties, self.version)); + let track = request.idle().stage(accepted_info(&ok.properties, self.version)); + // Marked received before any reader sees it, so none resolves an anchor this wire dropped. track.received(); + let track = track.commit(); Some(Idle { demand: track.demand(), track, diff --git a/rs/moq-net/src/lite/subscriber.rs b/rs/moq-net/src/lite/subscriber.rs index 057546afaa5..b542eed554e 100644 --- a/rs/moq-net/src/lite/subscriber.rs +++ b/rs/moq-net/src/lite/subscriber.rs @@ -7172,8 +7172,10 @@ impl ServeLoop { true => request.request_start(None), false => request, }; - let serving = request.accept(info); + // Marked received before any reader sees it, so none resolves an anchor this wire dropped. + let serving = request.stage(info); serving.received(); + let serving = serving.commit(); Self { largest: None, demand: serving.demand(), diff --git a/rs/moq-net/src/model/resume.rs b/rs/moq-net/src/model/resume.rs index d1633035ec7..420f32135f2 100644 --- a/rs/moq-net/src/model/resume.rs +++ b/rs/moq-net/src/model/resume.rs @@ -1313,6 +1313,10 @@ impl Reader { } Poll::Ready(Ok(sub)) => sub, }; + // The reader's own ranges, which no copy of this route serves either. + if let Some(err) = sub.refused() { + return Some(Poll::Ready(Err(err))); + } if ordered { sub.skip_ordered(floor); } @@ -1462,6 +1466,9 @@ impl Reader { } Poll::Ready(Ok(sub)) => sub, }; + if let Some(err) = sub.refused() { + return Some(Poll::Ready(Err(err))); + } match sub.poll_recv_wire_datagram(waiter) { Poll::Pending => break, Poll::Ready(Ok(Some(datagram))) => { diff --git a/rs/moq-net/src/model/subscription.rs b/rs/moq-net/src/model/subscription.rs index 0554c86003a..e36a0cfbf7a 100644 --- a/rs/moq-net/src/model/subscription.rs +++ b/rs/moq-net/src/model/subscription.rs @@ -111,10 +111,10 @@ pub enum Order { /// and again whenever the subscriber replaces its ranges. Before any group exists a /// relative anchor resolves at the first one, so [`Range::live`] starts there. /// -/// No published wire carries either yet: upstream, a relative or time start is no floor, -/// the same request as [`Range::oldest`], and a relative or time end is no end. Behind a -/// moq-transport upstream, which joins without a floor at the live group, `Relative(n)..` -/// starts there. +/// No wire carries either upstream yet, beyond the live and oldest starts it spells with +/// no floor ([`Range::live`] and [`Range::oldest`]). A track copy received over a session +/// refuses any other relative or time anchor with [`Error::Unsupported`](crate::Error::Unsupported) +/// on read, rather than resolve it against the partial cache it holds. #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Anchor { /// This exact position. @@ -186,6 +186,17 @@ impl Range { } } + /// Whether a wire without ranges carries this range upstream: absolute anchors, and + /// the live and oldest starts it spells with no floor. + pub(super) fn is_wire(&self) -> bool { + let start = match self.start { + Anchor::Absolute(_) => true, + Anchor::Relative(back) => back == 0 || back == u64::MAX, + Anchor::Time(_) => false, + }; + start && matches!(self.end, None | Some(Anchor::Absolute(_))) + } + /// Whether this range certainly delivers nothing, wherever the latest group lands. pub(super) fn is_empty(&self) -> bool { match (self.start, self.end) { diff --git a/rs/moq-net/src/model/subscription/window.rs b/rs/moq-net/src/model/subscription/window.rs index 0867c7e561e..8746d504df0 100644 --- a/rs/moq-net/src/model/subscription/window.rs +++ b/rs/moq-net/src/model/subscription/window.rs @@ -27,6 +27,12 @@ pub(in crate::model) trait Holdings { /// Whether the track carries timestamps at all. fn timed(&self) -> bool; + /// Whether the groups are a copy received over a wire, which asks upstream only for + /// what [`Range::is_wire`] covers, so any other anchor can't resolve here. + fn received(&self) -> bool { + false + } + /// Where `pts` falls among the groups with a known start. fn containing(&self, pts: Timestamp) -> Containing; @@ -311,7 +317,8 @@ impl TimeEnd { impl Window { /// Resolve `ranges`, counting relative anchors back from `latest`. /// - /// Refuses a time anchor on an untimed track with [`Error::TimestampMismatch`]. + /// Refuses a time anchor on an untimed track with [`Error::TimestampMismatch`], and an + /// anchor a received copy's wire drops with [`Error::Unsupported`]. pub fn new(ranges: &[Range], latest: Option, holdings: &impl Holdings) -> Result { let mut window = Self { ranges: ranges.to_vec(), @@ -531,6 +538,9 @@ impl Window { { return Err(Error::TimestampMismatch); } + if holdings.received() && !self.ranges.iter().all(Range::is_wire) { + return Err(Error::Unsupported); + } self.spans.clear(); self.pending = false; for (index, range) in self.ranges.iter().enumerate().filter(|(_, range)| !range.is_empty()) { diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index 3aba138fea0..41cd93b54db 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 { start_pending: bool, // A copy received from a remote publisher, whose declared end waits for groups still - // in flight below it (see `tail`). + // in flight below it (see `tail`), and whose readers' anchors resolve only as far as + // the wire carried them upstream (see `Holdings::received`). received: bool, // Sequences the upstream publisher gave up, with the error each was given up with: an // incoming SUBSCRIBE_DROP or a producer cut. Kept apart from the cache so reclaiming a @@ -745,6 +746,10 @@ impl Holdings for TrackState { self.info.as_ref().is_none_or(|info| info.timescale.is_some()) } + fn received(&self) -> bool { + self.received + } + fn containing(&self, pts: Timestamp) -> Containing { let starts = self.starts.lock().unwrap_or_else(PoisonError::into_inner); let (Some((&first, &first_at)), Some((&last, &last_at))) = (starts.first_key_value(), starts.last_key_value()) @@ -6792,24 +6797,28 @@ impl Subscriber { Poll::Ready(start.map(|start| start.max(cursor.floor()))) } - /// The lowest group this subscriber's ranges name, as resolved here when it last read: - /// `None` while one reaches back to the oldest group still around, or a relative - /// start still waits on the first group to arrive. + /// The lowest group this subscriber's ranges name, as resolved here when it last read, + /// raised to the start of [`Self::set_groups`]: `None` while one reaches back to the + /// oldest group still around, or a relative start still waits on the first group to + /// arrive. /// /// Where a reader that waits on each group in sequence starts, rather than at whatever /// arrives first, which newest-first delivery makes the latest. pub fn floor(&self) -> Option { - match &self.inner { + let start = match &self.inner { Inner::Plain(cursor) => cursor.filter.window.start(), Inner::Resume(resume, _) => resume.floor(), - } + }; + Some(start?.max(self.bounds().start)) } - /// The lowest group at or above `from` this subscriber's ranges cover, `None` when - /// none does: the groups between are never read, so a reader waiting on each group in - /// sequence need not wait for them. `Some(from)` while a relative anchor waits on the - /// first group, which can't say yet. + /// The lowest group at or above `from` this subscriber's ranges and + /// [`Self::set_groups`] floor cover, `None` when none does: the groups between are + /// never read, so a reader waiting on each group in sequence need not wait for them. + /// `Some` from there while a relative anchor waits on the first group, which can't + /// say yet. pub fn next_in_range(&self, from: u64) -> Option { + let from = from.max(self.bounds().start); match &self.inner { Inner::Plain(cursor) => cursor.filter.window.runs(from).next().map(|run| *run.start()), Inner::Resume(resume, _) => resume.next_in_range(from), @@ -6828,6 +6837,18 @@ impl Subscriber { } } + /// Why this subscriber's ranges can't be served from its track, the error its reads + /// fail with; `None` for a front's reader, whose copies answer for it. + pub(super) fn refused(&mut self) -> Option { + match &mut self.inner { + Inner::Plain(cursor) => { + cursor.sync(); + cursor.filter.refused.clone() + } + Inner::Resume(..) => None, + } + } + /// `ranges` resolved against this track's cache now, by index. pub(super) fn resolve_ranges(&self, ranges: &[Range]) -> Vec> { match &self.inner { @@ -8068,6 +8089,30 @@ mod test { } } + /// The floor a reader waiting on each group starts at is the higher of its ranges' and + /// its local one, so it never waits on a group the local floor withholds. + #[test] + fn floor_honors_set_groups() { + let producer = track_producer("test", Info::default()); + let _groups: Vec<_> = (0..6).map(|sequence| framed(&producer, sequence, 2)).collect(); + + let mut reader = producer.subscribe(replay().with_groups(2..)); + assert_eq!((reader.floor(), reader.next_in_range(0)), (Some(2), Some(2))); + reader.set_groups(4..); + assert_eq!((reader.floor(), reader.next_in_range(0)), (Some(4), Some(4))); + assert_eq!(reader.next_in_range(5), Some(5)); + + // Below the ranges' floor, the ranges still decide. + let mut reader = producer.subscribe(replay().with_groups(3..)); + reader.set_groups(1..); + assert_eq!((reader.floor(), reader.next_in_range(0)), (Some(3), Some(3))); + + // A floor reaching back to the oldest group stays unknown. + let mut reader = producer.subscribe(replay()); + reader.set_groups(4..); + assert_eq!(reader.floor(), None); + } + /// The largest reports only while it is within the bounds: a cap below it or a floor /// above it reports nothing, rather than a cached group standing in for it. #[test] diff --git a/rs/moq-net/tests/integration/main.rs b/rs/moq-net/tests/integration/main.rs index 99e9941f634..4faf3d4ec0e 100644 --- a/rs/moq-net/tests/integration/main.rs +++ b/rs/moq-net/tests/integration/main.rs @@ -41,6 +41,7 @@ mod model; mod multi_cdn; mod partial_group; mod quiet_catalog; +mod range_anchors; mod received_rewind; mod refresh; mod rejoin; diff --git a/rs/moq-net/tests/integration/range_anchors.rs b/rs/moq-net/tests/integration/range_anchors.rs new file mode 100644 index 00000000000..8b4f9e3eedc --- /dev/null +++ b/rs/moq-net/tests/integration/range_anchors.rs @@ -0,0 +1,146 @@ +#![cfg(feature = "async")] + +//! A range starting relative to the latest group or at a presentation time resolves only +//! where the track is held. No wire carries such an anchor upstream yet, so a copy +//! received over a session refuses one instead of joining at the live edge. + +use crate::support; + +use std::time::Duration; + +use moq_net::track::{Anchor, Info, Order, Range, Subscription}; +use moq_net::{Error, Hop, Timescale, Timestamp, Version}; +use support::harness::peer; + +const TIMEOUT: Duration = Duration::from_secs(10); + +/// A budget no group outlives, so only the range decides what is read. +const FOREVER: Duration = Duration::from_millis((1 << 53) - 1); + +const VERSIONS: &[&str] = &[ + "moq-lite-03", + "moq-lite-04", + "moq-lite-05", + "moq-lite-06", + "moq-lite-07-wip", + "moq-transport-14", + "moq-transport-16", + "moq-transport-17", + "moq-transport-20", + "moq-transport-22", +]; + +fn produce_origin(hop: u64) -> moq_net::origin::Producer { + let (producer, driver) = moq_net::origin::Producer::new(moq_net::origin::Config::new(Hop::new(hop).unwrap())); + support::harness::spawn(driver); + producer +} + +fn millis(ms: u64) -> Timestamp { + Timestamp::from_millis(ms).unwrap() +} + +/// Groups 0 to 4, group `n` presenting at `n` seconds, then what a subscriber to `range` +/// reads oldest first: through the publisher's own origin with no `version`, otherwise +/// over one session on it. +async fn read(version: Option<&str>, range: Range) -> Result, Error> { + let publisher = produce_origin(1); + let broadcast = publisher.create_broadcast("room").unwrap(); + let track = broadcast + .create_track("data", Info::default().with_timescale(Timescale::MILLI).with_max_age(FOREVER)) + .unwrap(); + broadcast.announce(Default::default()).unwrap(); + for sequence in 0..5 { + let mut group = track.create_group(moq_net::group::Info { sequence }).unwrap(); + group.write_frame(millis(sequence * 1000), &b"x"[..]).unwrap(); + group.finish().unwrap(); + } + + let subscriber = produce_origin(2); + let _pair; + let remote = match version { + // Through the origin, as a reader of a local route. + None => moq_clock::timeout(TIMEOUT, publisher.consume().request_broadcast("room", None)) + .await + .expect("resolve timeout") + .expect("broadcast resolves"), + Some(version) => { + _pair = peer(version.parse::().unwrap(), &publisher, &subscriber).await; + let consumer = subscriber.consume(); + moq_clock::timeout(TIMEOUT, consumer.routed("room")) + .await + .expect("announce timeout") + .expect("routed"); + moq_clock::timeout(TIMEOUT, consumer.request_broadcast("room", None)) + .await + .expect("resolve timeout") + .expect("broadcast resolves") + } + }; + + let subscription = Subscription::default() + .with_max_delay(FOREVER) + .with_order(Order::Ascending) + .with_ranges([range]); + let mut reader = moq_clock::timeout(TIMEOUT, remote.track("data").unwrap().subscribe(subscription)) + .await + .expect("subscribe timeout")?; + + let mut read = Vec::new(); + while let Ok(group) = moq_clock::timeout(TIMEOUT, reader.recv_group()).await { + match group? { + Some(group) => read.push(group.sequence), + None => break, + } + } + track.finish().unwrap(); + Ok(read) +} + +fn from(start: Anchor) -> Range { + Range { start, end: None } +} + +/// Where the track is held, both anchors resolve against its groups. +#[moq_clock::test] +async fn a_held_track_resolves_relative_and_time_starts() { + assert_eq!(read(None, from(Anchor::Relative(2))).await.unwrap(), vec![2, 3, 4]); + assert_eq!(read(None, from(Anchor::Time(millis(2500)))).await.unwrap(), vec![2, 3, 4]); +} + +/// Over a session, the anchors the wire cannot carry are refused, while the live and +/// oldest starts it does carry still read. +#[moq_clock::test] +async fn a_received_copy_refuses_what_its_wire_drops() { + let refused = [ + from(Anchor::Relative(2)), + from(Anchor::Time(millis(2500))), + Range { + start: Anchor::Absolute(moq_net::track::Position::group(0)), + end: Some(Anchor::Relative(1)), + }, + Range { + start: Anchor::Absolute(moq_net::track::Position::group(0)), + end: Some(Anchor::Time(millis(2500))), + }, + ]; + for version in VERSIONS { + for range in refused { + let result = read(Some(version), range).await; + // A wire without timestamps refuses a time anchor for that first. + let timed = !matches!( + *version, + "moq-lite-03" | "moq-lite-04" | "moq-lite-05" | "moq-lite-06" | "moq-transport-14" | "moq-transport-16" + ); + let time = matches!(range.start, Anchor::Time(_)) || matches!(range.end, Some(Anchor::Time(_))); + match (time && !timed, &result) { + (true, Err(Error::TimestampMismatch)) | (false, Err(Error::Unsupported)) => {} + _ => panic!("{version}: {range:?} read {result:?}"), + } + } + let live = read(Some(version), Range::live()).await; + assert_eq!(live.unwrap().last(), Some(&4), "{version}: live reads the latest group"); + let oldest = read(Some(version), Range::oldest()).await; + assert_eq!(oldest.unwrap().last(), Some(&4), "{version}: oldest reads through the latest group"); + } +} diff --git a/swift/MIGRATE.md b/swift/MIGRATE.md index 976a5a725ad..4d5449f02b3 100644 --- a/swift/MIGRATE.md +++ b/swift/MIGRATE.md @@ -4,6 +4,17 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Subscription max delay is optional + +`Subscription.maxDelayUs` is `UInt64?`, and `nil` (the default) keeps moq-net's default of zero, which skips a superseded group at once. +Explicit values are unchanged; code reading it back unwraps it. + +### Relative and time ranges are refused over a session + +No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. +Ask for absolute groups over a session, or resolve the anchor where the track is published. + ### A broadcast reference waits for its sibling's announcement (#6254) Resolving a rendition's `broadcast` reference, through `BroadcastConsumer.resolve(_:epoch:)` and the rendition-based subscribes and fetches, now waits for a sibling nothing announces yet instead of failing as unroutable, so a late sibling plays once it is announced. From 9477ff6918c098411660a6427a036020dfe86918 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 23 Oct 2026 00:34:39 -0700 Subject: [PATCH 3/9] style: format range anchor test and python docstring Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EeyiEy5FWz3z44DYZVo7vU --- py/moq-rs/moq/_records.py | 7 ++++--- rs/moq-net/tests/integration/range_anchors.rs | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/py/moq-rs/moq/_records.py b/py/moq-rs/moq/_records.py index 37eaae20752..baaa51c789d 100644 --- a/py/moq-rs/moq/_records.py +++ b/py/moq-rs/moq/_records.py @@ -95,9 +95,10 @@ class Subscription: ``priority`` is in ``-128..=127``, higher first, and defaults to 0, the midpoint. ``max_delay`` is how far a non-latest group may fall behind before it is skipped, - ``None`` for moq-net's default of zero, which skips at once; it caps every range. ``ranges`` are the spans of the track to - deliver, ``None`` for everything ``max_delay`` still allows. ``order`` is which pending - group the publisher sends first, ``None`` for newest first. + ``None`` for moq-net's default of zero, which skips at once; it caps every range. + ``ranges`` are the spans of the track to deliver, ``None`` for everything ``max_delay`` + still allows. ``order`` is which pending group the publisher sends first, ``None`` for + newest first. """ priority: int = 0 diff --git a/rs/moq-net/tests/integration/range_anchors.rs b/rs/moq-net/tests/integration/range_anchors.rs index 8b4f9e3eedc..fde5e877ca7 100644 --- a/rs/moq-net/tests/integration/range_anchors.rs +++ b/rs/moq-net/tests/integration/range_anchors.rs @@ -47,7 +47,10 @@ async fn read(version: Option<&str>, range: Range) -> Result, Error> { let publisher = produce_origin(1); let broadcast = publisher.create_broadcast("room").unwrap(); let track = broadcast - .create_track("data", Info::default().with_timescale(Timescale::MILLI).with_max_age(FOREVER)) + .create_track( + "data", + Info::default().with_timescale(Timescale::MILLI).with_max_age(FOREVER), + ) .unwrap(); broadcast.announce(Default::default()).unwrap(); for sequence in 0..5 { @@ -105,7 +108,10 @@ fn from(start: Anchor) -> Range { #[moq_clock::test] async fn a_held_track_resolves_relative_and_time_starts() { assert_eq!(read(None, from(Anchor::Relative(2))).await.unwrap(), vec![2, 3, 4]); - assert_eq!(read(None, from(Anchor::Time(millis(2500)))).await.unwrap(), vec![2, 3, 4]); + assert_eq!( + read(None, from(Anchor::Time(millis(2500)))).await.unwrap(), + vec![2, 3, 4] + ); } /// Over a session, the anchors the wire cannot carry are refused, while the live and @@ -141,6 +147,10 @@ async fn a_received_copy_refuses_what_its_wire_drops() { let live = read(Some(version), Range::live()).await; assert_eq!(live.unwrap().last(), Some(&4), "{version}: live reads the latest group"); let oldest = read(Some(version), Range::oldest()).await; - assert_eq!(oldest.unwrap().last(), Some(&4), "{version}: oldest reads through the latest group"); + assert_eq!( + oldest.unwrap().last(), + Some(&4), + "{version}: oldest reads through the latest group" + ); } } From e504a230d5ed3eee37fe4dedcec44ce28f804bba Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Fri, 23 Oct 2026 01:06:06 -0700 Subject: [PATCH 4/9] test(interop): pass the Go client's optional max delay Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EeyiEy5FWz3z44DYZVo7vU --- test/interop/clients/go/main.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/interop/clients/go/main.go b/test/interop/clients/go/main.go index 1b988744e3f..9781655dd1b 100644 --- a/test/interop/clients/go/main.go +++ b/test/interop/clients/go/main.go @@ -44,6 +44,9 @@ const readChunk = 64 * 1024 // media.TrackConsumer max delay: how much reordering the jitter buffer tolerates. const maxDelay = time.Second +// durationPtr is d as the optional duration the wrapper's options take. +func durationPtr(d time.Duration) *time.Duration { return &d } + // Synthetic audio: a 48 kHz tone per channel at 0.5 amplitude, encoded as Opus. const ( audioTrack = "tone" @@ -329,7 +332,7 @@ func finishSubscribe(ctx context.Context, client *moq.Client, broadcast string, for id, video = range catalog.Video { break } - media, err := moqmedia.NewTrackConsumer(ctx, consumer, moqmedia.TrackConfig{Rendition: moqmedia.VideoRendition(id, video), Subscription: &moq.Subscription{MaxDelay: maxDelay}}) + media, err := moqmedia.NewTrackConsumer(ctx, consumer, moqmedia.TrackConfig{Rendition: moqmedia.VideoRendition(id, video), Subscription: &moq.Subscription{MaxDelay: durationPtr(maxDelay)}}) if err != nil { return err } @@ -441,7 +444,7 @@ func finishSubscribe(ctx context.Context, client *moq.Client, broadcast string, func decodeAudio(ctx context.Context, consumer *moq.BroadcastConsumer, id string, rendition moqmedia.Audio, out string, audioMs int) error { decoder, err := moqaudio.Subscribe(ctx, consumer, id, rendition, moqaudio.DecoderOutput{ Format: moq.AudioSampleFormatF32, - MaxDelay: func() *time.Duration { d := maxDelay; return &d }(), + MaxDelay: durationPtr(maxDelay), }) if err != nil { return err @@ -535,7 +538,7 @@ func subscribe(ctx context.Context, url, broadcast string, opts dialOptions, tim break } - media, err := moqmedia.NewTrackConsumer(ctx, consumer, moqmedia.TrackConfig{Rendition: moqmedia.VideoRendition(id, video), Subscription: &moq.Subscription{MaxDelay: maxDelay}}) + media, err := moqmedia.NewTrackConsumer(ctx, consumer, moqmedia.TrackConfig{Rendition: moqmedia.VideoRendition(id, video), Subscription: &moq.Subscription{MaxDelay: durationPtr(maxDelay)}}) if err != nil { return err } From 4e443f77d3dabba37c611a3b1017553a6140b08a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 23 Oct 2026 09:20:20 -0700 Subject: [PATCH 5/9] fix(net): refuse only the range anchors a session's wire drops A lite-07 copy learns the largest and media time and asks for everything the budget allows, so it resolves relative and time anchors as its publisher would. Only copies received over lite-06 or earlier, or moq-transport, refuse them. The per-wire table in range_anchors.rs now covers both ends and the held track. Co-Authored-By: Claude Opus 5.5 --- dart/moq/MIGRATE.md | 7 +- dart/moq_ffi/MIGRATE.md | 7 +- doc/concept/moq-lite.md | 11 +-- go/wrapper/MIGRATE.md | 7 +- kt/moq/MIGRATE.md | 7 +- py/moq-ffi/MIGRATE.md | 7 +- py/moq-rs/MIGRATE.md | 7 +- quest/m1/subscribe-ranges/lite.md | 8 ++ rs/moq-c/MIGRATE.md | 7 +- rs/moq-ffi/MIGRATE.md | 7 +- rs/moq-net/MIGRATE.md | 7 +- rs/moq-net/src/lite/subscriber.rs | 3 + rs/moq-net/src/lite/version.rs | 7 ++ rs/moq-net/src/model/subscription.rs | 9 +- rs/moq-net/src/model/subscription/window.rs | 8 +- rs/moq-net/src/model/track.rs | 22 ++++- rs/moq-net/tests/integration/range_anchors.rs | 87 ++++++++++--------- swift/MIGRATE.md | 7 +- 18 files changed, 138 insertions(+), 87 deletions(-) diff --git a/dart/moq/MIGRATE.md b/dart/moq/MIGRATE.md index da75c450977..7d587653bf8 100644 --- a/dart/moq/MIGRATE.md +++ b/dart/moq/MIGRATE.md @@ -9,11 +9,12 @@ How to update your code for each breaking change, newest first. `Subscription.maxDelayUs` is `int?` and `Subscription.maxDelay` is `Duration?`, and `null` (the default) keeps moq-net's default of zero, which skips a superseded group at once. Explicit values are unchanged; code reading them back handles `null`. -### Relative and time ranges are refused over a session +### Relative and time ranges are refused over older wires -No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +A track received over moq-lite-06 or earlier, or any moq-transport version, used to resolve a relative or time range anchor against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. -Ask for absolute groups over a session, or resolve the anchor where the track is published. +A track received over moq-lite-07 resolves them as its publisher would. +Ask for absolute groups over those wires, or resolve the anchor where the track is published. ### Cancelling a stream cancels its pending read diff --git a/dart/moq_ffi/MIGRATE.md b/dart/moq_ffi/MIGRATE.md index c2f49f0b780..94363c38c48 100644 --- a/dart/moq_ffi/MIGRATE.md +++ b/dart/moq_ffi/MIGRATE.md @@ -9,11 +9,12 @@ How to update your code for each breaking change, newest first. `MoqSubscription.maxDelayUs` is `int?`, and `null` (the default) keeps moq-net's default of zero, which skips a superseded group at once. Explicit values are unchanged. -### Relative and time ranges are refused over a session +### Relative and time ranges are refused over older wires -No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +A track received over moq-lite-06 or earlier, or any moq-transport version, used to resolve a relative or time range anchor against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. -Ask for absolute groups over a session, or resolve the anchor where the track is published. +A track received over moq-lite-07 resolves them as its publisher would. +Ask for absolute groups over those wires, or resolve the anchor where the track is published. ### Native futures support operation cancellation diff --git a/doc/concept/moq-lite.md b/doc/concept/moq-lite.md index 00351d71087..60d07935d22 100644 --- a/doc/concept/moq-lite.md +++ b/doc/concept/moq-lite.md @@ -252,11 +252,12 @@ own ranges cover, resolved again whenever it replaces them, even when another subscriber of the same track asked for more. Widening them, including lowering the start, also serves the cached groups they newly cover, never one already served. A relay merges its subscribers' ranges into one upstream request, which -today's wire versions carry as the single span covering them. No wire version -carries a relative or time anchor yet, so beyond the live and default starts they -resolve only on the hop that publishes the track: a subscriber reading over a -session gets them refused as unsupported, and an untimed track refuses a time -anchor. At the live edge, a time end +today's wire versions carry 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 +reports the live edge and media time and asks upstream for every group the budget +allows. Over an older lite or any moq-transport version, a subscriber gets every +anchor but the live and default starts refused as unsupported, and an untimed +track refuses a time anchor. At the live edge, a time end may let one group through before its first frame shows it starts past the end: the first group that has yet to start is handed out without waiting for that frame, and the next one waits on it. A datagram is judged by its own timestamp. diff --git a/go/wrapper/MIGRATE.md b/go/wrapper/MIGRATE.md index 4055d6e6bfb..37ca4a221f6 100644 --- a/go/wrapper/MIGRATE.md +++ b/go/wrapper/MIGRATE.md @@ -9,11 +9,12 @@ How to update your code for each breaking change, newest first. `Subscription.MaxDelay` is `*time.Duration`, and `nil` keeps moq-net's default of zero, which skips a superseded group at once. Point it at the duration you set before. -### Relative and time ranges are refused over a session +### Relative and time ranges are refused over older wires -No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +A track received over moq-lite-06 or earlier, or any moq-transport version, used to resolve a relative or time range anchor against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. -Ask for absolute groups over a session, or resolve the anchor where the track is published. +A track received over moq-lite-07 resolves them as its publisher would. +Ask for absolute groups over those wires, or resolve the anchor where the track is published. ### A broadcast reference waits for its sibling's announcement (#6254) diff --git a/kt/moq/MIGRATE.md b/kt/moq/MIGRATE.md index e9b6813a92a..68bdcc8b995 100644 --- a/kt/moq/MIGRATE.md +++ b/kt/moq/MIGRATE.md @@ -9,11 +9,12 @@ How to update your code for each breaking change, newest first. `Subscription.maxDelayUs` is `ULong?` and `Subscription.maxDelay` is `Duration?`, and `null` (the default) keeps moq-net's default of zero, which skips a superseded group at once. Explicit values are unchanged; code reading them back handles `null`. -### Relative and time ranges are refused over a session +### Relative and time ranges are refused over older wires -No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +A track received over moq-lite-06 or earlier, or any moq-transport version, used to resolve a relative or time range anchor against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. -Ask for absolute groups over a session, or resolve the anchor where the track is published. +A track received over moq-lite-07 resolves them as its publisher would. +Ask for absolute groups over those wires, or resolve the anchor where the track is published. ### A broadcast reference waits for its sibling's announcement (#6254) diff --git a/py/moq-ffi/MIGRATE.md b/py/moq-ffi/MIGRATE.md index 838b8b02482..7b4534bd6e2 100644 --- a/py/moq-ffi/MIGRATE.md +++ b/py/moq-ffi/MIGRATE.md @@ -9,11 +9,12 @@ How to update your code for each breaking change, newest first. `MoqSubscription.max_delay_us` is `int | None`, and `None` (the default) keeps moq-net's default of zero, which skips a superseded group at once. Explicit values are unchanged. -### Relative and time ranges are refused over a session +### Relative and time ranges are refused over older wires -No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +A track received over moq-lite-06 or earlier, or any moq-transport version, used to resolve a relative or time range anchor against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. -Ask for absolute groups over a session, or resolve the anchor where the track is published. +A track received over moq-lite-07 resolves them as its publisher would. +Ask for absolute groups over those wires, or resolve the anchor where the track is published. ### A broadcast reference waits for its sibling's announcement (#6254) diff --git a/py/moq-rs/MIGRATE.md b/py/moq-rs/MIGRATE.md index a5d568a9817..2bb94d18eb5 100644 --- a/py/moq-rs/MIGRATE.md +++ b/py/moq-rs/MIGRATE.md @@ -9,11 +9,12 @@ How to update your code for each breaking change, newest first. `Subscription.max_delay` is `timedelta | None`, and `None` (the default) keeps moq-net's default of zero, which skips a superseded group at once. Explicit values are unchanged; code reading `max_delay` back handles `None`. -### Relative and time ranges are refused over a session +### Relative and time ranges are refused over older wires -No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +A track received over moq-lite-06 or earlier, or any moq-transport version, used to resolve a relative or time range anchor against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. -Ask for absolute groups over a session, or resolve the anchor where the track is published. +A track received over moq-lite-07 resolves them as its publisher would. +Ask for absolute groups over those wires, or resolve the anchor where the track is published. ### A broadcast reference waits for its sibling's announcement (#6254) diff --git a/quest/m1/subscribe-ranges/lite.md b/quest/m1/subscribe-ranges/lite.md index 6600a91b9ad..e87612bd4d1 100644 --- a/quest/m1/subscribe-ranges/lite.md +++ b/quest/m1/subscribe-ranges/lite.md @@ -35,6 +35,14 @@ that is the Largest Object's group, so a newest group with no objects yet is not counted until its first object arrives; the relay reports what it has rather than waiting for the peer. +Today a track copy received over lite-06 or earlier, or any moq-transport +draft, refuses relative and time anchors with `Unsupported`, while a lite-07 +copy resolves them locally (it learns the largest and media time and asks for +everything the budget allows; `lite::Version::resolves_anchors`). Each mapping +above that makes an older wire carry an anchor lifts that wire's refusal for +that anchor only, and extends the per-wire table in +`rs/moq-net/tests/integration/range_anchors.rs`. + Test the lite-05 relay case #5000 left out, on mock time beside `rs/moq-net/tests/integration/late_lower_group.rs`: a live subscriber already reading group 1, then one from `Absolute(0)`, and a fresh group 0 reaches only the diff --git a/rs/moq-c/MIGRATE.md b/rs/moq-c/MIGRATE.md index 54721550a7c..5c119bd6a0d 100644 --- a/rs/moq-c/MIGRATE.md +++ b/rs/moq-c/MIGRATE.md @@ -9,11 +9,12 @@ How to update your code for each breaking change, newest first. `moq_subscription.max_delay_us` is read only when the new `max_delay_present` is true, so it is optional: a zeroed struct keeps moq-net's default of zero, which skips a superseded group at once. Set `max_delay_present = true` wherever you set a nonzero `max_delay_us`. -### Relative and time ranges are refused over a session +### Relative and time ranges are refused over older wires -No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +A track received over moq-lite-06 or earlier, or any moq-transport version, used to resolve a relative or time range anchor against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. -Ask for absolute groups over a session, or resolve the anchor where the track is published. +A track received over moq-lite-07 resolves them as its publisher would. +Ask for absolute groups over those wires, or resolve the anchor where the track is published. ### A broadcast reference waits for its sibling's announcement (#6254) diff --git a/rs/moq-ffi/MIGRATE.md b/rs/moq-ffi/MIGRATE.md index a3563a77905..0ddbac68001 100644 --- a/rs/moq-ffi/MIGRATE.md +++ b/rs/moq-ffi/MIGRATE.md @@ -10,11 +10,12 @@ These are the UniFFI names; each language wrapper has its own `MIGRATE.md` in it `MoqSubscription.max_delay_us` is `Option`, and `None` (the default) keeps moq-net's default of zero, which skips a superseded group at once. Wrap an explicit value in `Some`. -### Relative and time ranges are refused over a session +### Relative and time ranges are refused over older wires -No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +A track received over moq-lite-06 or earlier, or any moq-transport version, used to resolve a relative or time range anchor against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. -Ask for absolute groups over a session, or resolve the anchor where the track is published. +A track received over moq-lite-07 resolves them as its publisher would. +Ask for absolute groups over those wires, or resolve the anchor where the track is published. ### A broadcast reference waits for its sibling's announcement (#6254) diff --git a/rs/moq-net/MIGRATE.md b/rs/moq-net/MIGRATE.md index 1f10cf60a90..534f1825d7e 100644 --- a/rs/moq-net/MIGRATE.md +++ b/rs/moq-net/MIGRATE.md @@ -4,11 +4,12 @@ How to update your code for each breaking change, newest first. ## Unreleased -### Relative and time ranges are refused over a session +### Relative and time ranges are refused over older wires -No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with `Error::Unsupported`. +A track received over moq-lite-06 or earlier, or any moq-transport version, used to resolve a relative or time range anchor against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with `Error::Unsupported`. This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. -Ask for absolute groups over a session, or resolve the anchor where the track is published. +A track received over moq-lite-07 resolves them as its publisher would. +Ask for absolute groups over those wires, or resolve the anchor where the track is published. ### `Subscriber::floor` and `next_in_range` honor `set_groups` diff --git a/rs/moq-net/src/lite/subscriber.rs b/rs/moq-net/src/lite/subscriber.rs index 0223d5735ae..b2e6532087f 100644 --- a/rs/moq-net/src/lite/subscriber.rs +++ b/rs/moq-net/src/lite/subscriber.rs @@ -7185,6 +7185,9 @@ impl ServeLoop { // Marked received before any reader sees it, so none resolves an anchor this wire dropped. let serving = request.stage(info); serving.received(); + if serve.subscriber.version.resolves_anchors() { + serving.anchored(); + } let serving = serving.commit(); Self { edge: serving.consume(), diff --git a/rs/moq-net/src/lite/version.rs b/rs/moq-net/src/lite/version.rs index df4d9307b0a..d7ba7c3a4e0 100644 --- a/rs/moq-net/src/lite/version.rs +++ b/rs/moq-net/src/lite/version.rs @@ -40,6 +40,13 @@ impl Version { } } + /// Whether a copy received over this version resolves relative and time range anchors + /// as its publisher would: the start resolves from the budget, the answer reports the + /// largest, and frames carry media time. Added in lite-07; an earlier copy refuses them. + pub(crate) fn resolves_anchors(self) -> bool { + self.resolves_start() && self.has_largest() && self.has_media_time() + } + /// Whether the version has lite-05's dedicated TRACK stream and related stream /// layout changes. /// diff --git a/rs/moq-net/src/model/subscription.rs b/rs/moq-net/src/model/subscription.rs index e36a0cfbf7a..c6fe1ea0f20 100644 --- a/rs/moq-net/src/model/subscription.rs +++ b/rs/moq-net/src/model/subscription.rs @@ -111,10 +111,11 @@ pub enum Order { /// and again whenever the subscriber replaces its ranges. Before any group exists a /// relative anchor resolves at the first one, so [`Range::live`] starts there. /// -/// No wire carries either upstream yet, beyond the live and oldest starts it spells with -/// no floor ([`Range::live`] and [`Range::oldest`]). A track copy received over a session -/// refuses any other relative or time anchor with [`Error::Unsupported`](crate::Error::Unsupported) -/// on read, rather than resolve it against the partial cache it holds. +/// Over a session, the copy resolves them only on moq-lite-07, which reports the live edge +/// and media time and asks upstream for every group the budget allows. A copy received +/// over an older lite or any moq-transport version refuses each other than [`Range::live`] +/// and [`Range::oldest`] with [`Error::Unsupported`](crate::Error::Unsupported) on read, +/// rather than resolve it against the part of the track it holds. #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Anchor { /// This exact position. diff --git a/rs/moq-net/src/model/subscription/window.rs b/rs/moq-net/src/model/subscription/window.rs index 8746d504df0..019ccdf77ac 100644 --- a/rs/moq-net/src/model/subscription/window.rs +++ b/rs/moq-net/src/model/subscription/window.rs @@ -27,9 +27,9 @@ pub(in crate::model) trait Holdings { /// Whether the track carries timestamps at all. fn timed(&self) -> bool; - /// Whether the groups are a copy received over a wire, which asks upstream only for - /// what [`Range::is_wire`] covers, so any other anchor can't resolve here. - fn received(&self) -> bool { + /// Whether the groups are a copy received over a wire that can't resolve relative or + /// time anchors as the publisher would, so only what [`Range::is_wire`] covers reads. + fn drops_anchors(&self) -> bool { false } @@ -538,7 +538,7 @@ impl Window { { return Err(Error::TimestampMismatch); } - if holdings.received() && !self.ranges.iter().all(Range::is_wire) { + if holdings.drops_anchors() && !self.ranges.iter().all(Range::is_wire) { return Err(Error::Unsupported); } self.spans.clear(); diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index 1a3dbab3811..5fd2b1e9180 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -446,9 +446,12 @@ pub(crate) struct TrackState { start_pending: bool, // A copy received from a remote publisher, whose declared end waits for groups still - // in flight below it (see `tail`), and whose readers' anchors resolve only as far as - // the wire carried them upstream (see `Holdings::received`). + // in flight below it (see `tail`), and whose readers' relative and time anchors are + // refused unless `anchored` (see `Holdings::drops_anchors`). received: bool, + // 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, // Sequences the upstream publisher gave up, with the error each was given up with: an // incoming SUBSCRIBE_DROP or a producer cut. Kept apart from the cache so reclaiming a // slot cannot erase a disposition a relay must forward, and as ranges so a wide DROP @@ -746,8 +749,8 @@ impl Holdings for TrackState { self.info.as_ref().is_none_or(|info| info.timescale.is_some()) } - fn received(&self) -> bool { - self.received + fn drops_anchors(&self) -> bool { + self.received && !self.anchored } fn containing(&self, pts: Timestamp) -> Containing { @@ -3007,12 +3010,23 @@ impl Producer { /// Mark this track as a copy received from a remote publisher, before writing to it. /// /// Its declared end waits for groups still in flight below it; see [`Self::finish_at`]. + /// Its readers' relative and time anchors, other than [`Range::live`](crate::track::Range::live) + /// and [`Range::oldest`](crate::track::Range::oldest), fail with [`Error::Unsupported`] + /// unless its session's wire lets it resolve them, since it holds only part of the track. pub fn received(&self) { if let Ok(mut state) = self.modify() { state.received = true; } } + /// Let this received copy's readers resolve relative and time anchors, for a wire that + /// reports the live edge and media time and asks for every group the budget allows. + pub(crate) fn anchored(&self) { + if let Ok(mut state) = self.modify() { + state.anchored = true; + } + } + /// Record that the publisher gave up `groups` with `err`: none will arrive, so a reader /// waiting on one moves past it, a group still arriving in them ends with `err`, the /// declared end does not wait for them, and a relay serving this track forwards the drop. diff --git a/rs/moq-net/tests/integration/range_anchors.rs b/rs/moq-net/tests/integration/range_anchors.rs index fde5e877ca7..90dad663011 100644 --- a/rs/moq-net/tests/integration/range_anchors.rs +++ b/rs/moq-net/tests/integration/range_anchors.rs @@ -1,14 +1,15 @@ #![cfg(feature = "async")] -//! A range starting relative to the latest group or at a presentation time resolves only -//! where the track is held. No wire carries such an anchor upstream yet, so a copy -//! received over a session refuses one instead of joining at the live edge. +//! 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. use crate::support; use std::time::Duration; -use moq_net::track::{Anchor, Info, Order, Range, Subscription}; +use moq_net::track::{Anchor, Info, Order, Position, Range, Subscription}; use moq_net::{Error, Hop, Timescale, Timestamp, Version}; use support::harness::peer; @@ -100,50 +101,56 @@ async fn read(version: Option<&str>, range: Range) -> Result, Error> { Ok(read) } -fn from(start: Anchor) -> Range { - Range { start, end: None } +fn range(start: Anchor, end: Option) -> Range { + Range { start, end } } -/// Where the track is held, both anchors resolve against its groups. -#[moq_clock::test] -async fn a_held_track_resolves_relative_and_time_starts() { - assert_eq!(read(None, from(Anchor::Relative(2))).await.unwrap(), vec![2, 3, 4]); - assert_eq!( - read(None, from(Anchor::Time(millis(2500)))).await.unwrap(), - vec![2, 3, 4] - ); +/// Relative and time anchors at each end, with what a reader of the held track reads. +fn anchored() -> [(Range, Vec); 6] { + let zero = Anchor::Absolute(Position::group(0)); + [ + (range(Anchor::Relative(2), None), vec![2, 3, 4]), + (range(Anchor::Time(millis(2500)), None), vec![2, 3, 4]), + (range(zero, Some(Anchor::Relative(1))), vec![0, 1, 2, 3]), + (range(zero, Some(Anchor::Time(millis(2500)))), vec![0, 1, 2]), + (range(Anchor::Relative(2), Some(Anchor::Relative(1))), vec![2, 3]), + ( + range(Anchor::Time(millis(1500)), Some(Anchor::Time(millis(3500)))), + vec![1, 2, 3], + ), + ] } -/// Over a session, the anchors the wire cannot carry are refused, while the live and -/// oldest starts it does carry still read. +/// Each wire resolves the anchors it carries as the held track does and refuses the rest, +/// rather than resolve them against the part of the track its copy happens to hold. #[moq_clock::test] -async fn a_received_copy_refuses_what_its_wire_drops() { - let refused = [ - from(Anchor::Relative(2)), - from(Anchor::Time(millis(2500))), - Range { - start: Anchor::Absolute(moq_net::track::Position::group(0)), - end: Some(Anchor::Relative(1)), - }, - Range { - start: Anchor::Absolute(moq_net::track::Position::group(0)), - end: Some(Anchor::Time(millis(2500))), - }, - ]; - for version in VERSIONS { - for range in refused { - let result = read(Some(version), range).await; - // A wire without timestamps refuses a time anchor for that first. - let timed = !matches!( - *version, - "moq-lite-03" | "moq-lite-04" | "moq-lite-05" | "moq-lite-06" | "moq-transport-14" | "moq-transport-16" - ); +async fn each_wire_refuses_only_the_anchors_it_drops() { + for version in std::iter::once(None).chain(VERSIONS.iter().copied().map(Some)) { + // Lite-07 reports the largest and media time and asks for everything the budget + // allows, so its copy resolves every anchor where it is held. + let carried = matches!(version, None | Some("moq-lite-07-wip")); + // A wire without timestamps refuses a time anchor for that first. + let timed = !matches!( + version, + Some("moq-lite-03" | "moq-lite-04" | "moq-lite-05" | "moq-lite-06" | "moq-transport-14" | "moq-transport-16") + ); + for (range, held) in anchored() { + let result = read(version, range).await; let time = matches!(range.start, Anchor::Time(_)) || matches!(range.end, Some(Anchor::Time(_))); - match (time && !timed, &result) { - (true, Err(Error::TimestampMismatch)) | (false, Err(Error::Unsupported)) => {} - _ => panic!("{version}: {range:?} read {result:?}"), + match (&result, time && !timed, carried) { + (Err(Error::TimestampMismatch), true, _) => {} + (Err(Error::Unsupported), false, false) => {} + (Ok(read), false, true) if *read == held => {} + _ => panic!("{version:?}: {range:?} read {result:?}"), } } + } +} + +/// Every wire carries the live and oldest starts, which it spells with no floor. +#[moq_clock::test] +async fn every_wire_carries_the_live_and_oldest_starts() { + for version in VERSIONS { let live = read(Some(version), Range::live()).await; assert_eq!(live.unwrap().last(), Some(&4), "{version}: live reads the latest group"); let oldest = read(Some(version), Range::oldest()).await; diff --git a/swift/MIGRATE.md b/swift/MIGRATE.md index 4d5449f02b3..9802e188254 100644 --- a/swift/MIGRATE.md +++ b/swift/MIGRATE.md @@ -9,11 +9,12 @@ How to update your code for each breaking change, newest first. `Subscription.maxDelayUs` is `UInt64?`, and `nil` (the default) keeps moq-net's default of zero, which skips a superseded group at once. Explicit values are unchanged; code reading it back unwraps it. -### Relative and time ranges are refused over a session +### Relative and time ranges are refused over older wires -No wire carries a relative or time range anchor upstream yet. A track received over a session used to resolve one against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +A track received over moq-lite-06 or earlier, or any moq-transport version, used to resolve a relative or time range anchor against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. -Ask for absolute groups over a session, or resolve the anchor where the track is published. +A track received over moq-lite-07 resolves them as its publisher would. +Ask for absolute groups over those wires, or resolve the anchor where the track is published. ### A broadcast reference waits for its sibling's announcement (#6254) From 5980d74dd04f0d025b858ab8d45d955f7c3d998a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 23 Oct 2026 10:35:02 -0700 Subject: [PATCH 6/9] chore(net): mark the anchored setter a capability gap and format Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/model/track.rs | 3 +++ rs/moq-net/tests/integration/range_anchors.rs | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index 5fd2b1e9180..3f2f55abde5 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -3021,6 +3021,9 @@ impl Producer { /// Let this received copy's readers resolve relative and time anchors, for a wire that /// reports the live edge and media time and asks for every group the budget allows. + /// Private with [`Self::report_largest`], which a custom subscriber needs first. + #[cfg_attr(not(feature = "async"), allow(dead_code))] + // private: capability gap pub(crate) fn anchored(&self) { if let Ok(mut state) = self.modify() { state.anchored = true; diff --git a/rs/moq-net/tests/integration/range_anchors.rs b/rs/moq-net/tests/integration/range_anchors.rs index 90dad663011..7a4dcb2fea5 100644 --- a/rs/moq-net/tests/integration/range_anchors.rs +++ b/rs/moq-net/tests/integration/range_anchors.rs @@ -132,7 +132,9 @@ async fn each_wire_refuses_only_the_anchors_it_drops() { // A wire without timestamps refuses a time anchor for that first. let timed = !matches!( version, - Some("moq-lite-03" | "moq-lite-04" | "moq-lite-05" | "moq-lite-06" | "moq-transport-14" | "moq-transport-16") + Some( + "moq-lite-03" | "moq-lite-04" | "moq-lite-05" | "moq-lite-06" | "moq-transport-14" | "moq-transport-16" + ) ); for (range, held) in anchored() { let result = read(version, range).await; From d6cba37e646f3360489f63d367dfb20799f0dce1 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 23 Oct 2026 13:27:58 -0700 Subject: [PATCH 7/9] docs(ffi): note the optional max delay and anchor refusal in the raw bindings Co-Authored-By: Claude Opus 5.5 --- cpp/moq/MIGRATE.md | 12 ++++++++++++ go/ffi/MIGRATE.md | 12 ++++++++++++ kt/moq-ffi/MIGRATE.md | 12 ++++++++++++ swift/ffi/MIGRATE.md | 12 ++++++++++++ 4 files changed, 48 insertions(+) diff --git a/cpp/moq/MIGRATE.md b/cpp/moq/MIGRATE.md index ed65c7f0dd6..649dc5266a4 100644 --- a/cpp/moq/MIGRATE.md +++ b/cpp/moq/MIGRATE.md @@ -4,6 +4,18 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Subscription max delay is optional + +`moq::Subscription::max_delay_us` is `std::optional`, and an empty value (the default) keeps moq-net's default of zero, which skips a superseded group at once. +Explicit values are unchanged; code reading it back checks `has_value()`. + +### Relative and time ranges are refused over older wires + +A track received over moq-lite-06 or earlier, or any moq-transport version, used to resolve a relative or time range anchor against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. +A track received over moq-lite-07 resolves them as its publisher would. +Ask for absolute groups over those wires, or resolve the anchor where the track is published. + ### `announce` takes an `AnnounceRoute` `BroadcastProducer::announce` takes `moq::AnnounceRoute{cost, epoch}` instead of a `moq::Route`: the origin builds the hop chain, so `hops` is no longer an input. diff --git a/go/ffi/MIGRATE.md b/go/ffi/MIGRATE.md index 325b963e8c5..227548096b5 100644 --- a/go/ffi/MIGRATE.md +++ b/go/ffi/MIGRATE.md @@ -4,6 +4,18 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Subscription max delay is optional + +`MoqSubscription.MaxDelayUs` is `*uint64`, and `nil` keeps moq-net's default of zero, which skips a superseded group at once. +Point it at the value you set before, and regenerate the bindings for the changed checksums. + +### Relative and time ranges are refused over older wires + +A track received over moq-lite-06 or earlier, or any moq-transport version, used to resolve a relative or time range anchor against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. +A track received over moq-lite-07 resolves them as its publisher would. +Ask for absolute groups over those wires, or resolve the anchor where the track is published. + ### `announce` takes a `MoqAnnounceRoute` `MoqBroadcastProducer.announce` takes `MoqAnnounceRoute` (`cost`, `epoch`) instead of a `MoqRoute`: the origin builds the hop chain, so `hops` is no longer an input. diff --git a/kt/moq-ffi/MIGRATE.md b/kt/moq-ffi/MIGRATE.md index 5b1d29aed88..2cfd8c8d9c0 100644 --- a/kt/moq-ffi/MIGRATE.md +++ b/kt/moq-ffi/MIGRATE.md @@ -4,6 +4,18 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Subscription max delay is optional + +`MoqSubscription.maxDelayUs` is `ULong?`, and `null` (the default) keeps moq-net's default of zero, which skips a superseded group at once. +Explicit values are unchanged; code reading it back handles `null`. + +### Relative and time ranges are refused over older wires + +A track received over moq-lite-06 or earlier, or any moq-transport version, used to resolve a relative or time range anchor against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. +A track received over moq-lite-07 resolves them as its publisher would. +Ask for absolute groups over those wires, or resolve the anchor where the track is published. + ### `announce` takes a `MoqAnnounceRoute` `MoqBroadcastProducer.announce` takes `MoqAnnounceRoute` (`cost`, `epoch`) instead of a `MoqRoute`: the origin builds the hop chain, so `hops` is no longer an input. diff --git a/swift/ffi/MIGRATE.md b/swift/ffi/MIGRATE.md index b71386a0365..142b5a0b77a 100644 --- a/swift/ffi/MIGRATE.md +++ b/swift/ffi/MIGRATE.md @@ -4,6 +4,18 @@ How to update your code for each breaking change, newest first. ## Unreleased +### Subscription max delay is optional + +`MoqSubscription.maxDelayUs` is `UInt64?`, and `nil` (the default) keeps moq-net's default of zero, which skips a superseded group at once. +Explicit values are unchanged; code reading it back unwraps it. + +### Relative and time ranges are refused over older wires + +A track received over moq-lite-06 or earlier, or any moq-transport version, used to resolve a relative or time range anchor against the groups it happened to hold, which silently read from the live edge or the wrong groups; reading it now fails with an unsupported error. +This covers a relative start other than the live (`0`) and oldest starts, a time start, and a relative or time end. +A track received over moq-lite-07 resolves them as its publisher would. +Ask for absolute groups over those wires, or resolve the anchor where the track is published. + ### `announce` takes a `MoqAnnounceRoute` `MoqBroadcastProducer.announce` takes `MoqAnnounceRoute` (`cost`, `epoch`) instead of a `MoqRoute`: the origin builds the hop chain, so `hops` is no longer an input. From 46c6599af7f02f89ed881931a59db546697fd01f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 23 Oct 2026 18:29:29 -0700 Subject: [PATCH 8/9] fix(net): a replaced copy's anchor refusal stays its own A front's reader returned the first copy's refusal, so a retained copy from an older wire failed a range the lite-07 copy serving now resolves. A replaced copy that refuses now ends; only the serving copy's refusal fails the read. Also drops the `// private:` mark main retired. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/model/resume.rs | 57 ++++++++++++++++++++++++++++++++-- rs/moq-net/src/model/track.rs | 2 -- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/rs/moq-net/src/model/resume.rs b/rs/moq-net/src/model/resume.rs index a9522eed197..129753834a5 100644 --- a/rs/moq-net/src/model/resume.rs +++ b/rs/moq-net/src/model/resume.rs @@ -1311,9 +1311,14 @@ impl Reader { } Poll::Ready(Ok(sub)) => sub, }; - // The reader's own ranges, which no copy of this route serves either. + // Each copy's wire decides what it resolves: a copy it replaced refusing the + // reader's ranges leaves the rest to the copy now serving. if let Some(err) = sub.refused() { - return Some(Poll::Ready(Err(err))); + if !copy.replaced { + return Some(Poll::Ready(Err(err))); + } + copy.done = Some(Err(err)); + break; } if ordered { sub.skip_ordered(floor); @@ -3972,6 +3977,54 @@ mod test { ); } + /// Each copy's wire decides which anchors it resolves: a replaced copy that refuses the + /// reader's ranges leaves them to the copy serving now, whose own refusal fails the read. + #[test] + #[cfg(feature = "async")] + fn only_the_serving_copy_refuses_an_anchor() { + let routes = Producer::new(); + let front = logical(&routes); + let a = copy(); + a.received(); + routes.serve(a.consume()); + let mut sub = subscribe(&front, Duration::from_secs(30)); + let mut zero = a.create_group(group::Info { sequence: 0 }).unwrap(); + zero.write_frame(ts(0), b"x".as_ref()).unwrap(); + assert_eq!(recv(&mut sub).sequence, 0); + + let b = copy(); + b.received(); + b.anchored(); + routes.serve(b.consume()); + let ranges = [track::Range { + start: track::Anchor::Relative(1), + end: None, + }]; + sub.update(sub.subscription().with_ranges(ranges)).unwrap(); + assert!(sub.recv_group().now_or_never().is_none()); + for sequence in 1..4 { + let mut group = b.create_group(group::Info { sequence }).unwrap(); + group.write_frame(ts(sequence * 1000), b"x".as_ref()).unwrap(); + group.finish().unwrap(); + } + // Asked before b held any group, the relative start resolves at its first. + let group = sub.recv_group().now_or_never().unwrap().unwrap().unwrap(); + assert_eq!(group.sequence, 1); + + // Served by a copy that can't resolve it, the same range fails. + let routes = Producer::new(); + let front = logical(&routes); + let a = copy(); + a.received(); + routes.serve(a.consume()); + let mut sub = subscribe(&front, Duration::from_secs(30)); + sub.update(sub.subscription().with_ranges(ranges)).unwrap(); + assert!(matches!( + sub.recv_group().now_or_never(), + Some(Err(Error::Unsupported)) + )); + } + /// Capping a replaced copy never replaces a time end it has not settled: the copy keeps /// filtering by time, so a group below the cap that starts past the end stays out. #[test] diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index e592c477645..d244e713580 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -3008,9 +3008,7 @@ impl Producer { /// Let this received copy's readers resolve relative and time anchors, for a wire that /// reports the live edge and media time and asks for every group the budget allows. - /// Private with [`Self::report_largest`], which a custom subscriber needs first. #[cfg_attr(not(feature = "async"), allow(dead_code))] - // private: capability gap pub(crate) fn anchored(&self) { if let Ok(mut state) = self.modify() { state.anchored = true; From 62cde36b777f7eea90eeae829984c6fafcfd6306 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 23 Oct 2026 18:31:58 -0700 Subject: [PATCH 9/9] style(net): format the serving-copy refusal test Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/model/resume.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rs/moq-net/src/model/resume.rs b/rs/moq-net/src/model/resume.rs index 129753834a5..49664c13a7a 100644 --- a/rs/moq-net/src/model/resume.rs +++ b/rs/moq-net/src/model/resume.rs @@ -4019,10 +4019,7 @@ mod test { routes.serve(a.consume()); let mut sub = subscribe(&front, Duration::from_secs(30)); sub.update(sub.subscription().with_ranges(ranges)).unwrap(); - assert!(matches!( - sub.recv_group().now_or_never(), - Some(Err(Error::Unsupported)) - )); + assert!(matches!(sub.recv_group().now_or_never(), Some(Err(Error::Unsupported)))); } /// Capping a replaced copy never replaces a time end it has not settled: the copy keeps