From 48a6c1a872e39734e3d148b100e032e38c516879 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 9 Nov 2026 01:38:29 -0800 Subject: [PATCH 1/5] chore(quest): claim quest/m1/mixed-version-ring.md Quest-Claim: b510eb5eacc2c9fc From 3cbf67c39eab22684d6d6e58d55bb88e7a930a7c Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 9 Nov 2026 02:10:12 -0800 Subject: [PATCH 2/5] feat(moq-net): carry the lite-06 chain through lite-07 so a withdrawn claim ends in a mixed ring Co-Authored-By: Claude Opus 5.5 --- doc/bin/relay/cluster.md | 9 +- drafts/draft-lcurley-moq-lite.md | 23 +++- quest/m1/README.md | 1 - quest/m1/mixed-version-ring.md | 92 -------------- quest/m2/cluster-routing/routes/js.md | 3 +- quest/m2/lite07-finalize.md | 7 +- rs/moq-net/src/client.rs | 2 + rs/moq-net/src/lite/announce.rs | 119 ++++++++++++++---- rs/moq-net/src/lite/publisher.rs | 2 + rs/moq-net/src/lite/publisher/routed.rs | 30 ++++- rs/moq-net/src/lite/session.rs | 2 + rs/moq-net/src/lite/setup.rs | 44 +++++++ rs/moq-net/src/lite/subscriber.rs | 19 +-- rs/moq-net/src/lite/subscriber/routed.rs | 45 ++++--- rs/moq-net/src/model/origin.rs | 3 + rs/moq-net/src/route/node.rs | 6 + rs/moq-net/src/server.rs | 3 + rs/moq-net/tests/integration/mesh_withdraw.rs | 86 +++++++++++++ 18 files changed, 339 insertions(+), 157 deletions(-) delete mode 100644 quest/m1/mixed-version-ring.md diff --git a/doc/bin/relay/cluster.md b/doc/bin/relay/cluster.md index 7032c7ddc02..d82613e1946 100644 --- a/doc/bin/relay/cluster.md +++ b/doc/bin/relay/cluster.md @@ -23,10 +23,11 @@ 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 versions translates: a moq-lite-06 peer's routes enter the route layer as the -relay's own claims, and lite-07 routes reach a moq-lite-06 peer as a hop list -that starts at their origin node. A relay drops a moq-lite-06 route whose hop -list names its own routing identity, since that is one of its claims coming -back. +relay's own claims, keeping their hop list, which lite-07 carries alongside +them. A lite-07 route reaches a moq-lite-06 peer as that hop list followed by +its origin node. A relay drops a route whose hop list names it, by its hop or +its routing identity, since that is one of its claims coming back, so a +rolling upgrade's mix of versions ends a withdrawn broadcast everywhere. A track from a moq-transport publisher keeps its Object IDs, object properties, and END\_OF\_GROUP status objects across a moq-lite-07 link, since relays diff --git a/drafts/draft-lcurley-moq-lite.md b/drafts/draft-lcurley-moq-lite.md index fb445513146..0653dfbdfef 100644 --- a/drafts/draft-lcurley-moq-lite.md +++ b/drafts/draft-lcurley-moq-lite.md @@ -972,6 +972,8 @@ The following Setup Parameters are defined: |------|----------------|-------------| | 0x8 | Route Key | Proof (..) | |------|----------------|-------------| +| 0x9 | Lite-06 Chain | (empty) | +|------|----------------|-------------| ### Probe Parameter {#probe-parameter} The Probe Parameter advertises the sender's capability level when acting as a publisher on a [Probe Stream](#probe). @@ -1064,6 +1066,11 @@ A receiver that relies on the key MUST verify the signature first, closing the s A relay MUST NOT forward it. +### Lite-06 Chain Parameter {#lite06-chain-parameter} +The Lite-06 Chain Parameter says the sender reads the Lite-06 Chain on ANNOUNCE_START, ANNOUNCE_UPDATE, and ANNOUNCE_RESTART (see [ANNOUNCE_START](#announce-start)). +It is a temporary extension for relays that also peer over moq-lite-06, and the next version removes it. +The Parameter Value MUST be empty; a receiver MUST close the session with a PROTOCOL_VIOLATION otherwise. + ## ANNOUNCE_REQUEST {#announce-request} A subscriber sends an ANNOUNCE_REQUEST message to indicate it wants to receive the claims, and the routes they travel under, for any broadcasts with a path that starts with the requested prefix. @@ -1258,6 +1265,7 @@ ANNOUNCE_START Message { Instance (b), Epoch (i), Announce Cost (i), + [Lite-06 Chain (..)], } ~~~ @@ -1290,6 +1298,12 @@ Only an ANNOUNCE_RESTART changes the Instance or the Epoch; ANNOUNCE_UPDATE neve The origin's price for this prefix, in the units of the [Cost Parameter](#cost-parameter): 0 for content it already produces, larger for a standby that starts work on demand. A relay forwards it unchanged; the cost of a path through the claim is the Announce Cost plus the route's metric. +**Lite-06 Chain**: +The moq-lite-06 Hop ID list a claim arrived with where its origin node learned it over moq-lite-06, encoded as that list: a count, then each Hop ID. +A publisher sends it, as the message's last field, only to a peer that sent the [Lite-06 Chain Parameter](#lite06-chain-parameter), and only when the claim has one; a received empty chain is a PROTOCOL_VIOLATION. +A relay forwards it unchanged, and translating the claim for a moq-lite-06 peer sends it followed by a Hop ID standing for the claim's origin node. +A node MUST NOT serve a claim whose chain names itself, by its own Hop ID or one standing for its Node ID, or whose translated chain would exceed its hop limit. + ## ANNOUNCE_END {#announce-end} A publisher sends an ANNOUNCE_END message when the origin withdrew a claim, referencing its Announce ID. @@ -1325,6 +1339,7 @@ ANNOUNCE_UPDATE Message { Message Length (i) Announce ID (i), Announce Cost (i), + [Lite-06 Chain (..)], } ~~~ @@ -1334,8 +1349,8 @@ Set to 0x2 to indicate an ANNOUNCE_UPDATE message. **Announce ID**: As defined for [ANNOUNCE_END](#announce-end). -**Announce Cost**: -As defined for [ANNOUNCE_START](#announce-start), replacing the claim's. +**Announce Cost** and **Lite-06 Chain**: +As defined for [ANNOUNCE_START](#announce-start), replacing the claim's; an absent chain replaces it with none. ## ANNOUNCE_RESTART {#announce-restart} @@ -1352,6 +1367,7 @@ ANNOUNCE_RESTART Message { Instance (b), Epoch (i), Announce Cost (i), + [Lite-06 Chain (..)], } ~~~ @@ -1361,7 +1377,7 @@ Set to 0x3 to indicate an ANNOUNCE_RESTART message. **Announce ID**: As defined for [ANNOUNCE_END](#announce-end). -**Instance**, **Epoch**, and **Announce Cost**: +**Instance**, **Epoch**, **Announce Cost**, and **Lite-06 Chain**: As defined for [ANNOUNCE_START](#announce-start), replacing the claim's. ## ANNOUNCE_FLOOR {#announce-floor} @@ -2199,6 +2215,7 @@ The `Message Length` describes the payload size on the wire. - The Cost parameter must be at least 1. - Replaced the shortest-path, Hop ID, Instance Hash, and Chain Hash tie-breaks with the local priority of the route's session, the Announce Cost plus the route's metric, and a Rendezvous Hash of the requested path and the origin's Node ID. - Removed the standby-ordering deployment requirements on Route Cost seeds and bounds. +- Added the temporary Lite-06 Chain Setup Parameter (0x9) and a trailing Lite-06 Chain on ANNOUNCE_START, ANNOUNCE_UPDATE, and ANNOUNCE_RESTART: the moq-lite-06 Hop ID list of a claim learned over moq-lite-06, which a node drops when it names that node. ### Tracks {#changelog-07-tracks} diff --git a/quest/m1/README.md b/quest/m1/README.md index df79db13c63..b5e3ad4a75d 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -33,7 +33,6 @@ moves what remains of them once their claims merge. - [Drop set](/quest/m1/drop-set.md) - the drop set's track and cursor runs are billed to the cache pool, so fragmenting drops costs what the pool holds; eviction folds final runs or ends the cursor with `TooFarBehind` - [Routing guide](/quest/m1/routing-guide.md) - concepts and practical outbound federation setup -- [A withdrawn claim ends across mixed lite-06 and lite-07 relays](/quest/m1/mixed-version-ring.md) - lite-07 carries a temporary lite-06 compatibility chain, so a rolling upgrade's withdrawn broadcast stops circling - [A reader on a failed copy continues on the held re-offer](/quest/m1/copy-recover.md) - a live reader keeps a group whose copy fails by continuing on the same track's re-offer at the same frame - [Group errors are cached by kind](/quest/m1/group-error-cache.md) - permanent group errors bind every reader, retryable ones are kept only for a bounded time, and a live SUBSCRIBE_DROP or FETCH answered `Old` no longer caches it for good - [The overcommitted receive-window cells run again](/quest/m1/receive-windows-evicted.md) - `benchmark_receive_windows` measures its 256-stream and 4 MiB-frame cells again, reporting delivered frames and evictions instead of stalling diff --git a/quest/m1/mixed-version-ring.md b/quest/m1/mixed-version-ring.md deleted file mode 100644 index 34aa381e1e0..00000000000 --- a/quest/m1/mixed-version-ring.md +++ /dev/null @@ -1,92 +0,0 @@ -# [L] A withdrawn claim ends across mixed lite-06 and lite-07 relays - -## Goal - -After a publisher leaves, its broadcast ends at every relay within a bounded -number of route updates, for any mix of moq-lite-06 and moq-lite-07 relay -links. That includes a rolling upgrade, where one lite-06 relay links to -three or more lite-07 relays. Today such a claim circles forever after its -withdrawal, and every subscriber sees a Restart on every lap. - -Not here: relay links over moq-transport. moq-transport is supported for -clients, not relays (decided 2026-11-08), so its anonymous chains stay out of -scope. - -## Plan - -Root cause, reproduced 2026-11-08 on main at `8065e7148f`. The loop has been -on main since [moq-dev/moq#8023](https://github.com/moq-dev/moq/pull/8023), -which added the lite-06 translation and its single-link reflection check: - -- A route learned over lite-06 becomes the translating relay's own claim - (`OwnClaims::apply` in `rs/moq-net/src/model/origin.rs`, the `learned` - flag), and its lite-06 hop chain is dropped there. -- Translating a lite-07 route back out to lite-06 sends only its origin - node's hop (`hops()` in `rs/moq-net/src/lite/subscriber/routed.rs`). -- So `Subscriber::chain` (`rs/moq-net/src/lite/subscriber.rs`) only catches a - claim that went out and came back across one lite-06 segment. Once a claim - crosses two lite-06 to lite-07 boundaries, no relay sees its own hop again. - In A-07-B-06-C-07-D-06-A, B and D keep re-originating each other's copy. -- Minting a `~` instance per lite-06 hop only turns each lap into a Restart. - It does not cause the loop, and the rising cost saturates only near - `MAX_COST`, so in practice the loop never ends. - -Announcing settles in every topology probed; only withdrawal loops. It loops -in a ring with two lite-06 links separated by lite-07 links (three behave the -same), and when one lite-06 relay links to three or more lite-07 relays, -wherever the publisher sits. A 07-06-06 triangle, a ring with adjacent lite-06 -links, and an old relay with two lite-07 neighbours all settle. - -Decided 2026-11-08 (maintainer, /quest-plan): - -- ✅ Carry the lite-06 chain through lite-07, as a crate-private chain plus a - lite-07-wip compatibility extension and field. Rejected: a cost or hop - ceiling with no wire change, which still circles for hundreds to thousands - of laps and is an arbitrary constant; never forwarding a lite-06-learned - claim to another lite-07 relay, which breaks old-new-new chains mid-upgrade; - documenting mixed rings as unsupported, which a rolling upgrade cannot - avoid. A claim learned over lite-06 keeps that chain. lite-07 - ANNOUNCE_START, ANNOUNCE_RESTART and ANNOUNCE_UPDATE carry it, empty for a - native claim. Translating back to lite-06 sends the chain plus this node's - hop. Both receive sides drop a chain that names them: lite-06 in `chain()`, - and lite-07 when it serves the route. `max_hops` then bounds the total - across islands, and the existing route-hop check becomes one case of it. -- ✅ It is temporary: the draft and code mark the extension and field as - lite-06 compatibility, and the lite-07 to lite-08 migration deletes them. - No public API carries the chain. Keep it apart from the minted flag that - `quest/m2/instance-provenance.md` plans (on - [moq-dev/moq#8266](https://github.com/moq-dev/moq/pull/8266)'s branch - until it merges), even though a non-empty chain marks exactly the - announcements that flag would: the flag also covers moq-transport routes - and outlives lite-06. -- ✅ m1 (rejected: m0, m2). lite-07 is opt-in `-wip`, so nothing published - breaks, and the field must exist before - [lite-07 is finalized](/quest/m2/lite07-finalize.md). - -A throwaway prototype, with a process-wide table standing in for the wire -field, made every looping topology settle in 4 to 13 events after withdrawal. -All integration and lib tests still passed. It needed the lite-07-side drop, -or it tripped `origin.rs`'s "announce called with a looping hop chain" -debug assertion. A chain change on an open session also needs -ANNOUNCE_UPDATE to carry the field. - -Tests, in `rs/moq-net/tests/integration/mesh_withdraw.rs` beside -`mixed_version_ring_withdraw_retracts`. Each announces at one relay, checks -that every relay sees it start, withdraws it, and checks that every relay -sees it end: - -- The ring A-07-B-06-C-07-D-06-A. -- A rolling upgrade with the publisher at the lite-06 relay, linked to each - relay of a three-relay lite-07 full mesh. This one hung 12 of 12 runs, so - it is the reliable gate. -- The same rolling upgrade with the publisher at a lite-07 relay. It hung 11 - of 12 runs, because route identities are random and tie-breaks hash them. - Make it deterministic or drop it. - -The js/net lite-07 port in [routes/js.md](/quest/m2/cluster-routing/routes/js.md) -decodes the field; JS translates nothing, so it keeps no chain. - -## Related - -- [Route session integration](/quest/m2/cluster-routing/routes/session.md) - makes `Hops` crate-private behind a chain type, which this fills from a third source, and merges the lite-06 and lite-07 identities, which folds the two receive checks together -- [Routes acceptance](/quest/m2/cluster-routing/routes/acceptance.md) - these tests are its kind of fixture, a stale neighbour unable to revive an ended broadcast diff --git a/quest/m2/cluster-routing/routes/js.md b/quest/m2/cluster-routing/routes/js.md index cd01f10c22e..44d06197e34 100644 --- a/quest/m2/cluster-routing/routes/js.md +++ b/quest/m2/cluster-routing/routes/js.md @@ -18,7 +18,7 @@ Decided 2026-10-27 (maintainer), from the cheapest one; fix it with the route-selection rework here. - Feed the availability API from [Announcement availability](/quest/m2/cluster-routing/routes/availability.md). - Rust/JS interop covers the route messages, the floor marker, and the echo. -- Decode the temporary lite-06 compatibility chain that lite-07 announcements carry ([mixed-version ring](/quest/m1/mixed-version-ring.md)). JS translates nothing, so it keeps no chain. +- Leave the temporary Lite-06 Chain Setup Parameter unsent: JS translates nothing, so it keeps no chain, and a Rust peer sends the chain only to a peer that offers it. - Restore the native JS lite-07 lanes. Decided 2026-11-06 (maintainer, /quest-complete on [moq-dev/moq#8023](https://github.com/moq-dev/moq/pull/8023)), asked how to handle the in-tree lanes running JS on lite-07-wip once the @@ -43,7 +43,6 @@ the cheapest one; fix it with the route-selection rework here. ## Required - [Announcement availability](/quest/m2/cluster-routing/routes/availability.md) - the API this feeds -- [Mixed-version ring](/quest/m1/mixed-version-ring.md) - defines the compatibility chain field this decodes ## Related diff --git a/quest/m2/lite07-finalize.md b/quest/m2/lite07-finalize.md index 3c443093591..f8e56bf0143 100644 --- a/quest/m2/lite07-finalize.md +++ b/quest/m2/lite07-finalize.md @@ -28,9 +28,9 @@ The route layer of [Cluster routing](/quest/m2/cluster-routing/README.md) (ROUTE_START/UPDATE/END, path-less ANNOUNCE, the native hop list dropped) lands in lite-07, decided 2026-10-05. That removes lite-07's `Hop Base`/`Hop Keep` announce compression along with the hop list, and moq.pro's lite-07 rollout -has to plan for a lite-07 without native hop lists; only the temporary lite-06 -compatibility chain from [Mixed-version ring](/quest/m1/mixed-version-ring.md) -rides announcements until the lite-07 to lite-08 migration. Only +has to plan for a lite-07 without native hop lists; only the temporary Lite-06 +Chain, negotiated by its Setup Parameter, rides announcements until the lite-07 +to lite-08 migration. Only [Routes and announces](/quest/m2/cluster-routing/routes/README.md) gates the cut, not the later federation/P2P integrations. Decided 2026-10-13: routes now owns the tier/partition correctness tests, so they run before the cut. Peer @@ -127,7 +127,6 @@ whose lite-07 encoding [lite-07 by start](/quest/m2/time-addressing/lite07.md) c - [A group a subscriber gives up on is always reported](/quest/m2/group-drops.md) - may add SUBSCRIBE_DROP for a stopped group; leaves this list if it takes the no-wire path - [Delete the old start bookkeeping](/quest/m2/subscribe-ranges/start-bookkeeping.md) - may change START per update on lite-07 - [Minted instances are a typed flag](/quest/m2/instance-provenance.md) - lite-07 carries an explicit minted flag beside each instance instead of the `~` prefix -- [A withdrawn claim ends across mixed lite-06 and lite-07 relays](/quest/m1/mixed-version-ring.md) - lite-07 announcements carry a temporary lite-06 compatibility chain ## Related diff --git a/rs/moq-net/src/client.rs b/rs/moq-net/src/client.rs index 6f60cc4f4df..28a854715ad 100644 --- a/rs/moq-net/src/client.rs +++ b/rs/moq-net/src/client.rs @@ -331,6 +331,8 @@ impl Client { implementation: self.implementation(), // Filled by `lite::start` from the attached origin handles. route_key: None, + // Filled by `lite::start` from the version. + lite06_chain: false, } } else { lite::Setup::default() diff --git a/rs/moq-net/src/lite/announce.rs b/rs/moq-net/src/lite/announce.rs index 417a7524c02..8df68b3e5a8 100644 --- a/rs/moq-net/src/lite/announce.rs +++ b/rs/moq-net/src/lite/announce.rs @@ -55,8 +55,10 @@ pub fn update_supported(version: Version) -> bool { /// The path is as it appears on the wire: on lite-07 it may name a base announcement, /// resolved against the stream's history by [`AnnounceDecoder`](super::AnnounceDecoder). /// -/// Lite-07 names the route each claim travels under in place of a hop chain, so `hops` -/// must be empty there and `route` must be 0 on every earlier version. +/// Lite-07 names the route each claim travels under in place of a hop chain, and `route` +/// must be 0 on every earlier version. There `hops` is the Lite-06 Chain instead: the +/// chain of a claim learned over moq-lite-06, empty for every other claim, and sent only +/// to a peer that offered the Lite-06 Chain Setup Parameter. #[derive(Clone, Debug, PartialEq, Eq)] pub enum AnnounceBroadcast { /// ANNOUNCE_START (lite-06) / active (older): a broadcast is now available. @@ -88,6 +90,7 @@ pub enum AnnounceBroadcast { instance: Option, epoch: u64, cost: Cost, + hops: Hops, }, /// An unknown lite-06+ announce type. The length-prefixed body was skipped so /// the stream stays up; it does not assign an announce id. @@ -216,16 +219,15 @@ fn decode_route_id(r: &mut Decoder<'_>, version: Version) -> Result, version: Version, hops: &Hops) -> Result<(), EncodeError> { match version.has_routes() { - true if !hops.is_empty() => Err(EncodeError::InvalidState), true => Ok(()), false => hops.encode(w, version), } } -/// Decode a lite-06+ announcement's hop chain, empty on lite-07. +/// Decode a lite-06 announcement's hop chain, empty on lite-07. fn decode_chain(r: &mut Decoder<'_>, version: Version) -> Result { match version.has_routes() { true => Ok(Hops::default()), @@ -233,6 +235,28 @@ fn decode_chain(r: &mut Decoder<'_>, version: Version) -> Result, version: Version, hops: &Hops) -> Result<(), EncodeError> { + match version.has_routes() && !hops.is_empty() { + true => hops.encode(w, version), + false => Ok(()), + } +} + +/// Decode lite-07's trailing Lite-06 Chain: present only when bytes remain, and never +/// empty, so an empty chain has one spelling. +fn decode_lite06_chain(r: &mut Decoder<'_>, version: Version) -> Result { + if !version.has_routes() || r.is_empty() { + return Ok(Hops::default()); + } + let hops = Hops::decode(r, version)?; + match hops.is_empty() { + true => Err(DecodeError::InvalidValue), + false => Ok(hops), + } +} + impl Encode for Cost { fn encode(&self, w: &mut Encoder<'_>, version: Version) -> Result<(), EncodeError> { if !version.has_route_cost() { @@ -310,22 +334,26 @@ impl Encode for AnnounceBroadcast { super::instance::encode_route(w, version, instance.as_ref(), *epoch)?; encode_chain(w, version, hops)?; cost.encode(w, version)?; + encode_lite06_chain(w, version, hops)?; } Self::EndedId { id } => w.varint(*id)?, Self::Update { id, hops, cost } => { w.varint(*id)?; encode_chain(w, version, hops)?; cost.encode(w, version)?; + encode_lite06_chain(w, version, hops)?; } Self::Restart { id, instance, epoch, cost, + hops, } => { w.varint(*id)?; super::instance::encode_route(w, version, instance.as_ref(), *epoch)?; cost.encode(w, version)?; + encode_lite06_chain(w, version, hops)?; } Self::Synced => {} Self::RouteStart { node, advert } => { @@ -410,22 +438,35 @@ impl<'a> Decode<'a, Version> for AnnounceBroadcast { let suffix = PathRef::decode(&mut body, version)?; let route = decode_route_id(&mut body, version)?; let (instance, epoch) = super::instance::decode_route(&mut body, version)?; + let hops = decode_chain(&mut body, version)?; + let cost = Cost::decode(&mut body, version)?; Self::Active { suffix, route, instance, epoch, - hops: decode_chain(&mut body, version)?, - cost: Cost::decode(&mut body, version)?, + hops: match version.has_routes() { + true => decode_lite06_chain(&mut body, version)?, + false => hops, + }, + cost, } } SYNCED if version.has_synced() => Self::Synced, ANNOUNCE_END => Self::EndedId { id: body.varint()? }, - ANNOUNCE_UPDATE => Self::Update { - id: body.varint()?, - hops: decode_chain(&mut body, version)?, - cost: Cost::decode(&mut body, version)?, - }, + ANNOUNCE_UPDATE => { + let id = body.varint()?; + let hops = decode_chain(&mut body, version)?; + let cost = Cost::decode(&mut body, version)?; + Self::Update { + id, + hops: match version.has_routes() { + true => decode_lite06_chain(&mut body, version)?, + false => hops, + }, + cost, + } + } ANNOUNCE_RESTART if version.has_announce_restart() => { let id = body.varint()?; let (instance, epoch) = super::instance::decode_route(&mut body, version)?; @@ -434,6 +475,7 @@ impl<'a> Decode<'a, Version> for AnnounceBroadcast { instance, epoch, cost: Cost::decode(&mut body, version)?, + hops: decode_lite06_chain(&mut body, version)?, } } ROUTE_START if version.has_routes() => { @@ -1048,6 +1090,7 @@ mod tests { instance: Some(Instance::random()), epoch, cost, + hops: Hops::default(), }; assert_eq!(broadcast_round_trip(&restart, Version::Lite07), restart); } @@ -1094,36 +1137,61 @@ mod tests { instance: Some("a".parse().unwrap()), epoch: 5, cost: Cost::new(6), + hops: Hops::default(), }), [3, 5, 7, 1, b'a', 5, 6] ); } - /// Lite-07 names a claim's route instead of its hop chain, so a chain is refused there. + /// Lite-07 carries a lite-06 chain after the cost, only when it is not empty, so an + /// explicitly empty one is refused. #[test] - fn lite07_refuses_a_hop_chain() { + fn lite07_carries_a_trailing_lite06_chain() { let mut hops = Hops::new(); hops.push(Hop::new(7).unwrap()).unwrap(); - let refused = [ + hops.push(Hop::new(9).unwrap()).unwrap(); + let encode = |msg: &AnnounceBroadcast| { + let mut buf = Vec::new(); + msg.encode(&mut Encoder::new(&mut buf, Version::Lite07.into()), Version::Lite07) + .unwrap(); + buf + }; + let msgs = [ AnnounceBroadcast::Active { - route: 0, + route: 3, instance: Some("a".parse().unwrap()), - epoch: 0, - suffix: PathRef::literal(Path::from_static("cam")), + epoch: 5, + suffix: PathRef::literal(Path::from_static("c")), hops: hops.clone(), - cost: Cost::default(), + cost: Cost::new(6), }, AnnounceBroadcast::Update { - id: 0, + id: 7, + hops: hops.clone(), + cost: Cost::new(6), + }, + AnnounceBroadcast::Restart { + id: 7, + instance: Some("a".parse().unwrap()), + epoch: 5, + cost: Cost::new(6), hops, - cost: Cost::default(), }, ]; - for msg in refused { - let mut buf = Vec::new(); - let res = msg.encode(&mut Encoder::new(&mut buf, Version::Lite07.into()), Version::Lite07); - assert!(matches!(res, Err(EncodeError::InvalidState)), "{msg:?}"); + let layouts: [&[u8]; 3] = [ + &[0, 12, 0, 0, 1, b'c', 3, 1, b'a', 5, 6, 2, 7, 9], + &[2, 5, 7, 6, 2, 7, 9], + &[3, 8, 7, 1, b'a', 5, 6, 2, 7, 9], + ]; + for (msg, layout) in msgs.iter().zip(layouts) { + assert_eq!(encode(msg), layout, "{msg:?}"); + assert_eq!(broadcast_round_trip(msg, Version::Lite07), *msg); } + + // An ANNOUNCE_UPDATE whose chain is present but empty. + let mut empty: &[u8] = &[2, 3, 7, 6, 0]; + let res = crate::coding::decode_buf(&mut empty, Version::Lite07, |r, v| AnnounceBroadcast::decode(r, v)); + assert!(res.is_err(), "{res:?}"); } /// Only lite-07 carries a Route ID: a non-zero one has nowhere to go earlier, and an @@ -1154,6 +1222,7 @@ mod tests { instance: Some("a".parse().unwrap()), epoch: 0, cost: Cost::default(), + hops: Hops::default(), }; let mut buf = Vec::new(); assert!(matches!( diff --git a/rs/moq-net/src/lite/publisher.rs b/rs/moq-net/src/lite/publisher.rs index ddb380a6fee..7d296c859ca 100644 --- a/rs/moq-net/src/lite/publisher.rs +++ b/rs/moq-net/src/lite/publisher.rs @@ -972,6 +972,7 @@ impl AnnounceServe { hidden, self.shared.auth.clone(), ) + .with_peer_setup(self.shared.peer_setup.clone()) }); // The identity whose routes we filter out. Lite-04/05 carry it per @@ -1402,6 +1403,7 @@ impl AnnounceRun { instance, epoch, cost, + hops: crate::Hops::new(), })?; self.sent(stream)?; } diff --git a/rs/moq-net/src/lite/publisher/routed.rs b/rs/moq-net/src/lite/publisher/routed.rs index cb4faf2cfae..917746540d4 100644 --- a/rs/moq-net/src/lite/publisher/routed.rs +++ b/rs/moq-net/src/lite/publisher/routed.rs @@ -98,6 +98,11 @@ pub(super) struct Answer { phase: Phase, /// Passes before the stream yields, so a peer flooding replies cannot hold the task. budget: kio::coop::Budget, + /// The peer's SETUP, which says whether it reads the Lite-06 Chain. `None` sends no + /// chain. + peer_setup: Option, + /// Whether the claims sent carry their Lite-06 Chain, known once the peer's SETUP is. + chains: bool, } impl Answer { @@ -129,9 +134,17 @@ impl Answer { permit: Default::default(), phase: Phase::Init, budget: kio::coop::Budget::new(32), + peer_setup: None, + chains: false, } } + /// Send each claim's Lite-06 Chain if the peer's SETUP offers to read it. + pub(super) fn with_peer_setup(mut self, peer_setup: lite::PeerSetup) -> Self { + self.peer_setup = Some(peer_setup); + self + } + /// Run the stream until the peer closes it, or `withdrawing` closes it here. pub(super) fn poll( &mut self, @@ -143,6 +156,9 @@ impl Answer { // Start from the grant the setup token earns, so the initial set never // advertises something it would end a moment later. ready!(self.gate.poll_setup_answered(waiter)); + if let Some(peer_setup) = &self.peer_setup { + self.chains = ready!(peer_setup.poll_lite06_chain(waiter)); + } if let Poll::Ready(permit) = self.gate.poll_permit(&mut self.epoch, waiter) { self.permit = permit; } @@ -449,6 +465,11 @@ impl Answer { .filter(|claim| self.shows(&path) && sends(&self.link, claim)) .cloned(); let wire = sent.wire; + // The Lite-06 Chain goes only to a peer that reads it. + let chain = (wanted.as_ref()) + .filter(|_| self.chains) + .map(|claim| claim.chain.clone()) + .unwrap_or_default(); let key = (id, path); match (self.live.get_mut(&key), wanted) { (None, Some(claim)) => { @@ -460,7 +481,7 @@ impl Answer { route: wire, instance: Some(claim.instance.clone()), epoch: claim.epoch, - hops: crate::Hops::new(), + hops: chain, cost: origin::Cost::new(claim.cost), })?; let announce = announce.expect("lite-07 assigns announce ids"); @@ -469,7 +490,7 @@ impl Answer { (Some((announce, held)), Some(claim)) => { let announce = *announce; let restart = held.instance != claim.instance || held.epoch != claim.epoch; - let reprice = held.cost != claim.cost; + let update = held.cost != claim.cost || (self.chains && held.chain != claim.chain); if restart { tracing::debug!(route = %key.1, "restart"); stream.writer.buffer(&Msg::Restart { @@ -477,11 +498,12 @@ impl Answer { instance: Some(claim.instance.clone()), epoch: claim.epoch, cost: origin::Cost::new(claim.cost), + hops: chain, })?; - } else if reprice { + } else if update { stream.writer.buffer(&Msg::Update { id: announce, - hops: crate::Hops::new(), + hops: chain, cost: origin::Cost::new(claim.cost), })?; } diff --git a/rs/moq-net/src/lite/session.rs b/rs/moq-net/src/lite/session.rs index 485e4be4e84..f517ee5d1c9 100644 --- a/rs/moq-net/src/lite/session.rs +++ b/rs/moq-net/src/lite/session.rs @@ -281,6 +281,8 @@ pub fn start(config: Config) -> Result { if let (Some(transcript), Some(key)) = (&transcript, route_key) { our_setup.route_key = Some(transcript.prove(&key, client)); } + // Every lite-07 session reads the chain, so a claim learned over lite-06 keeps it. + our_setup.lite06_chain = version.has_routes(); // What the peer's connection credential earns by default: publishing what our // subscribe half accepts, and subscribing to what our publish half serves. A diff --git a/rs/moq-net/src/lite/setup.rs b/rs/moq-net/src/lite/setup.rs index 1fa835e333e..907a577b146 100644 --- a/rs/moq-net/src/lite/setup.rs +++ b/rs/moq-net/src/lite/setup.rs @@ -21,6 +21,9 @@ const PARAM_IMPLEMENTATION: u64 = 0x6; const PARAM_TOKEN: u64 = 0x7; /// Setup Parameter id for the sender's route key proof (lite-07+). const PARAM_ROUTE_KEY: u64 = 0x8; +/// Setup Parameter id offering to receive the Lite-06 Chain on lite-07 announcements, a +/// lite-06 compatibility extension that the lite-07 to lite-08 migration deletes. +const PARAM_LITE06_CHAIN: u64 = 0x9; /// Setup Parameter id offering the `ietf` extension (draft-lcurley-moq-ietf): "IETF" in ASCII. const PARAM_IETF: u64 = 0x4945_5446; @@ -213,6 +216,9 @@ pub struct Setup { pub implementation: Option, /// Proof that the sender holds its route key, bound to this session (lite-07+). pub route_key: Option, + /// Whether the sender reads the Lite-06 Chain on lite-07 announcements, so the peer + /// sends it the chain of every claim learned over moq-lite-06. Lite-07 only. + pub lite06_chain: bool, } impl std::fmt::Debug for Setup { @@ -231,6 +237,7 @@ impl std::fmt::Debug for Setup { .field("ietf", &self.ietf) .field("implementation", &self.implementation) .field("route_key", &self.route_key) + .field("lite06_chain", &self.lite06_chain) .finish() } } @@ -296,6 +303,12 @@ impl<'a> Message<'a> for Setup { } params.set_bytes(PARAM_ROUTE_KEY, proof.to_bytes()); } + if self.lite06_chain { + if !version.has_routes() { + return Err(EncodeError::Version); + } + params.set_bytes(PARAM_LITE06_CHAIN, Vec::new()); + } params.encode(w, version) } @@ -373,6 +386,11 @@ impl<'a> Message<'a> for ReceivedSetup { } _ => None, }; + let lite06_chain = match params.get_bytes(PARAM_LITE06_CHAIN) { + Some([]) if version.has_routes() => true, + Some(_) if version.has_routes() => return Err(DecodeError::InvalidValue), + _ => false, + }; Ok(Self { role_present: role_code.is_some(), @@ -386,6 +404,7 @@ impl<'a> Message<'a> for ReceivedSetup { ietf, implementation, route_key, + lite06_chain, }, }) } @@ -590,6 +609,12 @@ impl PeerSetup { self.poll_get(waiter, |setup| setup.cost) } + /// Poll whether the peer reads the Lite-06 Chain, waiting until its SETUP arrives. + /// Every lite-07 session offers it, so the peer's offer alone negotiates it. + pub fn poll_lite06_chain(&self, waiter: &kio::Waiter) -> std::task::Poll { + self.poll_get(waiter, |setup| setup.lite06_chain) + } + /// Poll for the [`Hop`](crate::Hop) id the peer declared in its SETUP `Hop` /// parameter. `None` when it declared none: a leaf with no identity worth excluding. pub fn poll_hop(&self, waiter: &kio::Waiter) -> std::task::Poll> { @@ -779,6 +804,25 @@ mod tests { assert!(Setup::decode_slice(&valued, Version::Lite07).is_err()); } + /// The Lite-06 Chain offer is an empty parameter that only lite-07 sends, and lite-06 + /// ignores like any unknown parameter. + #[test] + fn lite06_chain_offer_is_lite07_only() { + let msg = Setup { + lite06_chain: true, + ..Default::default() + }; + let buf = msg.encode_bytes(Version::Lite07).unwrap(); + // Length, one parameter, its ID, and an empty value. + assert_eq!(buf, &[0x03, 0x01, 0x09, 0x00][..]); + assert_eq!(Setup::decode_slice(&buf, Version::Lite07).unwrap().0, msg); + assert!(matches!(msg.encode_bytes(Version::Lite06), Err(EncodeError::Version))); + assert_eq!(Setup::decode_slice(&buf, Version::Lite06).unwrap().0, Setup::default()); + + // A value it does not define is refused. + assert!(Setup::decode_slice(&[0x04, 0x01, 0x09, 0x01, 0x07], Version::Lite07).is_err()); + } + /// Route key proofs are accepted only on lite-07 and must have the fixed wire size. #[test] fn route_key_is_lite07_only() { diff --git a/rs/moq-net/src/lite/subscriber.rs b/rs/moq-net/src/lite/subscriber.rs index 36a1fa515d4..1c94bca35dc 100644 --- a/rs/moq-net/src/lite/subscriber.rs +++ b/rs/moq-net/src/lite/subscriber.rs @@ -633,12 +633,13 @@ impl Subscriber { instance, epoch, cost, + .. } => { // Resolved like an update: the id stays live. let suffix = run.decoder.get(id)?; let path = prefix.join(&suffix)?; run.announced.restart(&path, instance.map(|instance| (instance, epoch))); - // Lite-07 carries no hop chain; its claims name their route instead. + // Only lite-07 restarts, and its claims name their route instead. self.restart_announce( path, crate::Hops::new(), @@ -826,6 +827,14 @@ impl Subscriber { Ok(announced.offer(self, path, route)) } + /// Whether `hops` passed through this node, under its lite-06 hop or the hop its + /// route identity travels as: a moq-lite-07 relay translating this node's claims + /// for a lite-06 peer names the latter. Either way the claim came back, and filed + /// again it would keep itself alive once its source left. + pub(super) fn names_self(&self, hops: &crate::Hops) -> bool { + hops.contains(&self.self_origin) || self.origin.route_hop().is_some_and(|hop| hops.contains(&hop)) + } + /// The full chain of a new or replacing advertisement, or `None` when it is /// reflected or exceeds the origin's hop limit. fn chain(&self, path: &Path, mut hops: crate::Hops, responder_origin: Option) -> Option { @@ -835,14 +844,10 @@ impl Subscriber { Some(responder) => { (responder != crate::Hop::UNKNOWN && hops.contains(&responder)) || hops.push(responder).is_err() - || hops.contains(&self.self_origin) + || self.names_self(&hops) } - None => hops.contains(&self.self_origin), + None => self.names_self(&hops), }; - // A claim of this node's that a moq-lite-07 relay translated for a lite-06 peer - // starts with its route identity's hop instead of this origin's. Filed again as - // an own claim, it would keep itself alive once its source left. - let reflected = reflected || self.origin.route_hop().is_some_and(|hop| hops.contains(&hop)); if reflected { tracing::debug!(route = %self.log_path(path), "dropping reflected announce"); return None; diff --git a/rs/moq-net/src/lite/subscriber/routed.rs b/rs/moq-net/src/lite/subscriber/routed.rs index 28ba6df8f97..d1edec1a5f8 100644 --- a/rs/moq-net/src/lite/subscriber/routed.rs +++ b/rs/moq-net/src/lite/subscriber/routed.rs @@ -219,16 +219,17 @@ impl Routed { route, instance, epoch, + hops, cost, - .. } => { let path = self.path(prefix, &decoder.start(suffix)?)?; - let claim = claim(instance, epoch, cost)?; + let claim = claim(instance, epoch, cost, hops)?; self.start(decoder.last(), route, path, claim)?; } - Msg::Update { id, cost, .. } => { + Msg::Update { id, hops, cost } => { let claim = self.claims.get_mut(&id).ok_or(Error::ProtocolViolation)?; claim.claim.cost = cost.value(); + claim.claim.chain = hops; let change = (claim.path.clone(), Some(claim.claim.clone())); self.pending(id, change)?; } @@ -237,8 +238,9 @@ impl Routed { instance, epoch, cost, + hops, } => { - let fresh = self::claim(instance, epoch, cost)?; + let fresh = self::claim(instance, epoch, cost, hops)?; let claim = self.claims.get_mut(&id).ok_or(Error::ProtocolViolation)?; claim.claim = fresh; let change = (claim.path.clone(), Some(claim.claim.clone())); @@ -422,17 +424,32 @@ impl Routed { if !self.permit.within_limit(path.as_str()) { return; } + let key = (id, claim); + // The chain a claim of `id` travels to a lite-06 peer: the one it crossed into + // lite-07 with, then its origin node, so a relay it reaches back through + // recognizes it. A chain already naming this node looped back across lite-06, + // and the hop limit bounds the whole path across both versions. + let mut hops = served.claim.chain.clone(); + if hops.push(route::node::hop(id)).is_err() + || subscriber.names_self(&hops) + || hops.len() > self.origin.max_hops().get() + { + tracing::debug!(route = %subscriber.log_path(&path), node = id, "dropping looped claim"); + for entry in self.previous.remove(&key).into_iter().chain(self.served.remove(&key)) { + entry.route.dynamic.withdrawn(); + } + return; + } let cost = match self.drained || !served.available { true => crate::origin::Cost::DRAIN, false => crate::origin::Cost::new(served.claim.cost.saturating_add(served.metric)), }; let route = crate::origin::RouteInfo::new() .with_instance(served.claim.instance.clone(), served.claim.epoch) - .with_hops(hops(id)) + .with_hops(hops) .with_cost(cost) .with_via(subscriber.via(None)) .with_node(Some(id)); - let key = (id, claim); if let Some(entry) = self.previous.remove(&key) { self.served.insert(key.clone(), entry); } @@ -512,24 +529,22 @@ fn refused(_: route::Error) -> Error { } /// A claim off the wire. Lite-07 names every claim's instance. -fn claim(instance: Option, epoch: u64, cost: crate::origin::Cost) -> Result { +fn claim( + instance: Option, + epoch: u64, + cost: crate::origin::Cost, + chain: crate::Hops, +) -> Result { Ok(node::Claim { instance: instance.ok_or(Error::ProtocolViolation)?, epoch, cost: cost.value(), upstream: false, learned: false, + chain, }) } -/// The hop chain a claim of `id` travels to a lite-06 peer, so a relay it reaches -/// back through recognizes it. -fn hops(id: route::Id) -> crate::Hops { - let mut hops = crate::Hops::new(); - hops.push(route::node::hop(id)).expect("one hop fits any chain"); - hops -} - /// Whether `permit`'s limit admits the peer's claim at the absolute `path`. /// Whether the node may hold the peer's claim at `path`: the permit's limit admits /// it, and the origin would serve it rather than refuse it (an excluded subtree or mount). diff --git a/rs/moq-net/src/model/origin.rs b/rs/moq-net/src/model/origin.rs index a3998a62048..efe7a3ab3ff 100644 --- a/rs/moq-net/src/model/origin.rs +++ b/rs/moq-net/src/model/origin.rs @@ -3710,6 +3710,9 @@ impl OwnClaims { upstream: false, // Only a route published here has crossed no node. learned: !route.hops.is_empty(), + // Kept, so the claim that crossed into lite-07 here is still recognized + // wherever it leaves for lite-06 again. + chain: route.hops, }; self.best.insert(announce.prefix.clone(), claim); self.feed(announce.prefix); diff --git a/rs/moq-net/src/route/node.rs b/rs/moq-net/src/route/node.rs index ff66f4e7f02..49366b4f520 100644 --- a/rs/moq-net/src/route/node.rs +++ b/rs/moq-net/src/route/node.rs @@ -44,6 +44,11 @@ pub(crate) struct Claim { /// older version: sent only to a peer this node proxies for, so a node that does /// not proxy is never transit. Always unset on a claim off the wire. pub learned: bool, + /// The hop chain of a claim learned over moq-lite-06 or moq-transport, which + /// lite-07 carries as the Lite-06 Chain; empty for a native claim. A relay + /// translating the claim back to lite-06 extends it, so a node the claim reaches + /// again recognizes its own hop and drops it. Deleted with lite-06 compatibility. + pub chain: crate::Hops, } /// A shown claim as the origin serves it through the selected route. @@ -725,6 +730,7 @@ mod tests { cost, upstream: false, learned: false, + chain: crate::Hops::new(), } } diff --git a/rs/moq-net/src/server.rs b/rs/moq-net/src/server.rs index ecbbe1c7c9c..9e7798ef1cd 100644 --- a/rs/moq-net/src/server.rs +++ b/rs/moq-net/src/server.rs @@ -252,6 +252,8 @@ impl Server { implementation: self.implementation(), // Filled by `lite::start` from the attached origin handles. route_key: None, + // Filled by `lite::start` from the version. + lite06_chain: false, } } else { lite::Setup::default() @@ -1719,6 +1721,7 @@ mod tests { ietf: false, implementation: None, route_key: None, + lite06_chain: false, } .encode(&mut crate::coding::Encoder::new(&mut buf, v.into()), v) .unwrap(); diff --git a/rs/moq-net/tests/integration/mesh_withdraw.rs b/rs/moq-net/tests/integration/mesh_withdraw.rs index 1f1bee0d062..3a5e265fddc 100644 --- a/rs/moq-net/tests/integration/mesh_withdraw.rs +++ b/rs/moq-net/tests/integration/mesh_withdraw.rs @@ -682,6 +682,92 @@ async fn mixed_version_ring_withdraw_retracts() { } } +/// Relays peered over `links`, each moq-lite-06 or moq-lite-07: broadcasts announced at +/// relay `publisher` start at every relay, and once withdrawn end at every one. +/// +/// A claim crossing from lite-06 into lite-07 at one relay and back out at another +/// must still name the first, or the two keep re-originating each other's copy after +/// its source left. Such a claim circles at one instant forever, so a regression never +/// settles here and fails on the runner's timeout instead. +/// +/// Whether a topology loops can hang on the route identities, which are random, and +/// selection hashes them with the path, so eight paths each draw their own tie-breaks. +async fn assert_mixed_withdrawal(links: &[(usize, usize, &str)], publisher: usize) { + let n = links.iter().map(|&(a, b, _)| a.max(b) + 1).max().unwrap(); + let relays: Vec<_> = (1..=n as u64).map(produce_origin).collect(); + let mut pairs = Vec::new(); + for &(a, b, version) in links { + pairs.push(peer(version.parse().unwrap(), &relays[a], &relays[b]).await); + } + let mut watched: Vec<_> = relays.iter().map(|relay| watch(relay.consume().routes())).collect(); + + let paths: Vec = (0..8).map(|i| format!("room/{i}")).collect(); + let broadcasts: Vec<_> = (paths.iter()) + .map(|path| { + let broadcast = relays[publisher].route(path, origin::RouteOptions::hidden()).unwrap(); + broadcast.announce().unwrap(); + broadcast + }) + .collect(); + kio::clock::sim::idle().await; + for (relay, watched) in watched.iter_mut().enumerate() { + let mut updates = drain(watched); + for path in &paths { + let kinds = updates.remove(path.as_str()); + let (first, last) = ( + kinds.as_ref().and_then(|k| k.first()), + kinds.as_ref().and_then(|k| k.last()), + ); + assert_eq!(first, Some(&Kind::Start), "relay {relay} {path}: {kinds:?}"); + assert_ne!(last, Some(&Kind::End), "relay {relay} {path}: {kinds:?}"); + } + } + + drop(broadcasts); + kio::clock::sim::idle().await; + for (relay, watched) in watched.iter_mut().enumerate() { + let mut updates = drain(watched); + for path in &paths { + let kinds = updates.remove(path.as_str()); + let last = kinds.as_ref().and_then(|kinds| kinds.last()); + assert_eq!(last, Some(&Kind::End), "relay {relay} {path}: {kinds:?}"); + } + } +} + +const LITE06: &str = "moq-lite-06"; +const LITE07: &str = "moq-lite-07-wip"; + +/// A ring alternating lite-07 and lite-06 links: A-07-B-06-C-07-D-06-A. +#[kio::test] +async fn alternating_version_ring_withdraw_retracts() { + let ring = [(0, 1, LITE07), (1, 2, LITE06), (2, 3, LITE07), (3, 0, LITE06)]; + assert_mixed_withdrawal(&ring, 0).await; +} + +/// A rolling upgrade: one relay still on lite-06, linked to each relay of a lite-07 +/// full mesh. +const ROLLING_UPGRADE: &[(usize, usize, &str)] = &[ + (0, 1, LITE06), + (0, 2, LITE06), + (0, 3, LITE06), + (1, 2, LITE07), + (1, 3, LITE07), + (2, 3, LITE07), +]; + +/// [`ROLLING_UPGRADE`] with the publisher on the lite-06 relay. +#[kio::test] +async fn rolling_upgrade_withdraw_retracts() { + assert_mixed_withdrawal(ROLLING_UPGRADE, 0).await; +} + +/// [`ROLLING_UPGRADE`] with the publisher on a lite-07 relay. +#[kio::test] +async fn rolling_upgrade_from_lite07_withdraw_retracts() { + assert_mixed_withdrawal(ROLLING_UPGRADE, 1).await; +} + /// A relay never carries traffic between two upstreams, across versions too: a /// broadcast it learned from a moq-lite-06 upstream enters the route layer as one of /// its own claims, yet never reaches a moq-lite-07 upstream, while one published at From ca2fabdb77a43e524ba0dab1ccd2aafbd208435c Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Mon, 9 Nov 2026 10:29:47 -0800 Subject: [PATCH 3/5] fix(moq-net): fuzz claims carry an empty chain --- rs/moq-net/src/fuzz.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rs/moq-net/src/fuzz.rs b/rs/moq-net/src/fuzz.rs index f7f8aae9924..a1adae64608 100644 --- a/rs/moq-net/src/fuzz.rs +++ b/rs/moq-net/src/fuzz.rs @@ -537,6 +537,7 @@ impl RouteNode { cost: 0, upstream: false, learned: false, + chain: crate::Hops::new(), } } From 5ee5a84fa2a5bc8c31f4bca7cb2a7ec2e39a7756 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Mon, 9 Nov 2026 11:52:33 -0800 Subject: [PATCH 4/5] fix(moq-net): a lite-07 claim's carried lite-06 chain does not rank it --- rs/moq-net/src/model/origin.rs | 36 ++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/rs/moq-net/src/model/origin.rs b/rs/moq-net/src/model/origin.rs index 26395381bc9..a15f5ebdca3 100644 --- a/rs/moq-net/src/model/origin.rs +++ b/rs/moq-net/src/model/origin.rs @@ -794,13 +794,19 @@ impl<'a> Epochs<'a> { /// under a new instance, so a hash would keep its dead session winning half the time /// until the transport times out. fn route_order(path: &Path, entry: &RouteEntry) -> RouteOrder { + // A lite-07 claim ranks as the one hop to its origin node: the rest of its hops are + // the moq-lite-06 chain it carries only for loop detection and translation. + let (anonymous, hops) = match entry.node { + Some(_) => (false, 1), + None => (entry.is_anonymous(), entry.hops.len()), + }; ( entry.draining, Reverse(entry.preference), - entry.is_anonymous(), + anonymous, entry.cost, !entry.local, - entry.hops.len(), + hops, match (entry.node, entry.link == Link::Local && entry.prefix == *path) { (_, true) => (0, 0), // Every node that knows the claim ranks its origin node alike. @@ -9900,6 +9906,32 @@ mod tests { assert_eq!(route.cost, Cost::new(5)); } + #[kio::test] + async fn a_lite07_claims_carried_chain_does_not_rank_it() { + let producer = origin(1).produce(); + let mut announced = producer.consume().routes(); + + let _native = producer + .announce( + "room", + RouteInfo::new().with_hops(hops(&[10])).with_cost(5).with_node(Some(10)), + ) + .unwrap(); + announced.expect_next_active("room").await; + + let _carried = producer + .announce( + "room", + RouteInfo::new() + .with_hops(hops(&[0, 7, 20])) + .with_cost(1) + .with_node(Some(20)), + ) + .unwrap(); + let route = announced.expect_next_active("room").await; + assert_eq!(route.cost, Cost::new(1)); + } + #[kio::test] async fn anonymous_routes_order_by_cost() { let producer = origin(1).produce(); From 966a128076fd7c023491e9a1bb80a21a09609942 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Mon, 9 Nov 2026 14:58:52 -0800 Subject: [PATCH 5/5] Merge origin/main; fuzz claims carry an empty chain --- rs/moq-net/src/fuzz.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rs/moq-net/src/fuzz.rs b/rs/moq-net/src/fuzz.rs index a5d4a598219..75bb03aad55 100644 --- a/rs/moq-net/src/fuzz.rs +++ b/rs/moq-net/src/fuzz.rs @@ -638,6 +638,7 @@ impl RouteRelay { cost, upstream: false, learned: false, + chain: crate::Hops::new(), } }