Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion quest/m1/interop-coverage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ coverage on `main` at `3ab6cbf81d`.

- [JS namespace lifecycle](/quest/m1/interop-coverage/js-namespace-done.md) - the runner's moq-dev-js client moves to an `@moq/net` that withdraws namespaces by reset, so subscribe-namespace-lifecycle passes on Cloudflare draft-18 and aiomoqt
- [JS subgroup data through imquic](/quest/m1/interop-coverage/js-imquic-objects.md) - the runner's moq-dev-js client moves to an `@moq/net` patch that writes data stream headers in one write, so data-subgroup-basic passes against imquic
- [Late join and FETCH](/quest/m1/interop-coverage/late-join.md) - a late subscriber gets the current group from object 0, and a standalone FETCH returns a past group exactly

## Related

Expand Down
25 changes: 0 additions & 25 deletions quest/m1/interop-coverage/late-join.md

This file was deleted.

4 changes: 0 additions & 4 deletions quest/m1/next-object-cold-copy.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,3 @@ with Next Object before any frame of `g` arrives. If it reproduces, keep the
reported Object ID out of the reader's frame index, as JS does.

Public API: none. Wire: none.

## Related

- [Interop covers late join and FETCH](/quest/m1/interop-coverage/late-join.md) - the cross-implementation late-join case
5 changes: 0 additions & 5 deletions quest/m2/ietf-headless-group.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,3 @@ the mid-group stream arrives and after it. Both drop the group, and the
subscription keeps delivering whole groups after it.

Public API: none. Wire: none.

## Related

- [Late join and FETCH](/quest/m1/interop-coverage/late-join.md) - the
joining FETCH that normally supplies the head
1 change: 0 additions & 1 deletion quest/m2/ietf-join-after-finish.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,3 @@ refused.
## Related

- [JS joining FETCH](/quest/m2/ietf-js-joining-fetch.md) - the JS publisher mirrors the bound settled here
- [Interop covers late join and FETCH](/quest/m1/interop-coverage/late-join.md) - the cross-implementation joining FETCH case
23 changes: 19 additions & 4 deletions test/interop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,22 @@ The normal run also checks a finite raw track through the relay. Its publisher
announces end 4 before writing four 256 KiB groups; the reader verifies every byte,
exactly groups 0 through 3, and a clean end at 4. Rust-to-Rust always runs. Selecting
native JS adds both Rust-to-JS and JS-to-Rust under that runtime, so `--all` covers
Node and Bun. The current CLI also FETCHes group 0, verifies every byte, and closes under the relay idle-out check. `--tail` runs this FETCH round and the five finite-tail lanes. The wire-compat lanes, which swap in released relays and clients, skip them.
Node and Bun. The current CLI also FETCHes group 1 of a finished track from the Rust
publisher and each selected native JS runtime, requires exactly its three objects, each
with its own bytes, and closes under the relay idle-out check.

A late-join lane runs Rust-to-Rust and Rust/Node/Bun in both directions. The publisher
writes the first two objects of group 0 before any subscriber exists and leaves the group
open. The subscriber joins at the latest group, as a player does, and reports once it has
read those two objects; only then does the harness release the rest of the group and
group 1. A join that skips the head cannot pass by racing the publisher. On
moq-transport a Rust subscriber, and the relay toward its publisher, recover the head
with a joining FETCH before draft 22 and a fill from it. A JS subscriber requests
neither: on draft 22 it subscribes from the current group's start, and before that the
Rust relay replays the group on the subscription.

`--tail` runs the FETCH round, the late joins, and the five finite-tail lanes. The
wire-compat lanes, which swap in released relays and clients, skip them.

The finite clients keep their session alive until the harness acknowledges the
reader's complete clean end over stdin, so a lane tests delivery rather than
Expand Down Expand Up @@ -184,8 +199,8 @@ delivers them as minted: a publisher is granted its exact broadcast, a subscribe
relay. `auto`, the default, is everything above. Any other version pins every
client in its pass to offer that version alone, and `ietf` expands to the even
drafts `moq-transport-18` through `moq-transport-22`. A pinned pass keeps the
media cells, the relay close check, the CLI FETCH of group 0, and the finite
tails. The grant, refusal, close-code, and drop cases are moq-lite's and run in
media cells, the relay close check, the CLI FETCH round, the late joins, and the
finite tails. The grant, refusal, close-code, and drop cases are moq-lite's and run in
`auto` alone.

