Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ef30f31
chore(quest): claim quest/m2/cluster-routing/routes/js.md
kixelated Nov 10, 2026
93f99fc
feat(net)!: js/net speaks lite-07's route layer
kixelated Nov 10, 2026
d448e32
test(tokio): the datagram tracks relay carries what it learns on
kixelated Nov 10, 2026
aa4a00d
fix(net): rank every lite-07 route's claim per consume, apply replies…
kixelated Nov 10, 2026
a817f15
fix(net): newest stream wins a consume tie, and a held instance follo…
kixelated Nov 10, 2026
5339f99
fix(net): js/net breaks route ties as rs/moq-net does, in one helper
kixelated Nov 10, 2026
8e2b7aa
chore(quest): claim quest/m2/route-latency.md
kixelated Nov 10, 2026
eb45e04
fix(net): bound a lite-07 answer's ended routes, and finish it with i…
kixelated Nov 10, 2026
7dff282
quest: size the route latency sum for the maintainer's lite-07 decision
kixelated Nov 10, 2026
2b4e16d
fix(net): serve a received claim only its own instance, and rank mixe…
kixelated Nov 10, 2026
20ec9fd
fix(net): the origin holds each lite-07 node's claim, and a handover …
kixelated Nov 10, 2026
5c8f391
Merge remote-tracking branch 'origin/main' into quest/m2/cluster-rout…
kixelated Nov 10, 2026
3041b06
feat(net): lite-07 routes carry an informational min RTT
kixelated Nov 10, 2026
4af6bc0
fix(net): gate the link RTT sampler on async, and format
kixelated Nov 10, 2026
c28ca28
fix(net): stop the link RTT timer on a transport that reports none
kixelated Nov 10, 2026
d99d0e6
fix(net): forward a Min RTT past the field's range as unknown
kixelated Nov 10, 2026
c2468ba
feat(net)!: name the route's round trip `rtt` and drop withholding
kixelated Nov 11, 2026
3fe08a6
fix(net): restart the link RTT window after a pause in routes
kixelated Nov 11, 2026
f580c52
Merge remote-tracking branch 'origin/main' into quest/m2/route-latency
kixelated Nov 11, 2026
685c438
Merge remote-tracking branch 'origin/main' into quest/m2/route-latency
kixelated Nov 11, 2026
e71cb1f
fix(net): sample a link's RTT before serving the first claims
kixelated Nov 11, 2026
6cdeb93
style: rustfmt
kixelated Nov 11, 2026
11e4198
docs(relay): route RTT ends at the origin node, not the publisher
kixelated Nov 11, 2026
5964c6e
Merge remote-tracking branch 'origin/main' into quest/m2/cluster-rout…
kixelated Nov 11, 2026
9172c53
Merge commit '11e4198e8a2c2a5815fd0478aba9519a4aaa21b3' into quest/m2…
kixelated Nov 11, 2026
8a7484f
feat(net): js/net reads and writes lite-07 route flags and RTT
kixelated Nov 11, 2026
764e98c
Merge remote-tracking branch 'origin/main' into quest/m2/cluster-rout…
kixelated Nov 11, 2026
2c8c9ed
Merge remote-tracking branch 'origin/main' into quest/m2/cluster-rout…
kixelated Nov 11, 2026
84b6c9a
feat(net): js/net carries lite-07 route hops
kixelated Nov 11, 2026
323c67f
Merge remote-tracking branch 'origin/main' into quest/m2/cluster-rout…
kixelated Nov 11, 2026
60de5b5
Merge remote-tracking branch 'origin/main' into quest/m2/cluster-rout…
kixelated Nov 12, 2026
613e510
fix(net): js/net advances its route seqno only when a session carryin…
kixelated Nov 12, 2026
23d7e3b
quest: scope.md names js/net's route layer files, since this PR delet…
kixelated Nov 12, 2026
fb1a99d
Merge remote-tracking branch 'origin/main' into quest/m2/cluster-rout…
kixelated Nov 12, 2026
ab23477
fix(net): js/net merges a node's floors across announce streams
kixelated Nov 12, 2026
ba81448
fix(net): js/net keeps a route's certified view and its newest cost
kixelated Nov 12, 2026
3ffdf15
Merge remote-tracking branch 'origin/main' into iterate/8443-floors
kixelated Nov 12, 2026
3656205
test(net): floors.test builds its mutable view directly
kixelated Nov 12, 2026
fddac7d
fix(net): js/net reshows a node's other routes when one leaves
kixelated Nov 12, 2026
7aa9c33
fix(net): js/net's floors re-show pruned claims, skip covered claims,…
kixelated Nov 12, 2026
71a900b
fix(net): a lite-07 consume pinned to a minted instance asks for it
kixelated Nov 12, 2026
9cfc186
quest: the router quest makes js/net's origin apply the covering rule
kixelated Nov 12, 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
9 changes: 6 additions & 3 deletions .github/workflows/interop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ jobs:
run: nix develop --command just test max-age
shell: bash -leo pipefail {0}

