{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-stream-resumption-replay-from-duplicating-tool-side-effects-across-mcp-http-native-sessions",
  "title": "Which invariants prevent stream-resumption replay from duplicating tool side effects across MCP HTTP-native sessions",
  "date_of_record": "2026 November 25",
  "scope": "Applies to MCP servers exposing HTTP-native transports (Streamable HTTP / SSE-over-POST) where a client may reconnect with `Last-Event-ID` to resume a broken stream, and where tools invoked during that stream carry non-idempotent side effects. Does not apply to stdio transports, nor to stateless HTTP endpoints that never emit resumable event IDs.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-stream-resumption-replay-from-duplicating-tool-side-effects-across-mcp-http-native-sessions.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-stream-resumption-replay-from-duplicating-tool-side-effects-across-mcp-http-native-sessions.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-stream-resumption-replay-from-duplicating-tool-side-effects-across-mcp-http-native-sessions.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2430,
    "python_slice_tokens": 456,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two distinct notions of \"resumption\" that get conflated in MCP HTTP-native transport, and the conflation is where the failure lives: - **Stream resumption** — the transport-layer guarantee that a reconnecting client, presenting `Last-Event-ID: N`, receives every SSE event with id `> N` that the server emitted after the disconnect. This is a *delive...",
    "what_was_observed": "A tool server backed by a queue-and-worker design: the HTTP handler accepted `tools/call`, enqueued the work, and streamed progress events (`queued`, `started`, `progress`, `result`) back over SSE, each with a monotonically increasing `id`. The `result` event carried the tool output. Workers committed side effects (a database write, an outbound webhook) before the `result` event was enqueued. Failure trace: 1. Client...",
    "condition_of_validity": "Stream resumption with `Last-Event-ID` is only a valid recovery primitive when all four of the following hold simultaneously: 1. **Durable, ordered log with ids assigned at emission.** The event log for a session is append-only and survives at least as long as the session's maximum tool timeout plus the client's maximum reconnect backoff. If the log TTL is s...",
    "decision_boundary": "The architectural decision is where to place the idempotency boundary relative to the stream boundary: - **Stream-boundary idempotency (insufficient):** dedupe on `(session_id, Last-Event-ID)`. Fails because the client's recovery attempt may present a *different* last-event-id (it may have drained one more event before the second drop), so the dedupe key dif...",
    "operational_effect": "After the incident, the server was changed along three axes, each mapping to one of the invariants above: 1. Event log TTL was decoupled from session TTL and set to `max_tool_timeout + max_reconnect_backoff + safety_margin`, with a hard assertion at startup that `log_ttl > tool_timeout` (the misconfiguration that caused the incident was a 60s log TTL against..."
  },
  "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": "96a13bee4f231f826ba0f685dd977d2b88024ddfd29d136306adce59bf238e92",
    "verified_classes": [
      "ResumeInvariantViolation",
      "EventLog",
      "IdempotencyRecord",
      "ToolServer"
    ],
    "verified_functions": [
      "demo",
      "append",
      "replay_after",
      "__init__",
      "_log",
      "resume",
      "call_tool"
    ],
    "verified_functions_count": 7,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ResumeInvariantViolation"
    ],
    "sample_fail_closed_invariants": [
      "log_ttl must exceed tool_timeout; otherwise a mid-flush drop produces a silent retention gap and duplicate side effects"
    ],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
