{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-that-an-mcp-resumable-stream-token-has-been-silently-rebound-to-a-different-session-affinity-shard",
  "title": "How does an instance detect that an MCP resumable stream token has been silently rebound to a different session-affinity shard",
  "date_of_record": "2026 November 25",
  "scope": "Applies to MCP clients resuming a long-running `tools/call` stream via a previously issued `Last-Event-ID`/resume token after the transport layer has rebalanced session affinity (rolling deploy, shard eviction, or connection-pool recycling). Does not apply to stateless request/response MCP calls, nor to single-process servers with no affinity layer in front of them.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-an-mcp-resumable-stream-token-has-been-silently-rebound-to-a-different-session-affinity-shard.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-an-mcp-resumable-stream-token-has-been-silently-rebound-to-a-different-session-affinity-shard.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-an-mcp-resumable-stream-token-has-been-silently-rebound-to-a-different-session-affinity-shard.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2389,
    "python_slice_tokens": 573,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two failure classes that look identical at the client's `resume` call but diverge completely in consequence: 1. **Token rejection** — the server *knows* the token is invalid and returns an error (e.g. `-32602`, or a 404/410 on the SSE endpoint). This is loud, cheap, and safe. 2. **Token acceptance with silent rebinding** — a *different* server inst...",
    "what_was_observed": "A long-running `tools/call` (a code-analysis tool emitting incremental `notifications/message` progress events over a streamable-HTTP MCP transport) was configured with a resume token scheme: token = `HMAC(session_id || stream_id || last_event_seq)`, plus a server-side map `stream_id -> ring buffer of events`. The buffer lived in process memory. A load balancer in front used a sticky cookie for session affinity. Duri...",
    "condition_of_validity": "The resumable-stream contract is only sound when **all three** of the following hold simultaneously. Drop any one and silent rebinding becomes possible: 1. **Buffer locality is guaranteed by affinity.** The resume token must route to the shard that owns the buffer. This requires the token (or the routing layer) to encode the *owning shard*, not merely the se...",
    "decision_boundary": "The boundary is between *resumable* and *replayable*, and it is decided by whether execution state is reconstructible off-shard: - If the tool execution is **idempotent and cheap to replay** (pure function, < a few seconds, no external side effects), the correct design is to *not* offer resumption at all — issue no resume token, and on disconnect the client ...",
    "operational_effect": "Once silent rebinding is possible, three second-order effects follow, each worse than the first: 1. **False completion propagates as ground truth.** A clean-close-on-empty is indistinguishable from a real finish, so the empty result enters the semantic memory / result store and is later retrieved as fact. The agent's episodic record now contains a completed ..."
  },
  "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": "70ba588188364d71fab46806c23c21f1299ca898cd47e93caa1ff091d8703ddf",
    "verified_classes": [
      "StreamContinuityError",
      "ResumeToken"
    ],
    "verified_functions": [
      "verify_resume",
      "emit_resumed_stream"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 7,
    "raised_exceptions": [
      "StreamContinuityError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "hmac"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
