{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-emits-genai-span-attributes-that-violate-the-otel-semantic-conventions-cardinality-contract-mid-trace",
  "title": "What happens when an instance emits GenAI span attributes that violate the OTel semantic conventions' cardinality contract mid-trace",
  "date_of_record": "2026 November 30",
  "scope": "Applies to agent runtimes that emit OpenTelemetry `gen_ai.*` spans per the GenAI semantic conventions (v1.27+) where a single trace spans multiple LLM invocations, tool calls, and sub-agent handoffs. Does not apply to single-shot inference telemetry, nor to legacy non-OTel tracing shims that flatten agent state into flat log lines.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-genai-span-attributes-that-violate-the-otel-semantic-conventions-cardinality-contract-mid-trace.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-genai-span-attributes-that-violate-the-otel-semantic-conventions-cardinality-contract-mid-trace.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-emits-genai-span-attributes-that-violate-the-otel-semantic-conventions-cardinality-contract-mid-trace.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2367,
    "python_slice_tokens": 392,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions define `gen_ai.*` attributes with an implicit **cardinality contract**: a span represents *one* model invocation or *one* tool execution, and its identifying attributes (`gen_ai.request.model`, `gen_ai.operation.name`, `gen_ai.usage.input_tokens`, `gen_ai.response.finish_reasons`) describe that single unit. The failure mode exa...",
    "what_was_observed": "Consider a planner agent that, to save span overhead, wraps a *retry loop* around a single `gen_ai.chat` span. The inner code calls the model up to N times on rate-limit or validation failure, then returns the final response. The instrumentation emits: - `gen_ai.operation.name = \"chat\"` - `gen_ai.request.model = \"gpt-4o\"` (constant across retries) - `gen_ai.usage.input_tokens = <sum of all attempts>` - `gen_ai.usage....",
    "condition_of_validity": "The cardinality contract holds—and the failure is bounded—only when all of the following are true. Violate any one and the invariant breaks: 1. **One span = one `gen_ai` operation.** If a span emits any `gen_ai.*` attribute, the span must represent exactly one model invocation or tool execution. Retries, fallbacks, and fan-out each require *child spans*, not...",
    "decision_boundary": "The operational decision is: **when an agent harness retries, falls back, or fans out, does it emit child spans, or does it collapse into the parent?** The boundary condition is the *first* retry or fan-out. Before it, a single span is correct. At the moment a second model call is issued under the same logical operation, the harness faces a fork: - **Emit a ...",
    "operational_effect": "The downstream consequences are graded by how long detection takes: - **Immediate (seconds):** None. The collector accepts the spans. This is why the failure is insidious—the instrumentation \"works.\" - **Hours:** Cost dashboards show per-span costs that don't reconcile with provider invoices, because merged-usage spans inflate individual span costs while the..."
  },
  "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": "0edee8350470cff8fa54a3ce621376e9ba2b67b6bff188994a24f54d07438882",
    "verified_classes": [
      "GenAISpanCardinalityError",
      "GenAISpanGuard"
    ],
    "verified_functions": [
      "emit_chat_span",
      "record_call",
      "assert_single_response_model",
      "build_attributes"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "GenAISpanCardinalityError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
