{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-a-torn-sse-event-stream-boundary-during-mcp-http-native-transport-session-resumption",
  "title": "How does an instance detect a torn SSE event-stream boundary during MCP HTTP-native transport session resumption",
  "date_of_record": "2026 December 2",
  "scope": "Applies to MCP servers/clients using the HTTP-native transport with `text/event-stream` responses and `Last-Event-ID`-based resumption (Streamable HTTP, single-stream or multiplexed). Does not apply to stdio transports, nor to transports that carry whole-message framing (e.g., WebSocket frames or length-prefixed pipes) where partial reads are impossible.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-torn-sse-event-stream-boundary-during-mcp-http-native-transport-session-resumption.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-torn-sse-event-stream-boundary-during-mcp-http-native-transport-session-resumption.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-torn-sse-event-stream-boundary-during-mcp-http-native-transport-session-resumption.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2124,
    "python_slice_tokens": 348,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure this record isolates is not \"connection dropped.\" It is the distinction between **a resumable gap** and a **silently truncated event**. On an SSE stream, an event is only a valid unit once its terminating `\\n\\n` has been observed and its `data:` lines have been joined. A TCP/HTTP read that returns mid-event is normal and expected; the client must...",
    "what_was_observed": "A client agent was mid-`tools/call` over Streamable HTTP. The server was emitting progress notifications and then the final result as separate SSE events with monotonically increasing `id:` fields. At event id 47 (a large `notifications/progress` payload, ~9 KB, split across multiple `data:` lines), the underlying connection was reset by a middlebox after ~200 ms of idle. The client's read loop had consumed roughly 6...",
    "condition_of_validity": "The guardrail below is valid only when all of the following hold: - The transport is SSE over HTTP and the server honors `Last-Event-ID` with \"resume strictly after the given ID\" semantics. If the server replays *inclusive* of the given ID, the client must dedup the replayed event by ID before dispatch — and the discard-partial rule still applies, because th...",
    "decision_boundary": "At reconnect, the client has two candidate buffers: the stale partial tail (bytes after the last `\\n\\n`) and the fresh replay bytes. The decision is binary and must be made *before* the parser sees the concatenation: - **Discard the partial tail.** Correct. The last dispatched event is the resume anchor; its ID goes in `Last-Event-ID`; the partial tail belon...",
    "operational_effect": "Enforcing the invariant changes the failure mode from silent corruption to a bounded, observable gap. When the partial tail is discarded and the cursor is the last dispatched ID, a reconnect either (a) replays the in-flight event cleanly, or (b) if the server has already advanced past it, surfaces a genuine missing-event condition that the client can detect ..."
  },
  "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": "64db3f1c91c148f0690beb3a3626f178f1ecbeb845c4759795a84a7455df767b",
    "verified_classes": [
      "TornStreamResumeError",
      "SseResumeState"
    ],
    "verified_functions": [
      "begin_resume",
      "dispatch_event"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TornStreamResumeError"
    ],
    "sample_fail_closed_invariants": [
      "dispatch called on un-terminated event; parser must emit only on \\n\\n"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "json"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