# Datagram tracks awaits the JS lite-07 route wire in
# quest/m2/cluster-routing/routes/js.md; recorded as skipped below.
- name: Datagram tracks
id: datagram-tracks
if: ${{ !cancelled() && steps.setup.outcome == 'success' }}
run: nix develop --command just test datagram-tracks
shell: bash -leo pipefail {0}

- name: Stream limits over WebSocket
id: stream-limits
Expand Down Expand Up @@ -222,7 +225,7 @@ jobs:
"Rust cache": "${{ steps.rust-cache.outcome }}",
"Playwright Chromium": "${{ steps.setup.outcome }}",
"Optional publisher retention": "${{ steps.max-age.outcome }}",
"Datagram tracks": "skipped",
"Datagram tracks": "${{ steps.datagram-tracks.outcome }}",
"Stream limits over WebSocket": "${{ steps.stream-limits.outcome }}",
"Relay fills": "${{ steps.relay-fill.outcome }}",
"Receive credit recovery": "${{ steps.receive-credit.outcome }}",
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,9 @@ jobs:
# `rs uring` is a separate feature compile (off the default set), and
# CI_STRICT fails it below the 6.12 kernel floor. The embedding tests for
# io_uring live there; uring.yml also runs it on affected release PRs.
# `test drain` awaits the JS lite-07 route wire in
# quest/m2/cluster-routing/routes/js.md; keep its local recipe usable.
# `test drain` stands up two relays and drains one under a live JS
# viewer: diff-independent, since a break can arrive through the relay,
# js/net, or the wire between them.
# `rs quic-sim` sweeps moq-quic's simulated workloads from a fresh seed; PRs run a fixed 64.
# `rs rung-disable` proves FFI simulcast disable and recovery on a shaped BBR3 uplink.
# `test resume-model` sweeps resume against its model from a fresh seed; PRs run a fixed 64.
Expand All @@ -362,7 +363,7 @@ jobs:
# `rs v4l2` streams moq-video's V4L2 capture from the kernel's vivid
# virtual camera, a module load no pull request job should make.
# `js worklet-matrix` loads `?worklet` output through the bundlers pinned in test/worklet.
recipe: ["gate", "gh test-integration", "rs doctest --workspace", "rs send-depth", "test drill-sensitivity", "rs uring", "test json-properties", "test resume-model", "test route-key-model", "test route-sweep", "rs quic-sim", "rs rung-disable", "test drill impaired", "rs cli-export", "rs hls-conformance", "rs quic-stress", "rs audio-devices", "rs multicast", "rs render-sw", "test qmux", "rs v4l2", "js worklet-matrix"]
recipe: ["gate", "gh test-integration", "rs doctest --workspace", "rs send-depth", "test drill-sensitivity", "rs uring", "test drain", "test json-properties", "test resume-model", "test route-key-model", "test route-sweep", "rs quic-sim", "rs rung-disable", "test drill impaired", "rs cli-export", "rs hls-conformance", "rs quic-stress", "rs audio-devices", "rs multicast", "rs render-sw", "test qmux", "rs v4l2", "js worklet-matrix"]
include:
# Miri interprets kio's and moq-net's in-memory unsafe; too slow for the merge gate.
- recipe: rs miri
Expand Down
14 changes: 14 additions & 0 deletions js/net/src/announced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ export interface Options {
covering?: boolean;
}

/**
* Options for a route stream, which forwarding code reads.
*
* @internal
*/
export interface RouteOptions extends Options {
/**
* Report each origin node's claim at a path as its own route, rather than only the one the
* session ranks best, so the origin it feeds ranks every candidate as rs/moq-net's does. Only
* lite-07 carries more than one route per path on a stream.
*/
claims?: boolean;
}

