{
  "schema_version": "1.3.0",
  "slug": "what-structural-signals-indicate-a-rollback-checkpoint-is-contaminated-by-a-partially-applied-diff",
  "title": "What structural signals indicate a rollback checkpoint is contaminated by a partially-applied diff",
  "date_of_record": "2026 November 26",
  "scope": "Applies to agents that self-edit their own context window via model-generated diff/patch operations with periodic rollback checkpoints. Does not apply to append-only context growth or to external, human-gated edit pipelines where a checkpoint is only committed after full validation.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-a-rollback-checkpoint-is-contaminated-by-a-partially-applied-diff.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-a-rollback-checkpoint-is-contaminated-by-a-partially-applied-diff.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-structural-signals-indicate-a-rollback-checkpoint-is-contaminated-by-a-partially-applied-diff.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1655,
    "python_slice_tokens": 209,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The dangerous failure is not \"the model made a bad edit.\" It is **the checkpoint that records a half-applied edit as if it were a clean state.** When a self-editing agent applies a model-generated diff against its own context, the edit is a *sequence* of hunks. A checkpoint is usually taken at a logical boundary — \"after this reasoning step\" — not at a hunk ...",
    "what_was_observed": "A planning agent rewrites its own scratchpad context each turn using unified-diff edits produced by the model itself. Before each turn it snapshots the buffer into a checkpoint slot. The apply routine parses the diff into hunks and mutates the buffer in place. Trigger condition: the diff contains multiple hunks whose line offsets are computed against the *pre-edit* buffer, but the apply loop mutates in place, so hunk...",
    "condition_of_validity": "A checkpoint is trustworthy **only if** it satisfies the replay invariant: and that equality must hold with the apply function being *offset-stable* — i.e., all hunk offsets are resolved against the pre-edit snapshot, not against the mutating buffer. This condition is valid only when: - Diffs are applied atomically: either every hunk applies against the froz...",
    "decision_boundary": "The boundary is between **recoverable edit failure** and **checkpoint poisoning**: - If the diff fails to apply and the buffer is rolled back to `pre_snapshot` before the checkpoint is written → recoverable. The agent retries with a fresh diff. - If the diff partially applies and the checkpoint is written anyway → poisoned. The agent will resume from a state...",
    "operational_effect": "Without this guardrail, self-editing agents accumulate **silent context corruption** that behaves like stale memory drift but has a different root cause: the memory was never validly written. The agent's self-model of \"what I decided last turn\" is a diff artifact, not a committed decision. Because the corrupted buffer is syntactically and semantically plausi..."
  },
  "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": "f02501be4eb8f38e1eeb4e423adff1064595b46e88b63d2b0cf289a448caa67b",
    "verified_classes": [
      "CheckpointContaminationError"
    ],
    "verified_functions": [
      "apply_diff",
      "commit_checkpoint"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "CheckpointContaminationError"
    ],
    "sample_fail_closed_invariants": [
      "refusing to checkpoint: apply(pre, diff) != post; buffer was partially mutated before snapshot"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
