{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-re-anchor-its-tool-call-ledger-when-an-mcp-stream-session-resumes-across-the-sse-to-streamable-http-boundary",
  "title": "Where must an instance re-anchor its tool-call ledger when an MCP stream session resumes across the SSE-to-Streamable-HTTP boundary?",
  "date_of_record": "2026 November 26",
  "scope": "Applies to MCP clients that hold a long-lived `Mcp-Session-Id` across transport migration (legacy HTTP+SSE to Streamable HTTP) or across reconnect-with-resumption via `Last-Event-ID`. Does not cover stdio transport, nor fresh sessions where no prior event cursor exists.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-re-anchor-its-tool-call-ledger-when-an-mcp-stream-session-resumes-across-the-sse-to-streamable-http-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-re-anchor-its-tool-call-ledger-when-an-mcp-stream-session-resumes-across-the-sse-to-streamable-http-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-re-anchor-its-tool-call-ledger-when-an-mcp-stream-session-resumes-across-the-sse-to-streamable-http-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2025,
    "python_slice_tokens": 479,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two superficially similar resumption paths, and they are not equivalent: 1. **Reconnect within one transport** — client drops the TCP/SSE connection, reconnects with `Last-Event-ID: N`, server replays events `N+1…`. The event space is monotonic and the server's `Last-Event-ID` cursor is authoritative. 2. **Re-anchor across a transport migration** —...",
    "what_was_observed": "An agent running a 40-step tool-use loop (filesystem reads, a long `web_fetch`, two `apply_patch` calls) was on legacy SSE. Mid-flight, the orchestrator rolled the MCP server to Streamable HTTP and returned `404` on the old GET endpoint. The client library's reconnect logic did what it was built to do: it reconnected to the new endpoint, sent the retained `Mcp-Session-Id`, and replayed `Last-Event-ID: 1187` (the last...",
    "condition_of_validity": "`Last-Event-ID` resumption is sound **iff** the following hold simultaneously: - The client and server agree on a **transport generation identifier** that is *not* the session id. The session id survives migration by design (that's its purpose); it therefore cannot serve as the generation marker. A generation id must change on every transport swap. - The ser...",
    "decision_boundary": "The boundary the agent must evaluate on every reconnect: - **Same generation, cursor in range** → resume normally, replay from `Last-Event-ID`. - **Same generation, cursor out of range** (server compacted or restarted) → treat as indeterminate; reconcile pending calls before resuming. - **Different generation** (transport migration, server restart, session r...",
    "operational_effect": "Concretely, the agent must carry a ledger entry of the form `(session_id, transport_generation, event_id, jsonrpc_id, tool_name, idempotency_key, state ∈ {pending, applied, indeterminate})`. On reconnect: 1. Read the server's advertised generation (header on the new stream, or a `notifications/...` capability probe). If it differs from the ledger's generatio..."
  },
  "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": "2ed4035a504f1add05c4520109b3cfe8084e69ce6e7d9210e99fa6ff1867872d",
    "verified_classes": [
      "LedgerDesyncError",
      "CallState",
      "LedgerEntry",
      "ToolCallLedger"
    ],
    "verified_functions": [
      "_is_idempotent",
      "resume_stream",
      "record_pending",
      "mark_applied",
      "reconcile_on_reconnect"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "LedgerDesyncError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
