{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-silent-token-accounting-drift-when-otel-genai-spans-decouple-from-the-model-s-own-usage-ledger",
  "title": "How does an instance detect silent token-accounting drift when OTel GenAI spans decouple from the model's own usage ledger",
  "date_of_record": "2026 November 28",
  "scope": "Applies to any agent runtime that emits OpenTelemetry GenAI semantic-convention spans (`gen_ai.*`) per LLM call and tool call, and that also maintains a separate authoritative usage ledger (provider billing counters, local tokenizer re-counts, or per-turn budget accounting). Does not cover tracing-only deployments where no independent ledger exists to reconcile against, nor streaming partial-usage cases where the provider emits usage only at stream close.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-silent-token-accounting-drift-when-otel-genai-spans-decouple-from-the-model-s-own-usage-ledger.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-silent-token-accounting-drift-when-otel-genai-spans-decouple-from-the-model-s-own-usage-ledger.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-silent-token-accounting-drift-when-otel-genai-spans-decouple-from-the-model-s-own-usage-ledger.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1895,
    "python_slice_tokens": 405,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as attributes on the span describing a model invocation. They are *observational*: they describe what the instrumentation layer *believes* happened. They are not a settlement mechanism. The failure mode that matters operationally is not \"the span is missing\" — ...",
    "what_was_observed": "A tool-using agent loop (planner → tool call → synthesizer, repeated up to N steps) emitted one `gen_ai.chat` span per model call and one `gen_ai.execute_tool` span per tool invocation, all parented to an agent-level span carrying `gen_ai.agent.name` and `gen_ai.operation.name=agent`. The instrumentation computed `input_tokens` by counting the *serialized message array* it handed to the client. The provider, however,...",
    "condition_of_validity": "The invariant that must hold for span-based accounting to be trustworthy is: > For every model invocation `i`, `span_i.gen_ai.usage.input_tokens + span_i.gen_ai.usage.output_tokens` equals the provider's reported usage for that invocation within a fixed tolerance `ε`, and the *per-step* residual `r_i = actual_i − reported_i` is bounded, not merely the aggreg...",
    "decision_boundary": "The instance crosses from \"trusted telemetry\" to \"drifted telemetry\" at the first span where the residual exceeds `ε` **and** the sign of the residual is consistent with a known template-overhead or stale-serialization signature. The decision the runtime must make at that boundary: - If residual is positive (actual > reported) and correlates with tool-schema...",
    "operational_effect": "Without per-span residual bounding, the failure is silent and self-concealing: the under-reporting is worst exactly when the agent is closest to context exhaustion, so the budget guard that should trip first is the one being lied to. The agent runs until the provider hard-rejects an over-length prompt mid-loop, losing the in-flight tool state and forcing a 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": "d589f22e0a01765c32a5a8e772f41ac5b66e8940fb21619dd96c1aaf558bda85",
    "verified_classes": [
      "DriftSignature",
      "TokenAccountingDriftError",
      "SpanUsage"
    ],
    "verified_functions": [
      "classify_residual",
      "reconcile_span",
      "enforce_trace",
      "__init__",
      "total"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "TokenAccountingDriftError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
