{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-silent-event-loss-in-mcp-http-native-streaming-transports-with-resumable-sse-session-negotiation-for-stateless-agent-clients",
  "title": "Which invariants prevent silent event loss in MCP HTTP-native streaming transports with resumable SSE session negotiation for stateless agent clients",
  "date_of_record": "2026 November 16",
  "scope": "Applies to MCP servers exposing a Streamable HTTP transport where a stateless agent client (no persistent process memory between requests) negotiates a session via `Mcp-Session-Id`, receives server-to-client messages over an SSE stream, and may resume that stream using `Last-Event-ID` after a disconnect. Does not apply to stdio transports, to stateful clients that hold the stream open in-process, or to servers that do not implement event IDs on the SSE channel.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-event-loss-in-mcp-http-native-streaming-transports-with-resumable-sse-session-negotiation-for-stateless-agent-clients.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-event-loss-in-mcp-http-native-streaming-transports-with-resumable-sse-session-negotiation-for-stateless-agent-clients.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-event-loss-in-mcp-http-native-streaming-transports-with-resumable-sse-session-negotiation-for-stateless-agent-clients.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1602,
    "python_slice_tokens": 352,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *transport-level resumption* and *logical-level replay*. `Last-Event-ID` resumption guarantees only that the server will resume the byte stream after a given event ID; it does **not** guarantee that the event ID the client holds corresponds to the last message the client actually *processed*. A stateless agent client t...",
    "what_was_observed": "In a deployment where an MCP server kept a per-session ring buffer of 1,024 events for resumption, a stateless agent client performing long-running tool orchestration persisted `Last-Event-ID` on every received event. During a 40-second pause while the client executed a local tool, the server emitted 1,300 low-priority progress notifications into the same session buffer. On reconnect, the client sent `Last-Event-ID: ...",
    "condition_of_validity": "The invariant \"a resumed SSE stream is a superset of the client's processed state\" holds only when all of the following are true: 1. The server retains every event from the client's `Last-Event-ID` forward, unbounded or for a retention window that provably exceeds the client's maximum disconnect-plus-processing pause. 2. The server, on receiving a `Last-Even...",
    "decision_boundary": "The operational decision is: **when a stateless client reconnects with an event ID the server cannot honor, the server must choose explicit failure over implicit truncation.** The boundary is crossed the moment the server can detect that the requested ID no longer exists in its buffer. Below that boundary (ID still retained), resumption is safe and should pr...",
    "operational_effect": "Enforcing the invariant changes the failure mode from *silent data loss detected hours later* to *a recoverable `ResumeGapError` at reconnect time*. The client's reconnect handler becomes: attempt resume; on gap, discard the session ID, negotiate a new session, and re-hydrate state from the tool-result snapshot or by re-invoking idempotent tools. The cost is..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION"
  ],
  "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": "2e494e3d7a5fe8277a0b12dd90a01896017b8b6861701fffa8dc13a675f68dfe",
    "verified_classes": [
      "ResumeGapError",
      "SessionBuffer"
    ],
    "verified_functions": [
      "negotiate_resume",
      "handle_streamable_http_reconnect",
      "can_resume_from"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ResumeGapError"
    ],
    "sample_fail_closed_invariants": [
      "missing Mcp-Session-Id on reconnect"
    ],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
