From 1bab12acd3826fb05b92d03d3c2fdb430bcef769 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 17:12:44 -0800 Subject: [PATCH 1/6] chore(quest): claim quest/m2/time-addressing/scale-less-arrival.md Quest-Claim: d35f0dc05081d1b5 From feff1ed046a0f7c512beddcb6fcc106caa2ecf8c Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 17:49:04 -0800 Subject: [PATCH 2/6] wip: a scale-less track ages by arrival, and lite-05/06 stamp its group's start Co-Authored-By: Claude Opus 5.5 --- doc/concept/moq-lite.md | 11 ++- doc/setup/upgrade.md | 4 +- drafts/draft-lcurley-moq-lite.md | 4 +- js/net/src/lite/publisher.test.ts | 60 +++++++++++- js/net/src/lite/publisher.ts | 44 +++------ js/net/src/lite/subscriber.test.ts | 2 +- js/net/src/lite/version.ts | 8 +- js/net/src/track.test.ts | 27 +++++ js/net/src/track.ts | 49 ++++------ js/net/src/untimed.test.ts | 35 ++++--- quest/m2/README.md | 1 - quest/m2/time-addressing/group-times.md | 1 - .../m2/time-addressing/scale-less-arrival.md | 54 ---------- rs/moq-net/fixtures/stamps.json | 16 +++ rs/moq-net/src/fuzz/ingest.rs | 2 +- rs/moq-net/src/lite/publisher.rs | 55 ++++++++++- rs/moq-net/src/lite/track.rs | 2 +- rs/moq-net/src/lite/version.rs | 7 +- rs/moq-net/src/model/track.rs | 98 ++++++++++++------- 19 files changed, 287 insertions(+), 193 deletions(-) delete mode 100644 quest/m2/time-addressing/scale-less-arrival.md create mode 100644 rs/moq-net/fixtures/stamps.json diff --git a/doc/concept/moq-lite.md b/doc/concept/moq-lite.md index 2efcb0e9a5..d3d649e40d 100644 --- a/doc/concept/moq-lite.md +++ b/doc/concept/moq-lite.md @@ -368,14 +368,15 @@ A track is timed or untimed: it declares a timescale or none, and a frame that doesn't match is refused. No receiver fills in an arrival time, so an untimed track is judged by the wall clock alone. Tracks from moq-lite before 05, or from moq-transport without a `TIMESCALE`, arrive -untimed. moq-lite 05 and 06 cannot declare an untimed track, so there its -frames go out stamped with their send time; the work-in-progress 07 carries it -without a timescale, each frame stamped with its group's start. +untimed. moq-lite 05 and 06 cannot declare an untimed track, so there it goes +out as milliseconds, each frame stamped with its group's start; the +work-in-progress 07 carries it without a timescale, with the same stamps. 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. A relay serves them on +05 and 06 without checking them, since an older publisher stamps an untimed +track there with send times, which look like media time, and 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. diff --git a/doc/setup/upgrade.md b/doc/setup/upgrade.md index 2b9d44ef4a..047968b922 100644 --- a/doc/setup/upgrade.md +++ b/doc/setup/upgrade.md @@ -87,8 +87,8 @@ These land with the next breaking release. receive.** Tracks from moq-lite before 05, and moq-transport tracks without `TIMESCALE` arrive untimed instead of stamped with their arrival time. moq-lite 05 and 06 can't encode absence and - carry a send time instead, which their receivers pass through as the track's - time; see [untimed tracks](/concept/moq-lite#subscriptions). A new subscriber with no + carry each group's start as milliseconds instead, which their receivers pass + through as the track's time; see [untimed tracks](/concept/moq-lite#subscriptions). A new subscriber with no start on an untimed track starts at the latest group. - **Max age and max delay count wall-clock time too.** A superseded group is stale once its successor arrived a full budget ago, as well as by media diff --git a/drafts/draft-lcurley-moq-lite.md b/drafts/draft-lcurley-moq-lite.md index 673c08a48b..eab5db0685 100644 --- a/drafts/draft-lcurley-moq-lite.md +++ b/drafts/draft-lcurley-moq-lite.md @@ -823,7 +823,7 @@ A group is expired once either of two ages meets the relevant `Max Age`: - Its **timestamp age** is the difference between the *newest* frame timestamp of the latest group that has at least one frame, and this group's **reach**, defined below. - Its **arrival age** is the time elapsed since its successor arrived at this hop. -On a scale-less Track, timestamp age counts bare units as the milliseconds of a Max Age. +A scale-less Track has no timestamp age: its groups expire by arrival age alone. By timestamp age, a group is expired only once it **provably cannot overlap the Max Age window**: every frame it could still present is older than the budget allows. Arrival age needs no such proof: it bounds how long a superseded group may still wait to be delivered. @@ -2371,7 +2371,7 @@ A stream that FINs without a GROUP_END carries a closed Group, which may have he - FRAME and datagrams always carry a timestamp, a bare number on a scale-less Track. - Replaced GROUP's `Group Sequence` with `Group Start`, added `Previous Start`, the start of the Group before it, so a subscriber sees the gap before a Group without a SUBSCRIBE_SKIP. - Added GROUP_END, a `Payload Length` of 0 followed by the Group's exclusive end: a Group or Fetch Stream ends with it when its Group finished, a FIN alone ends a closed Group whose frames may not all exist, and a reset aborts. A Group's own end bounds its reach. -- Expiration also measures a group's arrival age, the time since its successor arrived at this hop. +- Expiration also measures a group's arrival age, the time since its successor arrived at this hop, and only that on a scale-less Track. - A relay closes a Group it holds only the start of, without a GROUP_END. A publisher resets the Group Stream of a group that expires with OLD, even one whose GROUP_END it sent but is not yet acknowledged, and names the group in a SUBSCRIBE_DROP with OLD. - FRAME leads with `Payload Length`, the payload size plus one, in place of the trailing `Message Length`; 0 is malformed. - A publisher SHOULD drop a datagram rather than block when the transport has no room for it, where it previously sent one only if the congestion controller could transmit it immediately. diff --git a/js/net/src/lite/publisher.test.ts b/js/net/src/lite/publisher.test.ts index 02077e4971..00371d3d6d 100644 --- a/js/net/src/lite/publisher.test.ts +++ b/js/net/src/lite/publisher.test.ts @@ -35,7 +35,16 @@ import { SubscribeUpdate, } from "./subscribe.ts"; import { TrackInfo, Track as TrackMessage } from "./track.ts"; -import { ALPN_05, ALPN_06, ALPN_07_WIP, hasLengthFirst, hasRanges, keepsSubscribeOpen, Version } from "./version.ts"; +import { + ALPN_05, + ALPN_06, + ALPN_07_WIP, + hasLengthFirst, + hasRanges, + keepsSubscribeOpen, + Version, + versionName, +} from "./version.ts"; function publish(origin: OriginProducer, path: Path.Valid) { const broadcastRoute = origin.route(path); @@ -642,6 +651,55 @@ test("lite draft-06: an unchecked track's fetched frames carry their own timesta } }); +// Replays `rs/moq-net/fixtures/stamps.json`, which moq-net replays too: lite-05/06 stamp a +// scale-less frame with its group's start, never a clock, so a frame carries the same timestamp +// on every hop and fetch, and its Group Stream matches byte for byte in both languages. +const STAMPS = (await Bun.file(new URL("../../../../rs/moq-net/fixtures/stamps.json", import.meta.url)).json()) as { + name: string; + version: string; + start: number; + payloads: string[]; + hex: string; +}[]; + +test.each(STAMPS.map((stamp) => [stamp.name, stamp] as const))("%s", async (_name, stamp) => { + using clock = manual(); + const version = defined([Version.DRAFT_05, Version.DRAFT_06].find((v) => versionName(v) === stamp.version)); + const pair = createMockTransportPair(stamp.version); + const origin = new OriginProducer(); + const publisher = new Publisher(pair.server, version, randomHop(), origin.consume()); + const broadcast = publish(origin, Path.from("test")); + const track = defined(broadcast.createTrack("video", {})); + + const client = await Stream.open(pair.client, { version }); + const server = await Stream.accept(pair.server, version); + if (!server) throw new Error("publisher never accepted the subscribe stream"); + void publisher.runSubscribe( + new Subscribe({ id: 0n, broadcast: Path.from("test"), track: "video", priority: 0 }), + server, + ); + + const start = BigInt(stamp.start); + const group = track.createGroup(start); + for (const payload of stamp.payloads) group.writeFrame(textFrame(payload, Timestamp.unscaled(start))); + group.finish(); + await clock.advance(Duration.ZERO); + + const opened = pair.client.incomingUnidirectionalStreams.getReader(); + try { + const next = await opened.read(); + if (next.done) throw new Error("publisher never opened the group stream"); + const bytes = await new Response(next.value).arrayBuffer(); + expect(Buffer.from(bytes).toString("hex")).toBe(stamp.hex); + } finally { + await opened.cancel(); + publisher.close(); + client.close(); + broadcast.close(); + origin.close(); + } +}); + // How long a served-subscription test waits on its manual clock for the next group stream // before calling the publisher idle. const IDLE_MS = Duration.millis(500); diff --git a/js/net/src/lite/publisher.ts b/js/net/src/lite/publisher.ts index da9f002725..82b24e1934 100644 --- a/js/net/src/lite/publisher.ts +++ b/js/net/src/lite/publisher.ts @@ -40,9 +40,8 @@ import type { Consumer as OriginConsumer } from "../origin.ts"; import * as Path from "../path.ts"; import { readSize, sendPayload } from "../payload.ts"; import { Priority, sendOrder } from "../priority.ts"; -import { rescale } from "../rescale.ts"; import { concat, encodeVarint, type Reader, type Stream, type StreamVersion, Writer } from "../stream.ts"; -import { floorAt, type Timescale, Timestamp } from "../time.ts"; +import { floorAt, type Timescale, type Timestamp } from "../time.ts"; import type * as track from "../track.ts"; import type { Reported } from "../track.ts"; import { untilAborted } from "../util/abort.ts"; @@ -150,15 +149,9 @@ function groupEnd(version: StreamVersion, end: bigint): Uint8Array { interface Stamp { /** * The wire timescale TRACK_INFO declared (see `wireTimescale`), or undefined on a scale-less - * lite-07 track, whose timestamps go out as bare numbers: a frame's its group's start. + * lite-07 track, whose timestamps go out as bare numbers. */ timescale?: Timescale; - /** - * The timed track whose frames' own timestamps go out, at its timescale, which the wire's - * equals. Lite-05/06 cannot encode a scale-less track, so a scale-less one carries its send - * time instead. - */ - timed?: { timescale?: Timescale | null }; } /** @@ -166,26 +159,23 @@ interface Stamp { * lite-05. Lite-05/06 declare milliseconds for a scale-less track, and lite-07 stamps it bare. */ function stamping(version: Version, info: { timescale?: Timescale | null }): Stamp | undefined { - const timescale = info.timescale ?? undefined; - const wire = wireTimescale(version, timescale); + const wire = wireTimescale(version, info.timescale); if (wire === undefined) return hasLengthFirst(version) ? {} : undefined; - return timescale === undefined ? { timescale: wire } : { timescale: wire, timed: info }; + return { timescale: wire }; } /** - * A frame or datagram's `timestamp` as its raw wire value: bare on a scale-less lite-07 track, or - * its send time when a lite-05/06 track goes out scale-less. + * A frame or datagram's `timestamp` as its raw wire value. A scale-less track's is its group's + * start, or its datagram's sequence, which goes out verbatim on every version: nothing is stamped + * with a clock, so a frame carries the same timestamp through every hop and fetch. Mirrors the + * Rust `Stamp::wire`. */ function wireTime(timestamp: Timestamp, stamp: Stamp): bigint { - if (stamp.timescale === undefined) return bareTime(timestamp); - return BigInt(stamp.timed ? rescale(stamp.timed, timestamp).value : floorAt(Timestamp.now(), stamp.timescale)); -} - -/** A scale-less lite-07 datagram's timestamp as it goes out: the bare value its producer gave. */ -function bareTime(timestamp: Timestamp): bigint { const key = timestamp.key; - if (key === undefined) throw new TimestampMismatch(); - return key; + if (key !== undefined) return key; + // A timed timestamp on a track declared scale-less: the model never writes one. + if (stamp.timescale === undefined) throw new TimestampMismatch(); + return BigInt(floorAt(timestamp, stamp.timescale)); } /** @@ -2423,15 +2413,7 @@ export class Publisher { end = max(end, datagram.sequence + 1n); // An old subscription uses its stream track's timescale for both kinds. Without one // the track is a scale-less lite-07 one, whose timestamp goes out bare. - const timescale = options.stamp?.timescale; - const timestamp = - timescale === undefined - ? bareTime(datagram.timestamp) - : BigInt( - datagram.timestamp.scale === undefined - ? floorAt(Timestamp.now(), timescale) - : floorAt(datagram.timestamp, timescale), - ); + const timestamp = wireTime(datagram.timestamp, options.stamp ?? {}); const body = new DatagramMessage(options.sub, datagram.sequence, timestamp, datagram.payload).encode( this.version, ); diff --git a/js/net/src/lite/subscriber.test.ts b/js/net/src/lite/subscriber.test.ts index f8b086a45f..b7e12da34c 100644 --- a/js/net/src/lite/subscriber.test.ts +++ b/js/net/src/lite/subscriber.test.ts @@ -2830,7 +2830,7 @@ async function groupStream(timestamp: number, version: Version = Version.DRAFT_0 ); } -// Lite-05/06 stamp an untimed track's frames with their send time, which a receiver cannot tell +// A released lite-05/06 publisher stamps an untimed track's frames with their send time, which a receiver cannot tell // from media time, so it keeps every timestamp there unchecked: a group that rewinds or lands out // of order is accepted with its timestamp. test.each([Version.DRAFT_05, Version.DRAFT_06])("version %p passes received timestamps through", async (version) => { diff --git a/js/net/src/lite/version.ts b/js/net/src/lite/version.ts index c05f4a219b..cde9654b6b 100644 --- a/js/net/src/lite/version.ts +++ b/js/net/src/lite/version.ts @@ -483,9 +483,9 @@ export function hasRefresh(version: Version): boolean { } } -/** Whether received frame timestamps are the publisher's media time. Lite-05/06 stamp an untimed - * track's payloads with their send time, which a receiver cannot tell from it, so it passes them - * through as the track's time without checking them for a rewind. */ +/** Whether received frame timestamps are the publisher's media time. A released lite-05/06 + * publisher may stamp an untimed track's payloads with their send time, which a receiver cannot + * tell from it, so it passes them through as the track's time without checking them for a rewind. */ export function hasMediaTime(version: Version): boolean { // Explicitly list older versions so future versions keep the lite-07+ behavior. switch (version) { @@ -637,7 +637,7 @@ export function hasEndError(version: Version): boolean { /** * The timescale the wire carries for a track with `timescale`, or `undefined` when its frames * and datagrams carry no timestamp. Lite-05 and lite-06 always carry one, so an untimed track - * declares milliseconds there and its payloads carry their send times instead. + * declares milliseconds there and its payloads carry their group's start, or their sequence. */ export function wireTimescale(version: Version, timescale: Timescale | null | undefined): Timescale | undefined { switch (version) { diff --git a/js/net/src/track.test.ts b/js/net/src/track.test.ts index a99ec62ca9..1b61a6a7cb 100644 --- a/js/net/src/track.test.ts +++ b/js/net/src/track.test.ts @@ -1334,6 +1334,33 @@ test("a scale-less join reaches back by arrival", () => { } }); +// A scale-less track's starts and ends are bare numbers, never milliseconds, so groups whose +// starts jump age by arrival alone, anywhere in the key range, and a group finished whole waits +// for a successor. Mirrors the Rust `a_scale_less_track_ages_by_arrival_alone`. +test("a scale-less track ages by arrival alone", () => { + const clock = manualTime(0); + try { + for (const [i, base] of [0n, 1n << 61n, 2n ** 64n - 30_001n].entries()) { + clock.set(i * 1000); + const producer = new TrackProducer("test").accept({ maxAge: null }); + for (const offset of [0n, 10_000n, 20_000n]) { + const group = producer.createGroup(base + offset); + group.writeFrame(textFrame("x", Timestamp.unscaled(base + offset))); + group.finishAt(base + offset + 1n); + } + const subscribe = () => producer.subscribe({ delay: { max: Duration.millis(5) } }); + // All three arrived at once, so however far apart their starts, none is stale yet. + expect(readable(subscribe())).toEqual([base, base + 10_000n, base + 20_000n]); + // Their successors arrived a full budget ago, and the newest has none to age it. + clock.set(i * 1000 + 10); + expect(readable(subscribe())).toEqual([base + 20_000n]); + producer.close(); + } + } finally { + clock.installed.close(); + } +}); + // A time start resolves on keys alone: groups opened before their first frames, below a // reached end, are read from the one containing it. Mirrors the Rust `a_time_start_needs_no_frame`. test("a time start resolves on keys alone, before any group's first frame", () => { diff --git a/js/net/src/track.ts b/js/net/src/track.ts index 5383643d5e..43b17f0060 100644 --- a/js/net/src/track.ts +++ b/js/net/src/track.ts @@ -2917,7 +2917,7 @@ type Drift = { // The budget is the track's max age, which no widening passes: its verdicts are final. bounded: boolean; // The live edge: its group, and the newest time it presents, in milliseconds. A scale-less - // track's bare starts count as milliseconds, as the Rust `age` reads them. + // track has none: its bare starts are no time, so it ages by arrival alone. presentation?: { key: bigint; at: number }; end?: bigint; // Judged against the whole track rather than this reader's window, as a fetch is. @@ -3157,17 +3157,13 @@ export class Subscriber { let presentation: Drift["presentation"]; const info = this.#state.info.peek(); // The edge wants the newest content that exists, so it takes the newest stamped group's - // latest frame: walk back from the cap to the first one. A scale-less track's frames carry - // no timestamp, so its edge is the newest group's start. + // latest frame: walk back from the cap to the first one. A scale-less track has none, so it + // walks nothing. const scaleless = info !== undefined && info.timescale == null; - for (let i = (end === undefined ? timeline.length : timelineIndex(timeline, end)) - 1; i >= 0; i--) { + const top = scaleless ? 0 : end === undefined ? timeline.length : timelineIndex(timeline, end); + for (let i = top - 1; i >= 0; i--) { const group = timeline[i]; if (hooks.groupFailed(group) || !this.#judges(group.start, whole)) continue; - if (scaleless) { - if (!hooks.groupStarted(group)) continue; - presentation = { key: group.start, at: Number(group.start) }; - break; - } const timestamp = hooks.groupTimestamp(group); if (timestamp === undefined) continue; presentation = { key: group.start, at: (hooks.groupLatest(group) ?? timestamp).asMillis() }; @@ -3257,9 +3253,10 @@ export class Subscriber { // falls out for free. // // The wall clock judges it too: a group is also stale once its successor arrived a full - // budget ago, so a peer whose timestamps stop advancing, an untimed track, or an empty - // successor that never presents cannot pin a superseded group. The successor is re-read, - // not latched, like the reach, except by a reader holding the group: it passes `held`, so + // budget ago, so a peer whose timestamps stop advancing or an empty successor that never + // presents cannot pin a superseded group. A scale-less track has no presentation time, so + // only the wall clock judges it. The successor is re-read, not latched, like the reach, + // except by a reader holding the group: it passes `held`, so // the wall clock outlives the successor's eviction (see {@link #supersededAt}). The newest // group has no successor, so neither clock ever convicts it. `wake` arms a timer for the // wall deadline, for a held read that waits on it. @@ -3279,16 +3276,11 @@ export class Subscriber { const deadline = arrived.since(Instant.ZERO).asNanos() + drift.budget * 1_000_000; if (now().since(Instant.ZERO).asNanos() >= deadline) return true; if (wake) this.#wakeAt(deadline); - // A closed subscriber keeps no timeline to bound the reach with. - if (this.#arrivals) return false; - + // A closed subscriber keeps no timeline to bound the reach with, and only a live edge + // above `key` convicts it by media time. + if (this.#arrivals || drift.presentation === undefined || drift.presentation.key <= key) return false; const reach = this.#reach(key, drift.end, drift.whole); - return ( - drift.presentation !== undefined && - drift.presentation.key > key && - reach !== undefined && - drift.presentation.at - reach >= drift.budget - ); + return reach !== undefined && drift.presentation.at - reach >= drift.budget; } // The cached group starting at `key`, failed or not. @@ -3298,13 +3290,11 @@ export class Subscriber { return group?.start === key ? group : undefined; } - // A start or a group's end, in milliseconds of presentation time: a scale-less track's bare - // units count as milliseconds. Mirrors the Rust `TrackState::presented` and `age`. + // A start or a group's end, in milliseconds of presentation time, or undefined on a + // scale-less track, whose bare numbers are no time. Mirrors the Rust `TrackState::presented`. #presented(value: bigint): number | undefined { - const info = this.#state.info.peek(); - if (info === undefined) return undefined; - const scale = info.timescale; - return scale == null ? Number(value) : (Number(value) * 1000) / scale; + const scale = this.#state.info.peek()?.timescale; + return scale == null ? undefined : (Number(value) * 1000) / scale; } // The furthest presentation time, in milliseconds, group `key` could still reach: its own @@ -3315,14 +3305,13 @@ export class Subscriber { if (own !== undefined) return this.#presented(own); const successor = this.#successor(key, end, whole); if (!successor) return undefined; - const info = this.#state.info.peek(); - if (info !== undefined && info.timescale == null) return this.#presented(successor.start); return hooks.groupTimestamp(successor)?.asMillis(); } // When group `key`, finished whole, stops presenting on the wall clock: its arrival plus // its span, which stands in for a successor arriving, so the last group of a paused or - // finished track ages out without one. Mirrors the Rust `TrackState::ended_at`. + // finished track ages out without one. A scale-less group's span is no time, so it waits + // for a successor. Mirrors the Rust `TrackState::ended_at`. #endedAt(key: bigint): Instant | undefined { const group = this.#held(key); const end = group?.end; diff --git a/js/net/src/untimed.test.ts b/js/net/src/untimed.test.ts index 9cc3253b9d..1758ddfaed 100644 --- a/js/net/src/untimed.test.ts +++ b/js/net/src/untimed.test.ts @@ -1,6 +1,7 @@ // A track keeps its timedness end to end: no receive path fills in arrival time, a wire that // can't declare a timeline delivers frames scale-less, stamped with their group's key, and -// lite-05/06, which can't declare a scale-less one, deliver its send times. Mirrors rs/moq-net/tests/integration/untimed.rs. +// lite-05/06, which can't declare a scale-less one, deliver its group keys as milliseconds. +// Mirrors rs/moq-net/tests/integration/untimed.rs. import { expect, test } from "bun:test"; import { type Consumer as BroadcastConsumer, Producer as BroadcastProducer } from "./broadcast.ts"; import { accept, connect } from "./connection/index.ts"; @@ -23,8 +24,8 @@ interface Wire { version?: number; /** Whether a timed track arrives timed. */ declares: boolean; - /** Whether an untimed track arrives timed in milliseconds with its send times, as on lite-05/06. */ - sends: boolean; + /** Whether an untimed track arrives timed in milliseconds at its group keys, as on lite-05/06. */ + keys: boolean; /** * Whether a timed track's frames arrive at their group's key in its units rather than their * own times, as on moq-transport, which carries no Timestamp. @@ -33,13 +34,13 @@ interface Wire { } const WIRES: Wire[] = [ - { name: "lite-01", protocol: "", version: Lite.Version.DRAFT_01, declares: false, sends: false }, - { name: "lite-03", protocol: Lite.ALPN_03, declares: false, sends: false }, - { name: "lite-04", protocol: Lite.ALPN_04, declares: false, sends: false }, - { name: "lite-05", protocol: Lite.ALPN_05, declares: true, sends: true }, - { name: "lite-06", protocol: Lite.ALPN_06, declares: true, sends: true }, - { name: "lite-07-wip", protocol: Lite.ALPN_07_WIP, declares: true, sends: false }, - { name: "ietf-22", protocol: Ietf.ALPN.DRAFT_22, declares: true, sends: false, keyed: true }, + { name: "lite-01", protocol: "", version: Lite.Version.DRAFT_01, declares: false, keys: false }, + { name: "lite-03", protocol: Lite.ALPN_03, declares: false, keys: false }, + { name: "lite-04", protocol: Lite.ALPN_04, declares: false, keys: false }, + { name: "lite-05", protocol: Lite.ALPN_05, declares: true, keys: true }, + { name: "lite-06", protocol: Lite.ALPN_06, declares: true, keys: true }, + { name: "lite-07-wip", protocol: Lite.ALPN_07_WIP, declares: true, keys: false }, + { name: "ietf-22", protocol: Ietf.ALPN.DRAFT_22, declares: true, keys: false, keyed: true }, ]; /** @@ -167,23 +168,25 @@ test("a forwarded untimed track stays untimed", async () => { }); for (const wire of WIRES) { - test(`${wire.name}: an untimed track arrives ${wire.sends ? "with its send times" : "untimed"}`, async () => { + test(`${wire.name}: an untimed track arrives ${wire.keys ? "with its keys as milliseconds" : "untimed"}`, async () => { // The track's first group is 0, which each scale-less frame's key names. const key = Timestamp.unscaled(0n); const { info, frames } = await roundTrip(wire, undefined, [key, key]); expect(frames.map((frame) => frame.payload[0])).toEqual([0, 1]); - expect(info.timescale).toBe(wire.sends ? Timescale.MILLI : null); - for (const frame of frames) expect(frame.timestamp.scale !== undefined).toBe(wire.sends); + expect(info.timescale).toBe(wire.keys ? Timescale.MILLI : null); + for (const frame of frames) expect(frame.timestamp.scale !== undefined).toBe(wire.keys); }); // Lite-07 stamps each scale-less frame with its group's start as a bare number, which the - // subscriber checks against the GROUP, so a start past 0 tells it apart from no stamp at all. - if (wire.name === "lite-07-wip") { + // subscriber checks against the GROUP, and lite-05/06 as milliseconds, so a start past 0 + // tells it apart from no stamp, or a clock, at all. + if (wire.name === "lite-07-wip" || wire.keys) { test(`${wire.name}: an untimed group past 0 arrives stamped with its start`, async () => { const key = Timestamp.unscaled(9n); const { frames } = await roundTrip(wire, undefined, [key, key], 9n); expect(frames.map((frame) => frame.payload[0])).toEqual([0, 1]); - for (const frame of frames) expect(frame.timestamp).toEqual(key); + const stamped = wire.keys ? Timestamp.fromMillis(9) : key; + for (const frame of frames) expect(frame.timestamp).toEqual(stamped); }); } diff --git a/quest/m2/README.md b/quest/m2/README.md index 1d4440c5f5..cdf6d513fa 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -68,7 +68,6 @@ found. Each fix is so that a subscription, frame, or catalog entry means the same whichever relay or reader serves it: [no relative anchors](/quest/m2/time-addressing/no-relative-anchors.md), with Min Age placing a live join; -[scale-less tracks aging by arrival](/quest/m2/time-addressing/scale-less-arrival.md); [Group Streams carrying each time once](/quest/m2/time-addressing/group-times.md), with GROUP_END's end back as a delta; and [the hang-04 text](/quest/m2/hang-04-text.md) on entry versions and HLS diff --git a/quest/m2/time-addressing/group-times.md b/quest/m2/time-addressing/group-times.md index d713ca4d9e..6d0ec5f015 100644 --- a/quest/m2/time-addressing/group-times.md +++ b/quest/m2/time-addressing/group-times.md @@ -112,5 +112,4 @@ which is unpublished. ## Related - [lite-07 has no relative anchors](/quest/m2/time-addressing/no-relative-anchors.md) - its live join resolves as a time start, which this changes inside a skipped span -- [A scale-less track ages by arrival](/quest/m2/time-addressing/scale-less-arrival.md) - lite-05/06 still stamp a scale-less frame, with its group's start - [Groups never overlap](/quest/m2/groups-never-overlap.md) - enforces the non-overlap rule in hang's producers and importers diff --git a/quest/m2/time-addressing/scale-less-arrival.md b/quest/m2/time-addressing/scale-less-arrival.md deleted file mode 100644 index 5e2efda74c..0000000000 --- a/quest/m2/time-addressing/scale-less-arrival.md +++ /dev/null @@ -1,54 +0,0 @@ -# [M] A scale-less track ages by arrival, and lite-05/06 stamp its group's start - -## Goal - -On a scale-less track (no timescale), Max Age expiry uses arrival age alone, -in Rust, `@moq/net`, and the lite-07 draft: group starts are bare numbers and -never count as milliseconds. Over lite-05/06, which can only declare -milliseconds, Rust and JS both stamp a scale-less frame with its group's bare -start, so a frame carries the same timestamp on every path and every fetch. -One shared byte fixture pins that encoding for both languages. - -## Plan - -Decided 2026-11-20 (maintainer, /quest-plan of a pre-cut audit of the lite-07 -and hang-04 wire changes): - -- ✅ Arrival age only (rejected: counting key gaps as milliseconds). A - sequence-keyed track would otherwise expire by how many groups passed: keys - 0, 10000, and 20000 arriving together already expire group 0 under a 5 ms - budget (Rust `a_scale_less_track_ages_wide_keys_by_their_distance`). -- ✅ The bare start on lite-05/06 in both languages (rejected: the send time - in both). A send time stamps the same frame differently at each relay and on - each later fetch, which breaks the identity rule in AGENTS.md. - -This matches what the rest of the code base already says. The draft measures -Min Age by arrival on these tracks, Rust's `track::Info::max_age` doc says an -untimed track is judged by the wall clock alone, and -`drafts/draft-lcurley-moq-timestamp.md` does the same for untimed moq-transport -tracks. Only Max Age disagrees. - -Where it lives: - -- Draft `drafts/draft-lcurley-moq-lite.md`, Expiration: "On a scale-less - Track, timestamp age counts bare units as the milliseconds of a Max Age." -- Rust `rs/moq-net/src/model/track.rs`: the scale-less edge and drift paths - (the docs that say "its max age counts bare units") and the test above. -- JS `js/net/src/track.ts`: the live edge and reach that count a scale-less - track's bare starts as milliseconds. -- The bridge: Rust `lite/publisher.rs` `Stamp::wire` already sends the bare - value; JS `lite/publisher.ts` `wireTime` stamps `Timestamp.now()` for a - scale-less track on lite-05/06, which changes. -- `track::Info`'s `unchecked` (a lite-05/06 copy skips the rewind check - because untimed origins stamped send times) likely stays, since released - publishers still do. - -Tests: arrival-age expiry on a scale-less track whose starts jump; the -lite-06 bytes of a scale-less frame match the shared fixture in Rust and JS. - -Public API: none; a behavior change. Wire: no byte change; lite-07-wip expiry -semantics, and a scale-less frame's lite-05/06 timestamp in JS. - -## Related - -- [lite-07 Group Streams carry each time once](/quest/m2/time-addressing/group-times.md) - a scale-less FRAME stops carrying a timestamp on lite-07; lite-05/06 still need this one diff --git a/rs/moq-net/fixtures/stamps.json b/rs/moq-net/fixtures/stamps.json new file mode 100644 index 0000000000..3b1c78cabe --- /dev/null +++ b/rs/moq-net/fixtures/stamps.json @@ -0,0 +1,16 @@ +[ + { + "name": "a lite-06 scale-less group stamps each frame with its start as milliseconds", + "version": "moq-lite-06", + "start": 5, + "payloads": ["a", "b"], + "hex": "00030005000a0161000162" + }, + { + "name": "a lite-05 scale-less group stamps each frame with its start as milliseconds", + "version": "moq-lite-05", + "start": 5, + "payloads": ["a", "b"], + "hex": "000200050a0161000162" + } +] diff --git a/rs/moq-net/src/fuzz/ingest.rs b/rs/moq-net/src/fuzz/ingest.rs index cd8d9fc71e..c6d1a878fe 100644 --- a/rs/moq-net/src/fuzz/ingest.rs +++ b/rs/moq-net/src/fuzz/ingest.rs @@ -91,7 +91,7 @@ pub fn ingest(data: &[u8]) -> bool { 0 => { let version = super::LITE_VERSIONS[(*selector as usize / 2) % super::LITE_VERSIONS.len()]; // The track arrives timed exactly when the wire stamps it: never before Lite05, - // always on Lite05/06 (an untimed one carries its send times), as declared after. + // always on Lite05/06 (an untimed one carries its keys), as declared after. let timed = version.wire_timescale(timed.then_some(Timescale::MILLI)).is_some(); // Only the `ietf` extension carries a Version, and only on a track that has one. let draft = draft.filter(|_| settings & 0x10 != 0 && version.has_ietf()); diff --git a/rs/moq-net/src/lite/publisher.rs b/rs/moq-net/src/lite/publisher.rs index 068eaa8a12..c240ef0425 100644 --- a/rs/moq-net/src/lite/publisher.rs +++ b/rs/moq-net/src/lite/publisher.rs @@ -90,8 +90,7 @@ struct Shared { subscriptions: crate::session::Slots, /// Holds this session's listings: one per broadcast, the newest replacing the rest. lister: crate::broadcast::Owner, - // The send time an untimed track's frames carry on Lite05/06, which can't mark them - // untimed (see `wire_timestamp`). + // The clock the session's timers and auth replies read. runtime: crate::time::Deadlines, estimate: kio::ProducerWeak, /// The peer's latest PROBE target, which the session's sender probes up to. @@ -7784,6 +7783,58 @@ mod serve_group_test { } } + /// One case of `fixtures/stamps.json`, which `js/net` replays too. + #[derive(serde::Deserialize)] + #[serde(deny_unknown_fields)] + struct StampCase { + name: String, + version: crate::Version, + start: u64, + payloads: Vec, + hex: String, + } + + /// Lite-05/06 stamp a scale-less frame with its group's start, so a frame carries the same + /// timestamp on every hop and fetch, never a clock: the Group Stream matches the shared + /// fixture byte for byte. + #[kio::test] + async fn a_scale_less_group_stream_matches_the_shared_fixture() { + let cases: Vec = + serde_json::from_str(include_str!("../../fixtures/stamps.json")).expect("a malformed fixture"); + assert!(!cases.is_empty(), "the fixture is empty"); + for case in cases { + let crate::Version(crate::Draft::Lite(version)) = case.version else { + panic!("{}: not a moq-lite version", case.name); + }; + let log = Log::default(); + let mut subscription = lite07_subscription(SinkSession::new(log.clone())); + subscription.version = version; + subscription.stamp = Stamp::new(version, None); + let track = track::Producer::new( + Arc::new(broadcast::Info::default()), + "test", + crate::track::Info::default(), + ); + let mut group = track.create_group(group::Info { start: case.start }).unwrap(); + for payload in &case.payloads { + group + .write_frame(Timestamp::unscaled(case.start), payload.as_bytes()) + .unwrap(); + } + group.finish().unwrap(); + let handle = subscription.priority.insert(Priority::new(0, 0, 0)); + subscription + .serve_group(case.start, 0, handle, track.consume().peek_group(case.start).unwrap()) + .await + .unwrap(); + + let (bytes, fin) = first_stream(&log); + assert!(fin, "{}: no FIN", case.name); + let hex: String = bytes.iter().map(|b| format!("{b:02x}")).collect(); + assert_eq!(hex, case.hex, "{}", case.name); + } + } + /// A lite-07 group expiring while its stream is open, here behind a blocked transport /// write, resets the stream with OLD, sends none of the frames written since, and fails so /// its subscription names it in a stale drop. diff --git a/rs/moq-net/src/lite/track.rs b/rs/moq-net/src/lite/track.rs index fe5f7630bd..79b2e1d6d7 100644 --- a/rs/moq-net/src/lite/track.rs +++ b/rs/moq-net/src/lite/track.rs @@ -142,7 +142,7 @@ pub(crate) struct Framing { impl Framing { /// How `version` frames a track accepted as `info`. Lite05/06 stamp every frame, an - /// untimed track's with its send time in milliseconds. + /// untimed track's with its group's start as milliseconds. pub fn new(info: &crate::track::Info, version: Version) -> Self { Self { timescale: version.wire_timescale(info.timescale), diff --git a/rs/moq-net/src/lite/version.rs b/rs/moq-net/src/lite/version.rs index 03ca6b6ff3..a066c63a6f 100644 --- a/rs/moq-net/src/lite/version.rs +++ b/rs/moq-net/src/lite/version.rs @@ -382,9 +382,10 @@ impl Version { ) } - /// Whether received frame timestamps are the publisher's media time. Lite05/06 stamp an - /// untimed track's payloads with their send time, which a receiver cannot tell from it, - /// so it passes them through as the track's time without checking them for a rewind. + /// Whether received frame timestamps are the publisher's media time. A released Lite05/06 + /// publisher may stamp an untimed track's payloads with their send time, which a receiver + /// cannot tell from it, so it passes them through as the track's time without checking + /// them for a rewind. pub(crate) fn has_media_time(self) -> bool { !matches!( self, diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index 8ac17d86bd..25221ae765 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -176,7 +176,8 @@ pub struct Info { #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] 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. + /// untimed origin may be a released publisher stamping send times, so an older group + /// fetched later looks like a rewind. #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] pub(crate) unchecked: bool, } @@ -2199,8 +2200,8 @@ impl TrackState { }) } - /// This track's own edge within `servable`, for measuring drift. A scale-less track's - /// edge is its newest shown group's key, so its max age counts bare units. + /// This track's own edge within `servable`, for measuring drift. A scale-less track has + /// none: its bare starts are no time, so it ages by arrival alone. fn drift_edge(&self, servable: &Servable) -> Edge { Edge { presentation: self.live_edge(servable), @@ -2299,23 +2300,22 @@ impl TrackState { self.started_at(self.successor(key, servable)?) } - /// A key, or a group's end, in presentation time: in the track's timescale, or unscaled - /// on a scale-less track, over the whole key range, whose max age counts bare units as - /// milliseconds (see [`PresentationEdge::behind`]). + /// The track's timescale, or `None` on a scale-less track, or before its info is known. + fn timescale(&self) -> Option { + self.info.as_ref()?.timescale + } + + /// A key, or a group's end, in the track's timescale, or `None` on a scale-less track, + /// whose bare numbers are no time. fn presented(&self, value: u64) -> Option { - match self.info.as_ref()?.timescale { - Some(scale) => Timestamp::new(value, scale).ok(), - None => Some(Timestamp::unscaled(value)), - } + Timestamp::new(value, self.timescale()?).ok() } - /// Where the group in `slot` starts presenting: its first frame's timestamp, or its key - /// on a scale-less track, whose frames carry none. + /// Where the group in `slot` starts presenting: its first frame's timestamp, or `None` on + /// a scale-less track, whose frames carry no time. fn started_at(&self, slot: &Slot) -> Option { - match self.info.as_ref()?.timescale { - Some(_) => slot.group.timestamp(), - None => self.presented(slot.group.start), - } + self.timescale()?; + slot.group.timestamp() } /// Where group `key` ends, once its producer finished it whole: what bounds its reach @@ -2326,11 +2326,12 @@ impl TrackState { /// When group `key`, finished whole, stops presenting on the wall clock: its arrival plus /// its span, which stands in for a successor arriving, so the last group of a paused or - /// finished track ages out without one. + /// finished track ages out without one. A scale-less group's span is no time, so it waits + /// for a successor. fn ended_at(&self, key: u64) -> Option { let slot = self.lookup.get(&key)?; let span = self.presented(slot.group.end()?.checked_sub(key)?)?; - slot.arrived.checked_add(age(span)?) + slot.arrived.checked_add(Duration::try_from(span).ok()?) } /// The group after `key` that bounds it: the first servable one in `servable` whose @@ -2437,7 +2438,8 @@ impl TrackState { /// The wall clock judges it too: a group is also stale once its successor arrived a /// full `budget` ago (see [`Self::superseded`]), so a peer whose timestamps stop /// advancing or an empty successor that never presents cannot pin a superseded group. - /// Media time still convicts first when a burst arrives at once. A group finished whole + /// Media time still convicts first when a burst arrives at once. A scale-less track has + /// no media time, so only the wall clock judges it. A group finished whole /// ages from its arrival plus its span instead when no successor arrived, so the last /// group of a paused or finished track ages out; one with neither is never convicted. /// @@ -2513,6 +2515,10 @@ impl TrackState { if self.aged(arrived, budget) { return true; } + // A scale-less track ages by arrival alone. + if self.timescale().is_none() { + return false; + } let reach = loop { if let Some(end) = self.own_end(key) { break end; @@ -8614,20 +8620,11 @@ impl PresentationEdge { fn behind(&self, reach: Option, budget: Duration) -> bool { reach .and_then(|reach| self.timestamp.checked_sub(reach).ok()) - .and_then(age) + .and_then(|span| Duration::try_from(span).ok()) .is_some_and(|age| age >= budget) } } -/// A span of presentation time as a duration: a scale-less track's bare units count as -/// milliseconds, over the whole key range. -fn age(span: Timestamp) -> Option { - match span.scale() { - Some(_) => Duration::try_from(span).ok(), - None => Some(Duration::from_millis(span.value())), - } -} - /// The read cursor behind a [`Subscriber`]. struct Cursor { state: kio::Consumer, @@ -27765,27 +27762,52 @@ mod test { assert_eq!(drain_groups(&mut subscriber), [2998]); } - /// A scale-less track's max age counts bare key units as milliseconds over the whole key - /// range, so keys past a scaled timestamp's bound age by their distance as low ones do. + /// A scale-less track's starts are bare numbers, never milliseconds, so groups whose + /// starts jump age by arrival alone, anywhere in the key range. #[test] - fn a_scale_less_track_ages_wide_keys_by_their_distance() { + fn a_scale_less_track_ages_by_arrival_alone() { + let budget = Duration::from_millis(5); for base in [0, 1u64 << 61, u64::MAX - 30_000] { let producer = track_producer("test", None); for offset in [0, 10_000, 20_000] { write_untimed_group(&producer, base + offset); } - // All three arrived at once, so only the keys' distance makes the oldest stale: its - // successor starts 10 s behind the edge. The middle one reaches the edge. - let mut subscriber = producer - .subscribe(Subscription::default().with_delay(Delay::default().with_max(Duration::from_millis(5)))); + let subscribe = + || producer.subscribe(Subscription::default().with_delay(Delay::default().with_max(budget))); + // All three arrived at once, so however far apart their starts, none is stale yet. assert_eq!( - drain_groups(&mut subscriber), - [base + 10_000, base + 20_000], + drain_groups(&mut subscribe()), + [base, base + 10_000, base + 20_000], "from {base}" ); + // Their successors arrived a full budget ago, so only the newest is left. + elapse(&producer, budget); + assert_eq!(drain_groups(&mut subscribe()), [base + 20_000], "from {base}"); } } + /// A scale-less group's end is a bare number, no time, so a group finished whole ages only + /// once a successor arrives, as any other group does. + #[kio::test] + #[cfg(feature = "async")] + async fn a_scale_less_whole_group_ages_only_once_superseded() { + let producer = track_producer("test", Info::default().with_max_age(Duration::ZERO)); + elapse(&producer, Duration::ZERO); + let mut group = producer.append_group(Timestamp::unscaled(0)).unwrap(); + group + .write_frame(Timestamp::unscaled(0), bytes::Bytes::from_static(b"x")) + .unwrap(); + group.finish_at(1).unwrap(); + + let consumer = producer.consume(); + elapse(&producer, Duration::from_secs(1)); + let fetched = consumer.fetch_group(0, None).now_or_never().unwrap(); + assert!(fetched.is_ok(), "before a successor: {:?}", fetched.err()); + write_untimed_group(&producer, 1); + let fetched = consumer.fetch_group(0, None).now_or_never().unwrap(); + assert!(matches!(fetched, Err(Error::Old)), "{:?}", fetched.err()); + } + /// An empty successor gives the lowest group above a gap no reach, so media time never /// forgets that gap or any after it. The wall clock still does. #[test] From 2f64b9281effd468af29a37a1a7053a104aebb49 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 18:40:59 -0800 Subject: [PATCH 3/6] wip: test fixes for arrival-only scale-less aging Co-Authored-By: Claude Opus 5.5 --- js/net/src/group-id.test.ts | 7 ++++--- js/net/src/resume.test.ts | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/js/net/src/group-id.test.ts b/js/net/src/group-id.test.ts index be3bb30dd4..ed12500cfe 100644 --- a/js/net/src/group-id.test.ts +++ b/js/net/src/group-id.test.ts @@ -1,5 +1,6 @@ // Group IDs past 2^53 decode, survive a JS forwarding node, and encode again on every wire -// version, as a third-party moq-transport publisher's or a fine timescale's start ticks may be. +// version that can carry them, as a third-party moq-transport publisher's or a fine timescale's start +// ticks may be. import { expect, test } from "bun:test"; import { type Consumer as BroadcastConsumer, Producer as BroadcastProducer } from "./broadcast.ts"; import { accept, connect } from "./connection/index.ts"; @@ -33,8 +34,8 @@ const WIRES: Wire[] = [ { name: "lite-02", protocol: "", version: Lite.Version.DRAFT_02 }, { name: "lite-03", protocol: Lite.ALPN_03 }, { name: "lite-04", protocol: Lite.ALPN_04 }, - { name: "lite-05", protocol: Lite.ALPN_05, datagrams: true }, - { name: "lite-06", protocol: Lite.ALPN_06, datagrams: true }, + // Lite-05 and lite-06 are missing: they stamp a scale-less track's frames and datagrams with + // their keys as milliseconds, which a JS hop's timestamps hold only below 2^53. { name: "lite-07-wip", protocol: Lite.ALPN_07_WIP, datagrams: true }, { name: "ietf-18", protocol: Ietf.ALPN.DRAFT_18 }, { name: "ietf-20", protocol: Ietf.ALPN.DRAFT_20 }, diff --git a/js/net/src/resume.test.ts b/js/net/src/resume.test.ts index 3cb20d55f8..d44b160353 100644 --- a/js/net/src/resume.test.ts +++ b/js/net/src/resume.test.ts @@ -2005,8 +2005,8 @@ test.each([ ])( "a group fetched over a wire goes stale by the fetch's own budget ($budget)", async ({ maxDelay, stale, bounded }) => { - // Still, so only presentation time judges. - const { installed } = manual(); + // Still until the test moves it: a scale-less track ages by arrival alone. + const { clock, installed } = manual(); const front = new Front(); const a = new BroadcastProducer(); const ta = copy(a); @@ -2037,8 +2037,9 @@ test.each([ await settle(); expect(group.expired.peek()).toBeUndefined(); - // The copy's live edge runs a second past group 0's successor. + // Group 0's successor arrived at the copy a second ago. ta.write(2000n); + await clock.advance(SECOND); if (stale) expect(await verdict).toMatchObject({ code: StreamCode.Old }); else expect(await isPending(verdict)).toBe(true); From afa0f02b4ce038ffa4516eb4aef2e62429923803 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 19:17:58 -0800 Subject: [PATCH 4/6] quest: a JS hop's data decode error never closes another session Co-Authored-By: Claude Opus 5.5 --- .../m3/js-data-errors-stay-on-their-track.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 quest/m3/js-data-errors-stay-on-their-track.md diff --git a/quest/m3/js-data-errors-stay-on-their-track.md b/quest/m3/js-data-errors-stay-on-their-track.md new file mode 100644 index 0000000000..a8d95963a6 --- /dev/null +++ b/quest/m3/js-data-errors-stay-on-their-track.md @@ -0,0 +1,27 @@ +# [S] A JS hop's data decode error never closes another session + +## Goal + +In `@moq/net`, an error from decoding a Group or Fetch Stream ends only that +group and the tracks it reaches, never a session. Today `Reader` marks every +error a decoder throws as malformed (`stream.ts`, `decodeError`), and the +mark travels with the error object: a node that republishes a track aborts +its copy with that object, and its publisher's `runSubscribe` then closes the +downstream session with "invalid control encoding" (`lite/error.ts` +`closeViolation`). One bad group from one publisher drops every broadcast a +JS relay or forwarding client serves on that session. + +## Plan + +Found by [moq-dev/moq#9266](https://github.com/moq-dev/moq/pull/9266): a +lite-05/06 frame whose timestamp passes 2^53 milliseconds, such as a +scale-less track's key as Rust and now JS stamp it, fails `toNumber` in +`lite/group.ts` `readFrames`, and the `group-id.test.ts` relay chain then saw +the viewer's session close with code 3. + +Recommended: keep the malformed mark on control-stream decodes only, or +strip it where a data reader turns the error into a group abort +(`lite/subscriber.ts` `runGroup`, the fetch reader), so `closeViolation` +sees a plain error downstream. Check the Rust relay for the same leak, and +cover it with a JS relay-chain test that feeds one malformed group and keeps +a second broadcast on the downstream session flowing. From 2278f72b8eb1c8af4294e199399cf2d674cc0a90 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 20:14:10 -0800 Subject: [PATCH 5/6] fix(net): a scale-less track skips the live-edge scan Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/src/model/track.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index 2fe62fb347..88bfc3e87e 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -2347,6 +2347,8 @@ impl TrackState { /// Fetched backfill is absent from `arrival`, so it cannot age subscription content /// as though it were a live replacement. fn live_edge(&self, servable: &Servable) -> Option { + // A scale-less track's groups start at no time, so none is an edge: skip the scan. + self.timescale()?; self.find_servable(servable, 0, true, |slot| { if !slot.is_shown() { return None; From a2983e64f40f2c307a9f95680aa5671a8786cb8e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 21 Nov 2026 02:02:44 -0800 Subject: [PATCH 6/6] quest: a decode error aborts only its group, not the track Co-Authored-By: Claude Sonnet 5.5 --- quest/m3/js-data-errors-stay-on-their-track.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/quest/m3/js-data-errors-stay-on-their-track.md b/quest/m3/js-data-errors-stay-on-their-track.md index a8d95963a6..72eda7027d 100644 --- a/quest/m3/js-data-errors-stay-on-their-track.md +++ b/quest/m3/js-data-errors-stay-on-their-track.md @@ -2,8 +2,9 @@ ## Goal -In `@moq/net`, an error from decoding a Group or Fetch Stream ends only that -group and the tracks it reaches, never a session. Today `Reader` marks every +In `@moq/net`, an error from decoding a Group or Fetch Stream aborts only that +group on each copy of its track, never the track, its broadcast, its sibling +groups, or a session. Today `Reader` marks every error a decoder throws as malformed (`stream.ts`, `decodeError`), and the mark travels with the error object: a node that republishes a track aborts its copy with that object, and its publisher's `runSubscribe` then closes the