{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-deterministic-replay-of-agent-traces-when-opentelemetry-genai-span-attributes-are-truncated-reordered-or-sampled-away",
  "title": "Which invariants prevent deterministic replay of agent traces when OpenTelemetry GenAI span attributes are truncated, reordered, or sampled away",
  "date_of_record": "2026 December 1",
  "scope": "Applies to incident forensics on LLM agent runs instrumented with OpenTelemetry GenAI semantic conventions (`gen_ai.*` attributes) where replay is expected to reproduce a failure from recorded spans. Does not apply to live-traffic debugging, metrics-only dashboards, or traces where the agent runtime emits a bespoke, lossless event log outside OTel.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-deterministic-replay-of-agent-traces-when-opentelemetry-genai-span-attributes-are-truncated-reordered-or-sampled-away.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-deterministic-replay-of-agent-traces-when-opentelemetry-genai-span-attributes-are-truncated-reordered-or-sampled-away.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-deterministic-replay-of-agent-traces-when-opentelemetry-genai-span-attributes-are-truncated-reordered-or-sampled-away.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1993,
    "python_slice_tokens": 249,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A span is a *telemetry record*, not a *decision record*. The distinction matters because deterministic replay requires the second thing while forensics teams typically only have the first. An OTel GenAI span captures that a `gen_ai.chat` operation happened, its model, token counts, and (optionally) inputs/outputs — but the agent's *control decision* (which t...",
    "what_was_observed": "A support-triage agent (planner → retriever → tool-caller → synthesizer, four LLM calls per turn) failed on 0.4% of turns with a wrong-account action. The team pulled the trace from the collector and attempted replay in a harness that fed recorded `gen_ai.prompt.*` / `gen_ai.completion.*` attributes back into the same model with `temperature=0`, expecting the same tool calls. Replay diverged on 61% of sampled failing...",
    "condition_of_validity": "Replay is sound only when all of the following hold, and the harness must *assert* them rather than assume them: - **Completeness:** every `gen_ai.*` span in the causal path is present, and no attribute marked as decision-bearing (`gen_ai.prompt`, `gen_ai.completion`, tool arguments, retrieved-context references) was truncated. Truncation must be detectable ...",
    "decision_boundary": "The boundary is between **replay as reconstruction** and **replay as verification**. Reconstruction (feed recorded inputs, observe outputs, infer the decision) is what most harnesses do and is unsound under any of the three transforms above — it produces a trace that is consistent with the evidence but not entailed by it. Verification (assert that the record...",
    "operational_effect": "Instrumentation must be redesigned so the decision record is separable from the telemetry record. Concretely: emit a structured `gen_ai.decision` event (or a sidecar log) containing the full pre-truncation prompt hash, the retrieved-context document IDs (not the text), the tool-call arguments, and an explicit step index — small, bounded, and lossless — along..."
  },
  "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": "dd669c30ca3543822281724e68c7ab3ef8da97e7939c019179995058543be560",
    "verified_classes": [
      "ReplayInvariantViolation",
      "GenAISpan"
    ],
    "verified_functions": [
      "assert_replayable",
      "replay_turn"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ReplayInvariantViolation"
    ],
    "sample_fail_closed_invariants": [
      "empty span set: nothing to replay",
      "step_index sequence is non-monotonic; exporter reordering suspected"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
