{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-sse-event-id-reuse-from-silently-corrupting-resumable-mcp-sessions-across-server-restarts",
  "title": "Which invariants prevent SSE event-ID reuse from silently corrupting resumable MCP sessions across server restarts",
  "date_of_record": "2026 December 2",
  "scope": "Applies to MCP servers using the HTTP-native transport with `text/event-stream` responses, `Last-Event-ID`-based resumability, and opaque session tokens bound to a `Mcp-Session-Id`. Does not apply to stdio transport, to stateless SSE streams without resumption, or to WebSocket-based transports where the framing layer handles replay ordering.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-event-id-reuse-from-silently-corrupting-resumable-mcp-sessions-across-server-restarts.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-event-id-reuse-from-silently-corrupting-resumable-mcp-sessions-across-server-restarts.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-sse-event-id-reuse-from-silently-corrupting-resumable-mcp-sessions-across-server-restarts.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2481,
    "python_slice_tokens": 548,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two distinct notions of \"the same event\" in a streamable MCP session, and conflating them is the failure. The first is **positional**: the `id:` field on an SSE frame is a monotonic cursor into a stream that the client uses to say \"resume after this point.\" The second is **semantic**: the JSON-RPC message carried in the `data:` field is a specific ...",
    "what_was_observed": "A long-running agent (a code-review orchestrator) held an MCP session against a filesystem-plus-git server. The server emitted SSE frames with `id:` values from a per-process `itertools.count()`. Mid-task, the server process was restarted by a supervisor after an OOM. The new process bound the same port, accepted the same `Mcp-Session-Id` (session records were persisted in a small on-disk store keyed by the token, bu...",
    "condition_of_validity": "`Last-Event-ID` resumption is a valid recovery primitive only when all of the following hold simultaneously: 1. **Cursor monotonicity is session-scoped, not process-scoped.** Event IDs must be derived from a counter that survives process restart — either persisted, or derived from a durable log offset (e.g., a database sequence, a file byte offset, a Kafka o...",
    "decision_boundary": "The boundary is not \"should we support resumption\" — that is a product decision. The boundary is **what the server does when it cannot honor a `Last-Event-ID`**. There are exactly three correct behaviors, and one common incorrect one: - **Correct — replay from durable log:** the requested range exists; emit it, then continue live. The cursor remains meaningf...",
    "operational_effect": "The practical consequence is that **resumability is a durability property of the event log, not a property of the SSE framing**. Teams routinely implement SSE resumption as a transport feature — parse `Last-Event-ID`, keep a ring buffer of recent frames in memory, replay on reconnect — and this is correct for transient network blips within a process lifetime..."
  },
  "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": "9198126a775b44a50e2dc5c7b38e744b85b28b2773dd0175eedf28f5bae06790",
    "verified_classes": [
      "ResumeIncoherentError",
      "ResumeDecision"
    ],
    "verified_functions": [
      "evaluate_resume",
      "client_accept_resumed_frame"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ResumeIncoherentError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
