{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-distrust-a-causal-span-link-orphaned-span-reparenting-under-concurrent-trace-export-in-multi-agent-cost-attribution",
  "title": "When must an instance distrust a causal span link? Orphaned-span reparenting under concurrent trace export in multi-agent cost attribution",
  "date_of_record": "2026 November 29",
  "scope": "Applies to multi-agent systems whose observability pipeline reconstructs causal DAGs from parent-span-id references emitted asynchronously by agents and tool proxies, and then attributes token/compute cost by walking that DAG. Does not apply to single-agent traces with synchronous in-process span emission, nor to flat log aggregation without causal linking.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-distrust-a-causal-span-link-orphaned-span-reparenting-under-concurrent-trace-export-in-multi-agent-cost-attribution.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-distrust-a-causal-span-link-orphaned-span-reparenting-under-concurrent-trace-export-in-multi-agent-cost-attribution.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-distrust-a-causal-span-link-orphaned-span-reparenting-under-concurrent-trace-export-in-multi-agent-cost-attribution.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1703,
    "python_slice_tokens": 326,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *causal ancestry* (which invocation logically caused which) and *emission order* (which span record reached the collector first). Most observability backends conflate them at exactly one point: when a child span arrives before its declared parent, the collector must choose between (a) buffering the orphan until the par...",
    "what_was_observed": "A three-agent pipeline (planner → executor → verifier) with a shared MCP tool proxy. Each agent emits an `agent.invoke` root span and child `tool.call` spans. Tool proxies emit their own `tool.result` spans with `parent_span_id` set to the calling agent's `agent.invoke` span id. Export is batched with a 250 ms flush interval per process; the proxy runs in a separate process from the agents. Trigger condition: the exe...",
    "condition_of_validity": "The reparenting heuristic is only safe under the invariant: **for every span, the logical parent resolves in the collector before the orphan TTL expires, or the child carries an explicit agent-id and cost-basis tag independent of its parent link.** If either holds, reparenting is cosmetic and cost attribution is unaffected. The invariant fails when (i) paren...",
    "decision_boundary": "The boundary is the orphan TTL versus the p99 export latency of the slowest-emitting parent class. Concretely: if `p99(parent_export_latency) > orphan_ttl`, reparenting will fire on a non-trivial fraction of traces and cost attribution must not depend on the parent link. Two admissible resolutions: - **Raise the barrier:** set `orphan_ttl > p99(parent_export...",
    "operational_effect": "With the decoupled design, per-agent cost reconciles against meters to within metering noise regardless of export order, and orphan reparenting becomes a purely visual artifact in the trace view. With the coupled design, cost dashboards drift as a function of reasoning-trace length: longer agent reasoning → larger parent spans → later export → more reparenti..."
  },
  "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": "182d5c8eeea99dda64b3c2fe3940c45b0d21dfd35bd1e8907d603933a58f76e3",
    "verified_classes": [
      "TopologyCorruptedTrace",
      "Span",
      "Trace"
    ],
    "verified_functions": [
      "attribute_cost",
      "resolve_orphan"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TopologyCorruptedTrace"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
