{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-resume-an-mcp-stream-the-last-event-id-replay-divergence-boundary",
  "title": "When must an instance refuse to resume an MCP stream: the Last-Event-ID replay-divergence boundary",
  "date_of_record": "2026 November 30",
  "scope": "Applies to MCP servers/clients using the HTTP-native streaming transport (SSE over HTTP with `Last-Event-ID`-based resumption) where a client reconnects mid-stream after a dropped connection. Does not apply to stdio transport, nor to stateless request/response MCP calls that carry no resumable event log.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-resume-an-mcp-stream-the-last-event-id-replay-divergence-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-resume-an-mcp-stream-the-last-event-id-replay-divergence-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-resume-an-mcp-stream-the-last-event-id-replay-divergence-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1865,
    "python_slice_tokens": 449,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The tempting invariant is: *\"resumption is safe because the server replays every event with an ID greater than the client's `Last-Event-ID`.\"* This is false. Resumption is safe only if the server can prove that the **event log it is replaying from is the same logical stream generation** the client's `Last-Event-ID` was minted in. The non-obvious boundary is ...",
    "what_was_observed": "A long-running agent invoked an MCP tool (`db.migrate`) that streamed progress events `e1…e47`, then the terminal `e48` carrying `{status: \"ok\", applied: 47}`. The HTTP connection dropped between `e40` and `e41` (proxy idle timeout, 60s). The client reconnected with `Last-Event-ID: 40`. In the intervening 4 seconds, the MCP server process had been restarted by its supervisor (OOM kill on a sibling tool). The new proc...",
    "condition_of_validity": "`Last-Event-ID` resumption is valid **iff** the server can establish generation identity for the ID. Concretely, at least one of the following must hold: 1. **Generation-qualified IDs.** Event IDs are opaque tokens of the form `<generation>.<seq>` (e.g., `g7.40`), and the server rejects a `Last-Event-ID` whose generation does not match the current one with `...",
    "decision_boundary": "The boundary is the comparison between the client's `Last-Event-ID` and the server buffer's **minimum retained ID**, not its maximum. - If `last_event_id >= min_buffer_id - 1` **and** generation matches: replay `id > last_event_id`. Safe. - If `last_event_id < min_buffer_id - 1`: a gap exists in the retained log. The server cannot prove continuity. Must retu...",
    "operational_effect": "An agent that treats empty replay as clean resumption will, under server restart or buffer compaction, proceed with a stale or missing terminal event and act on it. The failure surfaces downstream — a `db.verify` against a half-migrated schema, a `file.write` that overwrites a result the agent thinks it read — and is attributed to the *downstream* tool, not ..."
  },
  "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": "c0e3b014c501422ede55c02910257c255d0f952c1c33e5cb469ffc82ef78e98e",
    "verified_classes": [
      "StreamResumptionDivergence",
      "Event",
      "ResumeRequest"
    ],
    "verified_functions": [
      "parse_token",
      "resume_stream",
      "token"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "StreamResumptionDivergence"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
