From 5f95b0733a4191a2a3de91166d8ba583d3446a27 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Sat, 31 Oct 2026 10:47:30 +0100 Subject: [PATCH 1/4] fix(net): answer a draft-18 TRACK_STATUS followed at once by a FIN On draft 18 we read a requester FIN as withdrawal of the request, so a TRACK_STATUS followed at once by a FIN was reset with CANCELLED instead of answered. Nothing can follow a TRACK_STATUS, so a requester may FIN right after it, and moxygen does. A FIN now only ends a TRACK_STATUS requester's input, on every draft, in the Rust and JS publishers; a reset or STOP_SENDING still withdraws it. The draft-18 FIN cancel of the other requests is unchanged, since our own draft-18 requesters cancel by FIN. The FIN rule is passed to the request stream watches, resolve and until_withdrawn instead of the version. Co-Authored-By: Claude Opus 5.5 --- js/net/src/ietf/publisher.test.ts | 29 +++++ js/net/src/ietf/publisher.ts | 4 +- js/net/src/ietf/request_stream.ts | 26 ++-- rs/moq-net/src/ietf/publisher.rs | 163 ++++++++++++++++++++++---- rs/moq-net/src/ietf/request_stream.rs | 24 ++-- rs/moq-net/src/ietf/subscriber.rs | 7 +- 6 files changed, 213 insertions(+), 40 deletions(-) diff --git a/js/net/src/ietf/publisher.test.ts b/js/net/src/ietf/publisher.test.ts index 3662971e843..5806d0f54ee 100644 --- a/js/net/src/ietf/publisher.test.ts +++ b/js/net/src/ietf/publisher.test.ts @@ -217,6 +217,8 @@ function requestStream(version: IetfVersion) { wire: () => new Reader(undefined, Uint8Array.from(written), version), send: (bytes: Uint8Array) => input.enqueue(bytes), cancel: () => input.error(new Error("request cancelled")), + /** FIN the request's side: the requester has nothing more to send. */ + finish: () => input.close(), /** * End the request as `version` cancels one: by FIN through draft 18, and by a reset * after. @@ -285,6 +287,33 @@ test("TRACK_STATUS is answered on every draft without subscribing", async () => } }); +// A requester may FIN right after TRACK_STATUS, since nothing can follow it (moxygen does). +// That only ends its input, so the request is still answered, on draft 18 too. +test("TRACK_STATUS finished at once is answered on every draft", async () => { + for (const version of IETF_VERSIONS) { + const pair = createMockTransportPair(ALPNS[version]); + const session = new NativeSession(pair.server, version, true); + const { pub, origin } = publisher(pair.server, { session }); + const requests = origin.requestsRoute(Path.from("room")).requested(); + + // The FIN arrives while the broadcast still resolves. + const { stream, wire, finish } = requestStream(version); + const task = pub.runTrackStatusRequest(trackStatus("room"), stream); + const pending = (await requests.next()).value; + if (!pending) throw new Error("no request for room"); + finish(); + const served = new BroadcastProducer(); + served.createTrack("video"); + hooks.acceptRequest(pending, served); + await task; + expect(await wire().u53()).toBe(TrackStatusOk.id); + + await requests.return?.(); + served.close(); + origin.close(); + } +}); + // A track that has published nothing answers without LARGEST_OBJECT. test("TRACK_STATUS for an empty track names no largest", async () => { const version = Version.DRAFT_22; diff --git a/js/net/src/ietf/publisher.ts b/js/net/src/ietf/publisher.ts index ec6775779d5..5caa9110c9b 100644 --- a/js/net/src/ietf/publisher.ts +++ b/js/net/src/ietf/publisher.ts @@ -2173,7 +2173,9 @@ export class Publisher { * @internal */ runTrackStatusRequest(msg: TrackStatusRequest, stream: Stream): Promise { - const request = new RequestStream(stream, this.#session, this.#quic); + // Nothing can follow a TRACK_STATUS, so a FIN only ends the requester's input; a reset or + // STOP_SENDING withdraws it. + const request = new RequestStream(stream, this.#session, this.#quic, { finCancels: false }); return request.serve(this.#runTrackStatusRequest(msg, request)); } diff --git a/js/net/src/ietf/request_stream.ts b/js/net/src/ietf/request_stream.ts index 0732883c18b..67392c9cd8a 100644 --- a/js/net/src/ietf/request_stream.ts +++ b/js/net/src/ietf/request_stream.ts @@ -10,7 +10,14 @@ import type { Session } from "./session.ts"; import { MalformedAuthToken } from "./token.ts"; import { type IetfVersion, Version } from "./version.ts"; -/** Whether the draft treats the requester finishing its messages as cancellation. */ +/** + * Whether the requester finishing its messages withdraws a request on `version`. + * + * Draft 18 asks for a reset or STOP_SENDING (section 3.3.2) and names a FIN as a cancel only for + * SUBSCRIBE_NAMESPACE and SUBSCRIBE_TRACKS (section 6.1), but our own draft-18 requesters cancel + * by FIN, so we read one that way. TRACK_STATUS passes `false` instead: nothing can follow it, so + * a requester may FIN right after it (moxygen does). + */ function finCancels(version: IetfVersion): boolean { return version === Version.DRAFT_18; } @@ -146,6 +153,8 @@ export class RequestStream { readonly #stream: Stream; readonly #session: Session; readonly #quic?: WebTransport; + // Whether the peer's FIN withdraws the request, rather than only ending its input. + readonly #finCancels: boolean; // The next message, read ahead of whoever takes it. Unset until someone first waits. #ahead?: Promise; #taking = false; @@ -154,12 +163,16 @@ export class RequestStream { readonly #ended: Promise; #end!: () => void; - /** Own `stream` for a request on `session`, closing `quic` over the peer's violations. */ - constructor(stream: Stream, session: Session, quic?: WebTransport) { + /** + * Own `stream` for a request on `session`, closing `quic` over the peer's violations. The + * peer's FIN withdraws the request where `finCancels`, by default as the draft has it. + */ + constructor(stream: Stream, session: Session, quic?: WebTransport, options: { finCancels?: boolean } = {}) { this.#stream = stream; this.writer = stream.writer; this.#session = session; this.#quic = quic; + this.#finCancels = options.finCancels ?? finCancels(session.version); this.#ended = new Promise((resolve) => { this.#end = resolve; }); @@ -199,7 +212,7 @@ export class RequestStream { */ cancel(): void { if (this.#closed) return; - if (finCancels(this.#session.version)) this.writer.close(); + if (this.#finCancels) this.writer.close(); else this.writer.reset(new StreamError(StreamCode.Cancel, { message: "cancel" })); } @@ -247,12 +260,11 @@ export class RequestStream { // Start reading on the first wait. #read(): Promise { if (this.#ahead === undefined) { - const version = this.#session.version; this.#ahead = this.#readAhead(); // The read ahead stops at an untaken message, so watch for the peer's end apart from it. this.#stream.reader.closed.then( () => { - if (finCancels(version)) this.#end(); + if (this.#finCancels) this.#end(); }, () => this.#end(), ); @@ -270,7 +282,7 @@ export class RequestStream { const read = this.#readFramed(); read.then( (framed) => { - if (framed === undefined && finCancels(this.#session.version)) this.#end(); + if (framed === undefined && this.#finCancels) this.#end(); }, (err: unknown) => { if (err instanceof ProtocolViolation) this.abort(err); diff --git a/rs/moq-net/src/ietf/publisher.rs b/rs/moq-net/src/ietf/publisher.rs index 7aa08c017d8..7818fd3f000 100644 --- a/rs/moq-net/src/ietf/publisher.rs +++ b/rs/moq-net/src/ietf/publisher.rs @@ -930,22 +930,24 @@ impl Publisher { kio::wait(|waiter| self.poll_serving_origin(waiter)).await } - /// Resolve a request's broadcast while the peer still wants the answer. + /// Resolve a request's broadcast while the peer still wants the answer, a FIN withdrawing it + /// where `fin_cancels`. async fn resolve( &self, stream: &mut Stream, + fin_cancels: bool, path: &crate::Path, epoch: Option, ) -> Result, Error> { let Some(origin) = self - .until_withdrawn(stream, |waiter| self.poll_serving_origin(waiter)) + .until_withdrawn(stream, fin_cancels, |waiter| self.poll_serving_origin(waiter)) .await else { return Ok(None); }; // The immediate lookup: answering a peer never starts discovery of its own. let requesting = origin.lookup(path.clone(), epoch.as_ref()); - self.until_withdrawn(stream, |waiter| requesting.poll_ok(waiter)) + self.until_withdrawn(stream, fin_cancels, |waiter| requesting.poll_ok(waiter)) .await .transpose() } @@ -1315,7 +1317,11 @@ impl Publisher { let verdict = gate.verify(token, Some(slot.clone())); // The subscriber cancelling or the session closing withdraws the token. let verified = self - .until_withdrawn(&mut stream, |waiter| verdict.poll_grant(waiter)) + .until_withdrawn( + &mut stream, + super::request_stream::fin_cancels(self.version), + |waiter| verdict.poll_grant(waiter), + ) .await; let Some(verified) = verified else { drop((verdict, slot)); @@ -1364,7 +1370,15 @@ impl Publisher { // already seen the announcement. The immediate lookup resolves it at once, or // falls back to the route covering it (an `origin::Requests`), if any. Pinned to // the instance it names, if any: another is refused, never served. - let broadcast = match self.resolve(&mut stream, &msg.track_namespace, msg.epoch.clone()).await { + let broadcast = match self + .resolve( + &mut stream, + super::request_stream::fin_cancels(self.version), + &msg.track_namespace, + msg.epoch.clone(), + ) + .await + { Ok(Some(broadcast)) => broadcast, // The reason is the origin's, not ours: a dynamic router refusing on // authorization or a drain says so, and only an unroutable path means the @@ -1612,23 +1626,28 @@ impl Publisher { &self, session: &mut Transport, stream: &mut Stream, + fin_cancels: bool, waiter: &kio::Waiter, ) -> Poll<()> { if session.poll_closed(waiter).is_ready() { return Poll::Ready(()); } - super::request_stream::poll_withdrawn(stream, self.version, waiter) + super::request_stream::poll_withdrawn(stream, fin_cancels, waiter) } /// Poll `step` of a request's setup until ready, or `None` once [`Self::poll_withdrawn`] is. async fn until_withdrawn( &self, stream: &mut Stream, + fin_cancels: bool, mut step: impl FnMut(&kio::Waiter) -> Poll, ) -> Option { let mut session = self.session.clone(); kio::wait(|waiter| { - if self.poll_withdrawn(&mut session, stream, waiter).is_ready() { + if self + .poll_withdrawn(&mut session, stream, fin_cancels, waiter) + .is_ready() + { return Poll::Ready(None); } step(waiter).map(Some) @@ -1669,8 +1688,14 @@ impl Publisher { if let Poll::Ready(res) = waiter.poll_future(marker.as_mut()) { return Poll::Ready(res); } - if super::request_stream::poll_cancel(stream, request_finished, goaways, self.version, waiter).is_ready() - || closed_session.poll_closed(waiter).is_ready() + if super::request_stream::poll_cancel( + stream, + request_finished, + goaways, + super::request_stream::fin_cancels(self.version), + waiter, + ) + .is_ready() || closed_session.poll_closed(waiter).is_ready() { return Poll::Ready(Err(Error::Cancel)); } @@ -1921,7 +1946,9 @@ impl Publisher { msg: &ietf::Subscribe<'_>, ) -> Option> { let declared = self - .until_withdrawn(stream, |waiter| self.peer_setup.poll_get(waiter)) + .until_withdrawn(stream, super::request_stream::fin_cancels(self.version), |waiter| { + self.peer_setup.poll_get(waiter) + }) .await?; // A live SUBSCRIBE's NEW_GROUP_REQUEST asks nothing more: subscribing is itself a join, // which the track's refresh ratio judges. @@ -1948,7 +1975,9 @@ impl Publisher { // anything is served. let subscribing = track.subscribe(subscription.clone()); let mut subscribed = match self - .until_withdrawn(stream, |waiter| subscribing.poll_ok(waiter)) + .until_withdrawn(stream, super::request_stream::fin_cancels(self.version), |waiter| { + subscribing.poll_ok(waiter) + }) .await? { Ok(subscribed) => subscribed, @@ -1958,8 +1987,10 @@ impl Publisher { // A relay's copy that went idle cannot say where its live edge is until its route // answers again; answering from its cache would advertise a stale one. - self.until_withdrawn(stream, |waiter| subscribed.poll_live(waiter)) - .await?; + self.until_withdrawn(stream, super::request_stream::fin_cancels(self.version), |waiter| { + subscribed.poll_live(waiter) + }) + .await?; // The filter and any fill are relative to the live edge, so snapshot it once: the fill // ends exactly where a Next Object subscription begins, which is what lets the draft's @@ -2795,7 +2826,15 @@ impl Publisher { // The peer must have seen the announcement to name this namespace, so this // resolves like a SUBSCRIBE does. - let broadcast = match gate.guard(self.resolve(&mut stream, &namespace, epoch)).await { + let broadcast = match gate + .guard(self.resolve( + &mut stream, + super::request_stream::fin_cancels(self.version), + &namespace, + epoch, + )) + .await + { Ok(Some(broadcast)) => broadcast, Ok(None) => return Ok(()), Err(err) => return self.reject_fetch(stream, &err, &err.to_string()).await, @@ -2908,8 +2947,14 @@ impl Publisher { compression, )); kio::wait(|waiter| { - if super::request_stream::poll_cancel(&mut stream, &mut finished, &mut messages, self.version, waiter) - .is_ready() + if super::request_stream::poll_cancel( + &mut stream, + &mut finished, + &mut messages, + super::request_stream::fin_cancels(self.version), + waiter, + ) + .is_ready() { return Poll::Ready(None); } @@ -3036,8 +3081,14 @@ impl Publisher { let res = { let mut respond = std::pin::pin!(respond); kio::wait(|waiter| { - if super::request_stream::poll_cancel(&mut stream, &mut finished, &mut messages, self.version, waiter) - .is_ready() + if super::request_stream::poll_cancel( + &mut stream, + &mut finished, + &mut messages, + super::request_stream::fin_cancels(self.version), + waiter, + ) + .is_ready() { return Poll::Ready(None); } @@ -3095,7 +3146,15 @@ impl Publisher { let mut deadline = crate::time::Deadline::after(&self.runtime, Duration::from_secs(10)); kio::wait(|waiter| { // The request reader is what the subscriber FINs or resets. - if super::request_stream::poll_cancel(stream, finished, messages, self.version, waiter).is_ready() { + if super::request_stream::poll_cancel( + stream, + finished, + messages, + super::request_stream::fin_cancels(self.version), + waiter, + ) + .is_ready() + { return Poll::Ready(Err(Error::Cancel)); } let joins = self.joins.poll(waiter, |joins| match joins.get(&subscribe_id) { @@ -3172,8 +3231,11 @@ impl Publisher { if !gate.allows() { return self.reject_track_status(stream, &Error::Unauthorized).await; } + // Nothing can follow a TRACK_STATUS, so a FIN only ends the requester's input; a reset or + // STOP_SENDING withdraws it. + let fin_cancels = false; let broadcast = match gate - .guard(self.resolve(&mut stream, &msg.track_namespace, msg.epoch.clone())) + .guard(self.resolve(&mut stream, fin_cancels, &msg.track_namespace, msg.epoch.clone())) .await { Ok(Some(broadcast)) => broadcast, @@ -3192,7 +3254,7 @@ impl Publisher { let mut finished = false; let mut messages = super::request_stream::Messages::new(self.session.clone(), self.control.client()); kio::wait(|waiter| { - if super::request_stream::poll_cancel(&mut stream, &mut finished, &mut messages, self.version, waiter) + if super::request_stream::poll_cancel(&mut stream, &mut finished, &mut messages, fin_cancels, waiter) .is_ready() { return Poll::Ready(None); @@ -6886,7 +6948,7 @@ mod serve_tests { &mut stream, &mut finished, &mut goaways, - version, + super::super::request_stream::fin_cancels(version), waiter ), Poll::Ready(Err(Error::ProtocolViolation)) @@ -8670,6 +8732,57 @@ mod serve_tests { body } + /// A requester may FIN right after TRACK_STATUS, since nothing can follow it (moxygen + /// does). That ends its input and is still answered, on draft 18 too. + #[moq_clock::test] + async fn track_status_finished_at_once_is_answered() { + for version in ALL_VERSIONS { + let h = serve_session( + version, + track::Info::timed(), + crate::origin::Route::default(), + ScriptedSession::per_stream_eof(vec![Vec::new()]), + ); + let stream = Stream::open(&mut crate::driver::Transport::new(h.session.clone()), version) + .await + .unwrap(); + let mark = h.log.trail().len(); + let body = track_status("room", true, version); + let task = h + .publisher + .clone() + .handle_stream( + ietf::TrackStatus::ID, + ietf::Body(bytes::Bytes::from(body)), + stream, + false, + ) + .unwrap(); + moq_clock::timeout(std::time::Duration::from_secs(1), task) + .await + .unwrap_or_else(|_| panic!("{version}: never answered")); + + let trail = h.log.trail()[mark..].to_vec(); + let wire: Vec = trail + .iter() + .filter_map(|(_, sent)| match sent { + Sent::Write(bytes) => Some(bytes.clone()), + _ => None, + }) + .flatten() + .collect(); + assert!(!wire.is_empty(), "{version}: not answered"); + let mut buf = Decoder::new(&wire, version.into()); + assert_eq!(buf.varint().unwrap(), ietf::TrackStatusOk::ID, "{version}"); + ietf::TrackStatusOk::decode(&mut buf, version).unwrap(); + assert!( + matches!(trail.last(), Some((_, Sent::Finish))), + "{version}: the answer did not end with a FIN: {trail:?}" + ); + assert!(h.log.resets().is_empty(), "{version}: reset"); + } + } + /// TRACK_STATUS gets what a SUBSCRIBE_OK would carry, as far as each draft's answer has /// room, without subscribing to the track. INCLUDE_PROPERTIES=0 empties the properties. #[moq_clock::test] @@ -12156,7 +12269,11 @@ mod serve_tests { ); assert_eq!(demanded(), !matches!(setup, Setup::Resolving), "{version} {setup:?}"); - withdraw(&request, version); + match kind { + // A FIN only ends a TRACK_STATUS requester's input; a reset withdraws it. + request::Kind::TrackStatus => request.close(crate::lite::test_transport::Close::Reset), + _ => withdraw(&request, version), + } let res = moq_clock::timeout(std::time::Duration::from_secs(1), serving) .await .unwrap_or_else(|_| panic!("{version} {setup:?}: outlived its withdrawal")); diff --git a/rs/moq-net/src/ietf/request_stream.rs b/rs/moq-net/src/ietf/request_stream.rs index fdb8c458127..53ef08e92b4 100644 --- a/rs/moq-net/src/ietf/request_stream.rs +++ b/rs/moq-net/src/ietf/request_stream.rs @@ -8,21 +8,28 @@ use crate::{ coding::{Decode, DecodeError, Decoder, Stream}, }; +/// Whether the requester finishing its messages withdraws a request on `version`. +/// +/// Draft 18 asks for a reset or STOP_SENDING (section 3.3.2) and names a FIN as a cancel only for +/// SUBSCRIBE_NAMESPACE and SUBSCRIBE_TRACKS (section 6.1), but our own draft-18 requesters cancel +/// by FIN, so we read one that way. TRACK_STATUS passes `false` instead: nothing can follow it, so +/// a requester may FIN right after it (moxygen does). pub(super) fn fin_cancels(version: Version) -> bool { matches!(version, Version::Draft18) } -/// Watch abrupt cancellation after the requester has finished sending messages. +/// Watch abrupt cancellation after the requester has finished sending messages, and its FIN +/// where `fin_cancels`. pub(super) fn poll_cancel( stream: &mut Stream, finished: &mut bool, messages: &mut Messages, - version: Version, + fin_cancels: bool, waiter: &kio::Waiter, ) -> Poll> { if !*finished { match messages.poll_end(&mut stream.reader, waiter) { - Poll::Ready(Ok(())) if !fin_cancels(version) => *finished = true, + Poll::Ready(Ok(())) if !fin_cancels => *finished = true, Poll::Ready(result) => return Poll::Ready(result), Poll::Pending => {} } @@ -33,17 +40,18 @@ pub(super) fn poll_cancel( /// Watch for the requester ending a request it has not been answered on yet, without consuming /// what it sent meanwhile: a waiting message (an update, say) ends the watch on the reader and /// is read once the request is answered. A withdrawal queued behind an update is therefore seen -/// only then; until the verifier answers, the requester holds nothing but its own slot. +/// only then; until the verifier answers, the requester holds nothing but its own slot. A FIN +/// withdraws it only where `fin_cancels`. pub(super) fn poll_withdrawn( stream: &mut Stream, - version: Version, + fin_cancels: bool, waiter: &kio::Waiter, ) -> Poll<()> { if stream.writer.poll_closed(waiter).is_ready() { return Poll::Ready(()); } match stream.reader.poll_has_more(waiter) { - Poll::Ready(Ok(false)) if fin_cancels(version) => Poll::Ready(()), + Poll::Ready(Ok(false)) if fin_cancels => Poll::Ready(()), Poll::Ready(Err(_)) => Poll::Ready(()), _ => Poll::Pending, } @@ -446,7 +454,7 @@ mod tests { &mut stream, &mut finished, &mut messages, - version, + fin_cancels(version), waiter, ))) .is_pending(), @@ -460,7 +468,7 @@ mod tests { &mut stream, &mut finished, &mut messages, - version, + fin_cancels(version), waiter, ))), Poll::Ready(Err(Error::ProtocolViolation)) diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index 409531f8c35..f3226f67839 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -1867,7 +1867,12 @@ impl Subscriber { let version = self.version; let verified = kio::wait(|waiter| { if session.poll_closed(waiter).is_ready() - || super::request_stream::poll_withdrawn(&mut stream, version, waiter).is_ready() + || super::request_stream::poll_withdrawn( + &mut stream, + super::request_stream::fin_cancels(version), + waiter, + ) + .is_ready() { return Poll::Ready(None); } From 232fbd0959e6d1463f2979c4cf88be2226bc9411 Mon Sep 17 00:00:00 2001 From: Michael Stuurman Date: Sat, 31 Oct 2026 16:56:08 +0100 Subject: [PATCH 2/4] docs(standard): a refused TRACK_STATUS fails the reader, and its FIN only ends input The fetch-only clause still said a reader whose publisher refuses TRACK_STATUS as NOT_SUPPORTED subscribes anyway. That fallback was removed, so any refusal now fails the reader's request. Also note when a requester's FIN cancels a request. Co-Authored-By: Claude Opus 5.5 --- doc/concept/standard.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/concept/standard.md b/doc/concept/standard.md index 68ccd9d86c1..42f77f7eb72 100644 --- a/doc/concept/standard.md +++ b/doc/concept/standard.md @@ -28,7 +28,8 @@ subset drops. What a peer actually observes against this implementation: - **Pull.** Subscribers ask. Single-track `PUBLISH` offers are declined, unless they answer our `SUBSCRIBE_TRACKS` (below); announce a namespace and serve the resulting subscriptions. Announcements go out unsolicited. A client asks only for the prefixes its readers watch, and a server or relay link for every prefix it may discover. We never hold two overlapping requests at a peer that did not declare solicit: a broader one replaces the narrower ones once they are closed. The solicit `SETUP` option makes us wait to be asked. Without it, a 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). - **`SUBSCRIBE_TRACKS` lists, it never pushes.** 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 a `PUBLISH_DONE` once the track is no longer listed: `TRACK_ENDED` if it finished, even just before its broadcast ended, and an error otherwise, 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` opens only as the peer's stream credit admits it, so a peer that grants none holds none. A listing that omits `FORWARD` or sets it to 1 asks for every track's objects: from draft 20 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. Rust sends it upstream for a listing (below); JavaScript does not. - **A Rust TRACKS listing sends `SUBSCRIBE_TRACKS` upstream, only on demand.** Listing a broadcast from a moq-transport peer sends `SUBSCRIBE_TRACKS` with `FORWARD=0` while someone lists it, never on connect, announce, or subscribe, so a peer that refuses, resets, or ignores it affects only that listing. Each listed track's paused `PUBLISH` is its upstream copy, which a reader resumes rather than subscribing again. Only a `PUBLISH_DONE` with `TRACK_ENDED` removes a listed track, and it lists as finished; any other end, including the error our own answerer sends for a track that left unfinished, fails the listing, and readers list again. -- **History is served one group at a time.** Our moq-transport publishers answer a `FETCH` only within one group, a draft-18 joining `FETCH` for the subscription's current group head, and a draft 20+ fill for the largest group's head. Whole-group fetches wait for an open group to finish. Both implementations accept and ignore `FILL_TIMEOUT`, including zero. A JavaScript subscription joins at the current group: on draft 18 it fetches the group's head with a Relative Joining `FETCH`, and from draft 20 asks for it with a fill. Datagrams are never fetchable. Subscribers still request ranges upstream, one per run of missing groups; a third-party publisher can answer those ranges and mark their gaps. A Rust reader that only fetches learns the track from `TRACK_STATUS`, so a finished track stays fetchable; a reader whose publisher refuses `TRACK_STATUS` as `NOT_SUPPORTED` still subscribes. +- **History is served one group at a time.** Our moq-transport publishers answer a `FETCH` only within one group, a draft-18 joining `FETCH` for the subscription's current group head, and a draft 20+ fill for the largest group's head. Whole-group fetches wait for an open group to finish. Both implementations accept and ignore `FILL_TIMEOUT`, including zero. A JavaScript subscription joins at the current group: on draft 18 it fetches the group's head with a Relative Joining `FETCH`, and from draft 20 asks for it with a fill. Datagrams are never fetchable. Subscribers still request ranges upstream, one per run of missing groups; a third-party publisher can answer those ranges and mark their gaps. A Rust reader that only fetches learns the track from `TRACK_STATUS`, so a finished track stays fetchable; a refused `TRACK_STATUS` fails that reader's request, whatever the code, rather than falling back to a `SUBSCRIBE`. +- **A requester's FIN.** On draft 18 a requester finishing its stream cancels its request, except after `TRACK_STATUS`: nothing can follow it, so the FIN only ends the requester's input and the request is still answered. From draft 20 a FIN never cancels; a reset or `STOP_SENDING` does. - **Compression.** Rust peers exchange compressed tracks when both offer the [Flate extension](/draft/moq-flate). Other peers receive one shared inflated copy. A publisher that seals the compression declaration makes that fallback unavailable: an incompatible peer is refused, preserving the sealed metadata. JavaScript does not offer the IETF extension. - **Timing.** A track whose `SUBSCRIBE_OK` declares no `TIMESCALE` is untimed. A Rust reader that never subscribed takes the units from `TRACK_STATUS`. - **Strict SETUP and parameters.** Repeated unknown `SETUP` options, GREASE included, are accepted if well-formed; a repeated known option is rejected. A `GROUP_ORDER` other than Ascending (1) or Descending (2) closes the session. An unknown message parameter, or one defined only for another message, closes the session. Other malformed control input closes the session with the draft's code too, such as a server `SETUP` carrying `PATH` or `AUTHORITY`, a namespace field ending in `/` (it would map to a path with an empty segment), a request cut short by FIN, or a second `GOAWAY` on one stream; a first `GOAWAY` on a request stream is legal. From bbc3ec32dad46b842272a987ad7f318d61755b08 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 31 Oct 2026 22:43:22 -0700 Subject: [PATCH 3/4] quest: the draft-18 TRACK_STATUS FIN quest is done Co-Authored-By: Claude Opus 5.5 --- quest/m1/interop-coverage/README.md | 1 - .../m1/interop-coverage/draft18-status-fin.md | 33 ------------------- 2 files changed, 34 deletions(-) delete mode 100644 quest/m1/interop-coverage/draft18-status-fin.md diff --git a/quest/m1/interop-coverage/README.md b/quest/m1/interop-coverage/README.md index 7c6d4177e78..36d24b8f589 100644 --- a/quest/m1/interop-coverage/README.md +++ b/quest/m1/interop-coverage/README.md @@ -44,7 +44,6 @@ coverage on `main` at `3ab6cbf81d`. ## Required -- [Draft-18 TRACK_STATUS FIN](/quest/m1/interop-coverage/draft18-status-fin.md) - a draft-18 TRACK_STATUS followed at once by a FIN is answered, so moqx-forwarded status requests reach moq-dev publishers - [JS namespace lifecycle](/quest/m1/interop-coverage/js-namespace-done.md) - the runner's moq-dev-js client moves to an `@moq/net` that withdraws namespaces by reset, so subscribe-namespace-lifecycle passes on Cloudflare draft-18 and aiomoqt - [JS subgroup data through imquic](/quest/m1/interop-coverage/js-imquic-objects.md) - the runner's moq-dev-js client moves to an `@moq/net` patch that writes data stream headers in one write, so data-subgroup-basic passes against imquic - [JS subscribers FETCH](/quest/m1/interop-coverage/js-ietf-fetch.md) - `@moq/net` fetches past groups over moq-transport, and joins the CLI FETCH round diff --git a/quest/m1/interop-coverage/draft18-status-fin.md b/quest/m1/interop-coverage/draft18-status-fin.md deleted file mode 100644 index fddb0d801dc..00000000000 --- a/quest/m1/interop-coverage/draft18-status-fin.md +++ /dev/null @@ -1,33 +0,0 @@ -# [S] A draft-18 TRACK_STATUS followed at once by a FIN is answered - -## Goal - -On draft 18, a moq-net publisher (Rust and `@moq/net`) answers a TRACK_STATUS whose requester FINs right after sending it, with TRACK_STATUS_OK or REQUEST_ERROR, instead of resetting the stream with CANCELLED. A reset or STOP_SENDING still withdraws it. Every other draft-18 request keeps treating a requester FIN as a cancel. A unit test sends TRACK_STATUS plus an immediate FIN on drafts 18, 20 and 22 and gets an answer on each. `doc/concept/standard.md` no longer says a reader whose publisher refuses `TRACK_STATUS` still subscribes, where that reader only queries or fetches. - -## Plan - -Decided 2026-10-31 (maintainer, `/quest-import` of [moq-dev/moq#7438](https://github.com/moq-dev/moq/issues/7438) and [moq-dev/moq#7423](https://github.com/moq-dev/moq/issues/7423)). - -moxygen FINs right after TRACK_STATUS on draft 18+, since nothing can follow one. The WG agrees this is normal (moq-wg/moq-transport#1634), and draft 19 §3.3.2 says a FIN is not a cancellation. On draft 18, `rs/moq-net/src/ietf/request_stream.rs:11` `fin_cancels` treats any requester FIN as a withdrawal. So a TRACK_STATUS forwarded by a moxygen-based relay such as moqx is reset, and a moq-lite viewer behind moq-relay never subscribes. - -- Scope of the FIN rule: - - ✅ TRACK_STATUS only: a FIN only ends a TRACK_STATUS requester's input, on every draft. Our own draft-18 requesters keep cancelling other requests by FIN. - - FIN never cancels on draft 18 (except SUBSCRIBE_NAMESPACE/SUBSCRIBE_TRACKS, §6.1) - - Won't fix -- The fix is in [moq-dev/moq#7439](https://github.com/moq-dev/moq/pull/7439), an external contributor's draft that allows maintainer edits, with exactly this scope. Rust passes `fin_cancels: bool` through `poll_cancel`/`poll_withdrawn`/`until_withdrawn`/`resolve`, and `serve_track_status_stream` passes `false`. JS `RequestStream` takes `{ finCancels }`. Review it, mark it ready, and land it. Push the doc fix below onto it, or land it as a follow-up commit. -- #7423 asked that a TRACK_INFO behind a publisher refusing TRACK_STATUS fall back to subscribing: - - ✅ Won't fix + doc fix: publishers must answer TRACK_STATUS. moqxr should implement it, which the maintainer called "really not hard". This matches the 2026-10-29 rejection of blind subscribing on [moq-dev/moq#7187](https://github.com/moq-dev/moq/pull/7187). - - Fallback subscribe - - Keep open, defer -- Doc: `doc/concept/standard.md:31` ends with "a reader whose publisher refuses `TRACK_STATUS` as `NOT_SUPPORTED` still subscribes". That is left over from the fallback that [moq-dev/moq#5991](https://github.com/moq-dev/moq/pull/5991) removed. Reword it so only a subscribing reader still subscribes, while a query-only or fetch-only reader fails, as `a_refused_track_status_never_subscribes` (`rs/moq-net/src/ietf/subscriber.rs`) pins. -- Not here: moqx's GROUP_ORDER parameter in TRACK_STATUS_OK, which draft 18 refuses. That is upstream moxygen's fix, facebookexperimental/moxygen#264, tracked by [Moxygen pin bump](/quest/m1/moxygen-pin-bump.md). - -Public API: none. Wire: a draft-18 TRACK_STATUS is no longer withdrawn by a FIN alone. `release` refuses TRACK_STATUS, so nothing needs backporting. - -## Closes - -- [#7438](https://github.com/moq-dev/moq/issues/7438) - draft-18 TRACK_STATUS followed by a FIN is reset instead of answered - -## Related - -- [Moxygen pin bump](/quest/m1/moxygen-pin-bump.md) - the other half of playing through moqx on draft 18 From f721a41f80991d47a55bd5238191e4074e3d59b4 Mon Sep 17 00:00:00 2001 From: quest fixer Date: Sun, 1 Nov 2026 08:03:54 -0800 Subject: [PATCH 4/4] test(net): adapt TRACK_STATUS FIN test to current stream dispatch signature --- rs/moq-net/src/ietf/publisher.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/rs/moq-net/src/ietf/publisher.rs b/rs/moq-net/src/ietf/publisher.rs index dbeee5fdf76..49a74444adf 100644 --- a/rs/moq-net/src/ietf/publisher.rs +++ b/rs/moq-net/src/ietf/publisher.rs @@ -8600,12 +8600,7 @@ mod serve_tests { let task = h .publisher .clone() - .handle_stream( - ietf::TrackStatus::ID, - ietf::Body(bytes::Bytes::from(body)), - stream, - false, - ) + .handle_stream(ietf::TrackStatus::ID, ietf::Body(bytes::Bytes::from(body)), stream) .unwrap(); kio::clock::timeout(std::time::Duration::from_secs(1), task) .await