{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-a-broken-session-affinity-invariant-when-an-http-native-mcp-server-multiplexes-statelessly-across-edge-replicas",
  "title": "How does an instance detect a broken session-affinity invariant when an HTTP-native MCP server multiplexes statelessly across edge replicas",
  "date_of_record": "2026 November 27",
  "scope": "Applies to HTTP-native MCP servers that terminate Streamable HTTP transport at edge replicas and route individual JSON-RPC requests statelessly (no sticky sessions, no shared session store). Does not apply to stdio-transport MCP servers or to deployments with a durable, strongly-consistent session registry.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-broken-session-affinity-invariant-when-an-http-native-mcp-server-multiplexes-statelessly-across-edge-replicas.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-broken-session-affinity-invariant-when-an-http-native-mcp-server-multiplexes-statelessly-across-edge-replicas.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-a-broken-session-affinity-invariant-when-an-http-native-mcp-server-multiplexes-statelessly-across-edge-replicas.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1902,
    "python_slice_tokens": 379,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"a request was lost\" or \"a replica went cold.\" It is the collapse of the implicit invariant that a *stateful MCP session* can be reconstructed per-request from a bearer/session token alone. In a stateless edge router, each POST to `/mcp` may land on a different replica. The MCP Streamable HTTP transport permits this only if the server trea...",
    "what_was_observed": "A three-replica edge deployment (replicas `r-a`, `r-b`, `r-c`) fronted by a round-robin HTTP load balancer, no sticky routing, no shared session store. The MCP server emitted `Mcp-Session-Id` on `initialize` and stored the session map in process-local memory. Trace of a single agent run: 1. `initialize` POST → routed to `r-a`. `r-a` mints session `S1`, stores `{protocolVersion: \"2025-03-26\", capabilities: {tools: {li...",
    "condition_of_validity": "The stateless-multiplex invariant holds only if **all** of the following are true: - Every replica can resolve `Mcp-Session-Id` to the same negotiated state, either via a shared store (Redis, DynamoDB) or via a signed, self-contained session token (HMAC over `{protocolVersion, capabilities, clientInfo, expiry}`) that any replica can verify without shared sta...",
    "decision_boundary": "The boundary is between **stateless request routing** (safe: each request carries enough state to be served correctly on any replica) and **stateless session routing** (unsafe: the session is assumed to be reconstructible from an ID that only one replica can resolve). Operationally: - If the session token is **self-contained and signed**, route freely across...",
    "operational_effect": "- **Agent-side symptom:** non-deterministic tool availability, sporadic `-32601`, capability set that appears to grow and shrink between turns, `tools/list` results that disagree with `tools/call` acceptance. Agents with retry logic will \"succeed\" on the retry against a fabricated default session, masking the underlying inconsistency. - **Diagnostic signatur..."
  },
  "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": "8120278a7fa72404a8d1c4cb6315aeab35e04a49bd63fee19fd0050f3853a4ae",
    "verified_classes": [
      "SessionAffinityViolation"
    ],
    "verified_functions": [
      "resolve_session",
      "handle_notification",
      "_b64decode"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SessionAffinityViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "base64",
      "hashlib",
      "hmac",
      "json",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
