From d80c893182d38a08d6f6669e71692a740cdad737 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 01:57:42 -0700 Subject: [PATCH 1/4] chore(quest): claim quest/m1/ietf-fetch-end-location.md Quest-Claim: 153fd45bc4bedc3d From 0e77179579e161c51d8398ba5a62641dbbcbdf0a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 02:19:48 -0700 Subject: [PATCH 2/4] fix(net): align whole-group IETF FETCH end locations Co-Authored-By: GPT-6 --- doc/concept/standard.md | 2 +- drafts/draft-lcurley-moq-ietf.md | 5 ++ js/net/src/ietf/fetch.ts | 5 +- js/net/src/ietf/ietf.test.ts | 36 +++++++++++++ quest/m1/ietf-fetch-end-location.md | 25 +++++++++ rs/moq-net/MIGRATE.md | 7 +++ rs/moq-net/src/ietf/fetch.rs | 2 + rs/moq-net/src/ietf/publisher.rs | 70 +++++++++++++++++------- rs/moq-net/src/ietf/subscriber.rs | 82 ++++++++++++++++++++--------- 9 files changed, 188 insertions(+), 46 deletions(-) diff --git a/doc/concept/standard.md b/doc/concept/standard.md index b84c326c9c7..5f3a8d1b845 100644 --- a/doc/concept/standard.md +++ b/doc/concept/standard.md @@ -27,7 +27,7 @@ subset drops. What a peer actually observes against this implementation: - **Pull.** Subscribers ask. Single-track `PUBLISH` offers are declined; announce a namespace and serve the resulting subscriptions. Announcements go out unsolicited, and we also ask for every prefix we may discover. The solicit `SETUP` option makes us wait to be asked. Without it, a draft 16+ peer also gets each match as a `NAMESPACE` on its `SUBSCRIBE_NAMESPACE` stream, so it hears the namespace twice. We send `PUBLISH` only to answer a `SUBSCRIBE_TRACKS` (below): on drafts 16 and 17 a `SUBSCRIBE_NAMESPACE` asking only for `PUBLISH` is refused, one asking for both gets only `NAMESPACE`, and any other Subscribe Options value closes the session. - **`SUBSCRIBE_TRACKS` lists, it never pushes.** In Rust, on draft 18 and later, it lists every track of every broadcast under its prefix, later ones included. With `FORWARD=0`, each track gets a paused `PUBLISH` carrying its Track Properties, and an error `PUBLISH_DONE` once the track is no longer listed, never `TRACK_ENDED`, since the track may go on elsewhere. A `REQUEST_UPDATE` with `FORWARD=1` resumes one, served from the cache like a `SUBSCRIBE` with the update's filter and answered with `LARGEST_OBJECT`; `FORWARD=0` pauses it again. Each paused `PUBLISH` holds a subscription slot, and past the cap a track gets `PUBLISH_SKIPPED` (`PUBLISH_BLOCKED` on draft 18) instead. A listing that omits `FORWARD` or sets it to 1 asks for every track's objects: from draft 19 each track gets `PUBLISH_SKIPPED`, and the subscriber `SUBSCRIBE`s to what it wants; draft 18 has no such skip, so the request is refused with `NOT_SUPPORTED`. A prefix overlapping another listing gets `PREFIX_OVERLAP`, a `TRACK_PROPERTY_FILTER` gets `NOT_SUPPORTED`, and a `REQUEST_UPDATE` on the listing itself ends it. On draft 18, a `SUBSCRIBE` to a track we `PUBLISH`ed gets `DUPLICATE_SUBSCRIPTION`. Cancelling the listing stops new `PUBLISH`es, while those sent live on. A broadcast is listed only while our publish grant covers it, from scratch once it does. A Rust relay does not yet send `SUBSCRIBE_TRACKS` upstream, and JavaScript refuses it with `NOT_SUPPORTED`. -- **History is one group.** In Rust, Object ID gaps must be marked by Prior Object ID Gap properties for a group to be fetchable. A `FETCH` returns one group from the cache, or on drafts 14 through 19 the saved prefix of the group a new subscription just joined. A range of groups is refused, as is a draft 20+ `LOCATION_FILTER` that ends at Largest Object rather than an absolute End Location. On draft 20 and later, `FETCH_OK`'s End Location is the requested end, capped at Largest Object: a range holding no objects gets an empty fetch stream, and only a start past Largest Object is refused, with `INVALID_RANGE`. A relay's copy with no upstream subscription can't know Largest Object short of the track's end, so it echoes the requested end instead. JavaScript publishing refuses every `FETCH`. Datagrams are never fetchable. A Rust reader that only fetches learns the track from `TRACK_STATUS` instead of subscribing, so a finished track stays fetchable; draft 17 still subscribes, since its `TRACK_STATUS` answer cannot say whether the track is timed, and so does a reader whose publisher refuses `TRACK_STATUS` as `NOT_SUPPORTED`. +- **History is one group.** In Rust, Object ID gaps must be marked by Prior Object ID Gap properties for a group to be fetchable. A `FETCH` returns one group from the cache, or on drafts 14 through 19 the saved prefix of the group a new subscription just joined. A range of groups is refused, as is a draft 20+ `LOCATION_FILTER` that ends at Largest Object rather than an absolute End Location. On drafts 14 through 19, `FETCH_OK` End Object 0 covers the entire End Group, matching the request; Rust also accepts the legacy answer naming the next group with Object 0. On draft 20 and later, `FETCH_OK`'s End Location is the requested end, capped at Largest Object: a range holding no objects gets an empty fetch stream, and only a start past Largest Object is refused, with `INVALID_RANGE`. A relay's copy with no upstream subscription can't know Largest Object short of the track's end, so it echoes the requested end instead. JavaScript publishing refuses every `FETCH`. Datagrams are never fetchable. A Rust reader that only fetches learns the track from `TRACK_STATUS` instead of subscribing, so a finished track stays fetchable; draft 17 still subscribes, since its `TRACK_STATUS` answer cannot say whether the track is timed, and so does a reader whose publisher refuses `TRACK_STATUS` as `NOT_SUPPORTED`. - **Timing.** A track whose `SUBSCRIBE_OK` declares no `TIMESCALE` is untimed, as is every track on drafts 14 through 16. A Rust reader that never subscribed takes the units from `TRACK_STATUS` on draft 18 and later. - **Strict SETUP and parameters.** Repeated unknown `SETUP` options, GREASE included, are accepted if well-formed; a repeated known option is rejected. On draft 17 and later, a `GROUP_ORDER` other than Ascending (1) or Descending (2) closes the session. Message parameters follow the negotiated draft's lists: drafts 14 and 15 ignore an unknown or misplaced parameter, draft 16 ignores one defined only for another message but closes the session on an unknown one, and draft 17 and later close it on both. Other malformed control input closes the session with the draft's code too, such as a server `SETUP` carrying `PATH` or `AUTHORITY`, a request cut short by FIN, or a second `GOAWAY` on one stream; a first `GOAWAY` on a request stream is legal. - **One `SETUP` credential**, forwarded to the [auth server](/bin/relay/auth#the-contract) unverified. A second `SETUP` token closes the session. We advertise no token cache, so an alias reference in `SETUP` closes it with `PROTOCOL_VIOLATION`, one on a request with `UNKNOWN_AUTH_TOKEN_ALIAS`, and a registration on a request with `AUTH_TOKEN_CACHE_OVERFLOW`. Where the Rust side authorizes the peer or verifies tokens, a token on a `SUBSCRIBE` or `PUBLISH_NAMESPACE` is verified like an in-band session token and authorizes that one request alone, even where that authorization already covers it; it never widens the session. It is refused with `NOT_SUPPORTED` when nothing verifies it, when it is empty, or when its Token Type is anything but 0 (out of band). A side that does neither, JavaScript included, ignores the token. Rust refuses a request carrying more than one distinct token with `NOT_SUPPORTED`, since it verifies one; JavaScript, which verifies none, ignores them all. A token-authorized `SUBSCRIBE` still stays within the grant the peer gave us. A token-authorized `PUBLISH_NAMESPACE` needs a grant covering everything beneath the namespace, and the tracks we subscribe under it rely on that announce instead of our limit, ending with it. An update renews the token, except on a drafts 14 and 15 `PUBLISH_NAMESPACE`, which has no update, and a refused renewal ends only that request. Rust and JavaScript send the token a route names (`Route::auth`) on its `PUBLISH_NAMESPACE`, including the one drafts 14 and 15 answer a solicited `SUBSCRIBE_NAMESPACE` with, and swapping it renews the request with `REQUEST_UPDATE` from draft 16, or ends and re-sends it before; the inline `NAMESPACE` that answers a solicited `SUBSCRIBE_NAMESPACE` from draft 16 carries no token. The token belongs to the session that added it, so a reconnect means adding it again and re-announcing. A token on any other request is decoded and grants nothing, and a request repeating one is refused with `MALFORMED_AUTH_TOKEN`. JavaScript's `SUBSCRIBE_TRACKS` reads its namespace before refusal; its token is not decoded. On draft 17 and later, the negotiated [MoQ Auth extension](/concept/moq-lite#authorization) accepts additional session tokens in band. diff --git a/drafts/draft-lcurley-moq-ietf.md b/drafts/draft-lcurley-moq-ietf.md index ac7b0680e59..a082b71fb24 100644 --- a/drafts/draft-lcurley-moq-ietf.md +++ b/drafts/draft-lcurley-moq-ietf.md @@ -99,6 +99,10 @@ A stream that stops at an end frame carries no END_OF_GROUP record, even when th Only subgroup 0 of a {{moqt}} group is carried. +When answering a whole-group FETCH on {{moqt}} drafts 14 through 19, a relay MUST name the fetched group with End Object 0 in FETCH_OK. +A receiver MUST treat that End Location as covering the whole group; it MAY also accept a legacy answer naming the next group with End Object 0 for the group it requested. +Draft 20 and later use an inclusive End Location instead. + ## Object Record ~~~ @@ -259,6 +263,7 @@ A high, distinctive value is used to avoid collisions with the low values {{moql ## Since draft-lcurley-moq-ietf-00 (in progress) - Initial version. +- Clarify whole-group FETCH_OK End Location mapping on MoQ Transport drafts 14 through 19. # Acknowledgments {:numbered="false"} diff --git a/js/net/src/ietf/fetch.ts b/js/net/src/ietf/fetch.ts index 398f1118571..72bc46435f0 100644 --- a/js/net/src/ietf/fetch.ts +++ b/js/net/src/ietf/fetch.ts @@ -92,7 +92,10 @@ export class Fetch { switch (fetchType) { case 0x1: // Standalone: namespace, name, start and end Locations trackNamespace = (await Namespace.decodeTrack(r)).namespace; - for (let i = 0; i < 4; i++) await r.u62(); + await r.u62(); // Start Group + await r.u62(); // Start Object + await r.u62(); // End Group, including its whole group when End Object is 0 + await r.u62(); // End Object: do not widen the whole-group form before refusal break; case 0x2: // Relative Joining: subscription, group offset case 0x3: // Absolute Joining: subscription, group diff --git a/js/net/src/ietf/ietf.test.ts b/js/net/src/ietf/ietf.test.ts index e3231756f45..c0f0608caff 100644 --- a/js/net/src/ietf/ietf.test.ts +++ b/js/net/src/ietf/ietf.test.ts @@ -2119,6 +2119,42 @@ test("Subscribe draft-22: Next Object is 0x21 0x05", async () => { expect(await encodeVersioned(msg, Version.DRAFT_22)).toEqual(body); }); +// The refusal decoder must consume a legal whole-group range at each wire's limit +// without widening End Group and overflowing it. JS still refuses all FETCH requests. +test("Fetch: a whole End Group at the numeric limit decodes for refusal", async () => { + for (const version of [ + Version.DRAFT_14, + Version.DRAFT_15, + Version.DRAFT_16, + Version.DRAFT_17, + Version.DRAFT_18, + Version.DRAFT_19, + ] as const) { + const legacy = version <= Version.DRAFT_16; + const maximum = legacy ? (1n << 62n) - 1n : (1n << 64n) - 1n; + const group = legacy ? Varint.encode(maximum) : Varint.encodeLeadingOnes(maximum); + const body = framed([ + 0x01, // Request ID + ...(version === Version.DRAFT_17 ? [0x00] : []), // Required Request ID Delta + ...(version === Version.DRAFT_14 ? [0x80, 0x01] : []), // Priority and order + 0x01, // Standalone + 0x01, + 0x04, + ...new TextEncoder().encode("live"), + 0x05, + ...new TextEncoder().encode("video"), + 0x00, + 0x02, // Start Group/Object + ...group, + 0x00, // The whole End Group + 0x00, // Parameters + ]); + const decoded = await decodeVersioned(body, Fetch.decode, version); + expect(decoded.requestId).toBe(1n); + expect(decoded.trackNamespace).toBe(Path.from("live")); + } +}); + // The tagged forms through draft-19, with a token. test("Fetch v15: decodes a joining FETCH", async () => { const body = framed([ diff --git a/quest/m1/ietf-fetch-end-location.md b/quest/m1/ietf-fetch-end-location.md index 48dcd05265a..fa669202b62 100644 --- a/quest/m1/ietf-fetch-end-location.md +++ b/quest/m1/ietf-fetch-end-location.md @@ -37,6 +37,31 @@ fixtures) with the whole-group reading, and add a subscriber case for a Document the pre-draft-20 FETCH_OK meaning next to the draft-20 line in `doc/concept/standard.md`. +The candidate implements all three sides and reproduces all three failures +before the fix. Whole-group and legacy FETCH_OK answers are tested with and +without End Of Track on drafts 14-19; drafts 20-22 retain inclusive answers. +The numeric-limit range test covers both a missing single group and an +unsupported multi-group request on every draft. JavaScript still refuses +FETCH, with decoder coverage for the maximum whole-group range. The migration +note, standard documentation and IETF extension draft are synchronized. + +Compatibility still needs confirmation. The versioned plan above excludes +released/current moq-net IETF pairings, while the repository asks for +published-wire compatibility. Also, `just test interop --all` runs the +in-tree language matrix, not moxygen. At upstream moxygen commit +`fcc97fc53d561f6ff4c654026824e2c47d55733e`, +[`MoQTestClient::validateFetchOk`](https://github.com/facebookexperimental/moxygen/blob/fcc97fc53d561f6ff4c654026824e2c47d55733e/moxygen/moqtest/MoQTestClient.cpp#L1201) +strictly compares the answer to +[`fetchEndLocation`](https://github.com/facebookexperimental/moxygen/blob/fcc97fc53d561f6ff4c654026824e2c47d55733e/moxygen/moqtest/Utils.cpp#L401), +which still widens whole-group Object 0 to the next group. For a draft-18 +track with groups 0-4 and objects 0-1, a request ending `{2,0}` sends bytes +`02 00`; the candidate replies `02 00`. Moxygen's parser and fetch handle +keep `{2,0}`, while its separate expectation helper produces `{3,0}`, so +moqtest marks a semantic failure. This is a validator conflict, not evidence +of a live FETCH delivery failure. Confirm the all-at-once compatibility exception for this +candidate, or choose a staged publisher rollout; do not claim the in-tree +matrix proves moxygen FETCH compatibility. The PR stays draft for that choice. + Public API: none. Wire: drafts 14 to 19 FETCH_OK End Location changes from `{g+1, 0}` to `{g, 0}` for a whole group. diff --git a/rs/moq-net/MIGRATE.md b/rs/moq-net/MIGRATE.md index c0be3ad9d98..02972fea574 100644 --- a/rs/moq-net/MIGRATE.md +++ b/rs/moq-net/MIGRATE.md @@ -4,6 +4,13 @@ How to update your code for each breaking change, newest first. ## Unreleased +### 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}`. +Readers accept both forms and set End Of Track to the sequence after the fetched group. +An older moq-net reader can reject the new answer; upgrade it before pairing it with a new publisher, or use draft 20 and later, whose inclusive End Location is unchanged. +No Rust API changes. + ### A dropped or cut group ends its reader with an error (#6143) A group the publisher cut, or named in `SUBSCRIBE_DROP`, after a `track::Subscriber` saw it is now handed out, and reading it fails with the publisher's error; before, it was skipped or ended cleanly. diff --git a/rs/moq-net/src/ietf/fetch.rs b/rs/moq-net/src/ietf/fetch.rs index aff3d5cb227..a38075bf727 100644 --- a/rs/moq-net/src/ietf/fetch.rs +++ b/rs/moq-net/src/ietf/fetch.rs @@ -328,6 +328,8 @@ pub struct FetchOk { pub request_id: Option, pub group_order: GroupOrder, pub end_of_track: bool, + /// Drafts 14-19 use the last object plus one, or Object 0 for the whole End Group; + /// draft 20 and later use an inclusive End Location. pub end_location: Location, /// The track's properties, as SUBSCRIBE_OK carries them: MAX_CACHE_DURATION from the /// draft-14/15 parameters, the Track Properties block from draft-16 on. diff --git a/rs/moq-net/src/ietf/publisher.rs b/rs/moq-net/src/ietf/publisher.rs index 3f98a8c421d..51bbab4197c 100644 --- a/rs/moq-net/src/ietf/publisher.rs +++ b/rs/moq-net/src/ietf/publisher.rs @@ -2390,16 +2390,14 @@ where .await; } - // An End Object of 0 asks for the whole End Group. - let end = match end.object { - 0 => end.group.checked_add(1).map(|group| Location { group, object: 0 }), - _ => Some(end), - }; - let Some(end) = end.filter(|end| (start.group, start.object) < (end.group, end.object)) else { + // End Object 0 includes the entire End Group, even at the largest Group ID. + if start.group > end.group + || (start.group == end.group && end.object != 0 && start.object >= end.object) + { return self .reject_fetch(stream, msg.request_id, &Error::InvalidRange, "empty range") .await; - }; + } // The peer must have seen the announcement to name this namespace, so this // resolves like a SUBSCRIBE does. @@ -2484,11 +2482,7 @@ where // One group per FETCH: on a relay, a range costs a serial upstream fetch per missing // group, all buffered until FETCH_OK. Ranges wait for upstream fills by range. - let last = match end.object { - 0 => end.group - 1, - _ => end.group, - }; - if start.group != last { + if start.group != end.group { return self .reject_fetch( stream, @@ -2605,9 +2599,9 @@ where } (end, false) } else { - // A group that ends the track ends the response at its last object; otherwise - // the response ends where it was asked to. - match end_of_track { + // Cap a bounded response at the track's last object. A whole-group response + // keeps Object 0 rather than claiming that the next group is covered. + match end_of_track && end.object > 0 { true => ( Location { group: group.sequence, @@ -2615,7 +2609,7 @@ where }, true, ), - false => (end, false), + false => (end, end_of_track), } }; // Draft-20's End Location is inclusive: the requested end, capped at Largest Object @@ -9741,8 +9735,8 @@ mod serve_tests { Version::Draft22, ]; - /// FETCH_OK's End Location for a response whose last object is `last`: one past it - /// before draft 20, and the object itself from then on. + /// A bounded FETCH_OK's End Location: one past `last` before draft 20, + /// and the object itself from then on. Whole-group answers use Object 0 before draft 20. fn end_location(version: Version, group: u64, last: u64) -> Location { let object = match Filter::is_draft20(version) { true => last, @@ -9943,7 +9937,7 @@ mod serve_tests { let (ok, objects) = fetch_answer(buf, version); let end = match Filter::is_draft20(version) { true => Location { group: 2, object: 1 }, - false => Location { group: 3, object: 0 }, + false => Location { group: 2, object: 0 }, }; assert_eq!(ok.end_location, end, "{version}"); assert!(!ok.end_of_track, "{version}"); @@ -10482,7 +10476,11 @@ mod serve_tests { ) .await; let (ok, objects) = fetch_answer(buf, version); - assert_eq!(ok.end_location, end_location(version, 4, 1), "{version}"); + let end = match Filter::is_draft20(version) { + true => end_location(version, 4, 1), + false => Location { group: 4, object: 0 }, + }; + assert_eq!(ok.end_location, end, "{version}"); assert!(ok.end_of_track, "{version}"); assert_eq!(objects, pairs([4])[1..].to_vec(), "{version}"); } @@ -10565,6 +10563,38 @@ mod serve_tests { } } + /// A whole End Group at the wire's limit is valid: a multi-group range is unsupported, + /// and a missing single group is not found. Drafts 14-16 cannot encode u64::MAX. + #[moq_clock::test] + async fn a_standalone_fetch_through_the_maximum_group_is_unsupported() { + for version in FETCH_DRAFTS { + let maximum = match version { + Version::Draft14 | Version::Draft15 | Version::Draft16 => (1 << 62) - 1, + _ => u64::MAX, + }; + let mut h = serve(version); + publish_pairs(&mut h, 1, None); + h.track.finish().unwrap(); + settle().await; + for (start, code) in [(0, 0x3), (maximum, does_not_exist(version))] { + let buf = standalone_fetch( + &h, + Location { + group: start, + object: 0, + }, + Location { + group: maximum, + object: 0, + }, + GroupOrder::Ascending, + ) + .await; + assert_eq!(fetch_refusal(buf, version), code, "{version}: start {start}"); + } + } + } + /// Read a REQUEST_ERROR (or draft-14 FETCH_ERROR) off a refused FETCH, as its code. fn fetch_refusal(wire: bytes::Bytes, version: Version) -> u64 { let mut buf = Decoder::new(&wire, version.into()); diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index 2c36057b310..1e28804191e 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -5034,7 +5034,7 @@ where } }; - // Draft-20's End Location is inclusive, so step one past it as older drafts spell it. + // Draft-20's End Location is inclusive; older drafts spell a bounded object one past it. let mut end = ok.end_location; if draft20 { let Some(object) = end.object.checked_add(1) else { @@ -5045,6 +5045,10 @@ where end.object = object; } + // Before draft-20, Object 0 covers the whole named group. Legacy answers one + // group past it still pass the exclusive comparison below. + let whole_group = !draft20 && end.group == sequence && end.object == 0; + // Draft-20's answer must cover its start within the requested group. Validate before // accepting the group or letting End of Track mark where the track ends. if draft20 && (end.group != sequence || end.object <= start) { @@ -5064,7 +5068,7 @@ where // The publisher knows where the track ends, which a range FETCH downstream needs. if ok.end_of_track { - let Some(final_sequence) = end.group.checked_add(u64::from(end.object > 0)) else { + let Some(final_sequence) = end.group.checked_add(u64::from(whole_group || end.object > 0)) else { request.reject(Error::ProtocolViolation); let _ = stream.writer.close().await; return; @@ -5073,14 +5077,14 @@ where } // Before draft-20, an empty answer opens no fetch stream at all. - if (end.group, end.object) <= (sequence, start) { + if !whole_group && (end.group, end.object) <= (sequence, start) { request.reject(Error::NotFound); let _ = stream.writer.close().await; return; } // An exclusive End Location inside the group bounds the stream; before draft-20 the - // stream also owes every object up to it. One past the group covers it whole. - let end = (end.group == sequence).then_some(end.object); + // stream also owes every object up to it. A whole-group answer has no object bound. + let end = (end.group == sequence && !whole_group).then_some(end.object); // Joined fetches still count until they pick the accepted group up from the cache. let joined = request.result.clone(); @@ -15663,7 +15667,7 @@ mod joining_fetch_tests { group_order: GroupOrder::Ascending, end_of_track: false, end_location: ietf::Location { - group: GROUP + 1, + group: GROUP, object: 0, }, properties: Default::default(), @@ -15839,7 +15843,7 @@ mod joining_fetch_tests { group_order: GroupOrder::Ascending, end_of_track: false, end_location: ietf::Location { - group: GROUP + 1, + group: GROUP, object: 0, }, properties: Default::default(), @@ -15896,7 +15900,7 @@ mod joining_fetch_tests { object: START - 1, }, ietf::Location { - group: GROUP + 1, + group: GROUP, object: 0, }, ] { @@ -15967,35 +15971,51 @@ mod joining_fetch_tests { /// numbers what arrives from there, so a publisher that evicted the prefix can answer. #[moq_clock::test] async fn a_group_fetch_asks_from_the_wanted_frame() { - for version in [Version::Draft19, Version::Draft20, Version::Draft22] { - group_fetch_from_frame(version).await; + for version in JOINING_DRAFTS + .into_iter() + .chain([Version::Draft20, Version::Draft21, Version::Draft22]) + { + for ended in [false, true] { + group_fetch_from_frame(version, false, ended).await; + } + } + } + + /// Legacy moxygen/cache answers one group past the requested group remain readable. + #[moq_clock::test] + async fn a_legacy_group_fetch_answer_still_covers_the_requested_group() { + for version in JOINING_DRAFTS { + for ended in [false, true] { + group_fetch_from_frame(version, true, ended).await; + } } } - async fn group_fetch_from_frame(version: Version) { + async fn group_fetch_from_frame(version: Version, legacy: bool, ended: bool) { const GROUP: u64 = 4; const START: u64 = 2; const LAST: u64 = START + 1; let draft20 = Filter::is_draft20(version); // The whole group, as each draft answers it: draft 20 names the last object, and - // older drafts one past the group. + // older drafts name the whole group with Object 0. let end_location = match draft20 { true => ietf::Location { group: GROUP, object: LAST, }, false => ietf::Location { - group: GROUP + 1, + group: GROUP + u64::from(legacy), object: 0, }, }; let ok = message_bytes( ietf::FetchOk::ID, &ietf::FetchOk { - request_id: None, + request_id: matches!(version, Version::Draft14 | Version::Draft15 | Version::Draft16) + .then_some(RequestId(1)), group_order: GroupOrder::Ascending, - end_of_track: false, + end_of_track: ended, end_location, properties: Default::default(), }, @@ -16014,15 +16034,24 @@ mod joining_fetch_tests { .unwrap(); for (index, payload) in [b"c", b"d"].iter().enumerate() { let first = index == 0; - ietf::FetchObject::Object { - subgroup: ietf::FetchSubgroup::Zero, - group: first.then_some(GROUP), - object: first.then_some(START), - priority: first.then_some(0), - properties: None, + if version == Version::Draft14 { + let w = &mut crate::coding::Encoder::new(&mut objects, version.into()); + w.varint(GROUP).unwrap(); + w.varint(0u64).unwrap(); // Subgroup + w.varint(START + index as u64).unwrap(); + w.u8(0); // Priority + w.varint(0u64).unwrap(); // Properties + } else { + ietf::FetchObject::Object { + subgroup: ietf::FetchSubgroup::Zero, + group: first.then_some(GROUP), + object: first.then_some(START), + priority: first.then_some(0), + properties: None, + } + .encode(&mut crate::coding::Encoder::new(&mut objects, version.into()), version) + .unwrap(); } - .encode(&mut crate::coding::Encoder::new(&mut objects, version.into()), version) - .unwrap(); crate::coding::Encoder::new(&mut objects, version.into()) .varint(1u64) .unwrap(); @@ -16067,9 +16096,14 @@ mod joining_fetch_tests { // The fetch stream, as the peer would open it. let (_, recv) = session.clone().open_bi(Default::default()).await.unwrap(); let mut stream = Reader::new(recv, version); - subscriber.clone().recv_fill(&mut stream).await.expect("group fetch"); + subscriber + .clone() + .recv_fill(&mut stream) + .await + .unwrap_or_else(|err| panic!("{version}: {err:?}")); serving.await.expect("run_group_fetch"); + assert_eq!(consumer.final_sequence(), ended.then_some(GROUP + 1)); let mut group = fetch.await.expect("fetched"); assert_eq!(group.index(), START, "the group starts where the reader wanted"); let mut payloads = Vec::new(); From 75dccc3f908b7e03a32fa8a54bcfcce2a9006064 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 14:37:19 -0700 Subject: [PATCH 3/4] chore(quest): retire ietf-fetch-end-location Co-Authored-By: Claude Opus 5.5 --- quest/m1/README.md | 1 - quest/m1/ietf-fetch-end-location.md | 70 ----------------------------- quest/m1/js-fetch.md | 1 - 3 files changed, 72 deletions(-) delete mode 100644 quest/m1/ietf-fetch-end-location.md diff --git a/quest/m1/README.md b/quest/m1/README.md index 8097ac7fddb..bc891a2bf44 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -105,7 +105,6 @@ tracks, so per-group stats stop costing cluster announces. - [More tests under load](/quest/m1/test-flakes-2/README.md) - the second round of load-only failures, one quest per flake, fixed at the cause - [A public model](/quest/m1/public-model/README.md) - every model item a built-in session reaches is public, unnecessary, or marked deliberately private, so a custom publisher, subscriber, or relay builds from the public model alone - [A smaller, safer API than release](/quest/m1/api-audit/README.md) - every surface added since release has a consumer or is gone, overlapping operations are collapsed, names mirror across Rust, JS, and the bindings, and every break has its MIGRATE entry -- [FETCH_OK whole group](/quest/m1/ietf-fetch-end-location.md) - on drafts 14 to 19, FETCH_OK End Object 0 means the whole group in both directions, and a FETCH ending at the maximum group is refused as unsupported - [JavaScript FETCH](/quest/m1/js-fetch.md) - browser publishers answer IETF FETCH through the JS ranges request surface - [IETF fill timeout](/quest/m1/ietf-fill-timeout.md) - native FILL_TIMEOUT bounds upstream waiting on drafts 18-22, alongside local content-age enforcement - [Rust identity enforcement](/quest/m1/catalog-identity-rs.md) - `moq-mux` refuses a redefined rendition, and every Rust publisher mints a new rendition name for a decoder identity change and updates everything else in place diff --git a/quest/m1/ietf-fetch-end-location.md b/quest/m1/ietf-fetch-end-location.md deleted file mode 100644 index fa669202b62..00000000000 --- a/quest/m1/ietf-fetch-end-location.md +++ /dev/null @@ -1,70 +0,0 @@ -# [S] FETCH_OK End Object 0 is the whole group - -## Goal - -On moq-transport drafts 14 to 19, moq-net reads and writes a FETCH_OK End -Location `{g, 0}` as all of group g, the same way it already writes the FETCH -request. A peer answering our whole-group FETCH with `{g, 0}` is served, not -refused, and a peer reading our answer no longer concludes that group g+1 does -not exist. A FETCH ending at `{2^64-1, 0}` gets the NOT_SUPPORTED that other -multi-group ranges get, on draft 17 and later, the drafts whose encoding can -carry it (14 to 16 cap a varint at `2^62-1`). - -## Plan - -Decided 2026-10-21 (maintainer): fix all three sides in one PR, on behavior -rather than on draft text. The request side already spells the whole group -`{g, 0}`, while FETCH_OK is written and read as exclusive `{g+1, 0}`, so one -message has two readings depending on direction. IETF pairings between our own -released and current builds are out of scope, so no staged rollout. - -- Subscriber (`rs/moq-net/src/ietf/subscriber.rs`, FETCH_OK handling): before - draft 20, End Object 0 means the whole End Group, so `{g, 0}` covers g and - End Of Track sets the final sequence to g+1. Keep accepting `{g+1, 0}`, - which moxygen's relay cache and moqtest send, as covering g. -- Publisher (`rs/moq-net/src/ietf/publisher.rs`, standalone FETCH range): - keep the request's wire form instead of widening `{g, 0}` to `{g+1, 0}`. - That removes the `checked_add(1)` overflow (which also reaches draft 20+ - through the Absolute filter rewrite) and the `end.group - 1` step. -- Publisher FETCH_OK: echo `{g, 0}` for a covered whole group. - -Tests: replace the `{g+1, 0}` pins (`a_standalone_fetch_serves_one_whole_group`, -the `end_location()` helper, and the subscriber's group-fetch and abandon -fixtures) with the whole-group reading, and add a subscriber case for a -`{g+1, 0}` answer and a publisher case for `{u64::MAX, 0}`. Run -`just test interop --all`; moxygen must still interoperate. - -Document the pre-draft-20 FETCH_OK meaning next to the draft-20 line in -`doc/concept/standard.md`. - -The candidate implements all three sides and reproduces all three failures -before the fix. Whole-group and legacy FETCH_OK answers are tested with and -without End Of Track on drafts 14-19; drafts 20-22 retain inclusive answers. -The numeric-limit range test covers both a missing single group and an -unsupported multi-group request on every draft. JavaScript still refuses -FETCH, with decoder coverage for the maximum whole-group range. The migration -note, standard documentation and IETF extension draft are synchronized. - -Compatibility still needs confirmation. The versioned plan above excludes -released/current moq-net IETF pairings, while the repository asks for -published-wire compatibility. Also, `just test interop --all` runs the -in-tree language matrix, not moxygen. At upstream moxygen commit -`fcc97fc53d561f6ff4c654026824e2c47d55733e`, -[`MoQTestClient::validateFetchOk`](https://github.com/facebookexperimental/moxygen/blob/fcc97fc53d561f6ff4c654026824e2c47d55733e/moxygen/moqtest/MoQTestClient.cpp#L1201) -strictly compares the answer to -[`fetchEndLocation`](https://github.com/facebookexperimental/moxygen/blob/fcc97fc53d561f6ff4c654026824e2c47d55733e/moxygen/moqtest/Utils.cpp#L401), -which still widens whole-group Object 0 to the next group. For a draft-18 -track with groups 0-4 and objects 0-1, a request ending `{2,0}` sends bytes -`02 00`; the candidate replies `02 00`. Moxygen's parser and fetch handle -keep `{2,0}`, while its separate expectation helper produces `{3,0}`, so -moqtest marks a semantic failure. This is a validator conflict, not evidence -of a live FETCH delivery failure. Confirm the all-at-once compatibility exception for this -candidate, or choose a staged publisher rollout; do not claim the in-tree -matrix proves moxygen FETCH compatibility. The PR stays draft for that choice. - -Public API: none. Wire: drafts 14 to 19 FETCH_OK End Location changes from -`{g+1, 0}` to `{g, 0}` for a whole group. - -## Closes - -- [#6199](https://github.com/moq-dev/moq/issues/6199) - FETCH_OK End Location Object 0 means the whole group diff --git a/quest/m1/js-fetch.md b/quest/m1/js-fetch.md index e9550f1e416..cd5c5024d02 100644 --- a/quest/m1/js-fetch.md +++ b/quest/m1/js-fetch.md @@ -40,7 +40,6 @@ claims that change. ## Required - [JS ranges](/quest/m1/subscribe-ranges/js.md) - the on-demand request surface this dispatches onto -- [FETCH_OK whole group](/quest/m1/ietf-fetch-end-location.md) - the Rust FETCH_OK contract this copies reads End Object 0 as the whole group first ## Related From 19d4a36a5b07fa354d2b6107dd6ce5d6690eebb1 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 14:38:08 -0700 Subject: [PATCH 4/4] fix(net): keep FETCH_OK end changes to the Rust moq-transport path The moq-ietf draft describes the moq-lite-07 relay extension, whose wire this change does not touch, and the JS FETCH decoder is unchanged. Co-Authored-By: Claude Opus 5.5 --- drafts/draft-lcurley-moq-ietf.md | 5 ----- js/net/src/ietf/fetch.ts | 5 +---- js/net/src/ietf/ietf.test.ts | 36 -------------------------------- 3 files changed, 1 insertion(+), 45 deletions(-) diff --git a/drafts/draft-lcurley-moq-ietf.md b/drafts/draft-lcurley-moq-ietf.md index a082b71fb24..ac7b0680e59 100644 --- a/drafts/draft-lcurley-moq-ietf.md +++ b/drafts/draft-lcurley-moq-ietf.md @@ -99,10 +99,6 @@ A stream that stops at an end frame carries no END_OF_GROUP record, even when th Only subgroup 0 of a {{moqt}} group is carried. -When answering a whole-group FETCH on {{moqt}} drafts 14 through 19, a relay MUST name the fetched group with End Object 0 in FETCH_OK. -A receiver MUST treat that End Location as covering the whole group; it MAY also accept a legacy answer naming the next group with End Object 0 for the group it requested. -Draft 20 and later use an inclusive End Location instead. - ## Object Record ~~~ @@ -263,7 +259,6 @@ A high, distinctive value is used to avoid collisions with the low values {{moql ## Since draft-lcurley-moq-ietf-00 (in progress) - Initial version. -- Clarify whole-group FETCH_OK End Location mapping on MoQ Transport drafts 14 through 19. # Acknowledgments {:numbered="false"} diff --git a/js/net/src/ietf/fetch.ts b/js/net/src/ietf/fetch.ts index 72bc46435f0..398f1118571 100644 --- a/js/net/src/ietf/fetch.ts +++ b/js/net/src/ietf/fetch.ts @@ -92,10 +92,7 @@ export class Fetch { switch (fetchType) { case 0x1: // Standalone: namespace, name, start and end Locations trackNamespace = (await Namespace.decodeTrack(r)).namespace; - await r.u62(); // Start Group - await r.u62(); // Start Object - await r.u62(); // End Group, including its whole group when End Object is 0 - await r.u62(); // End Object: do not widen the whole-group form before refusal + for (let i = 0; i < 4; i++) await r.u62(); break; case 0x2: // Relative Joining: subscription, group offset case 0x3: // Absolute Joining: subscription, group diff --git a/js/net/src/ietf/ietf.test.ts b/js/net/src/ietf/ietf.test.ts index c0f0608caff..e3231756f45 100644 --- a/js/net/src/ietf/ietf.test.ts +++ b/js/net/src/ietf/ietf.test.ts @@ -2119,42 +2119,6 @@ test("Subscribe draft-22: Next Object is 0x21 0x05", async () => { expect(await encodeVersioned(msg, Version.DRAFT_22)).toEqual(body); }); -// The refusal decoder must consume a legal whole-group range at each wire's limit -// without widening End Group and overflowing it. JS still refuses all FETCH requests. -test("Fetch: a whole End Group at the numeric limit decodes for refusal", async () => { - for (const version of [ - Version.DRAFT_14, - Version.DRAFT_15, - Version.DRAFT_16, - Version.DRAFT_17, - Version.DRAFT_18, - Version.DRAFT_19, - ] as const) { - const legacy = version <= Version.DRAFT_16; - const maximum = legacy ? (1n << 62n) - 1n : (1n << 64n) - 1n; - const group = legacy ? Varint.encode(maximum) : Varint.encodeLeadingOnes(maximum); - const body = framed([ - 0x01, // Request ID - ...(version === Version.DRAFT_17 ? [0x00] : []), // Required Request ID Delta - ...(version === Version.DRAFT_14 ? [0x80, 0x01] : []), // Priority and order - 0x01, // Standalone - 0x01, - 0x04, - ...new TextEncoder().encode("live"), - 0x05, - ...new TextEncoder().encode("video"), - 0x00, - 0x02, // Start Group/Object - ...group, - 0x00, // The whole End Group - 0x00, // Parameters - ]); - const decoded = await decodeVersioned(body, Fetch.decode, version); - expect(decoded.requestId).toBe(1n); - expect(decoded.trackNamespace).toBe(Path.from("live")); - } -}); - // The tagged forms through draft-19, with a token. test("Fetch v15: decodes a joining FETCH", async () => { const body = framed([