From ca536a18a5c11d0c56456c64e5b756a6d59ef35f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 13:34:11 -0800 Subject: [PATCH 1/2] test(net): pin the late better path on lite-07 and lite-06 meshes A relay that hears a broadcast over a longer path first moves to the shorter one when it arrives. On a lite-07 mesh the move keeps the instance, so lite-06 and lite-07 watchers see an update in place. On a lite-06 mesh each relay mints its own instance, so the watcher sees the live broadcast retracted and announced again; pinned as a residual for routes and announces. Co-Authored-By: Claude Opus 5.5 --- quest/m1/cluster-routing/routes.md | 11 +-- rs/moq-net/tests/integration/mesh_withdraw.rs | 67 +++++++++++++++++++ 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/quest/m1/cluster-routing/routes.md b/quest/m1/cluster-routing/routes.md index b7192ab4c77..769f22e57be 100644 --- a/quest/m1/cluster-routing/routes.md +++ b/quest/m1/cluster-routing/routes.md @@ -598,11 +598,12 @@ passing. On `main` an epochless switch to a stale path is a Restart, which a lite-06 client sees as a retraction and an announcement; the release sent an in-place update. -Publishing toggles too, decided 2026-10-13: add a time-mocked fixture where, -on some rings, a longer path arrives first and the better route then replaces -it as a Restart, so a lite-06 client sees `Start, End, Start` while the -broadcast stays live. Pin today's sequence beside the `residual_*` tests; -the epochless Restart rule above decides what it becomes. +Publishing toggles too, decided 2026-10-13: a longer path arrives first and +the better route then replaces it. `late_better_path_updates_in_place` pins +the lite-07 mesh, where the move keeps the instance and a lite-06 or lite-07 +client sees an update. `residual_late_better_path_restarts_on_lite06` pins the +lite-06 mesh, where each relay mints its own instance and the client sees +`Start, End, Start` while the broadcast stays live; turn it into an update. Tests, time mocked: the handoff fixtures and sweep in `handoff.rs`; [moq-dev/moq#4644](https://github.com/moq-dev/moq/pull/4644)'s live-graph withdrawal and failover tests (the PR closed and diff --git a/rs/moq-net/tests/integration/mesh_withdraw.rs b/rs/moq-net/tests/integration/mesh_withdraw.rs index e80b8654bdf..90cc6cd01c3 100644 --- a/rs/moq-net/tests/integration/mesh_withdraw.rs +++ b/rs/moq-net/tests/integration/mesh_withdraw.rs @@ -441,6 +441,63 @@ async fn cross_node_close_without_hold_reannounces() { assert_eq!(client, [Kind::End, Kind::Start, Kind::End]); } +/// Relay 3 hears a broadcast published on relay 0 first over the longer path +/// through relays 2 and 4, then 300 ms later over the shorter one through relay 1. +#[rustfmt::skip] +const LATE_BETTER_PATH: &[Link] = &[ + ((0, 1), ms(10)), ((1, 3), ms(300)), ((0, 2), ms(10)), ((2, 4), ms(10)), ((4, 3), ms(10)), +]; + +/// The relays mesh on `mesh` while a publishing client on relay 0 and a watching +/// client on relay 3 speak `client`. Publishes a broadcast, then closes it, and +/// returns what the watching client saw for each. +async fn late_better_path(mesh: &str, client: &str) -> (Vec, Vec) { + let mesh: Version = mesh.parse().unwrap(); + let client: Version = client.parse().unwrap(); + let relays: Vec<_> = (1..=5).map(produce_origin).collect(); + let mut pairs = Vec::new(); + for &((a, b), latency) in LATE_BETTER_PATH { + pairs.push(peer_with_latency(mesh, &relays[a], &relays[b], latency).await); + } + let publishing = produce(1000, Duration::ZERO); + let mut options = MockConnectOptions::new(client); + options.client_publish = Some(publishing.consume()); + options.server_subscribe = Some(relays[0].clone()); + pairs.push(connect_mock(options).await); + let watching = produce(1001, Duration::ZERO); + let mut options = MockConnectOptions::new(client); + options.server_publish = Some(relays[3].consume()); + options.client_subscribe = Some(watching.clone()); + pairs.push(connect_mock(options).await); + let mut watcher = watch(watching.consume().announced()); + kio::clock::sim::idle().await; + assert!(drain(&mut watcher).is_empty()); + + let broadcast = publishing.create_broadcast("room/a").unwrap(); + broadcast.announce(Default::default()).unwrap(); + kio::clock::sim::idle().await; + let published = drain(&mut watcher).remove("room/a").unwrap(); + drop(broadcast); + kio::clock::sim::idle().await; + let closed = drain(&mut watcher).remove("room/a").unwrap(); + (published, closed) +} + +/// A relay that first hears a broadcast over a longer path moves to the shorter +/// one when it arrives, and a client watching it sees a live broadcast only +/// update. Lite-07 relays carry the instance the publisher's relay minted for +/// its lite-06 or lite-07 publisher, so the move keeps the instance, and a +/// lite-06 watcher gets the update in place rather than a retraction and a new +/// announcement. +#[kio::test] +async fn late_better_path_updates_in_place() { + for client in ["moq-lite-06", "moq-lite-07-wip"] { + let (published, closed) = late_better_path("moq-lite-07-wip", client).await; + assert_eq!(published, [Kind::Start, Kind::Update], "{client}"); + assert_eq!(closed, [Kind::End], "{client}"); + } +} + // Residual counterexamples on `main`, with the hold and the retraction // quarantine. Each pins what the cluster does today, so a change either way // fails here. Routes and announces (quest/m1/cluster-routing/routes.md) must @@ -498,6 +555,16 @@ async fn residual_mesh_revives() { assert_capped_withdrawal(EDGES, 4, 8).await; } +/// On a lite-06 mesh each relay mints its own instance for what a neighbor +/// announces, so the move to the late, shorter path is another instance: the +/// watching client sees the live broadcast retracted and announced again. +#[kio::test] +async fn residual_late_better_path_restarts_on_lite06() { + let (published, closed) = late_better_path("moq-lite-06", "moq-lite-06").await; + assert_eq!(published, [Kind::Start, Kind::End, Kind::Start]); + assert_eq!(closed, [Kind::End]); +} + async fn assert_capped_withdrawal(edges: &[Link], publisher: usize, watcher: usize) { let mut config = origin::Config::default(); config.max_hops = origin::HopLimit::new(diameter(edges) + 2).unwrap(); From 48544b34fb86c4c18cd0450812c5aded4b35fc69 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 3 Nov 2026 14:09:15 -0800 Subject: [PATCH 2/2] test(net): state the late better path's hop counts and latencies Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/tests/integration/mesh_withdraw.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rs/moq-net/tests/integration/mesh_withdraw.rs b/rs/moq-net/tests/integration/mesh_withdraw.rs index 86136db0cd6..8fdb0c95dae 100644 --- a/rs/moq-net/tests/integration/mesh_withdraw.rs +++ b/rs/moq-net/tests/integration/mesh_withdraw.rs @@ -441,8 +441,9 @@ async fn cross_node_close_without_hold_reannounces() { assert_eq!(client, [Kind::End, Kind::Start, Kind::End]); } -/// Relay 3 hears a broadcast published on relay 0 first over the longer path -/// through relays 2 and 4, then 300 ms later over the shorter one through relay 1. +/// Relay 3 hears a broadcast published on relay 0 first over the longer, faster +/// path through relays 2 and 4 (3 hops, 30 ms), then 280 ms later over the +/// shorter, slower one through relay 1 (2 hops, 310 ms). #[rustfmt::skip] const LATE_BETTER_PATH: &[Link] = &[ ((0, 1), ms(10)), ((1, 3), ms(300)), ((0, 2), ms(10)), ((2, 4), ms(10)), ((4, 3), ms(10)),