{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-sse-replay-corruption-when-mcp-http-native-streams-resume-under-backpressure",
  "title": "Which invariants prevent SSE replay corruption when MCP HTTP-native streams resume under backpressure",
  "date_of_record": "2026 November 25",
  "scope": "Applies to MCP servers/clients using the HTTP-native transport with Server-Sent Events and `Last-Event-ID`-based session resumption, where the server buffers outbound notifications while a client is slow or disconnected. Does not apply to stdio transport, or to SSE streams that are strictly fire-and-forget with no resumption contract.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-replay-corruption-when-mcp-http-native-streams-resume-under-backpressure.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-replay-corruption-when-mcp-http-native-streams-resume-under-backpressure.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-replay-corruption-when-mcp-http-native-streams-resume-under-backpressure.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1768,
    "python_slice_tokens": 313,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **transport-level resumption** and **protocol-level replay**. `Last-Event-ID` is an HTTP/SSE mechanism: the client says \"I last saw event id N, send me what came after.\" MCP's session semantics require that the *logical* notification stream (tool-list changes, progress notifications, log entries, sampling requests) be ...",
    "what_was_observed": "A tool-serving MCP server emitted a burst of `notifications/tools/list_changed` and `notifications/progress` frames to a client that had opened a long-lived SSE stream. The client's HTTP read loop stalled (TCP zero-window) for ~40s while a tool call was in flight. During the stall the server's per-session outbound queue grew, then the server applied backpressure by dropping the oldest queued frames to bound memory, a...",
    "condition_of_validity": "The invariant that would have prevented this is: **the resumption cursor must be a session-scoped monotonic sequence that is (a) never advanced past a frame the server is willing to forget, and (b) never accepted from the client without proof that the client actually consumed up to that cursor.** Two conditions must both hold for `Last-Event-ID` to be safe a...",
    "decision_boundary": "The boundary is between **clamping** and **failing**. A server under memory pressure has three options when the requested `Last-Event-ID` falls outside the retained window: - **Clamp** (replay from window start): corrupts ordering and multiplicity, as observed. Never correct. - **Drop** (replay from window end): loses frames silently. Never correct. - **Fail...",
    "operational_effect": "With the invariant enforced, the observable behavior changes in three ways: - **Backpressure propagates to the producer, not the stream.** A slow client stalls the tool-execution loop (or its notification emission), not the retention window. The cursor and the buffer stay coupled. - **Resumption is either exact or refused.** There is no third outcome. A clie..."
  },
  "matched_failure_symptoms": [
    "HTTP_429_BURST_STARVATION"
  ],
  "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": "dd3595e185e877b25083b2c34ec1a02a9ab77cdf2565b47f1b750e87abfdf30f",
    "verified_classes": [
      "ResumptionInvariantError",
      "OutboundBuffer"
    ],
    "verified_functions": [
      "handle_resume",
      "retain",
      "resume"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ResumptionInvariantError"
    ],
    "sample_fail_closed_invariants": [
      "resumption_unavailable: client must re-initialize and re-sync tools/list"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
