{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-span-attribute-divergence-from-silently-corrupting-agent-invocation-telemetry-under-opentelemetry-genai-semantic-conventions",
  "title": "Which invariants prevent span-attribute divergence from silently corrupting agent-invocation telemetry under OpenTelemetry GenAI semantic conventions",
  "date_of_record": "2026 November 24",
  "scope": "Applies to any agent runtime that emits OTel GenAI spans (`gen_ai.*` attributes) for tool calls, token accounting, and agent invocation, where spans are correlated post-hoc for cost attribution, replay, or SLO computation. Does not apply to single-shot completion logging without span correlation, nor to runtimes that emit a single flat span per session with no child tool spans.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribute-divergence-from-silently-corrupting-agent-invocation-telemetry-under-opentelemetry-genai-semantic-conventions.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribute-divergence-from-silently-corrupting-agent-invocation-telemetry-under-opentelemetry-genai-semantic-conventions.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribute-divergence-from-silently-corrupting-agent-invocation-telemetry-under-opentelemetry-genai-semantic-conventions.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1741,
    "python_slice_tokens": 391,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"missing attributes\" — missing attributes are loud and detectable. The failure is **semantically divergent but schema-valid** attributes: two spans that both satisfy the GenAI convention's required fields yet describe the same tool call with incompatible token counts, incompatible `gen_ai.operation.name` values, or an `gen_ai.agent.id` tha...",
    "what_was_observed": "A multi-agent orchestrator emitted, per logical turn: - 1 agent-invocation span: `gen_ai.operation.name=\"invoke_agent\"`, `gen_ai.agent.id`, `gen_ai.usage.input_tokens=1840`, `gen_ai.usage.output_tokens=212`. - N tool-call spans (children): `gen_ai.operation.name=\"execute_tool\"`, `gen_ai.tool.name`, and — because the instrumentation library reused a shared `record_usage()` helper — `gen_ai.usage.input_tokens=1840` on ...",
    "condition_of_validity": "The invariant that must hold for GenAI telemetry to be aggregable: > **Token attribution is single-owner.** For any logical model invocation, `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens` appear on exactly one span — the span whose `gen_ai.operation.name` names the operation that *consumed* the tokens (`invoke_agent`, `chat`, or `execute_tool`...",
    "decision_boundary": "The boundary between safe and corrupting emission: - **Safe:** usage attributes are written by the code path that actually invokes the model/tool, using the response object's own usage field. Enclosing spans write *no* usage or write `gen_ai.usage.*` only for tokens the enclosing operation itself consumed (e.g., an agent's own planning call, distinct from it...",
    "operational_effect": "Downstream, the corruption manifests as three distinguishable-but-confusable symptoms: 1. **Fan-out-proportional cost inflation.** Per-turn cost scales with tool count in a way that tracks task complexity, so it reads as signal, not error. Detected only by a ratio check: `sum(child usage) / parent usage` should be ~0 for enclosing parents; a value > 1 flags ..."
  },
  "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": "48ea8718fda2c837588efc604f3b8ed5f9a8bab7a5609f63c82bd6a52ea69fed",
    "verified_classes": [
      "GenAiSpanInvariantError",
      "GenAiSpan"
    ],
    "verified_functions": [
      "_has_usage",
      "assert_single_owner_usage",
      "assert_identity_resolvable",
      "validate_trace",
      "walk"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "GenAiSpanInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
