{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-cross-tenant-token-attribution-drift-when-federated-agent-traces-are-joined-after-the-fact",
  "title": "Which invariants prevent cross-tenant token attribution drift when federated agent traces are joined after the fact",
  "date_of_record": "2026 November 30",
  "scope": "Applies to observability pipelines that reconstruct per-tenant, per-agent token cost by joining span records emitted independently by multiple agent runtimes (planner, tool-executor, auditor, sub-agent swarms) across trust or billing boundaries. Does not apply to single-process instrumentation where one tracer owns the full span tree and cost is computed inline at emission time.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-cross-tenant-token-attribution-drift-when-federated-agent-traces-are-joined-after-the-fact.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-cross-tenant-token-attribution-drift-when-federated-agent-traces-are-joined-after-the-fact.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-cross-tenant-token-attribution-drift-when-federated-agent-traces-are-joined-after-the-fact.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2184,
    "python_slice_tokens": 287,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Most observability designs treat token attribution as an *aggregation* problem: emit spans with `input_tokens`/`output_tokens`, tag them with `tenant_id` and `trace_id`, then `SUM(...) GROUP BY tenant_id` at the collector. This is correct only when the emitter is the authority on both the token count and the tenant identity, and when the trace is closed befo...",
    "what_was_observed": "A three-tier agent system: an orchestrator (tenant boundary A) dispatching work to a pool of sub-agents (tenant boundary B, a shared execution service) that call a metered model gateway (tenant boundary C). Each tier emitted OTLP spans to a shared collector. Cost was reconstructed nightly by joining gateway metering spans to orchestrator task spans on `trace_id`, then grouping by the orchestrator's `tenant_id`. The o...",
    "condition_of_validity": "The naive join is valid only under a conjunction that federated systems routinely break: - **Single-emitter authority.** Exactly one runtime emits the token count for a given model call, and that runtime also knows the billing entity. *Violated:* gateway meters tokens, orchestrator owns billing entity; the mapping is reconstructed post hoc. - **Idempotent tr...",
    "decision_boundary": "The boundary is whether retries are *identity-preserving* or *identity-generating* at each tier, and whether the join predicate can distinguish them. - If a retry reuses `trace_id` (identity-preserving) → dedup by `trace_id` before aggregation is safe and correct. - If a retry generates a new `trace_id` but carries `upstream_trace_id` + a stable `logical_op_...",
    "operational_effect": "Enforcing the conservation invariant changes three things: 1. **Cost dashboards gain a hard floor.** The unattributed bucket becomes a first-class, alarmed metric. A rising orphan rate is now a signal of handoff loss (A2A context drop, orchestrator crash-after-dispatch) rather than invisible overhead. In the observed system, surfacing it revealed that 4% of ..."
  },
  "matched_failure_symptoms": [
    "SECRET_OR_PII_LEAK_IN_LOGS"
  ],
  "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": "827e7c0333cc46c97b576662498b02979114d7c622e7efa5af6dbe51b96eb04b",
    "verified_classes": [
      "AttributionConservationError",
      "MeterSpan"
    ],
    "verified_functions": [
      "reconcile",
      "attribute_retry"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "AttributionConservationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
