Skip to content

Commit f98a836

Browse files
committed
docs: trim SEP-2260 comments to spec rationale
1 parent 05e782c commit f98a836

3 files changed

Lines changed: 16 additions & 26 deletions

File tree

crates/rmcp/src/service.rs

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ pub trait ServiceRole: std::fmt::Debug + Send + Sync + 'static + Copy + Clone {
163163
/// SEP-2260 says clients receiving a server-to-client request with no
164164
/// associated outbound request should reject it with invalid params. An
165165
/// error return is sent back to the peer instead of dispatching to the
166-
/// handler. The `association` argument is the transport-observed stream
167-
/// association; see [`PeerRequestAssociation`].
166+
/// handler.
168167
#[doc(hidden)]
169168
fn enforce_peer_request_association(
170169
_peer_request: &Self::PeerReq,
@@ -176,23 +175,21 @@ pub trait ServiceRole: std::fmt::Debug + Send + Sync + 'static + Copy + Clone {
176175
}
177176

178177
/// How an inbound peer request relates to this side's in-flight outbound
179-
/// requests, as observed by the transport (SEP-2260).
178+
/// requests (SEP-2260).
180179
///
181-
/// SEP-2260 defines no wire field for request association; only a
182-
/// stream-separating transport (streamable HTTP) can distinguish the first
183-
/// two variants. Transports without stream separation (stdio, in-process)
184-
/// yield [`Self::Unknown`], preserving the coarse in-flight check.
180+
/// SEP-2260 defines no wire field for association, so only stream-separating
181+
/// transports (streamable HTTP) can observe it; other transports yield
182+
/// [`Self::Unknown`].
185183
#[derive(Debug, Clone, PartialEq, Eq)]
186184
#[expect(clippy::exhaustive_enums, reason = "intentionally exhaustive")]
187185
pub enum PeerRequestAssociation {
188-
/// Arrived on the response stream of an outbound request that is still
189-
/// awaiting its response.
186+
/// Arrived on the response stream of an in-flight outbound request.
190187
Associated,
191188
/// Arrived on a stream tied to no in-flight outbound request (e.g. the
192189
/// streamable HTTP standalone GET stream).
193190
Unassociated,
194-
/// The transport supplied no stream provenance; only the coarse
195-
/// "is anything in flight" signal exists.
191+
/// The transport cannot distinguish streams; only the coarse in-flight
192+
/// signal is available.
196193
Unknown { has_pending_outbound_request: bool },
197194
}
198195

@@ -204,9 +201,6 @@ pub(crate) fn uses_legacy_lifecycle(
204201
&& protocol_version.is_none_or(|version| version < &ProtocolVersion::V_2026_07_28)
205202
}
206203

207-
/// Translate the transport-attached [`InboundStreamOrigin`] marker (if any)
208-
/// and the in-flight outbound request pool into the association passed to
209-
/// [`ServiceRole::enforce_peer_request_association`].
210204
pub(crate) fn peer_request_association<Req: crate::model::GetExtensions, V>(
211205
request: &Req,
212206
local_responder_pool: &std::collections::HashMap<RequestId, V>,
@@ -256,12 +250,9 @@ pub(crate) fn in_request_handler_scope() -> bool {
256250
pub struct OriginatingRequestId(pub RequestId);
257251

258252
/// Marker in an inbound request's non-serialized [`Extensions`] recording
259-
/// which HTTP response stream it arrived on (SEP-2260): the receive-side
260-
/// mirror of [`OriginatingRequestId`]. Attached by the streamable HTTP
261-
/// client transport; read by the service layer to enforce the client
262-
/// receive-side association check. Never on the wire (SEP-2260 defines no
263-
/// wire field), so transports that serialize messages cannot convey it and
264-
/// the service layer falls back to the coarse in-flight check.
253+
/// which HTTP response stream it arrived on: the receive-side mirror of
254+
/// [`OriginatingRequestId`]. Never on the wire (SEP-2260 defines no wire
255+
/// field); when absent, the coarse in-flight check applies.
265256
#[derive(Debug, Clone, PartialEq, Eq)]
266257
#[expect(clippy::exhaustive_enums, reason = "intentionally exhaustive")]
267258
pub enum InboundStreamOrigin {

crates/rmcp/src/service/client.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,9 @@ impl ServiceRole for RoleClient {
238238
}
239239
}
240240

241-
// SEP-2260: reject restricted server requests that the transport observed
242-
// arriving with no in-flight outbound request association. Transports
243-
// without stream separation (stdio) report `Unknown`, where the coarse
244-
// in-flight check is the best available under-approximation of the SHOULD.
241+
// SEP-2260: reject restricted server requests that arrived unassociated
242+
// with any in-flight outbound request. Without stream separation
243+
// (`Unknown`) the coarse in-flight check under-approximates the SHOULD.
245244
fn enforce_peer_request_association(
246245
peer_request: &Self::PeerReq,
247246
peer_info: Option<&Self::PeerInfo>,

crates/rmcp/src/transport/streamable_http_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,8 @@ impl<C: StreamableHttpClient> StreamableHttpClientWorker<C> {
654654
let Some(mut message) = message.transpose()? else {
655655
break;
656656
};
657-
// SEP-2260: record which stream this request arrived on so the
658-
// service layer can enforce receive-side request association.
657+
// SEP-2260: mark inbound requests with the stream they arrived on
658+
// for the client receive-side association check.
659659
if let ServerJsonRpcMessage::Request(request) = &mut message {
660660
request.request.extensions_mut().insert(origin.clone());
661661
}

0 commit comments

Comments
 (0)