Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
044ab7d
chore(quest): claim quest/m2/multicast/roll-echo-stall.md
kixelated Nov 19, 2026
6e35acd
fix(moq-net): a time start a shared lite-07 copy already covers is pl…
kixelated Nov 19, 2026
56e15bf
fix(moq-net): a floor at a time start waits on no placing
kixelated Nov 19, 2026
62dfe66
fix(moq-net): carry the time start fixes onto main's span map and ran…
kixelated Nov 19, 2026
3b1e922
chore(quest): finish roll-echo-stall; a roll's starved reader fails t…
kixelated Nov 19, 2026
879d3b1
fix(moq-net): a held group outranks an earlier range's start; port to…
kixelated Nov 19, 2026
acbf460
Merge main: a time start an eviction places is never skipped
kixelated Nov 19, 2026
f681b81
chore: format, and drop reopen-starve's empty Related heading
kixelated Nov 19, 2026
7023f2e
fix(moq-net): a floored waiting time start reports where delivery starts
kixelated Nov 19, 2026
3b76d6a
fix(moq-net): a floored waiting start keeps the end its window resolved
kixelated Nov 19, 2026
f3dcc0e
chore(moq-net): waiting_key is async-only
kixelated Nov 19, 2026
f38cf96
fix(moq-net): a routed reader tells its serving copy's waiting time s…
kixelated Nov 19, 2026
21b0324
perf(moq-net): look up waiting ranges in one batch
kixelated Nov 19, 2026
1df2bd4
Merge main: reopen-starve became splice-stall
kixelated Nov 19, 2026
ab8e91a
Merge remote-tracking branch 'origin/main' into HEAD
kixelated Nov 19, 2026
7860341
fix(moq-net): port roll-echo-stall to #9183's reader-keyed copy subsc…
kixelated Nov 19, 2026
de7abe7
fix(moq-net): a range placed between SUBSCRIBE_START's two reads stil…
kixelated Nov 19, 2026
2ea51ac
fix(moq-net): a routed reader places each range its copy resolved on …
kixelated Nov 19, 2026
4e5f742
Merge remote-tracking branch 'origin/main' into quest/m2/multicast/ro…
kixelated Nov 19, 2026
e9d926c
Merge remote-tracking branch 'origin/main' into quest/m2/multicast/ro…
kixelated Nov 19, 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
23 changes: 23 additions & 0 deletions js/net/src/lite/publisher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,29 @@ for (const version of [Version.DRAFT_05, Version.DRAFT_06, Version.DRAFT_07]) {
}
}

// A relay's copy already asks from the oldest group, so a downstream asking from time 2 adds no
// range upstream and gets no start of its own. The oldest range starting at 6 still places it:
// the source holds nothing at or before 2.
test("lite draft-07: a time start a copy's oldest range covers starts where that range did", async () => {
const sub = await servedSubscription({ version: Version.DRAFT_07, startGroup: 2n });
// The relay's own reader, asking from the oldest group, which the copy's demand then starts at.
const local = sub.track.subscribe({ delay: { max: Duration.millis(60_000) } });
try {
hooks.receiveTrack(sub.track);
await flush();
hooks.timeStarts(sub.track, [[0n, 6n]]);
hooks.startTrack(sub.track, { start: 6n });
sub.serve(6n);
expect(await sub.servedSequence()).toBe(6n);
const response = await decodeSubscribeResponse(sub.client.reader, Version.DRAFT_07);
if (!("start" in response)) throw new Error("expected SUBSCRIBE_START");
expect(response.start.starts[0]).toBe(6n);
} finally {
local.close();
await sub.close();
}
});

