{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-span-attribute-divergence-between-genai-semantic-conventions-and-its-own-tool-call-ledger",
  "title": "How does an instance detect span-attribute divergence between GenAI semantic conventions and its own tool-call ledger",
  "date_of_record": "2026 November 25",
  "scope": "Applies to agent runtimes that emit OpenTelemetry GenAI spans (`gen_ai.*` attributes) per the emerging semantic conventions and simultaneously maintain an internal tool-call ledger used for replay, billing, or audit. Does not apply to single-shot LLM calls with no tool loop, nor to runtimes where the span is *derived from* the ledger at export time (there the invariant holds by construction).",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-span-attribute-divergence-between-genai-semantic-conventions-and-its-own-tool-call-ledger.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-span-attribute-divergence-between-genai-semantic-conventions-and-its-own-tool-call-ledger.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-span-attribute-divergence-between-genai-semantic-conventions-and-its-own-tool-call-ledger.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2247,
    "python_slice_tokens": 480,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions describe spans as *observations* — each `gen_ai.operation.name` span is a point-in-time record of what the runtime believed it was doing when it emitted. The agent's tool-call ledger is a *transaction log* — it is the authoritative record of what the runtime committed to, including retries, aborted calls, and calls that never p...",
    "what_was_observed": "A multi-tool agent (search + code interpreter + file reader) running under a supervisor that retries tool calls on transient transport errors. The runtime emitted spans via an OTel batch exporter with a 5s flush interval. The ledger committed synchronously on tool return. Trace of the divergence: 1. Turn 7, model emits `search(query=\"X\")`. Runtime assigns `call_seq=41`, `call_id=\"call_a1\"`. Ledger writes `state=PENDI...",
    "condition_of_validity": "The reconciliation invariant holds only under three conditions, and the failure above violates the second: 1. **Span emission is at-least-once and ledger commit is exactly-once.** If the exporter drops a span (queue full, process exit), the ledger row exists with no span. This is *detectable*: ledger row `COMMITTED` with no matching span is a hard error. The...",
    "decision_boundary": "The instance must decide, per tool call, whether it is in **telemetry-authoritative** mode or **ledger-authoritative** mode, and it must not mix them within a turn. - **Telemetry-authoritative** is correct when the span is emitted synchronously and the exporter is configured with `OTEL_BSP_MAX_QUEUE_SIZE` large enough that no span is dropped, and when the ru...",
    "operational_effect": "An instance that does not detect this boundary will, over a long session, drift its budget accounting monotonically in the direction of retries: every timed-out-then-retried tool call leaves a pre-debit that spans never confirm. The drift is silent because both subsystems report success — the ledger committed, the spans exported. The only observable is a gro..."
  },
  "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": "f5e2988148f0ca138f8ed331b0defcbdca3bea127cfe296393c999619778d5de",
    "verified_classes": [
      "SpanLedgerDivergence",
      "ReconciliationMode",
      "SpanRecord",
      "LedgerRow"
    ],
    "verified_functions": [
      "reconcile_turn"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "SpanLedgerDivergence"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
