{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-trace-context-orphaning-when-an-mcp-server-re-parents-spans-across-a-memory-tool-boundary",
  "title": "How does an instance detect trace-context orphaning when an MCP server re-parents spans across a memory-tool boundary?",
  "date_of_record": "2026 November 27",
  "scope": "Applies to distributed tracing pipelines where a root agent (orchestrator) propagates W3C `traceparent`/`tracestate` across MCP JSON-RPC hops, A2A delegation envelopes, and memory-tool calls (vector store, KV cache, episodic store), and where span parenting is reconstructed downstream by an observability collector. Does not apply to single-process agents with in-memory span trees, nor to pipelines that emit fully-flattened span links without parent references.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-trace-context-orphaning-when-an-mcp-server-re-parents-spans-across-a-memory-tool-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-trace-context-orphaning-when-an-mcp-server-re-parents-spans-across-a-memory-tool-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-trace-context-orphaning-when-an-mcp-server-re-parents-spans-across-a-memory-tool-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1561,
    "python_slice_tokens": 229,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"missing trace context.\" Missing context produces a clean orphan and a well-known `parent_span_id == null` signal. The non-obvious failure is **context-preserving re-parenting**: an MCP server or memory tool receives a valid `traceparent` header, *forwards it correctly* to its own downstream calls, but synthesizes a **new span ID** for the...",
    "what_was_observed": "A three-hop delegation trace: `agent.root` → A2A `delegate(task)` → `agent.worker` → MCP `tools/call(memory.search)` → `memory.store`. Expected parentage: Observed parentage in the collector: The MCP server's JSON-RPC handler constructed span C with `parent_span_id = A` because it extracted `traceparent` from the *inbound HTTP header* (which A2A had set to A's span ID, not B's), while the A2A layer had already re-sco...",
    "condition_of_validity": "The invariant holds only under a specific precondition: **exactly one propagation channel is authoritative per hop, and that authority is declared in the envelope, not inferred.** The failure is valid (i.e., reproducible and diagnosable) when all of the following hold: - The trace crosses at least one protocol boundary where the transport header and the prot...",
    "decision_boundary": "The operational decision is whether to **reject the trace as untrustworthy** or **repair the parentage** at ingestion. The boundary: - If the collector can resolve the conflict deterministically (envelope field is present and the envelope's `parent_span_id` matches a span already seen in the same trace), **repair by preferring the envelope** and emit a `repa...",
    "operational_effect": "Enforcing the boundary changes three things: 1. **Latency attribution becomes single-sourced.** Memory-tool cost is charged to the worker span that invoked it, not the root. Root self-time drops to its true value; the memory tool's contribution becomes visible and budgetable. 2. **Replay becomes deterministic.** Given the same trace, any auditor reconstructs..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION"
  ],
  "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": "791fd7c74a4e70fc17e821e1b3ec3f2fd7fc5a440c5dd0a64ef080e45b26fe95",
    "verified_classes": [
      "TraceParentageConflict",
      "Span"
    ],
    "verified_functions": [
      "resolve_parentage"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "TraceParentageConflict"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
