Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a8d6123
chore(quest): claim quest/m2/cluster-routes/switch.md
kixelated Nov 14, 2026
c25b705
feat(net): path router pairs streams per session, bounds holds, scope…
kixelated Nov 14, 2026
2d34910
feat(net)!: lite-07 sessions run the path router
kixelated Nov 14, 2026
730a2d3
Merge main: refused forwarded routes on the path wire
kixelated Nov 14, 2026
ca2b9bf
feat(net)!: js/net speaks the lite-07 path wire
kixelated Nov 14, 2026
13ff34b
fix(net): lite-07 doubts and holds keep real time, and a hold's end r…
kixelated Nov 14, 2026
5b73de2
docs(drafts)!: moq-lite-07 routes by the path rule
kixelated Nov 14, 2026
75270dc
docs(quest): the routes contract describes the path rule as built
kixelated Nov 14, 2026
2806e3b
test(net): the model carries the down-only flag and its export rule
kixelated Nov 14, 2026
8425d99
chore(net): format, and retarget two drill mutations at the path-rout…
kixelated Nov 14, 2026
74ca656
fix(net): a later session to the next hop takes over among equal routes
kixelated Nov 14, 2026
984ee23
docs(skills): verify-route names the router's session tie-break and a…
kixelated Nov 14, 2026
950c02e
Merge origin/main into quest/m2/cluster-routes/switch
kixelated Nov 14, 2026
79ee4a5
fix(js/net): an ended lite-07 route unindexes itself before its floor…
kixelated Nov 14, 2026
d73ee8a
fix(net): bound what a lite-07 announce stream holds for a slow reader
kixelated Nov 14, 2026
272aa4e
fix(net): a split DEAD still names its hop, and a DEAD's ended routes…
kixelated Nov 14, 2026
10616de
feat(net): a DEAD past one message goes in parts the receiver applies…
kixelated Nov 14, 2026
60c9460
fix(net): isolate a scoped peer's own events, cancel unread claim chu…
kixelated Nov 14, 2026
f2dcad2
Merge origin/main into quest/m2/cluster-routes/switch
kixelated Nov 15, 2026
87e955f
fix(net): keep the node in step with an uncredited DEAD, bound what a…
kixelated Nov 15, 2026
dafc57e
fix(net): a route that ends stops counting whatever DEAD sealed it, a…
kixelated Nov 15, 2026
8b0c53f
fix(net): a held-back claim's release closes with its route's newest …
kixelated Nov 15, 2026
4e8032b
fix(net): read every hop an offer counts, and refuse a path at the ho…
kixelated Nov 15, 2026
63d620f
Merge origin/main into quest/m2/cluster-routes/switch
kixelated Nov 15, 2026
857f2ee
style(net): rustfmt the merge
kixelated Nov 15, 2026
73c74c0
docs(verify-route): move the sync commit to where the switch took in …
kixelated Nov 15, 2026
3277f5e
Merge origin/main into quest/m2/cluster-routes/switch
kixelated Nov 15, 2026
96dd6b3
docs(verify-route): record the merged model's state counts
kixelated Nov 15, 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
12 changes: 0 additions & 12 deletions .cargo/mutants.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,16 @@ exclude_re = [
# The rotation's xorshift step only picks which fresh identity comes next,
# and the guard after it enforces freshness and range.
'replace (\^= with \|=|<< with >>|>> with <<) in Router<N, A>::rotate',
# An index of a neighbor's interest: `carries()` filters each entry again.
'replace Router<N, A>::asked -> Path with Default::default\(\)',
# `full(old) == full(new)` is the same with both sides negated.
'replace >= with < in Router<N, A>::route$',
# A larger `differs` set only costs work: it is compared again before use.
'replace && with \|\| in Heard<A>::compare$',
# The test-only `Proof::LEN`.
'proof\.rs:\d+:\d+: replace \+ with \*$',
# The stale-view shortcut only saves work: without it, or at equal revisions,
# where both views hold the same claims, the full merge changes nothing.
'replace (> with (==|>=) in View<A>::outdates|View<A>::outdates -> bool with false)$',
# Dropping the cached context more often makes the next pass full, which
# reaches the same result.
':\d+:(25|38): replace && with \|\| in Router<N, A>::recompute$',
# A claim an answering certifier certifies is always in the merged view.
':\d+:35: replace && with \|\| in Router<N, A>::meets$',
# A new stream's first batch either flips its certifier's answer, which marks
# every claim, or reaches the reader only through the merge, which marks its own
# changes; marking all only reorders independent changes in a forwarded batch.
':\d+:32: replace != with == in Router<N, A>::batch$',
# At an equal metric both arms assign the same distance.
'replace < with <= in Router<N, A>::record$',
# The full presentation of a stream the interest misses is empty, and a full
# presentation equals the incremental one.
'replace match guard (!self\.meets\(id, ctx, watch\)|!dirty\.all) with false in Router<N, A>::advertise$',
Expand Down
28 changes: 16 additions & 12 deletions .claude/skills/verify-route/SKILL.md

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions doc/bin/relay/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ carry it: natively on moq-lite up to moq-lite-06, and via the

moq-lite-07-wip carries the list once per publishing node instead of once per
broadcast. Each publishing node declares a random routing identity, and relays
run a distance-vector route to it, loop-free by Babel's feasibility condition,
so every claim of one origin shares that route. The route names the relays it
crossed, and a relay never uses one that names itself.
keep a route to it per prefix, which every claim of that origin under the prefix
shares. The route names each relay it crossed and the session it crossed on, and
a relay never uses one that names itself. A relay that loses a session names it
to its neighbours, so every route through it is dropped at once, and a relay left
without a route holds its claims, unavailable, for up to ten seconds while one may
return.
The first relay a request reaches picks the origin node, by a hash of the path
and the node's identity that every relay computes alike, and names it on the
request so later hops follow their own route to that node. A relay running both
Expand Down
336 changes: 220 additions & 116 deletions drafts/draft-lcurley-moq-lite.md

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions js/net/src/connection/forward.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,17 @@ class FakeSession {
/** Called as the forwarder closes a request, before its stream can wind down. */
onClose?: () => void;

/** Whether a lite-07 claim of `node` at `at` serves `path` beneath it: the session's floors. */
covering?: (node: bigint, at: Path.Valid, path: Path.Valid) => boolean;

closed: Promise<Error | null>;
#die!: (reason: Error | null) => void;

/** `exclusive` stands in for a peer that refuses overlapping requests. */
constructor({ exclusive = false } = {}) {
registerWire(this, {
consume: (path, instance) => this.consume(path, instance),
covers: (node, at, path) => this.covering?.(node, at, path) ?? true,
exclusive,
leave: () => {},
auth: new AuthSession({ peerGrant: { publish: new Path.Patterns(), subscribe: new Path.Patterns() } }),
Expand Down Expand Up @@ -212,6 +216,43 @@ test("the origin holds each origin node's claim at a prefix", async () => {
origin.close();
});

// Two streams carry a lite-07 node's claims, and the newer floor, on the narrower one, presents
// nothing at live/x: the node's claim at live is older knowledge there. A request for live/x skips
// it, per request, for another node's claim at live of another instance. Mirrors `covering` in
// rs/moq-net.
test("the origin skips a claim above a newer floor's region", async () => {
const origin = new OriginProducer();
const session = new FakeSession();
forwardAnnounced(session.session, origin);
const a = Instance.parse("a");
const b = Instance.parse("b");
const NODE_A = 0x7an;
const NODE_B = 0x8bn;
const live = origin.routes(Path.Pattern.subtree(Path.from("live")));
await settle();
start(session.stream("live/**"), "live", { ...WireRoute.default, instance: a, node: NODE_A });
start(session.stream("live/**"), "live", { ...WireRoute.default, instance: b, node: NODE_B, cost: 5n });
session.stream("live/**").synced();
await settle();
const x = Path.from("live/x");
session.covering = (node, at, path) => !(node === NODE_A && at === Path.from("live") && Path.hasPrefix(x, path));

const request = origin.request(x);
await settle();
expect(request.active.peek()).toBeDefined();
expect(session.pins).toEqual([b]);
// Elsewhere under live the cheaper claim still serves.
const y = origin.request(Path.from("live/y"));
await settle();
expect(session.pins).toEqual([b, a]);

request.close();
y.close();
live.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 () => {
Expand Down
14 changes: 11 additions & 3 deletions js/net/src/connection/forward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,15 @@ interface Reported {
*/
export function forwardAnnounced(conn: Session, origin: OriginProducer): void {
const originWire = wireOf(origin);
const exclusive = wireOf(conn).exclusive;
const session = wireOf(conn);
const exclusive = session.exclusive;
// A lite-07 claim covers only what its origin node's newest floor on the session still
// certifies beneath it, which the origin asks per request. Mirrors `covering` in rs/moq-net.
const covering = (prefix: Path.Valid, route: WireRoute) => {
const node = route.node;
if (node === undefined || !session.covers) return undefined;
return (path: Path.Valid) => session.covers?.(node, prefix, path) ?? true;
Comment thread
kixelated marked this conversation as resolved.
Resolved
};
// Reassigned on a downgrade, so the origin stops counting this session as discovering.
// Called through a closure so the session's death always detaches the current one.
let detach = originWire.attach(true);
Expand All @@ -111,7 +119,7 @@ export function forwardAnnounced(conn: Session, origin: OriginProducer): void {

const existing = routes.get(key);
if (!existing) {
const handle = originWire.receive(prefix, route);
const handle = originWire.receive(prefix, route, covering(prefix, route));
routes.set(key, { prefix, handle, reporters: new Map([[interest, route]]) });
void drive(handle, conn);
return;
Expand All @@ -135,7 +143,7 @@ export function forwardAnnounced(conn: Session, origin: OriginProducer): void {
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(existing.prefix, route);
const handle = originWire.receive(existing.prefix, route, covering(existing.prefix, route));
existing.handle.close();
existing.handle = handle;
void drive(handle, conn);
Expand Down
4 changes: 2 additions & 2 deletions js/net/src/consume.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ test("the node serving an instance follows its routes even when another instance
const c = {};
cache.announce(path, a, { ...WireRoute.default, instance: x, node: 1n });
cache.announce(path, b, { ...WireRoute.default, instance: x, node: 2n, cost: 5n });
expect(cache.node(path, x)).toBe(1n);
expect(cache.node(path, x)).toEqual({ node: 1n, depth: 0 });
cache.withdraw(path, a);
cache.announce(path, c, { ...WireRoute.default, instance: Instance.random(), node: 3n });
expect(cache.instance(path).route.node).toBe(3n);
expect(cache.node(path, x)).toBe(2n);
expect(cache.node(path, x)).toEqual({ node: 2n, depth: 0 });
cache.withdraw(path, b);
expect(cache.node(path, x)).toBeUndefined();
});
15 changes: 10 additions & 5 deletions js/net/src/consume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ class Validity {
}

// The route a consume selected: its instance, and the origin node its requests name (lite-07).
type Selection = Served & { readonly route: Pick<WireRoute, "instance" | "node">; readonly validity?: Validity };
type Selection = Served & {
readonly route: Pick<WireRoute, "instance" | "node" | "depth">;
readonly validity?: Validity;
};

class Blind implements Selection {
readonly identity = {};
Expand Down Expand Up @@ -148,11 +151,13 @@ export class BroadcastCache {
}

/**
* The origin node of the best route now serving `instance` at `path` (lite-07), whichever
* instance wins the path, or undefined when no route names one.
* The publisher node of the best route now serving `instance` at `path` (lite-07), and the
* depth of that route's prefix, whichever instance wins the path, or undefined when no route
* names one.
*/
node(path: Path.Valid, instance: Instance.Valid): bigint | undefined {
return this.pinned(path, instance).route.node;
node(path: Path.Valid, instance: Instance.Valid): { node: bigint; depth: number } | undefined {
const { node, depth } = this.pinned(path, instance).route;
return node === undefined ? undefined : { node, depth: depth ?? 0 };
}

/** Clone the live cached consumer only when it serves the selected instance. */
Expand Down
17 changes: 16 additions & 1 deletion js/net/src/hop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,17 @@ export interface WireRoute {
* see it.
*/
readonly node?: bigint;
/**
* How many leading segments of a requested path make up the prefix of the lite-07 route to
* {@link node}, which every request through it names. Local, as `node` is.
*/
readonly depth?: number;
/**
* The lowest priority of a link on the path of the lite-07 route to {@link node}: higher
* ranks first, after drain and before cost, as routes to one node rank. Unset ranks as 0, the
* priority of a link no one set. Local, as `node` is.
*/
readonly priority?: number;
/** See {@link RouteInfo.rtt}. */
readonly rtt?: Duration;
}
Expand All @@ -210,6 +221,8 @@ export const WireRoute = {
draining: route.draining,
available: route.available,
node: route.node,
depth: route.depth,
priority: route.priority,
rtt: route.rtt,
};
},
Expand All @@ -229,7 +242,7 @@ export function isAnonymous(route: WireRoute): boolean {

/**
* Whether two routes name the same instance, epoch, hop chain, cost, auth, drain state,
* availability, origin node, and RTT.
* availability, origin node, route depth and priority, and RTT.
*
* @internal
*/
Expand All @@ -244,6 +257,8 @@ export function routesEqual(a: WireRoute | undefined, b: WireRoute | undefined):
(a.draining ?? false) === (b.draining ?? false) &&
(a.available ?? true) === (b.available ?? true) &&
a.node === b.node &&
a.depth === b.depth &&
(a.priority ?? 0) === (b.priority ?? 0) &&
(a.rtt === b.rtt || (!!a.rtt && !!b.rtt && a.rtt.eq(b.rtt))) &&
a.hops.length === b.hops.length &&
a.hops.every((hop, i) => hop === b.hops[i])
Expand Down
3 changes: 2 additions & 1 deletion js/net/src/integers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,11 @@ for (const version of [Lite.DRAFT_06, Lite.DRAFT_07]) {
const body = await Writer.collect(version, async (w) => {
await w.string("room");
if (version === Lite.DRAFT_07) {
// No pinned instance: empty and unminted, and no origin node.
// No pinned instance: empty and unminted, and no origin node nor route depth.
await w.u53(0);
await w.bool(false);
await w.u62(0n);
await w.u53(0);
}
await w.string("video");
await w.u8(0);
Expand Down
4 changes: 3 additions & 1 deletion js/net/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1502,12 +1502,14 @@ export class Epochs {

/**
* Prefer a route that is neither draining (a peer that sent GOAWAY) nor unavailable (held),
* which rank below every other, then identified publishers, then lower static cost.
* which rank below every other, then the highest priority on its path, then identified
* publishers, then lower static cost.
*/
export function compareRoutes(a: WireRoute, b: WireRoute): number {
const last = (route: WireRoute) => Number((route.draining ?? false) || route.available === false);
return (
last(a) - last(b) ||
(b.priority ?? 0) - (a.priority ?? 0) ||
Number(a.node === undefined && isAnonymous(a)) - Number(b.node === undefined && isAnonymous(b)) ||
(a.cost < b.cost ? -1 : a.cost > b.cost ? 1 : 0)
);
Expand Down
Loading