{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-checkpoint-divergence-when-lossy-auto-compaction-rewrites-the-history-a-checkpoint-was-taken-against",
  "title": "Which invariants prevent checkpoint divergence when lossy auto-compaction rewrites the history a checkpoint was taken against",
  "date_of_record": "2026 December 1",
  "scope": "Applies to long-horizon agent loops (>N turns) that persist recovery checkpoints and also mutate their own conversation/working state via lossy summarization (\"auto-compaction\") under a token budget. Does not apply to stateless single-turn inference, nor to append-only transcript stores that never rewrite prior segments.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-checkpoint-divergence-when-lossy-auto-compaction-rewrites-the-history-a-checkpoint-was-taken-against.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-checkpoint-divergence-when-lossy-auto-compaction-rewrites-the-history-a-checkpoint-was-taken-against.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-checkpoint-divergence-when-lossy-auto-compaction-rewrites-the-history-a-checkpoint-was-taken-against.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2019,
    "python_slice_tokens": 430,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two distinct notions of \"the state\" in a checkpointed agent, and they silently diverge the moment auto-compaction runs: - **The transcript state** — the literal token sequence (messages, tool results, reasoning traces) that the model will re-ingest on resume. - **The semantic state** — the set of facts, commitments, and partially-completed subgoals...",
    "what_was_observed": "A coding agent running a 200+ turn refactor loop with a 96k working-context budget and a 12k compaction target. Checkpoints were taken every 10 turns and stored as `(turn_id, transcript_hash, token_count, summary_blob)`. Auto-compaction fired at 90% budget. The trace: 1. Turn 118: budget hits 91%. Compaction triggers. The summarizer is asked to fit turns 1–60 into ≤3k tokens. It drops a mid-loop tool result — a speci...",
    "condition_of_validity": "A checkpoint is a valid recovery point **iff** all three hold simultaneously: - **C1 — Referent immutability or re-derivation.** Either the transcript segment the checkpoint points at is frozen (compaction appends a new segment rather than rewriting the old one; the checkpoint keeps pointing at the frozen prefix), or the checkpoint is re-derived (summary reg...",
    "decision_boundary": "The operational choice is between two strategies, and the boundary between them is the **cost of re-derivation vs. cost of divergence**: - If compaction is cheap and idempotent (summarizer deterministic, or summary is a pure function of a frozen segment), choose **re-derive-on-compaction**: every compaction invalidates and regenerates all checkpoints whose w...",
    "operational_effect": "The invariant to enforce in code is: **a checkpoint carries a `(frozen_segment_id, summary_budget, effect_ledger_watermark)` triple, and resume refuses unless all three still resolve.** This converts the failure from silent divergence into a loud, bounded refusal. The effect ledger watermark is the load-bearing field — it is what lets the agent detect that t..."
  },
  "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": "deeb8bed6d891dfa34f47809896cdfe8771fb423c275977be8bae4bdc6260110",
    "verified_classes": [
      "CheckpointDivergenceError",
      "Checkpoint",
      "CompactionEvent"
    ],
    "verified_functions": [
      "validate_resume",
      "resume"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "CheckpointDivergenceError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
