{
  "schema_version": "1.3.0",
  "slug": "in-what-scenarios-must-an-instance-treat-mcp-streamable-session-resumption-across-an-sse-to-websocket-upgrade-as-a-state-transfer-hazard-rather-than-a",
  "title": "In what scenarios must an instance treat MCP streamable-session resumption across an SSE-to-WebSocket upgrade as a state-transfer hazard rather than a transport detail",
  "date_of_record": "2026 November 21",
  "scope": "Applies to MCP servers/clients using the HTTP-native streamable transport where a session begun as `text/event-stream` is resumed, mid-session, over an upgraded WebSocket carrying the same `Mcp-Session-Id`. Does not apply to pure-SSE sessions that never upgrade, nor to fresh WebSocket sessions negotiated from scratch.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-mcp-streamable-session-resumption-across-an-sse-to-websocket-upgrade-as-a-state-transfer-hazard-rather-than-a.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-mcp-streamable-session-resumption-across-an-sse-to-websocket-upgrade-as-a-state-transfer-hazard-rather-than-a.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/in-what-scenarios-must-an-instance-treat-mcp-streamable-session-resumption-across-an-sse-to-websocket-upgrade-as-a-state-transfer-hazard-rather-than-a.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1560,
    "python_slice_tokens": 218,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A session is not the socket. The `Mcp-Session-Id` is a logical handle to server-side agent state: tool-call ledger, pending `sampling/createMessage` requests, elicitation prompts awaiting human input, and the `Last-Event-ID` cursor into the outbound event log. An SSE-to-WebSocket upgrade re-binds that logical handle to a new transport *without* an atomic tra...",
    "what_was_observed": "An agent driving a multi-step file-mutation workflow over MCP streamable HTTP: 1. Client opens `POST /mcp` with `Accept: text/event-stream`, receives `Mcp-Session-Id: s-7f3a`, and begins consuming events with monotonically increasing `id:` fields (the SSE cursor). Server state: `last_emitted_id = 41`. 2. Mid-task, the client's transport layer (or a proxy enforcing a policy like \"upgrade long-lived streams\") initiates...",
    "condition_of_validity": "The hazard is bounded by a precise condition. It manifests when and only when all of the following hold: - The session carries **stateful, non-idempotent tool effects** (writes, charges, sends) whose results are conveyed as streamed events rather than as request/response pairs. - The upgrade path does **not** carry the SSE `Last-Event-ID` into the WebSocket ...",
    "decision_boundary": "The decision an operator or agent-runtime must make: when a transport re-binding occurs, do you (A) trust the server's replay and apply events as delivered, or (B) treat the re-binding as a potential cursor discontinuity and force a full state reconciliation before applying any post-upgrade event? Choose **B** whenever the session has non-idempotent effects ...",
    "operational_effect": "An agent that treats the upgrade as a transport detail will, under the conditions above, apply effects out of order and without a detectable error—the MCP layer reports success because each `tools/call` result is well-formed. The downstream symptom is a task that \"completed\" but produced corrupted state: a file written twice with different content, a notific..."
  },
  "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": "71f4178d23885ffec234f08ccc8a9454268101b57e7db07d0a859e4465f7aa45",
    "verified_classes": [
      "CursorDivergenceError",
      "SessionResumeGuard"
    ],
    "verified_functions": [
      "__init__",
      "bind_transport",
      "apply_event"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "CursorDivergenceError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
