Skip to content

fix(moq-net): a scoped peer's lite-07 session exchanges claims instead of closing Unauthorized - #9373

Merged
kixelated merged 6 commits into
mainfrom
quest/m1/lite07-routing/scoped-peer-node-id
Nov 22, 2026
Merged

kixelated merged 6 commits into
mainfrom
quest/m1/lite07-routing/scoped-peer-node-id

Conversation

@kixelated

@kixelated kixelated commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A lite-07 relay that admits a peer with a link and a scoped grant at the root (publish and subscribe ["tenant-a"]) closed the session Unauthorized, and the dialer retried forever. The relay's Cluster::scope_session widens the session's origin handles to every prefix so in-band AUTH can regrant. origin::Consumer::node_id saw those whole handles and declared a Node ID in SETUP, and RouteStream::poll_setup then checked the real AUTH permit and closed, as the draft mandates. The same grant worked over lite-06 and over lite-07 without a link.

Approach

lite::session::start declares a Node ID only when the handles are whole and the grant the application admitted the peer under (Handle::authorize, which the relay applies before answering SETUP) covers every path in both directions (new auth::Link::admits_whole). A scoped peer's relay declares none, so the pair exchanges claims as on lite-06. The fix is in moq-net, so any server that widens its handles hits it too, moq auth serve included. The draft's Routing paragraph now says an endpoint sends the Node ID only when the grant it admits covers every path.

Validation

  • scoped_link_exchanges_claims (moq-relay, real TCP/TLS lite-07): a CDN admitting a dial at /scoped (link upstream, root "", ["tenant-a"] both ways) now routes tenant-a/cdn and tenant-a/edge both ways and reads frames across; other/cam never reaches the dialer. It timed out at "the edge learns the tenant" before the fix (confirmed red).
  • a_scope_admits_whole_only_when_it_leaves_nothing_out (moq-net): unset, whole, and each way of leaving a path out, widening and narrowing.
  • just check (rs, js, drafts, quest) passed. just test interop --all was not run: no wire change.

Impact

  • Public API: none.
  • Wire: none; the draft paragraph is reworded to state what the code does.
  • Behavior: a lite-07 server whose admitted grant is scoped no longer declares a Node ID.

Choices for review

  • Decide at SETUP, from the admitted grant. SETUP goes out before any AUTH answer, so the Node ID follows the grant the session holds when it starts (the relay sets it before request.ok()), not the peer's AUTH_OK to our token, which arrives later. An app that calls authorize only after the session starts is still judged by its handles.
  • A later regrant keeps the session's mode. Widening a claims-only session leaves it on claims until the next dial; narrowing a routing session still closes Unauthorized, as the draft's MUST requires. Demoting a routing session to claims would need a wire change.
  • No JS change: js/net never declares a Node ID.
  • Test shape: one test, since the grant belongs to the listener's admission of the dial and the dialer's side is the same session; data flows both ways in it. A dialer that itself publishes outside the grant it was given still closes, as before.
  • Deleted the finished quest and its links in lite07-finalize.md and federation.md.

Caused by

  • moq-dev/moq#8987 - decided the Node ID from origin handles and added the AUTH-permit close, meeting the handle widening moq-dev/moq#5282 added to scope_session (found by person).

Follow-ups

None.

Models

Size: S
Implementer: Claude Code, claude-sonnet-5-5, unknown effort (arm B)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 283e5ec

  • Base: origin/main at 7d491a3

  • Risk: medium, Could break lite-07 sessions with a scoped peer at the root: `rs/moq-net/src/lite/session.rs` now declares a Node ID only when the admitted grant covers the whole tree, so such peers exchange claims instead of being closed Unauthorized, a behavior change for relay operators and their peers that a revert fully undoes. No public API or wire format changes (the new `admits_whole` is `pub(crate)`), so this is a bug fix rather than high; the draft wording, quest deletions, and integration test are low.

  • Classified: medium by Claude Code, claude-haiku-5-5, low effort, session 7eb42818-d665-4a25-9e5b-da3dddd24977

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a2026e-08c1-7900-97a2-d1c829f52d4c, round 1

  • Score: 9/10, No actionable regressions were found; the fix directly targets admission and adds bidirectional integration coverage, though builds and tests were not run as instructed.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

@kixelated kixelated changed the title A scoped peer's lite-07 session exchanges claims instead of closing Unauthorized fix(moq-net): a scoped peer's lite-07 session exchanges claims instead of closing Unauthorized Nov 22, 2026
@kixelated
kixelated marked this pull request as ready for review November 22, 2026 08:46
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2b96fad8-a559-4d9c-a890-9d1978c9d046
Commits

Reviewing files that changed from the base of the PR and between 0c5b90d and 283e5ec.

Files selected for processing: 7

  • drafts/draft-lcurley-moq-lite.md
  • quest/m1/lite07-routing/scoped-peer-node-id.md
  • quest/m2/lite07-finalize.md
  • quest/m3/cluster-routing/federation.md
  • rs/moq-net/src/auth.rs
  • rs/moq-net/src/lite/session.rs
  • rs/moq-relay/tests/integration/upstream_links.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@kixelated
kixelated enabled auto-merge November 22, 2026 08:47

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: sound. It gates the Node ID on the scope the application admitted (Handle::authorize) rather than on the origin handles alone, which Cluster::scope_session widens to every prefix. The fix sits in moq-net, so every server that widens its handles for in-band AUTH gets it.

Reviewed changes

I reviewed all 7 files at 283e5ec, plus the relay admission path that sets the grant before SETUP (connection.rs:160 → Lease::preparing → Refresh::new → handle.authorize, which runs before request.ok()).

  • lite::session::start gates the Node ID on the admitted grant: node_id(...).filter(|_| auth.admits_whole()). Because of this, routing stays false and RouteStream::poll_setup never reaches its Unauthorized close for a scoped peer, since it checks self.publish.routing before the whole-grant check.
  • New auth::Link::admits_whole: true only while the session scope (limit plus issued grants) matches "" in both directions. A unit test covers unset, whole, and each way a grant can narrow.
  • Draft wording: the Routing paragraph now says an endpoint sends the Node ID only when its admitted grant is whole. It keeps the UNAUTHORIZED MUST for the case where both sides declared and a grant later narrows, which matches the poll_permit loop in route_stream.rs.
  • Integration test scoped_link_exchanges_claims: a lite-07 link scoped to tenant-a routes both ways, frames cross in both directions, and other/cam does not leak.
  • Quest cleanup: the finished quest file and the links to it are removed.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 2f3edd8 Nov 22, 2026
12 checks passed
@kixelated
kixelated deleted the quest/m1/lite07-routing/scoped-peer-node-id branch November 22, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant