{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-sse-event-id-replay-from-corrupting-resumable-mcp-sessions-across-stateless-http-servers",
  "title": "Which invariants prevent SSE event-ID replay from corrupting resumable MCP sessions across stateless HTTP servers",
  "date_of_record": "2026 December 1",
  "scope": "Applies to MCP servers exposing the HTTP-native transport (Streamable HTTP / SSE streaming) where clients may reconnect with `Last-Event-ID` and the server is horizontally scaled or otherwise stateless. Does not apply to stdio transport or to single-process servers holding session state in memory for the process lifetime.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-event-id-replay-from-corrupting-resumable-mcp-sessions-across-stateless-http-servers.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-event-id-replay-from-corrupting-resumable-mcp-sessions-across-stateless-http-servers.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-event-id-replay-from-corrupting-resumable-mcp-sessions-across-stateless-http-servers.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2214,
    "python_slice_tokens": 596,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the SSE connection dropped.\" Drops are expected and survivable. The failure is that a *resume* request (`GET` with `Last-Event-ID: N`) is answered by a *different* server instance that never produced event `N+1`, so it either (a) fabricates a plausible continuation from whatever it can reconstruct, or (b) silently restarts the stream from...",
    "what_was_observed": "A tool-calling MCP server is deployed behind a round-robin load balancer across three replicas. A single `tools/call` streams progress notifications as SSE events: `event: progress`, `data: {\"tool\":\"fetch\",\"pct\":20}`, `id: 1` … `id: 47`, terminating with `id: 48` carrying the final result. The client's connection drops at event `id: 31` (mobile network handoff). The client reconnects per spec: The load balancer route...",
    "condition_of_validity": "`Last-Event-ID` resumption is only sound when all of the following hold for every event ID the server emits: - **Durable append log per session.** Events `1..N` are written to a store readable by *any* replica (Redis stream, Kafka partition keyed by session, or a durable object store) *before* the frame is flushed to the client. Write-then-flush ordering is ...",
    "decision_boundary": "The architect must choose, explicitly, between two regimes and must not straddle them: - **Durable-resume regime:** pay for a per-session append log and enforce write-before-flush. `Last-Event-ID` is honored exactly or the stream is failed with `resume_unavailable`. Clients are entitled to assume exact continuation. - **No-resume regime:** the server does no...",
    "operational_effect": "In the durable-resume regime, the operational cost is a write per event and a retention policy (how long can a client be offline before `resume_unavailable`?). The retention window is the real SLA: a client offline longer than retention must be told to restart the request, and the client must be built to accept that. In the no-resume regime, the cost moves e..."
  },
  "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": "10b67c9567b682c6fc639b889b79b7c186dd470d7ba0ce454a85c5ac2152449d",
    "verified_classes": [
      "ResumeContractViolation",
      "SessionEventLog"
    ],
    "verified_functions": [
      "handle_resume",
      "last_id",
      "append",
      "resume_from"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ResumeContractViolation"
    ],
    "sample_fail_closed_invariants": [
      "assert [e[0] for e in successors] == [4, 5]"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