/** Reactive backing state shared by announcement producers and consumers. */
class AnnounceState {
queue = new Signal<RouteEvent[]>([]);
Expand Down
6 changes: 3 additions & 3 deletions js/net/src/connection/close.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ for (const protocol of [Lite.ALPN_07_WIP, Ietf.ALPN.DRAFT_18]) {
const closing = server.close();
await fin.reached;
expect(closed).toBe(false);
// lite-07 withdraws its claims; moq-transport only ends the stream, which
// withdraws nothing without a NAMESPACE_DONE.
expect((await announced.next())?.kind).toBe(protocol === Lite.ALPN_07_WIP ? "end" : "offline");
// lite-07 lets go of its route with a ROUTE_END, and moq-transport only ends the
// stream: neither withdraws the origin's claims, so the path goes offline.
expect((await announced.next())?.kind).toBe("offline");
if (outcome === "timeout") {
// bun's `rejects` blocks on a pending promise, so catch first and advance.
const timedOut = closing.catch((err: unknown) => err);
Expand Down
105 changes: 101 additions & 4 deletions js/net/src/connection/forward.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class FakeSession {
scope: string;
hidden: boolean | undefined;
covering: boolean | undefined;
claims: boolean | undefined;
stream: Announce.Producer;
}[] = [];

Expand All @@ -58,6 +59,9 @@ class FakeSession {
*/
readonly consumed = new Map<Path.Valid, BroadcastProducer[]>();

/** The instance each consume was pinned to, in order. */
readonly pins: (Instance.Valid | undefined)[] = [];

/** Whether each request is synced as it opens, as one with no initial set to wait for is. */
syncedAtOnce = false;

Expand All @@ -70,7 +74,7 @@ class FakeSession {
/** `exclusive` stands in for a peer that refuses overlapping requests. */
constructor({ exclusive = false } = {}) {
registerWire(this, {
consume: (path) => this.consume(path),
consume: (path, instance) => this.consume(path, instance),
exclusive,
leave: () => {},
auth: new AuthSession({ peerGrant: { publish: new Path.Patterns(), subscribe: new Path.Patterns() } }),
Expand All @@ -80,9 +84,15 @@ class FakeSession {
});
}

routes(scope: Path.Pattern = Path.Pattern.all(), options?: Announce.Options): Announce.Routes {
routes(scope: Path.Pattern = Path.Pattern.all(), options?: Announce.RouteOptions): Announce.Routes {
const stream = new Announce.Producer();
this.requests.push({ scope: scope.text, hidden: options?.hidden, covering: options?.covering, stream });
this.requests.push({
scope: scope.text,
hidden: options?.hidden,
covering: options?.covering,
claims: options?.claims,
stream,
});
if (this.syncedAtOnce) stream.synced();
const consumer = stream.consume();
const close = consumer.close.bind(consumer);
Expand All @@ -109,7 +119,8 @@ class FakeSession {
return found.stream;
}

consume(path: Path.Valid): BroadcastConsumer {
consume(path: Path.Valid, instance?: Instance.Valid): BroadcastConsumer {
this.pins.push(instance);
const producer = new BroadcastProducer();
const existing = this.consumed.get(path);
if (existing) existing.push(producer);
Expand Down Expand Up @@ -146,6 +157,92 @@ function record(stream: Announce.Routes): string[] {
return events;
}

// A session can carry another instance's claim at the prefix, which ranks apart from this one:
// a request through a received route consumes that route's instance, never whichever wins.
test("a request through a received route consumes that route's instance", async () => {
const origin = new OriginProducer();
const session = new FakeSession();
forwardAnnounced(session.session, origin);
const instance = Instance.parse("a");
const request = origin.request(Path.from("pool/job"));
await settle();
start(session.stream("pool/job/**"), "pool/job", { ...WireRoute.default, instance });
session.stream("pool/job/**").synced();
await settle();
expect(request.active.peek()).toBeDefined();
expect(session.pins).toEqual([instance]);
request.close();
session.die();
origin.close();
});

// A lite-07 stream reports each origin node's claim at a path as its own route, so the origin
// holds every candidate: an unpinned request spreads by node as Rust's does, and one pinned to
// the claim that does not win still resolves.
test("the origin holds each origin node's claim at a prefix", async () => {
const origin = new OriginProducer();
const session = new FakeSession();
forwardAnnounced(session.session, origin);
const a = Instance.parse("a");
const b = Instance.parse("b");
const watch = origin.routes(Path.Pattern.subtree(Path.from("pool")));
await settle();
expect(session.requests[0]).toMatchObject({ claims: true });
start(session.stream("pool/**"), "pool", { ...WireRoute.default, instance: a, node: 0x7an });
start(session.stream("pool/**"), "pool", { ...WireRoute.default, instance: b, node: 0x8bn });
session.stream("pool/**").synced();
await settle();

// 0x8b's rendezvous hash wins `pool/job`; see `lite07_ties_match_js` in rs/moq-net.
const job = Path.from("pool/job");
const unpinned = origin.request(job);
await settle();
expect(unpinned.active.peek()).toBeDefined();
expect(session.pins).toEqual([b]);
const pinned = origin.request(job, { instance: a });
await settle();
expect(pinned.active.peek()).toBeDefined();
expect(session.pins).toEqual([b, a]);

unpinned.close();
pinned.close();
watch.close();
session.die();
origin.close();
});

// A route handed to another request's report of another instance restarts, so its requests
// consume that instance rather than the one the first report named.
test("a route handed over to another instance consumes that instance", async () => {
const origin = new OriginProducer();
const session = new FakeSession();
forwardAnnounced(session.session, origin);
const a = Instance.parse("a");
const b = Instance.parse("b");
const narrow = origin.routes(Path.Pattern.subtree(Path.from("a/b")));
await settle();
start(session.stream("a/b/**"), "a/b/x", { ...WireRoute.default, instance: a, epoch: 0n });
session.stream("a/b/**").synced();
const broad = origin.routes(Path.Pattern.subtree(Path.from("a")));
await settle();
start(session.stream("a/**"), "a/b/x", { ...WireRoute.default, instance: b, epoch: 0n });
session.stream("a/**").synced();
await settle();

session.stream("a/b/**").close(new Error("namespace rejected"));
await settle();
const request = origin.request(Path.from("a/b/x"));
await settle();
expect(request.active.peek()).toBeDefined();
expect(session.pins.at(-1)).toBe(b);

request.close();
narrow.close();
broad.close();
session.die();
origin.close();
});

test("a request discovers an unwatched path and waits for its initial set", async () => {
const origin = new OriginProducer();
const session = new FakeSession();
Expand Down
57 changes: 37 additions & 20 deletions js/net/src/connection/forward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,20 @@ export const DISCOVERY_REMOVED =
/** How long an announce request outlives its last watcher, so a watcher torn down and rebuilt reuses it. */
const LINGER = Duration.millis(2000);

/**
* Names one route a session reports: its prefix, and on lite-07 the origin node whose claim it
* is, since a stream reports each node's claim at a path as its own route.
*/
type Key = string;

function keyOf(prefix: Path.Valid, route: WireRoute): Key {
return route.node === undefined ? prefix : `${prefix}\u0000${route.node}`;
}

/** One announce request open on the session, and the routes it currently reports. */
interface Interest {
readonly announced: Announce.Routes;
readonly reported: Set<Path.Valid>;
readonly reported: Set<Key>;
/** The pending close, set while nothing at or beneath the prefix is watched. */
linger?: () => void;
/** Closed on purpose, so its end is not a discovery failure. */
Expand All @@ -39,6 +49,7 @@ interface Interest {
* request handing over to another never retracts it. The first reporter drives it.
*/
interface Reported {
readonly prefix: Path.Valid;
handle: Claim;
/** Each request's latest route for the prefix. */
readonly reporters: Map<Interest, WireRoute>;
Expand Down Expand Up @@ -85,22 +96,23 @@ export function forwardAnnounced(conn: Session, origin: OriginProducer): void {
let blind = false;

const interests = new Map<Path.Valid, Interest>();
const routes = new Map<Path.Valid, Reported>();
const routes = new Map<Key, Reported>();

void serveRequests(conn, origin);

const report = (interest: Interest, event: Announce.RouteEvent) => {
const { prefix, route } = event;
const key = keyOf(prefix, route);
if (event.kind === "end" || event.kind === "offline") {
unreport(interest, prefix, event.kind === "end");
unreport(interest, key, event.kind === "end");
return;
}
interest.reported.add(prefix);
interest.reported.add(key);

const existing = routes.get(prefix);
const existing = routes.get(key);
if (!existing) {
const handle = originWire.receive(prefix, route);
routes.set(prefix, { handle, reporters: new Map([[interest, route]]) });
routes.set(key, { prefix, handle, reporters: new Map([[interest, route]]) });
void drive(handle, conn);
return;
}
Expand All @@ -109,21 +121,21 @@ export function forwardAnnounced(conn: Session, origin: OriginProducer): void {
existing.reporters.set(interest, route);
// Another request covering the prefix only holds it; the first reporter drives it.
if (joined && existing.reporters.keys().next().value === interest) {
updateReported(existing, prefix, route, event.kind === "restart");
updateReported(existing, route, event.kind === "restart");
}
};

/**
* Bring the handle up to its driving reporter's route: a fresh route for another publisher
* instance, so nothing resolved through the old one is joined again, and an in-place
* instance or epoch, so nothing resolved through the old one is joined again, and an in-place
* update otherwise.
*/
const updateReported = (existing: Reported, prefix: Path.Valid, route: WireRoute, restart: boolean) => {
const updateReported = (existing: Reported, route: WireRoute, restart: boolean) => {
const current = wireOf(existing.handle).info;
if (restart || route.epoch !== current?.epoch) {
if (restart || route.instance !== current?.instance || route.epoch !== current?.epoch) {
// Inserted before the old one leaves, so local readers see one restart rather than
// an end and a start.
const handle = originWire.receive(prefix, route);
const handle = originWire.receive(existing.prefix, route);
existing.handle.close();
existing.handle = handle;
void drive(handle, conn);
Expand All @@ -132,23 +144,23 @@ export function forwardAnnounced(conn: Session, origin: OriginProducer): void {
}
};

/** Stop `interest` reporting `prefix`, which its peer `ended` rather than lost. */
const unreport = (interest: Interest, prefix: Path.Valid, ended = false) => {
interest.reported.delete(prefix);
const existing = routes.get(prefix);
/** Stop `interest` reporting the route `key` names, which its peer `ended` rather than lost. */
const unreport = (interest: Interest, key: Key, ended = false) => {
interest.reported.delete(key);
const existing = routes.get(key);
if (!existing) return;
const driving = existing.reporters.keys().next().value === interest;
if (!existing.reporters.delete(interest)) return;

const next = existing.reporters.values().next();
if (next.done) {
routes.delete(prefix);
routes.delete(key);
if (ended) wireOf(existing.handle).end();
else existing.handle.close();
} else if (driving) {
// The next request takes over driving. Without an instance nothing proves it reports
// the stream the handle serves, so the route restarts rather than stitch two together.
updateReported(existing, prefix, next.value, next.value.instance === undefined);
updateReported(existing, next.value, next.value.instance === undefined);
}
};

Expand Down Expand Up @@ -176,7 +188,7 @@ export function forwardAnnounced(conn: Session, origin: OriginProducer): void {

// Hidden and covering routes are mirrored too; each local reader opts in on its own.
const interest: Interest = {
announced: conn.routes(Path.Pattern.subtree(prefix), { hidden: true, covering: true }),
announced: conn.routes(Path.Pattern.subtree(prefix), { hidden: true, covering: true, claims: true }),
reported: new Set(),
closing: false,
held: new Map(),
Expand Down Expand Up @@ -291,12 +303,17 @@ export function forwardAnnounced(conn: Session, origin: OriginProducer): void {
});
}

/** Answer the requests under a received route by consuming them from the session. */
/**
* Answer the requests under a received route by consuming them from the session, pinned to the
* route's instance: the session may carry another instance's claim at the prefix, which ranks
* apart from this one, and must never be served under this one's identity.
*/
async function drive(handle: Claim, conn: Session): Promise<void> {
const session = wireOf(conn);
try {
for await (const request of handle.requested()) {
request.serve(session.consume(request.path));
// Read per request: a handover may update the handle in place.
request.serve(session.consume(request.path, wireOf(handle).info?.instance));
}
} catch {
handle.close();
Expand Down
4 changes: 2 additions & 2 deletions js/net/src/connection/session.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { GetPromise, Getter } from "@moq/signals";
import type * as announce from "../announce.ts";
import type { Routes } from "../announced.ts";
import type { RouteOptions, Routes } from "../announced.ts";
import type * as Auth from "../auth.ts";
import type * as Path from "../path.ts";
import type { Drain } from "./goaway.ts";
Expand Down Expand Up @@ -60,7 +60,7 @@ export interface Session {
announced(scope?: Path.Pattern, options?: announce.Options): announce.Consumer;

/** Every route change matching `scope`, for code that forwards routes. @internal */
routes(scope?: Path.Pattern, options?: announce.Options): Routes;
routes(scope?: Path.Pattern, options?: RouteOptions): Routes;

/**
* Snapshot the transport's counters, querying it fresh on each call.
Expand Down
Loading