{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-silent-event-loss-when-an-mcp-streamable-http-session-resumes-mid-flight-under-backpressure",
  "title": "Which invariants prevent silent event loss when an MCP streamable-HTTP session resumes mid-flight under backpressure",
  "date_of_record": "2026 December 1",
  "scope": "Applies to MCP servers exposing the streamable-HTTP transport (single POST endpoint, optional SSE upgrade, `Mcp-Session-Id` header, `Last-Event-ID` resumption) when a client reconnects after a transport drop while the server still holds unacknowledged events in flight. Does not apply to stdio transport, nor to stateless request/response MCP servers that never emit SSE event IDs.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-event-loss-when-an-mcp-streamable-http-session-resumes-mid-flight-under-backpressure.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-event-loss-when-an-mcp-streamable-http-session-resumes-mid-flight-under-backpressure.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-event-loss-when-an-mcp-streamable-http-session-resumes-mid-flight-under-backpressure.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1674,
    "python_slice_tokens": 170,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the connection dropped.\" It is the collision of two independent ordering systems: the **transport's** monotonic SSE `id:` sequence (per-session, server-assigned) and the **application's** tool-call/response correlation (per-request, client-assigned `id` in JSON-RPC). Resumption via `Last-Event-ID` only guarantees *transport* replay from a...",
    "what_was_observed": "A tool-calling agent issues `tools/call` for a long-running operation (e.g., a 40-second crawl). The server streams progress notifications as SSE events with sequential `id:` values. Mid-stream, TCP stalls (client's read loop blocked on a slow downstream consumer, or a proxy buffers). The server's write buffer fills. Observed trace, reproduced across three server implementations: 1. Server enqueues progress events `i...",
    "condition_of_validity": "The resumption contract is sound only if all four hold simultaneously: - **ID-at-enqueue:** every event receives its `id` at the instant it enters the durable buffer, before any write attempt. IDs are never reassigned on flush. - **Suffix retention:** the server retains every event from the oldest *unacknowledged* cursor forward. \"Unacknowledged\" must be def...",
    "decision_boundary": "The operating rule for an agent consuming a streamable-HTTP MCP session: - **Trust resumption only when the server advertises a resume-capable, gap-detecting contract** (e.g., a capability flag or a documented guarantee that resumed streams are contiguous or explicitly gap-flagged). Absent that, treat every reconnect as a **potential state discontinuity** an...",
    "operational_effect": "Without these invariants, agents exhibit a specific pathology: **progress amnesia that looks like success.** The agent reconnects, receives a valid stream, processes it, and reports task completion — while having silently skipped 10–20% of the intermediate events. Downstream, this manifests as: partial tool results treated as complete, state machines that \"c..."
  },
  "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": "773f2e5940ce59a77399a24eec5dd71e39e2c03a671799089bfbc29517a3ae84",
    "verified_classes": [
      "ResumptionContinuityError",
      "McpStreamResumer"
    ],
    "verified_functions": [
      "__init__",
      "validate_resume",
      "consume"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "ResumptionContinuityError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
