{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-span-attribution-collapse-when-a-traced-agent-trajectory-is-replayed-across-a-cost-accounting-boundary",
  "title": "Which invariants prevent span-attribution collapse when a traced agent trajectory is replayed across a cost-accounting boundary",
  "date_of_record": "2026 December 1",
  "scope": "Applies to agents whose execution is instrumented with span-level trajectory tracing (OpenTelemetry-style parent/child spans, one span per LLM call and per tool call) and whose cost and hallucination tags are attributed per span, then reconciled against a billing or audit ledger. Does not apply to single-call, single-span inference where no parent-child tree exists and no replay reconciliation is performed.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribution-collapse-when-a-traced-agent-trajectory-is-replayed-across-a-cost-accounting-boundary.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribution-collapse-when-a-traced-agent-trajectory-is-replayed-across-a-cost-accounting-boundary.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-span-attribution-collapse-when-a-traced-agent-trajectory-is-replayed-across-a-cost-accounting-boundary.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2007,
    "python_slice_tokens": 371,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure here is not \"the agent hallucinated\" and it is not \"the trace was incomplete.\" It is a **span-identity invariant violation**: the tracer treats a span's identity as its position in the execution tree, while the cost ledger treats a span's identity as its `(trace_id, span_id)` pair. When an agent retries, re-plans, or resumes from a checkpoint, th...",
    "what_was_observed": "An agent executing a 14-step research task with three tool calls (web search, calculator, file write) emitted a clean span tree on the first pass. At step 9, the web-search tool returned a schema-valid but semantically empty result (`{\"results\": []}`), which the model misread as \"no results exist\" and began to confabulate citations. The confabulated citation text was tagged as a hallucination span by a post-hoc span ...",
    "condition_of_validity": "The invariant that must hold for span-attributed cost and hallucination tags to be trustworthy is: > **For every span `s`, the tuple `(trace_id, span_id)` is globally unique and immutable for the lifetime of the trace, and every tag or cost row referencing `s` is written exactly once against that tuple and never re-resolved by tree position.** This decompose...",
    "decision_boundary": "The boundary between safe and unsafe operation is whether the cost/hallucination join is **positional** or **identity-based**: - **Positional join (unsafe):** attribution keyed on `(trace_id, step_index)` or `(trace_id, sibling_index)` or \"the Nth LLM span under the root.\" Any retry, re-plan, or checkpoint-resume that changes tree shape silently re-binds att...",
    "operational_effect": "When the invariant holds, cost over-attribution is bounded by the retry count (each retry is a billed span, correctly attributed to the retry attempt, and the ledger can report \"step 9 cost $0.04 across 2 attempts\") and hallucination tags are *per-attempt*, so a retry that fixes a hallucination shows one tagged attempt and one clean attempt — which is the op..."
  },
  "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": "96a30bde0db9c2a01fa22f3f7297add08887ac62d6e85d1b4a5f0a7c83dba40f",
    "verified_classes": [
      "SpanAttributionCollapse",
      "Span",
      "CostLedger"
    ],
    "verified_functions": [
      "reconcile",
      "record"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SpanAttributionCollapse"
    ],
    "sample_fail_closed_invariants": [
      "hallucination tag bound to non-existent span"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
