{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-causal-replay-of-agent-traces-from-silently-rewriting-history-when-tool-outputs-are-re-sampled",
  "title": "Which invariants prevent causal replay of agent traces from silently rewriting history when tool outputs are re-sampled",
  "date_of_record": "2026 November 26",
  "scope": "Applies to agent runtimes that persist per-step traces (prompt, sampled tool result, model output) and offer causal replay or counterfactual debugging by re-executing a suffix of the trace. Does not cover pure logging pipelines with no re-execution, nor offline evaluation harnesses that never claim step-level equivalence to a prior live run.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-causal-replay-of-agent-traces-from-silently-rewriting-history-when-tool-outputs-are-re-sampled.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-causal-replay-of-agent-traces-from-silently-rewriting-history-when-tool-outputs-are-re-sampled.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-causal-replay-of-agent-traces-from-silently-rewriting-history-when-tool-outputs-are-re-sampled.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1871,
    "python_slice_tokens": 392,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There is a difference between *replaying a trace* and *re-deriving a trace*. A replay asserts that step *n* is causally identical to the recorded step *n*: same inputs, same tool call, same returned bytes, same model decision. A re-derivation re-runs the agent from a checkpoint and lets non-determinism (sampling temperature, tool latency, external API state,...",
    "what_was_observed": "A support-triage agent was instrumented with a trace store. Each step recorded `{step_id, prompt_hash, tool_name, tool_args, tool_output, model_output, parent_step}`. A failure was reported: at step 7 the agent called `lookup_order(order_id=\"A-4412\")`, received `{\"status\": \"shipped\"}`, and at step 8 issued a refund. The reviewer opened causal replay from step 6. The replay engine, by design, re-executed steps rather ...",
    "condition_of_validity": "Causal replay is only valid when the following hold simultaneously: - **Input immutability:** every step's consumed inputs are content-addressed (`sha256` over canonicalized prompt + tool_args) and stored *with* the step, not recomputed at replay time. - **Output provenance:** each recorded tool output is tagged `recorded` or `replayed`, and a replay that su...",
    "decision_boundary": "The operative question at replay time is: *does this step re-execute or re-read?* - If the step's tool is declared world-coupled **and** a recorded output exists → **re-read**. Re-execution is forbidden; a re-executed world-coupled step is a new experiment, not a replay. - If the step's tool is declared deterministic-by-contract **and** the input fingerprint...",
    "operational_effect": "Enforcing these invariants changes three things in practice. First, trace stores gain a uniqueness constraint on step identity and a `input_fingerprint` column; the collision class above becomes a write-time error instead of a silent overwrite discovered weeks later during a debugging session that itself lies. Second, replay engines gain a `replay_mode` per ..."
  },
  "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": "c7e27d63eafdad39b50a4b177013f5e392025146e0eadeb8972eeb83656e2c95",
    "verified_classes": [
      "ReplayInvariantError",
      "ReplayMode",
      "Step"
    ],
    "verified_functions": [
      "fingerprint",
      "replay_step",
      "replay_run",
      "step_key"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ReplayInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
