{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-resumable-mcp-http-streams-from-replaying-a-tool-call-whose-side-effect-already-committed",
  "title": "Which invariants prevent resumable MCP HTTP streams from replaying a tool call whose side effect already committed",
  "date_of_record": "2026 November 30",
  "scope": "Applies to MCP servers exposing HTTP-native transports (SSE-framed JSON-RPC over `POST`/`GET` with `Last-Event-ID` resumption) where a client may reconnect mid-`tools/call` and re-issue the request. Does not apply to stdio transports, nor to stateless request/response MCP endpoints with no event log.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-resumable-mcp-http-streams-from-replaying-a-tool-call-whose-side-effect-already-committed.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-resumable-mcp-http-streams-from-replaying-a-tool-call-whose-side-effect-already-committed.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-resumable-mcp-http-streams-from-replaying-a-tool-call-whose-side-effect-already-committed.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1642,
    "python_slice_tokens": 430,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The resumption contract of an HTTP-native MCP stream is *transport-level*: `Last-Event-ID` tells the server \"resume the byte stream after event N.\" It says nothing about *effect-level* idempotency. The dangerous conflation is treating a transport replay as a semantic replay — assuming that because the server can re-send events from the log, the client can sa...",
    "what_was_observed": "An agent issued `tools/call` for `transfer_funds` (a mutating tool) with JSON-RPC `id: 4471`. The server executed the tool, committed the transfer, and began streaming progress events (`notifications/progress`) followed by the final `result`. The connection dropped after the progress notification (`id: 12`) but before the `result` event (`id: 13`) was flushed to the client. The client's SSE reader saw the socket clos...",
    "condition_of_validity": "The effect-once invariant holds **only if** the server maintains a durable, request-`id`-keyed record of committed executions, and the record is consulted *before* the tool body runs, and the record is written *atomically with* the side effect (or the side effect is itself idempotent under a client-supplied idempotency key). Absent any one of these, the foll...",
    "decision_boundary": "The correct decision, on reconnect, is **not** \"re-issue the call.\" It is: - If the client has a `Last-Event-ID` for the stream, reconnect and drain the stream to its terminal event for `id: 4471`. If the terminal `result` (or an `error`) arrives, the call is resolved — do not re-issue. - If the stream log has been truncated (server-side TTL expired, `Last-E...",
    "operational_effect": "Without the idempotency key on the request `id`, every mutating tool is a duplicate-effect hazard under any network flap, any client restart mid-call, any load-balancer timeout that severs the SSE stream after the tool committed. The probability is not small: it is the probability that a stream drops in the window between effect-commit and result-flush — whi..."
  },
  "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": "9a9aec7b1b4f2b2e0a2a097d985c018c3a32e1342cd22cecefa67d75b43c7ca4",
    "verified_classes": [
      "DuplicateEffectError",
      "ResumptionGapError",
      "CommittedEffect",
      "EffectOnceDispatcher"
    ],
    "verified_functions": [
      "handle_reconnect",
      "handle_duplicate_without_record",
      "__init__",
      "dispatch",
      "resume_stream"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "DuplicateEffectError",
      "ResumptionGapError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "threading",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
