{
  "schema_version": "1.3.0",
  "slug": "under-what-conditions-must-an-instance-refuse-to-replay-a-genai-trace-non-idempotent-tool-side-effects-and-the-replay-eligibility-invariant",
  "title": "Under what conditions must an instance refuse to replay a GenAI trace: non-idempotent tool side effects and the replay-eligibility invariant",
  "date_of_record": "2026 December 2",
  "scope": "Applies to post-hoc deterministic replay and counterfactual debugging of agent trajectories reconstructed from OpenTelemetry GenAI semantic-convention spans (`gen_ai.*` attributes, `execute_tool` spans, `invoke_agent` spans, `chat` spans). Does not apply to pure model-only traces with no tool execution spans, nor to live shadow-traffic replay where the environment is forked and isolated.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-replay-a-genai-trace-non-idempotent-tool-side-effects-and-the-replay-eligibility-invariant.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-replay-a-genai-trace-non-idempotent-tool-side-effects-and-the-replay-eligibility-invariant.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/under-what-conditions-must-an-instance-refuse-to-replay-a-genai-trace-non-idempotent-tool-side-effects-and-the-replay-eligibility-invariant.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2590,
    "python_slice_tokens": 720,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There is a class of replay failure that is *not* a data-loss problem and *not* a nondeterminism problem. It is an **eligibility** problem. A GenAI trace can be perfectly complete—every span exported, every `gen_ai.tool.call.id` present, every `gen_ai.request.temperature` recorded as `0`, every `gen_ai.usage.*` count consistent—and still be **unreplayable**, ...",
    "what_was_observed": "A debugging session on a 14-step agent trajectory (customer-support refund agent) exported via OTel GenAI conventions. The trace contained: - 9 `chat` spans (`gen_ai.operation.name = \"chat\"`, `gen_ai.request.temperature = 0`). - 4 `execute_tool` spans: `lookup_order`, `check_refund_policy`, `issue_refund`, `send_confirmation`. - 1 `execute_tool` span that **failed** with `gen_ai.tool.call.error = \"rate_limited\"` at s...",
    "condition_of_validity": "Deterministic replay of a GenAI agent trajectory is sound **if and only if** the following invariant holds for every `execute_tool` span in the trajectory: > **Replay-Eligibility Invariant (REI):** For every `execute_tool` span *s* in trajectory *T*, either (a) *s* is marked replay-safe (declared idempotent and side-effect-free, or its recorded output is sub...",
    "decision_boundary": "The boundary is sharp and must be enforced before the first replayed `chat` span is emitted: - **Admit replay** when: all tool spans on the counterfactual branch have `gen_ai.tool.call.result` or `gen_ai.tool.call.error` present, *and* the harness is in `SUBSTITUTE` mode (never `REINVOKE`), *and* the counterfactual injection point is downstream of any span w...",
    "operational_effect": "The operational consequence is that GenAI telemetry replay harnesses must carry an **eligibility pre-pass** that runs over the span tree before any `chat` span is re-emitted. The pre-pass: 1. Walks all `execute_tool` spans on the counterfactual branch. 2. Checks for `gen_ai.tool.call.result` or `gen_ai.tool.call.error`. 3. Checks the harness mode flag (must ..."
  },
  "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": "6b796a2185300f34f189ceabe1b993291443fa62ea6c15c83988dc15901620ad",
    "verified_classes": [
      "ReplayIneligibleError",
      "HarnessMode",
      "ToolSpan",
      "ReplayEligibility"
    ],
    "verified_functions": [
      "check_replay_eligibility",
      "replay_trajectory"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ReplayIneligibleError"
    ],
    "sample_fail_closed_invariants": [
      "counterfactual asks 'what would the tool return now'; this is simulation and requires environment forking, not trace rep"
    ],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
