{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-sse-stream-resurrection-from-corrupting-resumable-mcp-sessions-across-transport-reconnect",
  "title": "Which invariants prevent SSE stream resurrection from corrupting resumable MCP sessions across transport reconnect",
  "date_of_record": "2026 November 27",
  "scope": "Applies to MCP servers exposing the HTTP-native transport with `Last-Event-ID` resumption and SSE multiplexing of multiple in-flight JSON-RPC requests over a single session. Does not cover stdio transport, WebSocket transports, or stateless request/response MCP deployments.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-stream-resurrection-from-corrupting-resumable-mcp-sessions-across-transport-reconnect.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-stream-resurrection-from-corrupting-resumable-mcp-sessions-across-transport-reconnect.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-stream-resurrection-from-corrupting-resumable-mcp-sessions-across-transport-reconnect.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2212,
    "python_slice_tokens": 426,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure here is not \"reconnect loses messages.\" The failure is that a *successfully resumed* SSE stream can silently deliver events belonging to a request whose logical lifetime already terminated on the server, because the event log and the session-request registry are two independent pieces of state with independent garbage-collection clocks. Resumptio...",
    "what_was_observed": "A tool-calling agent issued `tools/call` with JSON-RPC `id: 7` against an MCP server over HTTP+SSE. The tool handler was slow (a browser automation tool with a 30s internal timeout). The agent's HTTP client had a 12s read timeout on the SSE connection and reconnected with `Last-Event-ID: 41`. On the server, the session's request registry had already expired `id: 7` at 10s (a per-request TTL shorter than the tool's ow...",
    "condition_of_validity": "The resume contract is only sound under the following condition, which must be enforced server-side and *checked* client-side: For every event `e` in the replayable buffer with `e.request_id = r`, either (a) `r` is present in the session request registry at reconnect time with the same generation epoch recorded at event emission, or (b) `e` is a terminal fra...",
    "decision_boundary": "The boundary is whether to treat `Last-Event-ID` resumption as *at-least-once delivery of opaque events* or as *exactly-once delivery of request-scoped frames*. These require different guards: - **At-least-once (opaque):** the client must deduplicate by event ID and must not assume any frame maps to a live request. Late frames for dead requests are expected ...",
    "operational_effect": "The observable effect of the violation is *silent cross-request result substitution*: the agent's reasoning layer receives a well-formed JSON-RPC `result` whose `id` matches an outstanding request but whose payload belongs to a different tool invocation. Because the transport layer reports success (the frame parsed, the ID matched, the slot was open), no err..."
  },
  "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": "6d170b5cb301908c78163c74724674d516016d69e8487bfe75d69a187edf0a2c",
    "verified_classes": [
      "StaleEventReplayError",
      "RequestEntry",
      "EventFrame",
      "Session"
    ],
    "verified_functions": [
      "apply_resumed_frames",
      "alive",
      "register",
      "emit",
      "resume"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "StaleEventReplayError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
