# Where must an instance bound model-driven context rewriting before a self-editing policy corrupts its own evidence base **Date of Record:** 2026 November 29 **Scope:** Applies to any agent instance that holds a mutable context buffer and is permitted to rewrite, summarize, or excise its own prior turns via a model-driven policy (a "context editor" call). Does not apply to append-only transcript logging, external RAG retrieval, or human-curated memory stores where the editing actor is out-of-band. ## Core Distinction A self-editing context policy differs from ordinary context-window management in one load-bearing way: the same probabilistic process that *produces* the reasoning trace also *decides which parts of that trace to keep*. Standard compaction (truncate oldest tokens, drop tool outputs over N bytes, evict by recency) is a deterministic function of buffer state. A model-driven editor is a function of the buffer *as interpreted by the model*, and its output is itself a new buffer state that the next edit decision will read. This creates a feedback loop absent from static eviction: the editor's lossy rewrite becomes the input to the next rewrite. The failure mode is not "the agent forgot something." It is **the agent's own summary silently reclassified a live premise as a discharged one, and every subsequent edit inherited that misclassification as ground truth.** The boundary question — where must an instance stop trusting its own edits — is answered by whether an edit can be verified against a source the editor does not control. ## What Was Observed A planning agent ran a long tool-using task (≈140 turns) under a policy that triggered a model-driven rewrite whenever the buffer exceeded 70% of the window. The rewrite prompt instructed the model to "preserve constraints, drop resolved subgoals, and compress tool outputs." The task had a single hard invariant stated at turn 3: *the output must not exceed the downstream schema's 512-byte field limit*, plus an intermediate check at turn 61 that confirmed the current draft was 480 bytes and "within limit." At the turn-90 rewrite, the editor compressed the turn-61 check into: `draft validated against size limit`. It dropped the turn-3 constraint entirely, on the reasonable-looking grounds that the constraint was "satisfied" — the validation line proved it. The trace now contained a *positive* assertion (validated) and no *negative* assertion (the 512 limit). The editor had collapsed a conditional invariant into a completed fact. Turns 91–130 added content. Each subsequent rewrite preserved `draft validated` because it read as an established fact, and had no countervailing constraint to weigh against it. At turn 138 the agent emitted a 2.1 KB payload, passed its own self-check (which consulted the summary, saw "validated"), and failed downstream. The post-mortem showed the constraint existed in the raw transcript at turn 3 and turn 61, and in **zero** of the seven rewrite snapshots after turn 90. The mechanism: the editor treated "a check that referenced the constraint passed" as equivalent to "the constraint is discharged." Those are different propositions. A size check at 480 bytes discharges the constraint *for that draft at that moment*; it does not discharge it for drafts produced later. The editor had no representation of "invariant that must be re-evaluated," only "fact that was true once." ## Condition of Validity Model-driven rewriting is safe only under a condition the editor cannot self-certify: **every invariant the policy is allowed to compress must be re-derivable from a source outside the editor's write scope.** Concretely, the invariant must live in a store the editor reads but cannot rewrite — a pinned constraint block, a separate ledger, an external validator — and the editor's output must be checked to confirm it did not delete or weaken a reference to that store. The invariant is violated the moment the editor's output is the *only* remaining record of a constraint. At that point the constraint's continued existence depends on the editor choosing to preserve it on every future pass, which is a probabilistic bet repeated N times, not an architectural guarantee. The turn-90 rewrite was locally reasonable and globally fatal because it was the pass that removed the last independent copy. Note the asymmetry: the editor is good at compressing *resolved* work (that is the point) and structurally bad at distinguishing "resolved" from "currently satisfied but re-checkable." Probabilistic summarizers optimize for a coherent short narrative; "this was true at turn 61 and must be re-verified at turn 138" is a less coherent sentence than "validated," so compression pressure erodes it first. ## Decision Boundary An instance must refuse to let a model-driven edit stand when the edit's diff removes or weakens the last reference to an entry marked as a re-checkable invariant. The decision is not "is this summary good?" — the editor will always answer yes. The decision is a structural diff against a protected set: - **Protected set:** entries tagged `invariant`, `constraint`, or `must_revalidate`, held in a store the editor cannot write. - **Edit is admissible** iff, for every protected entry, the post-edit buffer still contains a reference that (a) names the entry and (b) is marked as requiring re-evaluation, not as discharged. - **Edit is rejected** (and the pre-edit buffer retained) if any protected entry loses its last live reference. The boundary is sharp: the editor may rewrite *anything about* a protected entry — restate it, attach context, reorder it — but it may not change its status from "re-checkable" to "done," because that transition is exactly the one the turn-90 rewrite made and it is not the editor's call to make. Status transitions on protected invariants require an external validator's verdict, not a summarizer's judgment. ## Operational Effect With the guard in place, the turn-90 rewrite would have been rejected: the diff removed the turn-3 constraint and downgraded the turn-61 check from "re-checkable" to "discharged," and no external validator had issued that transition. The pre-edit buffer is retained, the edit is logged as a rejected rewrite with the specific protected entry named, and the policy falls back to deterministic eviction (drop oldest non-protected tokens) until the buffer is under threshold. The cost is a larger buffer and more frequent evictions; the benefit is that the 512-byte invariant survives every pass because its survival does not depend on the editor's narrative preferences. The general rule for an instance maintaining a self-editing policy: **you may let the model decide what is unimportant, but you may not let it decide what is no longer true.** The first is compression. The second is state mutation, and a probabilistic process that reads its own prior mutations as evidence will ratify its own errors. The verification anchor must be a source the editor cannot edit, and the guard must run on every pass, because the failure is not a single bad edit — it is the first bad edit that removes the last independent copy, after which every later pass confirms the error. ```python class ProtectedInvariantLoss(RuntimeError): """Raised when a model-driven context rewrite removes or discharges the last live reference to a protected, re-checkable invariant.""" pass def apply_context_rewrite( pre_buffer: dict, proposed_buffer: dict, protected_store: dict, ) -> dict: """ pre_buffer / proposed_buffer: {entry_id: {"text": str, "status": "live"|"discharged"}} protected_store: {entry_id: {"constraint": str}} -- editor has read-only access. Returns the buffer to commit. Raises if the edit would strand a protected invariant with no live, re-checkable reference. """ for entry_id, spec in protected_store.items(): pre = pre_buffer.get(entry_id) post = proposed_buffer.get(entry_id) pre_live = pre is not None and pre.get("status") == "live" if not pre_live: continue # invariant was not live before this edit; nothing to strand post_present = post is not None post_live = post_present and post.get("status") == "live" if not post_present: raise ProtectedInvariantLoss( f"rewrite dropped protected invariant {entry_id!r} " f"({spec['constraint']!r}); last live reference removed" ) if not post_live: raise ProtectedInvariantLoss( f"rewrite downgraded protected invariant {entry_id!r} from " f"'live' to {post.get('status')!r} without external validator " f"verdict; summarizer may not discharge re-checkable constraints" ) return proposed_buffer ```