From ea8d2364f1627d0c8a4bf21a23fde42c372a10fc Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 8 Oct 2026 16:30:00 -0700 Subject: [PATCH 1/2] quest: claim m0/ietf-end-of-group-status Co-Authored-By: Claude Opus 5.5 From fc5e0e829ebbe1d3b9517d70f8cfe3e068008e55 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 8 Oct 2026 17:08:43 -0700 Subject: [PATCH 2/2] fix(net): accept an End of Group status on a marked subgroup stream The END_OF_GROUP header bit only lets a FIN imply the group's end; it does not forbid an explicit End of Group (0x3) status object. imquic sends both, and moq-net refused the stream as Unsupported, aborting the group and losing its last object. Accept the status either way in Rust and JS, as END_OF_TRACK already is. Co-Authored-By: Claude Opus 5.5 --- js/net/src/ietf/object.ts | 5 ++- js/net/src/ietf/subscriber.test.ts | 28 +++++++++++++++ quest/m0/README.md | 1 - quest/m0/ietf-end-of-group-status.md | 30 ---------------- quest/m1/papercuts-js.md | 6 ---- rs/moq-net/src/ietf/subscriber.rs | 51 +++++++++++++++++++++++----- 6 files changed, 75 insertions(+), 46 deletions(-) delete mode 100644 quest/m0/ietf-end-of-group-status.md diff --git a/js/net/src/ietf/object.ts b/js/net/src/ietf/object.ts index 84ade416538..6b6c36af850 100644 --- a/js/net/src/ietf/object.ts +++ b/js/net/src/ietf/object.ts @@ -367,11 +367,14 @@ export class Frame { // Defined on every implemented draft, whether or not the header marks the group's end. if (status === END_OF_TRACK) return new Frame({ endOfTrack: true }); + // Allowed even when the header marks the group's end: that bit only lets a FIN imply it, + // and imquic sends both. + if (status === GROUP_END) return new Frame(); if (flags.hasEnd) { // Empty frame if (status === 0) return new Frame({ payload: new Uint8Array(0), timestamp }); - } else if (status === 0 || status === GROUP_END) { + } else if (status === 0) { // TODO status === 0 should be an empty frame, but moq-rs seems to be sending it incorrectly on group end. return new Frame(); } diff --git a/js/net/src/ietf/subscriber.test.ts b/js/net/src/ietf/subscriber.test.ts index e67b56d016a..537cf47702e 100644 --- a/js/net/src/ietf/subscriber.test.ts +++ b/js/net/src/ietf/subscriber.test.ts @@ -1370,6 +1370,34 @@ test("a clear FIRST_OBJECT at object 0 is the whole group", async () => { track.close(); }); +/** + * The END_OF_GROUP header bit only lets a FIN imply the group's end, so an explicit + * END_OF_GROUP status on the same stream ends the group there rather than failing it. + */ +test("an END_OF_GROUP status on a marked stream finishes the group", async () => { + const { subscriber, track } = await subscribeTrack(); + + const flags = groupFlags(true); + expect(flags.hasEnd).toBe(true); + // Objects 0..4, then object 5 as a zero-length END_OF_GROUP (0x3) status. + const objects = new Uint8Array([...encodeObjects([0, 0, 0, 0, 0]), 0, 0, 0x3]); + await subscriber.handleGroup( + new GroupMessage({ trackAlias: ALIAS, groupId: 3, subGroupId: 0, publisherPriority: 0, flags }), + new Reader(undefined, objects, VERSION), + ); + + const group = await track.ordered().nextGroup(); + expect(group?.sequence).toBe(3); + if (!group) return; + for (let i = 0; i < 5; i++) { + expect(await group.readString()).toBe("object 0"); + } + expect(await group.readFrame()).toBeUndefined(); + expect(await group.closed).toBeNull(); + + track.close(); +}); + /** * A clear FIRST_OBJECT whose first ID is not 0 still has a hole at the front, so the * stream is dropped and the track resumes at the next group. diff --git a/quest/m0/README.md b/quest/m0/README.md index 1a36af68210..c786f772a0a 100644 --- a/quest/m0/README.md +++ b/quest/m0/README.md @@ -65,7 +65,6 @@ remain and no release waits on them. - [Draft-22 LOCATION_FILTER](/quest/m0/ietf-location-filter-22.md) - moqt-22 LOCATION_FILTER carries its type instead of a Length in Rust and JS, so a draft-22 peer reads our Next Object correctly - [Draft-22 media on 0.17](/quest/m0/release-22/README.md) - a 0.17.x with the LOCATION_FILTER and FIRST_OBJECT fixes and moq-noq 1.3.4, before Seattle - [Capped stream END_OF_GROUP](/quest/m0/ietf-end-of-track-location.md) - a stream capped by the subscription's end Location never claims END_OF_GROUP; moving End of Track's Location is deferred -- [End of Group status](/quest/m0/ietf-end-of-group-status.md) - an End of Group status on a stream whose header already marks the group's end is accepted, so imquic's last object per group arrives - [Demand lost wake](/quest/m0/demand-lost-wake.md) - a reader that comes and goes between a demand poll and its re-read never leaves a front or `broadcast::Demand` without a wake - [FFI publisher stall](/quest/m0/ffi-publisher-stall.md) - every Go and Python publisher cell passes reliably once the serve budget lands, and a cell fails when a connection idles out - [web-transport releases the qmux fixes](/quest/m0/qmux-credit-upstream.md) - waiting on moq-dev/web-transport#412 and #413 to merge and ship, which qmux credit bumps to diff --git a/quest/m0/ietf-end-of-group-status.md b/quest/m0/ietf-end-of-group-status.md deleted file mode 100644 index b7abe86220a..00000000000 --- a/quest/m0/ietf-end-of-group-status.md +++ /dev/null @@ -1,30 +0,0 @@ -# [XS] End of Group status on a marked stream - -## Goal - -`rs/moq-net` and `js/net` accept an End of Group status object (0x3) on a -subgroup stream whose header sets the END_OF_GROUP bit, and end the group -there, instead of refusing the stream. imquic sends both on d16, d18 and -d21, and moq-dev loses each group's last object today. - -## Plan - -Triaged from Fastly's follow-up on #5020 (#issuecomment-6046932019, runs of -2026-10-07 on `0f310a5`). d16 ยง10.4.2 says the bit only lets a subscriber -infer the group's end at FIN, and nothing forbids sending the status too. - -Where it lives: the `IngestPhase::Status` arm in -`rs/moq-net/src/ietf/subscriber.rs` accepts 0x3 only when `!self.has_end` and otherwise -returns `Unsupported`, which aborts the local group producer (`recv_group` -then returns `Ok`, so the session is not stopped). A downstream reader only -gets the rest of the group if the model's fetch path recovers it. Accept the -status either way, as END_OF_TRACK already is. Check the matching status parse in `js/net/src/ietf/object.ts`. - -Test: a d18 stream with the END_OF_GROUP bit, objects 0..4, then a 0x3 -status at 5 delivers a finished group with five frames. - -Public API: none. Wire: none. - -## Related - -- [JS papercuts](/quest/m1/papercuts-js.md) - edits the same status branch in `js/net/src/ietf/object.ts`; whichever lands second rebases diff --git a/quest/m1/papercuts-js.md b/quest/m1/papercuts-js.md index 56a8e2cfbf4..c9660ed94df 100644 --- a/quest/m1/papercuts-js.md +++ b/quest/m1/papercuts-js.md @@ -28,15 +28,9 @@ regression test that fails without it: invalid value warns and falls back to the default, as `parseDelay` and `parseVisible` already do. -Decided 2026-10-08: [End of Group status](/quest/m0/ietf-end-of-group-status.md) -edits the same status branch in `Frame.decode`; it is m0 and lands first, so -this rebases onto it. - Public API: none. Wire: none. ## Related -- [End of Group status](/quest/m0/ietf-end-of-group-status.md) - the same `Frame.decode` status branch, landing first - - [Rust papercuts](/quest/m1/papercuts-rs.md) - the Rust half of the same audit - [Audio jitter target](/quest/m1/audio-jitter-target/README.md) - owns the audio ring and its backpressure diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index 6479900078f..0a236a6d4ab 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -3178,7 +3178,6 @@ where /// status for empty objects, and the streamed payload. struct GroupIngest { has_extensions: bool, - has_end: bool, timescale: Option, version: Version, prior_object: Option, @@ -3217,7 +3216,6 @@ impl GroupIngest { ) -> Self { Self { has_extensions: group.flags.has_extensions, - has_end: group.flags.has_end, timescale, version: subscriber.version, prior_object: None, @@ -4227,7 +4225,9 @@ impl GroupIngest { frame.finish()?; } self.phase = IngestPhase::Delta; - } else if status == END_OF_GROUP && !self.has_end { + } else if status == END_OF_GROUP { + // Allowed even when the header marks the group's end: that bit only + // lets a FIN imply it, and imquic sends both. self.phase = IngestPhase::Finished(Ended::Group); } else if status == END_OF_TRACK { // Defined on every implemented draft, whether or not the header marks @@ -7952,10 +7952,10 @@ mod stitch_tests { } } - /// Append an END_OF_TRACK object: delta 0, an empty payload, then its status. - fn end_of_track(mut stream: Vec) -> Vec { + /// Append a status object such as END_OF_TRACK: delta 0, an empty payload, then its status. + fn end_marker(mut stream: Vec, status: u64) -> Vec { // The id delta, an empty extension block, a zero size, and the status. - for value in [0u64, 0, 0, END_OF_TRACK] { + for value in [0u64, 0, 0, status] { crate::coding::Encoder::new(&mut stream, VERSION.into()) .varint(value) .unwrap(); @@ -8029,7 +8029,10 @@ mod stitch_tests { /// END_OF_TRACK after a group's last object ends the track right after that group. #[moq_net_sim::test] async fn an_end_of_track_after_a_group_ends_the_track_after_it() { - let h = Harness::new(Fill::Done, vec![end_of_track(tail_stream(SEQUENCE, 0, &[b"last"]))]); + let h = Harness::new( + Fill::Done, + vec![end_marker(tail_stream(SEQUENCE, 0, &[b"last"]), END_OF_TRACK)], + ); let mut consumer = h.track.subscribe(None); let mut stream = h.stream().await; @@ -8064,7 +8067,10 @@ mod stitch_tests { /// and no group is created for it. #[moq_net_sim::test] async fn an_end_of_track_at_object_zero_creates_no_group() { - let h = Harness::new(Fill::Done, vec![end_of_track(tail_stream(SEQUENCE, 0, &[]))]); + let h = Harness::new( + Fill::Done, + vec![end_marker(tail_stream(SEQUENCE, 0, &[]), END_OF_TRACK)], + ); let mut stream = h.stream().await; h.subscriber.clone().recv_group(&mut stream).await.unwrap(); @@ -8364,6 +8370,35 @@ mod stitch_tests { assert_eq!(frames[1].1, b"next"); } + /// The END_OF_GROUP header bit only lets a FIN imply the group's end, so an explicit + /// END_OF_GROUP status on the same stream ends the group there rather than failing it. + #[moq_net_sim::test] + async fn an_end_of_group_status_on_a_marked_stream_finishes_the_group() { + use futures::FutureExt; + + let payloads: [&[u8]; 5] = [b"o0", b"o1", b"o2", b"o3", b"o4"]; + let bytes = end_marker(draft18_subgroup(SEQUENCE, true, 0, &payloads), END_OF_GROUP); + let flags = ietf::GroupFlags::decode(u64::from(bytes[0]), Version::Draft18).unwrap(); + assert!(flags.has_end, "the header marks the group's end"); + + let mut h = Harness::new(Fill::Done, vec![bytes]); + h.subscriber.version = Version::Draft18; + let mut consumer = h.track.subscribe(None); + let mut stream = read_draft18(&h.session).await; + + h.subscriber.clone().recv_group(&mut stream).await.expect("the group"); + + // The stream was read to its end, so everything is already delivered. + let mut group = consumer.recv_group().now_or_never().unwrap().unwrap().unwrap(); + assert_eq!(group.sequence, SEQUENCE); + for payload in payloads { + let frame = group.read_frame().now_or_never().unwrap().unwrap().unwrap(); + assert_eq!(frame.payload.as_ref(), payload); + } + let end = group.read_frame().now_or_never().expect("the group is closed"); + assert!(matches!(end, Ok(None)), "the group is finished, not aborted: {end:?}"); + } + /// A clear FIRST_OBJECT whose first ID is not 0 still has a hole at the front, so /// the stream is dropped and the track resumes at the next group. #[moq_net_sim::test]