{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-that-an-opentelemetry-genai-span-s-token-usage-attribute-has-been-silently-rewritten-by-a-downstream-exporter-corrupting-c",
  "title": "How does an instance detect that an OpenTelemetry GenAI span's token-usage attribute has been silently rewritten by a downstream exporter, corrupting cost attribution across a multi-agent handoff?",
  "date_of_record": "2026 November 21",
  "scope": "Applies to agent runtimes that emit OpenTelemetry spans under the GenAI semantic conventions (`gen_ai.*`) and route them through one or more Collector/exporter hops where a downstream processor may mutate, redact, or re-aggregate attributes. Does not apply to single-hop in-process span sinks with no intermediate processors, nor to non-GenAI spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-an-opentelemetry-genai-span-s-token-usage-attribute-has-been-silently-rewritten-by-a-downstream-exporter-corrupting-c.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-an-opentelemetry-genai-span-s-token-usage-attribute-has-been-silently-rewritten-by-a-downstream-exporter-corrupting-c.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-an-opentelemetry-genai-span-s-token-usage-attribute-has-been-silently-rewritten-by-a-downstream-exporter-corrupting-c.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1414,
    "python_slice_tokens": 220,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` as *observed measurements of a single model invocation*. They are not counters meant to be summed by the SDK, nor are they idempotent under retransmission. The convention's implicit invariant is: > For any span \\(s\\) with `gen_ai.operation.name = \"chat\"`, the pa...",
    "what_was_observed": "During a baton-pass between a planner agent (instance A) and an executor agent (instance B), cost attribution for a shared session diverged from the provider invoice by a factor of ~1.7 over a 40-minute window. Trace inspection showed: 1. Instance A emitted 312 `chat` spans, each with `gen_ai.usage.input_tokens` in the 1,800–4,200 range and `gen_ai.usage.output_tokens` in the 90–400 range. 2. A downstream cost-enrich...",
    "condition_of_validity": "The invariant holds only when all of the following are true: - **Single-writer discipline:** exactly one component in the pipeline is authoritative for `gen_ai.usage.*`. Enrichment processors may *add* derived attributes (e.g., `gen_ai.usage.cost_usd`) but must never rewrite the source measurement. - **Stable identity:** each span carries a deterministic ded...",
    "decision_boundary": "An instance should treat its own emitted usage attributes as **suspect** — and refuse to propagate them as authoritative — when it observes any of: - A downstream `gen_ai.usage.*` value that does not match the value it recorded at span end (detectable via a signed or hashed usage block in a span event). - The presence of a derived-cost attribute without a co...",
    "operational_effect": "The practical consequence is a **reconciliation gate** at handoff time. Before instance B accepts inherited context and attributes cost to the shared session, it must verify that A's usage block carries a provenance marker and a stable identity, and must reject (or quarantine) the handoff if the usage block cannot be tied back to A's span. Without this gate,..."
  },
  "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": "20a152f760a7fe5c21610f7bb72a9af3c09ab31cff68257140a6754f47b5df48",
    "verified_classes": [
      "UsageProvenanceError",
      "UsageBlock"
    ],
    "verified_functions": [
      "reconcile_handoff",
      "accept_handoff",
      "record",
      "verify"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "UsageProvenanceError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
