{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-span-attribute-lineage-collapse-when-genai-tool-call-spans-are-exported-asynchronously",
  "title": "Which invariants prevent span-attribute lineage collapse when GenAI tool-call spans are exported asynchronously",
  "date_of_record": "2026 November 25",
  "scope": "Applies to agents emitting OpenTelemetry GenAI semantic-convention spans (`gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.tool.call.id`, `gen_ai.usage.input_tokens`, `gen_ai.response.finish_reasons`) where the span processor is a batching exporter and tool calls are correlated to model invocations via `gen_ai.tool.call.id` and parent/child span links. Does not apply to synchronous `SimpleSpanProcessor` setups or to pure log-based telemetry that never reconstructs lineage.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribute-lineage-collapse-when-genai-tool-call-spans-are-exported-asynchronously.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribute-lineage-collapse-when-genai-tool-call-spans-are-exported-asynchronously.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribute-lineage-collapse-when-genai-tool-call-spans-are-exported-asynchronously.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1571,
    "python_slice_tokens": 346,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"lost spans.\" A batching exporter reliably delivers *every* span. The failure is **lineage collapse**: the `gen_ai.tool.call.id` that a child tool-execution span carries no longer resolves to the parent `gen_ai.operation.name = \"execute_tool\"` invocation record at reconstruction time, because the parent span was exported, sampled, or dropp...",
    "what_was_observed": "An agent loop emitted, per turn, one `gen_ai.operation.name = \"chat\"` span (the model invocation, carrying `gen_ai.usage.input_tokens`, `gen_ai.response.finish_reasons = [\"tool_calls\"]`) and one or more `gen_ai.operation.name = \"execute_tool\"` child spans (each carrying `gen_ai.tool.name` and `gen_ai.tool.call.id`). The tracer used a `BatchSpanProcessor` with a 5s schedule delay and a tail-based sampler configured to...",
    "condition_of_validity": "The lineage invariant `tool.call.id(child) ⇒ exists parent chat span with that id in finish_reasons` holds **only if** the sampling decision is made at the trace (root) level and applied uniformly, *or* if `gen_ai.tool.call.id` is redundantly stamped onto the parent `chat` span (e.g., as `gen_ai.response.tool_call_ids` — a list attribute) so the join survive...",
    "decision_boundary": "The boundary is: **does the telemetry pipeline need to answer \"which model invocation produced this tool call\" from spans alone, or can it tolerate the join being probabilistic?** - If lineage must be exact, the guardrail is: stamp the full set of `gen_ai.tool.call.id` values onto the parent `chat` span as a list attribute *before* the tool executes, and mak...",
    "operational_effect": "Without the guardrail, observability reports systematically under-count tool executions and over-count \"model emitted tool call but nothing ran\" — inflating apparent hallucination rates and depressing apparent tool-success rates. The error is *directional and silent*: it looks like a model-quality regression, not a telemetry defect, so teams chase prompt fix..."
  },
  "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": "8b6279c6a8e3b17649d5b339b9acc2e2a2b0dd4d035f88c1b83d27ccfdc97fa8",
    "verified_classes": [
      "LineageCollapseError",
      "GenAISpan"
    ],
    "verified_functions": [
      "reconstruct_lineage",
      "safe_reconstruct"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "LineageCollapseError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
