{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-forensic-replay-from-silently-diverging-when-an-agent-resumes-mid-tool-call",
  "title": "Which invariants prevent forensic replay from silently diverging when an agent resumes mid-tool-call",
  "date_of_record": "2026 November 30",
  "scope": "Applies to deterministic reconstruction of agentic sessions from OpenTelemetry GenAI semantic-convention spans (`gen_ai.*`) when a session is checkpointed and resumed across process boundaries. Does not apply to live tracing, single-shot inference, or sessions whose tool calls are fully idempotent and side-effect-free.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-forensic-replay-from-silently-diverging-when-an-agent-resumes-mid-tool-call.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-forensic-replay-from-silently-diverging-when-an-agent-resumes-mid-tool-call.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-forensic-replay-from-silently-diverging-when-an-agent-resumes-mid-tool-call.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2037,
    "python_slice_tokens": 402,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A GenAI telemetry stream is a *record of what an agent observed*, not a *record of what the environment was*. The two coincide only when every span attribute that the agent's decision depended on is captured and every span boundary is causally ordered. The subtle boundary is this: **an agent that resumes mid-tool-call emits a span whose `parent_span_id` poin...",
    "what_was_observed": "A three-hour agentic session (retrieval-augmented task agent, ~180 tool calls) was checkpointed at a `tool_call` boundary — specifically, after the model emitted a tool call but before the tool result span closed. The process was killed by an OOM killer; the orchestrator resumed from the last durable checkpoint. Post-mortem replay from the OTel collector produced a transcript that diverged from the ground-truth side-...",
    "condition_of_validity": "Deterministic replay from GenAI telemetry is valid **iff** all four of the following hold: - **Span-closure invariant:** every `gen_ai.tool.call` span has a matching `end_time` and a `gen_ai.tool.call.result` attribute, OR is explicitly marked `gen_ai.tool.call.status = \"aborted\"` with a `gen_ai.checkpoint.orphan = true` flag. An open span at checkpoint time...",
    "decision_boundary": "The operational decision is: **when a replay detects a violated invariant, does it (a) halt and flag the trace as unreplayable, or (b) proceed with a best-effort reconstruction and annotate the divergence?** The boundary is drawn by **downstream use**: - If the replay feeds an *auditor agent* whose output is used for safety gating, **halt** (option a). A bes...",
    "operational_effect": "Enforcing the four invariants changes the checkpoint protocol in three concrete ways: 1. **Checkpoints must be span-aligned, not message-aligned.** The checkpoint boundary is the last *closed* span, and any in-flight span is recorded with `gen_ai.checkpoint.orphan = true` and its `gen_ai.tool.call.id`. On resume, the orchestrator must either re-issue with 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": "37a65d93f5e0909404a005f97e07ae8fb4f9755f8b6f8bd3aa09b5fdf8c5c3b9",
    "verified_classes": [
      "ReplayIntegrityError",
      "Span"
    ],
    "verified_functions": [
      "_hash_messages",
      "verify_replayable",
      "replay_decision"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ReplayIntegrityError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "json",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
