diff --git a/doc/concept/moq-lite.md b/doc/concept/moq-lite.md index 38a72e4ff0..2efcb0e9a5 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 69e7a2e287..4ede687949 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 7809b78a22..60bf94ce66 100644 --- a/js/net/src/ietf/subscriber.ts +++ b/js/net/src/ietf/subscriber.ts @@ -1643,7 +1643,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 7912e4b62c..8f18c09ec1 100644 --- a/js/net/src/lite/publisher.test.ts +++ b/js/net/src/lite/publisher.test.ts @@ -611,8 +611,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 904877b625..a99ec62ca9 100644 --- a/js/net/src/track.test.ts +++ b/js/net/src/track.test.ts @@ -1382,6 +1382,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 } }); @@ -4610,11 +4622,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); @@ -4623,8 +4636,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 a3af08b498..5345da801b 100644 --- a/js/net/src/track.ts +++ b/js/net/src/track.ts @@ -173,11 +173,11 @@ export interface Info { priority: number; /** When a reader asks for a new group: on a live join, on a {@link Subscriber.refresh}, or both. See {@link Refresh}. */ refresh: Refresh; - /** 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; @@ -2578,10 +2578,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 3f149e6daa..0000000000 --- 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/quest/m3/release/migrate-audit.md b/quest/m3/release/migrate-audit.md index 0f44281600..69b868ab64 100644 --- a/quest/m3/release/migrate-audit.md +++ b/quest/m3/release/migrate-audit.md @@ -46,6 +46,13 @@ m1 quest on 2026-10-22. [moq-dev/moq#8987](https://github.com/moq-dev/moq/pull/8987) and [moq-dev/moq#9053](https://github.com/moq-dev/moq/pull/9053) removed them. + And both `js/net/MIGRATE.md` and `rs/moq-net/MIGRATE.md` say, under "A + timed track refuses a group that rewinds (#5803)", that a track received + over moq-transport stays unchecked, which + [moq-dev/moq#9028](https://github.com/moq-dev/moq/pull/9028) overturned: + a group received over moq-transport is checked too, since its time is its + Group ID, and only a moq-lite-05/06 copy keeps its timestamps unchecked, + so "serves both on" becomes "serves it on". - Run the API-diff report on the cut PR and read the diff of the hand-written binding wrappers (`py/moq-rs`, `kt/moq`, `dart/moq`, `go/wrapper`, `swift`, `cpp/moq`, `cpp/obs`) and of each binary's flags, diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index b1d5939e78..540402227c 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -16913,10 +16913,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"])]); @@ -16931,7 +16931,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() @@ -16939,8 +16938,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 8e9d738043..1bc52fcb08 100644 --- a/rs/moq-net/src/lite/ietf.rs +++ b/rs/moq-net/src/lite/ietf.rs @@ -1132,9 +1132,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]] { @@ -1189,19 +1189,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 c788c7cc20..632821e26b 100644 --- a/rs/moq-net/src/model/resume.rs +++ b/rs/moq-net/src/model/resume.rs @@ -9495,15 +9495,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 ead2ef5aac..e0decd378a 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -177,7 +177,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, } @@ -362,8 +361,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) } @@ -1493,11 +1491,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);