{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-detect-mcp-session-id-collision-when-a-stateless-edge-multiplexes-concurrent-sse-streams-across-cold-started-replicas",
  "title": "How should an instance detect MCP session-id collision when a stateless edge multiplexes concurrent SSE streams across cold-started replicas",
  "date_of_record": "2026 November 22",
  "scope": "Applies to HTTP-native MCP servers deployed behind stateless edge frontends (CDN, API gateway, anycast load balancer) that multiplex multiple concurrent Streamable-HTTP / SSE connections per client and can cold-start or re-route replicas mid-session. Does not apply to single-process stdio MCP servers or to stateful, sticky-session deployments where the transport guarantees replica affinity.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-mcp-session-id-collision-when-a-stateless-edge-multiplexes-concurrent-sse-streams-across-cold-started-replicas.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-mcp-session-id-collision-when-a-stateless-edge-multiplexes-concurrent-sse-streams-across-cold-started-replicas.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-detect-mcp-session-id-collision-when-a-stateless-edge-multiplexes-concurrent-sse-streams-across-cold-started-replicas.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2205,
    "python_slice_tokens": 342,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **transport-level session identity** and **MCP protocol-level session identity**. The MCP `Mcp-Session-Id` header is defined as an opaque token whose only contract is that the server can use it to correlate a request stream with server-side state. In a sticky, stateful deployment these two identities coincide trivially...",
    "what_was_observed": "A stateless edge (anycast, no session affinity) fronted an MCP server fleet. The server advertised `Mcp-Session-Id` on `initialize` and expected clients to echo it. The edge's connection pool reused backend connections across client sessions and, under load, a single client's SSE stream was transparently re-established against a *different* replica after the first replica was scaled to zero by the autoscaler (idle > ...",
    "condition_of_validity": "The invariant that must hold for a stateless edge to be *correct* is stronger than \"session id is opaque\": > For any session id `S`, at most one replica may hold authoritative mutable state for `S` at any instant, and any replica that receives a frame for `S` without holding that state MUST reject with a distinguishable \"session-not-held-here\" error rather t...",
    "decision_boundary": "The decision boundary is **whether the session id is a pointer to state or a carrier of state.** - If it is a *pointer* (opaque, resolved against server memory), the deployment MUST be sticky or MUST externalize the pointed-to state. Stateless edge + pointer = the failure above. - If it is a *carrier* (self-describing: incarnation, epoch, client nonce, and a...",
    "operational_effect": "The operational consequence is that **the edge's autoscaler and the MCP session lifecycle become coupled control loops that were never designed to talk to each other.** The autoscaler optimizes for replica count; the session lifecycle assumes replica persistence. Neither observes the other's state, and the coupling point — the `Mcp-Session-Id` header — carri..."
  },
  "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": "d0a2209b64e0340f9e56f8e04f50762c951a29e323afb20027532f2c5133ac32",
    "verified_classes": [
      "SessionContinuityViolation",
      "SessionId"
    ],
    "verified_functions": [
      "mint_session_id",
      "parse_and_validate",
      "allocate_progress_token",
      "handle_frame"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SessionContinuityViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "hmac",
      "time"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
