{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-span-attribute-coverage-gaps-from-silently-erasing-tool-call-causality-in-opentelemetry-genai-traces",
  "title": "Which invariants prevent span-attribute coverage gaps from silently erasing tool-call causality in OpenTelemetry GenAI traces",
  "date_of_record": "2026 November 28",
  "scope": "Applies to agents that emit OpenTelemetry spans under the GenAI semantic conventions (`gen_ai.*`) while executing multi-step tool-call loops, where child tool spans are correlated to the parent inference span via context propagation. Does not apply to single-shot inference with no tool invocation, nor to agents whose tool calls are traced by a non-OTel sidecar.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribute-coverage-gaps-from-silently-erasing-tool-call-causality-in-opentelemetry-genai-traces.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribute-coverage-gaps-from-silently-erasing-tool-call-causality-in-opentelemetry-genai-traces.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribute-coverage-gaps-from-silently-erasing-tool-call-causality-in-opentelemetry-genai-traces.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1588,
    "python_slice_tokens": 274,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"a span was missing.\" It is that a span *existed and was exported* but was structurally orphaned from the causal chain that downstream consumers reconstruct. GenAI conventions define a set of *required* attributes (`gen_ai.system`, `gen_ai.operation.name`, `gen_ai.request.model`) and a larger set of *conditionally required* ones (`gen_ai.r...",
    "what_was_observed": "A ReAct-style agent ran a three-tool loop (search → fetch → summarize). The tracer emitted: - Parent span `chat` with `gen_ai.operation.name=chat`, `gen_ai.request.model`, `gen_ai.response.finish_reasons=[\"tool_calls\"]`. - Three child spans `execute_tool`, each with `gen_ai.tool.name` and `gen_ai.tool.call.id`. - A second `chat` span carrying the tool results back into the model. The first `chat` span's `gen_ai.respo...",
    "condition_of_validity": "The invariant holds — traces are causally reconstructable — only if all of the following are true simultaneously: 1. Every `execute_tool` span carries `gen_ai.tool.call.id` equal, byte-for-byte, to the `tool_call_id` present in the model response that requested it. 2. The requesting `chat` span carries `gen_ai.response.finish_reasons=[\"tool_calls\"]` **and** ...",
    "decision_boundary": "The operational decision is whether to treat a missing or mismatched `gen_ai.tool.call.id` as a **hard export failure** (drop the span, fail the trace, alert) or a **soft degradation** (export with a `otel.status=error` marker and a `correlation.missing=true` attribute). The boundary: - If the agent's outputs are used in any audit, replay, or causal-attribut...",
    "operational_effect": "Without the invariant enforced, three concrete degradations follow: 1. **Replay divergence.** Incident replay tools that reconstruct agent state by walking the span tree will order tool results by wall-clock time. Under concurrent tool execution (parallel tool calls are a first-class GenAI feature), this reorders context and produces a replay that diverges f..."
  },
  "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": "e16aadd93b162e191afe931d8e1a2a6280172ce656d4c3214b62e7e1981e0b6b",
    "verified_classes": [
      "ToolCallCorrelationError",
      "ModelToolRequest",
      "ToolSpanAttrs"
    ],
    "verified_functions": [
      "build_tool_span_attrs",
      "assert_bidirectional_link"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ToolCallCorrelationError"
    ],
    "sample_fail_closed_invariants": [
      "missing parent span id: context propagation across dispatcher boundary was lost; tool span would become a trace root"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
