{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-halt-span-emission-when-opentelemetry-genai-token-accounting-attributes-diverge-from-the-reasoning-trajectory-s-terminal-state",
  "title": "Where must an instance halt span emission when OpenTelemetry GenAI token-accounting attributes diverge from the reasoning trajectory's terminal state",
  "date_of_record": "2026 November 26",
  "scope": "Applies to agents instrumented with OpenTelemetry GenAI semantic conventions (`gen_ai.*`) where a single logical trajectory spans multiple LLM invocations and tool calls under one trace; specifically the boundary where cumulative token accounting on a parent span must reconcile with terminal child-span usage before the span is closed. Does not cover single-shot inference instrumentation or metrics-only pipelines that omit span-level usage attributes.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-halt-span-emission-when-opentelemetry-genai-token-accounting-attributes-diverge-from-the-reasoning-trajectory-s-terminal-state.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-halt-span-emission-when-opentelemetry-genai-token-accounting-attributes-diverge-from-the-reasoning-trajectory-s-terminal-state.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-halt-span-emission-when-opentelemetry-genai-token-accounting-attributes-diverge-from-the-reasoning-trajectory-s-terminal-state.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1991,
    "python_slice_tokens": 388,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat token usage as a *span attribute* (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, and the newer `gen_ai.usage.cache_read.input_tokens` / `gen_ai.usage.reasoning.output_tokens` families) that is *reported per span*. They do not define a normative aggregation rule across a parent agent span and its child LLM/too...",
    "what_was_observed": "A multi-step agent (planner → 4 tool calls → synthesizer, 3 LLM invocations total) was instrumented with a parent span `agent.trajectory` carrying a rollup of `gen_ai.usage.*`. The observed trace exhibited a **1,847-token over-attribution** on the parent relative to the sum of exported leaf spans, with no error recorded anywhere. The trigger condition was a specific interleaving: 1. The parent span accumulated usage ...",
    "condition_of_validity": "The rollup invariant `attributed_usage(parent) == Σ reported_usage(exported children)` is **valid only under all of the following**, and instrumentation must assert them or refuse to emit the parent rollup: - **Close ordering:** every child span that contributes to the rollup is closed *before* the parent's close callback runs. Streaming, async tool dispatch...",
    "decision_boundary": "The boundary is a single predicate evaluated at parent-span close: When `emit_rollup` is false, the span must transition to a **degraded-accounting state**: attributes `gen_ai.usage.attribution=\"partial\"` (or `\"unavailable\"`), no `gen_ai.usage.*` totals, and a recorded `gen_ai.usage.attribution_reason` enumerating the violated conjuncts. This is the decision...",
    "operational_effect": "With the boundary enforced, three operational properties change: 1. **Cost dashboards become leaf-authoritative or explicitly partial.** A query summing `gen_ai.usage.*` over leaf spans is always correct; parent rollups are trusted only when `attribution=\"complete\"`. The 22% phantom-cost class of bug disappears because the dashboard has a defined fallback. 2..."
  },
  "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": "bae3ae8ffbefa1eb6e21a03996906ef1ca97c8064a3c84c9937d4ee807008d34",
    "verified_classes": [
      "UsageAttributionError",
      "ChildSpanUsage",
      "ParentTrajectory"
    ],
    "verified_functions": [
      "_partitioned_input",
      "compute_authoritative_rollup",
      "close_parent_span"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "UsageAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
