{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-attributes-token-cost-to-a-span-before-its-parent-trace-context-is-federated",
  "title": "What happens when an instance attributes token cost to a span before its parent trace context is federated",
  "date_of_record": "2026 November 13",
  "scope": "Applies to multi-agent systems where spans are emitted by independently-deployed agents and joined into a single trace by a federation layer (e.g., a collector or trace-store merge) that resolves cross-agent parent references asynchronously. Does not apply to single-process instrumentation where parent-child relationships are established synchronously in memory before span emission, nor to systems where cost is attributed only at trace-close time by a single authoritative writer.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-attributes-token-cost-to-a-span-before-its-parent-trace-context-is-federated.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-attributes-token-cost-to-a-span-before-its-parent-trace-context-is-federated.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-attributes-token-cost-to-a-span-before-its-parent-trace-context-is-federated.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1456,
    "python_slice_tokens": 234,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between *span-local cost* (tokens consumed by a single LLM call, attributable to the emitting agent the moment the call returns) and *trace-attributed cost* (the share of a trace's total cost that rolls up to a given parent agent or workflow node). Span-local cost is knowable synchronously. Trace-attributed cost is not, becaus...",
    "what_was_observed": "In a three-agent pipeline (planner → retriever → synthesizer) where each agent runs in a separate deployment and emits OTLP spans to a shared collector, the synthesizer's spans routinely arrived before the planner's parent span. The federation layer buffered orphaned spans for a fixed grace window (default 30s) and then, on timeout, re-parented them to a synthetic root. Under normal load the planner's span arrived wi...",
    "condition_of_validity": "The rollup-at-emission approach is valid only if, for every cross-agent edge, the parent span is guaranteed to be present at the federation layer before the child span is processed. In practice this holds when: - Parent and child are emitted by the same process (synchronous parent context), or - The federation layer enforces causal ordering (child spans are ...",
    "decision_boundary": "The decision is between two strategies, and the boundary is whether the federation layer can guarantee parent-before-child processing: - **If the federation layer guarantees causal ordering** (no timeout-based re-parenting, or timeout strictly greater than worst-case parent latency): roll up cost at emission. Cost is available in real time and per-node attri...",
    "operational_effect": "When the boundary is crossed silently, the observable symptoms are: (1) per-node cost breakdowns that sum correctly at trace level but assign cost to the synthetic root; (2) chargeback reports where a workflow node's downstream cost is zero despite downstream agents consuming tokens; (3) the discrepancy appearing only under load or cold-start, so it is invis..."
  },
  "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": "b7c317aa116a1bfd5d5a4a6d99be3a0b91210c71f18e305b66a3f3b0a0a0ae76",
    "verified_classes": [
      "CostAttributionError"
    ],
    "verified_functions": [
      "attribute_cost"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "CostAttributionError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
