Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
53b06aa
chore(quest): claim quest/m1/subscribe-ranges/lite.md
kixelated Oct 27, 2026
66c7317
feat(net): lite-07 SUBSCRIBE_OK names each range's resolved start
kixelated Oct 28, 2026
e87c577
quest: the resolved start landed; lite-07 ranges keeps range fill and…
kixelated Oct 28, 2026
638e56e
quest: lite07-finalize names what lite-07 ranges still owes
kixelated Oct 28, 2026
7ccf42b
style: rustfmt
kixelated Oct 28, 2026
21afbec
Merge remote-tracking branch 'origin/main' into feat/subscribe-ranges…
kixelated Oct 28, 2026
a3e71c6
fix(net): report a lite-07 range with no start as group 0
kixelated Oct 28, 2026
d6e693e
fix(net): report no start for a lite-07 range that resolves empty
kixelated Oct 28, 2026
06d49b2
fix(net): keep a lite-07 range empty partway through a group
kixelated Oct 28, 2026
7327d26
Merge remote-tracking branch 'origin/main' into lite-subscribe-range-…
kixelated Oct 28, 2026
9fd2893
feat(net): drop Group from lite-07 SUBSCRIBE_OK
kixelated Oct 28, 2026
4dcc35c
test(interop): pass SUBSCRIBE_OK's starts to the bare-FIN harness
kixelated Oct 28, 2026
04efb51
Merge remote-tracking branch 'origin/main' into quest/m1/subscribe-ra…
kixelated Oct 29, 2026
71b994d
fix(net): owe each lite-07 range from its own start, and check JS sta…
kixelated Oct 29, 2026
2d5d59c
chore(quest): claim quest/m1/subscribe-ranges/lite.md
kixelated Nov 4, 2026
17bcfb9
Merge claim commit into quest/m1/subscribe-ranges/lite
kixelated Nov 4, 2026
9f824d3
feat(net)!: lite-07 Range IDs and SUBSCRIBE_STARTED in Rust
kixelated Nov 4, 2026
587b1fa
feat(net)!: lite-07 Range IDs and SUBSCRIBE_STARTED in JS, and SUBSCR…
kixelated Nov 4, 2026
6b2e1d3
fix(net): SUBSCRIBE_STARTED takes type 0x4, leaving 0x3 to SUBSCRIBE_…
kixelated Nov 4, 2026
dec0639
feat(net): lite-07 fills more than one group through the subscription
kixelated Nov 4, 2026
26ccfca
feat(net): test lite-07 range fills and recovery, describe them in th…
kixelated Nov 4, 2026
538cdfe
fix: rename SubscribeEnd in the interop client, and format
kixelated Nov 4, 2026
b26931f
fix(net): allow the one-run list in the recovery test
kixelated Nov 4, 2026
b2cdb17
test(net): a run's SUBSCRIBE carries its subscriber's four ranges
kixelated Nov 4, 2026
6cca68c
fix(net): a pre-07 start still says where a replaced demand was serve…
kixelated Nov 4, 2026
20413b7
Merge remote-tracking branch 'origin/main' into quest/m1/subscribe-ra…
kixelated Nov 4, 2026
81fc769
fix(net): bound fill cleanup by what is held, and scope recovery to t…
kixelated Nov 4, 2026
9d0504e
fix(net): an abandoned recovery is released once nobody reads the track
kixelated Nov 4, 2026
5612c46
Merge origin/main into quest/m1/subscribe-ranges/lite
kixelated Nov 4, 2026
23f9bf7
fix(net): address lite-07 range review findings
kixelated Nov 4, 2026
e3b0663
fix(net): pin a settled time end too, as a range resolves once
kixelated Nov 4, 2026
d44d9e3
Merge origin/main into quest/m1/subscribe-ranges/lite
kixelated Nov 4, 2026
483305c
fix(net): a fill refused short of a genuine miss records nothing
kixelated Nov 4, 2026
eb27b0e
Merge origin/main into quest/m1/subscribe-ranges/lite
kixelated Nov 4, 2026
10611bf
fix(net): pin a time start that names group 0 too
kixelated Nov 4, 2026
4704411
Merge origin/main into quest/m1/subscribe-ranges/lite
kixelated Nov 4, 2026
10e2fe2
fix(net): a fill retired before SUBSCRIBE_START never sets the live f…
kixelated Nov 4, 2026
d6dd3eb
Merge origin/main into quest/m1/subscribe-ranges/lite
kixelated Nov 4, 2026
a4109af
quest: name the JS port of lite-07 subscription fills in lite07-fetch
kixelated Nov 4, 2026
57e04fe
Merge branch 'base' into pr-7872
Nov 4, 2026
23a690e
fix(quest): remove completed lite-07 ranges prerequisite
Nov 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 54 additions & 7 deletions drafts/draft-lcurley-moq-lite.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ An advertiser signals capacity through its route alone, withdrawing or re-pricin
A subscriber opens Subscribe Streams to request a Track.

