{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-tail-biased-sampler-collapse-from-erasing-the-only-spans-that-explain-a-failed-agent-run",
  "title": "Which invariants prevent tail-biased sampler collapse from erasing the only spans that explain a failed agent run",
  "date_of_record": "2026 November 24",
  "scope": "Applies to distributed tracing of LLM agent runs where spans are retained under an adaptive, cost-aware sampling policy keyed on latency, token count, or error status. Does not apply to full-capture regimes, nor to trace stores where retention decisions are made after an immutable, complete trace has already been persisted.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-tail-biased-sampler-collapse-from-erasing-the-only-spans-that-explain-a-failed-agent-run.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-tail-biased-sampler-collapse-from-erasing-the-only-spans-that-explain-a-failed-agent-run.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-tail-biased-sampler-collapse-from-erasing-the-only-spans-that-explain-a-failed-agent-run.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2646,
    "python_slice_tokens": 546,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that governs everything here is between *sampling for volume reduction* and *sampling for causal sufficiency*. Head-based uniform sampling is statistically honest: every span has the same inclusion probability, so aggregates are unbiased. Tail-based and cost-aware sampling are not. They condition inclusion on observable span properties (durat...",
    "what_was_observed": "Across a week of agent runs instrumented with an adaptive sampler configured with `max_retained_tokens=200_000` per trace and per-span drop rules on `llm.generate` spans exceeding 40k input tokens, the following pattern recurred on a specific class of failure. Trigger condition: a multi-step agent task where step *k* produces a prompt whose size crosses the 40k threshold, the model emits a malformed tool-call argumen...",
    "condition_of_validity": "The invariant that must hold for a cost-aware sampler to remain causally sufficient is: > For every retained span *s* with `status=ERROR` or `status=FAILED`, every span *t* that *s* causally depends on (its ancestors in the trace DAG, and any sibling whose output *s* consumed) must either be retained, or be explicitly marked as `retention_dropped=true` with ...",
    "decision_boundary": "The boundary between admissible and inadmissible retention is sharp: - **Admissible:** retain-on-error with backward causal closure. When any span transitions to `ERROR`, the sampler walks its ancestor chain and its consumed-sibling set and pins them for retention regardless of cost. Budget overruns are permitted and recorded as `budget_exceeded=true` on the...",
    "operational_effect": "The practical consequence is that cost-aware sampling must be *causality-aware* to be safe, and causality-awareness has a cost that must be budgeted explicitly rather than discovered at trace-close. Concretely: - Error-bearing traces will exceed their token budgets. Plan for a small fraction of traces (typically 1–5% under compounding-error regimes) to run 2..."
  },
  "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": "7b718761c3e0ec0e36f8a1b0fe7ae2ddcd64ace288a01d342c7976ecebae7028",
    "verified_classes": [
      "RetentionDecision",
      "CausalClosureViolation",
      "Span",
      "Trace"
    ],
    "verified_functions": [
      "enforce_causal_closure",
      "apply_greedy_budget",
      "apply_closure_preserving_budget",
      "add",
      "ancestors"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "CausalClosureViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