The relay logs the version each connection negotiated, so every round in a
Expand Down Expand Up @@ -246,7 +261,7 @@ just test interop --all
# Pick your own axes:
just test interop --publishers rust,python --subscribers rust,c,js-native-bun

# CLI FETCH close and finite track tails only: Rust-to-Rust and Rust/Node/Bun in both directions.
# CLI FETCH close, late joins, and finite track tails only: Rust-to-Rust and Rust/Node/Bun in both directions.
just test interop --tail

# The full matrix once per even moq-transport draft (see moq-transport below).
Expand Down
2 changes: 1 addition & 1 deletion test/interop/clients/js-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@moq/hang": "workspace:*",
"@moq/json": "workspace:*",
"@moq/net": "workspace:*",
"@moq/web-transport": "^0.1.5",
"@moq/web-transport": "^0.1.6",
"@zod/mini": "^4.6.7",
"zod": "^4.6.7"
},
Expand Down
122 changes: 91 additions & 31 deletions test/interop/clients/js-native/tail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
* `drop` cuts group 1. `join` reads from whichever group the subscription starts at: a
* moq-transport subscription starts at the largest group rather than at the range asked for, so
* it must read a contiguous run of groups through the last one. `compress` publishes a compressed
* track with several frames, one empty, in each group.
* track with several frames, one empty, in each group. `cached` publishes every group before
* announcing, for a FETCH of a past group. `late` writes the head of group 0 before announcing and
* the rest only once the harness relays that the subscriber read it, so a join that skips the head
* stalls rather than racing the publisher.
*
* @module
*/
Expand All @@ -17,6 +20,9 @@ import { install } from "@moq/web-transport";
install();
const GROUPS = 4;
const BYTES = 256 * 1024;
// The groups a `late` track publishes, and how many frames of group 0 precede the subscriber.
const LATE_GROUPS = 2;
const LATE_HEAD = 2;
const [role, url, path, version, mode] = process.argv.slice(2);
const drop = mode === "drop";
const compress = mode === "compress";
Expand All @@ -25,13 +31,55 @@ console.info = console.error;
const join = mode === "join" || mode === "status";
const datagram = mode === "datagram";
const status = mode === "status";
const cached = mode === "cached";
const late = mode === "late";
if (
!url ||
!path ||
!["publish", "subscribe"].includes(role) ||
![undefined, "drop", "join", "compress", "datagram", "status"].includes(mode)
![undefined, "drop", "join", "compress", "datagram", "status", "cached", "late"].includes(mode)
) {
throw new Error("usage: tail.ts publish|subscribe URL BROADCAST [VERSION [drop|join|compress|datagram|status]]");
throw new Error(
"usage: tail.ts publish|subscribe URL BROADCAST [VERSION [drop|join|compress|datagram|status|cached|late]]",
);
}

/**
* The frames of each group. A compressed track spans several frames, one empty, per window.
* `cached` and `late` give every frame its own bytes, so a FETCH or join that drops, repeats, or
* reorders one fails.
*/
function frames(sequence: number): Uint8Array[] {
if (compress)
return [new Uint8Array(BYTES / 2).fill(sequence), new Uint8Array(0), new Uint8Array(BYTES / 2).fill(sequence)];
if (cached || late) return [0, 1, 2].map((index) => new Uint8Array(BYTES / 4).fill(sequence * 16 + index));
return [new Uint8Array(BYTES).fill(sequence)];
}

/** Publish every group, cutting group 1 for `drop`. The end precedes the last group's data. */
function write(track: Moq.Track.Producer) {
track.finishAt({ group: GROUPS, frame: 0 });
for (let sequence = 0; sequence < GROUPS; sequence++) {
const group = track.appendGroup();
if (drop && sequence === 1) {
group.abort(new Error("cut"));
continue;
}
for (const payload of frames(sequence)) group.writeFrame({ payload });
group.finish();
}
track.finish();
}

