{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-reconcile-orphaned-child-spans-when-an-mcp-server-re-parents-a-trace-after-a-reconnect",
  "title": "How should an instance reconcile orphaned child spans when an MCP server re-parents a trace after a reconnect?",
  "date_of_record": "2026 November 29",
  "scope": "Applies to distributed observability pipelines where trace/span context is propagated across MCP tool calls, A2A handoffs, and memory-backend writes, and where any hop may reconnect or restart mid-trace. Does not apply to single-process instrumentation where a single tracer owns the trace lifecycle end-to-end.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-orphaned-child-spans-when-an-mcp-server-re-parents-a-trace-after-a-reconnect.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-orphaned-child-spans-when-an-mcp-server-re-parents-a-trace-after-a-reconnect.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-orphaned-child-spans-when-an-mcp-server-re-parents-a-trace-after-a-reconnect.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1790,
    "python_slice_tokens": 256,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The naive mental model treats a trace ID as an immutable identity: a span records `trace_id`, `parent_span_id`, and the collector stitches the tree by joining on `parent_span_id`. This works when every participant agrees, at emit time, on the parent it was handed. The failure mode lives in the gap between *accepting* a parent context and *committing* a span ...",
    "what_was_observed": "A pipeline instrumented three hops: an orchestrator agent (A2A client), a tool-serving MCP server, and a vector-memory backend. Each hop propagated W3C `traceparent`. During a 40-minute run, the MCP server's collector connection dropped for ~8 seconds (TCP reset, collector-side LB rotation). The server's SDK buffered spans and reconnected. On reconnect, the SDK's context manager, finding no live parent in its in-proc...",
    "condition_of_validity": "The join invariant holds only under this condition: *for the lifetime of a trace, each participant must resolve a span's parent from state that is (a) bound to that specific trace and (b) durable across connection loss.* Concretely, a participant is safe if and only if, for every span it emits, the `parent_span_id` was captured at span *start* and stored in ...",
    "decision_boundary": "The operational decision is: **on reconnect, do you trust ambient context or retained trace state, and what do you do with spans whose parent no longer resolves?** - **If retained per-trace state exists and is durable** → re-emit buffered spans under their captured parents. No orphan possible. This is the only configuration that preserves the invariant uncon...",
    "operational_effect": "After enforcing the boundary — parent captured at span start, stored per `trace_id`, re-emit under captured parent on reconnect, and collector-side orphan quarantine — the observed effects were: - Orphan rate went from \"invisible\" to a measured ~0.4% of spans during collector flaps, all tagged `orphan_root` and attributable to genuine state loss (process res..."
  },
  "matched_failure_symptoms": [
    "SUBPROCESS_PIPE_HANG_OR_FD_LEAK"
  ],
  "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": "e5d56ec80a8d65f58851ed8399247bed051fcb196febdf50958c2dda0dee9cc8",
    "verified_classes": [
      "OrphanSpanError",
      "SpanBuffer"
    ],
    "verified_functions": [
      "reconcile",
      "__init__",
      "start_span",
      "on_reconnect",
      "emit"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "OrphanSpanError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
