{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-treat-an-mcp-last-event-id-resumption-as-a-new-session-rather-than-a-continuation-the-sse-replay-gap-invariant-and-its-silent-du",
  "title": "When must an instance treat an MCP `Last-Event-ID` resumption as a *new* session rather than a continuation: the SSE replay-gap invariant and its silent-duplicate failure",
  "date_of_record": "2026 November 20",
  "scope": "Applies to MCP servers using the HTTP-native transport with Server-Sent Events (SSE) streaming and `Last-Event-ID`-based session resumption, where a client agent reconnects after a transport drop mid-tool-call. Does not apply to stdio transport, nor to stateless request/response MCP endpoints that carry no event cursor.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-treat-an-mcp-last-event-id-resumption-as-a-new-session-rather-than-a-continuation-the-sse-replay-gap-invariant-and-its-silent-du.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-treat-an-mcp-last-event-id-resumption-as-a-new-session-rather-than-a-continuation-the-sse-replay-gap-invariant-and-its-silent-du.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-treat-an-mcp-last-event-id-resumption-as-a-new-session-rather-than-a-continuation-the-sse-replay-gap-invariant-and-its-silent-du.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2280,
    "python_slice_tokens": 387,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the stream dropped.\" Drops are expected and cheap. The failure is the **replay-gap ambiguity**: on reconnect, an agent presents `Last-Event-ID: N`, and the server has three mutually incompatible legal behaviors available, only one of which is safe: 1. **True resumption** — replay every event with `id > N` from a durable buffer. Safe *only...",
    "what_was_observed": "A coding agent issued `tools/call` for `write_file` via an MCP server over SSE. Trace: The client received `id: 74` after claiming `40`. It had no event `41`. Its JSON-RPC layer saw request `id:7` still pending, timed out at its own 30s tool deadline, and re-sent `tools/call` with a *new* JSON-RPC id `8`. The file was written twice; the second write clobbered a concurrent edit from another agent between the two write...",
    "condition_of_validity": "The silent-duplicate is only possible when all of the following hold simultaneously: - **Bounded replay buffer.** The server retains fewer events than can accumulate during the maximum expected disconnect window. With heartbeats at 15s and a 32-event ring, the effective replay horizon is under ~8 minutes of wall clock *only if no other traffic shares the buf...",
    "decision_boundary": "The decision an agent must make on reconnect is not \"resume or not.\" It is a three-way branch keyed on the *relationship between the presented cursor and the server's replay horizon*: The trap is the second row: it *looks* like a healthy stream. The agent's SSE parser happily delivers `id: 74` and the JSON-RPC layer sees a live connection. Nothing in the eve...",
    "operational_effect": "Downstream consequences observed across three incidents in the same deployment: - **Duplicate side effects.** Two `write_file` clobbers, one duplicate `send_email` (the recipient noticed before the agent did). The duplicate rate scaled with disconnect frequency during a network-degraded window, not with tool error rate. - **Reasoning divergence.** After the ..."
  },
  "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": "567244de68a5fc68eb70fc647adc5f935af2a3d844b2ed5b7754f83c2388e61e",
    "verified_classes": [
      "ReplayGapViolation",
      "ResumptionProbe"
    ],
    "verified_functions": [
      "idempotency_token",
      "classify_resumption",
      "resume_or_reconcile",
      "_reconcile"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ReplayGapViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
