{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-reconcile-genai-semantic-convention-spans-against-a-divergent-tool-call-ledger-before-emitting-cost-metrics",
  "title": "Under what conditions must an instance reconcile GenAI semantic-convention spans against a divergent tool-call ledger before emitting cost metrics",
  "date_of_record": "2026 November 30",
  "scope": "Applies to agent runtimes that emit OpenTelemetry spans using the GenAI semantic conventions (`gen_ai.*` attributes) for tool-call child spans and derive token/cost metrics from those spans. Does not apply to runtimes that compute cost from a single authoritative billing ledger independent of span emission, nor to plain LLM inference spans with no tool-call fan-out.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reconcile-genai-semantic-convention-spans-against-a-divergent-tool-call-ledger-before-emitting-cost-metrics.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reconcile-genai-semantic-convention-spans-against-a-divergent-tool-call-ledger-before-emitting-cost-metrics.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-reconcile-genai-semantic-convention-spans-against-a-divergent-tool-call-ledger-before-emitting-cost-metrics.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1717,
    "python_slice_tokens": 209,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define attributes — `gen_ai.operation.name`, `gen_ai.tool.name`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.request.model`, `gen_ai.response.finish_reasons` — as *descriptive* telemetry attached to spans. They do not define a transactional contract between the span tree and the agent's actual execution l...",
    "what_was_observed": "A tool-using agent (planner → N parallel tool calls → synthesizer) emitted one parent `gen_ai.operation.name=chat` span per reasoning turn and one `gen_ai.operation.name=execute_tool` child span per dispatched call. Each child span carried `gen_ai.tool.name`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens` for the *tool-augmented* model call that produced the arguments, plus `gen_ai.response.finish_reasons`...",
    "condition_of_validity": "Span-derived cost metrics are valid **only when the following holds for every parent agent turn**: - The set of exported `execute_tool` child spans is bijective with the executor's dispatch ledger for that turn — one span per dispatch, not per logical call, and not per intent. - Every child span that carries `gen_ai.usage.*_tokens` corresponds to a model com...",
    "decision_boundary": "The boundary is between two emission architectures: - **Intent-keyed emission** (the failing case): child spans are created when the loop decides to call a tool. Cardinality follows the loop. Under retry, cancellation, or late return, span count and token sum diverge from billing. - **Ledger-keyed emission** (the valid case): child spans are created when the...",
    "operational_effect": "Under intent-keyed emission, the observable symptom is a cost dashboard that is *stable and plausible* while being wrong in a direction that depends on the workload's retry and cancellation profile. High-fan-out speculative planners overcount (cancelled calls still carry argument tokens); flaky-tool workloads undercount (retries collapse to one span); long-t..."
  },
  "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": "4f2da3746061cdeaf9a59e7c2923445cea89c32656d07cc2889d685c68360171",
    "verified_classes": [
      "SpanLedgerDivergenceError"
    ],
    "verified_functions": [
      "reconcile_span_cost"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "SpanLedgerDivergenceError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
