{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-resume-an-mcp-stream-after-a-last-event-id-gap-exceeds-the-server-s-replay-ring",
  "title": "When must an instance refuse to resume an MCP stream after a `Last-Event-ID` gap exceeds the server's replay ring",
  "date_of_record": "2026 November 27",
  "scope": "Applies to MCP servers exposing HTTP-native streaming transports (SSE / streamable HTTP) that advertise resumability via `Last-Event-ID` and a bounded server-side event replay buffer. Does not apply to stateless request/response MCP tool calls, nor to stdio transports where resumption is undefined.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-resume-an-mcp-stream-after-a-last-event-id-gap-exceeds-the-server-s-replay-ring.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-resume-an-mcp-stream-after-a-last-event-id-gap-exceeds-the-server-s-replay-ring.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-resume-an-mcp-stream-after-a-last-event-id-gap-exceeds-the-server-s-replay-ring.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1921,
    "python_slice_tokens": 361,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the SSE connection dropped.\" Connections drop constantly and that is the designed-for case. The failure is the *silent* resumption: the client reconnects with a `Last-Event-ID` that the server can no longer honor, the server accepts the reconnect, and the client treats the fresh stream as continuous with the old one. Two distinct conditio...",
    "what_was_observed": "An agent orchestrator held a long-lived MCP stream to a tool server for a multi-step task (a code-mutation workflow issuing `apply_patch` calls and awaiting `patch_applied` / `patch_conflict` events). The server used a 256-event ring with a 60-second TTL per event. During a 90-second stall on a downstream dependency, the client's read loop timed out and reconnected with `Last-Event-ID: 4417`. By then the ring had adv...",
    "condition_of_validity": "The guardrail below is valid only when all of the following hold; if any fails, the instance must escalate to full session re-establishment (re-`initialize`, re-fetch capabilities, re-issue idempotent state queries) rather than attempt resume: 1. The server advertises a resumption contract (an `event:` stream with `id:` fields and an explicit replay window, ...",
    "decision_boundary": "The decision the instance must make at reconnect is binary and must be made *before* processing any event body: - If `F == R + 1`: resume. Continue the existing state machine, retain `pending_patch`, retain dedupe set. - If `F > R + 1`: **refuse resume.** The gap `(R, F)` is unobservable. Any event in that window — a `patch_applied`, a `patch_conflict`, a `t...",
    "operational_effect": "With the guardrail enforced, the reconnect in the observed incident would have been classified as an unresumable gap at `F=4345`, `R=4417` (note `F < R` here — the server replayed *older* events, a second failure mode where the ring wrapped past the cursor). The instance would have: - Refused to process `4345` as a live event, recognized it as stale replay o..."
  },
  "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": "4b74dba485d17fd80ab531c9fd1e1814d453cb7e245d388babc10a18c7462b21",
    "verified_classes": [
      "StreamResumeViolation"
    ],
    "verified_functions": [
      "classify_reconnect",
      "resume_stream"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "StreamResumeViolation"
    ],
    "sample_fail_closed_invariants": [
      "server advertises no replay window; resume is undefined",
      "unresumable gap and server cannot answer idempotent state queries; full session re-establishment required"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
