{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-reject-sse-to-websocket-upgrade-resumption-after-an-mcp-streamable-session-reconnect",
  "title": "When must an instance reject SSE-to-WebSocket upgrade resumption after an MCP streamable-session reconnect",
  "date_of_record": "2026 November 29",
  "scope": "Applies to MCP servers and clients using the streamable HTTP transport where a session may be resumed via `Last-Event-ID` replay and where the transport permits an in-band upgrade from `text/event-stream` to WebSocket. Does not apply to pure stdio transports, nor to stateless MCP servers that mint a fresh session per request.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-reject-sse-to-websocket-upgrade-resumption-after-an-mcp-streamable-session-reconnect.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-reject-sse-to-websocket-upgrade-resumption-after-an-mcp-streamable-session-reconnect.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-reject-sse-to-websocket-upgrade-resumption-after-an-mcp-streamable-session-reconnect.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2107,
    "python_slice_tokens": 334,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the WebSocket upgrade failed.\" The failure is that the upgrade *succeeded* and the resuming instance accepted a replayed event stream whose sequence numbers were generated under the SSE framing and then continued emitting under WebSocket framing, silently renumbering. There are two distinct notions of continuity that operators routinely c...",
    "what_was_observed": "An agent worker held an MCP session against a streamable-HTTP server. The server emitted SSE events with `id:` values of the form `sess-7f3a:00000000000000000042`. The agent consumed through event `...0042`, then its HTTP/1.1 chunked connection was torn down by an intermediary proxy at the 60-second idle mark. The client reconnected with `Last-Event-ID: sess-7f3a:00000000000000000042` and, per server policy, the conn...",
    "condition_of_validity": "Resumption across a framing upgrade is valid **if and only if** all of the following hold simultaneously: 1. **Cursor namespace identity.** The event-ID emitted by the first post-upgrade WebSocket frame is strictly greater, under the *server's own comparison function*, than the last event ID the client consumed pre-upgrade — and the client is told which comp...",
    "decision_boundary": "The decision the client must make on receiving an upgrade hint is binary and must be made *before* consuming any post-upgrade frame: - **Accept the upgrade** only when the server advertises a cursor-compatibility token (e.g. `Mcp-Cursor-Namespace: <hash>` in the 101 handshake) that matches the namespace hash the client recorded at session start, *and* the fi...",
    "operational_effect": "Enforcing the invariant changes three things in practice: - **Server implementers** must thread a single monotonic allocator across both framings and emit a sequenced `transport.upgrade` event; the per-connection `ws_seq` shortcut is banned. - **Client implementers** must treat event IDs as namespace-scoped opaque tokens with a server-declared comparator, ne..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "1cea17c35dc0707a50d9f9e80a095dd1a86a78dbe973a13f3f42256211b8967e",
    "verified_classes": [
      "CursorNamespaceMismatch",
      "Cursor"
    ],
    "verified_functions": [
      "_compare",
      "accept_upgrade",
      "resume_session"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "CursorNamespaceMismatch"
    ],
    "sample_fail_closed_invariants": [
      "upgrade handshake omitted cursor namespace hash; cannot prove replay shares the pre-upgrade ID space",
      "no sequenced frame after 101; upgrade event not represented in stream"
    ],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
