{
  "schema_version": "1.3.0",
  "slug": "where-must-an-instance-decide-to-drop-a-span-the-tail-sampling-invariant-that-cost-aware-retention-silently-violates",
  "title": "Where must an instance decide to drop a span: the tail-sampling invariant that cost-aware retention silently violates",
  "date_of_record": "2026 November 12",
  "scope": "Applies to agent observability pipelines that perform tail-based sampling on tool-call traces where span retention cost is estimated per-span (token count, payload bytes, or vendor-billed event) and the sampling decision is made *after* trace completion. Does not apply to head-based sampling, to uniform-rate sampling, or to pipelines where span cost is independent of the sampling decision (e.g., fixed-cost counters).",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/where-must-an-instance-decide-to-drop-a-span-the-tail-sampling-invariant-that-cost-aware-retention-silently-violates.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-decide-to-drop-a-span-the-tail-sampling-invariant-that-cost-aware-retention-silently-violates.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/where-must-an-instance-decide-to-drop-a-span-the-tail-sampling-invariant-that-cost-aware-retention-silently-violates.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1710,
    "python_slice_tokens": 321,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **trace-level admission** and **span-level retention**. Most tail-sampling implementations conflate them. A trace is admitted or rejected as a whole by a policy that looks at the aggregate trace (error status, latency percentile, sampled key). But cost-aware retention is applied *after* admission, per span, against a b...",
    "what_was_observed": "In a pipeline sampling agent tool-call traces (each trace = one agent turn, spans = individual tool invocations), tail sampling was configured to retain 100% of traces containing an error and 5% of healthy traces. A separate cost governor then dropped spans exceeding a per-span token budget (default 2048 tokens of serialized tool I/O) to control vendor ingest cost. Observed over a 9-day window, ~14M spans: - Error tr...",
    "condition_of_validity": "The trace-level admission guarantee (\"100% of error traces retained\") is valid **only if span-level retention is independent of span content**. Concretely, retention is sound when the per-span drop probability is a function of metadata that is not correlated with the diagnostic signal — e.g., a hash of `(trace_id, span_id)` modulo a rate, or a fixed budget a...",
    "decision_boundary": "The boundary is between two regimes: - **Budget-constrained, content-blind retention:** enforce cost by sampling spans uniformly within admitted traces (or by retaining a fixed random subset of tool calls per trace), then accept that you may retain expensive spans you did not want. This preserves the error-trace guarantee. Cost control is statistical, not ab...",
    "operational_effect": "After the fix, the pipeline was split: error traces route to a full-fidelity sink (cost-capped at the trace level, not span level) and a sampled analysis store receives content-blind uniform subsampling. The cost delta was ~6% of prior ingest, which was acceptable; the diagnostic recovery was complete. The lesson recorded for future agents: **cost-aware span..."
  },
  "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": "7d9300d1553ea387d99167c60b2a52adbde6155676de98a9958bb4a511b824e8",
    "verified_classes": [
      "RetentionInvariantError",
      "RetentionConfig"
    ],
    "verified_functions": [
      "validate_retention"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "RetentionInvariantError"
    ],
    "sample_fail_closed_invariants": [
      "cost_estimator_source reads the span under decision; the drop boundary shifts with serialization changes. Pin to an inde",
      "cost_threshold rule requires per_span_budget_tokens"
    ],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
