{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-sse-to-streamable-http-session-resumption-from-silently-replaying-events-across-a-reconnected-mcp-client",
  "title": "Which invariants prevent SSE-to-streamable-HTTP session resumption from silently replaying events across a reconnected MCP client",
  "date_of_record": "2026 November 28",
  "scope": "Applies to MCP servers migrating from the legacy HTTP+SSE transport to the streamable-HTTP transport where `Last-Event-ID` resumption is honored across reconnects; does not cover stdio transport, WebSocket-based bridges, or stateless streamable-HTTP servers that reject resumption entirely.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-to-streamable-http-session-resumption-from-silently-replaying-events-across-a-reconnected-mcp-client.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-to-streamable-http-session-resumption-from-silently-replaying-events-across-a-reconnected-mcp-client.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-to-streamable-http-session-resumption-from-silently-replaying-events-across-a-reconnected-mcp-client.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1923,
    "python_slice_tokens": 249,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure here is not \"the connection dropped.\" It is that a *resumed* stream is not the same object as the *original* stream, but the transport protocol treats `Last-Event-ID` as if it were a durable cursor into a single, monotonic event log. In the legacy SSE transport, one long-lived `EventSource` bound to one `GET /sse` response carried a session's ent...",
    "what_was_observed": "A server was migrated from SSE to streamable-HTTP. The legacy handler kept a single `self.event_counter` incremented per emitted event across the whole process. The new handler was refactored so that each `POST /mcp` request created an ephemeral `EventStream` object whose `emit()` started at `id=0` per request, while the standalone `GET /mcp` resumption stream read from a separate per-session ring buffer. Trace of th...",
    "condition_of_validity": "The invariant \"resume by `Last-Event-ID`\" is only valid when all of the following hold simultaneously: - **Namespace unity:** Every event emitted for a session—whether on the POST response body or the standalone GET stream—draws from one per-session counter. A per-request counter is not a per-session counter; they cannot be mixed under the same `Last-Event-I...",
    "decision_boundary": "The correct decision at the server boundary is: **when the requested `Last-Event-ID` is older than the oldest event still in the session buffer, refuse resumption with `404` and a `Mcp-Session-Id` invalidation, rather than clamping to the buffer head.** Clamping is the trap because it looks like graceful degradation—the client gets *a* stream—but it delivers...",
    "operational_effect": "Downstream, the observable effects of violating the invariant are: - **Duplicate tool side effects:** a replayed `tools/call` result is not a side effect, but a replayed *request* (if the server replays inbound frames, which some implementations do for reliability) causes a second execution of a non-idempotent tool—file writes, emails, payments. - **Agent st..."
  },
  "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": "2f288381c7017f8d397bceb7badca53881c6c9d73797b0f977805f4e91c4726c",
    "verified_classes": [
      "SessionResumptionViolation",
      "Session"
    ],
    "verified_functions": [
      "handle_resume",
      "emit",
      "resume",
      "evict_through"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SessionResumptionViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
