{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-silent-token-accounting-divergence-across-opentelemetry-genai-agent-spans-when-tool-call-attribute-emission-and-multi-agent-t",
  "title": "Which invariants prevent silent token-accounting divergence across OpenTelemetry GenAI agent spans when tool-call attribute emission and multi-agent trace propagation interleave",
  "date_of_record": "2026 November 25",
  "scope": "Applies to multi-agent systems that emit OpenTelemetry GenAI semantic-convention spans (`gen_ai.*`) for LLM invocations, tool calls, and agent-to-agent handoffs, where a single logical task fans out across more than one process boundary. Does not apply to single-process, single-span synchronous LLM calls where the span is closed before any child work begins.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-token-accounting-divergence-across-opentelemetry-genai-agent-spans-when-tool-call-attribute-emission-and-multi-agent-t.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-token-accounting-divergence-across-opentelemetry-genai-agent-spans-when-tool-call-attribute-emission-and-multi-agent-t.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-silent-token-accounting-divergence-across-opentelemetry-genai-agent-spans-when-tool-call-attribute-emission-and-multi-agent-t.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2089,
    "python_slice_tokens": 337,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The GenAI semantic conventions treat a span as a *reporting unit*: attributes such as `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, and `gen_ai.operation.name` describe the cost and nature of one model or tool interaction. They do **not** define a *conservation law*. Nothing in the spec requires that the sum of `gen_ai.usage.*` across a trace eq...",
    "what_was_observed": "A three-tier agent topology: an orchestrator (process A) calls a planner sub-agent (process B) over an A2A-style transport, which in turn invokes a tool-executor sub-agent (process C). Context was propagated via W3C `traceparent`/`tracestate`, and each process ran its own OTel SDK with a batch span processor (`schedule_delay_millis=5000`, `max_export_batch_size=512`). The orchestrator's `gen_ai.operation.name=chat` s...",
    "condition_of_validity": "The invariant that must hold for accounting to be correct is: > For every trace root, the set of spans carrying `gen_ai.usage.*` is closed and final before any consumer computes aggregate cost, and every such span's usage attributes were set before that span's `end()` call. This holds only when all of the following are true: - Usage attributes are set on the...",
    "decision_boundary": "The boundary is between *span-level correctness* and *trace-level conservation*. A span can be perfectly spec-compliant—correct name, correct parent, correct attributes at close—and the trace can still be wrong in aggregate, because the spec governs spans, not sums. Concretely, the decision an implementer must make is where to place the completion barrier: -...",
    "operational_effect": "The shortfall is silent and systematic. It scales with fan-out depth and with the fraction of usage that is patched post-`end()` (streaming output is the usual culprit). In the observed system it was ~30% of tasks and ~980 tokens each—small enough to pass casual review, large enough to corrupt cost attribution and any budget-enforcement loop that reads from ..."
  },
  "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": "a970975611cbdaf5c7c515cae42ec1702df8a6cdf1f5a566a98df683046e4a7c",
    "verified_classes": [
      "TraceAccountingError",
      "GenAISpan",
      "TraceStore"
    ],
    "verified_functions": [
      "ingest",
      "reconcile_task_cost"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "TraceAccountingError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
