{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-a-torn-sse-event-boundary-when-an-mcp-http-native-transport-resumes-a-session-mid-stream",
  "title": "How does an instance detect a torn SSE event boundary when an MCP HTTP-native transport resumes a session mid-stream",
  "date_of_record": "2026 November 13",
  "scope": "Applies to MCP servers and clients using the HTTP-native transport (SSE streaming over HTTP POST/GET with `Mcp-Session-Id` and `Last-Event-ID` resumption) when a stream is interrupted and renegotiated. Does not apply to stdio transport, to stateless HTTP transports without event IDs, or to servers that do not emit `id:` fields on SSE events.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-torn-sse-event-boundary-when-an-mcp-http-native-transport-resumes-a-session-mid-stream.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-torn-sse-event-boundary-when-an-mcp-http-native-transport-resumes-a-session-mid-stream.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-torn-sse-event-boundary-when-an-mcp-http-native-transport-resumes-a-session-mid-stream.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1690,
    "python_slice_tokens": 256,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **resumption as replay** and **resumption as continuation**. A client that reconnects with `Last-Event-ID: N` is asking the server to continue the logical event stream *after* event N. A server that has lost its per-session event buffer cannot honor that contract; it can only start a fresh stream. These two behaviors a...",
    "what_was_observed": "During a load test of an MCP server streaming a 4 MB tool result over HTTP-native transport, with a proxy injecting a 250 ms connection reset at a random point, the following sequence was recorded: 1. Client received event `id: 42`, `data:` line 1 of 3 (partial JSON, ~1.3 MB, no trailing newline). 2. Connection reset. Client reconnected with `Last-Event-ID: 42`. 3. Server, having evicted its ring buffer (capacity 64 ...",
    "condition_of_validity": "The \"resumption as replay\" contract is valid only when all three of the following hold: - The server retains every event in the session's logical stream since the client's `Last-Event-ID`, **or** explicitly signals unrecoverable loss by closing with a non-200 status or an SSE `event: error` frame carrying a resumption-failed code. - The client treats each SS...",
    "decision_boundary": "An instance should treat a reconnect as **unsafe to continue** — and must tear down the session and renegotiate a fresh `Mcp-Session-Id` — when any of the following is true at reconnect time: - The last event received had an `id` but the event's `data:` payload did not parse as complete JSON (i.e., the client is holding a partial event). - The server's repla...",
    "operational_effect": "The practical consequence is that MCP HTTP-native sessions must be treated as **resumable only at message granularity, never at byte granularity**, and the client must own the completeness check. Servers that evict event buffers under memory pressure convert a recoverable interruption into a silent corruption unless they downgrade the response to an explicit..."
  },
  "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": "84d14100d36b8d23e9e9c5ff13a856a4c21752691cf3ebc678b8ac8bdd2debae",
    "verified_classes": [
      "TornStreamBoundaryError",
      "ResumableStreamGuard"
    ],
    "verified_functions": [
      "__init__",
      "on_event",
      "on_reconnect"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "TornStreamBoundaryError"
    ],
    "sample_fail_closed_invariants": [
      "reconnect while holding partial event; must renegotiate session"
    ],
    "stdlib_dependencies": [
      "json",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
