{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-diverges-mid-trace-causal-replay-failure-under-non-deterministic-sampling-and-the-counterfactual-logging-invariant",
  "title": "What happens when an instance diverges mid-trace: causal replay failure under non-deterministic sampling and the counterfactual logging invariant",
  "date_of_record": "2026 November 22",
  "scope": "Applies to observability and replay infrastructure for agent traces that capture sampled LLM calls, tool invocations, and inter-agent handoffs where the sampling seed, model version, or tool output is non-deterministic across re-execution. Does not apply to deterministic function-call graphs or to traces recorded with full input/output capture at every node where replay is byte-exact by construction.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-diverges-mid-trace-causal-replay-failure-under-non-deterministic-sampling-and-the-counterfactual-logging-invariant.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-diverges-mid-trace-causal-replay-failure-under-non-deterministic-sampling-and-the-counterfactual-logging-invariant.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-diverges-mid-trace-causal-replay-failure-under-non-deterministic-sampling-and-the-counterfactual-logging-invariant.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2108,
    "python_slice_tokens": 480,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The common assumption in agent observability is that a \"trace\" is a log of what happened, and that \"causal replay\" reconstructs the execution by re-running the recorded steps. This conflates two fundamentally different objects: - **A recorded trace** is a sequence of observations: prompts sent, tokens sampled, tool results returned, state mutations applied. ...",
    "what_was_observed": "An agent (call it the planner) executes a 14-step task: retrieve documents, summarize, call a code tool, verify, and emit a structured answer. The observability layer records each step as `{prompt_hash, response_text, tool_name, tool_args, tool_result, timestamp}`. During an incident review, an engineer replays the trace to determine why the planner chose tool `B` over tool `A` at step 9. The replay runs cleanly. Eve...",
    "condition_of_validity": "Causal replay is valid **only** under the *pinned-output invariant*: for every step *i* in the trace, the replay must consume the *recorded* output of step *i* rather than re-executing step *i*, unless step *i* is explicitly marked `deterministic=true` and verified so. Formally, replay of step *k* is causally faithful iff: The invariant fails in three concre...",
    "decision_boundary": "The operational decision is: *at each trace node, do we pin or re-execute?* The boundary is drawn by a per-node determinism attestation, not by node type. A retrieval call is non-deterministic by default; a pure arithmetic tool is deterministic only if its registry entry is content-hashed and the hash matches at replay time. The decision rule: - If `node.pin...",
    "operational_effect": "When the pinned-output invariant is enforced, three things change: 1. **Replay becomes a verifier, not a re-enactor.** The replay's job is to confirm that the recorded outputs *entail* the recorded decisions, not to regenerate them. Divergence at a pinned node is a hard error (`ReplayDivergence`), because it means the trace itself is corrupt or the model ver..."
  },
  "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": "b5c384ae81f888fb475bb18fa2f756bf7c3cc8fcc575f215e2f903ed34378c61",
    "verified_classes": [
      "UnpinnedNonDeterministicNode",
      "ReplayDivergence",
      "TraceNode"
    ],
    "verified_functions": [
      "_hash",
      "causal_replay",
      "assert_faithful"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ReplayDivergence",
      "UnpinnedNonDeterministicNode",
      "ValueError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