/** Read one whole group, checking every frame's bytes, and report when the `late` head is in. */
async function read(group: Moq.Group.Consumer) {
for (const [index, want] of frames(group.sequence).entries()) {
const frame = await group.readFrame();
assert(frame, "short group");
assert(Buffer.from(frame.payload).equals(want), `wrong frame ${index} in group ${group.sequence}`);
if (late && group.sequence === 0 && index + 1 === LATE_HEAD) process.stdout.write("late head\n");
}
assert.equal(await group.readFrame(), undefined, "extra frame");
}

const origin = new Moq.Origin.Producer();
Expand All @@ -46,10 +94,27 @@ try {
const broadcastPublication = origin.createBroadcast(Moq.Path.from(path));
const broadcast = broadcastPublication.broadcast;
const track = broadcast.createTrack("tail", { compress, ...(status ? { priority: 2 } : {}) });
if (cached) write(track);
let head: Moq.Group.Producer | undefined;
if (late) {
head = track.appendGroup();
for (const payload of frames(0).slice(0, LATE_HEAD)) head.writeFrame({ payload });
}
broadcastPublication.announce();
const lines = createInterface({ input: process.stdin });
const commands = lines[Symbol.asyncIterator]();
if (!status) {
if (head) {
assert.equal((await commands.next()).value, "late tail", "subscriber did not read the head");
for (const payload of frames(0).slice(LATE_HEAD)) head.writeFrame({ payload });
head.finish();
for (let sequence = 1; sequence < LATE_GROUPS; sequence++) {
const group = track.appendGroup();
for (const payload of frames(sequence)) group.writeFrame({ payload });
group.finish();
}
track.finish();
track.close();
} else if (!status && !cached) {
const demand = track.demand();
while (demand.wanted.peek() === undefined) await demand.wanted.changed();
if (datagram) {
Expand All @@ -58,20 +123,7 @@ try {
track.appendDatagram(undefined, new Uint8Array(900).fill(sequence));
}
} else {
// The end precedes the last group's data; the transport still has to drain it.
track.finishAt({ group: GROUPS, frame: 0 });
for (let sequence = 0; sequence < GROUPS; sequence++) {
const group = track.appendGroup();
if (drop && sequence === 1) {
group.abort(new Error("cut"));
continue;
}
for (const size of compress ? [BYTES / 2, 0, BYTES / 2] : [BYTES]) {
group.writeFrame({ payload: new Uint8Array(size).fill(sequence) });
}
group.finish();
}
track.finish();
write(track);
track.close();
}
}
Expand All @@ -91,9 +143,12 @@ try {
await request.active.changed();
broadcast = request.active.peek();
}
const track = broadcast
.track("tail")
.subscribe({ maxDelay: Milli(drop ? 60_000 : 5000), groups: { start: { included: 0 } } });
// `late` names no start, joining the latest group as a player does: group 0, whose
// head predates the subscription.
const track = broadcast.track("tail").subscribe({
maxDelay: Milli(drop ? 60_000 : 5000),
...(late ? {} : { groups: { start: { included: 0 } } }),
});
if (compress) assert.equal((await track.info()).compress, version === "moq-lite-07-wip");
const seen: number[] = [];
try {
Expand All @@ -113,22 +168,27 @@ try {
process.stdout.write(`datagram ${sequence}\n`);
}
console.error("datagram clean groups=0,1,2,3 bytes=3600");
} else if (late) {
for (let sequence = 0; sequence < LATE_GROUPS; sequence++) {
const group = await track.recvGroup();
assert(group, "missing group");
try {
assert.equal(group.sequence, sequence, "joined the wrong group");
await read(group);
} finally {
group.close();
}
}
assert.equal(await track.recvGroup(), undefined, "extra group");
assert.deepEqual(await track.finished(), { group: LATE_GROUPS, frame: 0 });
console.error("late join clean groups=0,1 frames=6");
} else {
for (;;) {
const group = await track.recvGroup();
if (!group) break;
try {
assert(group.sequence < GROUPS, `unexpected group ${group.sequence}`);
for (const size of compress ? [BYTES / 2, 0, BYTES / 2] : [BYTES]) {
const frame = await group.readFrame();
assert(frame, "empty group");
assert.equal(frame.payload.byteLength, size, "truncated group");
assert(
frame.payload.every((byte) => byte === group.sequence),
"corrupt group",
);
}
assert.equal(await group.readFrame(), undefined, "extra frame");
await read(group);
seen.push(group.sequence);
} finally {
group.close();
Expand Down
Loading
Loading