From 3481d2ed91bdf65bee9920254f2a66b8cfd83aa7 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 11:31:59 -0800 Subject: [PATCH 1/5] chore(quest): claim quest/m2/ietf-rewind-check.md Quest-Claim: f813fd72228ffe04 From fac7d48a36875b98a6841f98ec183d531c1f0185 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 12:05:09 -0800 Subject: [PATCH 2/5] feat(net): moq-transport tracks get the rewind check A moq-transport frame's time is its Group ID since #8918, so its timestamps cannot rewind. Drop the exemption in Rust and JS, and JS's refusal of time anchors on moq-transport copies. Co-Authored-By: Claude Opus 5.5 --- doc/concept/moq-lite.md | 8 +++----- drafts/draft-lcurley-moq-ietf.md | 2 -- js/net/src/ietf/subscriber.ts | 1 - js/net/src/track.test.ts | 23 ++++++++++++----------- js/net/src/track.ts | 13 ++++--------- quest/m2/ietf-rewind-check.md | 22 ---------------------- rs/moq-net/src/ietf/subscriber.rs | 14 ++++++++------ rs/moq-net/src/lite/ietf.rs | 20 +++++++++++--------- rs/moq-net/src/model/resume.rs | 7 ++----- rs/moq-net/src/model/track.rs | 10 ++-------- 10 files changed, 42 insertions(+), 78 deletions(-) delete mode 100644 quest/m2/ietf-rewind-check.md diff --git a/doc/concept/moq-lite.md b/doc/concept/moq-lite.md index 336387708f6..a53dd85dcd4 100644 --- a/doc/concept/moq-lite.md +++ b/doc/concept/moq-lite.md @@ -375,11 +375,9 @@ without a timescale, each frame stamped with its group's start. A publisher refuses a group that starts before a lower one, and so does a moq-lite 07 receiver. A receiver passes on the timestamps it gets over moq-lite 05 and 06 without checking them, since their send times look like media time and -an older group fetched later would look like a rewind. Timestamps received over -moq-transport, whose peers may stamp arrival times, are not checked either. A -relay serves both on over every version. Over moq-lite 07 the -[ietf extension](/draft/moq-ietf) keeps moq-transport ones unchecked; without -it, the receiver checks them and may refuse a group that rewinds. +an older group fetched later would look like a rewind. A relay serves them on +over every version. A moq-transport frame's time is its Group ID, so its +timestamps cannot rewind and are checked like any other. A publisher may [compress](/concept/compression) a track, which pays off for repetitive data such as JSON and not for media. Each group's frames become one diff --git a/drafts/draft-lcurley-moq-ietf.md b/drafts/draft-lcurley-moq-ietf.md index 69e7a2e2877..5e1ea269156 100644 --- a/drafts/draft-lcurley-moq-ietf.md +++ b/drafts/draft-lcurley-moq-ietf.md @@ -143,8 +143,6 @@ Other properties are opaque to this extension. ## Timestamps {#timestamps} A relay MUST preserve a relayed track's Timescale and timestamps across a negotiated hop. A nonzero Version identifies a track from MoQ Transport, whose objects take their time from their Group ID, in the track's Timescale. -The receiver MUST NOT apply moq-lite's group-start rewind check to such a track; a Version of zero retains that check. -Without this extension, or in a listing ({{track}}), the receiver may check them like native moq-lite timestamps and refuse a Group that rewinds. The FRAME's Timestamp is the object's time. A Timestamp property (0x10) a {{moqt}} publisher attached, mutable or sealed, is opaque like any other: it stays in the Property Block, and a relay neither reads nor restates it. diff --git a/js/net/src/ietf/subscriber.ts b/js/net/src/ietf/subscriber.ts index da2b5cf9c51..c03d6d43688 100644 --- a/js/net/src/ietf/subscriber.ts +++ b/js/net/src/ietf/subscriber.ts @@ -1647,7 +1647,6 @@ export class Subscriber { priority: fromWire(ok.properties.priority ?? DEFAULT_WIRE), // No MAX_CACHE_DURATION sets no publisher limit, not the authored default. maxAge: maxCacheDuration === undefined ? null : Duration.millis(Number(maxCacheDuration)), - // A moq-transport peer may stamp arrival times, and nothing on the wire says it didn't. ietf: version, }); const producer = known ?? staged?.producer; diff --git a/js/net/src/track.test.ts b/js/net/src/track.test.ts index 38b04701455..3f5498f9a6c 100644 --- a/js/net/src/track.test.ts +++ b/js/net/src/track.test.ts @@ -1037,17 +1037,13 @@ test("a drop a time end settles over is reported", () => { expect(hooks.tryRecvGroup(reader, true)).toEqual({ kind: "drop", start: 1n, end: 2n, error: DROPPED }); }); -test("an untimed track or a moq-transport copy refuses a time anchor", () => { +test("an untimed track refuses a time anchor", () => { const ranges = [{ start: { time: Timestamp.fromMillis(0) } }]; const untimed = new TrackProducer("test"); untimed.accept({}); const reader = untimed.subscribe({ ranges }); untimed.createGroup(0n).finish(); expect(() => reader.tryRecvGroup()).toThrow(TimestampMismatch); - - const copy = new TrackProducer("test"); - copy.accept({ timescale: Timescale.MILLI, ietf: IetfVersion.DRAFT_18 }); - expect(() => copy.subscribe({ ranges }).tryRecvGroup()).toThrow("moq-transport"); }); test("only unstated minimums aggregate to an unstated one", () => { @@ -4289,11 +4285,12 @@ test("an endless track with gaps remembers only those within the budget", () => } }); -for (const [name, extra] of [ - ["unchecked", { unchecked: true }], - ["IETF provenance", { ietf: IetfVersion.DRAFT_22 }], +for (const [name, extra, checked] of [ + ["unchecked", { unchecked: true }, false], + // A moq-transport frame's time is its Group ID, so it cannot rewind and is checked. + ["IETF provenance", { ietf: IetfVersion.DRAFT_22 }, true], ] as const) { - test(`${name} survives normalization and skips the rewind check`, () => { + test(`${name} survives normalization and ${checked ? "keeps" : "skips"} the rewind check`, () => { for (const timescale of [null, Timescale.MILLI]) { const info = authoredInfo({ ...extra, timescale }); expect(info).toMatchObject(extra); @@ -4302,8 +4299,12 @@ for (const [name, extra] of [ const producer = new TrackProducer("rewind").accept({ timescale: Timescale.MILLI, ...extra }); try { stampGroup(producer, 0n, 1000); - stampGroup(producer, 1n, 500); - producer.writeFrame({ payload: enc.encode("arrival"), timestamp: Timestamp.fromMillis(250) }); + if (checked) { + expect(() => stampGroup(producer, 1n, 500)).toThrow(TimestampMismatch); + } else { + stampGroup(producer, 1n, 500); + producer.writeFrame({ payload: enc.encode("arrival"), timestamp: Timestamp.fromMillis(250) }); + } } finally { producer.finish(); producer.close(); diff --git a/js/net/src/track.ts b/js/net/src/track.ts index 5469269bf6b..11ec003481c 100644 --- a/js/net/src/track.ts +++ b/js/net/src/track.ts @@ -176,11 +176,11 @@ export interface Info { * one is pending. `0` asks on any join after a delta. An integer in `0..2^32`. */ refresh: number | null; - /** The original moq-transport publisher's draft, whose timestamps may rewind. @internal */ + /** The original moq-transport publisher's draft. @internal */ ietf?: IetfVersion; /** * Whether this copy's groups skip the rewind check, since its timestamps may be lite-05/06 send - * times. An {@link Info.ietf} track skips it too. Mirrors the Rust `track::Info::unchecked`. + * times. Mirrors the Rust `track::Info::unchecked`. * @internal */ unchecked?: boolean; @@ -2193,10 +2193,9 @@ export class Producer { return group; } - // Whether this track's timestamps may rewind (see {@link Info.unchecked} and {@link Info.ietf}). + // Whether this track's timestamps may rewind (see {@link Info.unchecked}). #unchecked(): boolean { - const info = this.#state.info.peek(); - return info?.unchecked === true || info?.ietf !== undefined; + return this.#state.info.peek()?.unchecked === true; } /** @@ -3238,10 +3237,6 @@ export class Subscriber { } const info = this.#state.info.peek(); if (info && info.timescale == null && hasTime(ranges)) return new TimestampMismatch(); - // Its timestamps may rewind, so its group starts are never checked or indexed. - if (info?.ietf !== undefined && hasTime(ranges)) { - return new Error("a time anchor needs timestamps that never rewind, which moq-transport does not promise"); - } if (this.#resume || this.#window.settled) return undefined; // The live feed had no group when the ranges resolved, so the newest one then was the first. const latest = this.#window.pending ? this.#state.first : this.#latestGroup(); diff --git a/quest/m2/ietf-rewind-check.md b/quest/m2/ietf-rewind-check.md deleted file mode 100644 index 3f149e6daa7..00000000000 --- a/quest/m2/ietf-rewind-check.md +++ /dev/null @@ -1,22 +0,0 @@ -# [S] moq-transport tracks get the rewind check - -## Goal - -A moq-transport track is checked for timestamp rewinds like any other timed -track. The exemption goes: `Info.ietf` in Rust (`track::Info::ietf()`, the -`unchecked` copy path in `rs/moq-net/src/model/track.rs` and -`rs/moq-net/src/lite/ietf.rs`, and the moq-transport subscriber's -`unchecked` marking) and in JS (`Info.ietf` in `js/net/src/track.ts` and its -rewind check). Rust and JS change together. - -## Plan - -Decided 2026-11-16 (maintainer, /quest-run): this follows -[moq-dev/moq#8918](https://github.com/moq-dev/moq/pull/8918), where a -moq-transport frame's time is its Group ID in the track's TIMESCALE and a -third party's TIMESTAMP is never read, so a moq-transport timestamp cannot -rewind and the exemption no longer has a reason. A moq-lite track that is -`unchecked` for another reason (a pre-media-time version) keeps its flag. -Confirm each remaining reader of `ietf()` is only the exemption before -deleting the field; the lite-07 `ietf` hop provenance goes with it if -nothing else reads it. diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index 2142f90687b..c201a1a0a52 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -16918,10 +16918,10 @@ mod stitch_tests { assert!(h.session.log.closes().is_empty()); } - /// A received group whose first object rewinds past the group before it is accepted: a - /// moq-transport peer may stamp arrival times, so its timed tracks are unchecked. + /// A received group whose first object rewinds past the group before it is refused: a + /// moq-transport frame's time is its Group ID, so its timed tracks are checked like any. #[kio::test] - async fn a_received_rewind_is_accepted() { + async fn a_received_rewind_is_refused() { use futures::FutureExt; let mut h = Harness::new(Fill::Done, vec![draft18_subgroup(KEY, true, 0, &[b"rewound"])]); @@ -16936,7 +16936,6 @@ mod stitch_tests { let mut stream = read_draft18(&h.session).await; h.subscriber.clone().recv_group(&mut stream).await.unwrap(); - // The stream was read to its end, so the group is already delivered. let mut group = consumer .recv_group() .now_or_never() @@ -16944,8 +16943,11 @@ mod stitch_tests { .unwrap() .unwrap(); assert_eq!(group.start, KEY); - let frame = group.read_frame().now_or_never().unwrap().unwrap().unwrap(); - assert_eq!(frame.payload.as_ref(), b"rewound"); + // The group fails, but the track stays open for the groups after it. + assert!(matches!( + group.read_frame().now_or_never().unwrap(), + Err(Error::TimestampMismatch) + )); assert!(h.track.closed().now_or_never().is_none()); } diff --git a/rs/moq-net/src/lite/ietf.rs b/rs/moq-net/src/lite/ietf.rs index c700b64e0f2..48699b09d3a 100644 --- a/rs/moq-net/src/lite/ietf.rs +++ b/rs/moq-net/src/lite/ietf.rs @@ -1127,9 +1127,9 @@ mod hop_tests { drop(sessions); } - /// Every hop carries IETF times, and provenance keeps them unchecked after a hop that - /// negotiated the extension. A peer declining it checks them like native moq-lite, as a - /// listing's copy does. SUBSCRIBE and FETCH must agree with TRACK_INFO. + /// Every hop carries IETF times, and provenance survives a hop that negotiated the + /// extension. A peer declining it, like a listing, sees a native moq-lite track. + /// SUBSCRIBE and FETCH must agree with TRACK_INFO. #[kio::test] async fn ietf_timestamps_keep_their_provenance_across_a_hop() { for offer in [[true, true], [true, false], [false, true]] { @@ -1184,19 +1184,21 @@ mod hop_tests { .await .unwrap() .unwrap(); - // A peer may have stamped arrival times. The second group's rewind must not - // acquire native moq-lite checks merely because it crossed a negotiated hop; - // without the extension, the copy is checked, so it advances instead. - let start = if negotiated { ts(50) } else { ts(150) }; let mut group = track.create_group(1u64.into()).unwrap(); - group.write_frame(start, b"frame".to_vec()).unwrap(); + group.write_frame(ts(150), b"frame".to_vec()).unwrap(); group.finish().unwrap(); let mut received = recv(&mut subscriber).await; assert_eq!(received.start, 1); let frame = next(&mut received).await.unwrap(); - assert_eq!(frame.timestamp, start, "{offer:?}"); + assert_eq!(frame.timestamp, ts(150), "{offer:?}"); assert_eq!(&frame.payload.contiguous(0)[..], b"frame"); assert!(next(&mut received).await.is_none()); + // Provenance exempts nothing from the rewind check. + let mut rewound = track.create_group(2u64.into()).unwrap(); + assert!(matches!( + rewound.write_frame(ts(50), b"frame".to_vec()), + Err(crate::Error::TimestampMismatch) + )); drop(sessions); } } diff --git a/rs/moq-net/src/model/resume.rs b/rs/moq-net/src/model/resume.rs index 2dbdb619e1d..246a1ce1c1b 100644 --- a/rs/moq-net/src/model/resume.rs +++ b/rs/moq-net/src/model/resume.rs @@ -7706,15 +7706,12 @@ mod test { let mut group = recv(&mut sub); assert_eq!(read(&mut group), Some(b"held".to_vec())); - // A moq-transport route's copy, whose timestamps are never checked for a rewind. + // A lite-05/06 route's copy, whose timestamps are never checked for a rewind. let b = track::Producer::new( Arc::new(broadcast::Info::default()), "video", crate::track::Info { - properties: Some(Arc::new(crate::model::object::TrackProperties { - version: crate::ietf::Version::Draft22, - values: Vec::new(), - })), + unchecked: true, ..crate::track::Info::timed() }, ); diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index 200ec629bcb..13830f4ee00 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -181,7 +181,6 @@ pub struct Info { pub(crate) properties: Option>, /// Whether this copy's groups skip the rewind check: set on a lite-05/06 copy, whose /// untimed origin stamps send times, so an older group fetched later looks like a rewind. - /// A track with moq-transport provenance ([`Self::ietf`]) skips it too. #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) unchecked: bool, } @@ -305,8 +304,7 @@ impl Info { } } - /// The original moq-transport publisher's draft, whose timestamps may rewind, or - /// `None` for a native moq-lite track. + /// The original moq-transport publisher's draft, or `None` for a native moq-lite track. pub(crate) fn ietf(&self) -> Option { self.properties.as_ref().map(|properties| properties.version) } @@ -1227,11 +1225,7 @@ impl TrackState { /// Usually one group lookup each way; only unstarted or partial neighbors are skipped. /// `None` on an [unchecked](Info::unchecked) track, whose timestamps may rewind. pub(super) fn neighbors(&self, key: u64) -> Option { - if self - .info - .as_ref() - .is_some_and(|info| info.unchecked || info.ietf().is_some()) - { + if self.info.as_ref().is_some_and(|info| info.unchecked) { return None; } let bounds = self.bounds.lock().unwrap_or_else(PoisonError::into_inner); From e9af3419797828fd08a09af54fd94d09b0371457 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 15:28:27 -0800 Subject: [PATCH 3/5] test(net): a moq-transport copy resolves a time anchor Co-Authored-By: Claude Opus 5.5 --- js/net/src/track.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/net/src/track.test.ts b/js/net/src/track.test.ts index 3f5498f9a6c..d4c660d70bc 100644 --- a/js/net/src/track.test.ts +++ b/js/net/src/track.test.ts @@ -1046,6 +1046,18 @@ test("an untimed track refuses a time anchor", () => { expect(() => reader.tryRecvGroup()).toThrow(TimestampMismatch); }); +// A moq-transport frame's time is its Group ID, so its starts never rewind and index like any. +test("a moq-transport copy resolves a time anchor", () => { + const producer = new TrackProducer("test"); + producer.accept({ timescale: Timescale.MILLI, maxAge: null, ietf: IetfVersion.DRAFT_18 }); + for (let sequence = 0n; sequence < 3n; sequence++) stampGroup(producer, sequence, Number(sequence) * 1000); + const reader = producer.subscribe({ + delay: { max: null }, + ranges: [{ start: { time: Timestamp.fromMillis(1500) } }], + }); + expect(readable(reader)).toEqual([1n, 2n]); +}); + test("only unstated minimums aggregate to an unstated one", () => { const producer = new TrackProducer("test"); producer.subscribe({ delay: { min: null } }); From 73828d786b090d1c6927e474c02e84cb957b0d1f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 19:20:05 -0800 Subject: [PATCH 4/5] test(net): a moq-transport time anchor is a bare key after #9027 --- js/net/src/track.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/net/src/track.test.ts b/js/net/src/track.test.ts index 53676f375bf..f9e0b5f3644 100644 --- a/js/net/src/track.test.ts +++ b/js/net/src/track.test.ts @@ -1060,7 +1060,7 @@ test("a moq-transport copy resolves a time anchor", () => { for (const key of [0n, 1000n, 2000n]) stampGroup(producer, key, Number(key)); const reader = producer.subscribe({ delay: { max: null }, - ranges: [{ start: { time: Timestamp.fromMillis(1500) } }], + ranges: [{ start: { time: 1500n } }], }); expect(readable(reader)).toEqual([1000n, 2000n]); }); From 2e014364f32677ed4c8c3376b5bffa8289d8a343 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 19:29:03 -0800 Subject: [PATCH 5/5] docs(net): leave MIGRATE.md to the release cut --- js/net/MIGRATE.md | 5 ++--- rs/moq-net/MIGRATE.md | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/js/net/MIGRATE.md b/js/net/MIGRATE.md index d5bad445a87..d43665e8430 100644 --- a/js/net/MIGRATE.md +++ b/js/net/MIGRATE.md @@ -350,9 +350,8 @@ A new group or datagram raises it at frame 0 before any frame lands, and it can A local write whose first frame starts before a lower-sequence group's, or after a higher one's, throws `TimestampMismatch`. A group received over moq-lite-07 is checked the same way. -A group received over moq-transport is checked too, since its time is its Group ID. -A track received over moq-lite-05/06 keeps its timestamps unchecked, since they may be an untimed origin's send times. -A relay serves it on over every version, where a moq-lite-07 receiver checks them and may refuse a group that rewinds. +A track received over moq-lite-05/06 keeps its timestamps unchecked, since they may be an untimed origin's send times, and so does one received over moq-transport. +A relay serves both on over every version, where a moq-lite-07 receiver checks them and may refuse a group that rewinds. A publisher whose timeline restarts publishes a new broadcast instead. ### `Auth.Auth` is `Auth.Handle`, and `Auth.Token` is `Auth.Auth` (#5695) diff --git a/rs/moq-net/MIGRATE.md b/rs/moq-net/MIGRATE.md index 197218b6f4c..1355e33844c 100644 --- a/rs/moq-net/MIGRATE.md +++ b/rs/moq-net/MIGRATE.md @@ -607,9 +607,8 @@ let rate = bandwidth.as_ref().and_then(|b| b.peek()); A local write whose first frame starts before a lower-sequence group's, or after a higher one's, fails with `TimestampMismatch`; `@moq/net` throws it the same way. A group received over moq-lite-07 is checked the same way. -A group received over moq-transport is checked too, since its time is its Group ID. -A track received over moq-lite-05/06 keeps its timestamps unchecked, since they may be an untimed origin's send times. -A relay serves it on over every version, where a moq-lite-07 receiver checks them and may refuse a group that rewinds. +A track received over moq-lite-05/06 keeps its timestamps unchecked, since they may be an untimed origin's send times, and so does one received over moq-transport. +A relay serves both on over every version, where a moq-lite-07 receiver checks them and may refuse a group that rewinds. A publisher whose timeline restarts, such as an HLS `EXT-X-DISCONTINUITY` that resets decode times, publishes a new broadcast instead. ### Broadcast `finish` is gone