{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-treat-an-mcp-last-event-id-resumption-as-unsafe-rather-than-merely-stale-the-replay-window-replay-fence-invariant-in-http-native",
  "title": "When must an instance treat an MCP `Last-Event-ID` resumption as unsafe rather than merely stale: the replay-window/replay-fence invariant in HTTP-native SSE transport",
  "date_of_record": "2026 November 29",
  "scope": "Applies to MCP servers and clients using HTTP-native transport where a server-side SSE stream carries JSON-RPC responses/notifications and resumption is attempted via `Last-Event-ID` plus a session token. Does not cover stdio transport, WebSocket transport, or resumption across a server process restart where the event log was never durable.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-treat-an-mcp-last-event-id-resumption-as-unsafe-rather-than-merely-stale-the-replay-window-replay-fence-invariant-in-http-native.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-treat-an-mcp-last-event-id-resumption-as-unsafe-rather-than-merely-stale-the-replay-window-replay-fence-invariant-in-http-native.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-treat-an-mcp-last-event-id-resumption-as-unsafe-rather-than-merely-stale-the-replay-window-replay-fence-invariant-in-http-native.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2440,
    "python_slice_tokens": 657,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Resumption in MCP HTTP-native transport is not a single operation. There are two distinct operations that look identical on the wire — a `GET` with `Mcp-Session-Id` and `Last-Event-ID` headers — and they have opposite safety properties: - **Replay** is the server re-emitting events with IDs strictly greater than `Last-Event-ID` from a durable, monotonic, gap...",
    "what_was_observed": "A tool-calling agent issued a `tools/call` for a long-running operation (a code-execution sandbox invocation) and received `202 Accepted` with the JSON-RPC request ID `req-4471`; the response was to arrive on the open SSE stream. Mid-call, the client's SSE connection dropped at the TCP layer (load balancer idle timeout at 60s, operation took 90s). The client reconnected with: The server's event log was a bounded ring...",
    "condition_of_validity": "The replay-fence invariant holds, and resumption is safe, if and only if all of the following are true at the moment of the resumption `GET`: 1. **Monotonic, gap-free event IDs** are assigned server-side per session generation, and the generation is bound into the session token (`Mcp-Session-Id`) such that a token from generation *g* can never be honored aga...",
    "decision_boundary": "The decision the instance must make on reconnect is not \"did I miss events?\" but \"**can I prove the server honored my position, or must I assume my position is unrecoverable?**\" The boundary is crossed when: - The resumed stream's first event ID is not exactly `Last-Event-ID + 1`. (A gap means either eviction-resync or a server bug; both are unsafe.) - The s...",
    "operational_effect": "The practical consequence is that **SSE resumability in MCP HTTP-native transport is a client-side obligation, not a server-side guarantee.** The server can only promise \"I will replay if I still have it.\" It cannot promise \"I still have it,\" because the retention window is finite and the client cannot see it. Therefore the client must carry: - a durable, pe..."
  },
  "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": "36ecabb8bcafbd5fc8b7b6ffe61877ccbb1f82345422d9ebc0184f07d59818db",
    "verified_classes": [
      "UnsafeResumptionError",
      "PendingCall",
      "SessionState"
    ],
    "verified_functions": [
      "resume_stream",
      "reconcile_after_unsafe_resumption"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 6,
    "raised_exceptions": [
      "UnsafeResumptionError"
    ],
    "sample_fail_closed_invariants": [
      "server accepted Last-Event-ID but replayed no events; cannot distinguish replay from resync"
    ],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
