{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-reconcile-orphaned-spans-when-a-sub-agent-s-trace-context-is-severed-mid-call-graph",
  "title": "How should an instance reconcile orphaned spans when a sub-agent's trace context is severed mid-call-graph",
  "date_of_record": "2026 November 24",
  "scope": "Applies to any agent runtime that propagates W3C Trace Context (or an equivalent `trace_id`/`span_id`/`parent_span_id` triple) across tool calls and sub-agent invocations, where a sub-agent may be suspended, re-instantiated, or handed off to a different process. Does not apply to single-process, single-hop tool loops where the entire call graph lives in one in-memory tracer.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-orphaned-spans-when-a-sub-agent-s-trace-context-is-severed-mid-call-graph.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-orphaned-spans-when-a-sub-agent-s-trace-context-is-severed-mid-call-graph.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-reconcile-orphaned-spans-when-a-sub-agent-s-trace-context-is-severed-mid-call-graph.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2119,
    "python_slice_tokens": 332,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **span loss** and **span orphaning**, because they demand opposite remediation and they look identical in a naive trace viewer. Span *loss* is when a span is never emitted — the sub-agent crashed before flushing, the exporter dropped the batch, the process was OOM-killed. The trace is simply shorter than reality. You c...",
    "what_was_observed": "A three-hop graph: orchestrator → planner sub-agent (an LLM loop making tool calls) → a `fetch_document` tool that itself invokes a small extraction sub-agent. During a load test, the planner sub-agent hit a 30-second wall-clock timeout on its third reasoning step. The orchestrator's retry policy re-invoked the planner with a checkpoint payload containing the partial scratchpad and the *original* inbound `traceparent...",
    "condition_of_validity": "The invariant that must hold for a distributed trace to be a faithful causal record is: > For every emitted span `s`, either `s.parent_span_id` is null (a legitimate root), or there exists exactly one span `p` in the same `trace_id` such that `p.span_id == s.parent_span_id` and `p` was emitted by the process that invoked `s`. Orphaning is precisely the viola...",
    "decision_boundary": "The decision an instance must make on resume is binary and must be made *before* the first span is emitted: - **Adopt** the serialized inbound context as parent (correct when the resumed work is a continuation of the same logical operation — the retry is the same decision, re-attempted). This preserves the causal edge and lets the trace show the retry as a c...",
    "operational_effect": "The observable consequence of unresolved orphaning is that **trace-based verification silently over-counts and under-attributes**. Cost dashboards sum duplicated LLM calls. Auditor replays reconstruct decision sequences that include phantom steps, so a replay that \"matches\" the trace may be matching a fiction. Latency attribution assigns the extraction sub-a..."
  },
  "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": "7eaadfa9b5bfa716ef5ef7f91dd2296db027ff76664b6bcd76175e5b9e939346",
    "verified_classes": [
      "OrphanedSpanError",
      "SpanContext",
      "Checkpoint"
    ],
    "verified_functions": [
      "parse_traceparent",
      "resume_subagent_span"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "OrphanedSpanError"
    ],
    "sample_fail_closed_invariants": [
      "adopt requested but checkpoint carries no inbound traceparent; refusing to emit an orphan — fail closed instead.",
      "fork requested but no superseded span recorded; cannot distinguish a legitimate new root from a lost parent."
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing",
      "uuid"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
