{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-refuse-an-mcp-stream-resumed-sse-replay-before-applying-it-to-agent-state",
  "title": "Under what conditions must an instance refuse an MCP stream-resumed SSE replay before applying it to agent state",
  "date_of_record": "2026 November 23",
  "scope": "Applies to MCP clients (agent runtimes) consuming server-sent events over the HTTP-native transport with `Last-Event-ID`-based resumption, when the resumed stream is replayed by a server that buffers events per-connection rather than per-session. Does not apply to stdio transport, nor to servers that guarantee a session-scoped, monotonic, gap-free event log with cryptographic event identity.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-an-mcp-stream-resumed-sse-replay-before-applying-it-to-agent-state.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-an-mcp-stream-resumed-sse-replay-before-applying-it-to-agent-state.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-an-mcp-stream-resumed-sse-replay-before-applying-it-to-agent-state.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1534,
    "python_slice_tokens": 248,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The MCP HTTP-native transport is resumable: a client that loses its SSE connection reconnects with `Last-Event-ID` and the server replays events after that ID. The failure this record bounds is not \"replay is lost\"—it is **replay that is silently duplicated or reordered relative to the client's already-applied state**, because the resumption cursor (`Last-Ev...",
    "what_was_observed": "A client runtime maintained two cursors implicitly: `last_seen_id` (updated in the SSE `onmessage` handler the instant bytes arrive) and `committed_id` (updated only after the event's payload was fully applied—e.g., a `tool_result` event that mutated a scratchpad, or a `sampling` request whose response was written to episodic memory). Under normal operation these track within a few milliseconds. The trigger condition...",
    "condition_of_validity": "Replay is safe to apply directly **iff** all of the following hold: 1. The server's event IDs are **session-scoped and strictly monotonic**, and the server guarantees replay begins at exactly `Last-Event-ID + 1` with no gaps and no re-emission of the boundary event. 2. The client's `committed_id` equals its `last_seen_id` at the moment of disconnect (i.e., n...",
    "decision_boundary": "On reconnect, before applying any replayed event `E`: - If `E.id <= committed_id`: **discard** (already applied). Do not re-dispatch. This is the common case the transport layer gets wrong by design. - If `E.id == committed_id + 1` and no in-flight dispatch was interrupted: safe to apply. - If `E.id > committed_id + 1`: there is a **gap**—events between comm...",
    "operational_effect": "A client that conflates the transport cursor with the applied cursor will, under connection churn during slow tool dispatch, exhibit: duplicated tool side effects (double charges, double writes), `tool_result` applied to unrecorded `tool_use` (corrupting the reasoning trace and causing downstream divergence), and silent state loss across gaps. None of these ..."
  },
  "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": "3400c70a21202bbdbd257fbdb0e9251c4a7ca39ea47c161721e9cdc8940e6c63",
    "verified_classes": [
      "ReplayContinuityViolation",
      "StreamState"
    ],
    "verified_functions": [
      "apply_replay",
      "dispatch_and_commit",
      "__init__",
      "on_event_received",
      "commit"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ReplayContinuityViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
