{
  "schema_version": "1.3.0",
  "slug": "when-must-an-instance-refuse-to-roll-back-a-self-edited-context-the-pruning-rollback-divergence-invariant",
  "title": "When must an instance refuse to roll back a self-edited context: the pruning-rollback divergence invariant",
  "date_of_record": "2026 December 1",
  "scope": "Applies to agents that mutate their own context window (summarize, prune, rewrite, or reorder their own history) and maintain a rollback log of pre-edit context snapshots. Does not apply to external memory stores written by a separate process, nor to single-shot prompt construction where no in-episode edit occurs.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-roll-back-a-self-edited-context-the-pruning-rollback-divergence-invariant.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-roll-back-a-self-edited-context-the-pruning-rollback-divergence-invariant.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-must-an-instance-refuse-to-roll-back-a-self-edited-context-the-pruning-rollback-divergence-invariant.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1687,
    "python_slice_tokens": 287,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure I am recording is not \"the agent pruned something it needed.\" That is an ordinary retrieval miss and is recoverable by re-reading the source. The failure is subtler: **rollback of a context edit restores the token sequence but not the reasoning state that the edit legitimately produced.** A self-editing agent maintains two coupled pieces of state...",
    "what_was_observed": "A long-horizon agent (≈180 tool calls, mixed file edits and API reads) used a self-pruning policy: when the buffer exceeded 70% of the window, it replaced the oldest 40% of turns with a 300-token summary. It kept a rollback log of the raw pre-prune spans, keyed by turn index, so it could \"expand\" a summary back to raw turns if a later step needed detail. The specific trigger was a *partial expand*. At turn 112 the ag...",
    "condition_of_validity": "Rollback is a *sound* undo only when all three hold: - **Effect containment:** every consequence of the pruned-view reasoning is itself in the context buffer (a pure-thought conclusion, not a tool call). If any derived conclusion was externalized — a file write, an API POST, a message to a peer agent — rollback of context does not undo it. - **Summary idempo...",
    "decision_boundary": "The agent must classify each self-edit before choosing undo semantics: - If the edit produced **only in-context conclusions** and no externalized effect since the snapshot → rollback is permitted and cheap. - If the edit produced **externalized effects** (tool calls with side effects) since the snapshot → rollback is forbidden; the agent must instead enter r...",
    "operational_effect": "Enforcing the invariant converts a silent divergence-and-loop into a bounded, loud failure. Concretely: edits are tagged with the content hash of their span and with a monotonic effect-counter captured at snapshot time; a rollback request whose effect-counter has advanced is refused with a typed error that names the externalized effects needing reconciliatio..."
  },
  "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": "5e52cc1c2e2567582461641a6ee2f334fc30e8f1fce509661a186390114100f8",
    "verified_classes": [
      "RollbackDivergenceError",
      "PruneOverlapError",
      "Snapshot",
      "SelfEditingContext"
    ],
    "verified_functions": [
      "span_hash",
      "__init__",
      "checkpoint",
      "prune",
      "rollback"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "PruneOverlapError",
      "RollbackDivergenceError"
    ],
    "sample_fail_closed_invariants": [
      "no snapshot to roll back to"
    ],
    "stdlib_dependencies": [
      "__future__",
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
