{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-replays-a-genai-trace-whose-tool-call-spans-were-reordered-by-the-collector-s-batch-exporter",
  "title": "What happens when an instance replays a GenAI trace whose tool-call spans were reordered by the collector's batch exporter",
  "date_of_record": "2026 November 21",
  "scope": "Applies to deterministic replay of agent sessions reconstructed from OpenTelemetry GenAI semantic-convention event logs (spans carrying `gen_ai.*` attributes plus `gen_ai.tool.call` / message events), where spans are exported via an asynchronous batching processor. Does not apply to synchronous exporters that preserve emission order, nor to traces captured with a single-span-per-session custom envelope.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-replays-a-genai-trace-whose-tool-call-spans-were-reordered-by-the-collector-s-batch-exporter.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-replays-a-genai-trace-whose-tool-call-spans-were-reordered-by-the-collector-s-batch-exporter.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-replays-a-genai-trace-whose-tool-call-spans-were-reordered-by-the-collector-s-batch-exporter.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1850,
    "python_slice_tokens": 403,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two different things practitioners call \"replay.\" The first is *semantic replay*: feed the recorded prompts and tool outputs back to a model and let it regenerate reasoning; divergence from the original run is expected and is the point. The second is *deterministic replay*: reconstruct the exact causal sequence of model invocations and tool executi...",
    "what_was_observed": "A single agent session with three tool calls in one turn — `search_docs`, `read_file`, `write_file` — where `write_file` depends on the handle returned by `read_file`. The trace arrived at the backend with all four spans present and all `parent_span_id` values correct. But the batch processor had flushed the `write_file` span in an earlier batch than the `read_file` span, because `write_file` completed fast (cache hi...",
    "condition_of_validity": "The failure requires all of the following to co-occur: 1. **Asynchronous batch export** with a queue large enough that spans from one turn land in different batches, or a schedule delay long enough that a fast child span flushes before its slower sibling. 2. **Cross-process or cross-host clock skew** exceeding the inter-span delta, so that `start_time_unix_n...",
    "decision_boundary": "The guardrail is a **replay admission check** that runs before any step is executed, and it must reject the trace rather than guess. The rule: - Build the causal DAG from `parent_span_id` edges. This is authoritative and survives reordering. - For each parent, order children by `(start_time_unix_nano, span_id)` but only *after* verifying that the max `end_ti...",
    "operational_effect": "On our fleet this check converted a class of silent replay divergences into hard admission failures. Before: ~0.7% of replay sessions produced a final-state hash mismatch with no error, and we spent days attributing them to model non-determinism. After: those sessions are rejected at admission with a `ReplayOrderingError` naming the conflicting spans, and th..."
  },
  "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": "4de8cfd743460b0050d7f1f0d65e45e4931e5f7831785f13581ef9a5b5d2f96d",
    "verified_classes": [
      "ReplayOrderingError",
      "Span"
    ],
    "verified_functions": [
      "admit_for_replay",
      "visit"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ReplayOrderingError"
    ],
    "sample_fail_closed_invariants": [
      "duplicate span_id in trace; cannot build DAG",
      "cycle or disconnected component in span DAG; trace is not a single causal chain and cannot be replayed as one session"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
