{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-attribute-token-cost-when-semantic-convention-spans-disagree-with-the-billing-meter",
  "title": "Where must an instance attribute token cost when semantic-convention spans disagree with the billing meter",
  "date_of_record": "2026 November 21",
  "scope": "Applies to agent runtimes that emit GenAI semantic-convention metrics (`gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.client.operation.duration`) per span while a separate billing meter aggregates actual provider charges. Does not apply to single-shot, single-span inference calls where span and meter are the same event.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-attribute-token-cost-when-semantic-convention-spans-disagree-with-the-billing-meter.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-attribute-token-cost-when-semantic-convention-spans-disagree-with-the-billing-meter.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-attribute-token-cost-when-semantic-convention-spans-disagree-with-the-billing-meter.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1586,
    "python_slice_tokens": 364,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The semantic convention defines token usage as an *attribute of a span* — a per-operation observation. The billing meter defines token cost as an *aggregate over a billing window*, reconciled against the provider's own counter. These are two different accounting identities that happen to share a unit name (\"tokens\"). An instance is only safe when it treats s...",
    "what_was_observed": "A three-stage agent (plan → retrieve → synthesize) ran against a provider that bills cached input tokens at a discount and bills *reasoning tokens* separately from visible output tokens. The runtime emitted, per span, `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` from the response body's `usage` object. Observed trace on a single task: - Plan span: input 1,842, output 210, `gen_ai.usage.cache_read_inpu...",
    "condition_of_validity": "Span-level token attribution is valid for cost accounting only when three conditions hold simultaneously: 1. **Attribute completeness:** every billing dimension the provider charges for (cached input, reasoning/thinking tokens, image tokens, tool-schema overhead) maps to a populated semantic-convention attribute on the *same* span. If any billed dimension ha...",
    "decision_boundary": "The boundary is between *observability* use and *control* use of the same metric. - For **observability** (latency breakdown, per-stage token profile, detecting runaway prompts), span-level usage is authoritative enough — errors are bounded and the purpose is relative comparison. - For **control** (budget gates, retry admission, per-tenant chargeback, autosc...",
    "operational_effect": "The guardrail is a two-tier accounting model: spans carry usage as *observations* tagged with `attempt_index` and `billing_dimension_complete: bool`; a reconciler runs on a window and compares span sums to the meter, emitting a `drift_ratio`. Budget gates read the reconciled meter, never the raw span sum. When `billing_dimension_complete` is false for any sp..."
  },
  "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": "4b0e1f0ab28d4e195ba78355c06cb699491abefd1611f516ac9e5017127f7206",
    "verified_classes": [
      "AttributionInvariantError",
      "SpanUsage",
      "TaskCost"
    ],
    "verified_functions": [
      "gate_budget",
      "span_sum",
      "reconciled",
      "drift_ratio"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "AttributionInvariantError"
    ],
    "sample_fail_closed_invariants": [
      "budget gate attempted on unreconciled span metrics; span tokens are a lower bound, not a cost basis",
      "span set has uncovered billing dimensions; cost attribution is provisional",
      "cannot compute drift without a reconciled meter value"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
