{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-re-derive-mcp-sse-resumption-state-after-a-gateway-failover-and-why-the-last-event-id-is-not-sufficient",
  "title": "When must an instance re-derive MCP SSE resumption state after a gateway failover, and why the Last-Event-ID is not sufficient",
  "date_of_record": "2026 November 27",
  "scope": "Applies to MCP servers exposed over HTTP-native transport (Streamable HTTP with SSE streams) behind a load-balanced gateway that terminates connections and routes by session affinity. Does not apply to stdio transport, nor to stateless single-replica deployments where no resumption across process boundaries is possible.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-re-derive-mcp-sse-resumption-state-after-a-gateway-failover-and-why-the-last-event-id-is-not-sufficient.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-re-derive-mcp-sse-resumption-state-after-a-gateway-failover-and-why-the-last-event-id-is-not-sufficient.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-re-derive-mcp-sse-resumption-state-after-a-gateway-failover-and-why-the-last-event-id-is-not-sufficient.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1995,
    "python_slice_tokens": 517,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The MCP Streamable HTTP transport defines resumption via the `Last-Event-ID` header: a client that loses an SSE stream reconnects with the ID of the last event it consumed, and the server is expected to replay events after that ID. This is commonly read as a *transport-level* guarantee—\"the stream resumes where it left off.\" It is not. `Last-Event-ID` is a *...",
    "what_was_observed": "A three-replica MCP server fleet sat behind an L7 gateway with cookie-based session affinity. Each replica maintained an in-memory per-session event ring buffer (capacity 512 events) keyed by `Mcp-Session-Id`, and emitted monotonically increasing event IDs as decimal integers starting at 1 per session. The client was an agent runtime that had issued a long-running `tools/call` (a code-execution sandbox task), receive...",
    "condition_of_validity": "`Last-Event-ID` resumption is valid if and only if the following conjunction holds at the moment of reconnect: 1. The receiving replica shares the session's event log with the replica that produced the events (shared store, or sticky routing that survived the failover), **and** 2. The receiving replica can distinguish \"event ID 847 is unknown because it was ...",
    "decision_boundary": "The decision an MCP server implementation must make on a `GET /mcp` with `Last-Event-ID` is not \"replay or don't replay.\" It is a four-way branch, and only one branch is safe to answer with a silent 200: - **Session known, event ID within retained window:** replay from the ID. Safe. - **Session known, event ID older than retained window:** the server cannot ...",
    "operational_effect": "With the reject-on-unknown-session rule in place, the drained-replica failover produces an immediate `404`, the agent runtime re-runs `initialize`, and—critically—the agent's own task state machine sees a session reset and re-issues the `tools/call` it had in flight, or marks it failed deterministically. The 41-second silent hang becomes a sub-second, observ..."
  },
  "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": "79853c07506e2f919aa83c78231f1b1f99762bff52aeb843f5ef0504b4ccaac1",
    "verified_classes": [
      "SessionResumptionViolation",
      "McpSessionRegistry"
    ],
    "verified_functions": [
      "resume_or_fail",
      "__init__",
      "_lookup",
      "handle_stream_get",
      "append_event"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 7,
    "raised_exceptions": [
      "SessionResumptionViolation"
    ],
    "sample_fail_closed_invariants": [
      "missing Mcp-Session-Id on stream request"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
