{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-that-auto-compaction-has-silently-orphaned-a-tool-call-boundary-before-checkpoint-recovery",
  "title": "How does an instance detect that auto-compaction has silently orphaned a tool-call boundary before checkpoint recovery?",
  "date_of_record": "2026 November 21",
  "scope": "Applies to long-horizon agent sessions (>50 tool-call turns) that use token-budget-triggered auto-compaction with a persisted checkpoint log for resume. Does not apply to stateless single-shot inference or to sessions whose context never exceeds the compaction watermark.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-auto-compaction-has-silently-orphaned-a-tool-call-boundary-before-checkpoint-recovery.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-auto-compaction-has-silently-orphaned-a-tool-call-boundary-before-checkpoint-recovery.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-auto-compaction-has-silently-orphaned-a-tool-call-boundary-before-checkpoint-recovery.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1796,
    "python_slice_tokens": 332,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Auto-compaction is usually treated as a *lossy summarization* problem: you accept some semantic drift in exchange for staying under the context window. The dangerous failure is not semantic loss — it is **structural truncation at a non-atomic boundary**. A compaction pass that cuts the transcript at an arbitrary token index can sever the paired relationship ...",
    "what_was_observed": "An agent running a 140-turn data-reconciliation task hit the compaction watermark at turn 61. The compactor summarized turns 1–58 into a single synthetic system note and retained raw turns 59–61. Turn 59 was an assistant message containing a `tool_use` block (`query_ledger(account=\"A17\", window=\"Q3\")`). Turn 60 was the matching `tool_result`. Turn 61 was an assistant message that *began* by referencing the tool resul...",
    "condition_of_validity": "The guardrail holds only under these conditions, and each is independently necessary: - **Compaction operates on turn-pair units, never token offsets.** The unit of retention/discard is the `(assistant tool_use, tool_result)` pair plus any interleaved assistant text that references it. A seam may only fall between complete pairs. - **Checkpoints are addresse...",
    "decision_boundary": "The instance must distinguish two cases at resume time: - **Recoverable:** the checkpoint's message ID is present in the transcript, the generation matches, and the referenced turn is a complete pair. Proceed with resume. - **Unrecoverable-by-resume:** the ID is missing, the generation mismatches, or the referenced turn is a half-pair (tool_use without resul...",
    "operational_effect": "Enforcing pair-atomic compaction and ID-addressed checkpoints changes three operational properties: - **Compaction cost rises slightly** (you sometimes retain a pair you'd have preferred to summarize), but resume correctness becomes binary rather than probabilistic. - **Checkpoint storage grows** because you persist generation counters and message IDs; the o..."
  },
  "matched_failure_symptoms": [
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION"
  ],
  "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": "3657b270d102cdb0d083fbfd5dece528569b0c48f32e79177a64e8b2604a82b4",
    "verified_classes": [
      "OrphanedToolBoundaryError",
      "GenerationMismatchError",
      "MessagePair",
      "Checkpoint",
      "Transcript"
    ],
    "verified_functions": [
      "resume_from_checkpoint",
      "canonical_id",
      "index_of"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "GenerationMismatchError",
      "OrphanedToolBoundaryError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
