From b28cd333578b4ce3dd801f9d609e03c0ec48d1e9 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 16:03:05 -0700 Subject: [PATCH 1/8] fix(moq-net): a refused joining FETCH waits for the next group Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/ietf/subscriber.rs | 50 +++++++++++-------------------- 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index 0c0ba532556..bfd1fe066c4 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -3343,7 +3343,6 @@ where enum End { Idle, Revoked, - Unjoined(Error), Done(Result, Error>), Fetch(group::Request), Update(Update), @@ -3373,8 +3372,7 @@ where let answered_here = !matches!(self.version, Version::Draft14 | Version::Draft15); let mut fetch_done = fetching.is_none(); - // Our grant stopped covering the track, or its join failed: it is aborted rather than - // kept lingering. + // Our grant stopped covering the track: it is aborted rather than kept lingering. let mut failed = false; // How the upstream subscription ended, which ends a listing entry it held. let mut ended: Option> = None; @@ -3399,7 +3397,7 @@ where { fetch_done = true; if let Err(err) = res { - return Poll::Ready(End::Unjoined(err)); + tracing::debug!(%err, "joining FETCH failed, joining at the next whole group"); } } // An error is the track closing, which the arms below report. @@ -3496,13 +3494,6 @@ where ended = Some(Err(Error::Unauthorized)); break true; } - End::Unjoined(err) => { - tracing::debug!(%err, "joining FETCH failed"); - let _ = track.clone().abort(err.clone()); - failed = true; - ended = Some(Err(err)); - break true; - } End::Fetch(request) => { let fetch = self.clone().run_group_fetch( broadcast_path.to_owned(), @@ -3538,7 +3529,6 @@ where .subscribes .get(&request_id) .map(|held| (held.tail.consume(), held.fill.clone())); - let mut unjoined = None; if let Some((tail, fill)) = held { let mut settle = Settle::new(&self.runtime, tail); kio::wait(|waiter| { @@ -3548,8 +3538,7 @@ where { fetch_done = true; if let Err(err) = res { - unjoined = Some(err); - return Poll::Ready(()); + tracing::debug!(%err, "joining FETCH failed, joining at the next whole group"); } } poll_settled(&mut settle, waiter, &fill, count) @@ -3561,14 +3550,9 @@ where fill.end(); } } - if let Some(err) = unjoined { - tracing::debug!(%err, "joining FETCH failed"); - let _ = track.clone().abort(err); - } else { - // A no-op once an END_OF_TRACK declared the end, whose readers wait - // for a missing group only as long as the grace. - let _ = track.finish(); - } + // A no-op once an END_OF_TRACK declared the end, whose readers wait + // for a missing group only as long as the grace. + let _ = track.finish(); } Err(err) => { tracing::debug!(%err, "subscribe ended with error"); @@ -3632,7 +3616,7 @@ where }) .await; } - // A session abort took the copy too, and a revoked grant or a failed join ended it. + // A session abort took the copy too, and a revoked grant ended it. if aborted || failed { return None; } @@ -3876,7 +3860,8 @@ where /// it: a publisher serves one group per FETCH, so an earlier start's groups are left to /// group FETCHes of their own. The subscribe's request id names the FETCH. The data /// arrives on its own fetch stream and [`Self::recv_fill`] stitches it. A refusal or a - /// failed send is an error, since the head it owes is never coming. + /// failed send settles the fill as [`Fill::Done`], as a failed draft-20 fill does: only + /// a stream that starts mid-group is lost, and a whole group still stands alone. fn start_joining_fetch(&self, subscribe_id: RequestId, track: &track::Producer) -> Option { let fill = self.state.lock().subscribes.get(&subscribe_id)?.fill.clone(); let track = track.clone(); @@ -15846,10 +15831,12 @@ mod joining_fetch_tests { } } - /// The peer refusing the joining FETCH fails the subscription with its reason, rather - /// than leaving readers waiting on a head that is never coming. + /// A publisher that serves no FETCH refuses the joining FETCH. That costs the head of + /// the Largest group and nothing more, as a failed draft-20 fill does: the fill settles, + /// so a stream starting mid-group is dropped rather than parked, and the subscription + /// keeps delivering whole groups. #[moq_clock::test] - async fn a_refused_fetch_fails_the_subscription() { + async fn a_refused_fetch_joins_at_the_next_whole_group() { let largest = Some(ietf::Location { group: 4, object: 1 }); for version in JOINING_DRAFTS { let mut run = JoinRun::start(version, None, subscribe_ok(version, largest), fetch_error(version)).await; @@ -15858,13 +15845,10 @@ mod joining_fetch_tests { .expect("SUBSCRIBE_OK accepted the track") .unwrap(); assert!( - matches!(received.finished().now_or_never(), Some(Err(Error::Unsupported))), - "{version}" - ); - assert!( - run.subscriber.state.lock().subscribes.is_empty(), - "{version}: the subscription is cancelled upstream" + received.finished().now_or_never().is_none(), + "{version}: the track is still live" ); + assert!(!run.fill_outstanding(), "{version}: no head is coming"); } } From 4a495a3a0580e54fe8d1e5464e7bd9e10b172f49 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 16:12:26 -0700 Subject: [PATCH 2/8] quest: track the empty-tail join race; joining FETCH refusal no longer fails Co-Authored-By: Claude Opus 5.5 --- quest/m2/README.md | 1 + quest/m2/ietf-empty-tail-race.md | 35 ++++++++++++++++++++++++++++++ quest/m2/ietf-join-after-finish.md | 27 ++++++++++++----------- 3 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 quest/m2/ietf-empty-tail-race.md diff --git a/quest/m2/README.md b/quest/m2/README.md index 5608b7f99c0..607ec80ea9e 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -67,6 +67,7 @@ ranked just below deterministic TS legs, which it requires. - [Probe](/quest/m2/probe/README.md) - a session probes up to the bitrate it wants to send or receive, so a stopped simulcast rendition resumes and a viewer up-switches; the browser pads where native sessions retransmit - [Failed groups reach the publisher](/quest/m2/group-failed.md) - Rust and both JS publishers surface a group whose delivery a subscriber's stream gave up on, with one shape - [Headless moq-transport groups](/quest/m2/ietf-headless-group.md) - a group whose head no fill or joining FETCH supplies keeps its tail instead of being dropped, and a relay forwards it to moq-transport subscribers +- [Empty tail before its head](/quest/m2/ietf-empty-tail-race.md) - a pre-draft-20 joined group whose head lands after a clean PUBLISH_DONE is delivered whole, not empty - [A finished PROBE stops reporting](/quest/m2/probe-end-stale.md) - the Rust receive estimate reads unknown once its PROBE stream ends - [Wire stats](/quest/m2/wire-stats/README.md) - `Presence` counts each root's transport bytes on the wire, `wire_tx` and `wire_rx`, from QUIC, WebSocket, and embedder gateway sources - [Media stats](/quest/m2/stats/README.md) - publishers announce a stats track in the catalog, viewers answer a soliciting catalog through a per-catalog `.echo` broadcast, and one model turns both into a health verdict and a preflight report diff --git a/quest/m2/ietf-empty-tail-race.md b/quest/m2/ietf-empty-tail-race.md new file mode 100644 index 00000000000..c59daba6b64 --- /dev/null +++ b/quest/m2/ietf-empty-tail-race.md @@ -0,0 +1,35 @@ +# [S] An empty tail waits for a head still being written + +## Goal + +On drafts 14 to 19, a joined group whose head is still arriving on the +joining FETCH when a clean PUBLISH_DONE settles is delivered whole, never as +an empty group. `tail rust -> rust` on a pinned moq-transport pass stops +failing with "empty group". + +## Plan + +Seen once on draft 16 on 2026-10-22, while debugging +[moq-dev/moq#6407](https://github.com/moq-dev/moq/pull/6407). The relay +subscribed upstream with Largest at `{3, 0}`, so the joining FETCH carries +object 0 of group 3 and the subscription's stream for group 3 has no objects. +PUBLISH_DONE arrived 5 ms after SUBSCRIBE_OK, and the downstream reader got +group 3 with no frames. + +Suspected race in `rs/moq-net/src/ietf/subscriber.rs`: the empty tail stream +waits in `claim_fill` while the fill is `Fill::Active`. The settle after +PUBLISH_DONE calls `Fill::end`, which overwrites `Active` with `Ended`, so the +waiting tail sees no head, takes the `None` arm of `open_group`, and creates +group 3 empty. The head then lands on `Fill::Ended` and has no group left to +become. Reproduce it in a unit test first (both stream orders, mocked time), +then make the empty tail and the late head end the same way: the head is the +whole group. + +Public API: none. Wire: none. + +## Related + +- [Headless moq-transport groups](/quest/m2/ietf-headless-group.md) - the + mid-group stream with no head at all +- [Join after a quick finish](/quest/m2/ietf-join-after-finish.md) - the + joining FETCH that arrives after the subscription ended diff --git a/quest/m2/ietf-join-after-finish.md b/quest/m2/ietf-join-after-finish.md index 075167a9c1e..12ef223e0f7 100644 --- a/quest/m2/ietf-join-after-finish.md +++ b/quest/m2/ietf-join-after-finish.md @@ -5,31 +5,31 @@ On drafts 14 to 19, a joining FETCH that reaches our publisher after its subscription finished cleanly is still answered from the subscription's saved Largest group. A track that ends within about one RTT of SUBSCRIBE_OK -then finishes cleanly at the subscriber, head included, instead of failing. +then finishes cleanly at the subscriber, head included, instead of losing +its last group. What the publisher retains for this is bounded by design (the session, the subscription's request, or a limit the peer already negotiates), never by a timer constant. ## Plan -Starts after [moq-dev/moq#6348](https://github.com/moq-dev/moq/pull/6348) -merges (open on 2026-10-22). It makes every pre-draft-20 join a SUBSCRIBE -followed, after SUBSCRIBE_OK, by a `RelativeJoining{0}` FETCH, and fails the -subscription when that FETCH is refused. If it is abandoned, re-judge this -quest. +Every pre-draft-20 join is a SUBSCRIBE followed, after SUBSCRIBE_OK, by a +`RelativeJoining{0}` FETCH ([moq-dev/moq#6348](https://github.com/moq-dev/moq/pull/6348)). +A refused one costs the subscriber that group's head and nothing more +([moq-dev/moq#6407](https://github.com/moq-dev/moq/pull/6407), decided with +the maintainer on 2026-10-22): a stream starting mid-group is dropped and +the subscription goes on. State: `rs/moq-net/src/ietf/publisher.rs` registers a `Join` entry in `Publisher::joins` when it dispatches the SUBSCRIBE, fills it with a `Joined` snapshot as SUBSCRIBE_OK goes out, and drops it when the subscription ends, before PUBLISH_DONE. A joining FETCH that arrives later finds no entry, waits out the registration wait in `joined()`, and is refused as an unknown -subscription. Before #6348 the subscriber swallowed that refusal and lost the -head silently; after it, the subscriber errors. Short or already-finished -tracks hit this often. +subscription, so the subscriber loses the Largest group. Short or +already-finished tracks hit this often. -Fix it at the publisher. Accepting the refusal at the subscriber after a clean -PUBLISH_DONE would hide the lost head again, which is what #6348 fixed, and -other publishers may refuse the same way. +Fix it at the publisher: the subscriber cannot recover a head nobody serves, +and other publishers may refuse the same way. A finished entry holds a `track::Consumer`, which keeps the track's cache alive, so retaining it costs memory a peer controls. Candidate bounds: @@ -60,7 +60,8 @@ Tests, on mocked time with no sleeps, for each of drafts 14 to 19: - A track that finishes right after SUBSCRIBE_OK, with the joining FETCH delivered an RTT after PUBLISH_DONE: the FETCH returns the Largest group's - head and the subscriber's track finishes cleanly with it. Fails today. + head and the subscriber's track finishes cleanly with it. Today the FETCH + is refused and the group is lost. - More finished subscriptions than the limit with no FETCH: retained entries stay at the limit, the oldest are dropped, and their late FETCHes are refused. New subscriptions are still admitted. From cbc81e9b66f12113ef034176e0b046d60455507e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 16:22:37 -0700 Subject: [PATCH 3/8] quest: plan the JS publisher's joining FETCH Co-Authored-By: Claude Opus 5.5 --- quest/m2/README.md | 1 + quest/m2/ietf-join-after-finish.md | 1 + quest/m2/ietf-js-joining-fetch.md | 67 ++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 quest/m2/ietf-js-joining-fetch.md diff --git a/quest/m2/README.md b/quest/m2/README.md index 607ec80ea9e..20fdc64b344 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -218,6 +218,7 @@ ranked just below deterministic TS legs, which it requires. - [IETF request order](/quest/m2/ietf-request-order.md) - d14/15 requests take their ID after opening, legacy `control.sending()` races are gone, and SUBSCRIBE_NAMESPACE never closes over its own close - [JS IETF request streams](/quest/m2/js-request-stream.md) - `RequestStream` owns deadlines and cancellation, and TRACK trailing bytes close the session like Rust - [Join after a quick finish](/quest/m2/ietf-join-after-finish.md) - a pre-draft-20 joining FETCH that arrives after its subscription finished is still answered, within a bound the peer already negotiates +- [JS joining FETCH](/quest/m2/ietf-js-joining-fetch.md) - the JS publisher honors Largest Object before draft 20 and serves the head on a joining FETCH, as the Rust publisher does - [ashpd uses maintained D-Bus crates](/quest/m2/ashpd-maintained.md) - wait for a stable zbus 6 port, then remove the portal dependency exceptions - [Askama uses a maintained TOML parser](/quest/m2/askama-maintained.md) - wait for a stable parser migration, then remove the generator dependency exception - [Dependency and alternatives audit](/quest/m2/audit-deps.md) - dependencies are current, deduplicated, needed, and the best maintained option diff --git a/quest/m2/ietf-join-after-finish.md b/quest/m2/ietf-join-after-finish.md index 12ef223e0f7..f533a5759c9 100644 --- a/quest/m2/ietf-join-after-finish.md +++ b/quest/m2/ietf-join-after-finish.md @@ -76,5 +76,6 @@ refused. ## Related +- [JS joining FETCH](/quest/m2/ietf-js-joining-fetch.md) - the JS publisher mirrors the bound settled here - [Interop covers late join and FETCH](/quest/m1/interop-coverage/late-join.md) - the cross-implementation joining FETCH case - [IETF request order](/quest/m2/ietf-request-order.md) - d14/15 request IDs and their ordering races diff --git a/quest/m2/ietf-js-joining-fetch.md b/quest/m2/ietf-js-joining-fetch.md new file mode 100644 index 00000000000..2090fbc9c91 --- /dev/null +++ b/quest/m2/ietf-js-joining-fetch.md @@ -0,0 +1,67 @@ +# [M] The JS publisher serves the joining FETCH + +## Goal + +On drafts 14 to 19, the JS publisher answers a single-group joining FETCH +with the head of the group its SUBSCRIBE_OK named as Largest, the way the +Rust publisher does. A Largest Object subscription then gets exactly the +objects it asked for: the head on the fetch stream and the rest on the +subscription, with no gap or overlap. The `tail` interop cells with a +native JS or browser publisher keep passing on every draft, including a +track that finishes right after SUBSCRIBE_OK. + +## Plan + +Decided with the maintainer on 2026-10-22, after +[moq-dev/moq#6407](https://github.com/moq-dev/moq/pull/6407) made a refused +joining FETCH cost the Rust subscriber only that group's head. Until this +lands, `js/net/src/ietf/publisher.ts` refuses every FETCH, ignores the +filter before draft 20, and serves the latest group whole from object 0, +rounding SUBSCRIBE_OK's Largest to `{G, 0}`. + +Three parts, which only work together: + +1. **Honor Largest Object before draft 20.** `subscribeRange` serves the + `nextObject` filter from `edge.next`, as draft 20 already does, and + SUBSCRIBE_OK reports the true Largest on every draft. Otherwise the + FETCH's head duplicates the subscription's first objects, and the Rust + subscriber's "a whole group arrived for one the fill already headed" path + truncates the group to the head. JS subscribers send `unfiltered` before + draft 20 and are unaffected. A third-party Largest Object subscriber that + sends no joining FETCH then loses the head, as the draft says it should. +2. **Serve the head.** Keep a per-session registry of joinable SUBSCRIBEs: + their track, the advertised Largest, the SUBSCRIBE_OK properties and + timescale, the ranking, and the unsubscribe signal. `#runFetch` resolves a + joining FETCH against it: unknown subscription is + `invalid_joining_request_id`, no Largest or a start past it is + `invalid_range`, more than one group is `not_supported` (as in Rust and + the draft-20 fill), and a head evicted from the cache is refused before + FETCH_OK. Then it writes FETCH_OK (end `{G, k + 1}`, not end of track) and + a fetch stream named by the FETCH's own request ID, reusing + `#writeFillGroup`. It is not one of the subscription's counted streams. + Codec work: `Fetch` keeps the joining fields; a `FetchOk` encoder for + drafts 14 to 19 (request ID through 16, GROUP_ORDER on 14, empty + parameters, Track Properties from 15); `FetchFrame` writes draft-14's + explicit object layout and the status after an empty payload on 14 and 15. +3. **Answer a FETCH after the subscription ends.** In the tail test the track + is finished before SUBSCRIBE_OK goes out, so PUBLISH_DONE follows at once + and the FETCH arrives to no subscription. Keep a finished subscription's + join answerable under the bound + [Join after a quick finish](/quest/m2/ietf-join-after-finish.md) settles + for Rust, and mirror it here. + +Tests: unit tests per draft for each refusal and for a served head (bytes the +Rust subscriber stitches), and the tail cells +`just test interop --tail --publishers js-native-node,js-native-bun --subscribers rust --versions ietf` +plus the browser publisher on drafts 14 to 18. + +Public API: none. Wire: the JS publisher answers a joining FETCH it refused, +and serves a Largest Object subscription from past Largest. + +## Required + +- [Join after a quick finish](/quest/m2/ietf-join-after-finish.md) - settles the bound part 3 reuses + +## Related + +- [Headless moq-transport groups](/quest/m2/ietf-headless-group.md) - what a subscriber does with a tail whose head never comes From bdbe6eb9988ae04cb0994a4b55eb0fbe79cc3e5f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 16:31:30 -0700 Subject: [PATCH 4/8] fix(moq-net): a malformed joining FETCH answer still closes the session Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/ietf/subscriber.rs | 35 ++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index bfd1fe066c4..4f83ee3a087 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -3861,7 +3861,8 @@ where /// group FETCHes of their own. The subscribe's request id names the FETCH. The data /// arrives on its own fetch stream and [`Self::recv_fill`] stitches it. A refusal or a /// failed send settles the fill as [`Fill::Done`], as a failed draft-20 fill does: only - /// a stream that starts mid-group is lost, and a whole group still stands alone. + /// a stream that starts mid-group is lost, and a whole group still stands alone. A + /// malformed answer closes the session. fn start_joining_fetch(&self, subscribe_id: RequestId, track: &track::Producer) -> Option { let fill = self.state.lock().subscribes.get(&subscribe_id)?.fill.clone(); let track = track.clone(); @@ -3943,6 +3944,16 @@ where this.finish_joining_fetch(stream, progress).await } .await; + // A refusal costs only the head, but a malformed answer is the peer breaking the + // protocol, which closes the session as it would on any request. + if let Err(err) = &res + && is_protocol_violation(err) + { + this.session.close( + super::error::to_session_code(&SessionError::from(err)), + err.to_string().as_ref(), + ); + } // Release a mid-group tail parked on the head. if res.is_err() && let Ok(mut state) = fill.write() @@ -15849,6 +15860,28 @@ mod joining_fetch_tests { "{version}: the track is still live" ); assert!(!run.fill_outstanding(), "{version}: no head is coming"); + assert!(run.session.log.closes().is_empty(), "{version}: the session stays up"); + } + } + + /// A malformed answer to the joining FETCH is not a refusal: the peer broke the + /// protocol, so the session closes. + #[moq_clock::test] + async fn a_malformed_fetch_answer_closes_the_session() { + let largest = Some(ietf::Location { group: 4, object: 1 }); + for version in JOINING_DRAFTS { + // A SUBSCRIBE_OK where FETCH_OK or a refusal belongs. + let run = JoinRun::start( + version, + None, + subscribe_ok(version, largest), + subscribe_ok(version, largest), + ) + .await; + assert!( + !run.session.log.closes().is_empty(), + "{version}: an unexpected answer closes the session" + ); } } From e1f948ab555c7098e95d177527bae1e9f6a6b511 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 16:34:50 -0700 Subject: [PATCH 5/8] quest: fold the empty-group tail flake into join-after-finish Co-Authored-By: Claude Opus 5.5 --- quest/m2/README.md | 1 - quest/m2/ietf-empty-tail-race.md | 35 ------------------------------ quest/m2/ietf-join-after-finish.md | 9 ++++++++ 3 files changed, 9 insertions(+), 36 deletions(-) delete mode 100644 quest/m2/ietf-empty-tail-race.md diff --git a/quest/m2/README.md b/quest/m2/README.md index 20fdc64b344..cb4c75aa6e8 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -67,7 +67,6 @@ ranked just below deterministic TS legs, which it requires. - [Probe](/quest/m2/probe/README.md) - a session probes up to the bitrate it wants to send or receive, so a stopped simulcast rendition resumes and a viewer up-switches; the browser pads where native sessions retransmit - [Failed groups reach the publisher](/quest/m2/group-failed.md) - Rust and both JS publishers surface a group whose delivery a subscriber's stream gave up on, with one shape - [Headless moq-transport groups](/quest/m2/ietf-headless-group.md) - a group whose head no fill or joining FETCH supplies keeps its tail instead of being dropped, and a relay forwards it to moq-transport subscribers -- [Empty tail before its head](/quest/m2/ietf-empty-tail-race.md) - a pre-draft-20 joined group whose head lands after a clean PUBLISH_DONE is delivered whole, not empty - [A finished PROBE stops reporting](/quest/m2/probe-end-stale.md) - the Rust receive estimate reads unknown once its PROBE stream ends - [Wire stats](/quest/m2/wire-stats/README.md) - `Presence` counts each root's transport bytes on the wire, `wire_tx` and `wire_rx`, from QUIC, WebSocket, and embedder gateway sources - [Media stats](/quest/m2/stats/README.md) - publishers announce a stats track in the catalog, viewers answer a soliciting catalog through a per-catalog `.echo` broadcast, and one model turns both into a health verdict and a preflight report diff --git a/quest/m2/ietf-empty-tail-race.md b/quest/m2/ietf-empty-tail-race.md deleted file mode 100644 index c59daba6b64..00000000000 --- a/quest/m2/ietf-empty-tail-race.md +++ /dev/null @@ -1,35 +0,0 @@ -# [S] An empty tail waits for a head still being written - -## Goal - -On drafts 14 to 19, a joined group whose head is still arriving on the -joining FETCH when a clean PUBLISH_DONE settles is delivered whole, never as -an empty group. `tail rust -> rust` on a pinned moq-transport pass stops -failing with "empty group". - -## Plan - -Seen once on draft 16 on 2026-10-22, while debugging -[moq-dev/moq#6407](https://github.com/moq-dev/moq/pull/6407). The relay -subscribed upstream with Largest at `{3, 0}`, so the joining FETCH carries -object 0 of group 3 and the subscription's stream for group 3 has no objects. -PUBLISH_DONE arrived 5 ms after SUBSCRIBE_OK, and the downstream reader got -group 3 with no frames. - -Suspected race in `rs/moq-net/src/ietf/subscriber.rs`: the empty tail stream -waits in `claim_fill` while the fill is `Fill::Active`. The settle after -PUBLISH_DONE calls `Fill::end`, which overwrites `Active` with `Ended`, so the -waiting tail sees no head, takes the `None` arm of `open_group`, and creates -group 3 empty. The head then lands on `Fill::Ended` and has no group left to -become. Reproduce it in a unit test first (both stream orders, mocked time), -then make the empty tail and the late head end the same way: the head is the -whole group. - -Public API: none. Wire: none. - -## Related - -- [Headless moq-transport groups](/quest/m2/ietf-headless-group.md) - the - mid-group stream with no head at all -- [Join after a quick finish](/quest/m2/ietf-join-after-finish.md) - the - joining FETCH that arrives after the subscription ended diff --git a/quest/m2/ietf-join-after-finish.md b/quest/m2/ietf-join-after-finish.md index f533a5759c9..7996a56151c 100644 --- a/quest/m2/ietf-join-after-finish.md +++ b/quest/m2/ietf-join-after-finish.md @@ -28,6 +28,15 @@ out the registration wait in `joined()`, and is refused as an unknown subscription, so the subscriber loses the Largest group. Short or already-finished tracks hit this often. +It flakes the pinned-pass interop `tail` cells with a Rust publisher, about +one run in six on draft 14 (seen 2026-10-22 while landing +[moq-dev/moq#6407](https://github.com/moq-dev/moq/pull/6407)): the tail test +finishes its track before SUBSCRIBE_OK, so PUBLISH_DONE follows within +milliseconds. The relay's settle grace (about a second) ends long before the +10 s registration wait refuses the FETCH, and the empty subscription stream +for the Largest group then becomes an empty group, which `rust -> rust` and +`rust -> js-native-*` read as "empty group". + Fix it at the publisher: the subscriber cannot recover a head nobody serves, and other publishers may refuse the same way. From dc7c831c93429206edb597bc13086aa7583272e7 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 16:42:34 -0700 Subject: [PATCH 6/8] fix(moq-net): a joining request failing mid-head settles the fill Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/ietf/subscriber.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index 4f83ee3a087..c891142952d 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -3954,10 +3954,11 @@ where err.to_string().as_ref(), ); } - // Release a mid-group tail parked on the head. + // Release a mid-group tail parked on the head, including one still being written: + // a request that failed after FETCH_OK cannot be trusted to finish its stream. if res.is_err() && let Ok(mut state) = fill.write() - && matches!(*state, Fill::Requested | Fill::Serving(_)) + && matches!(*state, Fill::Requested | Fill::Serving(_) | Fill::Active) { *state = Fill::Done; } @@ -15661,6 +15662,28 @@ mod joining_fetch_tests { revoked_child_fetch(true).await; } + /// From draft 18 the joining FETCH's request stays open after FETCH_OK. Its failure while + /// the head is still being written settles the fill, so a mid-group tail is not parked + /// on a head that may never finish. + #[moq_clock::test] + async fn a_request_failing_mid_head_settles_the_fill() { + for version in [Version::Draft18, Version::Draft19] { + let session = ScriptedSession::per_stream_reset(vec![fetch_ok(version)]); + let (subscriber, track, _tasks) = pending_join(session, version); + let fill = subscriber.state.lock().subscribes[&RequestId(99)].fill.clone(); + // A fetch stream is writing the head. + if let Ok(mut state) = fill.write() { + *state = Fill::Active; + } + let mut joining = subscriber.start_joining_fetch(RequestId(99), &track).unwrap(); + assert!( + kio::wait(|waiter| joining.poll(waiter)).await.is_err(), + "{version}: the reset request fails" + ); + assert!(matches!(*fill.read(), Fill::Done), "{version}: the head is released"); + } + } + #[moq_clock::test] async fn invalid_joining_open_is_refused() { for version in JOINING_DRAFTS { From 972886ff1ef6a0f95773d523e94a64ebc5b4021b Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 16:51:22 -0700 Subject: [PATCH 7/8] fix(moq-net): a failed join drops its tail whichever stream lands first Fill::Done meant both "no join was asked for" and "the join settled without a head", and open_group treated it as the former: a mid-group tail that arrived after the head failed passed through as a partial group, while one that arrived first was dropped. Fill::Unrequested now marks a subscription with no join, so a settled join always drops a tail it cannot stitch. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/ietf/subscriber.rs | 124 ++++++++++++++++++------------ 1 file changed, 76 insertions(+), 48 deletions(-) diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index c891142952d..b52149c0e43 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -296,9 +296,13 @@ enum Fill { producer: group::Producer, }, - /// No head is coming: none was requested, the fill failed, the tail already claimed it, - /// or we stopped reading. A subgroup stream that starts mid-group is then unstitchable - /// and gets dropped, which degrades the join to the next group boundary. + /// No join was asked for. A subgroup stream that starts mid-group passes through with + /// the publisher's Object IDs, since no head of ours is missing from it. + Unrequested, + + /// No head is coming: the fill failed, the tail already claimed it, or we stopped + /// reading. A subgroup stream that starts mid-group is then unstitchable and gets + /// dropped, which degrades the join to the next group boundary. Done, /// The publisher ended the subscription cleanly, so no tail is coming. Unlike @@ -312,7 +316,7 @@ impl Fill { /// Whether a head might still arrive or is waiting to be claimed, which is what makes a /// subgroup stream worth peeking before its group is created. fn outstanding(&self) -> bool { - !matches!(self, Fill::Done | Fill::Ended) + !matches!(self, Fill::Unrequested | Fill::Done | Fill::Ended) } /// Take the head for `sequence`, if this is one and it ends where the tail begins. @@ -351,7 +355,7 @@ impl Fill { fn install(&mut self, head: Fill) { let mut head = head; match self { - Fill::Done => head.cancel(), + Fill::Unrequested | Fill::Done => head.cancel(), Fill::Ended => head.release(), _ => *self = head, } @@ -372,6 +376,9 @@ impl Fill { /// The publisher ended the subscription cleanly: release the head, and any still being /// written when it lands. fn end(&mut self) { + if matches!(self, Fill::Unrequested) { + return; + } self.release(); *self = Fill::Ended; } @@ -380,13 +387,14 @@ impl Fill { /// /// The group may still be open upstream, so finishing it would cut it short for good: a /// rejoin could not replace the cached group, and its readers would see it end early. - /// A clean end already settled the head, so [`Fill::Ended`] stays. + /// A clean end already settled the head, so [`Fill::Ended`] stays, as does + /// [`Fill::Unrequested`]: there was never a head. fn cancel(&mut self) { match std::mem::replace(self, Fill::Done) { Fill::Ready { producer, .. } => { let _ = producer.abort(Error::Cancel); } - Fill::Ended => *self = Fill::Ended, + state @ (Fill::Ended | Fill::Unrequested) => *self = state, _ => {} } } @@ -2919,7 +2927,7 @@ where // and so a fill fetch stream that overtakes it finds the subscription it answers. let fill = kio::Producer::new(match join.fill.is_some() || join.fetch { true => Fill::Requested, - false => Fill::Done, + false => Fill::Unrequested, }); { let mut state = self.state.lock(); @@ -4658,7 +4666,11 @@ where producer.start_at(resume.frame)?; return Ok(Opened::Group(producer, first.map_or(resume.frame, |first| first.id))); } - return Ok(Opened::Group(create(track)?, first.map_or(0, |first| first.id))); + // A settled join still drops a stream starting mid-group below: its head failed + // or was already claimed, whichever stream landed first. + if matches!(*fill.read(), Fill::Unrequested) || first.is_none_or(|first| first.id == 0) { + return Ok(Opened::Group(create(track)?, first.map_or(0, |first| first.id))); + } } // The first object's ID delta is its absolute Object ID (see `next_object_id`). @@ -4728,7 +4740,7 @@ where let settled = fill.poll(waiter, |fill| match **fill { Fill::Requested | Fill::Serving(_) | Fill::Active => Poll::Pending, - Fill::Ready { .. } | Fill::Done | Fill::Ended => Poll::Ready(()), + Fill::Ready { .. } | Fill::Unrequested | Fill::Done | Fill::Ended => Poll::Ready(()), }); match settled { @@ -5818,7 +5830,7 @@ fn poll_settled(settle: &mut Settle, waiter: &kio::Waiter, fill: &kio::Producer< fn poll_headed(fill: &kio::Producer, waiter: &kio::Waiter) -> Poll<()> { let headed = fill.poll(waiter, |fill| match **fill { Fill::Requested | Fill::Serving(_) | Fill::Active => Poll::Pending, - Fill::Ready { .. } | Fill::Done | Fill::Ended => Poll::Ready(()), + Fill::Ready { .. } | Fill::Unrequested | Fill::Done | Fill::Ended => Poll::Ready(()), }); match headed { Poll::Pending => Poll::Pending, @@ -6128,7 +6140,7 @@ mod tests { ..TrackState::pending( "video".to_string(), crate::Path::new("bcast").to_owned(), - kio::Producer::new(Fill::Done), + kio::Producer::new(Fill::Unrequested), ) }, ); @@ -6785,7 +6797,7 @@ mod tests { crate::track::Info::timed(), ), Path::new(broadcast).to_owned(), - kio::Producer::new(Fill::Done), + kio::Producer::new(Fill::Unrequested), ), ); } @@ -8043,7 +8055,7 @@ mod tests { crate::track::Info::timed(), ), Path::new("broadcast").to_owned(), - kio::Producer::new(Fill::Done), + kio::Producer::new(Fill::Unrequested), ) }, ); @@ -12875,7 +12887,7 @@ mod stitch_tests { ), ) .unwrap(); - let mut h = Harness::with_timescale(Fill::Done, vec![script], timescale); + let mut h = Harness::with_timescale(Fill::Unrequested, vec![script], timescale); h.subscriber.version = ingress; h.subscriber.state.lock().subscribes.get_mut(&REQUEST).unwrap().producer = Some(track.clone()); let mut stream = h.stream().await.with_version(ingress); @@ -13233,7 +13245,7 @@ mod stitch_tests { for version in [Version::Draft15, Version::Draft22] { for status in [END_OF_GROUP, END_OF_TRACK] { let script = object_stream(version, true, &[(0, &[], None), (1, &[0x20, 7], Some(status))]); - let mut h = Harness::with_timescale(Fill::Done, vec![script], None); + let mut h = Harness::with_timescale(Fill::Unrequested, vec![script], None); h.subscriber.version = version; let mut stream = h.stream().await.with_version(version); let result = h.subscriber.clone().recv_group(&mut stream).await; @@ -13250,7 +13262,7 @@ mod stitch_tests { let trailing: &[(u64, &[u8], Option)] = &[(0, &[], None), (1, &[0x20, 7], Some(END_OF_TRACK))]; for objects in [standalone, trailing] { let script = object_stream(Version::Draft14, true, objects); - let mut h = Harness::with_timescale(Fill::Done, vec![script], None); + let mut h = Harness::with_timescale(Fill::Unrequested, vec![script], None); h.subscriber.version = Version::Draft14; let mut stream = h.stream().await.with_version(Version::Draft14); let result = h.subscriber.clone().recv_group(&mut stream).await; @@ -13305,7 +13317,7 @@ mod stitch_tests { true, &[(0, &[0x10, 5], None), (1, &status, Some(END_OF_GROUP))], ); - let mut h = Harness::with_timescale(Fill::Done, vec![script], Some(Timescale::MILLI)); + let mut h = Harness::with_timescale(Fill::Unrequested, vec![script], Some(Timescale::MILLI)); h.subscriber.version = version; let mut consumer = h.track.subscribe(None); let mut stream = h.stream().await.with_version(version); @@ -13368,7 +13380,7 @@ mod stitch_tests { (&block(limit, true), None, true), ] { let script = object_stream(version, true, &[(0, properties, status)]); - let mut h = Harness::with_timescale(Fill::Done, vec![script], milli); + let mut h = Harness::with_timescale(Fill::Unrequested, vec![script], milli); h.subscriber.version = version; let mut stream = h.stream().await.with_version(version); let result = h.subscriber.clone().recv_group(&mut stream).await; @@ -13426,7 +13438,7 @@ mod stitch_tests { async fn passthrough_refuses_contradictory_gap_properties() { for properties in [vec![0x3e, 2], vec![0x3e, 3], vec![0x3e, 1, 0, 1]] { let script = object_stream(VERSION, true, &[(0, &[], None), (2, &properties, None)]); - let h = Harness::with_timescale(Fill::Done, vec![script], None); + let h = Harness::with_timescale(Fill::Unrequested, vec![script], None); let mut stream = h.stream().await; assert!(matches!( h.subscriber.clone().recv_group(&mut stream).await, @@ -13633,7 +13645,7 @@ mod stitch_tests { let track = broadcast .create_track("video", accepted_info(&Default::default(), version)) .unwrap(); - let mut h = Harness::with_timescale(Fill::Done, vec![], None); + let mut h = Harness::with_timescale(Fill::Unrequested, vec![], None); h.subscriber.version = version; h.subscriber.state.lock().subscribes.get_mut(&REQUEST).unwrap().producer = Some(track.clone()); let properties = if version == Version::Draft15 { @@ -13761,7 +13773,7 @@ mod stitch_tests { let track = broadcast .create_track("video", accepted_info(&Default::default(), ingress)) .unwrap(); - let mut h = Harness::with_timescale(Fill::Done, vec![], None); + let mut h = Harness::with_timescale(Fill::Unrequested, vec![], None); h.subscriber.version = ingress; h.subscriber.state.lock().subscribes.get_mut(&REQUEST).unwrap().producer = Some(track.clone()); let mut properties = Vec::new(); @@ -13889,7 +13901,7 @@ mod stitch_tests { encoder.varint(1u64).unwrap(); script.push(42); } - let mut h = Harness::with_timescale(Fill::Done, vec![script], None); + let mut h = Harness::with_timescale(Fill::Unrequested, vec![script], None); h.subscriber.version = version; let mut consumer = h.track.subscribe(None); let mut stream = h.stream().await.with_version(version); @@ -13902,7 +13914,7 @@ mod stitch_tests { #[moq_clock::test] async fn passthrough_accepts_datagrams_past_object_zero() { for version in [Version::Draft15, Version::Draft22] { - let mut h = Harness::with_timescale(Fill::Done, vec![], None); + let mut h = Harness::with_timescale(Fill::Unrequested, vec![], None); h.subscriber.version = version; let mut consumer = h.track.subscribe(None); let bytes = ietf::ObjectDatagram { @@ -13931,7 +13943,7 @@ mod stitch_tests { crate::coding::Encoder::new(&mut bytes, VERSION.into()) .varint(u64::MAX) .unwrap(); - let h = Harness::new(Fill::Done, vec![bytes]); + let h = Harness::new(Fill::Unrequested, vec![bytes]); let mut stream = h.stream().await; let result = h.subscriber.clone().recv_group(&mut stream).await; assert!( @@ -13968,7 +13980,7 @@ mod stitch_tests { bytes }) .collect(); - let mut h = Harness::with_timescale(Fill::Done, scripts, None); + let mut h = Harness::with_timescale(Fill::Unrequested, scripts, None); h.subscriber.version = version; let mut consumer = h.track.subscribe(None); let mut stream = h.stream().await.with_version(version); @@ -13999,7 +14011,7 @@ mod stitch_tests { .encode(&mut crate::coding::Encoder::new(&mut refused, VERSION.into()), VERSION) .unwrap(); - let h = Harness::new(Fill::Done, vec![refused, tail_stream(SEQUENCE, 0, &[b"ok"])]); + let h = Harness::new(Fill::Unrequested, vec![refused, tail_stream(SEQUENCE, 0, &[b"ok"])]); let mut consumer = h.track.subscribe(None); let mut stream = h.stream().await; @@ -14052,7 +14064,7 @@ mod stitch_tests { compact(SEQUENCE + 1, Some(0)), compact(SEQUENCE + 2, None), ]; - let mut h = Harness::with_timescale(Fill::Done, scripts, None); + let mut h = Harness::with_timescale(Fill::Unrequested, scripts, None); h.subscriber.version = version; let mut consumer = h.track.subscribe(None); @@ -14115,14 +14127,14 @@ mod stitch_tests { // Delta 0, then a 1-byte extension block holding half of a 2-byte varint. let mut stream = tail_stream(SEQUENCE, 0, &[b"ok"]); stream.extend_from_slice(&[0, 1, 0x40]); - let h = Harness::new(Fill::Done, vec![stream]); + let h = Harness::new(Fill::Unrequested, vec![stream]); h.dispatch_refused().await; } /// A FIN before the declared payload ends. #[moq_clock::test] async fn a_payload_cut_short_is_refused() { - let h = Harness::with_timescale(Fill::Done, vec![raw_stream(SEQUENCE, &[0, 4], &[1, 2])], None); + let h = Harness::with_timescale(Fill::Unrequested, vec![raw_stream(SEQUENCE, &[0, 4], &[1, 2])], None); h.dispatch_refused().await; } @@ -14130,7 +14142,7 @@ mod stitch_tests { #[moq_clock::test] async fn an_oversized_frame_is_refused() { let size = crate::group::MAX_CACHE_BYTES + 1; - let h = Harness::with_timescale(Fill::Done, vec![raw_stream(SEQUENCE, &[0, size], &[])], None); + let h = Harness::with_timescale(Fill::Unrequested, vec![raw_stream(SEQUENCE, &[0, size], &[])], None); h.dispatch_refused().await; } @@ -14139,7 +14151,7 @@ mod stitch_tests { async fn an_oversized_group_is_refused() { // Each empty object is its delta, a zero size, and the Normal status. let objects = vec![0u64; 3 * (crate::group::MAX_GROUP_FRAMES + 1)]; - let h = Harness::with_timescale(Fill::Done, vec![raw_stream(SEQUENCE, &objects, &[])], None); + let h = Harness::with_timescale(Fill::Unrequested, vec![raw_stream(SEQUENCE, &objects, &[])], None); h.dispatch_refused().await; } @@ -14147,7 +14159,7 @@ mod stitch_tests { #[moq_clock::test] async fn a_second_stream_for_a_group_is_refused() { let whole = raw_stream(SEQUENCE, &[0, 1], &[42]); - let h = Harness::with_timescale(Fill::Done, vec![whole.clone(), whole], None); + let h = Harness::with_timescale(Fill::Unrequested, vec![whole.clone(), whole], None); let mut stream = h.stream().await; h.subscriber.clone().recv_group(&mut stream).await.unwrap(); h.dispatch_refused().await; @@ -14187,7 +14199,7 @@ mod stitch_tests { } // Over-limit lengths deliberately carry no extension bytes. The objects carry // no Timestamp, so the track is untimed. - let h = Harness::with_timescale(Fill::Done, vec![script], None); + let h = Harness::with_timescale(Fill::Unrequested, vec![script], None); let mut consumer = h.track.subscribe(None); let mut stream = h.stream().await; let result = h.subscriber.clone().recv_group(&mut stream).await; @@ -14281,7 +14293,7 @@ mod stitch_tests { // The id delta, the size, and the payload, with no extension block. script.extend_from_slice(&[0, 1, 42]); - let h = Harness::new(Fill::Done, vec![script]); + let h = Harness::new(Fill::Unrequested, vec![script]); let mut stream = h.stream().await; let res = h.subscriber.clone().recv_group(&mut stream).await; assert!(matches!(res, Err(Error::MalformedTrack)), "{res:?}"); @@ -14292,7 +14304,7 @@ mod stitch_tests { #[moq_clock::test] async fn an_end_of_track_after_a_group_ends_the_track_after_it() { let h = Harness::new( - Fill::Done, + Fill::Unrequested, vec![end_marker(tail_stream(SEQUENCE, 0, &[b"last"]), END_OF_TRACK)], ); let mut consumer = h.track.subscribe(None); @@ -14319,7 +14331,7 @@ mod stitch_tests { for value in [5u64, 0, 0, END_OF_TRACK] { Encoder::new(&mut marker, VERSION.into()).varint(value).unwrap(); } - let h = Harness::new(Fill::Done, vec![marker]); + let h = Harness::new(Fill::Unrequested, vec![marker]); let mut stream = h.stream().await; h.subscriber.clone().recv_group(&mut stream).await.unwrap(); assert_eq!(h.track.end(), Some(track::Position { group: 5, frame: 5 })); @@ -14336,7 +14348,7 @@ mod stitch_tests { async fn a_group_past_the_declared_end_aborts_the_track() { use futures::FutureExt; - let mut h = Harness::new(Fill::Done, vec![tail_stream(SEQUENCE, 0, &[b"late"])]); + let mut h = Harness::new(Fill::Unrequested, vec![tail_stream(SEQUENCE, 0, &[b"late"])]); h.track.finish_at(track::Position::group(SEQUENCE)).unwrap(); let mut stream = h.stream().await; @@ -14353,7 +14365,7 @@ mod stitch_tests { #[moq_clock::test] async fn an_end_of_track_at_object_zero_creates_no_group() { let h = Harness::new( - Fill::Done, + Fill::Unrequested, vec![end_marker(tail_stream(SEQUENCE, 0, &[]), END_OF_TRACK)], ); let mut stream = h.stream().await; @@ -14557,7 +14569,7 @@ mod stitch_tests { /// delivered the rest. #[moq_clock::test] async fn a_resumed_whole_group_drops_the_delivered_head() { - let h = Harness::new(Fill::Done, vec![tail_stream(SEQUENCE, 0, &[b"0", b"1", b"2"])]).with_resume( + let h = Harness::new(Fill::Unrequested, vec![tail_stream(SEQUENCE, 0, &[b"0", b"1", b"2"])]).with_resume( track::Position { group: SEQUENCE, frame: 2, @@ -14608,13 +14620,26 @@ mod stitch_tests { /// A standalone subgroup tail keeps its identity while plain readers see its payload. #[moq_clock::test] async fn a_tail_without_a_fill_is_preserved() { - let h = Harness::new(Fill::Done, vec![tail_stream(SEQUENCE, 2, &[b"tail-2"])]); + let h = Harness::new(Fill::Unrequested, vec![tail_stream(SEQUENCE, 2, &[b"tail-2"])]); let mut consumer = h.track.subscribe(None); let mut tail = h.stream().await; h.subscriber.clone().recv_group(&mut tail).await.unwrap(); assert_eq!(read_group(&mut consumer).await.1[0].1, b"tail-2"); } + /// A join whose head failed before its tail arrived drops that tail, as it does when the + /// tail arrives first and waits on the head: the group is lost, not delivered partial. + #[moq_clock::test] + async fn a_tail_after_a_failed_fill_is_dropped() { + let h = Harness::new(Fill::Done, vec![tail_stream(SEQUENCE, 2, &[b"tail-2"])]); + let mut consumer = h.track.subscribe(None); + h.dispatch_refused().await; + assert!( + futures::FutureExt::now_or_never(consumer.recv_group()).is_none(), + "no partial group" + ); + } + /// Object IDs are absolute whatever FIRST_OBJECT says, and they start at 0, so a /// draft-18 stream that leaves the bit clear and starts at object 0 is the whole /// group. The publisher is out of spec on the bit, not missing a head. @@ -14627,7 +14652,7 @@ mod stitch_tests { "the bit is clear" ); - let mut h = Harness::new(Fill::Done, vec![bytes]); + let mut h = Harness::new(Fill::Unrequested, vec![bytes]); h.subscriber.version = Version::Draft18; let mut consumer = h.track.subscribe(None); let mut stream = read_draft18(&h.session).await; @@ -14652,7 +14677,7 @@ mod stitch_tests { 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]); + let mut h = Harness::new(Fill::Unrequested, vec![bytes]); h.subscriber.version = Version::Draft18; let mut consumer = h.track.subscribe(None); let mut stream = read_draft18(&h.session).await; @@ -14677,7 +14702,7 @@ mod stitch_tests { let whole = draft18_subgroup(SEQUENCE + 1, true, 0, &[b"next"]); assert_eq!(u64::from(partial[0]) & ietf::GroupFlags::FIRST_OBJECT_BIT, 0); - let mut h = Harness::new(Fill::Done, vec![partial, whole]); + let mut h = Harness::new(Fill::Unrequested, vec![partial, whole]); h.subscriber.version = Version::Draft18; let mut consumer = h.track.subscribe(None); @@ -14706,7 +14731,10 @@ mod stitch_tests { async fn a_received_rewind_is_accepted() { use futures::FutureExt; - let mut h = Harness::new(Fill::Done, vec![draft18_subgroup(SEQUENCE, true, 0, &[b"rewound"])]); + let mut h = Harness::new( + Fill::Unrequested, + vec![draft18_subgroup(SEQUENCE, true, 0, &[b"rewound"])], + ); h.subscriber.version = Version::Draft18; // Starts past the incoming group's first object, at `timestamp(0)`. let mut before = h.track.create_group((SEQUENCE - 1).into()).unwrap(); @@ -14760,7 +14788,7 @@ mod stitch_tests { #[moq_clock::test] async fn receive_drain_keeps_bound_aliases_and_ends_unknown_alias_waits() { - let h = Harness::new(Fill::Done, vec![]); + let h = Harness::new(Fill::Unrequested, vec![]); let aliases = h.subscriber.state.lock().aliases.consume(); let mut unknown = Box::pin(resolve_track_alias(&h.subscriber.runtime, aliases.clone(), ALIAS + 1)); assert!(futures::poll!(unknown.as_mut()).is_pending()); @@ -14829,7 +14857,7 @@ mod stitch_tests { #[moq_clock::test] async fn receive_drain_ends_a_group_fetch_waiting_for_fetch_ok() { - let h = Harness::new(Fill::Done, vec![fill_stream(SEQUENCE, &[b"head"])]); + let h = Harness::new(Fill::Unrequested, vec![fill_stream(SEQUENCE, &[b"head"])]); h.subscriber .state .lock() @@ -14872,7 +14900,7 @@ mod stitch_tests { /// subscription itself is delivering, so it is refused rather than written. #[moq_clock::test] async fn an_unsolicited_fill_is_refused() { - let h = Harness::new(Fill::Done, vec![fill_stream(SEQUENCE, &[b"head-0"])]); + let h = Harness::new(Fill::Unrequested, vec![fill_stream(SEQUENCE, &[b"head-0"])]); let mut fill = h.stream().await; assert!(matches!( From a5b8000bc2b0b468c038e21f59d21852750ae936 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 22 Oct 2026 16:58:04 -0700 Subject: [PATCH 8/8] revert(moq-net): leave the headless-tail race to its quest Reverts 972886ff1e. Dropping a mid-group or empty tail after a failed fill reverses the decision recorded in quest/m2/ietf-headless-group.md: keep the tail as a headless group, since a relay must not drop objects it received, and end both race orders that way once the model can mark a missing head. The docs no longer claim a mid-group stream is dropped after a refusal. Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/ietf/subscriber.rs | 132 ++++++++++++------------------ 1 file changed, 52 insertions(+), 80 deletions(-) diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index b52149c0e43..209963907b3 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -296,13 +296,9 @@ enum Fill { producer: group::Producer, }, - /// No join was asked for. A subgroup stream that starts mid-group passes through with - /// the publisher's Object IDs, since no head of ours is missing from it. - Unrequested, - - /// No head is coming: the fill failed, the tail already claimed it, or we stopped - /// reading. A subgroup stream that starts mid-group is then unstitchable and gets - /// dropped, which degrades the join to the next group boundary. + /// No head is coming: none was requested, the fill failed, the tail already claimed it, + /// or we stopped reading. A subgroup stream that starts mid-group is then unstitchable + /// and gets dropped, which degrades the join to the next group boundary. Done, /// The publisher ended the subscription cleanly, so no tail is coming. Unlike @@ -316,7 +312,7 @@ impl Fill { /// Whether a head might still arrive or is waiting to be claimed, which is what makes a /// subgroup stream worth peeking before its group is created. fn outstanding(&self) -> bool { - !matches!(self, Fill::Unrequested | Fill::Done | Fill::Ended) + !matches!(self, Fill::Done | Fill::Ended) } /// Take the head for `sequence`, if this is one and it ends where the tail begins. @@ -355,7 +351,7 @@ impl Fill { fn install(&mut self, head: Fill) { let mut head = head; match self { - Fill::Unrequested | Fill::Done => head.cancel(), + Fill::Done => head.cancel(), Fill::Ended => head.release(), _ => *self = head, } @@ -376,9 +372,6 @@ impl Fill { /// The publisher ended the subscription cleanly: release the head, and any still being /// written when it lands. fn end(&mut self) { - if matches!(self, Fill::Unrequested) { - return; - } self.release(); *self = Fill::Ended; } @@ -387,14 +380,13 @@ impl Fill { /// /// The group may still be open upstream, so finishing it would cut it short for good: a /// rejoin could not replace the cached group, and its readers would see it end early. - /// A clean end already settled the head, so [`Fill::Ended`] stays, as does - /// [`Fill::Unrequested`]: there was never a head. + /// A clean end already settled the head, so [`Fill::Ended`] stays. fn cancel(&mut self) { match std::mem::replace(self, Fill::Done) { Fill::Ready { producer, .. } => { let _ = producer.abort(Error::Cancel); } - state @ (Fill::Ended | Fill::Unrequested) => *self = state, + Fill::Ended => *self = Fill::Ended, _ => {} } } @@ -2927,7 +2919,7 @@ where // and so a fill fetch stream that overtakes it finds the subscription it answers. let fill = kio::Producer::new(match join.fill.is_some() || join.fetch { true => Fill::Requested, - false => Fill::Unrequested, + false => Fill::Done, }); { let mut state = self.state.lock(); @@ -3869,8 +3861,8 @@ where /// group FETCHes of their own. The subscribe's request id names the FETCH. The data /// arrives on its own fetch stream and [`Self::recv_fill`] stitches it. A refusal or a /// failed send settles the fill as [`Fill::Done`], as a failed draft-20 fill does: only - /// a stream that starts mid-group is lost, and a whole group still stands alone. A - /// malformed answer closes the session. + /// the head is lost, and a whole group still stands alone. A malformed answer closes + /// the session. fn start_joining_fetch(&self, subscribe_id: RequestId, track: &track::Producer) -> Option { let fill = self.state.lock().subscribes.get(&subscribe_id)?.fill.clone(); let track = track.clone(); @@ -4666,11 +4658,7 @@ where producer.start_at(resume.frame)?; return Ok(Opened::Group(producer, first.map_or(resume.frame, |first| first.id))); } - // A settled join still drops a stream starting mid-group below: its head failed - // or was already claimed, whichever stream landed first. - if matches!(*fill.read(), Fill::Unrequested) || first.is_none_or(|first| first.id == 0) { - return Ok(Opened::Group(create(track)?, first.map_or(0, |first| first.id))); - } + return Ok(Opened::Group(create(track)?, first.map_or(0, |first| first.id))); } // The first object's ID delta is its absolute Object ID (see `next_object_id`). @@ -4740,7 +4728,7 @@ where let settled = fill.poll(waiter, |fill| match **fill { Fill::Requested | Fill::Serving(_) | Fill::Active => Poll::Pending, - Fill::Ready { .. } | Fill::Unrequested | Fill::Done | Fill::Ended => Poll::Ready(()), + Fill::Ready { .. } | Fill::Done | Fill::Ended => Poll::Ready(()), }); match settled { @@ -5830,7 +5818,7 @@ fn poll_settled(settle: &mut Settle, waiter: &kio::Waiter, fill: &kio::Producer< fn poll_headed(fill: &kio::Producer, waiter: &kio::Waiter) -> Poll<()> { let headed = fill.poll(waiter, |fill| match **fill { Fill::Requested | Fill::Serving(_) | Fill::Active => Poll::Pending, - Fill::Ready { .. } | Fill::Unrequested | Fill::Done | Fill::Ended => Poll::Ready(()), + Fill::Ready { .. } | Fill::Done | Fill::Ended => Poll::Ready(()), }); match headed { Poll::Pending => Poll::Pending, @@ -6140,7 +6128,7 @@ mod tests { ..TrackState::pending( "video".to_string(), crate::Path::new("bcast").to_owned(), - kio::Producer::new(Fill::Unrequested), + kio::Producer::new(Fill::Done), ) }, ); @@ -6797,7 +6785,7 @@ mod tests { crate::track::Info::timed(), ), Path::new(broadcast).to_owned(), - kio::Producer::new(Fill::Unrequested), + kio::Producer::new(Fill::Done), ), ); } @@ -8055,7 +8043,7 @@ mod tests { crate::track::Info::timed(), ), Path::new("broadcast").to_owned(), - kio::Producer::new(Fill::Unrequested), + kio::Producer::new(Fill::Done), ) }, ); @@ -12887,7 +12875,7 @@ mod stitch_tests { ), ) .unwrap(); - let mut h = Harness::with_timescale(Fill::Unrequested, vec![script], timescale); + let mut h = Harness::with_timescale(Fill::Done, vec![script], timescale); h.subscriber.version = ingress; h.subscriber.state.lock().subscribes.get_mut(&REQUEST).unwrap().producer = Some(track.clone()); let mut stream = h.stream().await.with_version(ingress); @@ -13245,7 +13233,7 @@ mod stitch_tests { for version in [Version::Draft15, Version::Draft22] { for status in [END_OF_GROUP, END_OF_TRACK] { let script = object_stream(version, true, &[(0, &[], None), (1, &[0x20, 7], Some(status))]); - let mut h = Harness::with_timescale(Fill::Unrequested, vec![script], None); + let mut h = Harness::with_timescale(Fill::Done, vec![script], None); h.subscriber.version = version; let mut stream = h.stream().await.with_version(version); let result = h.subscriber.clone().recv_group(&mut stream).await; @@ -13262,7 +13250,7 @@ mod stitch_tests { let trailing: &[(u64, &[u8], Option)] = &[(0, &[], None), (1, &[0x20, 7], Some(END_OF_TRACK))]; for objects in [standalone, trailing] { let script = object_stream(Version::Draft14, true, objects); - let mut h = Harness::with_timescale(Fill::Unrequested, vec![script], None); + let mut h = Harness::with_timescale(Fill::Done, vec![script], None); h.subscriber.version = Version::Draft14; let mut stream = h.stream().await.with_version(Version::Draft14); let result = h.subscriber.clone().recv_group(&mut stream).await; @@ -13317,7 +13305,7 @@ mod stitch_tests { true, &[(0, &[0x10, 5], None), (1, &status, Some(END_OF_GROUP))], ); - let mut h = Harness::with_timescale(Fill::Unrequested, vec![script], Some(Timescale::MILLI)); + let mut h = Harness::with_timescale(Fill::Done, vec![script], Some(Timescale::MILLI)); h.subscriber.version = version; let mut consumer = h.track.subscribe(None); let mut stream = h.stream().await.with_version(version); @@ -13380,7 +13368,7 @@ mod stitch_tests { (&block(limit, true), None, true), ] { let script = object_stream(version, true, &[(0, properties, status)]); - let mut h = Harness::with_timescale(Fill::Unrequested, vec![script], milli); + let mut h = Harness::with_timescale(Fill::Done, vec![script], milli); h.subscriber.version = version; let mut stream = h.stream().await.with_version(version); let result = h.subscriber.clone().recv_group(&mut stream).await; @@ -13438,7 +13426,7 @@ mod stitch_tests { async fn passthrough_refuses_contradictory_gap_properties() { for properties in [vec![0x3e, 2], vec![0x3e, 3], vec![0x3e, 1, 0, 1]] { let script = object_stream(VERSION, true, &[(0, &[], None), (2, &properties, None)]); - let h = Harness::with_timescale(Fill::Unrequested, vec![script], None); + let h = Harness::with_timescale(Fill::Done, vec![script], None); let mut stream = h.stream().await; assert!(matches!( h.subscriber.clone().recv_group(&mut stream).await, @@ -13645,7 +13633,7 @@ mod stitch_tests { let track = broadcast .create_track("video", accepted_info(&Default::default(), version)) .unwrap(); - let mut h = Harness::with_timescale(Fill::Unrequested, vec![], None); + let mut h = Harness::with_timescale(Fill::Done, vec![], None); h.subscriber.version = version; h.subscriber.state.lock().subscribes.get_mut(&REQUEST).unwrap().producer = Some(track.clone()); let properties = if version == Version::Draft15 { @@ -13773,7 +13761,7 @@ mod stitch_tests { let track = broadcast .create_track("video", accepted_info(&Default::default(), ingress)) .unwrap(); - let mut h = Harness::with_timescale(Fill::Unrequested, vec![], None); + let mut h = Harness::with_timescale(Fill::Done, vec![], None); h.subscriber.version = ingress; h.subscriber.state.lock().subscribes.get_mut(&REQUEST).unwrap().producer = Some(track.clone()); let mut properties = Vec::new(); @@ -13901,7 +13889,7 @@ mod stitch_tests { encoder.varint(1u64).unwrap(); script.push(42); } - let mut h = Harness::with_timescale(Fill::Unrequested, vec![script], None); + let mut h = Harness::with_timescale(Fill::Done, vec![script], None); h.subscriber.version = version; let mut consumer = h.track.subscribe(None); let mut stream = h.stream().await.with_version(version); @@ -13914,7 +13902,7 @@ mod stitch_tests { #[moq_clock::test] async fn passthrough_accepts_datagrams_past_object_zero() { for version in [Version::Draft15, Version::Draft22] { - let mut h = Harness::with_timescale(Fill::Unrequested, vec![], None); + let mut h = Harness::with_timescale(Fill::Done, vec![], None); h.subscriber.version = version; let mut consumer = h.track.subscribe(None); let bytes = ietf::ObjectDatagram { @@ -13943,7 +13931,7 @@ mod stitch_tests { crate::coding::Encoder::new(&mut bytes, VERSION.into()) .varint(u64::MAX) .unwrap(); - let h = Harness::new(Fill::Unrequested, vec![bytes]); + let h = Harness::new(Fill::Done, vec![bytes]); let mut stream = h.stream().await; let result = h.subscriber.clone().recv_group(&mut stream).await; assert!( @@ -13980,7 +13968,7 @@ mod stitch_tests { bytes }) .collect(); - let mut h = Harness::with_timescale(Fill::Unrequested, scripts, None); + let mut h = Harness::with_timescale(Fill::Done, scripts, None); h.subscriber.version = version; let mut consumer = h.track.subscribe(None); let mut stream = h.stream().await.with_version(version); @@ -14011,7 +13999,7 @@ mod stitch_tests { .encode(&mut crate::coding::Encoder::new(&mut refused, VERSION.into()), VERSION) .unwrap(); - let h = Harness::new(Fill::Unrequested, vec![refused, tail_stream(SEQUENCE, 0, &[b"ok"])]); + let h = Harness::new(Fill::Done, vec![refused, tail_stream(SEQUENCE, 0, &[b"ok"])]); let mut consumer = h.track.subscribe(None); let mut stream = h.stream().await; @@ -14064,7 +14052,7 @@ mod stitch_tests { compact(SEQUENCE + 1, Some(0)), compact(SEQUENCE + 2, None), ]; - let mut h = Harness::with_timescale(Fill::Unrequested, scripts, None); + let mut h = Harness::with_timescale(Fill::Done, scripts, None); h.subscriber.version = version; let mut consumer = h.track.subscribe(None); @@ -14127,14 +14115,14 @@ mod stitch_tests { // Delta 0, then a 1-byte extension block holding half of a 2-byte varint. let mut stream = tail_stream(SEQUENCE, 0, &[b"ok"]); stream.extend_from_slice(&[0, 1, 0x40]); - let h = Harness::new(Fill::Unrequested, vec![stream]); + let h = Harness::new(Fill::Done, vec![stream]); h.dispatch_refused().await; } /// A FIN before the declared payload ends. #[moq_clock::test] async fn a_payload_cut_short_is_refused() { - let h = Harness::with_timescale(Fill::Unrequested, vec![raw_stream(SEQUENCE, &[0, 4], &[1, 2])], None); + let h = Harness::with_timescale(Fill::Done, vec![raw_stream(SEQUENCE, &[0, 4], &[1, 2])], None); h.dispatch_refused().await; } @@ -14142,7 +14130,7 @@ mod stitch_tests { #[moq_clock::test] async fn an_oversized_frame_is_refused() { let size = crate::group::MAX_CACHE_BYTES + 1; - let h = Harness::with_timescale(Fill::Unrequested, vec![raw_stream(SEQUENCE, &[0, size], &[])], None); + let h = Harness::with_timescale(Fill::Done, vec![raw_stream(SEQUENCE, &[0, size], &[])], None); h.dispatch_refused().await; } @@ -14151,7 +14139,7 @@ mod stitch_tests { async fn an_oversized_group_is_refused() { // Each empty object is its delta, a zero size, and the Normal status. let objects = vec![0u64; 3 * (crate::group::MAX_GROUP_FRAMES + 1)]; - let h = Harness::with_timescale(Fill::Unrequested, vec![raw_stream(SEQUENCE, &objects, &[])], None); + let h = Harness::with_timescale(Fill::Done, vec![raw_stream(SEQUENCE, &objects, &[])], None); h.dispatch_refused().await; } @@ -14159,7 +14147,7 @@ mod stitch_tests { #[moq_clock::test] async fn a_second_stream_for_a_group_is_refused() { let whole = raw_stream(SEQUENCE, &[0, 1], &[42]); - let h = Harness::with_timescale(Fill::Unrequested, vec![whole.clone(), whole], None); + let h = Harness::with_timescale(Fill::Done, vec![whole.clone(), whole], None); let mut stream = h.stream().await; h.subscriber.clone().recv_group(&mut stream).await.unwrap(); h.dispatch_refused().await; @@ -14199,7 +14187,7 @@ mod stitch_tests { } // Over-limit lengths deliberately carry no extension bytes. The objects carry // no Timestamp, so the track is untimed. - let h = Harness::with_timescale(Fill::Unrequested, vec![script], None); + let h = Harness::with_timescale(Fill::Done, vec![script], None); let mut consumer = h.track.subscribe(None); let mut stream = h.stream().await; let result = h.subscriber.clone().recv_group(&mut stream).await; @@ -14293,7 +14281,7 @@ mod stitch_tests { // The id delta, the size, and the payload, with no extension block. script.extend_from_slice(&[0, 1, 42]); - let h = Harness::new(Fill::Unrequested, vec![script]); + let h = Harness::new(Fill::Done, vec![script]); let mut stream = h.stream().await; let res = h.subscriber.clone().recv_group(&mut stream).await; assert!(matches!(res, Err(Error::MalformedTrack)), "{res:?}"); @@ -14304,7 +14292,7 @@ mod stitch_tests { #[moq_clock::test] async fn an_end_of_track_after_a_group_ends_the_track_after_it() { let h = Harness::new( - Fill::Unrequested, + Fill::Done, vec![end_marker(tail_stream(SEQUENCE, 0, &[b"last"]), END_OF_TRACK)], ); let mut consumer = h.track.subscribe(None); @@ -14331,7 +14319,7 @@ mod stitch_tests { for value in [5u64, 0, 0, END_OF_TRACK] { Encoder::new(&mut marker, VERSION.into()).varint(value).unwrap(); } - let h = Harness::new(Fill::Unrequested, vec![marker]); + let h = Harness::new(Fill::Done, vec![marker]); let mut stream = h.stream().await; h.subscriber.clone().recv_group(&mut stream).await.unwrap(); assert_eq!(h.track.end(), Some(track::Position { group: 5, frame: 5 })); @@ -14348,7 +14336,7 @@ mod stitch_tests { async fn a_group_past_the_declared_end_aborts_the_track() { use futures::FutureExt; - let mut h = Harness::new(Fill::Unrequested, vec![tail_stream(SEQUENCE, 0, &[b"late"])]); + let mut h = Harness::new(Fill::Done, vec![tail_stream(SEQUENCE, 0, &[b"late"])]); h.track.finish_at(track::Position::group(SEQUENCE)).unwrap(); let mut stream = h.stream().await; @@ -14365,7 +14353,7 @@ mod stitch_tests { #[moq_clock::test] async fn an_end_of_track_at_object_zero_creates_no_group() { let h = Harness::new( - Fill::Unrequested, + Fill::Done, vec![end_marker(tail_stream(SEQUENCE, 0, &[]), END_OF_TRACK)], ); let mut stream = h.stream().await; @@ -14569,7 +14557,7 @@ mod stitch_tests { /// delivered the rest. #[moq_clock::test] async fn a_resumed_whole_group_drops_the_delivered_head() { - let h = Harness::new(Fill::Unrequested, vec![tail_stream(SEQUENCE, 0, &[b"0", b"1", b"2"])]).with_resume( + let h = Harness::new(Fill::Done, vec![tail_stream(SEQUENCE, 0, &[b"0", b"1", b"2"])]).with_resume( track::Position { group: SEQUENCE, frame: 2, @@ -14620,26 +14608,13 @@ mod stitch_tests { /// A standalone subgroup tail keeps its identity while plain readers see its payload. #[moq_clock::test] async fn a_tail_without_a_fill_is_preserved() { - let h = Harness::new(Fill::Unrequested, vec![tail_stream(SEQUENCE, 2, &[b"tail-2"])]); + let h = Harness::new(Fill::Done, vec![tail_stream(SEQUENCE, 2, &[b"tail-2"])]); let mut consumer = h.track.subscribe(None); let mut tail = h.stream().await; h.subscriber.clone().recv_group(&mut tail).await.unwrap(); assert_eq!(read_group(&mut consumer).await.1[0].1, b"tail-2"); } - /// A join whose head failed before its tail arrived drops that tail, as it does when the - /// tail arrives first and waits on the head: the group is lost, not delivered partial. - #[moq_clock::test] - async fn a_tail_after_a_failed_fill_is_dropped() { - let h = Harness::new(Fill::Done, vec![tail_stream(SEQUENCE, 2, &[b"tail-2"])]); - let mut consumer = h.track.subscribe(None); - h.dispatch_refused().await; - assert!( - futures::FutureExt::now_or_never(consumer.recv_group()).is_none(), - "no partial group" - ); - } - /// Object IDs are absolute whatever FIRST_OBJECT says, and they start at 0, so a /// draft-18 stream that leaves the bit clear and starts at object 0 is the whole /// group. The publisher is out of spec on the bit, not missing a head. @@ -14652,7 +14627,7 @@ mod stitch_tests { "the bit is clear" ); - let mut h = Harness::new(Fill::Unrequested, vec![bytes]); + 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; @@ -14677,7 +14652,7 @@ mod stitch_tests { 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::Unrequested, vec![bytes]); + 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; @@ -14702,7 +14677,7 @@ mod stitch_tests { let whole = draft18_subgroup(SEQUENCE + 1, true, 0, &[b"next"]); assert_eq!(u64::from(partial[0]) & ietf::GroupFlags::FIRST_OBJECT_BIT, 0); - let mut h = Harness::new(Fill::Unrequested, vec![partial, whole]); + let mut h = Harness::new(Fill::Done, vec![partial, whole]); h.subscriber.version = Version::Draft18; let mut consumer = h.track.subscribe(None); @@ -14731,10 +14706,7 @@ mod stitch_tests { async fn a_received_rewind_is_accepted() { use futures::FutureExt; - let mut h = Harness::new( - Fill::Unrequested, - vec![draft18_subgroup(SEQUENCE, true, 0, &[b"rewound"])], - ); + let mut h = Harness::new(Fill::Done, vec![draft18_subgroup(SEQUENCE, true, 0, &[b"rewound"])]); h.subscriber.version = Version::Draft18; // Starts past the incoming group's first object, at `timestamp(0)`. let mut before = h.track.create_group((SEQUENCE - 1).into()).unwrap(); @@ -14788,7 +14760,7 @@ mod stitch_tests { #[moq_clock::test] async fn receive_drain_keeps_bound_aliases_and_ends_unknown_alias_waits() { - let h = Harness::new(Fill::Unrequested, vec![]); + let h = Harness::new(Fill::Done, vec![]); let aliases = h.subscriber.state.lock().aliases.consume(); let mut unknown = Box::pin(resolve_track_alias(&h.subscriber.runtime, aliases.clone(), ALIAS + 1)); assert!(futures::poll!(unknown.as_mut()).is_pending()); @@ -14857,7 +14829,7 @@ mod stitch_tests { #[moq_clock::test] async fn receive_drain_ends_a_group_fetch_waiting_for_fetch_ok() { - let h = Harness::new(Fill::Unrequested, vec![fill_stream(SEQUENCE, &[b"head"])]); + let h = Harness::new(Fill::Done, vec![fill_stream(SEQUENCE, &[b"head"])]); h.subscriber .state .lock() @@ -14900,7 +14872,7 @@ mod stitch_tests { /// subscription itself is delivering, so it is refused rather than written. #[moq_clock::test] async fn an_unsolicited_fill_is_refused() { - let h = Harness::new(Fill::Unrequested, vec![fill_stream(SEQUENCE, &[b"head-0"])]); + let h = Harness::new(Fill::Done, vec![fill_stream(SEQUENCE, &[b"head-0"])]); let mut fill = h.stream().await; assert!(matches!( @@ -15895,8 +15867,8 @@ mod joining_fetch_tests { /// A publisher that serves no FETCH refuses the joining FETCH. That costs the head of /// the Largest group and nothing more, as a failed draft-20 fill does: the fill settles, - /// so a stream starting mid-group is dropped rather than parked, and the subscription - /// keeps delivering whole groups. + /// so a stream starting mid-group no longer waits on it, and the subscription keeps + /// delivering whole groups. #[moq_clock::test] async fn a_refused_fetch_joins_at_the_next_whole_group() { let largest = Some(ietf::Location { group: 4, object: 1 });