From 5dbee6562f21a48c6a4e7e37a6f8c83047d83769 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 16 Nov 2026 15:41:07 -0800 Subject: [PATCH 1/2] chore(quest): claim quest/m2/cluster-routes/mount-scope.md Quest-Claim: 5e2913f4950c2132 From d65ca7cbcdedeb4347ccc6ce58fccd31e09f9baa Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 16 Nov 2026 16:00:36 -0800 Subject: [PATCH 2/2] fix(net): a mount closes under its session's scope A scoped session's mount filed its key with no scope, so the session closing through it doubted the Node ID the scoped peer declared. The router now reads each closing key's scope from the session it answers, as it stands at close. Co-Authored-By: Claude Opus 5.5 --- quest/m2/cluster-routes/mount-scope.md | 26 ----------------------- rs/moq-net/src/route/node.rs | 3 ++- rs/moq-net/src/route/node/tests.rs | 29 ++++++++++++++++++++++++++ rs/moq-net/src/route/path.rs | 13 ++++++++++-- 4 files changed, 42 insertions(+), 29 deletions(-) delete mode 100644 quest/m2/cluster-routes/mount-scope.md diff --git a/quest/m2/cluster-routes/mount-scope.md b/quest/m2/cluster-routes/mount-scope.md deleted file mode 100644 index 3c39fc12e38..00000000000 --- a/quest/m2/cluster-routes/mount-scope.md +++ /dev/null @@ -1,26 +0,0 @@ -# [S] A mount files under its session's scope - -## Goal - -A scoped lite-07 session that closes casts no doubt on the Node ID it -declared, whether or not a mount of it is open, and a test on the route node -shows it. - -## Plan - -Decided 2026-11-15 (maintainer, on [the route -stream](https://github.com/moq-dev/moq/pull/8835)): ✅ a follow-up quest in -m2 (rejected: m3; ignoring it). - -Pullfrog found it on the route stream. `Stream::mount` in -`rs/moq-net/src/route/node.rs` files a mount's key with `scope: None`, since -a mount hears nothing. A scoped session's close then reaches the -router as an unscoped one's, so the router doubts the Node ID the session -declared, which a scoped peer must not be trusted to speak for. - -- File a mount's key with the scope of the session it belongs to, or have the - session's close carry that scope for every key it ends. -- Test that a scoped session closing through a mount casts no doubt on its - declared Node ID, and that an unscoped one still does. - -Public API: none. Wire: none. diff --git a/rs/moq-net/src/route/node.rs b/rs/moq-net/src/route/node.rs index 55372348a00..151d42ceb92 100644 --- a/rs/moq-net/src/route/node.rs +++ b/rs/moq-net/src/route/node.rs @@ -1247,7 +1247,8 @@ impl Stream { tag, node: state.router.hop_of(self.key), }; - // A mount hears nothing, so it asks for nothing and files nothing. + // A mount hears nothing, so it asks for nothing and files nothing; it closes under + // its session's scope (`Router::disconnect`), which a permit may change. let link = Link { scope: None, interest: BTreeSet::new(), diff --git a/rs/moq-net/src/route/node/tests.rs b/rs/moq-net/src/route/node/tests.rs index 77daa71df00..bdaabf088cb 100644 --- a/rs/moq-net/src/route/node/tests.rs +++ b/rs/moq-net/src/route/node/tests.rs @@ -776,6 +776,35 @@ fn a_closed_session_takes_its_mounts() { assert_eq!(relay.lock().router.neighbors(), 0); } +/// A scoped session's close doubts no node, since a scoped peer names itself as it likes, +/// and an unscoped one doubts the Node ID it declared, whether or not a mount of it is +/// open. A mount closes under the scope its session holds then, here one set after the +/// mount opened. +#[test] +fn a_session_closing_with_its_mounts_doubts_only_if_unscoped() { + for scoped in [false, true] { + for mounted in [false, true] { + let relay = Node::new(2, 2, clock()); + let session = relay.answer(peer(1, 10), Link::default(), p("other")).unwrap(); + let mount = mounted.then(|| session.mount(p("live")).unwrap()); + let scope = scoped.then(|| crate::route::Scope { + regions: vec![p("live")], + qualify: crate::route::qualifier([7; 32]), + }); + let link = Link { + scope, + interest: Default::default(), + ..Default::default() + }; + session.relink(link, false).unwrap(); + drop(session); + drop(mount); + let doubt = relay.lock().router.retained().doubt; + assert_eq!(doubt, usize::from(!scoped), "scoped {scoped}, mounted {mounted}"); + } + } +} + /// The origin declares its hop id, without the qualified marker, or a random /// identity when nothing is left of it. #[test] diff --git a/rs/moq-net/src/route/path.rs b/rs/moq-net/src/route/path.rs index a74cb3721b3..2a00bd9ae06 100644 --- a/rs/moq-net/src/route/path.rs +++ b/rs/moq-net/src/route/path.rs @@ -1117,9 +1117,18 @@ impl Router { /// goes, and each names its hop to the others. pub fn disconnect(&mut self, neighbors: impl IntoIterator, now: Instant) { self.clock(now); + // A mount speaks for the session it answers, so it closes under that session's + // scope, read before any of them go. + let neighbors: Vec<(N, bool)> = (neighbors.into_iter()) + .map(|neighbor| { + let scoped = + (self.sessions.get(&self.listen(neighbor))).is_some_and(|session| session.link.scope.is_some()); + (neighbor, scoped) + }) + .collect(); let mut ids = BTreeSet::new(); let mut hops = Vec::new(); - for neighbor in neighbors { + for (neighbor, scoped) in neighbors { let Some(session) = self.sessions.remove(&neighbor) else { continue; }; @@ -1144,7 +1153,7 @@ impl Router { ids.extend(self.fail(hop, session.hop, None, Vec::new(), false, now)); // A scoped peer names itself as it likes, so its close neither doubts that node // nor names it to the neighbours: the routes it sent end one by one instead. - if session.link.scope.is_none() { + if !scoped { ids.extend(self.suspect(session.hop, now)); hops.push(Report::Closed(hop)); }