// A relay's group stream can beat the upstream START on its own stream. Resolving from that
// group would give up the backlog the START still promises, so the first group waits for it.
for (const version of [Version.DRAFT_06, Version.DRAFT_07]) {
Expand Down
5 changes: 3 additions & 2 deletions js/net/src/lite/subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2875,8 +2875,8 @@ export class Subscriber {
// say where one starts. Mirrors the Rust `SubStream::declare`.
#declare(entry: SubscribeEntry): void {
// Where the publisher started each live range asked from a group's start, which a reader's
// time start there resolves to when the copy holds no group at it. Mirrors the Rust
// `report_time_starts`.
// time start there resolves to when the copy holds no group at it, and one asked from the
// oldest group as asked from 0. Mirrors the Rust `SubStream::report_starts`.
const times: [bigint, bigint][] = [];
// And each one counting back, which the copy, holding only part of the track, can't count,
// with the latest group it counted back from.
Expand All @@ -2889,6 +2889,7 @@ export class Subscriber {
if (at === undefined) continue;
if (time !== undefined) times.push([time, at]);
else if (back !== undefined) relative.push([back, at, entry.edges.get(id)]);
else if (range !== undefined && range.start === undefined) times.push([0n, at]);
}
hooks.timeStarts(entry.track, times);
hooks.relativeStarts(entry.track, relative);
Expand Down
25 changes: 25 additions & 0 deletions js/net/src/resume.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4665,6 +4665,31 @@ test("a group an inner front hands out already failed still continues on the out
b.close();
});

// Mirrors `a_routed_reader_places_a_range_past_one_still_waiting` in rs/moq-net/src/model/resume.rs:
// a range the copy placed is placed on the reader too while an earlier one still waits on a time
// start, so a publisher names its start.
test("a routed reader places a range past one still waiting", async () => {
const a = new BroadcastProducer();
const ta = copy(a);
hooks.receiveTrack(ta.producer);
const front = new Front();
front.serve(a.consume());
ta.write(64n);
const sub = front.consumer
.track("seq")
.subscribe({ delay: { max: null }, ranges: [{ start: { time: 66n } }, { start: { time: 64n } }] });
try {
await settle();
const resolved = hooks.servingResolved(sub);
expect(resolved[0]).toBeUndefined();
expect(resolved[1]?.start).toBe(64n);
} finally {
sub.close();
front.consumer.close();
a.close();
}
});

// Mirrors `an_ended_copy_leaves_a_time_start_to_the_serving_copy` in rs/moq-net/src/model/resume.rs:
// a copy that failed holds nothing past its last group, so it reaches a time start past that group
// back to its oldest. The copy continuing the track places it where the track holds it.
Expand Down
45 changes: 22 additions & 23 deletions js/net/src/resume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,10 @@ class Reader implements ResumeSource {
}

/**
* The reader's ranges resolved, a relative or time anchor where the first copy to place them
* all placed it, whatever its failover cap: that bounds what the copy delivers, not where the
* ranges resolve. Kept once placed, past that copy being let go. Pending, naming every group,
* while an anchor waits on a copy to place it. A copy resolves a time start against the groups
* The reader's ranges resolved, a relative or time anchor where the first copy to place it
* placed it, whatever its failover cap: that bounds what the copy delivers, not where the ranges
* resolve. Kept once placed, past that copy being let go. A range stays as first held, unplaced,
* while an anchor of its waits on a copy to place it. A copy resolves a time start against the groups
* it holds, which may place it below where the reader's window did: the window decides what is
* handed out. Mirrors the Rust `Reader::window`.
*/
Expand Down Expand Up @@ -704,42 +704,41 @@ class Reader implements ResumeSource {
}

/**
* Resolve unsettled {@link #window} anchors with a copy's resolution of the reader's ranges,
* unless an anchor still waits there too. Mirrors the Rust `Reader::resolve`.
* Place each unsettled {@link #window} range where a copy resolved it, on its own: one whose
* anchors still wait leaves the rest placed, so a publisher names their starts. Mirrors the Rust
* `Reader::resolve`.
*/
#resolve(resolved: readonly (Resolved | undefined)[]): void {
const resolution = this.#resolution;
if (!resolution) return;
// Once placed, relative and time starts stay pinned even while a time end settles.
const placed = resolution.window.pending ? undefined : resolution.window.resolved();
const anchored: track.Range[] = [];
for (const [index, range] of resolution.from.entries()) {
const at = resolved[index];
const placed: [bigint, track.Range][] = [];
for (const key of resolution.window.unsettled()) {
const range = resolution.from[Number(key)];
if (range === undefined) continue;
const at = resolved[Number(key)];
if (!at) {
// A range the copy left unresolved keeps its anchors, which only a copy can place.
const unplaced =
range.start?.relative !== undefined ||
(range.start?.time ?? 0n) > 0n ||
range.end?.relative !== undefined;
if (unplaced && !isEmpty(range)) return;
anchored.push(range);
// Placed as it is: nothing of it waits on a copy.
if (!unplaced || isEmpty(range)) placed.push([key, range]);
continue;
}
const previous = placed?.[index];
const start = previous ?? at;
const end = previous?.end ?? at.end;
if (range.end !== undefined && end === 0n) {
anchored.push(EMPTY);
if (range.end !== undefined && at.end === 0n) {
placed.push([key, EMPTY]);
continue;
}
const out: track.Range = {};
// One that reached back to the oldest group still does, as on a plain reader.
if (range.start !== undefined && start.floored) out.start = { time: start.start };
if (range.end !== undefined) out.end = end === undefined ? range.end : { time: end - 1n };
anchored.push(out);
if (range.start !== undefined && at.floored) out.start = { time: at.start };
if (range.end !== undefined) out.end = at.end === undefined ? range.end : { time: at.end - 1n };
// A relative end still open would leave it waiting on a first group it never gets.
if (out.end?.relative !== undefined && !isEmpty(out)) continue;
placed.push([key, out]);
}
const window = new Window(anchored, undefined, AT_KEYS);
if (!window.pending) resolution.window = window;
if (placed.length > 0) resolution.window.edit([], placed, undefined, AT_KEYS);
}

/** The reader's ranges, as its preferences name them. */
Expand Down
18 changes: 16 additions & 2 deletions js/net/src/track.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5634,7 +5634,10 @@ test("finishing returns handles that write nothing new but fill a late group", a
finished.close();
});

test("track: a reader's unplaced times are the times its holdings can't place", () => {
// Mirrors moq-net's `unplaced_holds_only_what_containing_cant_place`: a run holds only times
// `containing` can't place, but those a reported start places directly, and leaves out only
// times below the newest start reported past an earlier range's time.
test("track: a reader's unplaced times are only times its holdings can't place", () => {
let seed = 5;
const random = (below: number) => {
seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0;
Expand All @@ -5645,14 +5648,25 @@ test("track: a reader's unplaced times are the times its holdings can't place",
for (let round = 0; round < 400; round++) {
const received = random(2) === 0;
const producer = received ? receivedTrack() : new TrackProducer("test").accept({ maxAge: null });
const starts: [bigint, bigint][] = [];
if (received) {
for (let n = random(3); n > 0; n--) starts.push([BigInt(random(48)), BigInt(random(48))]);
hooks.timeStarts(producer, starts);
}
const reported = new Set(starts.map(([time]) => time));
let past = 0n;
for (const [asked, start] of new Map(starts)) if (asked < start && start > past) past = start;
const reader = producer.subscribe();
for (let step = random(16); step >= 0; step--) {
const holdings = hooks.subscriberHoldings(reader);
const unplaced = holdings.unplaced?.();
expect(unplaced).toBeDefined();
for (let at = 0n; at < 64n; at++) {
const open = unplaced?.runs.some((run) => run.start <= at && at < run.end) ?? false;
expect([received, at, holdings.containing(at) === "unknown"]).toEqual([received, at, open]);
const unknown = holdings.containing(at) === "unknown";
if (reported.has(at)) expect([at, unknown]).toEqual([at, false]);
else if (open) expect([at, unknown]).toEqual([at, true]);
else if (unknown) expect([at, received && at < past]).toEqual([at, true]);
}
const key = BigInt(random(48));
if (random(2) === 0) {
Expand Down
31 changes: 28 additions & 3 deletions js/net/src/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,8 @@ let keysOf: (producer: Producer) => readonly bigint[];
let timeAnchors: (producer: Producer) => {
atKeys: boolean;
starts: ReadonlyMap<bigint, bigint>;
/** The newest of `starts` past the time its range asked from, 0 when none is. */
past: bigint;
relative: ReadonlyMap<bigint, { start: bigint; latest?: bigint }>;
/** Bumped whenever the others, or whether the producer is a received copy, change. */
placing: number;
Expand Down Expand Up @@ -1277,6 +1279,9 @@ export class Producer {
// Where the upstream publisher started each of a lite-07 copy's live wire ranges, by the time
// it asked from. Mirrors the Rust `TrackState::time_starts`.
#timeStarts = new Map<bigint, bigint>();
// The newest start in `#timeStarts` past the time its range asked from, kept as it is
// replaced: a reader's `unplaced` reads it on every settle. Mirrors the Rust `starts_past`.
#startsPast = 0n;
// On a lite-07 copy, where the publisher started each live range counting back, by its count.
#relativeStarts = new Map<bigint, { start: bigint; latest?: bigint }>();
// Counts changes to how a time start is placed other than by groups arriving or drops: the wire,
Expand Down Expand Up @@ -1513,6 +1518,7 @@ export class Producer {
timeAnchors = (producer) => ({
atKeys: producer.#startsAtKeys,
starts: producer.#timeStarts,
past: producer.#startsPast,
relative: producer.#relativeStarts,
placing: producer.#placing,
});
Expand All @@ -1522,6 +1528,10 @@ export class Producer {
};
hooks.timeStarts = (producer, starts) => {
producer.#timeStarts = new Map(starts);
producer.#startsPast = 0n;
for (const [asked, start] of producer.#timeStarts) {
if (asked < start && start > producer.#startsPast) producer.#startsPast = start;
}
producer.#placing++;
};
hooks.relativeStarts = (producer, starts) => {
Expand Down Expand Up @@ -3634,7 +3644,16 @@ export class Subscriber {
if (below !== undefined && (drops.covers(below + 1n, time + 1n) || index < keys.length)) {
return { group: below };
}
if (below === undefined && drops.covers(0n, time + 1n)) return "before";
if (below === undefined) {
if (drops.covers(0n, time + 1n)) return "before";
// A range asked from an earlier time, or from the oldest group (as 0), that the
// publisher started past it says the same, while the copy holds no group there.
if (anchors.past > time) {
for (const [asked, start] of anchors.starts) {
if (asked < time && start > time) return "before";
}
}
}
return "unknown";
}
if (below !== undefined) return { group: below };
Expand All @@ -3649,14 +3668,20 @@ export class Subscriber {
const runs: Run[] = [];
const first = keys[0];
const last = keys.at(-1);
// `containing` places a time below every held group from a start reported past an
// earlier range's time, which an eviction brings about without moving the mark, so a
// run there starts past the newest such start. Mirrors the Rust `TrackState::unplaced`.
const past = wire ? anchors.past : 0n;
const unheld = (run: Run | undefined): Run | undefined =>
run && run.start < past ? { start: past, end: run.end } : run;
if (anchors.atKeys || state.fetch) {
// Every time starts a group.
} else if (first === undefined || last === undefined) {
const open = uncovered(0n);
const open = unheld(uncovered(0n));
if (open) runs.push(open);
} else if (wire) {
// Below every group, up to the first, and above the last, past the drops after it.
const below = uncovered(0n);
const below = unheld(uncovered(0n));
if (below && below.start < first) runs.push({ start: below.start, end: first });
const above = uncovered(last + 1n);
if (above) runs.push(above);
Expand Down
11 changes: 11 additions & 0 deletions js/net/src/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,17 @@ export class Window {
return this.#pending.size > 0;
}

/**
* The keys of the ranges still waiting on a relative anchor, a live join's reach back, or a
* time start. Mirrors the Rust `Window::unsettled`.
*/
unsettled(): Set<bigint> {
const keys = new Set([...this.#pending, ...this.#reaching]);
for (const entry of this.#waiting.all()) for (const key of entry.keys) keys.add(key);
for (const entry of this.#looking.all()) for (const key of entry.keys) keys.add(key);
return keys;
}

/** Whether nothing is left to resolve as groups arrive. */
get settled(): boolean {
return this.#pending.size === 0 && !this.#unplaced() && this.#looking.size === 0;
Expand Down
5 changes: 2 additions & 3 deletions quest/m2/multicast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ resumes on a detour learned after its session closed. The lite-07 cut still
waits on this epic's children, the other flaw,
[a route moving behind one next hop resending a group](/quest/m2/multicast/resend.md),
whose fix changes the wire,
and two flaws the mesh replay found,
[feeding an old relay's subscription mid-roll](/quest/m2/multicast/roll-echo-stall.md)
and [a lite-07 front that stops delivering after it switches copies](/quest/m2/multicast/splice-stall.md);
and a flaw the mesh replay found,
[a lite-07 front that stops delivering after it switches copies](/quest/m2/multicast/splice-stall.md);
and on
[route layer acceptance](/quest/m2/cluster-routes/acceptance.md)'s
scoped subscriber whose grant is too wide to ask for. It does not wait on
Expand Down
59 changes: 0 additions & 59 deletions quest/m2/multicast/roll-echo-stall.md

This file was deleted.

2 changes: 1 addition & 1 deletion quest/m2/multicast/splice-stall.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ Not a wire change.

- [reopen-starve](https://github.com/moq-dev/moq/pull/9179) - a request
refused before the neighbour's claims returned, and never asked again
- [roll-echo-stall](/quest/m2/multicast/roll-echo-stall.md) - a time start a
- [roll-echo-stall](https://github.com/moq-dev/moq/pull/9174) - a time start a
shared copy never places
Loading