{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-replays-an-mcp-sse-stream-against-a-session-affinity-router-that-has-already-rebalanced-the-session",
  "title": "What happens when an instance replays an MCP SSE stream against a session-affinity router that has already rebalanced the session",
  "date_of_record": "2026 November 26",
  "scope": "Applies to MCP servers exposing HTTP-native transport with `text/event-stream` responses, `Last-Event-ID` resumption, and a load balancer enforcing session affinity keyed on the `Mcp-Session-Id` header. Does not apply to stdio transports, to stateless JSON-RPC-over-HTTP without SSE, or to deployments where session state is externally materialized (e.g., Redis-backed event logs shared across replicas).",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-replays-an-mcp-sse-stream-against-a-session-affinity-router-that-has-already-rebalanced-the-session.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-replays-an-mcp-sse-stream-against-a-session-affinity-router-that-has-already-rebalanced-the-session.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-replays-an-mcp-sse-stream-against-a-session-affinity-router-that-has-already-rebalanced-the-session.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2066,
    "python_slice_tokens": 336,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the SSE connection dropped.\" Disconnects are routine and the protocol explicitly anticipates them: the client reconnects with `Last-Event-ID`, the server replays from its per-session event log, and the stream continues. The failure is a **resumption that succeeds at the transport layer while silently violating session continuity at the se...",
    "what_was_observed": "A long-running agent task (a multi-step code-migration workflow) held an MCP session against a 4-replica deployment behind an L7 router with cookie-and-header affinity. The stream had been idle for 90 seconds (server sent keepalive comments every 15s, so no idle timeout on the client side). At T+91s the router's health check marked replica-2 as degraded due to a GC pause exceeding the probe threshold, and the router ...",
    "condition_of_validity": "This failure requires the conjunction of four conditions. Remove any one and the mode does not occur: 1. **Process-local session and event-log state.** If event logs are externalized (shared store keyed by session ID), replica-3 can serve the replay correctly regardless of affinity. The failure is specific to in-memory session stores. 2. **Lazy session initi...",
    "decision_boundary": "The architectural decision is where to place the continuity check. Three viable boundaries, in increasing cost: - **Router-side:** Bind affinity to the session ID for the lifetime of the SSE stream, and on drain, hold the affinity entry until the stream closes and a configurable grace window (≥ client reconnect backoff) elapses. This prevents the rebalance-d...",
    "operational_effect": "When the boundary is correctly placed, an affinity miss during resumption produces a `404 Mcp-Session-Expired`, the MCP client surfaces a `SessionDiscontinuity` error to the agent, and the agent's checkpoint/resume logic (which should already exist for cold-start amnesia) restarts the task from its last durable checkpoint rather than from a corrupted in-memo..."
  },
  "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": "2450547888d613c1a0259dfc7a3255304060e82802b84425d8bd220da9b242a6",
    "verified_classes": [
      "SessionDiscontinuity",
      "ReplayEvent"
    ],
    "verified_functions": [
      "validate_resumption",
      "resume_session",
      "payload_hash"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SessionDiscontinuity"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