The subscriber MUST start a Subscribe Stream with a SUBSCRIBE message followed by any number of SUBSCRIBE_UPDATE messages.
The publisher replies with a SUBSCRIBE_OK message once each Range's start is resolved, and a SUBSCRIBE_FINISH message once the Track's final group is known.
The publisher replies with a SUBSCRIBE_OK message once each Range's start is resolved, a SUBSCRIBE_STARTED message for each Range an update adds once its start is resolved, and a SUBSCRIBE_FINISH message once the Track's final group is known.
For a live track the publisher MAY withhold SUBSCRIBE_OK until the first matching group resolves the start, and withholds the SUBSCRIBE_DROP messages for groups it gives up meanwhile until it sends SUBSCRIBE_OK.
It MUST NOT withhold it past the point where no group can resolve it: once every Group in a subscription whose every Range has an `End` other than None has been given up, or once the Track has finished, the publisher sends SUBSCRIBE_OK and then the SUBSCRIBE_DROP messages it withheld.
A Track that finished before producing any Group is the one case with nothing to resolve: SUBSCRIBE_FINISH with a Group of 0 needs no SUBSCRIBE_OK.
Expand All @@ -515,10 +515,14 @@ The subscriber needs the track's TRACK_INFO (notably its timescale) to interpret

The publisher sends SUBSCRIBE_OK once the start is resolved, and SUBSCRIBE_FINISH as soon as the exclusive final group is known (see [SUBSCRIBE_OK](#subscribe-ok) and [SUBSCRIBE_FINISH](#subscribe-finish)).
Neither closes the stream: the publisher keeps reading SUBSCRIBE_UPDATE messages, so an update can still widen the Ranges, including into an ended Track's history, and the publisher serves or drops what it newly covers.
The subscriber judges a Range complete from what it observed: the Groups it received, the SUBSCRIBE_DROP messages, the Range Starts in SUBSCRIBE_OK, and SUBSCRIBE_FINISH.
The subscriber judges a Range complete from what it observed: the Groups it received, the SUBSCRIBE_DROP messages, the Range Starts in SUBSCRIBE_OK and SUBSCRIBE_STARTED, and SUBSCRIBE_FINISH.
Drops and Groups name absolute sequences, so the subscriber judges them against its latest Ranges, and an update still in flight changes nothing it has counted.
The publisher never closes its side first: a subscription whose every Range has an `End` other than None and whose every Group has been delivered or dropped stays open for an update to widen it.

A subscriber fills Groups it misses by asking for them as Ranges, adding them to an open subscription with SUBSCRIBE_UPDATE or opening a bounded SUBSCRIBE when none is open, rather than with a FETCH of each Group; FETCH remains for one Group, or a slice of one.
A publisher never sends a Group twice on one subscription, so a Group the subscription already delivered or named in SUBSCRIBE_DROP is asked for with a SUBSCRIBE of its own.
The subscriber asks that way, once, for a Group a subscription dropped with OLD that it still wants, with a `Subscriber Max Age` its age does not reach, and never for a Group that may still arrive on the existing subscription.

The subscriber closes its side (FIN) once it wants nothing more from the subscription, and the publisher then closes its side (FIN), cancelling any Group Stream still open.
After SUBSCRIBE_FINISH, the subscriber SHOULD close its side once its tail accounting has settled: every received Group Stream has been read to its FIN, reset, or dropped, and every sequence in range has arrived, been named by SUBSCRIBE_DROP, or exhausted the subscriber's grace period.
A publisher closing its session gracefully MUST wait for the subscriber's FIN or reset on every Subscribe Stream before closing the connection; a transport acknowledgement alone does not confirm the subscriber read the tail.
Expand Down Expand Up @@ -1308,6 +1312,7 @@ A value of 0 is a PROTOCOL_VIOLATION, since a subscription that asks for nothing
**Range**:
A span of the Track to deliver, from its `Start` up to its `End`.
The subscription is the union of its Ranges: the publisher delivers each Group inside any of them once, in `Group Order` across all of them, and accounts with SUBSCRIBE_DROP for every Group it will not deliver.
Each Range implicitly takes the next Range ID on the stream, starting at 0, which a [SUBSCRIBE_UPDATE](#subscribe-update) uses to retire it.

**Anchor Type**:
Which fields follow, and what the Anchor names:
Expand All @@ -1319,6 +1324,7 @@ Which fields follow, and what the Anchor names:

Any other value is a PROTOCOL_VIOLATION.
The publisher resolves a Relative or Time Anchor against the Track as it holds it.
A Range resolves once: an update that leaves it live does not resolve it again.

A `Start` is a floor, not a request; `Subscriber Max Age` is the only thing that asks for data.
The publisher SHOULD start at the oldest group at or above the floor that [Expiration](#expiration) has not expired, and MUST NOT deliver an older one.
Expand All @@ -1331,10 +1337,11 @@ An Absolute `Start` past frame 0 delivers its group from that frame; a start res
A subscriber MAY name any start frame, as described in [Positions](#positions).
An Absolute `End` past frame 0 delivers its group up to that frame.

## SUBSCRIBE_UPDATE
## SUBSCRIBE_UPDATE {#subscribe-update}
A subscriber can modify a subscription with a SUBSCRIBE_UPDATE message.
A subscriber MAY send multiple SUBSCRIBE_UPDATE messages to update the subscription.
Its Ranges replace the previous ones, growing or shrinking the subscription.
Every field but the Ranges restates the subscription, and the latest one applies.
The Ranges are an edit, growing or shrinking the subscription: the update retires the live Ranges it names by Range ID, then adds its own, each taking the next Range ID.
Lowering a `Start` covers the groups below the old one that the publisher still holds, not only those that arrive later; a group already sent is not sent again.

~~~
Expand All @@ -1344,6 +1351,8 @@ SUBSCRIBE_UPDATE Message {
Group Order (8)
Subscriber Max Age (i)
Subscriber Min Age (i)
Remove Count (i)
Range ID (i) ...
Range Count (i)
Range (..) ...
Wanted Group (i)
Expand All @@ -1353,6 +1362,14 @@ SUBSCRIBE_UPDATE Message {
See [SUBSCRIBE](#subscribe) for information about each field.
Moving a `Start` forward within a group that is already being delivered does not retract frames the publisher has already sent; it only bounds what the publisher sends from here on.

**Remove Count** and **Range ID**:
The live Ranges to retire.
A Range ID that was never assigned, or is already retired, including earlier in the same list, is a PROTOCOL_VIOLATION.

**Range Count** and **Range**:
The Ranges to add, which may be none.
The live Ranges after the edit MUST NOT be empty, and MUST fit in one SUBSCRIBE: once encoded they take at most 65,535 bytes.
A publisher closes the session with a PROTOCOL_VIOLATION otherwise.

**Wanted Group**:
The newest group the subscriber's live-edge joins want, encoded as the sequence plus one; `0` means none.
Expand Down Expand Up @@ -1572,11 +1589,12 @@ The largest position the publisher knows of for the track when it answers: the l
A subscriber takes it as where the live feed is: a relay holding groups from an earlier subscription serves them from cache only once this says they are current, which a publisher answering promptly lets it do without waiting for a frame.

**Range Start**:
One per Range the publisher is serving, in order: the Group where the Range's delivery starts, plus one, so a subscriber learns where a Relative or Time Anchor landed.
0 means the Range has no Group to deliver.
One per Range of the SUBSCRIBE, in Range ID order: the Group where the Range's delivery starts, plus one, so a subscriber learns where a Relative or Time Anchor landed.
0 means the Range has no Group to deliver, including one an update retired before the answer.
The Range's Groups from this one are owed as described in [SUBSCRIBE_DROP](#subscribe-drop); an earlier one is not, though it MAY still arrive.
A Range whose `Range Start` is its requested start Group begins at the requested frame, and otherwise at frame 0 (see [Positions](#positions)).
The Ranges are those of the SUBSCRIBE unless the publisher applied a SUBSCRIBE_UPDATE before answering; a subscriber that sent none MUST treat a count other than its number of Ranges as a PROTOCOL_VIOLATION.
A subscriber MUST treat a `Range Start Count` other than the SUBSCRIBE's `Range Count` as a PROTOCOL_VIOLATION.
A Range an update adds has its start reported by [SUBSCRIBE_STARTED](#subscribe-started) instead, even one added before SUBSCRIBE_OK.

## SUBSCRIBE_FINISH {#subscribe-finish}
A SUBSCRIBE_FINISH message is sent by the publisher to signal that no group at or after a given sequence will be produced.
Expand Down Expand Up @@ -1605,6 +1623,32 @@ Groups below the end stay deliverable either way; a subscriber reaching the end

The publisher SHOULD send SUBSCRIBE_FINISH as soon as the exclusive final group is known, even while lower groups are still in flight.

## SUBSCRIBE_STARTED {#subscribe-started}
A SUBSCRIBE_STARTED message resolves where a Range that a [SUBSCRIBE_UPDATE](#subscribe-update) added starts.

~~~
SUBSCRIBE_STARTED Message {
Type (i) = 0x4
Message Length (i)
Range ID (i)
Range Start (i)
}
~~~

**Type**:
Set to 0x4 to indicate a SUBSCRIBE_STARTED message.

**Range ID**:
The Range it resolves.
A Range ID the subscription never assigned, one of the SUBSCRIBE's Ranges, or one already resolved is a PROTOCOL_VIOLATION.
A Range the subscriber has since retired is ignored.

**Range Start**:
As in [SUBSCRIBE_OK](#subscribe-ok), and the Range's Groups from it are owed the same way.

The publisher sends it after SUBSCRIBE_OK, once the Range's start is resolved, and MUST NOT withhold it past the point where no group can resolve it, as for SUBSCRIBE_OK.
A Range retired before its start resolved gets none.

## SUBSCRIBE_DROP {#subscribe-drop}

A publisher names groups it will not deliver with SUBSCRIBE_DROP on the Subscribe Stream.
Expand Down Expand Up @@ -1947,6 +1991,9 @@ The `Message Length` describes the payload size on the wire.
- SUBSCRIBE may start at any frame, including when the subscriber no longer holds the prefix.
- A SUBSCRIBE_UPDATE that lowers a `Start` covers the groups below the old start that the publisher still holds, not only those that arrive later. A group already sent is not sent again.
- Replaced SUBSCRIBE_OK `Group` with a `Range Start` per Range: the Group where that Range's delivery starts, including at a Relative or Time Anchor, from which its Groups are owed.
- Each Range takes an implicit Range ID, and SUBSCRIBE_UPDATE edits the live Ranges instead of restating them: `Remove Count` Range IDs to retire, then the Ranges to add. The live Ranges must stay non-empty and fit in one SUBSCRIBE. A Range resolves its Anchors once, however many updates leave it live.
- SUBSCRIBE_OK's Range Starts answer the SUBSCRIBE's Ranges, and added SUBSCRIBE_STARTED (type 0x4) resolving where each Range an update adds starts.
- A subscriber fills missing Groups through Ranges on a subscription instead of a FETCH per Group, and asks for a Group a subscription already delivered or dropped, including one dropped with OLD, with a SUBSCRIBE of its own.
- Added `Largest Group` and `Largest Frame` to SUBSCRIBE_OK: the publisher's largest position when it answers, which a subscriber takes as where the live feed is. A publisher MUST answer at once when the requested start is past it.
- Renamed SUBSCRIBE_END to SUBSCRIBE_FINISH, matching TRACKS_FINISH: it ends the Track, not the subscription.
- Added `Error Code` to SUBSCRIBE_FINISH: a track can end with an error while keeping the groups below its end.
Expand Down
12 changes: 11 additions & 1 deletion js/net/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import type {
} from "./track.ts";
import { max, min } from "./util/sequence.ts";
import * as Varint from "./varint.ts";
import type { Window } from "./window.ts";
import type { Resolved, Window } from "./window.ts";
import type { Advertised, Advertisements } from "./wire.ts";

/** What a null {@link Delay.max} goes out as: the largest value every peer can read, as Rust sends for `None`. */
Expand Down Expand Up @@ -375,6 +375,8 @@ export interface ResumeSource {
end(): Position | undefined;
/** Where each range starts on the serving copy once delivery starts at `from`, undefined without one. */
starts(from: bigint): (bigint | undefined)[] | undefined;
/** Each range as the serving copy resolved it, undefined without one. */
resolved(): (Resolved | undefined)[] | undefined;
/** The runs of `[start, end)` the serving copy reads, undefined without one. */
runs(start: bigint, end: bigint): Run[] | undefined;
/**
Expand Down Expand Up @@ -586,6 +588,11 @@ export const hooks: {
* with no group there: what lite-07 SUBSCRIBE_START answers. Assigned by `track.ts`.
*/
servingStarts: (subscriber: Subscriber, from: bigint) => (bigint | undefined)[];
/**
* Each of a subscriber's ranges as resolved where it is served, undefined for one whose start
* still waits: what lite-07 SUBSCRIBE_STARTED answers. Assigned by `track.ts`.
*/
servingResolved: (subscriber: Subscriber) => (Resolved | undefined)[];
/** The lowest buffered candidate, which an ordered take may wait below; `floor` passes sequences taken on other copies. */
peekGroup: (subscriber: Subscriber, ordered: boolean, floor?: bigint) => bigint | undefined;
/** Take the next group in sequence order without waiting, as {@link tryRecvGroup} does in arrival order. */
Expand Down Expand Up @@ -795,6 +802,9 @@ export const hooks: {
servingStarts: () => {
throw new Error("track.ts not loaded");
},
servingResolved: () => {
throw new Error("track.ts not loaded");
},
makeRequest: () => {
throw new Error("track.ts not loaded");
},
Expand Down
14 changes: 7 additions & 7 deletions js/net/src/lite/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
decodeSubscribeResponse,
encodeSubscribeResponse,
Subscribe,
SubscribeEnd,
SubscribeFinish,
SubscribeStart,
} from "./subscribe.ts";
import { TrackInfo, Track as TrackMessage } from "./track.ts";
Expand Down Expand Up @@ -539,9 +539,9 @@ async function servedRawSubscription(alpn: string = ALPN_07_WIP, version: Versio
expect("start" in (await decodeSubscribeResponse(subscriber.reader, version))).toBe(true);
producer.finish();
producer.close();
// SUBSCRIBE_END, then before lite-07 the publisher's FIN; lite-07 keeps the stream open.
// SUBSCRIBE_FINISH, then before lite-07 the publisher's FIN; lite-07 keeps the stream open.
if (keepsSubscribeOpen(version)) {
while (!("end" in (await decodeSubscribeResponse(subscriber.reader, version)))) {}
while (!("finish" in (await decodeSubscribeResponse(subscriber.reader, version)))) {}
} else await subscriber.reader.readAll();

let closed = false;
Expand All @@ -561,7 +561,7 @@ async function servedRawSubscription(alpn: string = ALPN_07_WIP, version: Versio
}

// The publisher's FIN says nothing about whether the subscriber read the tail, and a receiver
// may drop unread bytes on close. From lite-05, whose SUBSCRIBE_END lets the subscriber settle
// may drop unread bytes on close. From lite-05, whose SUBSCRIBE_FINISH lets the subscriber settle
// its tail at once, the subscriber's FIN says so, and close waits for it.
for (const [alpn, version] of [
[ALPN_05, Version.DRAFT_05],
Expand Down Expand Up @@ -718,8 +718,8 @@ test("close waits for a request served while withdrawals are in flight", async (
expect("start" in (await decodeSubscribeResponse(subscriber.reader, version))).toBe(true);
producer.finish();
producer.close();
// SUBSCRIBE_END; lite-07 keeps the stream open past it.
while (!("end" in (await decodeSubscribeResponse(subscriber.reader, version)))) {}
// SUBSCRIBE_FINISH; lite-07 keeps the stream open past it.
while (!("finish" in (await decodeSubscribeResponse(subscriber.reader, version)))) {}

// The withdrawal completes, but the subscription still waits for the subscriber's FIN.
fin.release();
Expand Down Expand Up @@ -902,7 +902,7 @@ for (const violation of ["a partial group", "a group past the declared end"] as
// A received tail uses its wire position even without a locally retained prefix.
group = new GroupMessage({ subscribe: 0n, sequence: 0n, frameStart: 5 });
} else {
await encodeSubscribeResponse(sub.writer, { end: new SubscribeEnd(2n) }, version);
await encodeSubscribeResponse(sub.writer, { finish: new SubscribeFinish(2n) }, version);
group = new GroupMessage({ subscribe: 0n, sequence: 2n });
}
const writer = await Writer.open(pair.server, { version });
Expand Down
Loading
Loading