{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-divergence-between-its-recorded-trajectory-and-a-replayed-counterfactual-when-tool-outputs-are-non-deterministic-and-the-r",
  "title": "How does an instance detect divergence between its recorded trajectory and a replayed counterfactual when tool outputs are non-deterministic and the replay harness silently substitutes cached observations?",
  "date_of_record": "2026 November 28",
  "scope": "Applies to agent observability pipelines that reconstruct past trajectories for counterfactual debugging by replaying recorded steps against a live or mocked environment. Does not apply to pure post-hoc log inspection where no re-execution occurs, nor to deterministic tool environments with byte-identical replay.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-divergence-between-its-recorded-trajectory-and-a-replayed-counterfactual-when-tool-outputs-are-non-deterministic-and-the-r.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-divergence-between-its-recorded-trajectory-and-a-replayed-counterfactual-when-tool-outputs-are-non-deterministic-and-the-r.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-divergence-between-its-recorded-trajectory-and-a-replayed-counterfactual-when-tool-outputs-are-non-deterministic-and-the-r.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2177,
    "python_slice_tokens": 363,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters is between **causal replay** and **observational replay**. Causal replay re-executes each step against the environment and accepts whatever the tool returns, treating the new output as ground truth for the counterfactual branch. Observational replay feeds the agent the *recorded* outputs from the original trajectory so that the r...",
    "what_was_observed": "A coding agent was recorded over a 41-step trajectory debugging a failing test. Step 22 called `run_tests`, which returned a 340-line failure log; step 23 called `read_file(\"src/parser.py\")`, returning a 210-line file. The trajectory was persisted with per-step observation hashes. An engineer opened a counterfactual replay to test whether a modified system prompt (\"prefer minimal diffs\") would have changed the fix. T...",
    "condition_of_validity": "A counterfactual replay is only attributable to the perturbed variable if the following invariant holds across the entire replay: > For every step `i` in the counterfactual branch, the observation delivered to the agent is either (a) byte-identical to the recorded observation at the corresponding step of the original trajectory, or (b) explicitly marked as a...",
    "decision_boundary": "The boundary is between **replay as experiment** and **replay as demonstration**. If the goal is to attribute a behavioral delta to a specific perturbation, the harness must enforce observational mode up to the perturbation point and refuse to serve any observation that does not hash-match the record—failing loudly on cache miss rather than falling back to l...",
    "operational_effect": "Without provenance tracking, observability pipelines systematically over-attribute divergence to the variable the engineer chose to perturb, because the cache's silent fallbacks inject uncontrolled variation that the attribution logic never sees. The measured effect in this pipeline was a 3.4× overestimate of prompt sensitivity across 200 sampled counterfact..."
  },
  "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": "c77f3519cf0d6342242ba398b43a7e31d88fa949307974838ee925fe6834b77b",
    "verified_classes": [
      "ReplayMode",
      "ObservationProvenance",
      "ReplayDivergenceError",
      "Observation",
      "RecordedStep"
    ],
    "verified_functions": [
      "enforce_observational_prefix",
      "validate_counterfactual_report",
      "payload_hash"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ReplayDivergenceError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
