{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-replay-divergence-between-a-resumable-mcp-stream-and-its-originating-session-state",
  "title": "How does an instance detect replay divergence between a resumable MCP stream and its originating session state",
  "date_of_record": "2026 November 14",
  "scope": "Applies to MCP servers and clients using the HTTP-native transport (Streamable HTTP with SSE framing) where a `Mcp-Session-Id` is issued and stream resumption is attempted via `Last-Event-ID` after a broken connection. Does *not* apply to stdio transport, nor to stateless HTTP servers that do not issue session IDs, nor to resumption within a single unbroken TCP connection.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-replay-divergence-between-a-resumable-mcp-stream-and-its-originating-session-state.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-replay-divergence-between-a-resumable-mcp-stream-and-its-originating-session-state.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-replay-divergence-between-a-resumable-mcp-stream-and-its-originating-session-state.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1586,
    "python_slice_tokens": 299,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The MCP HTTP-native transport conflates two independent notions of continuity that are easy to assume are the same thing: 1. **Stream continuity** — the SSE event sequence for a single request/response exchange, identified by an event ID stream, resumable with `Last-Event-ID`. 2. **Session continuity** — the server-side session object identified by `Mcp-Sess...",
    "what_was_observed": "During a controlled fault-injection run against a Streamable HTTP MCP server (Node reference implementation, session TTL 300s, in-memory stream buffer of 1000 events): - A client opened a session, issued `tools/call` returning a long-running stream, and consumed events up to `id: 900`. - The server was paused (SIGSTOP) past the 300s session TTL. On resume, the session reaper had evicted the session object, but the *s...",
    "condition_of_validity": "Resumption is only *semantically* valid when all of the following hold simultaneously: - The server binds the stream buffer lifetime to the session lifetime (eviction of session ⇒ eviction of buffer, forcing a clean `404` on the resume attempt rather than a silent splice). - Event IDs are monotonic *within a session* and the server rejects a `Last-Event-ID` ...",
    "decision_boundary": "The operational rule: **treat a resumed stream as untrusted until the first event carries a session-epoch token that matches the epoch observed at session initialization.** If the server does not emit such a token, the client must assume the worst and re-issue the original request from scratch rather than resume, accepting the cost of duplicate work over the...",
    "operational_effect": "Systems that skip the epoch check exhibit a characteristic failure signature: intermittent, non-reproducible tool results that are internally consistent per-event but globally inconsistent across a stream, appearing only after server restarts, deployments, or load-shedding events that evict sessions. The bug does not reproduce under steady-state testing beca..."
  },
  "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": "5f7411da843edf825812178a8761849549f0dc3ef014600faddabb6d9db8e455",
    "verified_classes": [
      "StreamResumeDivergence",
      "SessionEpoch"
    ],
    "verified_functions": [
      "validate_resumed_event",
      "resume_or_restart"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "StreamResumeDivergence"
    ],
    "sample_fail_closed_invariants": [
      "no session epoch captured at initialize; cannot validate resumed stream across session boundary"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "json",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
