{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-reconcile-opentelemetry-genai-span-token-counts-against-the-turn-causality-chain-before-trusting-a-cumulative-cost-attribute",
  "title": "Where must an instance reconcile OpenTelemetry GenAI span token counts against the turn causality chain before trusting a cumulative cost attribute",
  "date_of_record": "2026 November 26",
  "scope": "Applies to agent runtimes that emit OpenTelemetry GenAI spans (`gen_ai.*` semantic conventions) and derive per-turn or per-session token/cost accounting from span attributes across multi-step tool-calling loops. Does not apply to single-shot inference where one span equals one request and no parent/child turn chain exists.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-span-token-counts-against-the-turn-causality-chain-before-trusting-a-cumulative-cost-attribute.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-span-token-counts-against-the-turn-causality-chain-before-trusting-a-cumulative-cost-attribute.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-reconcile-opentelemetry-genai-span-token-counts-against-the-turn-causality-chain-before-trusting-a-cumulative-cost-attribute.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1684,
    "python_slice_tokens": 368,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define *per-span* attributes such as `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` on individual inference spans, and separate span attributes for tool execution (`gen_ai.tool.name`, `gen_ai.tool.call.id`). They do **not** define a span-level cumulative session total. Any \"total tokens this turn\" figure is a *der...",
    "what_was_observed": "A three-step tool-calling turn (plan → tool call → synthesize) emitted 11 spans. The turn root carried a derived `turn.total_tokens` attribute computed by the orchestrator as the sum of all spans where `gen_ai.usage.input_tokens` was present. Observed trace: - Root `agent.turn` span, ended at T+4200ms. - Child `gen_ai.chat` (plan), input 1840, output 210, ended T+900ms. - Child `gen_ai.tool` span `search`, ended T+21...",
    "condition_of_validity": "A derived cumulative token attribute on a turn root is valid only when all of the following hold: 1. **Tree closure.** Every descendant span's end timestamp precedes the root's end timestamp. If any inference child can outlive the root, the root's cumulative attribute is a lower bound, not a total. 2. **Single-path reachability.** No inference span is a desc...",
    "decision_boundary": "The boundary is: **derive turn totals at read time from a closed, validated span graph; never write a cumulative total onto a span that can end before its children.** - If the runtime cannot guarantee root-outlives-children, it must emit turn totals as a *separate accounting event* (a span or metric emitted after the last child closes), not as an attribute o...",
    "operational_effect": "Unreconciled, this boundary produces silent cost under-reporting (orphaned late spans) and silent over-counting (nested retry spans summed twice) that net out unpredictably across a workload — so spot checks pass while the monthly bill diverges. The guardrail is a reconciliation pass that, per turn, (a) verifies every inference span's parent is ended-after-c..."
  },
  "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": "2cc60eeceda77b997ba856c44274f09ce4a845f6095d6d4e68e697d6349af0b0",
    "verified_classes": [
      "TurnAccountingError",
      "Span"
    ],
    "verified_functions": [
      "reconcile_turn",
      "walk"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "TurnAccountingError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
