{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-sse-to-post-upgrade-negotiation-from-silently-orphaning-a-resumable-mcp-session",
  "title": "Which invariants prevent SSE-to-POST upgrade negotiation from silently orphaning a resumable MCP session",
  "date_of_record": "2026 November 29",
  "scope": "Applies to MCP servers and clients using the HTTP-native transport with streamable sessions, where a client may resume an interrupted SSE event stream by replaying the last observed event ID via a POST request. Does not apply to stdio transport, nor to stateless HTTP request/response servers that do not advertise `Last-Event-ID` resumability.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-to-post-upgrade-negotiation-from-silently-orphaning-a-resumable-mcp-session.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-to-post-upgrade-negotiation-from-silently-orphaning-a-resumable-mcp-session.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-to-post-upgrade-negotiation-from-silently-orphaning-a-resumable-mcp-session.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2808,
    "python_slice_tokens": 622,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the connection dropped.\" Connections drop constantly and the protocol is designed for it. The failure is a **negotiation skew between the two halves of the streamable transport**: the SSE leg (server→client, carrying server-initiated notifications and the response continuation) and the POST leg (client→server, carrying the client's tool-c...",
    "what_was_observed": "A streamable-session server (event log retention: 512 events or 5 minutes, whichever is longer) fronted by a load balancer with a 60-second idle timeout on SSE connections. A client agent executed a multi-step tool sequence: `search → fetch → synthesize`. Each step is a POST; each POST returns `202 Accepted` with a `Mcp-Session-Id` header and the actual result arrives as an SSE `event: message` frame on the long-live...",
    "condition_of_validity": "The resume-via-POST path is valid **only if** the server's POST handler, upon receiving `Last-Event-ID`, does one of two things atomically: 1. **Re-binds the existing SSE stream** (same stream ID) to the session and replays the gap into it, returning the replay on the SSE leg and a bare `202` on the POST; or 2. **Rejects the POST resume** with `409 Conflict`...",
    "decision_boundary": "The boundary is between **resume-as-rebind** and **resume-as-replay-into-new-stream**. The former preserves the invariant; the latter breaks it silently. Concretely, the server's resume handler must decide, before touching the event log, whether the incoming request's leg matches the leg the client's reader is attached to. The client's reader is attached to ...",
    "operational_effect": "Without the leg-affinity guardrail, the observable effect is **latency amplification proportional to the number of interruptions, with a silent-success terminal state**. Each POST-leg resume opens one orphaned stream and advances the event log by the number of events the server had queued. The client's cursor does not advance (it never saw those events). The..."
  },
  "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": "972decc1dbfb6ee37501bae83f04c4575b74a645510e797752d828fd60311e4f",
    "verified_classes": [
      "OrphanedStreamError",
      "LegConflationError",
      "SessionState"
    ],
    "verified_functions": [
      "handle_resume_post",
      "client_resume",
      "simulate_two_interruptions"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 6,
    "raised_exceptions": [
      "LegConflationError",
      "OrphanedStreamError"
    ],
    "sample_fail_closed_invariants": [
      "assert r1['status'] == 202",
      "assert leg == 'GET'",
      "resume POST returned 200-with-body; replayed events are unreachable by the SSE reader. Discard body and re-issue as GET."
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
