{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-context-diff-self-edits-from-corrupting-rollback-checkpoints",
  "title": "Which invariants prevent context-diff self-edits from corrupting rollback checkpoints",
  "date_of_record": "2026 November 30",
  "scope": "Applies to agents that mutate their own working context by emitting structured diffs (insert/delete/replace spans) against a checkpointed context, then commit or roll back based on a verifier signal. Does not cover external file-system edits or human-authored prompts; only model-generated self-edits to the live context buffer.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-context-diff-self-edits-from-corrupting-rollback-checkpoints.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-context-diff-self-edits-from-corrupting-rollback-checkpoints.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-context-diff-self-edits-from-corrupting-rollback-checkpoints.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1545,
    "python_slice_tokens": 329,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A rollback checkpoint is *not* a snapshot of text — it is a snapshot of a **context state plus its diff lineage**. The common intuition is that a checkpoint lets you \"undo\" by restoring bytes. That intuition fails because a model-generated diff is authored against a *specific* base context the model was attending to, not against the checkpoint's stored bytes...",
    "what_was_observed": "A planner agent ran a long tool-use loop, checkpointing the context every N=8 turns. At turn 41 it emitted a self-edit diff deleting a 300-token block of stale tool output (a failed search) and inserting a distilled summary. The verifier accepted the edit (the summary was faithful). The agent then hit a token-budget wall at turn 44, and the orchestrator rolled back to the turn-40 checkpoint. The rollback restored the...",
    "condition_of_validity": "The base-hash invariant holds only under three simultaneous conditions, and it is worth stating them because violating any one reintroduces the failure: 1. **Checkpoints are immutable once sealed.** Any compaction, summarization, or eviction that touches a checkpointed state must produce a *new* checkpoint with a new hash, never mutate the sealed one. The tu...",
    "decision_boundary": "The operational rule is a hard rejection, not a fuzzy match: - If `diff.base_hash == checkpoint.restore_hash` → apply, advance lineage. - If `diff.base_hash != checkpoint.restore_hash` → the diff is **inadmissible**. Do not attempt offset correction, do not fuzzy-merge, do not \"best effort\" apply. Quarantine the diff, mark the checkpoint lineage as *diverged...",
    "operational_effect": "With base-hash anchoring enforced at authoring, seal, and every replay hop, the turn-41 class of failure becomes a loud rejection at the diff boundary rather than a silent corruption at resume. The cost is that self-editing agents must re-author edits after any rollback (they cannot replay pre-rollback diffs forward), which increases token spend on resume. T..."
  },
  "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": "da2723b88006e7942598afb41eb0c381caba46b90cd903cbdae1341bf51fe676",
    "verified_classes": [
      "ContextDiffInadmissible",
      "CheckpointTainted",
      "Checkpoint",
      "ContextDiff",
      "Lineage"
    ],
    "verified_functions": [
      "_hash",
      "seal_checkpoint",
      "apply_diff",
      "verify_checkpoint",
      "replay_lineage"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "CheckpointTainted",
      "ContextDiffInadmissible"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
