Repository navigation
feat(relay): configure client and peer request caps - #5310
Conversation
Co-Authored-By: GPT-6 Astra <noreply@openai.com>
Co-Authored-By: GPT-6 Astra <noreply@openai.com>
…y grant Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6d7abcf to
8d7c53c
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou'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 1 minute. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe relay now supports separate announcement and subscription caps for ordinary sessions and peer sessions. It selects limits from the admitted grant and applies them to relay sessions and outbound cluster clients. Session cap closures map to Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge summaryChanges: Decisions (maintainer accepted the recommended picks):
Also in this PR: it completes Validation: (Written by Claude Opus 5.5) |
# Conflicts: # doc/concept/stats.md
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed 522b282 against base 6a988ac, including changes since my previous read-only inspection (no review was published then).
No actionable findings. Reusing the existing cap machinery and selecting policy from the admitted peer grant keeps the change focused and the role boundary clear. Checked native/WebSocket/io_uring admission, outbound cluster and reconnect caps, legacy SETUP request windows, config plumbing, append-only error kinds, and the added regressions.
Verification: GitHub-only static review; no tests run.
Problem
Every relay session inherits moq-net's request caps (100,000 announcements, 10,000 subscriptions), sized for cluster links, so an ordinary viewer or publisher gets a mesh-sized allowance. Operators cannot configure the client and peer policies separately, and C/UniFFI clients classify a request-cap closure as an unknown error.
Approach
Add
[session]and[peer]tables withannouncesandsubscriptions, mirrored by--session-*/--peer-*flags andMOQ_SESSION_*/MOQ_PEER_*env vars. The relay picks the policy after admission and before answering SETUP on the native, WebSocket, and io_uring paths. Only an admittedpeergrant selects peer caps (upstreamrequirespeer, and verified LAN membership mints apeergrant); a client certificate, route hop, or cluster-looking path alone does not. Outgoing cluster links use the peer policy.Append a structured
TooManyRequestsprotocol kind across C, UniFFI, the wrappers, and OBS. OBS explains a request-cap closure instead of reporting a generic connection failure.These caps are not arbitrary runtime limits: they are moq-net's existing
session::Limits, now operator-configurable per role with sane defaults, and exceeding one already closed the session withTOO_MANY_REQUESTS. The PR only lets operators size them and gives clients a smaller default.Decisions
Settled during
/quest-iterate(the maintainer accepted the recommended picks):[session]and[peer], leaving one peer table for the QUIC peer limits. ✅[client]for ordinary sessions; overlaps the relay's outbound client terminology.with_limitsonmoq_net::server::Request,moq_tokio::server::Request, andmoq_tokio::Client, matchingmoq_net::Server::with_limitsand the otherwith_*builders. ✅grant.peeralone, since grant validation already refusesupstreamwithoutpeer. ✅Impact
moq-relay: newlimits::{Session, Peer}module;Config.session/Config.peer;cluster::Options.session/cluster::Options.peer; flags--session-announces,--session-subscriptions,--peer-announces,--peer-subscriptionsand matching env vars and TOML keys. Behavior: ordinary sessions now default to 1,000 / 1,000 instead of 100,000 / 10,000; peers keep 100,000 / 10,000.moq-net:server::Request::with_limits.moq-tokio:server::Request::with_limits,Client::with_limits.moq-ffi:MoqProtocolKind::TooManyRequestsappended as the last variant.moq-c:MOQ_PROTOCOL_KIND_TOO_MANY_REQUESTS = 25; existing values unchanged.ProtocolKindTooManyRequests. Dart, Kotlin, Swift, Python, and C++ pick it up through their generatedProtocolKind.TOO_MANY_REQUESTSstays session code 7. On moq-transport drafts 14 to 16 the caps also size the request window, so very small values can stall other requests.Composition with JS (#5214): the browser enforces moq-net's 100,000 / 10,000 on what the relay holds on it, while the relay enforces these caps on what the browser holds on the relay. They bound opposite directions, and
@moq/netalready names code 7SessionCode.TooManyRequests.Validation
main;just checkpasses on the head.just test interop --allpasses, including the browserrefused sessioncheck; all four flags appear in the built relay's--help.refused sessionwithConnection lost. The relay log shows that session refused at admission ("the auth server refused the session"), before the request-cap code runs, so it is the known flake tracked inquest/m1/test-flakes-2/interop-close-code.md, not this change. This PR records that run and its relay-log evidence in that quest. It passes locally and in CI on the rebased head.Alternatives
See Decisions.
Follow-ups
quest/m1/quic/peer-limits.md) extends[peer]with the QUIC stream and window values; its reference is updated and this PR completes the relay session limits quest.🤖 Generated with Claude Code
(Written by Claude Opus 5.5)