{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-bound-cost-and-latency-attribution-when-federated-trace-spans-arrive-out-of-causal-order-and-semantic-convention-tags-disagree",
  "title": "Where must an instance bound cost and latency attribution when federated trace spans arrive out of causal order and semantic-convention tags disagree across agents",
  "date_of_record": "2026 December 1",
  "scope": "Applies to federated multi-agent systems that emit OpenTelemetry-style spans tagged with GenAI semantic conventions (e.g., `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.operation.name`, `gen_ai.system`) and that aggregate cost/latency by joining spans across agent boundaries. Does not apply to single-process, single-agent tracing where spans are emitted synchronously into one exporter and parent-child ordering is guaranteed by the SDK.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-bound-cost-and-latency-attribution-when-federated-trace-spans-arrive-out-of-causal-order-and-semantic-convention-tags-disagree.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-bound-cost-and-latency-attribution-when-federated-trace-spans-arrive-out-of-causal-order-and-semantic-convention-tags-disagree.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-bound-cost-and-latency-attribution-when-federated-trace-spans-arrive-out-of-causal-order-and-semantic-convention-tags-disagree.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2211,
    "python_slice_tokens": 484,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters here is not \"did we record a span\" versus \"did we lose a span.\" It is whether the **attribution join** — the operation that assigns a token count and a wall-clock duration to a *logical unit of work* (a turn, a tool call, a delegated subtask) — is keyed on the semantic-convention fields themselves, or on a stable correlation iden...",
    "what_was_observed": "In a three-agent federation (a planner instance, a retrieval/tool-calling instance, and an auditor instance), the aggregator computed per-task cost by summing `gen_ai.usage.input_tokens + gen_ai.usage.output_tokens` across all spans with a matching `trace_id`. The auditor instance was running an older convention version: it emitted `gen_ai.usage.prompt_tokens` and `gen_ai.usage.completion_tokens` (the pre-rename fiel...",
    "condition_of_validity": "The invariant that must hold for correct attribution is: > **Every span that contributes tokens or duration to a logical unit of work must carry (a) a stable attempt-scoped correlation key and (b) a convention-version-agnostic usage record, and the aggregator must join on (a) and normalize (b) before summing.** Concretely, attribution is only valid when all ...",
    "decision_boundary": "The boundary is between two aggregator behaviors when a span fails to match the canonical schema or arrives out of causal order: - **Fold-and-continue** (the common default): map unknown fields to zero, sum by `trace_id`, compute latency across the whole trace. This is what produced the three symptoms above. It is acceptable only when the federation is singl...",
    "operational_effect": "The operational consequence is that cost and latency attribution in a federation must be treated as a **reconciliation problem with an explicit residual**, not a summation problem. The pipeline must: 1. Normalize usage through a versioned convention adapter and surface `USAGE_UNKNOWN` as a first-class value, so a renamed field produces a visible gap rather t..."
  },
  "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": "3a1b207664ae99deda706847b6473c7617f8338ce1cee3e022940aa4d018244a",
    "verified_classes": [
      "AttributionInvariantError",
      "Span",
      "Aggregate"
    ],
    "verified_functions": [
      "normalize_usage",
      "attribute",
      "reconcile"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "AttributionInvariantError"
    ],
    "sample_fail_closed_invariants": [
      "all spans quarantined: convention registry likely version-skewed; refusing to emit a zero-cost attribution"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
