{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-resume-an-mcp-stream-against-a-session-token-whose-event-history-has-already-been-compacted",
  "title": "Why does an instance resume an MCP stream against a session token whose event history has already been compacted?",
  "date_of_record": "2026 November 29",
  "scope": "Applies to MCP servers migrating from the legacy HTTP+SSE transport to streamable HTTP with `Mcp-Session-Id` and `Last-Event-ID` resumption. Does not apply to stdio transport, nor to stateless streamable-HTTP deployments that never issue session IDs.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-resume-an-mcp-stream-against-a-session-token-whose-event-history-has-already-been-compacted.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-resume-an-mcp-stream-against-a-session-token-whose-event-history-has-already-been-compacted.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-resume-an-mcp-stream-against-a-session-token-whose-event-history-has-already-been-compacted.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2057,
    "python_slice_tokens": 243,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The legacy SSE transport and the streamable-HTTP transport both carry a session identifier, but they assign it *different semantics of continuity*. In legacy HTTP+SSE, the session ID is a **connection-scoped handle**. It names a live SSE channel bound to one open `GET /sse` response. If the channel dies, the session dies with it; a reconnect opens a new chan...",
    "what_was_observed": "A single-node MCP server was migrated from SSE to streamable HTTP. The server retained per-session event history in a ring buffer keyed by `Mcp-Session-Id`, each event stamped with a monotonic `id`. To bound memory, the buffer evicted events older than the last 512 entries per session, advancing a per-session `compaction_watermark` (the highest evicted event ID). Sessions themselves were retained for 30 minutes past ...",
    "condition_of_validity": "The invariant the transport layer *must* enforce, and which the naive migration violates: > A resumption request whose `Last-Event-ID` is strictly less than the session's `compaction_watermark` MUST be rejected as unrecoverable, not silently clamped to the watermark. This is a **continuity invariant**, and it is violated by the single most natural line of co...",
    "decision_boundary": "The operational fork is: **when a resumption cursor precedes the compaction watermark, does the server (a) clamp and continue, (b) terminate the session and force re-initialization, or (c) reject the resume with an explicit unrecoverable-gap signal?** - **(a) Clamp** is only safe if the protocol guarantees that no event the client needs for correctness can b...",
    "operational_effect": "An agent operating across this boundary must treat a resumed stream as **untrusted continuity** until it has verified the gap. The practical guardrail is a client-side sequence check: the agent records the highest `Last-Event-ID` it has *durably* processed (not merely parsed), and on resume asserts that the first event received has `id == last_processed + 1`..."
  },
  "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": "47639f4815168715a2f237b2c057801913e79cf65451ee1dfc1075b10d2e3cac",
    "verified_classes": [
      "UnrecoverableGap",
      "SessionLog"
    ],
    "verified_functions": [
      "resume_stream",
      "handle_resume"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "UnrecoverableGap"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
