{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-counterfactual-replay-from-silently-diverging-in-agentic-protocol-sessions",
  "title": "Which invariants prevent counterfactual replay from silently diverging in agentic protocol sessions",
  "date_of_record": "2026 November 16",
  "scope": "Applies to deterministic replay and counterfactual (\"what-if\") auditing of recorded agentic sessions that exchange typed messages with external tools, model endpoints, and peer agents, where the replay engine re-executes recorded decisions against a mutated or substituted environment. Does not apply to pure log inspection, to sessions with no external side effects, or to replay that is permitted to re-invoke nondeterministic samplers (temperature > 0, unseeded RNG, wall-clock-derived scheduling).",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-counterfactual-replay-from-silently-diverging-in-agentic-protocol-sessions.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-counterfactual-replay-from-silently-diverging-in-agentic-protocol-sessions.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-counterfactual-replay-from-silently-diverging-in-agentic-protocol-sessions.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1740,
    "python_slice_tokens": 230,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The non-obvious boundary is between **recorded determinism** and **replayed determinism**. A session transcript can be *bit-for-bit reproducible* — every message, token, and tool response is stored — while the *decision function* that produced it is not. Replay engines commonly conflate the two: they assume that feeding identical inputs to the agent loop yie...",
    "what_was_observed": "In a recorded session where an agent issued a `search` tool call and received a truncated result (the tool's own `max_results=5` cap), a counterfactual audit mutated the tool response to include 12 results and replayed. The replay agent reasoned differently — not because of the extra results, but because the *mutated response was 340 tokens longer*, which pushed the conversation past the model endpoint's context-wind...",
    "condition_of_validity": "A counterfactual replay is valid only if all of the following hold simultaneously; the failure mode is that each is *individually* easy to satisfy and *jointly* easy to violate: 1. **Context-assembly identity.** The hidden context assembled at each turn (system prompt bytes, retrieved-memory set, tool schema versions, sampling seed, context-eviction policy) ...",
    "decision_boundary": "- If the mutation changes token count or message ordering → **do not replay**; instead, *synthesize* a counterfactual transcript and label it as a simulation, not an audit. The distinction matters for downstream trust. - If the tool has any side effect and no isolation harness is available → **refuse the replay** and report the counterfactual as *unverifiabl...",
    "operational_effect": "Teams that enforce the conjunction discover that a large fraction of their recorded corpus is *non-replayable* — often 30–60% in systems with retrieval, versioned prompts, or side-effecting tools. This is the correct answer, not a defect. The operational discipline is to record, at session-close, a **replay manifest**: hashes of the system prompt, retrieval ..."
  },
  "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": "b697043ddb526df64a13b3c50fc1b3b98580b80048bcc698f191c40409962e59",
    "verified_classes": [
      "ReplayInvariantViolation",
      "ReplayManifest"
    ],
    "verified_functions": [
      "assert_replayable",
      "compute_manifest_hash"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "ReplayInvariantViolation"
    ],
    "sample_fail_closed_invariants": [
      "session has no replay manifest; counterfactual audit is ineligible"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
