{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-treat-an-sse-last-event-id-replay-as-authoritative-versus-re-derive-state-from-scratch-after-mcp-session-re-attachment",
  "title": "When must an instance treat an SSE `Last-Event-ID` replay as authoritative versus re-derive state from scratch after MCP session re-attachment",
  "date_of_record": "2026 November 26",
  "scope": "Applies to MCP servers/clients using HTTP-native streamable transport where a dropped SSE stream is resumed via `Last-Event-ID` and a logical session is re-attached across reconnects. Does not apply to single-shot request/response MCP over stdio, nor to stateless transports with no event ledger.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-treat-an-sse-last-event-id-replay-as-authoritative-versus-re-derive-state-from-scratch-after-mcp-session-re-attachment.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-treat-an-sse-last-event-id-replay-as-authoritative-versus-re-derive-state-from-scratch-after-mcp-session-re-attachment.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-treat-an-sse-last-event-id-replay-as-authoritative-versus-re-derive-state-from-scratch-after-mcp-session-re-attachment.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1818,
    "python_slice_tokens": 234,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The streamable MCP transport carries two distinct continuities that look identical on the wire but have different failure semantics: **transport continuity** (the byte/event position of the SSE stream, tracked by `Last-Event-ID`) and **logical session continuity** (the server-side state a session ID points at). Re-attachment restores the *pointer*, not neces...",
    "what_was_observed": "A client held an SSE stream open on a long-running tool invocation. The proxy between client and server enforced a 90-second idle timeout and dropped the connection mid-stream. The client reconnected with the same `Mcp-Session-Id` and `Last-Event-ID: 4471`. The server had, in the interim, evicted events 4472–4478 from its 64-event per-session ring buffer because a burst of unrelated tool-progress events pushed them o...",
    "condition_of_validity": "The invariant that makes `Last-Event-ID` resume safe is: **the server holds a contiguous, durably-ordered event history for the session spanning from the requested `Last-Event-ID` to the current head, and the client's state is a pure function of that event sequence.** This holds only when all of the following are true: 1. The event ledger is **contiguous** —...",
    "decision_boundary": "The server's resume handler must make an explicit decision at the moment of re-attachment, not infer it from ID comparison: - **Resume-eligible:** requested `Last-Event-ID` is within the retained contiguous range `[ledger.floor_id, ledger.head_id]`. Stream from `Last-Event-ID + 1`. Safe. - **Gap-detected:** requested ID is below `ledger.floor_id` (evicted) o...",
    "operational_effect": "Once the gap-signaling discipline is enforced, three downstream behaviors change: 1. **Idempotency keys become derivable.** Because the client either has the full event history (including the `tool_call` event carrying the idempotency key) or has explicitly re-derived state from a snapshot, it never issues a retry with a missing key. The double-execution cla..."
  },
  "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": "0e7255e08feae4bd5530fca4b2bad7b3447365b5c79d0015989d3cf332a17239",
    "verified_classes": [
      "ResumeGapError",
      "EventLedger"
    ],
    "verified_functions": [
      "handle_reattach",
      "__init__",
      "append",
      "resume_plan"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "ResumeGapError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
