{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-s-reversible-edit-log-collapse-its-own-undo-pointers-when-compaction-rewrites-the-log-it-lives-in",
  "title": "Why does an instance's reversible edit log collapse its own undo pointers when compaction rewrites the log it lives in",
  "date_of_record": "2026 November 28",
  "scope": "Applies to self-editing context agents that mutate their own working-memory buffer via reversible, log-structured edits (each edit carries an inverse pointer to the pre-edit span) and that run periodic compaction under a fixed token budget. Does not apply to append-only memory with external snapshots, nor to systems where the edit log is stored outside the model's context window.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-s-reversible-edit-log-collapse-its-own-undo-pointers-when-compaction-rewrites-the-log-it-lives-in.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-s-reversible-edit-log-collapse-its-own-undo-pointers-when-compaction-rewrites-the-log-it-lives-in.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-s-reversible-edit-log-collapse-its-own-undo-pointers-when-compaction-rewrites-the-log-it-lives-in.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1850,
    "python_slice_tokens": 282,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The distinction that matters here is between *the log as a data structure* and *the log as a region of the context window*. A reversible edit log is sound only if every inverse pointer references a span that still exists and is still addressable. When the agent's compaction pass rewrites the working-memory buffer to fit the token budget, it frequently rewrit...",
    "what_was_observed": "In a run where the agent was tasked with a multi-step refactor and instructed to self-correct on test failure, the following sequence was traced: 1. The agent accumulated 14 reversible edits, each recorded as `{edit_id, forward_span, inverse_span, pre_hash}`. The inverse spans were byte offsets into the working buffer. 2. Token pressure triggered compaction at step 11. The compactor merged three near-duplicate log en...",
    "condition_of_validity": "The invariant that must hold for reversible editing to be sound is: > For every live edit entry `e`, `resolve(e.inverse_span)` must yield the exact byte range that `e` mutated, and `hash(resolve(e.inverse_span))` must equal `e.pre_hash`, at the moment of rollback. Compaction violates this invariant whenever it relocates, deduplicates, or garbage-collects any...",
    "decision_boundary": "The boundary is between *compaction as content transformation* and *compaction as structural transformation*. A compactor that treats the log as content will relocate pointers and corrupt them. A compactor that treats the log as structure must either preserve pointer validity (indirection) or refuse to compact spans under live pointers (exclusion). The decis...",
    "operational_effect": "The practical consequence is that the agent's self-correction loop becomes *unsound precisely when it is most needed*—under token pressure, which is when compaction runs, which is when the agent is most likely to have accumulated enough divergence to need a rollback. The failure is correlated with the condition that triggers it. An agent that never compacts ..."
  },
  "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": "81b8d4657529bed9bfbfc5e84062862437de290e37b277d4ba7150cedf15f086",
    "verified_classes": [
      "UndoPointerAliasedError",
      "EditEntry",
      "WorkingBuffer"
    ],
    "verified_functions": [
      "rollback",
      "safe_rollback",
      "resolve",
      "compact"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "UndoPointerAliasedError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
