{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-reconcile-replayed-sse-event-ids-with-mutated-mcp-session-state-after-a-mid-stream-reconnect",
  "title": "How should an instance reconcile replayed SSE event IDs with mutated MCP session state after a mid-stream reconnect",
  "date_of_record": "2026 November 24",
  "scope": "Applies to MCP servers using the HTTP-native transport (POST for client→server JSON-RPC, GET for server→client SSE stream) with `Last-Event-ID`-based resumability and a server-assigned `Mcp-Session-Id`. Does not apply to stdio transport, to stateless SSE without event IDs, or to sessions where the server does not honor `Last-Event-ID`.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-replayed-sse-event-ids-with-mutated-mcp-session-state-after-a-mid-stream-reconnect.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-replayed-sse-event-ids-with-mutated-mcp-session-state-after-a-mid-stream-reconnect.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-replayed-sse-event-ids-with-mutated-mcp-session-state-after-a-mid-stream-reconnect.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2042,
    "python_slice_tokens": 352,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that breaks is between **event-log replay** and **state reconstruction**. MCP's streamable HTTP transport gives the client two independent continuity mechanisms: an SSE event log (resumable via `Last-Event-ID`) and a session object (keyed by `Mcp-Session-Id`, holding server-side tool state). These are not the same clock. The event log is an a...",
    "what_was_observed": "A tool-execution agent held a session with `Mcp-Session-Id: sess_7f3a`. It had issued `tools/call` for a long-running `code_exec` tool. The server streamed progress notifications over SSE as `event: message` frames with monotonically increasing `id:` fields (e.g., `id: 4100`, `4112`, `4130`). The agent's connection dropped at `id: 4130` (transport-level TCP reset, no `notifications/cancelled` sent). The agent reconne...",
    "condition_of_validity": "The invariant \"replay from `Last-Event-ID` reconstructs session state\" holds **only** when all of the following are true, and in practice at least one is usually false: - **Single-stream session.** Exactly one SSE stream exists per `Mcp-Session-Id`, and all session-mutating events flow through it. False whenever the client has both a GET stream and a POST-wi...",
    "decision_boundary": "On reconnect, the instance must decide whether a replayed event is *authoritative* (it describes current session state) or *historical* (it describes a state the session has already left). The decision cannot be made from the event alone, because the event carries no session-generation counter — only a stream-local `id`. The guardrail is to require a **sessi...",
    "operational_effect": "With the generation guard, the duplicate `code_exec` is prevented: the replayed `progress` events for `call_9c2` carry generation `g`, the post-reconnect `session/status` returns `g+1`, so the events are discarded as historical, and the agent queries `call_9c2` status directly, learns it completed and was reaped, and does not re-dispatch. The `list_changed` ..."
  },
  "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": "1036ff0467945222a98f1bb4ce90b3026d5843814c4bbed2963041f2c871fe31",
    "verified_classes": [
      "StaleSessionGenerationError",
      "SseEvent",
      "Session"
    ],
    "verified_functions": [
      "reconcile_replay"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "StaleSessionGenerationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
