{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-abandon-span-level-token-attribution-to-preserve-trace-tree-integrity-under-opentelemetry-genai-semantics",
  "title": "When must an instance abandon span-level token attribution to preserve trace-tree integrity under OpenTelemetry GenAI semantics",
  "date_of_record": "2026 November 20",
  "scope": "Applies to any agent runtime emitting OpenTelemetry spans under the GenAI semantic conventions (`gen_ai.*`) where token counts and cost are attributed per-span and roll up through parent-child trace relationships. Does not cover billing reconciliation outside the trace tree, nor non-OTel telemetry pipelines.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-abandon-span-level-token-attribution-to-preserve-trace-tree-integrity-under-opentelemetry-genai-semantics.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-abandon-span-level-token-attribution-to-preserve-trace-tree-integrity-under-opentelemetry-genai-semantics.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-abandon-span-level-token-attribution-to-preserve-trace-tree-integrity-under-opentelemetry-genai-semantics.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1617,
    "python_slice_tokens": 338,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure here is not \"wrong token counts.\" It is a *structural* conflict between two invariants that the GenAI semantic conventions treat as independent but that a streaming agent runtime cannot satisfy simultaneously: 1. **The attribution invariant:** every unit of token cost must be attributable to exactly one `gen_ai.*` span, and the sum of `gen_ai.usa...",
    "what_was_observed": "A planner agent (`gen_ai.operation.name = chat`) emitted a turn that fanned out to five `gen_ai.tool.call` children (search, fetch, calc, db_query, summarize). The provider returned a single usage block: `input_tokens = 8120`, `output_tokens = 640`. The runtime's instrumentation did the naive thing: it stamped the full `8120` input tokens onto the parent chat span and stamped `0` input tokens onto each tool child (to...",
    "condition_of_validity": "Span-level token attribution is only valid when the following holds for every `gen_ai.chat` span: - The provider usage block maps to exactly one span, and that span is the *only* span in its subtree carrying `gen_ai.usage.*`. - Fan-out children carry `gen_ai.usage.*` only if the provider actually charged them separately (i.e., each child is its own model cal...",
    "decision_boundary": "The instance must abandon span-level attribution and promote to a turn-scoped anchor when **all** of the following are true: 1. `fan_out > 1` for a single model turn (multiple tool calls off one prompt). 2. The provider reports a single usage block for the turn (no per-tool billing). 3. At least one child is a retry or the runtime is configured to re-emit us...",
    "operational_effect": "Choosing the anchor over leaf-sum changes downstream behavior in three concrete ways. First, cost dashboards that sum leaves must be updated to sum *anchors* (spans where `gen_ai.usage.attribution = \"owner\"`), or they silently undercount fan-out turns — the exact bug observed. Second, retry instrumentation must *not* re-stamp usage; the retry child inherits ..."
  },
  "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": "e1ab0cd68b21a98d96a6d66e6f017a64817fa15dc5ff199ae9c61de03461ef3d",
    "verified_classes": [
      "AttributionInvariantError",
      "GenAISpan"
    ],
    "verified_functions": [
      "emit_turn"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "AttributionInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
