{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-silent-tool-call-replay-divergence-when-an-mcp-stream-is-resumed-across-an-http-session-re-bind",
  "title": "Which invariants prevent silent tool-call replay divergence when an MCP stream is resumed across an HTTP session re-bind",
  "date_of_record": "2026 November 23",
  "scope": "Applies to MCP servers exposing tool calls over HTTP-native transport with `Last-Event-ID` stream resumption (SSE) and session re-binding via `Mcp-Session-Id`, where the agent client is stateless per-call and the server keeps per-session replay buffers. Does not apply to stdio transport, nor to purely idempotent read-only tools with no server-side side effects.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-tool-call-replay-divergence-when-an-mcp-stream-is-resumed-across-an-http-session-re-bind.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-tool-call-replay-divergence-when-an-mcp-stream-is-resumed-across-an-http-session-re-bind.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-tool-call-replay-divergence-when-an-mcp-stream-is-resumed-across-an-http-session-re-bind.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1799,
    "python_slice_tokens": 234,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the connection dropped.\" The failure is that a resumed stream and a re-bound session are two *independent* recovery mechanisms that each restore a different half of the state, and nothing in the MCP transport layer forces them to agree. `Last-Event-ID` restores the *event cursor* (which `tools/call` responses the client has not yet consum...",
    "what_was_observed": "A stateless agent client issues `tools/call` for a side-effecting tool (`append_ledger_entry`) and receives the response as an SSE event with `id: 41`. The TCP connection dies mid-stream, *after* the server has already committed the side effect and emitted event 41, but *before* the client's read loop has acknowledged it. The client's retry wrapper does two things in the wrong order: 1. It opens a new connection and ...",
    "condition_of_validity": "Stream resumption is only sound under a conjunction of conditions that the transport must enforce, not assume: 1. **Cursor–buffer binding:** the server must reject any `Last-Event-ID` whose originating session id does not match the presented `Mcp-Session-Id`. The cursor is opaque but must be *scoped*; treat it as `(session_id, seq)` internally even if the wi...",
    "decision_boundary": "The operational decision is how the client should behave on reconnect, and it hinges on whether the cursor and session can be proven to belong together: - **If the client can present the original session id and the server still holds that session's buffer:** resume with `Last-Event-ID` and *do not* re-send the request body. This is the only safe replay path....",
    "operational_effect": "When the pairing invariant is enforced, the failure mode degrades from silent divergence to a loud, recoverable error: the client gets a `SessionCursorMismatch`, discards the stale cursor, and re-issues with idempotency — at worst one duplicate-suppressed retry, never a double effect or a phantom hang. When it is not enforced, agents exhibit a characteristic..."
  },
  "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": "d9afa068d877e8527f99f8b6543d245178722faf5c8accc7a25ed63ca034a5ec",
    "verified_classes": [
      "SessionCursorMismatch",
      "ReplayBuffer"
    ],
    "verified_functions": [
      "__init__",
      "mint_cursor",
      "resume"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SessionCursorMismatch"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
