diff --git a/doc/concept/moq-lite.md b/doc/concept/moq-lite.md index c5ede1661b5..f23cf2ddaef 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..4ede6879498 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. @@ -193,7 +191,7 @@ The receiver parses the keys inside the Immutable Properties from its value, whi It SHOULD read them from the value when needed rather than hold them beside it, as a list of IDs can cost several times the value. A TRACKS_ADD ({{moql}} Tracks Stream) embeds TRACK_INFO without TRACK_PROPERTIES, so when the extension is negotiated a subscriber MUST NOT skip the Track Stream for a track it learned from a listing. -Lacking the Version, a TRACKS_ADD cannot mark a {{moqt}} track's timestamps as unchecked ({{timestamps}}). +Lacking the Version, a TRACKS_ADD cannot say whether the track's Group Streams carry Object Records ({{group}}). # Security Considerations diff --git a/js/net/src/ietf/subscriber.ts b/js/net/src/ietf/subscriber.ts index ab861726496..35fda291f3c 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/lite/publisher.test.ts b/js/net/src/lite/publisher.test.ts index 8d0f15e8c77..dbe938a834c 100644 --- a/js/net/src/lite/publisher.test.ts +++ b/js/net/src/lite/publisher.test.ts @@ -607,8 +607,8 @@ test.each([0, 5, 6, 7])("a fetched cached tail keeps absolute indices from %s", } }); -// An unchecked track's frames go out with their own timestamps, which may be moq-transport -// arrival times, rather than their send time. +// An unchecked (lite-05/06) track's frames go out with their own timestamps, which may be an +// untimed origin's send times, rather than this hop's send time. test("lite draft-06: an unchecked track's fetched frames carry their own timestamp", async () => { const pair = createMockTransportPair(ALPN_06); const origin = new OriginProducer(); diff --git a/js/net/src/track.test.ts b/js/net/src/track.test.ts index eb353b62b67..f9e0b5f3644 100644 --- a/js/net/src/track.test.ts +++ b/js/net/src/track.test.ts @@ -1053,6 +1053,18 @@ test("an untimed track reads time anchors as keys", () => { expect(readable(reader)).toEqual([5n, 10n]); }); +// 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 (const key of [0n, 1000n, 2000n]) stampGroup(producer, key, Number(key)); + const reader = producer.subscribe({ + delay: { max: null }, + ranges: [{ start: { time: 1500n } }], + }); + expect(readable(reader)).toEqual([1000n, 2000n]); +}); + test("only unstated minimums aggregate to an unstated one", () => { const producer = new TrackProducer("test"); producer.subscribe({ delay: { min: null } }); @@ -4280,11 +4292,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); @@ -4293,8 +4306,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 1c5ea22ddb9..0b9a47efbac 100644 --- a/js/net/src/track.ts +++ b/js/net/src/track.ts @@ -174,11 +174,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; @@ -2289,10 +2289,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; } /** 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 1810e418b6b..0a8108d773b 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -16917,10 +16917,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"])]); @@ -16935,7 +16935,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() @@ -16943,8 +16942,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 4a8f327b4cb..fb0742cd9cf 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) } @@ -1226,11 +1224,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);