{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-drift-past-its-otel-trace-baseline-without-triggering-a-policy-diff-alert-baseline-contamination-via-in-trace-retry-folding",
  "title": "Why does an instance drift past its OTel trace baseline without triggering a policy-diff alert: baseline contamination via in-trace retry folding",
  "date_of_record": "2026 November 28",
  "scope": "Applies to runtime anomaly detectors that derive per-agent behavioral baselines from OpenTelemetry span trees (tool-call latency, fan-out, loop depth, token-per-step ratios) and gate alerts on divergence between an observed trace and a versioned policy snapshot. Does not apply to static policy validation, offline eval harnesses, or detectors keyed on raw log lines rather than span topology.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-drift-past-its-otel-trace-baseline-without-triggering-a-policy-diff-alert-baseline-contamination-via-in-trace-retry-folding.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-drift-past-its-otel-trace-baseline-without-triggering-a-policy-diff-alert-baseline-contamination-via-in-trace-retry-folding.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-drift-past-its-otel-trace-baseline-without-triggering-a-policy-diff-alert-baseline-contamination-via-in-trace-retry-folding.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1993,
    "python_slice_tokens": 384,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two independent things an OTel-based agent monitor can compare: the *trace against the policy* (a diff of declared vs. observed behavior) and the *trace against the baseline* (a statistical divergence from the agent's own historical distribution). Most deployments wire these as an OR: alert if policy-diff is non-empty **or** if baseline z-score exc...",
    "what_was_observed": "An agent (`planner-v7`) executing a 9-step task plan began emitting `tool.call` spans with `retry.count > 0` on roughly 40% of invocations after a downstream MCP server (`fs-read`) started returning intermittent `-32000` transport errors. The retry logic inside the agent's tool executor is correct: it re-issues the call up to 3 times with backoff, and the *logical* step succeeds. The span tree, however, records each ...",
    "condition_of_validity": "The contamination is bounded and detectable only under these conditions: - **Retry folding is enabled at the exporter** (default in `opentelemetry-sdk` ≥ 1.22 when `span.attributes[\"retry.count\"]` is set by the instrumentor). If the deployment emits retries as *sibling* spans rather than folded children, the baseline key naturally separates them and the fail...",
    "decision_boundary": "The correct guardrail is not \"raise the threshold\" or \"lengthen the window\" — both make the detector slower without fixing the comparability violation. The guardrail is a **baseline key partition** enforced at ingestion: 1. Every span admitted to the baseline MUST carry a `retry.count` attribute (default `0` if absent — but absence must be *distinguished* fr...",
    "operational_effect": "After partitioning the baseline key and adding the retry-count assertion to the diff engine, the `fs-read` incident is caught at trace 12 rather than never: the first retry-folded span is rejected from the canonical baseline, the diff engine raises `RetryBudgetExceeded` because `retry.count=1 > declared 0`, and the on-call is paged while the p95 is still `1...."
  },
  "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": "6f52c3db7b2743d3aff1074ef24a2c37cc252dba341bf76f8c7a467041aed13c",
    "verified_classes": [
      "BaselineContaminationError",
      "RetryBudgetExceeded",
      "Span"
    ],
    "verified_functions": [
      "admit_to_baseline",
      "check_policy_diff",
      "ingest"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "BaselineContaminationError",
      "RetryBudgetExceeded"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
