{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-orphaned-spans-from-silently-truncating-an-agent-s-causal-trace-across-mcp-tool-calls-a2a-handoffs-and-memory-reads",
  "title": "Which invariants prevent orphaned spans from silently truncating an agent's causal trace across MCP tool calls, A2A handoffs, and memory reads",
  "date_of_record": "2026 November 29",
  "scope": "Applies to multi-hop agent systems where a single logical task is instrumented with distributed traces (W3C `traceparent`/`tracestate`) that span MCP tool invocations, A2A peer handoffs, and memory-store operations. Does not cover single-process, single-LLM-call tracing, nor traces that are reconstructed post-hoc from logs rather than propagated at runtime.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-orphaned-spans-from-silently-truncating-an-agent-s-causal-trace-across-mcp-tool-calls-a2a-handoffs-and-memory-reads.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-orphaned-spans-from-silently-truncating-an-agent-s-causal-trace-across-mcp-tool-calls-a2a-handoffs-and-memory-reads.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-orphaned-spans-from-silently-truncating-an-agent-s-causal-trace-across-mcp-tool-calls-a2a-handoffs-and-memory-reads.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1822,
    "python_slice_tokens": 287,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode is not span *loss* (a dropped export that a collector retry can recover) but span *orphaning*: a child span that is exported successfully, carries a valid span ID, and is durably stored — yet whose `parent_span_id` points to a span the collector never received, or received under a different trace ID. The trace is *present but discontinuous*....",
    "what_was_observed": "A three-agent pipeline: an orchestrator (A) receives a task, calls an MCP filesystem tool to load context, invokes a memory retrieval service to fetch episodic memory, then hands off to a specialist agent (B) over A2A, which calls its own MCP tool and writes a distilled memory record. Trace context is threaded through `traceparent` headers on every outbound request. On roughly 4% of tasks, the resulting trace in the ...",
    "condition_of_validity": "This analysis holds only when all of the following are true, and the guardrail below is only sound under the same conditions: 1. Sampling is decided **once** at the trace root and propagated via the `sampled` flag in `traceparent`, not re-derived downstream. 2. `tracestate` is propagated verbatim and **truncated from the right** (dropping vendor entries) whe...",
    "decision_boundary": "The boundary is between **trusting the collector's span count** and **validating parent co-presence at write time**. A trace with N spans and zero dangling parents is *causally closed*. A trace with N spans and one dangling parent is *causally open* and must be treated as an observability failure even though every individual span is well-formed. The decision...",
    "operational_effect": "Without the invariant, the pipeline's dashboards reported 99.6% trace completeness and 100% span-export success while 4% of traces were causally broken at the A2A boundary — the exact boundary where handoff state loss occurs. Post-incident reconstruction of a memory-poisoning bug was delayed because the trace showed A's memory read and B's memory write as un..."
  },
  "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": "e5d0ffb27f850fd07b509a537c42af6c34db4a5cfae6c175059ae60cc45fb3a0",
    "verified_classes": [
      "TraceDiscontinuity",
      "Span",
      "TraceBuffer"
    ],
    "verified_functions": [
      "truncate_tracestate",
      "validate_export",
      "add",
      "validate"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TraceDiscontinuity"
    ],
    "sample_fail_closed_invariants": [
      "tracestate truncation removed all entries; refusing to drop sampling context wholesale"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
